Changeset 1446 for code/branches/network/src/network
- Timestamp:
- May 28, 2008, 5:30:11 AM (16 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/GameStateClient.cc
r1432 r1446 42 42 int id; 43 43 }; 44 44 45 45 GameStateClient::GameStateClient() { 46 46 COUT(5) << "this: " << this << std::endl; … … 96 96 return false; 97 97 } 98 98 99 99 GameStateCompressed *GameStateClient::popPartialGameState(){ 100 100 GameState *gs = getPartialSnapshot(); … … 104 104 return cgs; 105 105 } 106 106 107 107 void GameStateClient::addGameState(GameStateCompressed *gs){ 108 108 if(tempGameState_!=NULL){ … … 128 128 return GAMESTATEID_INITIAL; 129 129 } 130 130 131 131 132 132 /** … … 193 193 } 194 194 if( !no->create() ) 195 { 195 196 COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl; 197 } 196 198 it=orxonox::ObjectList<Synchronisable>::end(); 197 199 } … … 199 201 // we have our object 200 202 if(! it->updateData(sync)) 203 { 201 204 COUT(1) << "We couldn't update objectID: " \ 202 205 << sync.objectID << "; classID: " << sync.classID << std::endl; 206 } 203 207 } 204 208 ++it; … … 272 276 return retval; 273 277 } 274 275 278 279 276 280 GameState *GameStateClient::undiff(GameState *old, GameState *diff) { 277 281 if(!old || !diff) … … 334 338 switch ( retval ) { 335 339 case Z_OK: COUT(5) << "G.St.Cl: compress: successfully compressed" << std::endl; break; 336 case Z_MEM_ERROR: COUT(1) << "G.St.Cl: compress: not enough memory available in gamestate.compress" << std::endl; 340 case Z_MEM_ERROR: COUT(1) << "G.St.Cl: compress: not enough memory available in gamestate.compress" << std::endl; 337 341 return NULL; 338 342 case Z_BUF_ERROR: COUT(2) << "G.St.Cl: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; … … 352 356 return compressedGamestate; 353 357 } 354 355 358 359 356 360 GameState *GameStateClient::decompress(GameStateCompressed *a) { 357 361 //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl; … … 409 413 return t; 410 414 } 411 415 412 416 void GameStateClient::cleanup(){ 413 417 std::map<int, GameState*>::iterator temp, it = gameStateMap.begin(); … … 431 435 } 432 436 COUT(4) << std::endl; 433 434 } 435 437 438 } 439 436 440 bool GameStateClient::saveShipCache(){ 437 441 if(myShip_==NULL) … … 448 452 return false; 449 453 } 450 454 451 455 bool GameStateClient::loadShipCache(){ 452 456 if(myShip_){ … … 459 463 return false; 460 464 } 461 465 462 466 //##### ADDED FOR TESTING PURPOSE ##### 463 467 GameState* GameStateClient::testDecompress( GameStateCompressed* gc ) { 464 468 return decompress( gc ); 465 469 } 466 470 467 471 GameState* GameStateClient::testUndiff( GameState* g_old, GameState* g_diffed ) { 468 472 return undiff( g_old, g_diffed ); 469 473 } 470 474 //##### ADDED FOR TESTING PURPOSE ##### 471 472 475 476 473 477 } 474 478 -
code/branches/network/src/network/PacketDecoder.cc
r1440 r1446 84 84 return false; 85 85 } 86 86 87 87 bool PacketDecoder::testAndRemoveCRC(ENetPacket *packet){ 88 88 uint32_t submittetcrc; … … 102 102 return false; 103 103 } 104 104 105 105 // ATTENTION: TODO watch, that arguments we pass over to the processFunction gets deleted in THE PROCESSXXX function 106 106 … … 118 118 enet_packet_destroy( packet ); 119 119 } 120 120 121 121 bool PacketDecoder::command( ENetPacket* packet, int clientId ){ 122 122 int length = *(int*)((unsigned char *)packet->data+sizeof(int)); … … 175 175 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 176 176 if(currentState->compsize==0) 177 { 177 178 COUT(2) << "PacketDecoder: compsize is 0" << std::endl; 179 } 178 180 // currentState->data = (unsigned char*)(malloc( currentState->compsize )); 179 181 if(currentState->compsize==0) … … 181 183 currentState->data = new unsigned char[currentState->compsize]; 182 184 if(currentState->data==NULL) 185 { 183 186 COUT(2) << "PacketDecoder: Gamestatepacket-decoder: memory leak" << std::endl; 187 } 184 188 //copy the GameStateCompressed data 185 189 memcpy( (void*)(currentState->data), (const void*)(packet->data+5*sizeof( int ) + 2*sizeof(bool)), currentState->compsize ); … … 206 210 processClassid(cid); 207 211 } 208 209 212 213 210 214 bool PacketDecoder::decodeWelcome( ENetPacket* packet, int clientID ){ 211 215 welcome *w = new welcome; … … 217 221 return processWelcome(w); 218 222 } 219 223 220 224 bool PacketDecoder::decodeConnectRequest( ENetPacket *packet, int clientID ){ 221 225 connectRequest *con = new connectRequest; … … 256 260 return; 257 261 } 258 262 259 263 bool PacketDecoder::processWelcome( welcome *w ){ 260 264 delete w; 261 265 return true; 262 266 } 263 267 264 268 bool PacketDecoder::processConnectRequest( connectRequest *con, int clientID ){ 265 269 COUT(3) << "packetdecoder: processing connectRequest" << std::endl; … … 280 284 { 281 285 if(clientId!=CLIENTID_CLIENT) 286 { 282 287 COUT(5) << "client: " << clientId << std::endl; 288 } 283 289 COUT(5) << "data id: " << data->id << std::endl; 284 290 COUT(5) << "data: " << data->message << std::endl; -
code/branches/network/src/network/dummyclient3.cc
r1293 r1446 51 51 Client client( str, PORT ); 52 52 if ( client.establishConnection() ) 53 { 53 54 COUT(3) << "connection established" << std::endl; 54 else COUT(0) << "problems establishing connection" << std::endl; 55 } 56 else 57 { 58 COUT(0) << "problems establishing connection" << std::endl; 59 } 55 60 char message[10000]; 56 61 char signs[] = "abcdefghijklmnopqrstuvwxy";
Note: See TracChangeset
for help on using the changeset viewer.