Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 9, 2008, 8:38:52 PM (16 years ago)
Author:
scheusso
Message:

enhanced memory management in gamestatemanager and gamestateclient

File:
1 edited

Legend:

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

    r984 r1005  
    3333namespace network
    3434{
     35  struct GameStateItem{
     36    GameState *state;
     37    int id;
     38  };
     39 
    3540  GameStateClient::GameStateClient() {
    3641  }
     
    4146  bool GameStateClient::pushGameState(GameStateCompressed *compstate) {
    4247    GameState *gs;
    43     if(compstate->diffed)
    44       gs = decode(reference, compstate);
     48    if(compstate->diffed){
     49      while(compstate->base_id > gameStateList.front()->id){
     50        // clean up old gamestates
     51        free(gameStateList.front()->data);
     52        // TODO: critical section
     53        delete gameStateList.front();
     54        gameStateList.pop();
     55      }
     56      if(compstate->base_id!=gameStateList.front()->id){
     57        COUT(4) << "pushGameState: no reference found to diff" << std::endl;
     58        return false;
     59      }
     60      gs = decode(gameStateList.front(), compstate);
     61    }
    4562    else
    4663      gs = decode(compstate);
     
    197214  GameState *GameStateClient::decode(GameState *a, GameStateCompressed *x) {
    198215    GameState *t = decompress(x);
     216    gameStateList.push(t);
    199217    return undiff(a, t);
    200218  }
     
    202220  GameState *GameStateClient::decode(GameStateCompressed *x) {
    203221    GameState *t = decompress(x);
     222    gameStateList.push(t);
    204223    return t;
    205224  }
Note: See TracChangeset for help on using the changeset viewer.