Changeset 290
- Timestamp:
- Nov 28, 2007, 12:08:09 AM (17 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/GameStateManager.cc
r247 r290 22 22 } 23 23 24 GameState GameStateManager::getSnapshot(){ 24 GameState GameStateManager::getSnapshot() 25 { 25 26 26 27 } 27 28 28 bool GameStateManager::loadSnapshot(GameState state){ 29 bool GameStateManager::loadSnapshot(GameState state) 30 { 29 31 30 32 } -
code/branches/network/src/network/PacketDecoder.cc
r237 r290 40 40 return true; 41 41 break; 42 case GAMESTATE: 43 gstate( packet ); 44 return true; 45 break; 42 46 } 43 47 return false; … … 77 81 } 78 82 83 void PacketDecoder::gstate( ENetPacket* packet ) 84 { 85 GameState* currentState = new GameState; 86 unsigned char* data = (unsigned char*)packet->data; 87 memcpy( (void*)&(currentState->size), (const void*)(data+sizeof( int )), sizeof(int) ); 88 memcpy( (void*)(currentState->data), (const void*)(data+2*sizeof( int )), currentState->size ); 89 } 90 79 91 //these are some print functions for test stuff 80 92 … … 100 112 { 101 113 cout << "data id: " << data->id << endl; 102 cout << "blablabla" << endl;103 114 cout << "data: " << data->message << endl; 104 115 } 116 117 void PacketDecoder::printGamestate( GameState* data ) 118 { 119 cout << "size of gamestate: " << data->size << endl; 120 } -
code/branches/network/src/network/PacketGenerator.cc
r223 r290 68 68 } 69 69 70 /*### gamestate packet */ 71 ENetPacket* PacketGenerator::gstate( GameState* states, int reliable ) 72 { 73 int* gid; *gid = GAMESTATE; 74 int totalLen = sizeof( int ) + states->size; 75 unsigned char* data = (unsigned char*)malloc( totalLen ); 76 memcpy( (void*)(data), (const void*)gid, sizeof( int ) ); 77 memcpy( (void*)(data+sizeof( int )), (const void*)states->data, states->size ); 78 ENetPacket *packet = enet_packet_create( data , totalLen, reliable ); 79 80 return packet; 81 } -
code/branches/network/src/network/PacketManager.h
r223 r290 3 3 4 4 #include <enet/enet.h> 5 #include <network/GameStateManager.h> 5 6 6 7 //enum netowk generaly used to set the type ID of a packet … … 11 12 MOUSE, 12 13 KEYBOARD, 13 CHAT 14 CHAT, 15 GAMESTATE 14 16 }; 15 17 … … 29 31 ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE ); 30 32 ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE ); 33 ENetPacket* gstate( GameState* states, int reliable = ENET_PACKET_FLAG_RELIABLE ); 31 34 private: 32 35 //used to set the bytes in the right order … … 87 90 void keystrike( ENetPacket* packet ); 88 91 void chatMessage( ENetPacket* packet ); 92 void gstate( ENetPacket* packet ); 89 93 90 94 //print functions … … 93 97 void printKey( keyboard* data ); 94 98 void printChat( chat* data ); 95 void print Peer( ENetPeer* peer);99 void printGamestate( GameState* data ); 96 100 }; 97 101 }
Note: See TracChangeset
for help on using the changeset viewer.