Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 4, 2008, 8:53:10 PM (16 years ago)
Author:
rgrieder
Message:

merged network branch back to trunk

File:
1 edited

Legend:

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

    r1505 r1534  
    4444#include <iostream>
    4545#include <zlib.h>
     46#include <assert.h>
    4647
    4748#include "core/CoreIncludes.h"
     
    106107        break;
    107108      if( (*it).second <= 0 ){
    108         COUT(4) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
     109        COUT(5) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
    109110        std::map<int, GameState *>::iterator tempit = gameStateMap.find((*it).first);
    110111        if( tempit != gameStateMap.end() ){
     
    140141        client = it->second;
    141142      GameState *server = reference;
    142       COUT(4) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
     143      //COUT(4) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
     144      COUT(4) << "client: " << (client!=0 ? client->id : (int)client) << " server: " << server->id << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
    143145      if(client)
    144146        return encode(client, server);
     
    267269      sync.data = data;
    268270      data+=sync.length;
    269       COUT(4) << "objectID: " << sync.objectID << " classID: " << sync.classID << std::endl;
     271      COUT(5) << "objectID: " << sync.objectID << " classID: " << sync.classID << std::endl;
    270272      while(it && it->objectID!=sync.objectID)
    271273        ++it;
     
    319321
    320322  GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) {
    321     COUT(4) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
     323    COUT(5) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
    322324    GameState *r = diff(a,b);
    323325    GameStateCompressed *c = compress_(r);
     
    472474    if(gamestateID == GAMESTATEID_INITIAL){
    473475      temp->setGameStateID(GAMESTATEID_INITIAL);
    474       if(curid!=GAMESTATEID_INITIAL)
     476      if(curid!=GAMESTATEID_INITIAL){
     477        assert(gameStateUsed.find(curid)!=gameStateUsed.end());
    475478        --(gameStateUsed.find(curid)->second);
     479      }
    476480      return;
    477481    }
     
    483487//     deleteUnusedGameState(curid);
    484488    //increase gamestateused
    485     if(curid!=GAMESTATEID_INITIAL)
    486       --(gameStateUsed.find(curid)->second);
    487     ++(gameStateUsed.find(gamestateID)->second);
    488     temp->setGameStateID(gamestateID);
     489    std::map<int, int>::iterator it = gameStateUsed.find(curid);
     490    if(curid!=GAMESTATEID_INITIAL){
     491      if(it!=gameStateUsed.end())
     492        --(it->second);
     493    }
     494    it = gameStateUsed.find(gamestateID);
     495    if(it!=gameStateUsed.end()){
     496      ++(it->second);
     497      temp->setGameStateID(gamestateID);
     498    }
    489499    /*
    490500    GameState *old = clientGameState[clientID];
Note: See TracChangeset for help on using the changeset viewer.