- attempt to add code to NOT allow new connections on a slot that is no longer an open slot

This commit is contained in:
Mark Vejvoda 2012-03-20 20:31:41 +00:00
parent 1b8e1af25b
commit 8f98dbe566
3 changed files with 26 additions and 12 deletions

View File

@ -3535,19 +3535,27 @@ void MenuStateCustomGame::updateNetworkSlots() {
listBoxControls[i].setSelectedItemIndex(ctCpu);
}
}
if(serverInterface->getSlot(i) != NULL &&
listBoxControls[i].getSelectedItemIndex() != ctNetwork) {
if(serverInterface->getSlot(i)->isConnected() == true) {
if(listBoxControls[i].getSelectedItemIndex() != ctNetworkUnassigned) {
listBoxControls[i].setSelectedItemIndex(ctNetworkUnassigned);
ConnectionSlot *slot = serverInterface->getSlot(i);
if(slot != NULL) {
if(listBoxControls[i].getSelectedItemIndex() != ctNetwork) {
if(slot->getCanAcceptConnections() == true) {
slot->setCanAcceptConnections(false);
}
if(slot->isConnected() == true) {
if(listBoxControls[i].getSelectedItemIndex() != ctNetworkUnassigned) {
listBoxControls[i].setSelectedItemIndex(ctNetworkUnassigned);
}
}
else {
serverInterface->removeSlot(i);
if(listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
listBoxControls[i].setSelectedItemIndex(ctClosed);
}
}
}
else {
serverInterface->removeSlot(i);
if(listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
listBoxControls[i].setSelectedItemIndex(ctClosed);
}
else if(slot->getCanAcceptConnections() == false) {
slot->setCanAcceptConnections(true);
}
}
}

View File

@ -257,6 +257,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
this->gotLagCountWarning = false;
this->lastReceiveCommandListTime = 0;
this->receivedNetworkGameStatus = false;
this->canAcceptConnections = true;
this->setSocket(NULL);
this->slotThreadWorker = NULL;
@ -366,7 +367,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
this->setReceivedDataSynchCheck(false);
// Is the listener socket ready to be read?
if(checkForNewClients == true) {
if(checkForNewClients == true && this->canAcceptConnections == true) {
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());

View File

@ -133,6 +133,8 @@ private:
int playerStatus;
string playerLanguage;
bool canAcceptConnections;
public:
ConnectionSlot(ServerInterface* serverInterface, int playerIndex);
~ConnectionSlot();
@ -197,6 +199,9 @@ public:
PLATFORM_SOCKET getSocketId();
void setCanAcceptConnections(bool value) { canAcceptConnections = value; }
bool getCanAcceptConnections() const { return canAcceptConnections; }
protected:
Mutex * getServerSynchAccessor();