Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 7, 2006, 11:07:22 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the branche network back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r 6351:HEAD
no conflicts

File:
1 edited

Legend:

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

    r6243 r6424  
    2525#include "factory.h"
    2626#include "load_param.h"
     27#include "network_game_manager.h"
    2728
    2829using namespace std;
     
    5354void ParamPowerUp::init()
    5455{
     56  this->setClassID(CL_PARAM_POWER_UP, "ParamPowerUp");
    5557  this->value = 0;
    5658  this->max_value = 0;
     
    6365  static_cast<PowerUp*>(this)->loadParams(root);
    6466  LoadParam(root, "type", this, ParamPowerUp, setType);
    65   if(root->FirstChildElement("value") != NULL) {
     67
     68  if( root != NULL && root->FirstChildElement("value") != NULL) {
     69
    6670    LoadParam(root, "value", this, ParamPowerUp, setValue);
    6771  }
     
    116120}
    117121
     122int ParamPowerUp::writeBytes( const byte * data, int length, int sender )
     123{
     124  setRequestedSync( false );
     125  setIsOutOfSync( false );
    118126
     127  SYNCHELP_READ_BEGIN();
     128
     129  SYNCHELP_READ_FKT( PowerUp::writeState );
     130
     131  int i;
     132  SYNCHELP_READ_INT( i );
     133  this->type = (EnumParamPowerUpType)i;
     134  SYNCHELP_READ_INT( this->value );
     135
     136  if ( this->value != 0 )
     137  {
     138    SYNCHELP_READ_INT( this->min_value );
     139    SYNCHELP_READ_INT( this->max_value );
     140  }
     141
     142  return SYNCHELP_READ_N;
     143}
     144
     145
     146
     147int 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 );
     163
     164    int i = this->type;
     165    SYNCHELP_WRITE_INT( i );
     166    SYNCHELP_WRITE_INT( this->value );
     167
     168    if ( this->value != 0 )
     169    {
     170      SYNCHELP_WRITE_INT( this->min_value );
     171      SYNCHELP_WRITE_INT( this->max_value );
     172    }
     173
     174    return SYNCHELP_WRITE_N;
     175  }
     176
     177  *reciever = 0;
     178  return 0;
     179}
     180
Note: See TracChangeset for help on using the changeset viewer.