Changeset 1253
- Timestamp:
- May 8, 2008, 4:15:45 PM (17 years ago)
- Location:
- code/branches/network3/src/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/ClientConnection.cc
r1168 r1253 112 112 if(server==NULL) 113 113 return false; 114 if(enet_peer_send(server, 1, packet)!=0) 115 return false; 116 return true; 114 if(!packet){ 115 COUT(4) << "Cl.con: addpacket: invalid packet" << std::endl; 116 return false; 117 } 118 if(enet_peer_send(server, 0, packet)<0) 119 return false; 120 else 121 return true; 117 122 } 118 123 -
code/branches/network3/src/network/GameStateClient.cc
r1246 r1253 64 64 if(!reference){ 65 65 COUT(4) << "pushGameState: no reference found to diff" << std::endl; 66 delete[] compstate->data; 67 delete compstate; 66 68 return false; 67 69 } … … 89 91 GameStateCompressed *GameStateClient::popPartialGameState(){ 90 92 GameState *gs = getPartialSnapshot(); 91 return compress_(gs); 93 GameStateCompressed *cgs = compress_(gs); 94 delete[] gs->data; 95 delete gs; 96 return cgs; 92 97 } 93 98 … … 166 171 167 172 GameState *GameStateClient::getPartialSnapshot(){ 168 169 GameState *reference;170 // std::map<int, GameState*>::iterator it = --gameStateMap.end();171 // reference=(--gameStateMap.end())->second;172 173 173 //std::cout << "begin getSnapshot" << std::endl; 174 174 //the size of the gamestate … … 306 306 compressedGamestate->complete = a->complete; 307 307 compressedGamestate->base_id = a->base_id; 308 delete[] a->data;309 delete a;310 308 return compressedGamestate; 311 309 } … … 344 342 gamestate->complete = a->complete; 345 343 346 delete[] a->data; //delete compressed data347 delete a; //we do not need the old (struct) gamestate anymore348 344 349 345 return gamestate; … … 353 349 COUT(4) << "using diffed gamestate" << std::endl; 354 350 GameState *t = decode(diff); 355 return undiff(old, t); 356 // return t; 351 GameState *r = undiff(old, t); 352 delete[] t->data; 353 delete t; 354 return r; 357 355 } 358 356 359 357 GameState *GameStateClient::decode(GameStateCompressed *x) { 360 358 GameState *t = decompress(x); 361 /*GameState *t = new GameState; 362 t->base_id = x->base_id; 363 t->id = x->id; 364 t->diffed = x->diffed; 365 t->data = x->data; 366 t->size = x->normsize;*/ 359 delete[] x->data; 360 delete x; 367 361 return t; 368 362 } -
code/branches/network3/src/network/GameStateManager.cc
r1251 r1253 129 129 bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){ 130 130 GameState *ugs = decompress(gs); 131 return loadPartialSnapshot(ugs, clientID); 132 131 delete[] gs->data; 132 delete gs; 133 bool result = loadPartialSnapshot(ugs, clientID); 134 delete[] ugs->data; 135 delete ugs; 136 return result; 133 137 } 134 138 … … 261 265 } 262 266 263 delete[] state->data;264 delete state;265 267 return true; 266 268 } … … 280 282 COUT(4) << "G.St.Man: this will be a DIFFED gamestate" << std::endl; 281 283 GameState *r = diff(a,b); 282 // r->diffed = true; 283 // GameState *r = b; 284 // r->diffed = false; 285 return compress_(r); 286 /*GameStateCompressed *g = new GameStateCompressed; 287 g->base_id = r->base_id; 288 g->id = r->id; 289 g->diffed = r->diffed; 290 g->data = r->data; 291 g->normsize = r->size; 292 g->compsize = r->size; 293 return g*/; 284 GameStateCompressed *c = compress_(r); 285 delete[] r->data; 286 delete r; 287 return c; 294 288 } 295 289 296 290 GameStateCompressed *GameStateManager::encode(GameState *a) { 297 291 COUT(5) << "G.St.Man: encoding gamestate (compress)" << std::endl; 292 a->base_id=GAMESTATEID_INITIAL; 298 293 return compress_(a); 299 294 /*GameStateCompressed *g = new GameStateCompressed; -
code/branches/network3/src/network/Server.cc
r1248 r1253 223 223 224 224 void Server::processAck( ack *data, int clientID) { 225 COUT(4) << " Server: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;225 COUT(4) << "\b\b\b\n\n\n\n\nServer: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl; 226 226 gamestates->ackGameState(clientID, data->a); 227 227 delete data; … … 240 240 if(!gamestates->pushGameState(data, clientID)) 241 241 COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl; 242 delete[] data->data;243 delete data;244 242 } 245 243
Note: See TracChangeset
for help on using the changeset viewer.