Changeset 1574 for code/branches/core3/src/network/GameStateManager.cc
- Timestamp:
- Jun 9, 2008, 4:35:38 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/network/GameStateManager.cc
r1534 r1574 70 70 return; 71 71 } 72 72 73 73 void GameStateManager::addGameState(GameStateCompressed *gs, int clientID){ 74 74 if(!gs) … … 83 83 return; 84 84 } 85 85 86 86 void GameStateManager::processGameStates(){ 87 87 std::map<int, GameStateCompressed*>::iterator it; … … 93 93 gameStateQueue.clear(); 94 94 } 95 96 95 96 97 97 /** 98 98 * this function is used to keep the memory usage low 99 99 * it tries to delete all the unused gamestates 100 * 101 * 100 * 101 * 102 102 */ 103 103 void GameStateManager::cleanup(){ … … 155 155 } 156 156 } 157 157 158 158 bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){ 159 159 GameState *ugs = decompress(gs); … … 190 190 int offset=0, size=0; 191 191 // get total size of gamestate 192 for(it = orxonox::ObjectList<Synchronisable>:: start(); it; ++it){192 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){ 193 193 size+=it->getSize(); // size of the actual data of the synchronisable 194 194 size+=3*sizeof(int); // size of datasize, classID and objectID … … 204 204 memsize=size; 205 205 // go through all Synchronisables 206 for(it = orxonox::ObjectList<Synchronisable>:: start(); it; ++it){206 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){ 207 207 //get size of the synchronisable 208 208 tempsize=it->getSize(); … … 246 246 COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl; 247 247 // get the start of the Synchronisable list 248 orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>:: start();248 orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::begin(); 249 249 syncData sync; 250 250 /*ClientInformation *client = head_->findClient(clientID); … … 308 308 return true; 309 309 } 310 311 310 311 312 312 //##### ADDED FOR TESTING PURPOSE ##### 313 313 GameStateCompressed* GameStateManager::testCompress( GameState* g ) { … … 405 405 switch ( retval ) { 406 406 case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break; 407 case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; 407 case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; 408 408 return NULL; 409 409 case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; … … 426 426 return compressedGamestate; 427 427 } 428 428 429 429 GameState *GameStateManager::decompress(GameStateCompressed *a) { 430 430 //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl; … … 464 464 return gamestate; 465 465 } 466 466 467 467 468 468 void GameStateManager::ackGameState(int clientID, int gamestateID) { … … 471 471 return; 472 472 int curid = temp->getGamestateID(); 473 473 474 474 if(gamestateID == GAMESTATEID_INITIAL){ 475 475 temp->setGameStateID(GAMESTATEID_INITIAL); … … 481 481 } 482 482 if(curid > gamestateID) 483 // the network packets got messed up 483 // the network packets got messed up 484 484 return; 485 485 COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl; … … 512 512 return true; 513 513 } 514 514 515 515 bool GameStateManager::checkAccess(int clientID, int objectID){ 516 516 // currently we only check, wheter the object is the clients spaceship … … 518 518 return true; // TODO: change this 519 519 } 520 520 521 521 void GameStateManager::removeClient(ClientInformation* client){ 522 522 if(!client)
Note: See TracChangeset
for help on using the changeset viewer.