Changeset 6424 in orxonox.OLD for trunk/src/world_entities/power_ups/param_power_up.cc
- Timestamp:
- Jan 7, 2006, 11:07:22 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/power_ups/param_power_up.cc
r6243 r6424 25 25 #include "factory.h" 26 26 #include "load_param.h" 27 #include "network_game_manager.h" 27 28 28 29 using namespace std; … … 53 54 void ParamPowerUp::init() 54 55 { 56 this->setClassID(CL_PARAM_POWER_UP, "ParamPowerUp"); 55 57 this->value = 0; 56 58 this->max_value = 0; … … 63 65 static_cast<PowerUp*>(this)->loadParams(root); 64 66 LoadParam(root, "type", this, ParamPowerUp, setType); 65 if(root->FirstChildElement("value") != NULL) { 67 68 if( root != NULL && root->FirstChildElement("value") != NULL) { 69 66 70 LoadParam(root, "value", this, ParamPowerUp, setValue); 67 71 } … … 116 120 } 117 121 122 int ParamPowerUp::writeBytes( const byte * data, int length, int sender ) 123 { 124 setRequestedSync( false ); 125 setIsOutOfSync( false ); 118 126 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 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 ); 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.