mirror of
https://github.com/glest/glest-source.git
synced 2025-08-11 10:54:01 +02:00
Ported 3.3.4.2 fixes to trunk
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// 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(getLastDeadUnitId, "lastDeadUnit");
|
||||||
luaScript.registerFunction(getUnitCount, "unitCount");
|
luaScript.registerFunction(getUnitCount, "unitCount");
|
||||||
luaScript.registerFunction(getUnitCountOfType, "unitCountOfType");
|
luaScript.registerFunction(getUnitCountOfType, "unitCountOfType");
|
||||||
|
luaScript.registerFunction(unfogMap, "unfogMap");
|
||||||
|
|
||||||
|
|
||||||
//load code
|
//load code
|
||||||
@@ -396,4 +397,14 @@ int ScriptManager::getUnitCountOfType(LuaHandle* luaHandle){
|
|||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptManager::unfogMap() {
|
||||||
|
world->setFogOfWar(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScriptManager::unfogMap(LuaHandle* luaHandle){
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
thisScriptManager->unfogMap();
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include "lua_script.h"
|
#include "lua_script.h"
|
||||||
#include "vec.h"
|
|
||||||
|
|
||||||
#include "components.h"
|
#include "components.h"
|
||||||
#include "game_constants.h"
|
#include "game_constants.h"
|
||||||
@@ -122,7 +121,6 @@ public:
|
|||||||
void onUnitDied(const Unit* unit);
|
void onUnitDied(const Unit* unit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
string wrapString(const string &str, int wrapCount);
|
string wrapString(const string &str, int wrapCount);
|
||||||
|
|
||||||
//wrappers, commands
|
//wrappers, commands
|
||||||
@@ -138,6 +136,7 @@ private:
|
|||||||
void disableAi(int factionIndex);
|
void disableAi(int factionIndex);
|
||||||
void setPlayerAsWinner(int factionIndex);
|
void setPlayerAsWinner(int factionIndex);
|
||||||
void endGame();
|
void endGame();
|
||||||
|
void unfogMap();
|
||||||
|
|
||||||
//wrappers, queries
|
//wrappers, queries
|
||||||
Vec2i getStartLocation(int factionIndex);
|
Vec2i getStartLocation(int factionIndex);
|
||||||
@@ -164,6 +163,7 @@ private:
|
|||||||
static int disableAi(LuaHandle* luaHandle);
|
static int disableAi(LuaHandle* luaHandle);
|
||||||
static int setPlayerAsWinner(LuaHandle* luaHandle);
|
static int setPlayerAsWinner(LuaHandle* luaHandle);
|
||||||
static int endGame(LuaHandle* luaHandle);
|
static int endGame(LuaHandle* luaHandle);
|
||||||
|
static int unfogMap(LuaHandle* luaHandle);
|
||||||
|
|
||||||
//callbacks, queries
|
//callbacks, queries
|
||||||
static int getStartLocation(LuaHandle* luaHandle);
|
static int getStartLocation(LuaHandle* luaHandle);
|
||||||
|
@@ -39,6 +39,8 @@ const float World::airHeight= 5.f;
|
|||||||
World::World(){
|
World::World(){
|
||||||
Config &config= Config::getInstance();
|
Config &config= Config::getInstance();
|
||||||
|
|
||||||
|
fogOfWarOverride = false;
|
||||||
|
|
||||||
fogOfWarSmoothing= config.getBool("FogOfWarSmoothing");
|
fogOfWarSmoothing= config.getBool("FogOfWarSmoothing");
|
||||||
fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip");
|
fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip");
|
||||||
|
|
||||||
@@ -57,11 +59,23 @@ void World::end(){
|
|||||||
for(int i= 0; i<factions.size(); ++i){
|
for(int i= 0; i<factions.size(); ++i){
|
||||||
factions[i].end();
|
factions[i].end();
|
||||||
}
|
}
|
||||||
|
fogOfWarOverride = false;
|
||||||
//stats will be deleted by BattleEnd
|
//stats will be deleted by BattleEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================== init ===============================================
|
// ========================== 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){
|
void World::init(Game *game, bool createUnits){
|
||||||
|
|
||||||
this->game = game;
|
this->game = game;
|
||||||
@@ -70,7 +84,9 @@ void World::init(Game *game, bool createUnits){
|
|||||||
unitUpdater.init(game);
|
unitUpdater.init(game);
|
||||||
|
|
||||||
GameSettings *gs = game->getGameSettings();
|
GameSettings *gs = game->getGameSettings();
|
||||||
fogOfWar = gs->getFogOfWar();
|
if(fogOfWarOverride == false) {
|
||||||
|
fogOfWar = gs->getFogOfWar();
|
||||||
|
}
|
||||||
|
|
||||||
initFactionTypes(gs);
|
initFactionTypes(gs);
|
||||||
initCells(fogOfWar); //must be done after knowing faction number and dimensions
|
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),
|
i/(next2Power(map.getSurfaceW())-1.f),
|
||||||
j/(next2Power(map.getSurfaceH())-1.f)));
|
j/(next2Power(map.getSurfaceH())-1.f)));
|
||||||
|
|
||||||
for (int k = 0; k < GameConstants::maxPlayers; k++) {
|
for (int k = 0; k < GameConstants::maxPlayers; k++) {
|
||||||
sc->setExplored(k, !fogOfWar);
|
sc->setExplored(k, !fogOfWar);
|
||||||
sc->setVisible(k, !fogOfWar);
|
sc->setVisible(k, !fogOfWar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -84,10 +84,11 @@ private:
|
|||||||
int nextUnitId;
|
int nextUnitId;
|
||||||
|
|
||||||
//config
|
//config
|
||||||
|
bool fogOfWarOverride;
|
||||||
bool fogOfWar;
|
bool fogOfWar;
|
||||||
int fogOfWarSmoothingFrameSkip;
|
int fogOfWarSmoothingFrameSkip;
|
||||||
bool fogOfWarSmoothing;
|
bool fogOfWarSmoothing;
|
||||||
Game *game;
|
Game *game;
|
||||||
bool allowRotateUnits;
|
bool allowRotateUnits;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -117,9 +118,9 @@ public:
|
|||||||
int getFrameCount() const {return frameCount;}
|
int getFrameCount() const {return frameCount;}
|
||||||
|
|
||||||
//init & load
|
//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 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 loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum);
|
||||||
void loadMap(const string &path, Checksum* checksum);
|
void loadMap(const string &path, Checksum* checksum);
|
||||||
void loadScenario(const string &path, Checksum* checksum);
|
void loadScenario(const string &path, Checksum* checksum);
|
||||||
@@ -145,10 +146,12 @@ public:
|
|||||||
Vec2i getUnitPosition(int unitId);
|
Vec2i getUnitPosition(int unitId);
|
||||||
int getUnitFactionIndex(int unitId);
|
int getUnitFactionIndex(int unitId);
|
||||||
int getUnitCount(int factionIndex);
|
int getUnitCount(int factionIndex);
|
||||||
int getUnitCountOfType(int factionIndex, const string &typeName);
|
int getUnitCountOfType(int factionIndex, const string &typeName);
|
||||||
|
|
||||||
Game * getGame() { return game; }
|
Game * getGame() { return game; }
|
||||||
|
|
||||||
|
void setFogOfWar(bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void initCells(bool fogOfWar);
|
void initCells(bool fogOfWar);
|
||||||
|
@@ -407,6 +407,8 @@ MouseButton Window::getMouseButton(int sdlButton) {
|
|||||||
default:
|
default:
|
||||||
//throw std::runtime_error("Mouse Button > 3 not handled.");
|
//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);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",__FILE__,__FUNCTION__,__LINE__,sdlButton);
|
||||||
|
|
||||||
|
return mbUnknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user