Changeset 1005
- Timestamp:
- Apr 9, 2008, 8:38:52 PM (17 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/GameStateClient.cc
r984 r1005 33 33 namespace network 34 34 { 35 struct GameStateItem{ 36 GameState *state; 37 int id; 38 }; 39 35 40 GameStateClient::GameStateClient() { 36 41 } … … 41 46 bool GameStateClient::pushGameState(GameStateCompressed *compstate) { 42 47 GameState *gs; 43 if(compstate->diffed) 44 gs = decode(reference, compstate); 48 if(compstate->diffed){ 49 while(compstate->base_id > gameStateList.front()->id){ 50 // clean up old gamestates 51 free(gameStateList.front()->data); 52 // TODO: critical section 53 delete gameStateList.front(); 54 gameStateList.pop(); 55 } 56 if(compstate->base_id!=gameStateList.front()->id){ 57 COUT(4) << "pushGameState: no reference found to diff" << std::endl; 58 return false; 59 } 60 gs = decode(gameStateList.front(), compstate); 61 } 45 62 else 46 63 gs = decode(compstate); … … 197 214 GameState *GameStateClient::decode(GameState *a, GameStateCompressed *x) { 198 215 GameState *t = decompress(x); 216 gameStateList.push(t); 199 217 return undiff(a, t); 200 218 } … … 202 220 GameState *GameStateClient::decode(GameStateCompressed *x) { 203 221 GameState *t = decompress(x); 222 gameStateList.push(t); 204 223 return t; 205 224 } -
code/branches/network/src/network/GameStateClient.h
r984 r1005 13 13 #define _GameStateClient_H__ 14 14 15 #include <queue> 16 15 17 #include "NetworkPrereqs.h" 16 #include " GameStateManager.h"18 #include "PacketTypes.h" 17 19 18 20 namespace network … … 36 38 void removeObject(orxonox::Iterator<Synchronisable> &it); 37 39 38 GameState *reference; 40 GameState *reference; 41 std::queue<GameState *> gameStateList; 39 42 }; 40 43 -
code/branches/network/src/network/GameStateManager.cc
r986 r1005 64 64 ++id; 65 65 return; 66 } 67 68 void GameStateManager::cleanup(){ 69 /*unsigned int min_id=-1; 70 int temp_id=0; 71 ClientInformation *temp = head_; 72 while(temp){ 73 if(temp->head) 74 continue; 75 temp_id=temp->getID(); 76 if(temp_id<min_id) 77 min_id=temp_id; 78 temp=temp->next(); 79 }*/ // probably not very efficient 80 81 std::map<int,int>::iterator it = gameStateUsed.begin(); 82 while(it!=gameStateUsed.end()){ 83 if( (*it).second <= 0 ){ 84 free(gameStateMap[(*it).first]->data); 85 delete gameStateMap[(*it).first]; 86 gameStateMap.erase((*it).first); 87 gameStateUsed.erase(it++); 88 }else 89 it++; 90 } 66 91 } 67 92 -
code/branches/network/src/network/GameStateManager.h
r984 r1005 47 47 //#### END TESTING PURPOSE #### 48 48 void update(); 49 void cleanup(); // "garbage handler" 49 50 GameStateCompressed *popGameState(int clientID); 50 51 void ackGameState(int clientID, int gamestateID);
Note: See TracChangeset
for help on using the changeset viewer.