Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2018, 3:24:00 PM (7 years ago)
Author:
mdedial
Message:

Clean up code, remove TODOs and dead code.

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  
    105105      {
    106106        // manually add server to list of peers
    107         /*incomingEvent inEvent = */Connection::preprocessConnectEvent(event);
    108 //         addPeer(inEvent.peerID);
     107        Connection::preprocessConnectEvent(event);
     108
    109109        // start communication thread
    110110        this->established_=true;
     
    155155    assert( this->server_ );
    156156    assert( packet );
    157 //     return Connection::addPacket( packet, NETWORK_PEER_ID_SERVER, channelID );
    158157    // HACK: actually there should be a way to do this using addPacket and the correct peerID
    159158    return Connection::broadcastPacket(packet, channelID);
     
    168167    this->established_=false;
    169168    orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl;
    170         // server closed the connection
     169    // server closed the connection
    171170    this->stopCommunicationThread();
    172171    this->connectionClosed();
  • code/branches/Masterserver_FS18/src/libraries/network/ClientConnection.h

    r11842 r11990  
    4444    void setPort( unsigned int port );
    4545
    46 //     ENetEvent *getEvent();
    47     // check wheter the packet queue is empty
    48 //     bool queueEmpty();
    4946    // create a new listener thread
    5047    virtual bool establishConnection();
  • code/branches/Masterserver_FS18/src/libraries/network/Connection.cc

    r11880 r11990  
    7272    delete this->incomingEventsMutex_;
    7373    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.
    7774  }
    7875
     
    172169     
    173170      // Sleep for 1ms
    174       // TODO: Why?
    175171      msleep(1);
    176172     
    177173      // Send all waiting outgoing packets
    178       // TODO: Why do we need a mutex to read a single variable?
    179174      this->outgoingEventsMutex_->lock();
    180175      uint32_t outgoingEventsCount = this->outgoingEvents_.size();
    181176      this->outgoingEventsMutex_->unlock();
    182177
    183       // TODO: Not convinced about how mutexes are used here, seems kinda pointless
    184178      while(outgoingEventsCount > 0)
    185179      {
     
    406400  }
    407401
    408 
    409402}
  • code/branches/Masterserver_FS18/src/libraries/network/FunctionCallManager.cc

    r11842 r11990  
    6262  for (const auto& mapEntry : FunctionCallManager::sPeerMap_ )
    6363  {
    64     // TODO: This seems rather pointless, as it wouldn't be called anyways if the map was empty.
    6564    assert(!FunctionCallManager::sPeerMap_.empty());
    6665    mapEntry.second->send(host);
    6766  }
    68   // TODO: Why is the map cleared here?
    6967  FunctionCallManager::sPeerMap_.clear();
    7068}
  • code/branches/Masterserver_FS18/src/libraries/network/FunctionCallManager.h

    r11842 r11990  
    5656  static std::map<uint32_t, packet::FunctionCalls*>                           sPeerMap_;
    5757
    58   // TODO: What's up with the pair within the pair?
    59   // Vector of pairs
    60   // The pair consists of the FunctionCall and another pair, which...
    6158  static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t>>> sIncomingFunctionCallBuffer_;
    6259
  • code/branches/Masterserver_FS18/src/libraries/network/GamestateManager.cc

    r11937 r11990  
    8686  bool GamestateManager::update()
    8787  {
    88     return getSnapshot();
     88    return this->getSnapshot();
    8989  }
    9090
     
    119119    for(const auto& gsPair : this->gamestateQueue)
    120120    {
    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());
    123123      delete gsPair.second;
    124124    }
     
    214214
    215215    std::vector<packet::Gamestate*> peerGamestates;
    216     // TODO: mapEntry is an incredibly bad name
    217216    for(const auto& mapEntry : this->peerMap_)
    218217    {
     
    256255
    257256    // Create a copy of the gamestate
    258     // TODO: Does this actually create a copy of the gamestate?
    259257    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
    260258    this->peerMap_[peerID].gamestates[gamestate->getID()] = gs;
  • code/branches/Masterserver_FS18/src/libraries/network/GamestateManager.h

    r11842 r11990  
    111111    bool processGamestate(packet::Gamestate *gs);
    112112
    113     // TODO: What is the purpose of the gamestateQueue?
    114113    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    115114
  • code/branches/Masterserver_FS18/src/libraries/network/Host.cc

    r11829 r11990  
    5454    Host::instances_s.push_back(this);
    5555
    56     // TODO: What does this do?
    5756    ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this);
    5857
  • code/branches/Masterserver_FS18/src/libraries/network/LANDiscoverable.cc

    r11071 r11990  
    121121            info.setClientNumber(this->clientNumber);
    122122            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 );
    125123            enet_host_flush(this->host_);
    126124          }
  • code/branches/Masterserver_FS18/src/libraries/network/LANDiscoverable.h

    r10622 r11990  
    4343      void setActivity( bool bActive );
    4444      void update();
    45       void updateClientNumber(int clientNumber) {this->clientNumber = clientNumber;}
    46 ;
     45      void updateClientNumber(int clientNumber) { this->clientNumber = clientNumber; }
    4746      /** Function used for the configuration file parameter update */
    4847      void setConfigValues();
  • code/branches/Masterserver_FS18/src/libraries/network/LANDiscovery.cc

    r11071 r11990  
    6161    address.port = LAN_DISCOVERY_PORT;
    6262
    63     /* TODO: check for availability of each protocol */
    6463    /* IPv4 */
    6564    address.host = ENET_HOST_BROADCAST;
     
    102101              this->servers_.push_back(info);
    103102          }
    104 //           enet_address_get_host_ip(&event.peer->address, buffer, buflen );
    105 //           serverIPs.push_back(std::string(buffer));
    106103          break;
    107104        default:
  • code/branches/Masterserver_FS18/src/libraries/network/MasterServer.cc

    r11842 r11990  
    4040  SetConsoleCommand( "ms-listservers", &MasterServer::listServers );
    4141  SetConsoleCommand( "ms-delserver", &MasterServer::delServer );
    42   //SetConsoleCommand( "ms-serverinfo", &MasterServer::serverInfo );
    4342
    4443  /* forward declaration so the linker doesn't complain */
  • code/branches/Masterserver_FS18/src/libraries/network/MasterServerComm.cc

    r11071 r11990  
    3838     * the initialize method to facilitate debugging
    3939     */
    40     /* register object in orxonox */
    4140  }
    4241
     
    4847      return 1;
    4948    }
    50 
    51     /* initialize the event holder */
    52 //     this->event = (ENetEvent *)calloc( sizeof(ENetEvent), 1 );
    53    
    5449
    5550    /* initiate the client */
     
    226221    /* One could just use enet_host_service() instead. */
    227222    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 frees
    231 //     enet_packet_destroy( packet );
    232223
    233224    /* all done. */
     
    248239    /* One could just use enet_host_service() instead. */
    249240    enet_host_flush( this->client );
    250     // PLEASE: never do this, because enet will free the packet once it's delivered. this will cause double frees
    251 //     enet_packet_destroy( packet );
    252241
    253242    /* all done. */
  • code/branches/Masterserver_FS18/src/libraries/network/Server.cc

    r11829 r11990  
    167167      {
    168168        timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD;
    169         updateGamestate();
     169        this->updateGamestate();
    170170      }
    171171    }
     
    178178
    179179  /**
    180    * Return ping 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()
    183183  {
    184184    // TODO: Implement
    185     return 0;
    186   }
    187 
    188   /**
    189    * Print ping time to client in milliseconds.
    190    */
    191   void Server::printRTT()
    192   {
    193     // TODO: Implement
    194   }
    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: Implement
    202     return 0.;
    203185  }
    204186
     
    214196    }
    215197    GamestateManager::update();
    216     sendGameStates();
    217     sendObjectDeletes();
     198    this->sendGameStates();
     199    this->sendObjectDeletes();
    218200  }
    219201
     
    255237      orxout(internal_warning, context::network) << "Server: could not broadcast deleteObjects packet" << endl;
    256238    }
    257 
    258     // TODO: Possible memory leak?
    259     // del is allocated but only deleted if fetchIDs() returns false
    260239
    261240    return true;
     
    277256    orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl;
    278257
    279     createClient(peerID);
     258    this->createClient(peerID);
    280259  }
    281260
     
    297276      }
    298277    }
    299 
    300     // TODO: What happens if no peer with this ID is found?
    301     // Should probably at least log
    302278
    303279    WANDiscoverable::updateClientNumber(this->clientIDs_.size());
     
    339315
    340316    // synchronise class ids
    341     syncClassid(clientID);
     317    this->syncClassid(clientID);
    342318
    343319    // now synchronise functionIDs
     
    346322    bool b = fIDs->send(static_cast<Host*>(this));
    347323    assert(b);
    348     // TODO: assert probably isn't the way to go here, as a packet which fails to send will crash the game...
    349324
    350325    GamestateManager::setSynched(clientID);
     
    356331    b = w->send(static_cast<Host*>(this));
    357332    assert(b);
    358     // TODO: assert probably isn't the way to go here, as a packet which fails to send will crash the game...
    359333
    360334    (void)b; // avoid compiler warning
     
    380354  {
    381355    // 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 anymore
     356    if (!this->isValidTarget(targetID))
    383357    {
    384358      return;
     
    434408    packet::ClassID *classid = new packet::ClassID();
    435409    classid->setPeerID(clientID);
    436     // TODO: Better to do this with a for loop
     410
    437411    int failures = 0;
    438412    while(!classid->send(static_cast<Host*>(this)) && failures < 10)\
     
    441415    }
    442416    assert(failures<10);
    443     // TODO: assert probably isn't the way to go here, as 10 failed packets will crash the game...
    444417    orxout(verbose, context::network) << "syncClassid:\tall synchClassID packets have been sent" << endl;
    445418  }
  • code/branches/Masterserver_FS18/src/libraries/network/Server.h

    r11071 r11990  
    3838#include "core/CorePrereqs.h"
    3939#include "Host.h"
    40 // #include "GamestateManager.h"
    4140#include "ServerConnection.h"
    4241#include "LANDiscoverable.h"
     
    6261    void close();
    6362    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) ); }
    6564    void update(const Clock& time);
    66     unsigned int getRTT(unsigned int clientID);
    6765    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_; }
    7168
    7269  protected:
    7370    void updateGamestate();
    7471  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; }
    7774
    7875    virtual void addPeer(uint32_t peerID) override;
  • code/branches/Masterserver_FS18/src/libraries/network/ServerConnection.cc

    r11829 r11990  
    3939namespace orxonox
    4040{
    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 
    4741  /**
    4842   * Constructor
     
    131125  {
    132126    this->bListening_ = false;
    133     disconnectClients();
     127    this->disconnectClients();
    134128    Connection::stopCommunicationThread();
    135129    enet_host_destroy(this->host_);
     
    142136   * @param clientID The ID of the recipient
    143137   * @param channelID The channel ID
    144    * TODO: Not sure yet how this actually works
    145138   */
    146139  void ServerConnection::addPacket(ENetPacket *packet, unsigned int clientID, uint8_t channelID)
     
    148141    if (clientID == NETWORK_PEER_ID_BROADCAST)
    149142    {
    150       broadcastPacket(packet, channelID);
     143      this->broadcastPacket(packet, channelID);
    151144    }
    152145    else
  • code/branches/Masterserver_FS18/src/libraries/network/packet/ClassID.cc

    r11842 r11990  
    118118}
    119119
    120 // TODO: This parses the packet and calls ClassByString()
    121 // However, the resulting Identifier is discarded...
    122120bool ClassID::process(orxonox::Host* host) {
    123121  int nrOfClasses;
Note: See TracChangeset for help on using the changeset viewer.