Changeset 11071 for code/trunk/src/libraries/network/Host.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/Host.cc
r10624 r11071 44 44 SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT); 45 45 46 // Host* Host::instance_= 0;46 // Host* Host::instance_=nullptr; 47 47 uint32_t Host::clientID_s=0; 48 48 // uint32_t Host::shipID_s=-1; … … 54 54 Host::Host() 55 55 { 56 // assert(instance_== 0);56 // assert(instance_==nullptr); 57 57 instances_s.push_back(this); 58 58 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this); … … 62 62 63 63 /** 64 * @brief Destructor: resets the instance pointer to 064 * @brief Destructor: resets the instance pointer to nullptr 65 65 */ 66 66 Host::~Host() … … 68 68 assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() ); 69 69 instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this )); 70 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject( 0);70 ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(nullptr); 71 71 } 72 72 … … 80 80 void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID) 81 81 { 82 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it)82 for(Host* host : instances_s) 83 83 { 84 if( (*it)->isActive() )84 if( host->isActive() ) 85 85 { 86 (*it)->queuePacket(packet, clientID, channelID);86 host->queuePacket(packet, clientID, channelID); 87 87 } 88 88 } … … 97 97 void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 98 98 { 99 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it)100 if( (*it)->isActive() )101 (*it)->doSendChat(message, sourceID, targetID);99 for(Host* host : instances_s) 100 if( host->isActive() ) 101 host->doSendChat(message, sourceID, targetID); 102 102 } 103 103 … … 107 107 void Host::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) 108 108 { 109 for ( ObjectList<NetworkChatListener>::iterator it = ObjectList<NetworkChatListener>::begin(); it != ObjectList<NetworkChatListener>::end(); ++it)110 it->incomingChat(message, sourceID);109 for (NetworkChatListener* listener : ObjectList<NetworkChatListener>()) 110 listener->incomingChat(message, sourceID); 111 111 } 112 112 … … 114 114 bool Host::isServer() 115 115 { 116 for ( std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it)116 for (Host* host : instances_s) 117 117 { 118 if( (*it)->isActive() )118 if( host->isActive() ) 119 119 { 120 if( (*it)->isServer_() )120 if( host->isServer_() ) 121 121 return true; 122 122 } … … 135 135 ++it; 136 136 } 137 return 0;137 return nullptr; 138 138 } 139 139
Note: See TracChangeset
for help on using the changeset viewer.