Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 10, 2018, 3:06:55 PM (6 years ago)
Author:
merholzl
Message:

Merged Masterserver, refresh button had to be removed

Location:
code/branches/mergeFS18
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/mergeFS18

  • code/branches/mergeFS18/src/libraries/network/Host.cc

    r11071 r12027  
    4444  SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT);
    4545
    46   // Host*               Host::instance_=nullptr;
    47   uint32_t            Host::clientID_s=0;
    48 //   uint32_t            Host::shipID_s=-1;
     46  uint32_t            Host::clientID_s = 0;
    4947  std::vector<Host*>  Host::instances_s;
    5048
     
    5452  Host::Host()
    5553  {
    56   //   assert(instance_==nullptr);
    57     instances_s.push_back(this);
     54    Host::instances_s.push_back(this);
     55
    5856    ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this);
     57
    5958    this->bIsActive_ = false;
    6059  }
     
    6665  Host::~Host()
    6766  {
    68     assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
    69     instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
     67    assert(std::find( instances_s.begin(), instances_s.end(), this ) != instances_s.end());
     68    Host::instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
    7069    ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(nullptr);
    7170  }
     
    8079  void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID)
    8180  {
    82     for(Host* host : instances_s)
     81    for (Host* host : instances_s)
    8382    {
    84       if( host->isActive() )
     83      if (host->isActive())
    8584      {
    8685        host->queuePacket(packet, clientID, channelID);
     
    9796  void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
    9897  {
    99     for(Host* host : instances_s)
    100       if( host->isActive() )
     98    for (Host* host : instances_s)
     99    {
     100      if (host->isActive())
     101      {
    101102        host->doSendChat(message, sourceID, targetID);
     103      }
     104    }
    102105  }
    103106
     
    108111  {
    109112    for (NetworkChatListener* listener : ObjectList<NetworkChatListener>())
     113    {
    110114      listener->incomingChat(message, sourceID);
     115    }
    111116  }
    112117
     
    114119  bool Host::isServer()
    115120  {
    116     for (Host* host : instances_s)
     121    for (Host* host : Host::instances_s)
    117122    {
    118       if( host->isActive() )
     123      if (host->isActive())
    119124      {
    120         if( host->isServer_() )
     125        if (host->isServer_())
     126        {
    121127          return true;
     128        }
    122129      }
    123130    }
     
    125132  }
    126133
     134  /**
     135   * Singleton implementation. Return the first active instance.
     136   */
    127137  Host* Host::getActiveInstance()
    128138  {
    129139    std::vector<Host*>::iterator it = Host::instances_s.begin();
    130     while( it != Host::instances_s.end() )
     140    while (it != Host::instances_s.end())
    131141    {
    132       if( (*it)->isActive() )
     142      if ((*it)->isActive())
     143      {
    133144        return *it;
     145      }
    134146      else
     147      {
    135148        ++it;
     149      }
    136150    }
    137151    return nullptr;
Note: See TracChangeset for help on using the changeset viewer.