From a8255e5c9777be1f258632414ad93f74a4d4143d Mon Sep 17 00:00:00 2001 From: Andy Alt Date: Mon, 5 Feb 2018 16:01:29 -0600 Subject: [PATCH] [closes #13] enhanced observer mode additions and cleanup (#45) * additions and cleanup [skip ci] * disallow observers to change their faction and team [skip ci] * disable observer slots from admin control * when checkboxObserversAllowed is toggled, update correctly * Also adjusted the labels better * when scenario is checked, observer mode is disabled and extra slots are closed * attempted to add a feature that would allow the admin to change to a different slot (doesn't work yet) * graphics still needs some adjustment * host can not go to a slot > mapInfo.maxPlayers --- .../menu/menu_state_connected_game.cpp | 66 +++--- .../menu/menu_state_custom_game.cpp | 204 +++++++++++++----- source/glest_game/world/map.cpp | 16 +- source/shared_lib/include/map/map_preview.h | 2 + source/shared_lib/sources/map/map_preview.cpp | 4 + 5 files changed, 199 insertions(+), 93 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index a047a8715..b4d644631 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -201,16 +201,19 @@ namespace Glest vector < string > teamItems, controlItems, results, rMultiplier, playerStatuses; + + // Some of these values must also be changed to match those in + // menu_state_custom_game.cpp int labelOffset = 23; int - setupPos = 590; - int - mapHeadPos = 300; //330; + setupPos = 605; + // mapHeadPos is the placement of the text "map", not the map itself + int mapHeadPos = 310; int mapPos = mapHeadPos - labelOffset; int - aHeadPos = 240; + aHeadPos = mapHeadPos - 90; int aPos = aHeadPos - labelOffset; int @@ -300,7 +303,8 @@ namespace Glest checkBoxAllowObservers.registerGraphicComponent (containerName, "checkBoxAllowObservers"); checkBoxAllowObservers.init (xoffset + 325, aPos); - checkBoxAllowObservers.setValue (false); + checkBoxAllowObservers.setValue (checkBoxAllowObservers.getValue ()); + checkBoxAllowObservers.setEditable (false); for (int i = 0; i < 45; ++i) @@ -629,7 +633,7 @@ namespace Glest int buttonx = 165; int - buttony = 180; + buttony = 150; listBoxPlayerStatus.registerGraphicComponent (containerName, "listBoxPlayerStatus"); @@ -898,6 +902,21 @@ namespace Glest extractFileFromDirectoryPath (__FILE__).c_str (), __FUNCTION__, __LINE__); + + // I moved this block from loadMapInfo(), and modified it. It was + // setting the slots visible based on the number of hardMaxPlayers + // every time a new map was loaded. Trying it here instead, so the + // labels are made visible only once. Below, we'll be disabling slots + // that exceed hardMaxPlayers + for (int i = 0; i < GameConstants::maxPlayers; i++) + { + labelPlayers[i].setVisible (true); + labelPlayerNames[i].setVisible (true); + listBoxControls[i].setVisible (true); + listBoxFactions[i].setVisible (true); + listBoxTeams[i].setVisible (true); + labelNetStatus[i].setVisible (true); + } } void @@ -4516,8 +4535,8 @@ namespace Glest { bool hasOtherPlayer = false; bool hasOpenSlot = false; - for (unsigned int i = 0; - i < (unsigned int) GameConstants::maxPlayers; ++i) + for (int i = 0; + i < GameConstants::maxPlayers; ++i) { if (displayedGamesettings.getFactionControl (i) == ctNetwork && clientInterface->getPlayerIndex () != (int) i) @@ -6910,18 +6929,7 @@ namespace Glest (file, mapInfo, lang.getString ("MaxPlayers"), lang.getString ("Size"), true) == true) { - for (int i = 0; i < GameConstants::maxPlayers; ++i) - { - mapInfo->players = GameConstants::maxPlayers; - bool visible = i + 1 <= mapInfo->players; - labelPlayers[i].setVisible (visible); - labelPlayerNames[i].setVisible (visible); - listBoxControls[i].setVisible (visible); - listBoxRMultiplier[i].setVisible (visible); - listBoxFactions[i].setVisible (visible); - listBoxTeams[i].setVisible (visible); - labelNetStatus[i].setVisible (visible); - } + mapInfo->players = GameConstants::maxPlayers; // Not painting properly so this is on hold if (loadMapPreview == true) @@ -8667,8 +8675,16 @@ namespace Glest { if (clientInterface->getJoinGameInProgress () == false) { - listBoxFactions[slot].setEditable (true); - listBoxTeams[slot].setEditable (true); + if (i + 1 <= mapInfo.hardMaxPlayers) + { + listBoxFactions[slot].setEditable (true); + listBoxTeams[slot].setEditable (true); + } + else + { + listBoxFactions[slot].setEditable (false); + listBoxTeams[slot].setEditable (false); + } } } @@ -8953,12 +8969,12 @@ namespace Glest mapInfo.desc.c_str ()); throw megaglest_runtime_error (szBuf); } - playerSortedMaps[mapInfo.players].push_back (mapFiles.at (i)); - formattedPlayerSortedMaps[mapInfo.players].push_back (formatString + playerSortedMaps[mapInfo.hardMaxPlayers].push_back (mapFiles.at (i)); + formattedPlayerSortedMaps[mapInfo.hardMaxPlayers].push_back (formatString (mapFiles.at (i))); if (config.getString ("InitialMap", "Conflict") == - formattedPlayerSortedMaps[mapInfo.players].back ()) + formattedPlayerSortedMaps[mapInfo.hardMaxPlayers].back ()) { initialMapSelection = i; } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 4923171fa..ff6b7ef5d 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -12,7 +12,7 @@ // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -243,11 +243,14 @@ namespace Glest techTree.reset (new TechTree (config.getPathListForType (ptTechs))); + // Some of these values must also be changed to match those in + // menu_state_connected_game.cpp int labelOffset = 23; int setupPos = 605; - int mapHeadPos = 300; //330; + // mapHeadPos is the placement of the text "map", not the map itself + int mapHeadPos = 310; int mapPos = mapHeadPos - labelOffset; - int aHeadPos = 240; + int aHeadPos = mapHeadPos - 90; int aPos = aHeadPos - labelOffset; int networkHeadPos = 700; int networkPos = networkHeadPos - labelOffset; @@ -255,7 +258,7 @@ namespace Glest //create int buttonx = 165; - int buttony = 180; + int buttony = mapHeadPos - 150; // player status listBoxPlayerStatus.registerGraphicComponent (containerName, @@ -417,7 +420,7 @@ namespace Glest checkBoxAllowObservers.registerGraphicComponent (containerName, "checkBoxAllowObservers"); checkBoxAllowObservers.init (xoffset + 325, aPos); - checkBoxAllowObservers.setValue (false); + checkBoxAllowObservers.setValue (checkBoxAllowObservers.getValue ()); vector < string > rMultiplier; for (int i = 0; i < 45; ++i) @@ -653,9 +656,16 @@ namespace Glest (checkBoxAllowTeamResourceSharing.getX (), networkHeadPos); checkBoxNetworkPauseGameForLaggedClients.setValue (true); -//list boxes + //list boxes xoffset = 5; int rowHeight = 27; + + buttonClearBlockedPlayers.registerGraphicComponent (containerName, + "buttonClearBlockedPlayers"); + buttonClearBlockedPlayers.init (xoffset + 800, + setupPos - 30, + 134 + 2 + 50); + for (int i = 0; i < GameConstants::maxPlayers; ++i) { @@ -729,12 +739,6 @@ namespace Glest setFont3D (CoreData::getInstance ().getDisplayFontSmall3D ()); } - buttonClearBlockedPlayers.registerGraphicComponent (containerName, - "buttonClearBlockedPlayers"); - buttonClearBlockedPlayers.init (xoffset + 160, - setupPos - 30 - 8 * rowHeight, - 174 + 2 + 70); - labelControl.registerGraphicComponent (containerName, "labelControl"); labelControl.init (xoffset + 160, setupPos, 50, GraphicListBox::defH, true); @@ -839,6 +843,21 @@ namespace Glest labelNetStatus[i].setText (""); } + // I moved this block from loadMapInfo(), and modified it. It was + // setting the slots visible based on the number of hardMaxPlayers + // every time a new map was loaded. Trying it here instead, so the + // labels are made visible only once. Below, we'll be disabling slots + // that exceed hardMaxPlayers + for (int i = 0; i < GameConstants::maxPlayers; i++) + { + labelPlayers[i].setVisible (true); + labelPlayerNames[i].setVisible (true); + listBoxControls[i].setVisible (true); + listBoxFactions[i].setVisible (true); + listBoxTeams[i].setVisible (true); + labelNetStatus[i].setVisible (true); + } + loadMapInfo (Config::getMapPath (getCurrentMapFile ()), &mapInfo, true); labelMapInfo.setText (mapInfo.desc); @@ -2325,6 +2344,14 @@ namespace Glest } } } + else if (labelPlayers[i].mouseClick (x, y)) + { + listBoxControls[i].setEditable (true); + listBoxControls[i].setEnabled (true); + listBoxControls[i].setSelectedItemIndex (ctHuman); + //updateNetworkSlots (); + + } else if (buttonBlockPlayers[i].mouseClick (x, y)) { soundRenderer.playFx (coreData.getClickSoundB ()); @@ -3329,7 +3356,6 @@ namespace Glest ctNetworkUnassigned) { //printf("Player #%d [%s] control = %d\n",i,labelPlayerNames[i].getText().c_str(),listBoxControls[i].getSelectedItemIndex()); - labelPlayers[i].setVisible (true); labelPlayerNames[i].setVisible (true); listBoxControls[i].setVisible (true); @@ -3601,13 +3627,33 @@ namespace Glest && switchSetupRequests[i]->getSelectedFactionName () != "???DataMissing???")) { - listBoxFactions[newFactionIdx].setSelectedItem - (switchSetupRequests[i]->getSelectedFactionName ()); + // I don't believe we need to check to see if Observers + // are allowed. If it's not, there should be not button on the client + // side that would allow them to switch to a slot > mapInfo.hardMaxPlayers + if (newFactionIdx <= mapInfo.hardMaxPlayers) + { + + listBoxFactions[newFactionIdx].setSelectedItem + (switchSetupRequests[i]->getSelectedFactionName ()); + } + else + { + listBoxFactions[newFactionIdx].setSelectedItem (GameConstants::OBSERVER_SLOTNAME); + } + } if (switchSetupRequests[i]->getToTeam () != -1) { - listBoxTeams[newFactionIdx].setSelectedItemIndex - (switchSetupRequests[i]->getToTeam ()); + if (newFactionIdx <= mapInfo.hardMaxPlayers) + { + listBoxTeams[newFactionIdx].setSelectedItemIndex + (switchSetupRequests[i]->getToTeam ()); + } + else + { + listBoxTeams[i].setSelectedItem (intToStr (GameConstants::maxPlayers + + fpt_Observer)); + } } if (switchSetupRequests[i]->getNetworkPlayerName () != "") { @@ -4315,14 +4361,34 @@ namespace Glest if (checkBoxScenario.getValue () == false) { + // When scenario is checked the value for mapInfo.players is reset to + // hardMaxPlayers. This resets it. + mapInfo.players = checkBoxAllowObservers.getValue () == true ? + GameConstants::maxPlayers : + mapInfo.hardMaxPlayers; + for (int i = 0; i < GameConstants::maxPlayers; ++i) { - if (i >= mapInfo.players) + if (i >= mapInfo.hardMaxPlayers && checkBoxAllowObservers.getValue() == false) { + listBoxControls[i].setSelectedItemIndex (ctClosed); listBoxControls[i].setEditable (false); listBoxControls[i].setEnabled (false); - -//printf("In [%s::%s] Line: %d i = %d mapInfo.players = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,mapInfo.players); + listBoxRMultiplier[i].setEditable (false); + listBoxRMultiplier[i].setEnabled (false); + } + else if (i >= mapInfo.hardMaxPlayers && checkBoxAllowObservers.getValue() == true) + { + listBoxControls[i].setSelectedItemIndex (ctNetwork); + listBoxControls[i].setEditable (false); + listBoxFactions[i].setSelectedItem (GameConstants::OBSERVER_SLOTNAME); + listBoxFactions[i].setEditable (false); + listBoxTeams[i].setSelectedItem (intToStr (GameConstants::maxPlayers + + fpt_Observer)); + listBoxTeams[i].setEditable (false); + listBoxRMultiplier[i].setEditable (false); + listBoxRMultiplier[i].setEnabled (false); + listBoxRMultiplier[i].setVisible (false); } else if (listBoxControls[i].getSelectedItemIndex () != ctNetworkUnassigned) @@ -4336,6 +4402,8 @@ namespace Glest { listBoxControls[i].setEditable (true); listBoxControls[i].setEnabled (true); + listBoxFactions[i].setEditable (true); + listBoxTeams[i].setEditable (true); } else { @@ -4354,6 +4422,18 @@ namespace Glest } } } + else // if this is a scenario... + { + int i = mapInfo.players; + do + { + listBoxControls[i].setSelectedItemIndex (ctClosed); + listBoxControls[i].setEditable (false); + listBoxControls[i].setEnabled (false); + } while (++i < GameConstants::maxPlayers); + } + + updateNetworkSlots (); bool checkDataSynch = (serverInterface->getAllowGameDataSynchCheck () == true @@ -5685,14 +5765,17 @@ namespace Glest gameSettings->setFactionControl (slotIndex, ct); if (ct == ctHuman) { - if (SystemFlags::getSystemSettingType (SystemFlags::debugSystem). - enabled) - SystemFlags::OutputDebug (SystemFlags::debugSystem, + +// I'm putting this inside a ppd for now. I don't see it needs to be +// built in unless DEBUG is defined during building -andy5995 2018-01-26 +#ifdef DEBUG + SystemFlags::OutputDebug (SystemFlags::debugSystem, "In [%s::%s Line: %d] i = %d, slotIndex = %d, getHumanPlayerName(i) [%s]\n", extractFileFromDirectoryPath (__FILE__).c_str (), __FUNCTION__, __LINE__, i, slotIndex, getHumanPlayerName (i).c_str ()); +#endif gameSettings->setThisFactionIndex (slotIndex); gameSettings->setNetworkPlayerName (slotIndex, @@ -5720,24 +5803,22 @@ namespace Glest ()); } -//if(slotIndex == 0) printf("slotIndex = %d, i = %d, multiplier = %d\n",slotIndex,i,listBoxRMultiplier[i].getSelectedItemIndex()); - -//printf("Line: %d multiplier index: %d slotIndex: %d\n",__LINE__,listBoxRMultiplier[i].getSelectedItemIndex(),slotIndex); gameSettings->setResourceMultiplierIndex (slotIndex, listBoxRMultiplier [i].getSelectedItemIndex ()); -//printf("Line: %d multiplier index: %d slotIndex: %d\n",__LINE__,gameSettings->getResourceMultiplierIndex(slotIndex),slotIndex); - if (SystemFlags::getSystemSettingType (SystemFlags::debugSystem). - enabled) - SystemFlags::OutputDebug (SystemFlags::debugSystem, +// I'm putting this inside a ppd for now. I don't see it needs to be +// built in unless DEBUG is defined during building -andy5995 2018-01-26 +#ifdef DEBUG + SystemFlags::OutputDebug (SystemFlags::debugSystem, "In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n", extractFileFromDirectoryPath (__FILE__). c_str (), __FUNCTION__, __LINE__, i, factionFiles[listBoxFactions [i].getSelectedItemIndex ()].c_str ()); +#endif gameSettings->setFactionTypeName (slotIndex, factionFiles[listBoxFactions @@ -5810,9 +5891,10 @@ namespace Glest true)->getNetworkPlayerStatus ()); - if (SystemFlags::getSystemSettingType - (SystemFlags::debugSystem).enabled) - SystemFlags::OutputDebug (SystemFlags::debugSystem, +// I'm putting this inside a ppd for now. I don't see it needs to be +// built in unless DEBUG is defined during building -andy5995 2018-01-26 +#ifdef DEBUG + SystemFlags::OutputDebug (SystemFlags::debugSystem, "In [%s::%s Line: %d] i = %d, connectionSlot->getName() [%s]\n", extractFileFromDirectoryPath (__FILE__).c_str (), __FUNCTION__, @@ -5820,6 +5902,7 @@ namespace Glest serverInterface->getSlot (i, true)->getName ().c_str ()); +#endif gameSettings->setNetworkPlayerName (slotIndex, serverInterface->getSlot (i, @@ -5838,13 +5921,16 @@ namespace Glest } else { - if (SystemFlags::getSystemSettingType - (SystemFlags::debugSystem).enabled) - SystemFlags::OutputDebug (SystemFlags::debugSystem, + +// I'm putting this inside a ppd for now. I don't see it needs to be +// built in unless DEBUG is defined during building -andy5995 2018-01-26 +#ifdef DEBUG + SystemFlags::OutputDebug (SystemFlags::debugSystem, "In [%s::%s Line: %d] i = %d, playername unconnected\n", extractFileFromDirectoryPath (__FILE__).c_str (), __FUNCTION__, __LINE__, i); +#endif gameSettings->setNetworkPlayerName (slotIndex, GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME); @@ -5854,13 +5940,14 @@ namespace Glest else if (listBoxControls[i].getSelectedItemIndex () != ctHuman) { AIPlayerCount++; - if (SystemFlags::getSystemSettingType (SystemFlags::debugSystem). - enabled) - SystemFlags::OutputDebug (SystemFlags::debugSystem, + +#ifdef DEBUG + SystemFlags::OutputDebug (SystemFlags::debugSystem, "In [%s::%s Line: %d] i = %d, playername is AI (blank)\n", extractFileFromDirectoryPath (__FILE__).c_str (), __FUNCTION__, __LINE__, i); +#endif Lang & lang = Lang::getInstance (); gameSettings->setNetworkPlayerName (slotIndex, @@ -6089,16 +6176,16 @@ namespace Glest { time_t clientConnectedTime = 0; bool masterserver_admin_found = false; -//printf("mapInfo.players [%d]\n",mapInfo.players); for (int i = 0; i < mapInfo.players; ++i) { - if (SystemFlags::getSystemSettingType (SystemFlags::debugSystem). - enabled) - SystemFlags::OutputDebug (SystemFlags::debugSystem, + +#ifdef DEBUG + SystemFlags::OutputDebug (SystemFlags::debugSystem, "In [%s::%s Line %d]\n", extractFileFromDirectoryPath (__FILE__). c_str (), __FUNCTION__, __LINE__); +#endif if (listBoxControls[i].getSelectedItemIndex () == ctNetwork || listBoxControls[i].getSelectedItemIndex () == @@ -6414,7 +6501,7 @@ namespace Glest //printf("#6.2\n"); listBoxMapFilter.setSelectedItemIndex (0); - listBoxMap.setItems (formattedPlayerSortedMaps[mapInfo.players]); + listBoxMap.setItems (formattedPlayerSortedMaps[mapInfo.hardMaxPlayers]); listBoxMap.setSelectedItem (formatString (scenarioInfo.mapName)); } else @@ -6784,6 +6871,16 @@ namespace Glest (file, mapInfo, lang.getString ("MaxPlayers"), lang.getString ("Size"), true) == true) { + // Though we prefer not to change the actual value of mapInfo->players, + // which is the number of players assigned when making the map, we still know + // the actual value from mapInfo.hardMaxPlayers. Changing it here means + // not having to change a variable name in many places of this file + // to implement enhanced observer mode (issue #13)' + if (checkBoxAllowObservers.getValue () == 1) + { + mapInfo->players = GameConstants::maxPlayers; + } + ServerInterface *serverInterface = NetworkManager::getInstance ().getServerInterface (); for (int i = 0; i < GameConstants::maxPlayers; ++i) @@ -6804,13 +6901,6 @@ namespace Glest } } } - mapInfo->players = GameConstants::maxPlayers; - labelPlayers[i].setVisible (i + 1 <= mapInfo->players); - labelPlayerNames[i].setVisible (i + 1 <= mapInfo->players); - listBoxControls[i].setVisible (i + 1 <= mapInfo->players); - listBoxFactions[i].setVisible (i + 1 <= mapInfo->players); - listBoxTeams[i].setVisible (i + 1 <= mapInfo->players); - labelNetStatus[i].setVisible (i + 1 <= mapInfo->players); } // Not painting properly so this is on hold @@ -7569,6 +7659,8 @@ namespace Glest listBoxTileset.setSelectedItem (formatString (scenarioInfo.tilesetName)); + checkBoxAllowObservers.setValue (false); + setupMapList (scenarioInfo.name); listBoxMap.setSelectedItem (formatString (scenarioInfo.mapName)); loadMapInfo (Config::getMapPath @@ -7800,6 +7892,7 @@ namespace Glest (formattedPlayerSortedMaps[0][0])); loadMapInfo (Config::getMapPath (getCurrentMapFile (), "", true), &mapInfo, true); + labelMapInfo.setText (mapInfo.desc); setupTechList ("", false); @@ -7960,12 +8053,12 @@ namespace Glest mapInfo.desc.c_str ()); throw megaglest_runtime_error (szBuf); } - playerSortedMaps[mapInfo.players].push_back (mapFiles.at (i)); - formattedPlayerSortedMaps[mapInfo.players].push_back (formatString + playerSortedMaps[mapInfo.hardMaxPlayers].push_back (mapFiles.at (i)); + formattedPlayerSortedMaps[mapInfo.hardMaxPlayers].push_back (formatString (mapFiles.at (i))); if (config.getString ("InitialMap", "Conflict") == - formattedPlayerSortedMaps[mapInfo.players].back ()) + formattedPlayerSortedMaps[mapInfo.hardMaxPlayers].back ()) { initialMapSelection = i; } @@ -7981,7 +8074,7 @@ namespace Glest loadMapInfo (Config::getMapPath (scenarioInfo.mapName, scenarioDir, true), &mapInfo, false); -//printf("#6.2\n"); + listBoxMapFilter.setSelectedItem (intToStr (mapInfo.players)); listBoxMap.setItems (formattedPlayerSortedMaps[mapInfo.players]); } @@ -8194,7 +8287,6 @@ namespace Glest originalValue == formatString (GameConstants::OBSERVER_SLOTNAME))) { - listBoxFactions[i].setSelectedItemIndex (i % results.size ()); if (originalValue == diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 6538f2f67..0f5fdf0f5 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -391,21 +391,13 @@ void Map::end(){ } Vec2i Map::getStartLocation(int locationIndex) const { - // if(locationIndex >= maxPlayers) { - // char szBuf[8096]=""; - // snprintf(szBuf,8096,"locationIndex >= maxPlayers [%d] [%d]",locationIndex, maxPlayers); - // printf("%s\n",szBuf); - // throw megaglest_runtime_error(szBuf); - // assert(locationIndex < maxPlayers); - // } - // else if(startLocations == NULL) { - // throw megaglest_runtime_error("startLocations == NULL"); - // } - if(locationIndex < hardMaxPlayers) // maxPlayers for a map, not the Game return startLocations[locationIndex]; else if (locationIndex < maxPlayers) { - return startLocations[1]; + // needed for enhanced observer mode (issue #13) + // observer may be in slot 6 of a 4-player map. Just set the + // startLocation to 0 + return startLocations[0]; } else { char szBuf[8096]=""; diff --git a/source/shared_lib/include/map/map_preview.h b/source/shared_lib/include/map/map_preview.h index 48ac8d62f..0237c8a7c 100644 --- a/source/shared_lib/include/map/map_preview.h +++ b/source/shared_lib/include/map/map_preview.h @@ -99,11 +99,13 @@ public: Vec2i size; int players; + int hardMaxPlayers; string desc; MapInfo() { size = Vec2i(0,0); players = 0; + hardMaxPlayers = 0; desc = ""; } }; diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index d1eec5eaa..8e59333c0 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -1107,6 +1107,10 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla mapInfo->size.y = header.height; mapInfo->players= header.maxFactions; + // hardMaxPlayers is used in menu_state_custom_game, as part of + // enhanced observer mode (issue #13) + mapInfo->hardMaxPlayers = mapInfo->players; + mapInfo->desc = i18nMaxMapPlayersTitle + ": " + intToStr(mapInfo->players) + "\n"; mapInfo->desc += i18nMapSizeTitle + ": " + intToStr(mapInfo->size.x) + " x " + intToStr(mapInfo->size.y);