Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2008, 4:35:38 AM (16 years ago)
Author:
landauf
Message:

big change in ObjectList: separated the class into a non-template base and a template wrapper for the base. this also changes the Iterator, there is now a non-template IteratorBase. this brings much more flexibility, like iterating through all objects of a given identifier without knowing the type. however this needs a dynamic_cast, which isn't quite optimal, but I think there are much worser things than that out there. ;)

there isn't much you have to know about this, except there is no more ObjectList<myClass>::start() function but a ObjectList<myClass>::begin() to be more STLish. another thing: ObjectList<myClass>::end() points now to the element _after_ the last element, so it's possible to iterate in a for-loop until (it != ObjectList<myClass>::end()). the reason is the same as above. however, (it) as a boolean still works perfectly fine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/network/GameStateManager.cc

    r1534 r1574  
    7070    return;
    7171  }
    72  
     72
    7373  void GameStateManager::addGameState(GameStateCompressed *gs, int clientID){
    7474    if(!gs)
     
    8383    return;
    8484  }
    85  
     85
    8686  void GameStateManager::processGameStates(){
    8787    std::map<int, GameStateCompressed*>::iterator it;
     
    9393    gameStateQueue.clear();
    9494  }
    95  
    96  
     95
     96
    9797  /**
    9898   * this function is used to keep the memory usage low
    9999   * it tries to delete all the unused gamestates
    100    * 
    101    * 
     100   *
     101   *
    102102   */
    103103  void GameStateManager::cleanup(){
     
    155155    }
    156156  }
    157  
     157
    158158  bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){
    159159    GameState *ugs = decompress(gs);
     
    190190    int offset=0, size=0;
    191191    // get total size of gamestate
    192     for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
     192    for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
    193193      size+=it->getSize(); // size of the actual data of the synchronisable
    194194      size+=3*sizeof(int); // size of datasize, classID and objectID
     
    204204    memsize=size;
    205205    // go through all Synchronisables
    206     for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
     206    for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
    207207      //get size of the synchronisable
    208208      tempsize=it->getSize();
     
    246246    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
    247247    // 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();
    249249    syncData sync;
    250250    /*ClientInformation *client = head_->findClient(clientID);
     
    308308    return true;
    309309  }
    310  
    311  
     310
     311
    312312  //##### ADDED FOR TESTING PURPOSE #####
    313313  GameStateCompressed* GameStateManager::testCompress( GameState* g ) {
     
    405405    switch ( retval ) {
    406406      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;
    408408      return NULL;
    409409      case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
     
    426426    return compressedGamestate;
    427427  }
    428  
     428
    429429  GameState *GameStateManager::decompress(GameStateCompressed *a) {
    430430    //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;
     
    464464    return gamestate;
    465465  }
    466  
     466
    467467
    468468  void GameStateManager::ackGameState(int clientID, int gamestateID) {
     
    471471      return;
    472472    int curid = temp->getGamestateID();
    473    
     473
    474474    if(gamestateID == GAMESTATEID_INITIAL){
    475475      temp->setGameStateID(GAMESTATEID_INITIAL);
     
    481481    }
    482482    if(curid > gamestateID)
    483       // the network packets got messed up 
     483      // the network packets got messed up
    484484      return;
    485485    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
     
    512512    return true;
    513513  }
    514  
     514
    515515  bool GameStateManager::checkAccess(int clientID, int objectID){
    516516    // currently we only check, wheter the object is the clients spaceship
     
    518518    return true; // TODO: change this
    519519  }
    520  
     520
    521521  void GameStateManager::removeClient(ClientInformation* client){
    522522    if(!client)
Note: See TracChangeset for help on using the changeset viewer.