Changeset 12027 for code/branches/mergeFS18/src/libraries/network/Host.cc
- Timestamp:
- Oct 10, 2018, 3:06:55 PM (6 years ago)
- Location:
- code/branches/mergeFS18
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/mergeFS18
- Property svn:mergeinfo changed
/code/branches/Masterserver_FS18 (added) merged: 11816,11829,11842,11856,11858,11880,11889,11905,11907,11910,11929-11930,11937,11962-11963,11973,11983,11990
- Property svn:mergeinfo changed
-
code/branches/mergeFS18/src/libraries/network/Host.cc
r11071 r12027 44 44 SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT); 45 45 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; 49 47 std::vector<Host*> Host::instances_s; 50 48 … … 54 52 Host::Host() 55 53 { 56 // assert(instance_==nullptr);57 instances_s.push_back(this); 54 Host::instances_s.push_back(this); 55 58 56 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this); 57 59 58 this->bIsActive_ = false; 60 59 } … … 66 65 Host::~Host() 67 66 { 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 )); 70 69 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(nullptr); 71 70 } … … 80 79 void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID) 81 80 { 82 for (Host* host : instances_s)81 for (Host* host : instances_s) 83 82 { 84 if ( host->isActive())83 if (host->isActive()) 85 84 { 86 85 host->queuePacket(packet, clientID, channelID); … … 97 96 void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 98 97 { 99 for(Host* host : instances_s) 100 if( host->isActive() ) 98 for (Host* host : instances_s) 99 { 100 if (host->isActive()) 101 { 101 102 host->doSendChat(message, sourceID, targetID); 103 } 104 } 102 105 } 103 106 … … 108 111 { 109 112 for (NetworkChatListener* listener : ObjectList<NetworkChatListener>()) 113 { 110 114 listener->incomingChat(message, sourceID); 115 } 111 116 } 112 117 … … 114 119 bool Host::isServer() 115 120 { 116 for (Host* host : instances_s)121 for (Host* host : Host::instances_s) 117 122 { 118 if ( host->isActive())123 if (host->isActive()) 119 124 { 120 if( host->isServer_() ) 125 if (host->isServer_()) 126 { 121 127 return true; 128 } 122 129 } 123 130 } … … 125 132 } 126 133 134 /** 135 * Singleton implementation. Return the first active instance. 136 */ 127 137 Host* Host::getActiveInstance() 128 138 { 129 139 std::vector<Host*>::iterator it = Host::instances_s.begin(); 130 while ( it != Host::instances_s.end())140 while (it != Host::instances_s.end()) 131 141 { 132 if( (*it)->isActive() ) 142 if ((*it)->isActive()) 143 { 133 144 return *it; 145 } 134 146 else 147 { 135 148 ++it; 149 } 136 150 } 137 151 return nullptr;
Note: See TracChangeset
for help on using the changeset viewer.