Changeset 9347 in orxonox.OLD for branches/proxy/src/world_entities/spawning_point.cc
- Timestamp:
- Jul 20, 2006, 11:43:27 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.