Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9385 in orxonox.OLD


Ignore:
Timestamp:
Jul 21, 2006, 1:09:19 PM (18 years ago)
Author:
bensch
Message:

orxonox/proxy: better proxy-width approximation

Location:
branches/proxy/src
Files:
4 edited

Legend:

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

    r9383 r9385  
    3232IP::IP()
    3333{
    34   this->_ip = 0;
     34  this->_host = 0;
    3535  this->_port = IP::_defaultPort;
    3636}
     
    4545IP::IP(int ip, int port)
    4646{
    47   this->_ip = ip;
     47  this->_host = ip;
    4848  if (port != -1)
    4949    this->_port = port;
     
    8484IP::IP(const IPaddress& ip)
    8585{
    86   this->_ip = ip.host;
     86  this->_host = ip.host;
    8787  this->_port = ip.port;
    8888}
     
    9898  *this = ip;
    9999}
     100
     101
     102/**
     103 * @brief constructs an IP out of the four pairs and a Port.
     104 * @param first The first octal.
     105 * @param second The second octal.
     106 * @param third The third octal.
     107 * @param fourth The fourth octal.
     108 * @param port The Port.
     109 * @return self.
     110 */
     111IP::IP(unsigned int first, unsigned int second, unsigned int third, unsigned int fourth, int port)
     112{
     113  this->_host = (first << 24) +
     114                (second << 16) +
     115                (third <<  8) +
     116                fourth;
     117  this->_port = port;
     118}
     119
    100120
    101121/**
     
    106126const IP& IP::operator=(const IP& ip)
    107127{
    108   this->_ip = ip.host();
     128  this->_host = ip.host();
    109129  this->_port = ip.port();
    110130  return *this;
     
    119139const IP& IP::operator=(const IPaddress& ip)
    120140{
    121   this->_ip = ip.host;
     141  this->_host = ip.host;
    122142  this->_port = ip.port;
    123143  return *this;
     
    132152bool IP::operator==(const IP& ip) const
    133153{
    134   return (this->_ip == ip.host() &&
     154  return (this->_host == ip.host() &&
    135155          this->_port == ip.port());
    136156}
     
    144164bool IP::operator!=(const IP& ip) const
    145165{
    146   return (this->_ip != ip.host() ||
    147       this->_port != ip.port());
     166  return (this->_host != ip.host() ||
     167          this->_port != ip.port());
    148168}
    149169
     
    199219  {
    200220    case 0:
    201       return  (_ip & 0xFF000000) >> 24;
     221      return  (_host & 0xFF000000) >> 24;
    202222    case 1:
    203       return  (_ip & 0x00FF0000) >> 16;
     223      return  (_host & 0x00FF0000) >> 16;
    204224    case 2:
    205       return  (_ip & 0x0000FF00) >> 8;
     225      return  (_host & 0x0000FF00) >> 8;
    206226    case 3:
    207       return  (_ip & 0x000000FF);
     227      return  (_host & 0x000000FF);
    208228    default:
    209229      return -1;
     
    217237std::string IP::ipString() const
    218238{
    219   return IP::ipToString(this->_ip, this->_port);
     239  return IP::ipToString(this->_host, this->_port);
    220240}
    221241
  • branches/proxy/src/lib/network/ip.h

    r9383 r9385  
    2626    IP(const IPaddress& ip);
    2727    IP(const IP& ip);
     28    IP(unsigned int first, unsigned int second, unsigned int third, unsigned int fourth, int port = IP::_defaultPort);
    2829
    2930    /// OPERATORS
     
    3536    /// RETRIVEAL
    3637    /** @returns the IP */
    37     int host() const { return this->_ip; };
    38     int* hostRef()  { return &this->_ip; }
     38    int host() const { return this->_host; };
     39    int* hostRef()  { return &this->_host; }
    3940    /** @returns the Port */
    4041    int port() const { return this->_port; };
    4142    int* portRef() { return &this->_port; };
    4243
    43     inline IPaddress getSDLNotation() { IPaddress sdlIP; sdlIP.host = this->_ip; sdlIP.port = this->_port; return sdlIP; }
     44    inline IPaddress getSDLNotation() { IPaddress sdlIP; sdlIP.host = this->_host; sdlIP.port = this->_port; return sdlIP; }
    4445
    4546    int ipPart(unsigned int part) const;
     
    5960
    6061  private:
    61     int           _ip;           //!< The IP in int form.
    62     int         _port;         //!< The Port number of the IP
     62    int           _host;           //!< The IP in int form.
     63    int           _port;         //!< The Port number of the IP
    6364
    64     static int  _defaultPort;  //!< Default Port
     65    static int    _defaultPort;  //!< Default Port
    6566};
    6667
  • branches/proxy/src/util/network_stats_widget.cc

    r9383 r9385  
    5252  : _proxyWidget(proxyName, ip)
    5353  {
     54    this->_clientNameWidth = 100.0f;
    5455    this->pack(&_proxyWidget);
    5556  }
     
    5859  {
    5960    HostWidget* newClient = new HostWidget(name, ip);
     61    newClient->setNameWidth(this->_clientNameWidth);
    6062
    6163    this->pack(newClient);
     
    112114
    113115
     116  void ProxyWidget::setClientNameWidths(float width)
     117  {
     118    this->_clientNameWidth = width;
     119    for (unsigned int i = 0; i < this->_clients.size(); ++i)
     120      this->_clients[i]->setNameWidth(width);
     121  }
     122
    114123  void ProxyWidget::hiding()
    115124  {
     
    135144   */
    136145  NetworkStatsWidget::NetworkStatsWidget ()
    137       : GLGuiBox(Vertical)
     146  : GLGuiBox(Vertical), _thisHost("myName", IP(127, 0, 0 , 0))
    138147  {
    139148    //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
  • branches/proxy/src/util/network_stats_widget.h

    r9383 r9385  
    5353      bool removeClient(const std::string& name, const IP& ip);
    5454
     55      void setClientNameWidths(float width);
     56
    5557
    5658    protected:
     
    6365
    6466      std::vector<HostWidget*>  _clients;
     67      float            _clientNameWidth;
    6568  };
    6669
     
    9295
    9396    private:
    94       IP                     _ip;
    95       GLGuiText              _ipText;
     97      HostWidget             _thisHost;
    9698
    9799      GLGuiText              _upstreamText;
    98100      GLGuiText              _downstreamText;
    99101
    100       std::vector<GLGuiText> _connectedHosts;
     102      std::vector<HostWidget*>_connectedProxies;
    101103
    102104      GLGuiText              _serverIP;
Note: See TracChangeset for help on using the changeset viewer.