diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index 4d5a2a991..b013dd229 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -3,8 +3,8 @@ // // Copyright (C) 2001-2005 Martiņo Figueroa // -// You can redistribute this code and/or modify it under -// the terms of the GNU General Public License as published +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published // by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version // ============================================================== @@ -71,6 +71,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){ luaScript.registerFunction(getLastDeadUnitId, "lastDeadUnit"); luaScript.registerFunction(getUnitCount, "unitCount"); luaScript.registerFunction(getUnitCountOfType, "unitCountOfType"); + luaScript.registerFunction(unfogMap, "unfogMap"); //load code @@ -396,4 +397,14 @@ int ScriptManager::getUnitCountOfType(LuaHandle* luaHandle){ return luaArguments.getReturnCount(); } +void ScriptManager::unfogMap() { + world->setFogOfWar(false); +} + +int ScriptManager::unfogMap(LuaHandle* luaHandle){ + LuaArguments luaArguments(luaHandle); + thisScriptManager->unfogMap(); + return luaArguments.getReturnCount(); +} + }}//end namespace diff --git a/source/glest_game/game/script_manager.h b/source/glest_game/game/script_manager.h index ae896404f..4bb044659 100644 --- a/source/glest_game/game/script_manager.h +++ b/source/glest_game/game/script_manager.h @@ -3,8 +3,8 @@ // // Copyright (C) 2001-2005 Martiņo Figueroa // -// You can redistribute this code and/or modify it under -// the terms of the GNU General Public License as published +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published // by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version // ============================================================== @@ -16,7 +16,6 @@ #include #include "lua_script.h" -#include "vec.h" #include "components.h" #include "game_constants.h" @@ -122,7 +121,6 @@ public: void onUnitDied(const Unit* unit); private: - string wrapString(const string &str, int wrapCount); //wrappers, commands @@ -138,6 +136,7 @@ private: void disableAi(int factionIndex); void setPlayerAsWinner(int factionIndex); void endGame(); + void unfogMap(); //wrappers, queries Vec2i getStartLocation(int factionIndex); @@ -164,6 +163,7 @@ private: static int disableAi(LuaHandle* luaHandle); static int setPlayerAsWinner(LuaHandle* luaHandle); static int endGame(LuaHandle* luaHandle); + static int unfogMap(LuaHandle* luaHandle); //callbacks, queries static int getStartLocation(LuaHandle* luaHandle); diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 562dbb476..5f2d94972 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -39,6 +39,8 @@ const float World::airHeight= 5.f; World::World(){ Config &config= Config::getInstance(); + fogOfWarOverride = false; + fogOfWarSmoothing= config.getBool("FogOfWarSmoothing"); fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip"); @@ -57,11 +59,23 @@ void World::end(){ for(int i= 0; igetGameSettings() != NULL) { + game->getGameSettings()->setFogOfWar(fogOfWar); + initCells(fogOfWar); //must be done after knowing faction number and dimensions + initMinimap(); + } +} + void World::init(Game *game, bool createUnits){ this->game = game; @@ -70,7 +84,9 @@ void World::init(Game *game, bool createUnits){ unitUpdater.init(game); GameSettings *gs = game->getGameSettings(); - fogOfWar = gs->getFogOfWar(); + if(fogOfWarOverride == false) { + fogOfWar = gs->getFogOfWar(); + } initFactionTypes(gs); initCells(fogOfWar); //must be done after knowing faction number and dimensions @@ -502,9 +518,9 @@ void World::initCells(bool fogOfWar){ i/(next2Power(map.getSurfaceW())-1.f), j/(next2Power(map.getSurfaceH())-1.f))); - for (int k = 0; k < GameConstants::maxPlayers; k++) { - sc->setExplored(k, !fogOfWar); - sc->setVisible(k, !fogOfWar); + for (int k = 0; k < GameConstants::maxPlayers; k++) { + sc->setExplored(k, !fogOfWar); + sc->setVisible(k, !fogOfWar); } } } diff --git a/source/glest_game/world/world.h b/source/glest_game/world/world.h index 7a2e8b512..a98af70df 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -84,10 +84,11 @@ private: int nextUnitId; //config + bool fogOfWarOverride; bool fogOfWar; int fogOfWarSmoothingFrameSkip; - bool fogOfWarSmoothing; - Game *game; + bool fogOfWarSmoothing; + Game *game; bool allowRotateUnits; public: @@ -117,9 +118,9 @@ public: int getFrameCount() const {return frameCount;} //init & load - void init(Game *game, bool createUnits); + void init(Game *game, bool createUnits); void loadTileset(const vector pathList, const string &tilesetName, Checksum* checksum); - void loadTileset(const string &dir, Checksum* checksum); + void loadTileset(const string &dir, Checksum* checksum); void loadTech(const vector pathList, const string &techName, set &factions, Checksum* checksum); void loadMap(const string &path, Checksum* checksum); void loadScenario(const string &path, Checksum* checksum); @@ -145,10 +146,12 @@ public: Vec2i getUnitPosition(int unitId); int getUnitFactionIndex(int unitId); int getUnitCount(int factionIndex); - int getUnitCountOfType(int factionIndex, const string &typeName); - + int getUnitCountOfType(int factionIndex, const string &typeName); + Game * getGame() { return game; } + void setFogOfWar(bool value); + private: void initCells(bool fogOfWar); diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 438aea5d1..df96504c0 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -407,6 +407,8 @@ MouseButton Window::getMouseButton(int sdlButton) { default: //throw std::runtime_error("Mouse Button > 3 not handled."); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",__FILE__,__FUNCTION__,__LINE__,sdlButton); + + return mbUnknown; } }