Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6341 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Dec 30, 2005, 1:57:12 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

Location:
trunk/src/world_entities
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/npc.cc

    r6222 r6341  
    6262      this->collider = entity;
    6363  }
    64   else if (entity->isA(CL_PLAYER))
    65     this->applyForce(Vector(0,0,0)-location*100);
     64  //  else if (entity->isA(CL_PLAYER))
     65  //    this->applyForce(Vector(0,0,0)-location*100);
    6666  else if (entity->isA(CL_NPC))
    6767  {
  • trunk/src/world_entities/npcs/npc.h

    r6004 r6341  
    88class AI;
    99
    10 class NPC : public WorldEntity, public PhysicsInterface {
     10class NPC : public WorldEntity {
    1111
    1212 public:
  • trunk/src/world_entities/skybox.cc

    r6307 r6341  
    2222#include "static_model.h"
    2323#include "material.h"
     24#include "network_game_manager.h"
     25#include "converter.h"
    2426
    2527using namespace std;
     
    7779    }
    7880  this->setParentMode(PNODE_MOVEMENT);
     81
     82  this->textureName = NULL;
    7983}
    8084
     
    208212  this->setModel(model);
    209213}
     214
     215int SkyBox::writeBytes( const byte * data, int length, int sender )
     216{
     217  setRequestedSync( false );
     218  setIsOutOfSync( false );
     219
     220  SYNCHELP_READ_BEGIN();
     221
     222  SYNCHELP_READ_FKT( WorldEntity::writeState );
     223
     224  SYNCHELP_READ_FLOAT( size );
     225  if ( textureName )
     226  {
     227    delete[] textureName;
     228    textureName = NULL;
     229  }
     230  SYNCHELP_READ_STRINGM( textureName );
     231
     232  PRINT(0)("GOT DATA: size=%f texture='%s'\n", size, textureName);
     233
     234  this->setSize( size );
     235  this->setTextureAndType( textureName, "jpg" );
     236  this->rebuild();
     237
     238  return SYNCHELP_READ_N;
     239}
     240
     241
     242
     243int SkyBox::readBytes( byte * data, int maxLength, int * reciever )
     244{
     245  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     246  {
     247    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     248    setRequestedSync( true );
     249  }
     250
     251  int rec = this->getRequestSync();
     252  if ( rec > 0 )
     253  {
     254    PRINT(0)("SEND DATA: size=%f texture='%s'\n", size, textureName);
     255    *reciever = rec;
     256
     257    SYNCHELP_WRITE_BEGIN();
     258
     259    SYNCHELP_WRITE_FKT( WorldEntity::readState );
     260
     261    SYNCHELP_WRITE_FLOAT(this->size);
     262    SYNCHELP_WRITE_STRING(this->textureName);
     263
     264    return SYNCHELP_WRITE_N;
     265  }
     266
     267  *reciever = 0;
     268  return 0;
     269}
     270
     271void SkyBox::writeDebug( ) const
     272{
     273}
     274
     275void SkyBox::readDebug( ) const
     276{
     277}
  • trunk/src/world_entities/skybox.h

    r6307 r6341  
    3535  void setSize(float size);
    3636  /** assumes jpg as input-format */
    37   void setTexture(const char* name) { this->setTextureAndType (name, "jpg"); };
     37  void setTexture(const char* name) { if (textureName) delete[] textureName; textureName = new char[strlen(name)+1]; strcpy(textureName, name); this->setTextureAndType (name, "jpg"); };
    3838
    3939  void setTextureAndType(const char* name, const char* extension);
    4040  void setTextures(const char* top, const char* bottom, const char* left,
    4141                   const char* right, const char* front, const char* back);
     42
     43  virtual int       writeBytes(const byte* data, int length, int sender);
     44  virtual int       readBytes(byte* data, int maxLength, int * reciever);
     45  virtual void      writeDebug() const;
     46  virtual void      readDebug() const;
    4247
    4348 private:
     
    4651  Material*       material[6];     //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back
    4752  float           size;            //!< Size of the SkyBox. This should match the frustum maximum range.
     53  char*           textureName;     //!< Name of the Texture
    4854
    4955};
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6306 r6341  
    121121  PRINTF(4)("SPACESHIP INIT\n");
    122122
    123   EventHandler::getInstance()->grabEvents(true);
     123  //  EventHandler::getInstance()->grabEvents(true);
    124124
    125125  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
  • trunk/src/world_entities/terrain.cc

    r6142 r6341  
    2424#include "resource_manager.h"
    2525#include "model.h"
     26#include "network_game_manager.h"
     27
    2628
    2729#include "glincl.h"
     
    111113void Terrain::loadVegetation(const char* vegetationFile)
    112114{
     115  PRINTF(0)("loadVegetation: %s\n", vegetationFile);
    113116  if (this->vegetation)
    114117    ResourceManager::getInstance()->unload(this->vegetation, RP_LEVEL);
     
    116119  {
    117120    PRINTF(4)("fetching %s\n", vegetationFile);
    118       this->vegetation = (Model*)ResourceManager::getInstance()->load(vegetationFile, OBJ, RP_CAMPAIGN);
     121    this->vegetation = (Model*)ResourceManager::getInstance()->load(vegetationFile, OBJ, RP_CAMPAIGN);
    119122  }
    120123  else
     
    315318    }
    316319}
     320
     321int Terrain::writeBytes( const byte * data, int length, int sender )
     322{
     323  setRequestedSync( false );
     324  setIsOutOfSync( false );
     325
     326  SYNCHELP_READ_BEGIN();
     327  SYNCHELP_READ_FKT( WorldEntity::writeState );
     328
     329  return SYNCHELP_READ_N;
     330}
     331
     332int Terrain::readBytes( byte * data, int maxLength, int * reciever )
     333{
     334  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     335  {
     336    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     337    setRequestedSync( true );
     338  }
     339
     340  int rec = this->getRequestSync();
     341  if ( rec > 0 )
     342  {
     343    *reciever = rec;
     344
     345    return WorldEntity::readState( data, maxLength );
     346
     347  }
     348
     349  *reciever = 0;
     350  return 0;
     351}
     352
     353void Terrain::writeDebug( ) const
     354{
     355}
     356
     357void Terrain::readDebug( ) const
     358{
     359}
  • trunk/src/world_entities/terrain.h

    r5500 r6341  
    3030  virtual ~Terrain();
    3131
     32  virtual int       writeBytes(const byte* data, int length, int sender);
     33  virtual int       readBytes(byte* data, int maxLength, int * reciever);
     34  virtual void      writeDebug() const;
     35  virtual void      readDebug() const;
     36
    3237  void init();
    3338  void loadParams(const TiXmlElement* root);
     
    4449   Model*              vegetation;
    4550   int                 objectList;
     51
    4652};
    4753
  • trunk/src/world_entities/weapons/ground_turret.cc

    r6142 r6341  
    1919
    2020#include "factory.h"
     21#include "network_game_manager.h"
    2122#include "load_param.h"
    2223
     
    168169
    169170}
     171
     172/**
     173 * Writes data from network containing information about the state
     174 * @param data pointer to data
     175 * @param length length of data
     176 * @param sender hostID of sender
     177 */
     178int GroundTurret::writeBytes( const byte * data, int length, int sender )
     179{
     180  setRequestedSync( false );
     181  setIsOutOfSync( false );
     182
     183  SYNCHELP_READ_BEGIN();
     184
     185  SYNCHELP_READ_FKT( WorldEntity::writeState );
     186
     187  return SYNCHELP_READ_N;
     188}
     189
     190/**
     191 * data copied in data will bee sent to another host
     192 * @param data pointer to data
     193 * @param maxLength max length of data
     194 * @return the number of bytes writen
     195 */
     196int GroundTurret::readBytes( byte * data, int maxLength, int * reciever )
     197{
     198  SYNCHELP_WRITE_BEGIN();
     199
     200  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     201  {
     202    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     203    setRequestedSync( true );
     204  }
     205
     206  int rec = this->getRequestSync();
     207  if ( rec > 0 )
     208  {
     209    *reciever = rec;
     210
     211    SYNCHELP_WRITE_FKT( WorldEntity::readState );
     212
     213  }
     214
     215  *reciever = 0;
     216  return SYNCHELP_WRITE_N;
     217}
  • trunk/src/world_entities/weapons/ground_turret.h

    r5819 r6341  
    3030  virtual void collidesWith (WorldEntity* entity, const Vector& location);
    3131
     32  virtual int writeBytes(const byte* data, int length, int sender);
     33  virtual int readBytes(byte* data, int maxLength, int * reciever);
     34
    3235 private:
    3336   Weapon *left, *right;
  • trunk/src/world_entities/world_entity.cc

    r6281 r6341  
    105105void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber)
    106106{
    107   if (fileName != NULL)
     107  if ( fileName != NULL && strcmp(fileName, "") )
    108108  {
    109109   // search for the special character # in the LoadParam
     
    144144  }
    145145  else
     146  {
    146147    this->setModel(NULL);
     148  }
    147149}
    148150
     
    340342  glPopMatrix();
    341343}
     344
     345/**
     346 * Writes data from network containing information about the state
     347 * @param data pointer to data
     348 * @param length length of data
     349 * @param sender hostID of sender
     350 */
     351int WorldEntity::writeState( const byte * data, int length, int sender )
     352{
     353  char* modelFileName;
     354  SYNCHELP_READ_BEGIN();
     355
     356  SYNCHELP_READ_FKT( PNode::writeState );
     357
     358  SYNCHELP_READ_STRINGM( modelFileName );
     359  SYNCHELP_READ_FLOAT( scaling );
     360  //check if modelFileName is relative to datadir or absolute
     361  if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) )
     362  {
     363    loadModel( modelFileName+strlen(ResourceManager::getInstance()->getDataDir()), scaling );
     364  }
     365  else
     366  {
     367    loadModel( modelFileName, scaling );
     368  }
     369  delete[] modelFileName;
     370
     371  return SYNCHELP_READ_N;
     372}
     373
     374/**
     375 * data copied in data will bee sent to another host
     376 * @param data pointer to data
     377 * @param maxLength max length of data
     378 * @return the number of bytes writen
     379 */
     380int WorldEntity::readState( byte * data, int maxLength )
     381{
     382  SYNCHELP_WRITE_BEGIN();
     383
     384  SYNCHELP_WRITE_FKT( PNode::readState );
     385
     386  SYNCHELP_WRITE_STRING( getModel( 0 )->getName() );
     387  SYNCHELP_WRITE_FLOAT( scaling );
     388  return SYNCHELP_WRITE_N;
     389}
  • trunk/src/world_entities/world_entity.h

    r6281 r6341  
    7474  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
    7575
     76  int       writeState(const byte* data, int length, int sender);
     77  int       readState(byte* data, int maxLength );
    7678
    7779 protected:
    7880  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
     81
    7982
    8083 private:
     
    8992  std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
    9093
     94  float                   scaling;
     95
     96
    9197};
    9298
Note: See TracChangeset for help on using the changeset viewer.