Changeset 10768 for code/branches/cpp11_v2/src/libraries/network
- Timestamp:
- Nov 6, 2015, 10:54:34 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/network
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/network/Connection.cc
r8858 r10768 46 46 47 47 Connection::Connection(uint32_t firstPeerID): 48 host_( 0), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID)48 host_(nullptr), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID) 49 49 { 50 50 enet_initialize(); … … 81 81 { 82 82 // this->overallMutex_->lock(); 83 outgoingEvent outEvent = { peerID, outgoingEventType::disconnectPeer, 0, 0 };83 outgoingEvent outEvent = { peerID, outgoingEventType::disconnectPeer, nullptr, 0 }; 84 84 85 85 this->outgoingEventsMutex_->lock(); … … 91 91 void Connection::disconnectPeers() 92 92 { 93 outgoingEvent outEvent = { 0, outgoingEventType::disconnectPeers, 0, 0 };93 outgoingEvent outEvent = { 0, outgoingEventType::disconnectPeers, nullptr, 0 }; 94 94 95 95 this->outgoingEventsMutex_->lock(); … … 323 323 324 324 // create new peerEvent and return it 325 incomingEvent inEvent = { peerID, incomingEventType::peerConnect, 0};325 incomingEvent inEvent = { peerID, incomingEventType::peerConnect, nullptr }; 326 326 return inEvent; 327 327 } … … 338 338 339 339 // create new peerEvent and return it 340 incomingEvent inEvent = { peerID, incomingEventType::peerDisconnect, 0};340 incomingEvent inEvent = { peerID, incomingEventType::peerDisconnect, nullptr }; 341 341 return inEvent; 342 342 } -
code/branches/cpp11_v2/src/libraries/network/GamestateHandler.cc
r7801 r10768 32 32 namespace orxonox { 33 33 34 // GamestateHandler *GamestateHandler::instance_= 0;34 // GamestateHandler *GamestateHandler::instance_=nullptr; 35 35 36 36 GamestateHandler::GamestateHandler() -
code/branches/cpp11_v2/src/libraries/network/GamestateManager.cc
r8858 r10768 60 60 { 61 61 GamestateManager::GamestateManager() : 62 currentGamestate_( 0), id_(0)62 currentGamestate_(nullptr), id_(0) 63 63 { 64 64 // trafficControl_ = new TrafficControl(); … … 140 140 141 141 bool GamestateManager::getSnapshot(){ 142 if ( currentGamestate_ != 0)142 if ( currentGamestate_ != nullptr ) 143 143 delete currentGamestate_; 144 144 uint8_t gsMode; … … 165 165 { //we have no data to send 166 166 delete currentGamestate_; 167 currentGamestate_= 0;167 currentGamestate_=nullptr; 168 168 return false; 169 169 } … … 191 191 unsigned int lastAckedGamestateID = peerIt->second.lastAckedGamestateID; 192 192 193 packet::Gamestate* baseGamestate= 0;193 packet::Gamestate* baseGamestate=nullptr; 194 194 if(lastAckedGamestateID != GAMESTATEID_INITIAL) 195 195 { … … 200 200 } 201 201 202 peerGamestates.push_back( 0); // insert an empty gamestate* to be changed202 peerGamestates.push_back(nullptr); // insert an empty gamestate* to be changed 203 203 finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ ); 204 if( peerGamestates.back()== 0)204 if( peerGamestates.back()==nullptr ) 205 205 // nothing to send to remove pointer from vector 206 206 peerGamestates.pop_back(); … … 243 243 { 244 244 delete diffed1; 245 destgamestate = 0;245 destgamestate = nullptr; 246 246 return; 247 247 } -
code/branches/cpp11_v2/src/libraries/network/Host.cc
r10624 r10768 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 … … 135 135 ++it; 136 136 } 137 return 0;137 return nullptr; 138 138 } 139 139 -
code/branches/cpp11_v2/src/libraries/network/LANDiscoverable.cc
r10765 r10768 51 51 this->setConfigValues(); 52 52 // this->setActivity(true); 53 this->host_ = 0;53 this->host_ = nullptr; 54 54 this->bActive_ = false; 55 55 } … … 83 83 bindAddress.host = ENET_HOST_ANY; 84 84 bindAddress.port = LAN_DISCOVERY_PORT; 85 assert( this->host_ == 0);85 assert( this->host_ == nullptr ); 86 86 this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 ); 87 87 if ( this->host_ == nullptr ) … … 91 91 { 92 92 enet_host_destroy( this->host_ ); 93 this->host_ = 0;93 this->host_ = nullptr; 94 94 } 95 95 this->bActive_ = bActive; -
code/branches/cpp11_v2/src/libraries/network/NetworkFunction.h
r10624 r10768 144 144 inline bool call(uint32_t objectID) 145 145 { 146 if ( Synchronisable::getSynchronisable(objectID)!= 0)146 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 147 147 { 148 148 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID))); … … 154 154 inline bool call(uint32_t objectID, const MultiType& mt1) 155 155 { 156 if ( Synchronisable::getSynchronisable(objectID)!= 0)156 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 157 157 { 158 158 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1); … … 164 164 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) 165 165 { 166 if ( Synchronisable::getSynchronisable(objectID)!= 0)166 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 167 167 { 168 168 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2); … … 174 174 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 175 175 { 176 if ( Synchronisable::getSynchronisable(objectID)!= 0)176 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 177 177 { 178 178 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3); … … 184 184 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 185 185 { 186 if ( Synchronisable::getSynchronisable(objectID)!= 0)186 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 187 187 { 188 188 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4); … … 194 194 inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 195 195 { 196 if ( Synchronisable::getSynchronisable(objectID)!= 0)196 if ( Synchronisable::getSynchronisable(objectID)!=nullptr ) 197 197 { 198 198 (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5); -
code/branches/cpp11_v2/src/libraries/network/NetworkFunctionManager.cc
r10765 r10768 32 32 namespace orxonox 33 33 { 34 NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = 0;34 NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = nullptr; 35 35 36 36 void NetworkFunctionManager::registerFunction(NetworkFunctionBase* function) -
code/branches/cpp11_v2/src/libraries/network/Server.cc
r10765 r10768 194 194 void Server::printRTT() 195 195 { 196 // for( ClientInformation* temp=ClientInformation::getBegin(); temp!= 0; temp=temp->next() )196 // for( ClientInformation* temp=ClientInformation::getBegin(); temp!=nullptr; temp=temp->next() ) 197 197 // orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl; 198 198 } -
code/branches/cpp11_v2/src/libraries/network/TrafficControl.cc
r9667 r10768 64 64 *Initializing protected members 65 65 */ 66 TrafficControl *TrafficControl::instance_= 0;66 TrafficControl *TrafficControl::instance_=nullptr; 67 67 68 68 /** … … 72 72 { 73 73 RegisterObject(TrafficControl); 74 assert(instance_== 0);74 assert(instance_==nullptr); 75 75 instance_=this; 76 76 this->setConfigValues(); … … 78 78 79 79 /** 80 * @brief Destructor: resets the instance pointer to 080 * @brief Destructor: resets the instance pointer to nullptr 81 81 */ 82 82 TrafficControl::~TrafficControl() 83 83 { 84 instance_= 0;84 instance_=nullptr; 85 85 } 86 86 -
code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.cc
r10765 r10768 106 106 { 107 107 uint32_t tempsize=0, currentsize=0; 108 assert(data_== 0);108 assert(data_==nullptr); 109 109 uint32_t size = calcGamestateSize(id, mode); 110 110 -
code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.h
r7801 r10768 54 54 { 55 55 public: 56 GamestateHeader(){ data_= 0; }56 GamestateHeader(){ data_=nullptr; } 57 57 GamestateHeader(uint8_t* data) 58 58 { assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; } -
code/branches/cpp11_v2/src/libraries/network/packet/Packet.cc
r10765 r10768 69 69 packetDirection_ = Direction::Outgoing; 70 70 peerID_=0; 71 data_= 0;72 enetPacket_= 0;71 data_=nullptr; 72 enetPacket_=nullptr; 73 73 bDataENetAllocated_ = false; 74 74 } … … 80 80 peerID_=peerID; 81 81 data_=data; 82 enetPacket_= 0;82 enetPacket_=nullptr; 83 83 bDataENetAllocated_ = false; 84 84 } … … 95 95 memcpy(data_, p.data_, p.getSize()); 96 96 }else 97 data_= 0;97 data_=nullptr; 98 98 bDataENetAllocated_ = p.bDataENetAllocated_; 99 99 } … … 175 175 #endif 176 176 // ENetPacket *temp = enetPacket_; 177 // enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet177 // enetPacket_ = nullptr; // otherwise we have a double free because enet already handles the deallocation of the packet 178 178 if( this->flags_ & PacketFlag::Reliable ) 179 179 host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT); … … 191 191 // if( peerID==static_cast<unsigned int>(-2)) 192 192 // peerID = NETWORK_PEER_ID_SERVER; 193 Packet *p = 0;193 Packet *p = nullptr; 194 194 // orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl; 195 195 switch( *(Type::Value *)(data + _PACKETID) ) … … 251 251 assert(it != packetMap_.end()); 252 252 // Make sure we don't delete it again in the destructor 253 it->second->enetPacket_ = 0;253 it->second->enetPacket_ = nullptr; 254 254 delete it->second; 255 255 packetMap_.erase(it); -
code/branches/cpp11_v2/src/libraries/network/synchronisable/Synchronisable.cc
r10765 r10768 140 140 { 141 141 mem += header.getDataSize() + header.getSize(); 142 return 0;142 return nullptr; 143 143 } 144 144 // assert( !header.isDiffed() ); … … 156 156 } 157 157 assert(id); 158 Context* context = 0;158 Context* context = nullptr; 159 159 if (header.getContextID() != OBJECTID_UNKNOWN) 160 160 { … … 164 164 mem += header.getDataSize()+SynchronisableHeader::getSize(); //.TODO: this suckz.... remove size from header 165 165 assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^ 166 return 0;166 return nullptr; 167 167 } 168 168 else … … 172 172 context = Context::getRootContext(); 173 173 174 assert(getSynchronisable(header.getObjectID())== 0); //make sure no object with this id exists174 assert(getSynchronisable(header.getObjectID())==nullptr); //make sure no object with this id exists 175 175 BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(context)); 176 176 assert(bo); -
code/branches/cpp11_v2/src/libraries/network/synchronisable/Synchronisable.h
r9667 r10768 171 171 protected: 172 172 Synchronisable(Context* context); 173 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb= 0, bool bidirectional=false);174 template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb= 0, bool bidirectional=false);173 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false); 174 template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false); 175 175 template <class T> void unregisterVariable(T& var); 176 176 -
code/branches/cpp11_v2/src/libraries/network/synchronisable/SynchronisableVariable.h
r10624 r10768 71 71 { 72 72 public: 73 SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb= 0);73 SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=nullptr); 74 74 virtual ~SynchronisableVariable(); 75 75 … … 89 89 { 90 90 public: 91 SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb= 0);91 SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=nullptr); 92 92 virtual ~SynchronisableVariableBidirectional(); 93 93
Note: See TracChangeset
for help on using the changeset viewer.