Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 26, 2015, 1:38:24 PM (10 years ago)
Author:
frovelli
Message:

Added serverlist ping display in LAN

Location:
code/branches/multiplayerFS15/src/libraries/network
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/multiplayerFS15/src/libraries/network/LANDiscovery.cc

    r8858 r10334  
    124124  }
    125125
     126  std::string LANDiscovery::getServerListItemRTT(unsigned int index)
     127  {
     128    if( index >= this->servers_.size() )
     129      return BLANKSTRING;
     130    else{
     131      uint32_t serverrtt = this->servers_[index].getServerRTT();
     132      return Ogre::StringConverter::toString(serverrtt);
     133    }
     134
     135  }
     136
    126137
    127138} // namespace orxonox
  • code/branches/multiplayerFS15/src/libraries/network/LANDiscovery.h

    r8858 r10334  
    3333#include "packet/ServerInformation.h"
    3434#include "util/Singleton.h"
     35#include <OgreStringConverter.h>
    3536
    3637#include <vector>
     
    5152      std::string getServerListItemName( unsigned int index ); // tolua_export
    5253      std::string getServerListItemIP( unsigned int index ); // tolua_export
     54      std::string getServerListItemRTT( unsigned int index ); // tolua_export
    5355      static LANDiscovery& getInstance(){ return Singleton<LANDiscovery>::getInstance(); } // tolua_export
    54      
     56
    5557    private:
    5658      static LANDiscovery* singletonPtr_s;
  • code/branches/multiplayerFS15/src/libraries/network/ServerList.cc

    r8937 r10334  
    3030
    3131namespace orxonox
    32 { 
     32{
    3333  ServerList::ServerList()
    3434  { /* create a new list */ }
     
    3939  }
    4040
    41   int 
     41  int
    4242  ServerList::addServer( packet::ServerInformation toadd,
    4343    ENetPeer *peer )
    44   { 
     44  {
    4545    ServerListElem toAdd;
    4646    toAdd.ServerInfo = toadd;
    4747    toAdd.peer = peer;
    4848
    49     this->serverlist.push_back( toAdd ); 
     49    this->serverlist.push_back( toAdd );
    5050    return 0;
    5151  }
    5252
    53   bool 
     53  bool
    5454  ServerList::delServerByName( std::string name )
    55   { 
     55  {
    5656    /* get an iterator */
    5757    std::list<ServerListElem>::iterator i;
    5858
    5959    /* loop through list elements */
    60     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     60    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    6161      if( (*i).ServerInfo.getServerName() == name )
    6262      { /* found this name, remove and quit */
     
    6868
    6969  bool ServerList::delServerByAddress( std::string address )
    70   { 
     70  {
    7171    /* get an iterator */
    7272    std::list<ServerListElem>::iterator i;
    7373
    7474    /* loop through list elements */
    75     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     75    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    7676      if( (*i).ServerInfo.getServerIP() == address )
    7777      { /* found this name, remove and quit */
     
    9090
    9191    /* loop through list elements */
    92     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     92    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    9393      if( (*i).ServerInfo.getServerIP() == address )
    9494      { /* found the target, return it */
     
    110110    /* iterate, return when name found */
    111111    /* loop through list elements */
    112     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     112    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    113113      if( (*i).ServerInfo.getServerName() == name )
    114       { 
     114      {
    115115        ServerListSearchResult res = { (*i), true };
    116116        return res;
     
    124124  /* SORTING */
    125125  /* sort by name */
    126   bool sub_compare_names( ServerListElem no1, 
     126  bool sub_compare_names( ServerListElem no1,
    127127    ServerListElem no2 )
    128128  { return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName(); }
    129129
    130130  void ServerList::sortByName()
    131   { 
    132     this->serverlist.sort( sub_compare_names ); 
     131  {
     132    this->serverlist.sort( sub_compare_names );
    133133  }
    134  
     134
    135135  /* sort by ping */
    136   bool sub_compare_pings( ServerListElem no1, 
     136  bool sub_compare_pings( ServerListElem no1,
    137137    ServerListElem no2 )
    138   { 
    139     return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName();
     138  {
     139    return no1.ServerInfo.getServerRTT() > no2.ServerInfo.getServerRTT();
    140140  }
    141141
    142142  void ServerList::sortByPing()
    143143  {
    144     this->serverlist.sort( sub_compare_pings ); 
     144    this->serverlist.sort( sub_compare_pings );
    145145  }
    146146
  • code/branches/multiplayerFS15/src/libraries/network/packet/ServerInformation.cc

    r8351 r10334  
    3939  namespace packet
    4040  {
    41    
     41
    4242    ServerInformation::ServerInformation()
    4343    {
    44      
     44
    4545    }
    46    
     46
    4747    ServerInformation::ServerInformation(ENetEvent* event)
    4848    {
     
    6969    ServerInformation::~ServerInformation()
    7070    {
    71      
     71
    7272    }
    7373
     
    8181      ENetPacket* packet = enet_packet_create( temp, size, 0 );
    8282      enet_peer_send(peer, 0, packet);
    83      
     83
    8484      delete[] temp;
    8585    }
    86  
     86
    8787  } // namespace packet
    8888
     
    9595  }
    9696} // namespace orxonox
    97 
  • code/branches/multiplayerFS15/src/libraries/network/packet/ServerInformation.h

    r8351 r10334  
    4545        ServerInformation(ENetEvent* event);
    4646        ~ServerInformation();
    47        
     47
    4848        void          send( ENetPeer* peer );
    4949        std::string   getServerIP() { return this->serverIP_; }
     
    5252        void          setServerIP( std::string IP ) { this->serverIP_ = IP; }
    5353        uint32_t      getServerRTT() { return this->serverRTT_; }
    54        
     54
    5555      private:
    5656        std::string   serverName_;
Note: See TracChangeset for help on using the changeset viewer.