Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 12, 2010, 1:08:58 PM (14 years ago)
Author:
scheusso
Message:
  • merged network2 branch into presentation3 branch (lots of network traffic and cpu load improvements)
  • fixed network related bugs in BigExplosion
Location:
code/branches/presentation3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3

  • code/branches/presentation3/src/libraries/network/GamestateManager.cc

    r6417 r7153  
    4343#include <cassert>
    4444#include <queue>
     45#include "util/Clock.h"
    4546// #include <boost/thread/mutex.hpp>
    4647
     
    158159
    159160      clientGamestates.push(0);
    160       finishGamestate( cid, &clientGamestates.back(), client, reference );
     161      finishGamestate( cid, clientGamestates.back(), client, reference );
    161162      //FunctorMember<GamestateManager>* functor =
    162163//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
     
    180181
    181182
    182   void GamestateManager::finishGamestate( unsigned int clientID, packet::Gamestate** destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) {
     183  void GamestateManager::finishGamestate( unsigned int clientID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) {
    183184    //why are we searching the same client's gamestate id as we searched in
    184185    //Server::sendGameState?
     
    186187    //chose wheather the next gamestate is the first or not
    187188
    188     packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
    189 //     packet::Gamestate *gs = new packet::Gamestate(*gamestate);
     189//     packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
     190//       packet::Gamestate* gs = new packet::Gamestate(*gamestate);
     191//     packet::Gamestate* gs = gamestate;
     192    packet::Gamestate *gs = new packet::Gamestate(*gamestate); //TODO: is this neccessary ?
    190193//     packet::Gamestate *gs = new packet::Gamestate();
    191194//     gs->collectData( id_, 0x1 );
     
    193196    gamestateMap_[clientID][gamestate->getID()]=gs;
    194197//     this->threadMutex_->unlock();
     198      Clock clock;
     199      clock.capture();
    195200
    196201    if(base)
    197202    {
    198 
    199 //       COUT(3) << "diffing" << std::endl;
    200 //       packet::Gamestate* gs1  = gs;
    201       packet::Gamestate *diffed = gs->diff(base);
    202       //packet::Gamestate *gs2 = diffed->undiff(gs);
    203 //       assert(*gs == *gs2);
    204       gs = diffed;
    205 //       packet::Gamestate* gs2 = gs->undiff(client);
    206 //       gs = new packet::Gamestate(*gs);
    207 //       assert(*gs1==*gs2);
    208     }
    209     else{
     203      packet::Gamestate *diffed1 = gs->diffVariables(base);
     204      if( diffed1->getDataSize() == 0 )
     205      {
     206        delete diffed1;
     207        destgamestate = 0;
     208        return;
     209      }
     210      gs = diffed1;
     211    }
     212    else
     213    {
    210214      gs = new packet::Gamestate(*gs);
    211215    }
     
    214218    bool b = gs->compressData();
    215219    assert(b);
    216 //     COUT(4) << "sending gamestate with id " << gs->getID();
     220      clock.capture();
     221      COUT(0) << "diff time: " << clock.getDeltaTime() << endl;
     222//     COUT(5) << "sending gamestate with id " << gs->getID();
    217223//     if(gamestate->isDiffed())
    218 //     COUT(4) << " and baseid " << gs->getBaseID() << endl;
     224//       COUT(5) << " and baseid " << gs->getBaseID() << endl;
    219225//     else
    220 //     COUT(4) << endl;
     226//       COUT(5) << endl;
    221227    gs->setClientID(clientID);
    222     *destgamestate = gs;
     228    destgamestate = gs;
    223229  }
    224230
Note: See TracChangeset for help on using the changeset viewer.