diff --git a/source/game/game/game.cpp b/source/game/game/game.cpp index 20574a0ad..5c4eb8521 100644 --- a/source/game/game/game.cpp +++ b/source/game/game/game.cpp @@ -4435,6 +4435,8 @@ namespace Game { if (faction->getFactionDisconnectHandled() == false && (faction->getControlType() == ctNetwork)) { + if (aiInterfaces.size() <= i) + aiInterfaces.push_back(NULL); if (aiInterfaces[i] == NULL && (server == NULL || server->isClientConnected(faction->getStartLocationIndex()) == false)) { diff --git a/source/game/game/script_manager.cpp b/source/game/game/script_manager.cpp index adc2b003c..88b2f2845 100644 --- a/source/game/game/script_manager.cpp +++ b/source/game/game/script_manager.cpp @@ -555,8 +555,7 @@ namespace Game { luaScript.registerFunction(storeSaveGameData, "storeSaveGameData"); luaScript.registerFunction(loadSaveGameData, "loadSaveGameData"); - luaScript.registerFunction(getFactionPlayerType, - "getFactionPlayerType"); + luaScript.registerFunction(getPlayerType, "getPlayerType"); map>> scripts; map>>::iterator iter; @@ -3397,7 +3396,9 @@ namespace Game { } ControlType - ScriptManager::getFactionPlayerType(int factionIndex) { + ScriptManager::getPlayerType(int factionIndex) { + if (factionIndex < 0 || factionIndex >= world->getFactionCount()) + return ctClosed; Faction * faction = world->getFaction(factionIndex); if (faction != NULL) { @@ -6104,12 +6105,12 @@ namespace Game { } int - ScriptManager::getFactionPlayerType(LuaHandle * luaHandle) { + ScriptManager::getPlayerType(LuaHandle * luaHandle) { LuaArguments luaArguments(luaHandle); try { luaArguments.returnInt(thisScriptManager-> - getFactionPlayerType(luaArguments. + getPlayerType(luaArguments. getInt(-1))); } catch (const game_runtime_error & ex) { error(luaHandle, &ex, __FILE__, __FUNCTION__, __LINE__); diff --git a/source/game/game/script_manager.h b/source/game/game/script_manager.h index 185a2cf0b..1c6d8f499 100644 --- a/source/game/game/script_manager.h +++ b/source/game/game/script_manager.h @@ -768,8 +768,7 @@ namespace Game { string loadSaveGameData(string name); - ControlType - getFactionPlayerType(int factionIndex); + ControlType getPlayerType(int factionIndex); // ----------------------------------------------------------------------- static void @@ -1091,8 +1090,7 @@ namespace Game { static int loadSaveGameData(LuaHandle * luaHandle); - static int - getFactionPlayerType(LuaHandle * luaHandle); + static int getPlayerType(LuaHandle * luaHandle); }; } //end namespace diff --git a/source/game/game/stats.cpp b/source/game/game/stats.cpp index 07bf22f48..360ac88de 100644 --- a/source/game/game/stats.cpp +++ b/source/game/game/stats.cpp @@ -53,15 +53,20 @@ namespace Game { case ctCpuEasy: controlString = lang.getString("CpuEasy"); break; - case ctCpu:controlString = lang.getString("Cpu"); + case ctCpu: + controlString = lang.getString("Cpu"); break; - case ctCpuUltra:controlString = lang.getString("CpuUltra"); + case ctCpuUltra: + controlString = lang.getString("CpuUltra"); break; - case ctCpuGlest:controlString = lang.getString("CpuGlest"); + case ctCpuGlest: + controlString = lang.getString("CpuGlest"); break; - case ctNetwork:controlString = lang.getString("Network"); + case ctNetwork: + controlString = lang.getString("Network"); break; - case ctHuman:controlString = lang.getString("Human"); + case ctHuman: + controlString = lang.getString("Human"); break; default: controlString = lang.getString("Closed"); diff --git a/source/game/main/battle_end.cpp b/source/game/main/battle_end.cpp index 75e7d381d..629261e0b 100644 --- a/source/game/main/battle_end.cpp +++ b/source/game/main/battle_end.cpp @@ -275,66 +275,69 @@ namespace Game { GameConstants::OBSERVER_SLOTNAME && fileExists(factionDefinitionXML) == true) { - if (SystemFlags::VERBOSE_MODE_ENABLED) - printf("#2 tech [%s] faction [%s]\n", - currentTechName_factionPreview.c_str(), - currentFactionName_factionPreview.c_str()); + try { + if (SystemFlags::VERBOSE_MODE_ENABLED) + printf("#2 tech [%s] faction [%s]\n", + currentTechName_factionPreview.c_str(), + currentFactionName_factionPreview.c_str()); - XmlTree xmlTree; - std::map < string, string > mapExtraTagReplacementValues; - xmlTree.load(factionDefinitionXML, - Properties::getTagReplacementValues - (&mapExtraTagReplacementValues)); - const XmlNode * - factionNode = xmlTree.getRootNode(); - if (won == true) { - if (factionNode->hasAttribute("battle-end-win-music") == true) { - result = - factionNode-> - getAttribute("battle-end-win-music")->getValue(); + XmlTree xmlTree; + std::map < string, string > mapExtraTagReplacementValues; + xmlTree.load(factionDefinitionXML, + Properties::getTagReplacementValues + (&mapExtraTagReplacementValues)); + const XmlNode * + factionNode = xmlTree.getRootNode(); + if (won == true) { + if (factionNode->hasAttribute("battle-end-win-music") == true) { + result = + factionNode-> + getAttribute("battle-end-win-music")->getValue(); + } + } else { + if (factionNode->hasAttribute("battle-end-lose-music") == true) { + result = + factionNode-> + getAttribute("battle-end-lose-music")->getValue(); + } } - } else { - if (factionNode->hasAttribute("battle-end-lose-music") == true) { - result = - factionNode-> - getAttribute("battle-end-lose-music")->getValue(); + + if (result != "" && fileExists(result) == false) { + string techTreePath = ""; + string factionPath = ""; + std::vector < std::string > factionPartsList; + Tokenize(factionDefinitionXML, factionPartsList, "factions/"); + if (factionPartsList.size() > 1) { + techTreePath = factionPartsList[0]; + + string + factionPath = + techTreePath + "factions/" + + currentFactionName_factionPreview; + endPathWithSlash(factionPath); + result = factionPath + result; + } } - } - if (result != "" && fileExists(result) == false) { - string techTreePath = ""; - string factionPath = ""; - std::vector < std::string > factionPartsList; - Tokenize(factionDefinitionXML, factionPartsList, "factions/"); - if (factionPartsList.size() > 1) { - techTreePath = factionPartsList[0]; - - string - factionPath = - techTreePath + "factions/" + - currentFactionName_factionPreview; - endPathWithSlash(factionPath); - result = factionPath + result; + if (won == true) { + resultFallback = + Game::findFactionLogoFile(gameSettings, NULL, + "battle_end_win_music.*"); + } else { + resultFallback = + Game::findFactionLogoFile(gameSettings, NULL, + "battle_end_lose_music.*"); } - } - if (won == true) { - resultFallback = - Game::findFactionLogoFile(gameSettings, NULL, - "battle_end_win_music.*"); - } else { - resultFallback = - Game::findFactionLogoFile(gameSettings, NULL, - "battle_end_lose_music.*"); - } + if (SystemFlags::VERBOSE_MODE_ENABLED) + printf("#3 result [%s] resultFallback [%s]\n", result.c_str(), + resultFallback.c_str()); + //printf("#3 result [%s] resultFallback [%s]\n",result.c_str(),resultFallback.c_str()); - if (SystemFlags::VERBOSE_MODE_ENABLED) - printf("#3 result [%s] resultFallback [%s]\n", result.c_str(), - resultFallback.c_str()); - //printf("#3 result [%s] resultFallback [%s]\n",result.c_str(),resultFallback.c_str()); - - if (result == "") { - result = resultFallback; + if (result == "") { + result = resultFallback; + } + } catch (...) { } } //printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str()); diff --git a/source/game/menu/menu_state_custom_game.cpp b/source/game/menu/menu_state_custom_game.cpp index ae4c54918..87fbe4b2c 100644 --- a/source/game/menu/menu_state_custom_game.cpp +++ b/source/game/menu/menu_state_custom_game.cpp @@ -5873,7 +5873,7 @@ namespace Game { lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex(); } - // Alow Neutral cpu players + // Allow Neutral cpu players else if (listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == diff --git a/source/game/world/world.cpp b/source/game/world/world.cpp index cc2674269..dff3ca90f 100644 --- a/source/game/world/world.cpp +++ b/source/game/world/world.cpp @@ -1900,18 +1900,14 @@ namespace Game { void World::highlightUnit(int unitId, float radius, float thickness, Vec4f color) { Unit* unit = findUnitById(unitId); - if (unit == NULL) { - throw game_runtime_error("Can not find unit to set highlight unitId = " + intToStr(unitId), true); - } - game->highlightUnit(unitId, radius, thickness, color); + if (unit != NULL) + game->highlightUnit(unitId, radius, thickness, color); } void World::unhighlightUnit(int unitId) { Unit* unit = findUnitById(unitId); - if (unit == NULL) { - throw game_runtime_error("Can not find unit to set highlight unitId = " + intToStr(unitId), true); - } - game->unhighlightUnit(unitId); + if (unit != NULL) + game->unhighlightUnit(unitId); } diff --git a/source/shared_lib/include/versions.h b/source/shared_lib/include/versions.h index 40a48725c..d5a43565b 100644 --- a/source/shared_lib/include/versions.h +++ b/source/shared_lib/include/versions.h @@ -2,4 +2,4 @@ #define G3D_VIEWER_VERSION "1.0" #define MAP_EDITOR_VERSION "1.0" //Month then Day -#define GAME_BUILD_DATE "0306" +#define GAME_BUILD_DATE "0308"