Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7954 in orxonox.OLD for trunk/src/world_entities/power_ups


Ignore:
Timestamp:
May 29, 2006, 3:28:41 PM (18 years ago)
Author:
patrick
Message:

trunk: merged the network branche back to trunk.

Location:
trunk/src/world_entities/power_ups
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/power_ups/laser_power_up.cc

    r7193 r7954  
    120120}
    121121
    122 int LaserPowerUp::writeBytes( const byte * data, int length, int sender )
    123 {
    124   setRequestedSync( false );
    125   setIsOutOfSync( false );
    126122
    127   SYNCHELP_READ_BEGIN();
    128 
    129   SYNCHELP_READ_FKT( PowerUp::writeState, NWT_LPU_WE_STATE );
    130 
    131   return SYNCHELP_READ_N;
    132 }
    133 
    134 
    135 
    136 int LaserPowerUp::readBytes( byte * data, int maxLength, int * reciever )
    137 {
    138   if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
    139   {
    140     (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
    141     setRequestedSync( true );
    142   }
    143 
    144   int rec = this->getRequestSync();
    145   if ( rec > 0 )
    146   {
    147     *reciever = rec;
    148 
    149     SYNCHELP_WRITE_BEGIN();
    150 
    151     SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_LPU_WE_STATE );
    152 
    153     return SYNCHELP_WRITE_N;
    154   }
    155 
    156   *reciever = 0;
    157   return 0;
    158 }
    159 
  • trunk/src/world_entities/power_ups/laser_power_up.h

    r6512 r7954  
    2626  virtual void draw() const;
    2727
    28   virtual int writeBytes(const byte* data, int length, int sender);
    29   virtual int readBytes(byte* data, int maxLength, int * reciever );
    30 
    3128  private:
    3229   void init();
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r7221 r7954  
    4343  if( root != NULL)
    4444    this->loadParams(root);
     45 
     46  registerVar( new SynchronizeableInt( (int*)&type, (int*)&type, "type" ) );
     47  registerVar( new SynchronizeableFloat( &value, &value, "value" ) );
     48  registerVar( new SynchronizeableFloat( &max_value, &max_value, "max_value" ) );
     49  registerVar( new SynchronizeableFloat( &min_value, &min_value, "min_value" ) );
    4550}
    4651
     
    119124}
    120125
    121 int ParamPowerUp::writeBytes( const byte * data, int length, int sender )
    122 {
    123   setRequestedSync( false );
    124   setIsOutOfSync( false );
    125 
    126   SYNCHELP_READ_BEGIN();
    127 
    128   SYNCHELP_READ_FKT( PowerUp::writeState, NWT_PPU_WE_STATE );
    129 
    130   int i;
    131   SYNCHELP_READ_INT( i, NWT_PPU_TYPE );
    132   this->type = (EnumParamPowerUpType)i;
    133   SYNCHELP_READ_FLOAT( this->value, NWT_PPU_VALUE );
    134 
    135   if ( this->value != 0 )
    136   {
    137     SYNCHELP_READ_FLOAT( this->min_value, NWT_PPU_MINVALUE );
    138     SYNCHELP_READ_FLOAT( this->max_value, NWT_PPU_MAXVALUE );
    139     respawn();
    140   }
    141 
    142   return SYNCHELP_READ_N;
    143 }
    144 
    145 
    146 
    147 int ParamPowerUp::readBytes( byte * data, int maxLength, int * reciever )
    148 {
    149   if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
    150   {
    151     (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
    152     setRequestedSync( true );
    153   }
    154 
    155   int rec = this->getRequestSync();
    156   if ( rec > 0 )
    157   {
    158     *reciever = rec;
    159 
    160     SYNCHELP_WRITE_BEGIN();
    161 
    162     SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_PPU_WE_STATE );
    163 
    164     int i = (int)this->type;
    165     SYNCHELP_WRITE_INT( i, NWT_PPU_TYPE );
    166     SYNCHELP_WRITE_FLOAT( this->value, NWT_PPU_VALUE );
    167 
    168     if ( this->value != 0 )
    169     {
    170       SYNCHELP_WRITE_FLOAT( this->min_value, NWT_PPU_MINVALUE );
    171       SYNCHELP_WRITE_FLOAT( this->max_value, NWT_PPU_MAXVALUE );
    172     }
    173 
    174     return SYNCHELP_WRITE_N;
    175   }
    176 
    177   *reciever = 0;
    178   return 0;
    179 }
    180 
  • trunk/src/world_entities/power_ups/param_power_up.h

    r7221 r7954  
    3232  float getValue();
    3333
    34   virtual int writeBytes(const byte* data, int length, int sender);
    35   virtual int readBytes(byte* data, int maxLength, int * reciever );
    36 
    3734protected:
    3835  virtual void respawn();
  • trunk/src/world_entities/power_ups/power_up.cc

    r7460 r7954  
    201201
    202202
    203 /********************************************************************************************
    204  NETWORK STUFF
    205  ********************************************************************************************/
    206 
    207 
    208 /**
    209  * data copied in data will bee sent to another host
    210  * @param data pointer to data
    211  * @param maxLength max length of data
    212  * @return the number of bytes writen
    213  */
    214 int PowerUp::readState( byte * data, int maxLength )
    215 {
    216   SYNCHELP_WRITE_BEGIN();
    217   SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_PU_WE_STATE );
    218   return SYNCHELP_WRITE_N;
    219 }
    220 
    221 
    222 /**
    223  * Writes data from network containing information about the state
    224  * @param data pointer to data
    225  * @param length length of data
    226  * @param sender hostID of sender
    227  */
    228 int PowerUp::writeState( const byte * data, int length, int sender )
    229 {
    230   SYNCHELP_READ_BEGIN();
    231   SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_PU_WE_STATE );
    232   return SYNCHELP_READ_N;
    233 }
    234 
  • trunk/src/world_entities/power_ups/power_up.h

    r7460 r7954  
    3434  void setRespawnTime(const float respawn);
    3535
    36   int       writeState(const byte* data, int length, int sender);
    37   int       readState(byte* data, int maxLength );
    38 
    3936protected:
    4037  PowerUp(float r, float g, float b);
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r7193 r7954  
    115115  glPopMatrix();
    116116}
    117 
    118 
    119 
    120 
    121 /********************************************************************************************
    122  NETWORK STUFF
    123  ********************************************************************************************/
    124 
    125 
    126 int TurretPowerUp::writeBytes( const byte * data, int length, int sender )
    127 {
    128   setRequestedSync( false );
    129   setIsOutOfSync( false );
    130 
    131   SYNCHELP_READ_BEGIN();
    132 
    133   SYNCHELP_READ_FKT( PowerUp::writeState, NWT_TPU_WE_STATE );
    134 
    135   return SYNCHELP_READ_N;
    136 }
    137 
    138 
    139 int TurretPowerUp::readBytes( byte * data, int maxLength, int * reciever )
    140 {
    141   if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
    142   {
    143     (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
    144     setRequestedSync( true );
    145   }
    146 
    147   int rec = this->getRequestSync();
    148   if ( rec > 0 )
    149   {
    150     *reciever = rec;
    151 
    152     SYNCHELP_WRITE_BEGIN();
    153 
    154     SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_TPU_WE_STATE );
    155 
    156     return SYNCHELP_WRITE_N;
    157   }
    158 
    159   *reciever = 0;
    160   return 0;
    161 }
  • trunk/src/world_entities/power_ups/turret_power_up.h

    r7065 r7954  
    2424  virtual void draw() const;
    2525
    26   virtual int writeBytes(const byte* data, int length, int sender);
    27   virtual int readBytes(byte* data, int maxLength, int * reciever );
    28 
    2926  private:
    3027   void init();
  • trunk/src/world_entities/power_ups/weapon_power_up.cc

    r7370 r7954  
    103103}
    104104
    105 int WeaponPowerUp::writeBytes( const byte * data, int length, int sender )
    106 {
    107   setRequestedSync( false );
    108   setIsOutOfSync( false );
    109 
    110   SYNCHELP_READ_BEGIN();
    111 
    112   SYNCHELP_READ_FKT( PowerUp::writeState, NWT_WPU_WE_STATE );
    113 
    114   //TODO: sync weapon class ( see loadParams )
    115 
    116   return SYNCHELP_READ_N;
    117 }
    118 
    119 
    120 
    121 int WeaponPowerUp::readBytes( byte * data, int maxLength, int * reciever )
    122 {
    123   if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
    124   {
    125     (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
    126     setRequestedSync( true );
    127   }
    128 
    129   int rec = this->getRequestSync();
    130   if ( rec > 0 )
    131   {
    132     *reciever = rec;
    133 
    134     SYNCHELP_WRITE_BEGIN();
    135 
    136     SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_WPU_WE_STATE );
    137 
    138     //TODO: sync weapon class ( see loadParams )
    139 
    140     return SYNCHELP_WRITE_N;
    141   }
    142 
    143   *reciever = 0;
    144   return 0;
    145 }
  • trunk/src/world_entities/power_ups/weapon_power_up.h

    r7221 r7954  
    2424  void setWeaponClass(const std::string& name);
    2525
    26   virtual int writeBytes(const byte* data, int length, int sender);
    27   virtual int readBytes(byte* data, int maxLength, int * reciever );
    28 
    2926  bool process(WeaponManager* manager);
    3027
Note: See TracChangeset for help on using the changeset viewer.