Changeset 11990 for code/branches/Masterserver_FS18
- Timestamp:
- May 24, 2018, 3:24:00 PM (7 years ago)
- Location:
- code/branches/Masterserver_FS18/src/libraries/network
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Masterserver_FS18/src/libraries/network/ClientConnection.cc
r11071 r11990 105 105 { 106 106 // manually add server to list of peers 107 /*incomingEvent inEvent = */Connection::preprocessConnectEvent(event);108 // addPeer(inEvent.peerID); 107 Connection::preprocessConnectEvent(event); 108 109 109 // start communication thread 110 110 this->established_=true; … … 155 155 assert( this->server_ ); 156 156 assert( packet ); 157 // return Connection::addPacket( packet, NETWORK_PEER_ID_SERVER, channelID );158 157 // HACK: actually there should be a way to do this using addPacket and the correct peerID 159 158 return Connection::broadcastPacket(packet, channelID); … … 168 167 this->established_=false; 169 168 orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl; 170 169 // server closed the connection 171 170 this->stopCommunicationThread(); 172 171 this->connectionClosed(); -
code/branches/Masterserver_FS18/src/libraries/network/ClientConnection.h
r11842 r11990 44 44 void setPort( unsigned int port ); 45 45 46 // ENetEvent *getEvent();47 // check wheter the packet queue is empty48 // bool queueEmpty();49 46 // create a new listener thread 50 47 virtual bool establishConnection(); -
code/branches/Masterserver_FS18/src/libraries/network/Connection.cc
r11880 r11990 72 72 delete this->incomingEventsMutex_; 73 73 delete this->outgoingEventsMutex_; 74 75 // TODO: Why is enet_deinitialize() not called here?76 // Would make sense, since its counterpart, enet_initialize(), is called in the constructor.77 74 } 78 75 … … 172 169 173 170 // Sleep for 1ms 174 // TODO: Why?175 171 msleep(1); 176 172 177 173 // Send all waiting outgoing packets 178 // TODO: Why do we need a mutex to read a single variable?179 174 this->outgoingEventsMutex_->lock(); 180 175 uint32_t outgoingEventsCount = this->outgoingEvents_.size(); 181 176 this->outgoingEventsMutex_->unlock(); 182 177 183 // TODO: Not convinced about how mutexes are used here, seems kinda pointless184 178 while(outgoingEventsCount > 0) 185 179 { … … 406 400 } 407 401 408 409 402 } -
code/branches/Masterserver_FS18/src/libraries/network/FunctionCallManager.cc
r11842 r11990 62 62 for (const auto& mapEntry : FunctionCallManager::sPeerMap_ ) 63 63 { 64 // TODO: This seems rather pointless, as it wouldn't be called anyways if the map was empty.65 64 assert(!FunctionCallManager::sPeerMap_.empty()); 66 65 mapEntry.second->send(host); 67 66 } 68 // TODO: Why is the map cleared here?69 67 FunctionCallManager::sPeerMap_.clear(); 70 68 } -
code/branches/Masterserver_FS18/src/libraries/network/FunctionCallManager.h
r11842 r11990 56 56 static std::map<uint32_t, packet::FunctionCalls*> sPeerMap_; 57 57 58 // TODO: What's up with the pair within the pair?59 // Vector of pairs60 // The pair consists of the FunctionCall and another pair, which...61 58 static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t>>> sIncomingFunctionCallBuffer_; 62 59 -
code/branches/Masterserver_FS18/src/libraries/network/GamestateManager.cc
r11937 r11990 86 86 bool GamestateManager::update() 87 87 { 88 return getSnapshot();88 return this->getSnapshot(); 89 89 } 90 90 … … 119 119 for(const auto& gsPair : this->gamestateQueue) 120 120 { 121 OrxVerify( processGamestate(gsPair.second), "ERROR: could not process Gamestate");122 sendAck(gsPair.second->getID(), gsPair.second->getPeerID());121 OrxVerify(this->processGamestate(gsPair.second), "ERROR: could not process Gamestate"); 122 this->sendAck(gsPair.second->getID(), gsPair.second->getPeerID()); 123 123 delete gsPair.second; 124 124 } … … 214 214 215 215 std::vector<packet::Gamestate*> peerGamestates; 216 // TODO: mapEntry is an incredibly bad name217 216 for(const auto& mapEntry : this->peerMap_) 218 217 { … … 256 255 257 256 // Create a copy of the gamestate 258 // TODO: Does this actually create a copy of the gamestate?259 257 packet::Gamestate *gs = new packet::Gamestate(*gamestate); //this is neccessary because the gamestate are being kept (to diff them later on) for each client seperately 260 258 this->peerMap_[peerID].gamestates[gamestate->getID()] = gs; -
code/branches/Masterserver_FS18/src/libraries/network/GamestateManager.h
r11842 r11990 111 111 bool processGamestate(packet::Gamestate *gs); 112 112 113 // TODO: What is the purpose of the gamestateQueue?114 113 std::map<unsigned int, packet::Gamestate*> gamestateQueue; 115 114 -
code/branches/Masterserver_FS18/src/libraries/network/Host.cc
r11829 r11990 54 54 Host::instances_s.push_back(this); 55 55 56 // TODO: What does this do?57 56 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this); 58 57 -
code/branches/Masterserver_FS18/src/libraries/network/LANDiscoverable.cc
r11071 r11990 121 121 info.setClientNumber(this->clientNumber); 122 122 info.send(event.peer); 123 // ENetPacket* packet = enet_packet_create( LAN_DISCOVERY_ACK, strlen(LAN_DISCOVERY_ACK)+1, ENET_PACKET_FLAG_RELIABLE );124 // enet_peer_send(event.peer, 0, packet );125 123 enet_host_flush(this->host_); 126 124 } -
code/branches/Masterserver_FS18/src/libraries/network/LANDiscoverable.h
r10622 r11990 43 43 void setActivity( bool bActive ); 44 44 void update(); 45 void updateClientNumber(int clientNumber) {this->clientNumber = clientNumber;} 46 ; 45 void updateClientNumber(int clientNumber) { this->clientNumber = clientNumber; } 47 46 /** Function used for the configuration file parameter update */ 48 47 void setConfigValues(); -
code/branches/Masterserver_FS18/src/libraries/network/LANDiscovery.cc
r11071 r11990 61 61 address.port = LAN_DISCOVERY_PORT; 62 62 63 /* TODO: check for availability of each protocol */64 63 /* IPv4 */ 65 64 address.host = ENET_HOST_BROADCAST; … … 102 101 this->servers_.push_back(info); 103 102 } 104 // enet_address_get_host_ip(&event.peer->address, buffer, buflen );105 // serverIPs.push_back(std::string(buffer));106 103 break; 107 104 default: -
code/branches/Masterserver_FS18/src/libraries/network/MasterServer.cc
r11842 r11990 40 40 SetConsoleCommand( "ms-listservers", &MasterServer::listServers ); 41 41 SetConsoleCommand( "ms-delserver", &MasterServer::delServer ); 42 //SetConsoleCommand( "ms-serverinfo", &MasterServer::serverInfo );43 42 44 43 /* forward declaration so the linker doesn't complain */ -
code/branches/Masterserver_FS18/src/libraries/network/MasterServerComm.cc
r11071 r11990 38 38 * the initialize method to facilitate debugging 39 39 */ 40 /* register object in orxonox */41 40 } 42 41 … … 48 47 return 1; 49 48 } 50 51 /* initialize the event holder */52 // this->event = (ENetEvent *)calloc( sizeof(ENetEvent), 1 );53 54 49 55 50 /* initiate the client */ … … 226 221 /* One could just use enet_host_service() instead. */ 227 222 enet_host_flush( this->client ); 228 229 /* free the packet */230 // PLEASE: never do this, because enet will free the packet once it's delivered. this will cause double frees231 // enet_packet_destroy( packet );232 223 233 224 /* all done. */ … … 248 239 /* One could just use enet_host_service() instead. */ 249 240 enet_host_flush( this->client ); 250 // PLEASE: never do this, because enet will free the packet once it's delivered. this will cause double frees251 // enet_packet_destroy( packet );252 241 253 242 /* all done. */ -
code/branches/Masterserver_FS18/src/libraries/network/Server.cc
r11829 r11990 167 167 { 168 168 timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD; 169 updateGamestate();169 this->updateGamestate(); 170 170 } 171 171 } … … 178 178 179 179 /** 180 * Returnping time to client in milliseconds.181 */ 182 unsigned int Server::getRTT(unsigned int clientID)180 * Print ping time to client in milliseconds. 181 */ 182 void Server::printRTT() 183 183 { 184 184 // TODO: Implement 185 return 0;186 }187 188 /**189 * Print ping time to client in milliseconds.190 */191 void Server::printRTT()192 {193 // TODO: Implement194 }195 196 /**197 * Return packet loss ratio to client (scales from 0 to 1).198 */199 float Server::getPacketLoss(unsigned int clientID)200 {201 // TODO: Implement202 return 0.;203 185 } 204 186 … … 214 196 } 215 197 GamestateManager::update(); 216 sendGameStates();217 sendObjectDeletes();198 this->sendGameStates(); 199 this->sendObjectDeletes(); 218 200 } 219 201 … … 255 237 orxout(internal_warning, context::network) << "Server: could not broadcast deleteObjects packet" << endl; 256 238 } 257 258 // TODO: Possible memory leak?259 // del is allocated but only deleted if fetchIDs() returns false260 239 261 240 return true; … … 277 256 orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl; 278 257 279 createClient(peerID);258 this->createClient(peerID); 280 259 } 281 260 … … 297 276 } 298 277 } 299 300 // TODO: What happens if no peer with this ID is found?301 // Should probably at least log302 278 303 279 WANDiscoverable::updateClientNumber(this->clientIDs_.size()); … … 339 315 340 316 // synchronise class ids 341 syncClassid(clientID);317 this->syncClassid(clientID); 342 318 343 319 // now synchronise functionIDs … … 346 322 bool b = fIDs->send(static_cast<Host*>(this)); 347 323 assert(b); 348 // TODO: assert probably isn't the way to go here, as a packet which fails to send will crash the game...349 324 350 325 GamestateManager::setSynched(clientID); … … 356 331 b = w->send(static_cast<Host*>(this)); 357 332 assert(b); 358 // TODO: assert probably isn't the way to go here, as a packet which fails to send will crash the game...359 333 360 334 (void)b; // avoid compiler warning … … 380 354 { 381 355 // check if the target exists. just ignore the message otherwise 382 if (!this->isValidTarget(targetID)) // TODO: remove this if an invalid clientIDs don't trigger assertions anymore356 if (!this->isValidTarget(targetID)) 383 357 { 384 358 return; … … 434 408 packet::ClassID *classid = new packet::ClassID(); 435 409 classid->setPeerID(clientID); 436 // TODO: Better to do this with a for loop 410 437 411 int failures = 0; 438 412 while(!classid->send(static_cast<Host*>(this)) && failures < 10)\ … … 441 415 } 442 416 assert(failures<10); 443 // TODO: assert probably isn't the way to go here, as 10 failed packets will crash the game...444 417 orxout(verbose, context::network) << "syncClassid:\tall synchClassID packets have been sent" << endl; 445 418 } -
code/branches/Masterserver_FS18/src/libraries/network/Server.h
r11071 r11990 38 38 #include "core/CorePrereqs.h" 39 39 #include "Host.h" 40 // #include "GamestateManager.h"41 40 #include "ServerConnection.h" 42 41 #include "LANDiscoverable.h" … … 62 61 void close(); 63 62 virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) override; 64 virtual bool sendPacket( packet::Packet* packet ) override { return packet->send( static_cast<Host*>(this) ); }63 virtual bool sendPacket( packet::Packet* packet ) override { return packet->send( static_cast<Host*>(this) ); } 65 64 void update(const Clock& time); 66 unsigned int getRTT(unsigned int clientID);67 65 virtual void printRTT() override; 68 float getPacketLoss(unsigned int clientID); 69 int getClientCount() { return this->clientIDs_.size();} 70 std::string getServerName() { return this->serverName_;} 66 int getClientCount() { return this->clientIDs_.size(); } 67 std::string getServerName() { return this->serverName_; } 71 68 72 69 protected: 73 70 void updateGamestate(); 74 71 private: 75 virtual bool isServer_() override {return true;}76 unsigned int playerID() {return 0;}72 virtual bool isServer_() override { return true; } 73 unsigned int playerID() { return 0; } 77 74 78 75 virtual void addPeer(uint32_t peerID) override; -
code/branches/Masterserver_FS18/src/libraries/network/ServerConnection.cc
r11829 r11990 39 39 namespace orxonox 40 40 { 41 42 // TODO: Calls to the Connection superclass are done as follows:43 // Connection::startCommunicationThread()44 // However, these methods are not overridden.45 // Why can't we just do this->startCommunicationThread()?46 47 41 /** 48 42 * Constructor … … 131 125 { 132 126 this->bListening_ = false; 133 disconnectClients();127 this->disconnectClients(); 134 128 Connection::stopCommunicationThread(); 135 129 enet_host_destroy(this->host_); … … 142 136 * @param clientID The ID of the recipient 143 137 * @param channelID The channel ID 144 * TODO: Not sure yet how this actually works145 138 */ 146 139 void ServerConnection::addPacket(ENetPacket *packet, unsigned int clientID, uint8_t channelID) … … 148 141 if (clientID == NETWORK_PEER_ID_BROADCAST) 149 142 { 150 broadcastPacket(packet, channelID);143 this->broadcastPacket(packet, channelID); 151 144 } 152 145 else -
code/branches/Masterserver_FS18/src/libraries/network/packet/ClassID.cc
r11842 r11990 118 118 } 119 119 120 // TODO: This parses the packet and calls ClassByString()121 // However, the resulting Identifier is discarded...122 120 bool ClassID::process(orxonox::Host* host) { 123 121 int nrOfClasses;
Note: See TracChangeset
for help on using the changeset viewer.