Changeset 7780 for code/branches
- Timestamp:
- Dec 19, 2010, 9:41:57 PM (14 years ago)
- Location:
- code/branches/network5/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network5/src/libraries/network/Client.h
r7777 r7780 80 80 bool closeConnection(); 81 81 void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID); 82 virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); } 82 83 bool processChat(const std::string& message, unsigned int playerID); 83 84 virtual bool chat(const std::string& message); -
code/branches/network5/src/libraries/network/Connection.cc
r7777 r7780 82 82 void Connection::disconnectPeer(ENetPeer *peer) 83 83 { 84 assert(peer); 84 85 outgoingEvent outEvent = { peer, outgoingEventType::disconnectPeer, (ENetPacket*)10, 15 }; 85 86 … … 91 92 void Connection::addPacket(ENetPacket *packet, ENetPeer *peer, uint8_t channelID) 92 93 { 94 assert(peer); 93 95 outgoingEvent outEvent = { peer, outgoingEventType::sendPacket, packet, channelID }; 94 96 … … 100 102 void Connection::broadcastPacket(ENetPacket* packet, uint8_t channelID) 101 103 { 102 outgoingEvent outEvent = { 0, outgoingEventType::broadcastPacket, packet, channelID };104 outgoingEvent outEvent = { (ENetPeer*)15, outgoingEventType::broadcastPacket, packet, channelID }; 103 105 104 106 this->outgoingEventsMutex_->lock(); -
code/branches/network5/src/libraries/network/GamestateManager.cc
r7777 r7780 110 110 bool b = processGamestate(it->second); 111 111 assert(b); 112 sendAck( it->second->getID(), it->second->getPeerID() ); 112 113 delete it->second; 113 114 } … … 117 118 NetworkCallbackManager::callCallbacks(); 118 119 return true; 120 } 121 122 bool GamestateManager::sendAck(unsigned int gamestateID, uint32_t peerID) 123 { 124 packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, peerID); 125 if( !this->sendPacket(ack)) 126 { 127 COUT(3) << "could not ack gamestate: " << gamestateID << std::endl; 128 return false; 129 } 130 else 131 { 132 COUT(5) << "acked a gamestate: " << gamestateID << std::endl; 133 return true; 134 } 119 135 } 120 136 … … 173 189 peerGamestates.push_back(0); // insert an empty gamestate* to change 174 190 finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ ); 191 if( peerGamestates.back()==0 ) 192 // nothing to send to remove pointer from vector 193 peerGamestates.pop_back(); 175 194 //FunctorMember<GamestateManager>* functor = 176 195 // ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) ); … … 236 255 237 256 238 bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID) { 257 bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID) 258 { 239 259 // ClientInformation *temp = ClientInformation::findClient(peerID); 240 260 // assert(temp); … … 255 275 } 256 276 257 assert(curid==GAMESTATEID_INITIAL || curid< gamestateID);277 assert(curid==GAMESTATEID_INITIAL || curid<=gamestateID); 258 278 COUT(5) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl; 259 279 std::map<uint32_t, packet::Gamestate*>::iterator it2; -
code/branches/network5/src/libraries/network/GamestateManager.h
r7777 r7780 90 90 91 91 bool processGamestates(); 92 bool sendAck(unsigned int gamestateID, uint32_t peerID); 92 93 bool update(); 93 94 std::vector<packet::Gamestate*> getGamestates(); … … 101 102 void removePeer( uint32_t peerID ); 102 103 // void removeClient(ClientInformation *client); 104 protected: 105 virtual bool sendPacket( packet::Packet* packet ) = 0; 103 106 private: 104 107 bool processGamestate(packet::Gamestate *gs); -
code/branches/network5/src/libraries/network/Server.cc
r7777 r7780 360 360 else 361 361 { 362 GamestateManager::removePeer(client->getID()); 362 363 //ServerConnection::disconnectClient( client ); 363 364 //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now -
code/branches/network5/src/libraries/network/Server.h
r7777 r7780 67 67 bool processChat(const std::string& message, unsigned int playerID); 68 68 void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID); 69 virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); } 69 70 void update(const Clock& time); 70 71 unsigned int getRTT(unsigned int clientID); -
code/branches/network5/src/libraries/network/packet/FunctionCalls.cc
r7777 r7780 71 71 FunctionCall fctCall; 72 72 fctCall.loadData(temp); 73 if( this->minGamestateID_ > host->getLastProcessedGamestateID(this->getPeerID()) ||!fctCall.execute() )73 if( !fctCall.execute() ) 74 74 { 75 75 FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getPeerID() ); -
code/branches/network5/src/libraries/network/packet/Packet.cc
r7777 r7780 179 179 assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer()); 180 180 unsigned int peerID = ClientInformation::findClient(&peer->address)->getID(); 181 // HACK 182 if( peerID==static_cast<unsigned int>(-2)) 183 peerID = NETWORK_PEER_ID_SERVER; 181 184 Packet *p = 0; 182 185 // COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl; -
code/branches/network5/src/orxonox/gametypes/Gametype.cc
r7777 r7780 171 171 void Gametype::playerEntered(PlayerInfo* player) 172 172 { 173 COUT(0) << "Gametype: playerentered" << endl;174 173 this->players_[player].state_ = PlayerState::Joined; 175 174 } … … 412 411 void Gametype::spawnPlayer(PlayerInfo* player) 413 412 { 414 COUT(0) << "Gametype: spawnPlayer" << endl;415 413 SpawnPoint* spawnpoint = this->getBestSpawnPoint(player); 416 414 if (spawnpoint)
Note: See TracChangeset
for help on using the changeset viewer.