Changeset 9347 in orxonox.OLD for branches/proxy/src/world_entities
- Timestamp:
- Jul 20, 2006, 11:43:27 AM (18 years ago)
- Location:
- branches/proxy/src/world_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/world_entities/camera.cc
r9235 r9347 17 17 #include "camera.h" 18 18 #include "key_mapper.h" 19 #include "glincl.h" 19 20 20 21 /** -
branches/proxy/src/world_entities/creatures/fps_player.cc
r9235 r9347 287 287 //dealing damage 288 288 289 if ( State::isOnline() && SharedNetworkData::getInstance()->is GameServer() )289 if ( State::isOnline() && SharedNetworkData::getInstance()->isMasterServer() ) 290 290 { 291 291 this->damageTicker -= time; -
branches/proxy/src/world_entities/playable.cc
r9235 r9347 361 361 } 362 362 } 363 /**364 * @brief helps us colliding Playables365 * @param entity the Entity to collide366 * @param location where the collision occured.367 */368 void Playable::collidesWith(WorldEntity* entity, const Vector& location)369 {370 if (entity == collider)371 return;372 collider = entity;373 374 if ( entity->isA(CL_PROJECTILE) && ( !State::isOnline() || SharedNetworkData::getInstance()->isGameServer() ) )375 {376 this->decreaseHealth(entity->getHealth() *(float)rand()/(float)RAND_MAX);377 // EXTREME HACK378 if (this->getHealth() <= 0.0f)379 {380 // this->destory();381 382 if( State::getGameRules() != NULL)383 State::getGameRules()->registerKill(Kill(entity, this));384 }385 }386 }387 363 388 364 … … 413 389 } 414 390 this->bDead = true; 415 391 416 392 if( State::getGameRules() != NULL) 417 393 State::getGameRules()->registerKill(Kill(killer, this)); -
branches/proxy/src/world_entities/playable.h
r9235 r9347 82 82 virtual void destroy(WorldEntity* killer); 83 83 virtual void respawn(); 84 virtual void collidesWith(WorldEntity* entity, const Vector& location);85 84 virtual void process(const Event &event); 86 85 virtual void tick(float dt); … … 90 89 static const std::string& playmodeToString(Playable::Playmode playmode); 91 90 static const std::string playmodeNames[]; 92 91 93 92 inline bool beFire(){ return this->bFire; } 94 93 inline void fire(bool bF){ this->bFire = bF;} -
branches/proxy/src/world_entities/space_ships/space_ship.cc
r9235 r9347 314 314 if( entity->isA(CL_PROJECTILE) && entity != ref) 315 315 { 316 if ( isServer() )316 if ( SharedNetworkData::getInstance()->isMasterServer() ) 317 317 { 318 318 //TODO handle this -
branches/proxy/src/world_entities/spawning_point.cc
r9235 r9347 41 41 42 42 this->init(); 43 43 44 44 if (root != NULL) 45 45 this->loadParams(root); … … 50 50 this->setClassID(CL_SPAWNING_POINT, "SpawningPoint"); 51 51 PRINTF(0)("Created SpawningPoint\n"); 52 52 53 53 this->teamId = -1; 54 54 this->localTimer = 0.0f; 55 55 56 56 this->toList( OM_DEAD_TICK ); 57 57 58 58 MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL ); 59 59 60 60 this->setSynchronized( true ); 61 61 } … … 94 94 qe.entity = entity; 95 95 qe.respawnTime = this->localTimer + delay; 96 96 97 97 queue.push_back( qe ); 98 98 } … … 105 105 { 106 106 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 107 107 108 108 bool found = false; 109 109 110 110 if ( !list ) 111 111 return; 112 112 113 113 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 114 114 { … … 119 119 } 120 120 } 121 121 122 122 if ( !found ) 123 123 return; … … 128 128 entity->setAbsCoor( this->getAbsCoor() ); 129 129 entity->setAbsDir( this->getAbsDir() ); 130 130 131 131 //TODO set camera (not smooth) 132 132 133 133 if ( State::getGameRules() ) 134 134 { 135 135 (State::getGameRules())->registerSpawn( entity ); 136 136 } 137 137 138 138 entity->respawn(); 139 139 } … … 157 157 //spawn the player 158 158 this->spawn(it->entity); 159 159 160 160 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 161 161 162 162 bool found = false; 163 163 164 164 if ( !list ) 165 165 return; 166 166 167 167 for ( std::list<BaseObject*>::const_iterator it2 = list->begin(); it2 != list->end(); it2++ ) 168 168 { … … 173 173 } 174 174 } 175 176 if ( found && SharedNetworkData::getInstance()->is GameServer() )175 176 if ( found && SharedNetworkData::getInstance()->isMasterServer() ) 177 177 this->sendRespawnMessage( it->entity->getUniqueID() ); 178 178 179 179 std::list<QueueEntry>::iterator delit = it; 180 180 it++; 181 181 182 182 queue.erase( delit ); 183 183 184 184 continue; 185 185 } 186 186 187 187 it++; 188 188 } … … 204 204 { 205 205 byte * buf = new byte[2*INTSIZE]; 206 206 207 207 assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE ); 208 208 assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE ); 209 209 210 210 MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 211 211 } … … 213 213 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 214 214 { 215 if ( SharedNetworkData::getInstance()->is GameServer() )215 if ( SharedNetworkData::getInstance()->isMasterServer() ) 216 216 { 217 217 PRINTF(2)("server received spawn message!\n"); 218 218 return true; 219 219 } 220 220 221 221 int spUniqueId; 222 222 int uniqueId; 223 223 224 224 if ( dataLength != 2*INTSIZE ) 225 225 { … … 227 227 return true; 228 228 } 229 229 230 230 assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE ); 231 231 assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE ); 232 232 233 233 PRINTF(0)("SPAWNMESSAGE %d\n", uniqueId); 234 234 235 235 SpawningPoint * sp = NULL; 236 236 Playable * playable = NULL; 237 237 238 238 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 239 239 240 240 if ( list ) 241 241 { … … 250 250 } 251 251 } 252 252 253 253 if ( !sp ) 254 254 { … … 256 256 return false; 257 257 } 258 258 259 259 list = ClassList::getList( CL_PLAYABLE ); 260 260 261 261 if ( list ) 262 262 { … … 270 270 } 271 271 } 272 272 273 273 if ( !playable ) 274 274 { … … 276 276 return false; 277 277 } 278 278 279 279 sp->spawn( playable ); 280 280 281 281 return true; 282 282 }
Note: See TracChangeset
for help on using the changeset viewer.