- alittle more bullet proofing using NULL pointer checks

This commit is contained in:
Mark Vejvoda
2010-08-20 20:51:25 +00:00
parent fc31e7713d
commit 1fa9efc091

View File

@@ -241,16 +241,20 @@ void ConnectionSlot::update(bool checkForNewClients) {
if(hasOpenSlots == false) { if(hasOpenSlots == false) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] no open slots, disconnecting client\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] no open slots, disconnecting client\n",__FILE__,__FUNCTION__);
NetworkMessageIntro networkMessageIntro(getNetworkVersionString(), socket->getHostName(), playerIndex, nmgstNoSlots); if(socket != NULL) {
sendMessage(&networkMessageIntro); NetworkMessageIntro networkMessageIntro(getNetworkVersionString(), socket->getHostName(), playerIndex, nmgstNoSlots);
sendMessage(&networkMessageIntro);
}
close(); close();
} }
else { else {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] client will be assigned to the next open slot\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] client will be assigned to the next open slot\n",__FILE__,__FUNCTION__);
NetworkMessageIntro networkMessageIntro(getNetworkVersionString(), socket->getHostName(), playerIndex, nmgstOk); if(socket != NULL) {
sendMessage(&networkMessageIntro); NetworkMessageIntro networkMessageIntro(getNetworkVersionString(), socket->getHostName(), playerIndex, nmgstOk);
sendMessage(&networkMessageIntro);
}
} }
} }
} }
@@ -258,7 +262,7 @@ void ConnectionSlot::update(bool checkForNewClients) {
else { else {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(socket->isConnected()) { if(socket != NULL && socket->isConnected()) {
this->clearChatInfo(); this->clearChatInfo();
bool gotTextMsg = true; bool gotTextMsg = true;