From 848b84f1494cd52ae1f392b445dded101f54b1ff Mon Sep 17 00:00:00 2001 From: titison Date: Mon, 12 Jan 2015 17:21:29 +0100 Subject: [PATCH] shared team options in scenarios now you can enable sharedTeamUnits and sharedTeamResources in scenarios to do so use this two xml tags: put them in the node --- .../menu/menu_state_connected_game.cpp | 3 ++ .../menu/menu_state_custom_game.cpp | 5 +++ source/glest_game/world/scenario.cpp | 34 +++++++++++++++++++ source/glest_game/world/scenario.h | 6 ++++ 4 files changed, 48 insertions(+) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index d33aa046..09e26ca8 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -4565,6 +4565,9 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings, listBoxFogOfWar.setSelectedItemIndex(0); } + checkBoxAllowTeamUnitSharing.setValue(scenarioInfo.allowTeamUnitSharing); + checkBoxAllowTeamResourceSharing.setValue(scenarioInfo.allowTeamResourceSharing); + if(originalFOWValue != listBoxFogOfWar.getSelectedItemIndex()) { cleanupMapPreviewTexture(); } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 8ab49105..6a37ae43 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -3994,6 +3994,8 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin else { listBoxFogOfWar.setSelectedItemIndex(0); } + checkBoxAllowTeamUnitSharing.setValue(scenarioInfo.allowTeamUnitSharing); + checkBoxAllowTeamResourceSharing.setValue(scenarioInfo.allowTeamResourceSharing); } setupMapList(gameSettings.getScenario()); setupTechList(gameSettings.getScenario(),false); @@ -4691,6 +4693,9 @@ void MenuStateCustomGame::processScenario() { listBoxFogOfWar.setSelectedItemIndex(0); } + checkBoxAllowTeamUnitSharing.setValue(scenarioInfo.allowTeamUnitSharing); + checkBoxAllowTeamResourceSharing.setValue(scenarioInfo.allowTeamResourceSharing); + setupTechList(scenarioInfo.name, false); listBoxTechTree.setSelectedItem(formatString(scenarioInfo.techTreeName)); reloadFactions(false,scenarioInfo.name); diff --git a/source/glest_game/world/scenario.cpp b/source/glest_game/world/scenario.cpp index 442ebeb5..cb4259db 100644 --- a/source/glest_game/world/scenario.cpp +++ b/source/glest_game/world/scenario.cpp @@ -392,6 +392,22 @@ void Scenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo, bool is scenarioInfo->fogOfWar_exploredFlag = false; } + if(scenarioNode->hasChild("shared-team-units") == true) { + scenarioInfo->allowTeamUnitSharing=scenarioNode->getChild("shared-team-units")->getAttribute("value")->getBoolValue(); + //printf("\nallowTeamUnitSharing is set to [%B]\n",scenarioInfo->allowTeamUnitSharing); + } + else { + scenarioInfo->allowTeamUnitSharing = false; + } + + if(scenarioNode->hasChild("shared-team-resources") == true) { + scenarioInfo->allowTeamResourceSharing=scenarioNode->getChild("shared-team-resources")->getAttribute("value")->getBoolValue(); + //printf("\nallowTeamResourceSharing is set to [%B]\n",scenarioInfo->allowTeamResourceSharing); + } + else { + scenarioInfo->allowTeamResourceSharing = false; + } + scenarioInfo->file = file; scenarioInfo->name = extractFileFromDirectoryPath(file); scenarioInfo->name = cutLastExt(scenarioInfo->name); @@ -541,6 +557,24 @@ void Scenario::loadGameSettings(const vector &dirList, gameSettings->setFlagTypes1(valueFlags1); } + if(scenarioInfo->allowTeamUnitSharing == true) { + valueFlags1 |= ft1_allow_shared_team_units; + gameSettings->setFlagTypes1(valueFlags1); + } + else { + valueFlags1 &= ~ft1_allow_shared_team_units; + gameSettings->setFlagTypes1(valueFlags1); + } + + if(scenarioInfo->allowTeamResourceSharing == true) { + valueFlags1 |= ft1_allow_shared_team_resources; + gameSettings->setFlagTypes1(valueFlags1); + } + else { + valueFlags1 &= ~ft1_allow_shared_team_resources; + gameSettings->setFlagTypes1(valueFlags1); + } + gameSettings->setPathFinderType(static_cast(Config::getInstance().getInt("ScenarioPathFinderType",intToStr(pfBasic).c_str()))); } diff --git a/source/glest_game/world/scenario.h b/source/glest_game/world/scenario.h index 7184274c..549cb62c 100644 --- a/source/glest_game/world/scenario.h +++ b/source/glest_game/world/scenario.h @@ -68,6 +68,9 @@ public: fogOfWar = false; fogOfWar_exploredFlag = false; + allowTeamUnitSharing = false; + allowTeamResourceSharing = false; + file = ""; name = ""; namei18n = ""; @@ -91,6 +94,9 @@ public: bool fogOfWar; bool fogOfWar_exploredFlag; + bool allowTeamUnitSharing; + bool allowTeamResourceSharing; + string file; string name; string namei18n;