Changeset 1712
- Timestamp:
- Sep 6, 2008, 1:39:51 PM (16 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/GamestateClient.cc
r1707 r1712 74 74 int id = GAMESTATEID_INITIAL; 75 75 bool b = saveShipCache(); 76 if( tempGamestate_->spreadData()){76 if(processGamestate(tempGamestate_)){ 77 77 if(b) 78 78 loadShipCache(); … … 151 151 } 152 152 153 bool GamestateClient::processGamestate(packet::Gamestate *gs){ 154 assert(gs->decompressData()); 155 if(gs->isDiffed()) 156 assert(gs->undiff(gamestateMap_[gs->getBaseID()])); 157 return gs->spreadData(); 158 } 153 159 154 160 } -
code/branches/network/src/network/GamestateClient.h
r1707 r1712 66 66 void cleanup(); 67 67 private: 68 bool processGamestate(packet::Gamestate *gs); 68 69 void removeObject(orxonox::Iterator<Synchronisable> &it); 69 70 void printGamestateMap(); -
code/branches/network/src/network/GamestateManager.cc
r1705 r1712 81 81 // now push only the most recent gamestates we received (ignore obsolete ones) 82 82 for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){ 83 it->second->spreadData();83 assert(processGamestate(it->second)); 84 84 delete it->second; 85 85 } … … 197 197 ClientInformation::removeClient(client->getID()); 198 198 } 199 200 bool GamestateManager::processGamestate(packet::Gamestate *gs){ 201 assert(gs->decompressData()); 202 assert(!gs->isDiffed()); 203 return gs->spreadData(); 204 } 199 205 200 206 } -
code/branches/network/src/network/GamestateManager.h
r1705 r1712 82 82 private: 83 83 void cleanup(); // "garbage handler" 84 84 bool processGamestate(packet::Gamestate *gs); 85 85 86 std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate* 86 87 std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate -
code/branches/network/src/network/Server.cc
r1711 r1712 131 131 bool Server::sendChat(packet::Chat *chat) { 132 132 //TODO: change this (no informations about who wrote a message) 133 assert(0); 133 134 ClientInformation *temp = ClientInformation::getBegin(); 134 135 while(temp){ … … 321 322 w->setClientID(temp->getID()); 322 323 assert(w->send()); 323 delete w;324 324 return true; 325 325 } -
code/branches/network/src/network/packet/Chat.cc
r1711 r1712 44 44 messageLength_ = message.length()+1; 45 45 data_=new unsigned char[ getSize() ]; 46 *(ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::Chat;46 *(ENUM::Type *)&data_[ _PACKETID ] = ENUM::Chat; 47 47 *(unsigned int *)&data_[ _MESSAGELENGTH ] = messageLength_; 48 48 memcpy( &data_[ _MESSAGE ], (void *)message.c_str(), messageLength_ ); -
code/branches/network/src/network/packet/ClassID.cc
r1711 r1712 51 51 data_=new unsigned char[ getSize() ]; 52 52 assert(data_); 53 *( packet::ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::ClassID;53 *(ENUM::Type *)&data_[ _PACKETID ] = ENUM::ClassID; 54 54 *(unsigned int *)&data_[ _CLASSID ] = classID; 55 55 *(unsigned int *)&data_[ _CLASSNAMELENGTH ] = classNameLength_; -
code/branches/network/src/network/packet/Gamestate.cc
r1711 r1712 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 /* 20 2 * ORXONOX - the hottest 3D action shooter ever to exist … … 124 106 //start write gamestate header 125 107 HEADER->packetType = ENUM::Gamestate; 108 assert( *(ENUM::Type *)&data_[ 0 ] == ENUM::Gamestate); 126 109 HEADER->normsize = currentsize; 127 110 HEADER->id = id; … … 230 213 bool Gamestate::decompressData() 231 214 { 215 assert(compressed_); 232 216 //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl; 233 217 int normsize = HEADER->normsize; … … 256 240 *GAMESTATE_HEADER(ndata) = *HEADER; 257 241 //delete old (compressed data) 258 delete []data_;242 delete[] data_; 259 243 //set new pointers and create bytestream 260 244 data_ = ndata; … … 349 333 } 350 334 351 } 352 353 } 335 bool Gamestate::isDiffed(){ 336 return HEADER->diffed; 337 } 338 339 int Gamestate::getBaseID(){ 340 return HEADER->base_id; 341 } 342 } 343 344 } -
code/branches/network/src/network/packet/Gamestate.h
r1711 r1712 62 62 bool spreadData(int mode=0x0); 63 63 int getID(); 64 bool isDiffed(); 65 int getBaseID(); 64 66 Gamestate *diff(Gamestate *base); 65 67 Gamestate *undiff(Gamestate *base); -
code/branches/network/src/network/packet/Packet.cc
r1711 r1712 60 60 } 61 61 62 void blub(ENetPacket *packet){ 63 COUT(0) << "blubb" << std::endl; 64 } 65 62 66 Packet::Packet(unsigned char *data, int clientID){ 63 67 flags_ = PACKET_FLAG_DEFAULT; … … 73 77 clientID_ = ClientInformation::findClient(&peer->address)->getID(); 74 78 data_ = packet->data; 75 enet_packet_destroy(packet);76 79 } 77 80 78 81 Packet::Packet(const Packet &p){ 82 enetPacket_=p.enetPacket_; 79 83 flags_=p.flags_; 80 84 if(p.data_){ … … 93 97 94 98 bool Packet::send(){ 95 if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ) 99 /*if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){ 100 assert(0); 96 101 return false; 102 }*/ 97 103 if(!enetPacket_){ 98 if(!data_) 104 if(!data_){ 105 assert(0); 99 106 return false; 107 } 100 108 enetPacket_ = enet_packet_create(getData(), getSize(), getFlags()); 101 enetPacket_->freeCallback = & Packet::deletePacket;109 enetPacket_->freeCallback = &blub; 102 110 packetMap_[enetPacket_] = this; 103 111 }
Note: See TracChangeset
for help on using the changeset viewer.