diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 72e8f8a46..90b0e9bf9 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -3345,7 +3345,7 @@ void Game::checkWinnerStandard() { } void Game::checkWinnerScripted() { - if(scriptManager.getGameOver()) { + if(scriptManager.getIsGameOver()) { gameOver= true; for(int i= 0; igetWinner()) { diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index 1e4ef1e4b..06391136d 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -315,6 +315,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro luaScript.registerFunction(getUnitCount, "unitCount"); luaScript.registerFunction(getUnitCountOfType, "unitCountOfType"); + luaScript.registerFunction(getIsGameOver, "isGameOver"); luaScript.registerFunction(getGameWon, "gameWon"); luaScript.registerFunction(getSystemMacroValue, "getSystemMacroValue"); @@ -1207,11 +1208,16 @@ int ScriptManager::getWorldFrameCount() { return world->getFrameCount(); } -bool ScriptManager::getGameWon() { +bool ScriptManager::getGameWon() const { ScriptManager_STREFLOP_Wrapper streflopWrapper; return gameWon; } +bool ScriptManager::getIsGameOver() const { + ScriptManager_STREFLOP_Wrapper streflopWrapper; + return gameOver; +} + int ScriptManager::getLastCreatedUnitId() { if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); ScriptManager_STREFLOP_Wrapper streflopWrapper; @@ -2076,6 +2082,12 @@ int ScriptManager::getGameWon(LuaHandle* luaHandle){ return luaArguments.getReturnCount(); } +int ScriptManager::getIsGameOver(LuaHandle* luaHandle){ + LuaArguments luaArguments(luaHandle); + luaArguments.returnInt(thisScriptManager->getIsGameOver()); + return luaArguments.getReturnCount(); +} + int ScriptManager::loadScenario(LuaHandle* luaHandle) { LuaArguments luaArguments(luaHandle); thisScriptManager->loadScenario(luaArguments.getString(-2),luaArguments.getInt(-1)); diff --git a/source/glest_game/game/script_manager.h b/source/glest_game/game/script_manager.h index c8da5990f..3a52b1152 100644 --- a/source/glest_game/game/script_manager.h +++ b/source/glest_game/game/script_manager.h @@ -202,8 +202,6 @@ public: bool getMessageBoxEnabled() const {return !messageQueue.empty();} GraphicMessageBox* getMessageBox() {return &messageBox;} string getDisplayText() const {return displayText;} - bool getGameOver() const {return gameOver;} - bool getGameWon() const {return gameWon;} const PlayerModifiers *getPlayerModifiers(int factionIndex) const {return &playerModifiers[factionIndex];} //events @@ -217,6 +215,9 @@ public: void onCellTriggerEvent(Unit *movingUnit); void onTimerTriggerEvent(); + bool getGameWon() const; + bool getIsGameOver() const; + void saveGame(XmlNode *rootNode); void loadGame(const XmlNode *rootNode); @@ -311,8 +312,6 @@ private: int getUnitCount(int factionIndex); int getUnitCountOfType(int factionIndex, const string &typeName); - bool getGameWon(); - const string getSystemMacroValue(const string &key); const string getPlayerName(int factionIndex); @@ -412,6 +411,7 @@ private: static int getUnitCountOfType(LuaHandle* luaHandle); static int getGameWon(LuaHandle* luaHandle); + static int getIsGameOver(LuaHandle* luaHandle); static int getSystemMacroValue(LuaHandle* luaHandle); static int getPlayerName(LuaHandle* luaHandle);