Changeset 624
- Timestamp:
- Dec 18, 2007, 7:05:51 PM (17 years ago)
- Location:
- code/branches/FICN/src/network
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/Client.cc
r620 r624 190 190 void Client::processGamestate( GameStateCompressed *data){ 191 191 gamestate.pushGameState(data); 192 std::cout << "received gamestate id: " << data->id << std::endl; 192 193 client_connection.addPacket(pck_gen.acknowledgement(data->id)); 193 194 client_connection.sendPackets(); -
code/branches/FICN/src/network/GameStateClient.cc
r620 r624 145 145 int normsize = a.normsize; 146 146 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 ); 148 153 int retval; 149 154 uLongf length=normsize; -
code/branches/FICN/src/network/GameStateManager.cc
r620 r624 61 61 GameStateCompressed GameStateManager::popGameState(int clientID){ 62 62 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; 64 64 if(gID!=GAMESTATEID_INITIAL){ 65 65 GameState *client = gameStateMap[gID]; 66 66 GameState *server = reference; 67 //head_->findClient(clientID)->setGamestateID(id); 67 68 return encode(client, server); 68 69 } else { 69 70 GameState *server = reference; 70 head_->findClient(clientID)->setGamestateID(id);71 //head_->findClient(clientID)->setGamestateID(id); 71 72 return encode(server); 72 73 // return an undiffed gamestate and set appropriate flags … … 95 96 GameState *retval=new GameState; //return value 96 97 retval->id=id++; 98 std::cout << "producing gamestate with id: " << retval->id << std::endl; 97 99 // reserve a little memory and increase it later on 98 100 //COUT(2) << "mallocing" << std::endl; … … 193 195 compressedGamestate.compsize = buffer; 194 196 compressedGamestate.normsize = size; 195 compressedGamestate.id = GAMESTATE;197 compressedGamestate.id = a->id; 196 198 compressedGamestate.data = dest; 197 199 compressedGamestate.diffed = a->diffed; -
code/branches/FICN/src/network/GameStateManager.h
r496 r624 49 49 GameStateCompressed popGameState(int clientID); 50 50 void ackGameState(int clientID, int gamestateID); 51 int id; 51 52 private: 52 53 GameState *getSnapshot(int id); … … 60 61 std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate 61 62 GameState *reference; 62 int id;63 63 ClientInformation *head_; 64 64 }; -
code/branches/FICN/src/network/PacketDecoder.cc
r620 r624 89 89 90 90 91 std::cout << "got ack id: " << a->id << std::endl; 91 92 processAck( a, clientId ); //debug info 92 93 … … 146 147 //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) ); 147 148 currentState->id = (int)*(data+sizeof(int)); 149 std::cout << "id: " << currentState->id << std::endl; 148 150 //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th 149 151 //position of the data stream, data+2*sizeof( int ) 150 152 // memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) ); 151 153 currentState->compsize = (int)*(data+2*sizeof(int)); 154 std::cout << "compsize: " << currentState->compsize << std::endl; 152 155 //size of uncompressed data 153 156 // memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) ); 154 157 currentState->normsize = (int)*(data+3*sizeof(int)); 158 std::cout << "normsize. " << currentState->normsize << std::endl; 155 159 //since the packetgenerator was changed, due to a new parameter, change this function too 156 160 // memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool)); 157 161 currentState->diffed = (bool)*(data+4*sizeof(int)); 162 std::cout << "diffed: " << currentState->diffed << std::endl; 158 163 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 159 164 currentState->data = (unsigned char*)(malloc( currentState->compsize )); -
code/branches/FICN/src/network/PacketGenerator.cc
r620 r624 49 49 ENetPacket* PacketGenerator::acknowledgement( int state, int reliable ) 50 50 { 51 std::cout << "generating new acknowledgement "<< std::endl;51 std::cout << "generating new acknowledgement, id: " << state << std::endl; 52 52 ack* ackreq = new ack; 53 53 ackreq->id = ACK; -
code/branches/FICN/src/network/Server.cc
r620 r624 143 143 } 144 144 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; 151 152 added=true; 152 153 temp=temp->next(); … … 159 160 160 161 void Server::processAck( ack *data, int clientID){ 161 clients->findClient(clientID)->setGamestateID(data-> id);162 clients->findClient(clientID)->setGamestateID(data->a); 162 163 } 163 164
Note: See TracChangeset
for help on using the changeset viewer.