Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 624 for code


Ignore:
Timestamp:
Dec 18, 2007, 7:05:51 PM (17 years ago)
Author:
scheusso
Message:

changes in gamestatehandling

Location:
code/branches/FICN/src/network
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/Client.cc

    r620 r624  
    190190  void Client::processGamestate( GameStateCompressed *data){
    191191    gamestate.pushGameState(data);
     192    std::cout << "received gamestate id: " << data->id << std::endl;
    192193    client_connection.addPacket(pck_gen.acknowledgement(data->id));
    193194    client_connection.sendPackets();
  • code/branches/FICN/src/network/GameStateClient.cc

    r620 r624  
    145145  int normsize = a.normsize;
    146146  int compsize = a.compsize;
    147   unsigned char* dest = (unsigned char*)malloc( normsize );
     147  int bufsize;
     148  if(normsize < compsize)
     149    bufsize = compsize;
     150  else
     151    bufsize = normsize;
     152  unsigned char* dest = (unsigned char*)malloc( bufsize );
    148153  int retval;
    149154  uLongf length=normsize;
  • code/branches/FICN/src/network/GameStateManager.cc

    r620 r624  
    6161GameStateCompressed GameStateManager::popGameState(int clientID){
    6262  int gID = head_->findClient(clientID)->getGamestateID();
    63   std::cout << "popgamestate: sending gstate id: " << gID << std::endl;
     63  std::cout << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
    6464  if(gID!=GAMESTATEID_INITIAL){
    6565    GameState *client = gameStateMap[gID];
    6666    GameState *server = reference;
     67    //head_->findClient(clientID)->setGamestateID(id);
    6768    return encode(client, server);
    6869  } else {
    6970    GameState *server = reference;
    70     head_->findClient(clientID)->setGamestateID(id);
     71    //head_->findClient(clientID)->setGamestateID(id);
    7172    return encode(server);
    7273    // return an undiffed gamestate and set appropriate flags
     
    9596  GameState *retval=new GameState; //return value
    9697  retval->id=id++;
     98  std::cout << "producing gamestate with id: " << retval->id << std::endl;
    9799  // reserve a little memory and increase it later on
    98100  //COUT(2) << "mallocing" << std::endl;
     
    193195  compressedGamestate.compsize = buffer;
    194196  compressedGamestate.normsize = size;
    195   compressedGamestate.id = GAMESTATE;
     197  compressedGamestate.id = a->id;
    196198  compressedGamestate.data = dest;
    197199  compressedGamestate.diffed = a->diffed;
  • code/branches/FICN/src/network/GameStateManager.h

    r496 r624  
    4949  GameStateCompressed popGameState(int clientID);
    5050  void ackGameState(int clientID, int gamestateID);
     51  int id;
    5152private:
    5253  GameState *getSnapshot(int id);
     
    6061  std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
    6162  GameState *reference;
    62   int id;
    6363  ClientInformation *head_;
    6464};
  • code/branches/FICN/src/network/PacketDecoder.cc

    r620 r624  
    8989
    9090
     91  std::cout << "got ack id: " << a->id << std::endl;
    9192  processAck( a, clientId ); //debug info
    9293 
     
    146147  //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
    147148  currentState->id = (int)*(data+sizeof(int));
     149  std::cout << "id: " << currentState->id << std::endl;
    148150        //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
    149151        //position of the data stream, data+2*sizeof( int )
    150152//      memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
    151153  currentState->compsize = (int)*(data+2*sizeof(int));
     154  std::cout << "compsize: " << currentState->compsize << std::endl;
    152155        //size of uncompressed data
    153156//      memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
    154157  currentState->normsize = (int)*(data+3*sizeof(int));
     158  std::cout << "normsize. " << currentState->normsize << std::endl;
    155159        //since the packetgenerator was changed, due to a new parameter, change this function too
    156160//      memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
    157161  currentState->diffed = (bool)*(data+4*sizeof(int));
     162  std::cout << "diffed: " << currentState->diffed << std::endl;
    158163        //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    159164        currentState->data = (unsigned char*)(malloc( currentState->compsize ));
  • code/branches/FICN/src/network/PacketGenerator.cc

    r620 r624  
    4949ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
    5050{
    51     std::cout << "generating new acknowledgement" << std::endl;
     51    std::cout << "generating new acknowledgement, id: " << state << std::endl;
    5252        ack* ackreq = new ack;
    5353        ackreq->id = ACK;
  • code/branches/FICN/src/network/Server.cc

    r620 r624  
    143143      }
    144144      std::cout << "doing gamestate" << std::endl;
    145       int id = temp->getID();
    146       std::cout << "server, got ID: " << id << std::endl;
    147       GameStateCompressed *gs = &(gamestates->popGameState(id));
    148       std::cout << "adding gamestate" << std::endl;
    149       connection->addPacket(packet_gen.gstate(gs), id);
    150       std::cout << "added gamestate" << std::endl;
     145      int gid = temp->getGamestateID();
     146      int cid = temp->getID();
     147      std::cout << "server, got acked ID: " << gid << std::endl;
     148      GameStateCompressed *gs = &(gamestates->popGameState(cid));
     149      //std::cout << "adding gamestate" << std::endl;
     150      connection->addPacket(packet_gen.gstate(gs), cid);
     151      //std::cout << "added gamestate" << std::endl;
    151152      added=true;
    152153      temp=temp->next();
     
    159160 
    160161  void Server::processAck( ack *data, int clientID){
    161     clients->findClient(clientID)->setGamestateID(data->id);
     162    clients->findClient(clientID)->setGamestateID(data->a);
    162163  }
    163164 
Note: See TracChangeset for help on using the changeset viewer.