diff --git a/source/game/game/game.cpp b/source/game/game/game.cpp index 5c4eb8521..230475711 100644 --- a/source/game/game/game.cpp +++ b/source/game/game/game.cpp @@ -7705,7 +7705,14 @@ namespace Game { case ctCpuGlest: factionInfo += " CPU Glest" + multiplier; break; + case ctNetwork: + factionInfo += " (Network)"; + break; + case ctHuman: + factionInfo += " (Human)"; + break; default: + factionInfo += " (Closed)"; break; } diff --git a/source/game/game/script_manager.cpp b/source/game/game/script_manager.cpp index 88b2f2845..f9d19db89 100644 --- a/source/game/game/script_manager.cpp +++ b/source/game/game/script_manager.cpp @@ -556,6 +556,7 @@ namespace Game { luaScript.registerFunction(loadSaveGameData, "loadSaveGameData"); luaScript.registerFunction(getPlayerType, "getPlayerType"); + luaScript.registerFunction(setPlayerType, "setPlayerType"); map>> scripts; map>>::iterator iter; @@ -3406,6 +3407,23 @@ namespace Game { } return ctClosed; } + + void + ScriptManager::setPlayerType(int factionIndex, ControlType playerType) { + if (factionIndex < 0 || factionIndex >= world->getFactionCount() || playerType < ctClosed || playerType > ctHuman) + return; + Faction * + faction = world->getFaction(factionIndex); + if (faction != NULL) { + faction->setControlType(playerType); + GameSettings* settings = world->getGameSettingsPtr(); + if (settings != NULL) + settings->setFactionControl(factionIndex, playerType); + Stats* stats = world->getStats(); + if (stats != NULL) + stats->setControl(factionIndex, playerType); + } + } // ========================== lua callbacks =============================================== int @@ -6115,9 +6133,19 @@ namespace Game { } catch (const game_runtime_error & ex) { error(luaHandle, &ex, __FILE__, __FUNCTION__, __LINE__); } - return luaArguments.getReturnCount(); + } + int + ScriptManager::setPlayerType(LuaHandle * luaHandle) { + LuaArguments + luaArguments(luaHandle); + try { + thisScriptManager->setPlayerType(luaArguments.getInt(-2), static_cast(luaArguments.getInt(-1))); + } catch (const game_runtime_error & ex) { + error(luaHandle, &ex, __FILE__, __FUNCTION__, __LINE__); + } + return luaArguments.getReturnCount(); } void diff --git a/source/game/game/script_manager.h b/source/game/game/script_manager.h index 1c6d8f499..44d776f13 100644 --- a/source/game/game/script_manager.h +++ b/source/game/game/script_manager.h @@ -769,6 +769,8 @@ namespace Game { loadSaveGameData(string name); ControlType getPlayerType(int factionIndex); + void setPlayerType(int factionIndex, ControlType playerType); + // ----------------------------------------------------------------------- static void @@ -1091,6 +1093,7 @@ namespace Game { loadSaveGameData(LuaHandle * luaHandle); static int getPlayerType(LuaHandle * luaHandle); + static int setPlayerType(LuaHandle * luaHandle); }; } //end namespace