Changeset 6424 in orxonox.OLD for trunk/src/world_entities/power_ups
- Timestamp:
- Jan 7, 2006, 11:07:22 PM (19 years ago)
- Location:
- trunk/src/world_entities/power_ups
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/power_ups/laser_power_up.cc
r6222 r6424 19 19 #include "factory.h" 20 20 #include "state.h" 21 #include "network_game_manager.h" 21 22 22 23 #include "primitive_model.h" … … 118 119 } 119 120 121 int LaserPowerUp::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 ); 129 130 return SYNCHELP_READ_N; 131 } 132 133 134 135 int LaserPowerUp::readBytes( byte * data, int maxLength, int * reciever ) 136 { 137 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 138 { 139 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 140 setRequestedSync( true ); 141 } 142 143 int rec = this->getRequestSync(); 144 if ( rec > 0 ) 145 { 146 *reciever = rec; 147 148 SYNCHELP_WRITE_BEGIN(); 149 150 SYNCHELP_WRITE_FKT( PowerUp::readState ); 151 152 return SYNCHELP_WRITE_N; 153 } 154 155 *reciever = 0; 156 return 0; 157 } 158 -
trunk/src/world_entities/power_ups/laser_power_up.h
r5511 r6424 23 23 virtual void draw() const; 24 24 25 virtual int writeBytes(const byte* data, int length, int sender); 26 virtual int readBytes(byte* data, int maxLength, int * reciever ); 27 25 28 private: 26 29 void init(); -
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 -
trunk/src/world_entities/power_ups/param_power_up.h
r6113 r6424 30 30 int getValue(); 31 31 32 virtual int writeBytes(const byte* data, int length, int sender); 33 virtual int readBytes(byte* data, int maxLength, int * reciever ); 34 32 35 protected: 33 36 virtual void respawn(); -
trunk/src/world_entities/power_ups/power_up.cc
r6282 r6424 25 25 PowerUp::PowerUp(float r, float g, float b) 26 26 { 27 this->setClassID(CL_POWER_UP, "PowerUp"); 28 27 29 this->respawnType = RESPAWN_NONE; 28 30 /* if(!PowerUp::sphereModel) {*/ … … 52 54 void PowerUp::collidesWith (WorldEntity* entity, const Vector& location) 53 55 { 54 if(entity->isA(CL_EXTENDABLE))56 if(entity->isA(CL_EXTENDABLE)) 55 57 { 56 58 if(dynamic_cast<Extendable*>(entity)->pickup(this)) … … 94 96 } 95 97 98 /** 99 * data copied in data will bee sent to another host 100 * @param data pointer to data 101 * @param maxLength max length of data 102 * @return the number of bytes writen 103 */ 104 int PowerUp::readState( byte * data, int maxLength ) 105 { 106 SYNCHELP_WRITE_BEGIN(); 107 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 108 return SYNCHELP_WRITE_N; 109 } 110 111 /** 112 * Writes data from network containing information about the state 113 * @param data pointer to data 114 * @param length length of data 115 * @param sender hostID of sender 116 */ 117 int PowerUp::writeState( const byte * data, int length, int sender ) 118 { 119 SYNCHELP_READ_BEGIN(); 120 SYNCHELP_READ_FKT( WorldEntity::writeState ); 121 return SYNCHELP_READ_N; 122 } 123 -
trunk/src/world_entities/power_ups/power_up.h
r6282 r6424 26 26 void setRespawnType(const char* type); 27 27 28 int writeState(const byte* data, int length, int sender); 29 int readState(byte* data, int maxLength ); 30 28 31 protected: 29 32 PowerUp(float r, float g, float b); -
trunk/src/world_entities/power_ups/turret_power_up.cc
r6222 r6424 18 18 #include "turret_power_up.h" 19 19 #include "factory.h" 20 #include "network_game_manager.h" 20 21 #include "state.h" 21 22 … … 118 119 } 119 120 121 int TurretPowerUp::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 ); 129 130 return SYNCHELP_READ_N; 131 } 132 133 134 135 int TurretPowerUp::readBytes( byte * data, int maxLength, int * reciever ) 136 { 137 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 138 { 139 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 140 setRequestedSync( true ); 141 } 142 143 int rec = this->getRequestSync(); 144 if ( rec > 0 ) 145 { 146 *reciever = rec; 147 148 SYNCHELP_WRITE_BEGIN(); 149 150 SYNCHELP_WRITE_FKT( PowerUp::readState ); 151 152 return SYNCHELP_WRITE_N; 153 } 154 155 *reciever = 0; 156 return 0; 157 } -
trunk/src/world_entities/power_ups/turret_power_up.h
r5511 r6424 23 23 virtual void draw() const; 24 24 25 virtual int writeBytes(const byte* data, int length, int sender); 26 virtual int readBytes(byte* data, int maxLength, int * reciever ); 27 25 28 private: 26 29 void init(); -
trunk/src/world_entities/power_ups/weapon_power_up.cc
r6243 r6424 20 20 #include "state.h" 21 21 #include "list.h" 22 #include "network_game_manager.h" 22 23 23 24 #include "primitive_model.h" … … 85 86 this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name)); 86 87 } 88 89 int WeaponPowerUp::writeBytes( const byte * data, int length, int sender ) 90 { 91 setRequestedSync( false ); 92 setIsOutOfSync( false ); 93 94 SYNCHELP_READ_BEGIN(); 95 96 SYNCHELP_READ_FKT( PowerUp::writeState ); 97 98 //TODO: sync weapon class ( see loadParams ) 99 100 return SYNCHELP_READ_N; 101 } 102 103 104 105 int WeaponPowerUp::readBytes( byte * data, int maxLength, int * reciever ) 106 { 107 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 108 { 109 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 110 setRequestedSync( true ); 111 } 112 113 int rec = this->getRequestSync(); 114 if ( rec > 0 ) 115 { 116 *reciever = rec; 117 118 SYNCHELP_WRITE_BEGIN(); 119 120 SYNCHELP_WRITE_FKT( PowerUp::readState ); 121 122 //TODO: sync weapon class ( see loadParams ) 123 124 return SYNCHELP_WRITE_N; 125 } 126 127 *reciever = 0; 128 return 0; 129 } -
trunk/src/world_entities/power_ups/weapon_power_up.h
r6113 r6424 22 22 void setWeaponClass(const char* name); 23 23 24 virtual int writeBytes(const byte* data, int length, int sender); 25 virtual int readBytes(byte* data, int maxLength, int * reciever ); 26 24 27 protected: 25 28 virtual void respawn();
Note: See TracChangeset
for help on using the changeset viewer.