Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 10, 2008, 12:55:35 PM (16 years ago)
Author:
dumenim
Message:

changed some comments and catched some return values and maybe some stuff we have to unchange

File:
1 edited

Legend:

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

    r1007 r1008  
    9393
    9494  GameStateCompressed *GameStateManager::popGameState(int clientID) {
     95    //why are we searching the same client's gamestate id as we searched in
     96    //Server::sendGameState?
    9597    int gID = head_->findClient(clientID)->getGamestateID();
    96     COUT(4) << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
    97     if(gID!=GAMESTATEID_INITIAL){
     98    COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id << " diffed from: " << gID << " (not diffed yet)" << std::endl;
     99   
     100    //chose wheather the next gamestate is the first or not
     101    if(gID != GAMESTATEID_INITIAL){
    98102      GameState *client = gameStateMap[gID];
    99103      GameState *server = reference;
     
    115119  GameState *GameStateManager::getSnapshot(int id)
    116120  {
     121    //std::cout << "begin getSnapshot" << std::endl;
    117122    //the size of the gamestate
    118123    int totalsize=0;
     
    127132    GameState *retval=new GameState; //return value
    128133    retval->id=id++;
    129     COUT(4) << "producing gamestate with id: " << retval->id << std::endl;
     134    COUT(4) << "G.ST.Man: producing gamestate with id: " << retval->id << std::endl;
    130135    // reserve a little memory and increase it later on
    131     COUT(5) << "mallocing" << std::endl;
     136    COUT(5) << "G.ST.Man: mallocing: " << memsize << std::endl;
    132137    retval->data = (unsigned char*)malloc(memsize);
    133     COUT(5) << "malloced" << std::endl;
     138    COUT(5) << "G.ST.Man: malloced: " << memsize << std::endl;
    134139
    135140    // offset of memory functions
     
    137142    // go through all Synchronisables
    138143    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
     144      //std::cout << "begin inner loop" << std::endl;
    139145      //std::cout << "gamestatemanager: in for loop" << std::endl;
    140146      //get size of the synchronisable
    141147      tempsize=it->getSize();
    142 //       COUT(5) << "size of temp gamestate: " << tempsize << std::endl;
     148      //COUT(5) << "size of temp gamestate: " << tempsize << std::endl;
    143149      //COUT(2) << "size of synchronisable: " << tempsize << std::endl;
    144150      // add place for data and 3 ints (length,classid,objectid)
    145151      totalsize+=tempsize+3*sizeof(int);
    146152      //std::cout << "totalsize: " << totalsize << std::endl;
     153      //COUT(5) << "G.St.Man: current totalsize=" << totalsize << std::endl;
     154      //COUT(5) << "G.St.Man: current it->classID=" << it->classID << " it->objectID=" << it->objectID << std::endl;
    147155      // allocate additional space
    148       if(totalsize+tempsize>memsize){
    149         if(tempsize<1000){
     156      if((totalsize+tempsize) > memsize){
     157        COUT(5) << "G.St.Man: need additional memory" << std::endl;
     158        if(tempsize < 1000){
    150159          retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
    151160          memsize+=1000;
     
    154163          memsize+=tempsize+1000;
    155164        }
     165        COUT(5) << "G.St.Man: additional space allocation finished" << std::endl;
    156166      }
    157167
     
    166176      // increase data pointer
    167177      offset+=tempsize+3*sizeof(int);
    168     }
    169     COUT(5) << "Gamestate size: " << totalsize << std::endl;
     178      //std::cout << "end inner loop" << std::endl;
     179    }
    170180    retval->size=totalsize;
    171181    //#### bugfix
    172182    retval->diffed = false;
     183    //std::cout << "end snapShot" << std::endl;
     184    COUT(5) << "G.ST.Man: Gamestate size: " << totalsize << std::endl;
    173185    return retval;
    174186  }
     
    185197
    186198  GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) {
     199    COUT(5) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
    187200    //GameState r = diff(a,b);
    188201    //r.diffed = true;
     
    193206
    194207  GameStateCompressed *GameStateManager::encode(GameState *a) {
     208    COUT(5) << "G.St.Man: this will be a not diffed gamestate" << std::endl;
    195209    a->diffed=false;
    196210    return compress_(a);
     
    235249
    236250  GameStateCompressed *GameStateManager::compress_(GameState *a) {
    237     COUT(5) << "compressing gamestate" << std::endl;
     251    COUT(5) << "G.St.Man: compressing gamestate" << std::endl;
    238252    int size = a->size;
    239253    uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
     
    245259
    246260    switch ( retval ) {
    247       case Z_OK: COUT(5) << "successfully compressed" << std::endl; break;
    248       case Z_MEM_ERROR: COUT(1) << "not enough memory available in gamestate.compress" << std::endl;
     261      case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
     262      case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl;
    249263      return NULL;
    250       case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer in gamestate.compress" << std::endl;
     264      case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
    251265      return NULL;
    252       case Z_DATA_ERROR: COUT(2) << "decompress: data corrupted in gamestate.compress" << std::endl;
     266      case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl;
    253267      return NULL;
    254268    }
     
    263277    compressedGamestate->diffed = a->diffed;
    264278    compressedGamestate->base_id = a->base_id;
    265 
     279    COUT(5) << "G.St.Man: saved compressed data in GameStateCompressed" << std::endl;
    266280    return compressedGamestate;
    267281  }
Note: See TracChangeset for help on using the changeset viewer.