Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9426 in orxonox.OLD for branches/proxy


Ignore:
Timestamp:
Jul 24, 2006, 2:49:33 PM (18 years ago)
Author:
bensch
Message:

cleaner ip inclusion

Location:
branches/proxy/src/lib/network
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/ip.cc

    r9406 r9426  
    185185    IPaddress ipaddr;
    186186
    187     SDLNet_ResolveHost(&ipaddr, NULL, 2000);
    188 
    189     return IP(ipaddr.host, port);
     187    SDLNet_ResolveHost(&ipaddr, ip.c_str(), port);
     188
     189    return IP(ipaddr);
    190190  }
    191191  else
     
    255255/**
    256256 * @brief converts a IP into a String (without port).
    257  * @param ip the IP to put into the string.
     257 * @param host the IP to put into the string.
    258258 * @param port -1 if not wanted
    259259 * @return the string of the ip.
    260260 */
    261 std::string IP::ipToString(int ip, int port)
    262 {
    263   MultiType part0((int) (ip & 0xFF000000) >> 24);
    264   MultiType part1((int) (ip & 0x00FF0000) >> 16);
    265   MultiType part2((int) (ip & 0x0000FF00) >>  8);
    266   MultiType part3((int) (ip & 0x000000FF) );
     261std::string IP::ipToString(int host, int port)
     262{
     263  MultiType part0((int) ((host & 0xFF000000) >> 24));
     264  MultiType part1((int) ((host & 0x00FF0000) >> 16));
     265  MultiType part2((int) ((host & 0x0000FF00) >>  8));
     266  MultiType part3((int) ((host & 0x000000FF) ));
    267267
    268268  std::string addr = part3.getString() + "." + part2.getString() + "." +
  • branches/proxy/src/lib/network/ip.h

    r9406 r9426  
    5454
    5555    static std::string ipToString(const IPaddress& ipaddr);
    56     static std::string ipToString(int ip, int port = -1);
     56    static std::string ipToString(int host, int port = -1);
    5757
    5858    static void setDefaultPort(int defaultPort);
  • branches/proxy/src/lib/network/monitor/network_monitor.cc

    r9410 r9426  
    5757  {
    5858    // assuming that the config files are already read we get the proxy servers
    59     std::vector<IPaddress*>* proxyList = NetworkSettings::getInstance()->getProxyList();
    60     std::vector<IPaddress*>::iterator it = proxyList->begin();
     59    std::vector<IP>* proxyList = NetworkSettings::getInstance()->getProxyList();
     60    std::vector<IP>::iterator it = proxyList->begin();
    6161    // create a peer info class and a network node class for each new proxy and add them to the passive list
    6262    for(; it < proxyList->end(); it++)
    6363    {
    6464      PeerInfo* peer = new PeerInfo();
    65       peer->ip = *(*it);
     65      peer->ip = (*it);
    6666      peer->nodeType = NET_PROXY_SERVER_ACTIVE;
    6767      peer->userId = -1;
  • branches/proxy/src/lib/network/proxy/network_settings.cc

    r9416 r9426  
    5151
    5252  // remove all unused proxy data again
    53   for( int i = 0; i < this->proxies.size(); i++)
     53  for(unsigned int i = 0; i < this->proxies.size(); i++)
    5454  {
    55     IPaddress* ip = this->proxies.back();
     55    IP ip = this->proxies.back();
    5656    this->proxies.pop_back();
    57     delete ip;
    5857  }
    5958}
     
    139138    return;
    140139
    141   IPaddress *ip = new IPaddress;
     140  IP ip(proxyAddr, 9999);
     141  printf("========== ");
     142  ip.debug();
    142143
    143   SDLNet_ResolveHost( ip, proxyAddr.c_str(), 9999 );
    144 
    145   this->proxies.push_back(ip);
     144  this->proxies.push_back(ip);//IP(proxyAddr, 9999));
    146145}
    147146
  • branches/proxy/src/lib/network/proxy/network_settings.h

    r9410 r9426  
    4848    void setProxyAddr(const std::string& proxyAddr);
    4949    /** @returns the list of proxy servers from the init file */
    50     inline std::vector<IPaddress*>* getProxyList() { return &this->proxies; }
     50    inline std::vector<IP>* getProxyList() { return &this->proxies; }
    5151
    5252
     
    6161    float                        maxPlayerSaturation;     //!< the saturation level from where on the proxy server should be activated
    6262
    63     std::vector<IPaddress*>      proxies;                 //!< all registered proxies
     63    std::vector<IP>              proxies;                 //!< all registered proxies
    6464    IP                           masterServer;            //!< master server ip address
    6565
Note: See TracChangeset for help on using the changeset viewer.