Changeset 9406 in orxonox.OLD for trunk/src/world_entities/spawning_point.cc
- Timestamp:
- Jul 24, 2006, 11:09:47 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/spawning_point.cc
r9235 r9406 31 31 #include "shared_network_data.h" 32 32 33 34 /// TODO REMOVE converter.h 35 #include "converter.h" 36 33 37 CREATE_FACTORY( SpawningPoint, CL_SPAWNING_POINT ); 34 38 … … 41 45 42 46 this->init(); 43 47 44 48 if (root != NULL) 45 49 this->loadParams(root); … … 50 54 this->setClassID(CL_SPAWNING_POINT, "SpawningPoint"); 51 55 PRINTF(0)("Created SpawningPoint\n"); 52 56 53 57 this->teamId = -1; 54 58 this->localTimer = 0.0f; 55 59 56 60 this->toList( OM_DEAD_TICK ); 57 61 58 62 MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL ); 59 63 60 64 this->setSynchronized( true ); 61 65 } … … 94 98 qe.entity = entity; 95 99 qe.respawnTime = this->localTimer + delay; 96 100 97 101 queue.push_back( qe ); 98 102 } … … 105 109 { 106 110 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 107 111 108 112 bool found = false; 109 113 110 114 if ( !list ) 111 115 return; 112 116 113 117 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 114 118 { … … 119 123 } 120 124 } 121 125 122 126 if ( !found ) 123 127 return; 124 128 125 PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClass Name());129 PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassCName()); 126 130 127 131 128 132 entity->setAbsCoor( this->getAbsCoor() ); 129 133 entity->setAbsDir( this->getAbsDir() ); 130 134 131 135 //TODO set camera (not smooth) 132 136 133 137 if ( State::getGameRules() ) 134 138 { 135 139 (State::getGameRules())->registerSpawn( entity ); 136 140 } 137 141 138 142 entity->respawn(); 139 143 } … … 157 161 //spawn the player 158 162 this->spawn(it->entity); 159 163 160 164 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 161 165 162 166 bool found = false; 163 167 164 168 if ( !list ) 165 169 return; 166 170 167 171 for ( std::list<BaseObject*>::const_iterator it2 = list->begin(); it2 != list->end(); it2++ ) 168 172 { … … 173 177 } 174 178 } 175 176 if ( found && SharedNetworkData::getInstance()->is GameServer())179 180 if ( found && SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) 177 181 this->sendRespawnMessage( it->entity->getUniqueID() ); 178 182 179 183 std::list<QueueEntry>::iterator delit = it; 180 184 it++; 181 185 182 186 queue.erase( delit ); 183 187 184 188 continue; 185 189 } 186 190 187 191 it++; 188 192 } … … 203 207 void SpawningPoint::sendRespawnMessage( int uniqueId ) 204 208 { 209 #warning this byte array is not being deleted according to valginrd 205 210 byte * buf = new byte[2*INTSIZE]; 206 211 207 212 assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE ); 208 213 assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE ); 209 214 210 215 MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 211 216 } … … 213 218 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 214 219 { 215 if ( SharedNetworkData::getInstance()->is GameServer())220 if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) 216 221 { 217 222 PRINTF(2)("server received spawn message!\n"); 218 223 return true; 219 224 } 220 225 221 226 int spUniqueId; 222 227 int uniqueId; 223 228 224 229 if ( dataLength != 2*INTSIZE ) 225 230 { … … 227 232 return true; 228 233 } 229 234 230 235 assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE ); 231 236 assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE ); 232 237 233 238 PRINTF(0)("SPAWNMESSAGE %d\n", uniqueId); 234 239 235 240 SpawningPoint * sp = NULL; 236 241 Playable * playable = NULL; 237 242 238 243 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 239 244 240 245 if ( list ) 241 246 { … … 250 255 } 251 256 } 252 257 253 258 if ( !sp ) 254 259 { … … 256 261 return false; 257 262 } 258 263 259 264 list = ClassList::getList( CL_PLAYABLE ); 260 265 261 266 if ( list ) 262 267 { … … 270 275 } 271 276 } 272 277 273 278 if ( !playable ) 274 279 { … … 276 281 return false; 277 282 } 278 283 279 284 sp->spawn( playable ); 280 285 281 286 return true; 282 287 }
Note: See TracChangeset
for help on using the changeset viewer.