Ported 3.3.4.2 fixes to trunk

This commit is contained in:
Mark Vejvoda 2010-04-23 04:29:11 +00:00
commit a50b89e9cc
5 changed files with 48 additions and 16 deletions

View File

@ -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

View File

@ -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 <queue>
#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);

View File

@ -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; i<factions.size(); ++i){
factions[i].end();
}
fogOfWarOverride = false;
//stats will be deleted by BattleEnd
}
// ========================== init ===============================================
void World::setFogOfWar(bool value) {
fogOfWar = value;
fogOfWarOverride = true;
if(game != NULL && game->getGameSettings() != 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);
}
}
}

View File

@ -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<string> pathList, const string &tilesetName, Checksum* checksum);
void loadTileset(const string &dir, Checksum* checksum);
void loadTileset(const string &dir, Checksum* checksum);
void loadTech(const vector<string> pathList, const string &techName, set<string> &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);

View File

@ -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;
}
}