Changeset 891
- Timestamp:
- Mar 13, 2008, 4:01:48 PM (17 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/Client.cc
r790 r891 184 184 while(!(client_connection.queueEmpty())){ 185 185 packet = client_connection.getPacket(); 186 //std::cout << "tickpacket size " << packet->dataLength << std::endl;186 COUT(5) << "tick gamestate packet size " << packet->dataLength << std::endl; 187 187 elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server) 188 188 } … … 192 192 void Client::processGamestate( GameStateCompressed *data){ 193 193 gamestate.pushGameState(data); 194 std::cout<< "received gamestate id: " << data->id << std::endl;194 COUT(5) << "received gamestate id: " << data->id << std::endl; 195 195 client_connection.addPacket(pck_gen.acknowledgement(data->id)); 196 196 client_connection.sendPackets(); … … 207 207 208 208 void Client::processChat( chat *data){ 209 std::cout<< "Server: " << data->message << std::endl;209 COUT(0) << "Server: " << data->message << std::endl; 210 210 } 211 211 -
code/branches/network/src/network/ClientConnection.cc
r889 r891 43 43 44 44 #include "util/Sleep.h" 45 #include "orxonox/core/Debug.h" 45 46 #include "ClientConnection.h" 46 47 -
code/branches/network/src/network/GameStateManager.cc
r889 r891 72 72 GameState *server = reference; 73 73 //head_->findClient(clientID)->setGamestateID(id); 74 return encode(client, server);74 return *encode(client, server); 75 75 } else { 76 76 GameState *server = reference; 77 77 //head_->findClient(clientID)->setGamestateID(id); 78 return encode(server);78 return *encode(server); 79 79 // return an undiffed gamestate and set appropriate flags 80 80 } … … 142 142 } 143 143 144 GameStateCompressed GameStateManager::encode(GameState *a, GameState *b) {144 GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) { 145 145 //GameState r = diff(a,b); 146 146 //r.diffed = true; 147 GameState r = *b;148 r .diffed = false;149 return compress_( &r);150 } 151 152 GameStateCompressed GameStateManager::encode(GameState *a) {147 GameState *r = b; 148 r->diffed = false; 149 return compress_(r); 150 } 151 152 GameStateCompressed *GameStateManager::encode(GameState *a) { 153 153 a->diffed=false; 154 154 return compress_(a); 155 155 } 156 156 157 GameState GameStateManager::diff(GameState *a, GameState *b) {157 GameState *GameStateManager::diff(GameState *a, GameState *b) { 158 158 unsigned char *ap = a->data, *bp = b->data; 159 159 int of=0; // pointers offset … … 182 182 } 183 183 } 184 // should be finished now 185 // FIXME: is it true or false now? (struct has changed, producing warnings) 186 GameState r = {b->id, dest_length, true, dp}; 184 185 GameState *r = new GameState; 186 r->id = b->id; 187 r->size = dest_length; 188 r->diffed = true; 189 r->data = dp; 187 190 return r; 188 191 } 189 192 190 GameStateCompressed GameStateManager::compress_(GameState *a) {193 GameStateCompressed *GameStateManager::compress_(GameState *a) { 191 194 COUT(5) << "compressing gamestate" << std::endl; 192 195 int size = a->size; … … 199 202 200 203 switch ( retval ) { 201 case Z_OK: std::cout << "successfully compressed" << std::endl; break; 202 case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break; 203 case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break; 204 case Z_DATA_ERROR: std::cout << "decompress: data corrupted" << std::endl; break; 205 } 206 207 GameStateCompressed compressedGamestate; 208 compressedGamestate.compsize = buffer; 204 case Z_OK: COUT(5) << "successfully compressed" << std::endl; break; 205 case Z_MEM_ERROR: COUT(1) << "not enough memory available in gamestate.compress" << std::endl; 206 return NULL; 207 case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer in gamestate.compress" << std::endl; 208 return NULL; 209 case Z_DATA_ERROR: COUT(2) << "decompress: data corrupted in gamestate.compress" << std::endl; 210 return NULL; 211 } 212 213 GameStateCompressed *compressedGamestate = new GameStateCompressed; 214 compressedGamestate->compsize = buffer; 209 215 // std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl; 210 compressedGamestate .normsize = size;216 compressedGamestate->normsize = size; 211 217 // std::cout << "compressedGamestate.normsize = size; " << size << std::endl; 212 compressedGamestate .id = a->id;213 compressedGamestate .data = dest;214 compressedGamestate .diffed = a->diffed;218 compressedGamestate->id = a->id; 219 compressedGamestate->data = dest; 220 compressedGamestate->diffed = a->diffed; 215 221 216 222 return compressedGamestate; -
code/branches/network/src/network/GameStateManager.h
r790 r891 48 48 private: 49 49 GameState *getSnapshot(int id); 50 GameStateCompressed encode(GameState *a, GameState *b);51 GameStateCompressed encode(GameState *a);52 GameState diff(GameState *a, GameState *b);53 GameStateCompressed compress_(GameState *a);50 GameStateCompressed *encode(GameState *a, GameState *b); 51 GameStateCompressed *encode(GameState *a); 52 GameState *diff(GameState *a, GameState *b); 53 GameStateCompressed *compress_(GameState *a); 54 54 bool deleteUnusedGameState(int gamestateID); 55 55 -
code/branches/network/src/network/PacketDecoder.cc
r889 r891 38 38 #include "PacketTypes.h" 39 39 #include "PacketManager.h" 40 #include "orxonox/core/Debug.h" 40 41 41 42 namespace network -
code/branches/network/src/network/dummyclient3.cc
r790 r891 13 13 network::PacketGenerator pck; 14 14 const int PORT = 55556; 15 std::cout<< "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;15 COUT(0) << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl; 16 16 std::string str; 17 17 std::getline(std::cin, str); 18 std::cout<< "You entered: " << str << std::endl;18 COUT(3) << "You entered: " << str << std::endl; 19 19 if(str.compare("")==0) 20 20 str="127.0.0.1"; … … 22 22 Client client( str, PORT ); 23 23 if ( client.establishConnection() ) 24 std::cout<< "connection established" << std::endl;25 else std::cout<< "problems establishing connection" << std::endl;24 COUT(3) << "connection established" << std::endl; 25 else COUT(0) << "problems establishing connection" << std::endl; 26 26 char message[10000]; 27 27 char signs[] = "abcdefghijklmnopqrstuvwxy";
Note: See TracChangeset
for help on using the changeset viewer.