- bugfix to close empty slots on game start

This commit is contained in:
Mark Vejvoda 2011-09-10 01:45:34 +00:00
parent 7a6e937133
commit b8a8e3b519
2 changed files with 14 additions and 3 deletions

View File

@ -1185,7 +1185,7 @@ void MenuStateCustomGame::PlayNow() {
safeMutex.ReleaseLock(true);
GameSettings gameSettings;
loadGameSettings(&gameSettings);
loadGameSettings(&gameSettings, true);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
@ -2272,7 +2272,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool forceCloseUnusedSlots) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
int factionCount= 0;
@ -2316,6 +2316,17 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
int AIPlayerCount = 0;
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
ControlType ct= static_cast<ControlType>(listBoxControls[i].getSelectedItemIndex());
if(forceCloseUnusedSlots == true && (ct == ctNetworkUnassigned || ct == ctNetwork)) {
if(serverInterface->getSlot(i) == NULL ||
serverInterface->getSlot(i)->isConnected() == false) {
//printf("Closed A [%d] [%s]\n",i,labelPlayerNames[i].getText().c_str());
listBoxControls[i].setSelectedItemIndex(ctClosed);
ct = ctClosed;
}
}
if(ct != ctClosed) {
int slotIndex = factionCount;

View File

@ -181,7 +181,7 @@ public:
private:
bool hasNetworkGameSettings();
void loadGameSettings(GameSettings *gameSettings);
void loadGameSettings(GameSettings *gameSettings, bool forceCloseUnusedSlots=false);
void loadMapInfo(string file, MapInfo *mapInfo,bool loadMapPreview);
void cleanupMapPreviewTexture();