make FogOfWar a global pointer, not a static global
This commit is contained in:
parent
66390ec1ae
commit
7127bd00ff
8 changed files with 22 additions and 21 deletions
src
|
@ -204,7 +204,7 @@ private:
|
|||
const uint32_t (*CurrUpscaleTableExplored)[4] = UpscaleTableVisible;
|
||||
};
|
||||
|
||||
extern CFogOfWar FogOfWar;
|
||||
extern CFogOfWar *FogOfWar;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
/// FIXME: Maybe move it into CMap
|
||||
CFogOfWar FogOfWar; /// Fog of war itself
|
||||
CFogOfWar *FogOfWar; /// Fog of war itself
|
||||
CGraphic *CFogOfWar::TiledFogSrc {nullptr}; // Graphic tiles set for tiled fog
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -810,7 +810,7 @@ void CFogOfWar::DrawFogTile(const size_t visIndex, const size_t mapIndex, const
|
|||
vpFogSurface);
|
||||
}
|
||||
} else {
|
||||
DrawFullShroudOfFog(dx, dy, FogOfWar.GetExploredOpacity(), vpFogSurface);
|
||||
DrawFullShroudOfFog(dx, dy, FogOfWar->GetExploredOpacity(), vpFogSurface);
|
||||
}
|
||||
if (blackFogTile) {
|
||||
TiledAlphaFog->DrawFrameClipCustomMod(blackFogTile, dx, dy, PixelModifier::CopyWithSrcAlphaKey,
|
||||
|
|
|
@ -344,7 +344,7 @@ void CMap::Create()
|
|||
*/
|
||||
void CMap::Init()
|
||||
{
|
||||
FogOfWar.Init();
|
||||
FogOfWar->Init();
|
||||
this->isMapInitialized = true;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ void CMap::Clean(const bool isHardClean /* = false*/)
|
|||
|
||||
FieldOfView.Clean();
|
||||
|
||||
FogOfWar.Clean(isHardClean);
|
||||
FogOfWar->Clean(isHardClean);
|
||||
for (CViewport *vp = UI.Viewports; vp < UI.Viewports + UI.NumViewports; ++vp) {
|
||||
vp->Clean();
|
||||
}
|
||||
|
|
|
@ -392,11 +392,11 @@ void CViewport::DrawMapFogOfWar()
|
|||
this->AdjustFogSurface();
|
||||
}
|
||||
|
||||
FogOfWar.Draw(*this);
|
||||
FogOfWar->Draw(*this);
|
||||
|
||||
/// TODO: switch to hardware rendering
|
||||
const bool isSoftwareRender {true}; // FIXME: remove this
|
||||
if (isSoftwareRender && FogOfWar.GetType() != FogOfWarTypes::cTiledLegacy) {
|
||||
if (isSoftwareRender && FogOfWar->GetType() != FogOfWarTypes::cTiledLegacy) {
|
||||
SDL_Rect screenRect;
|
||||
screenRect.x = this->TopLeftPos.x;
|
||||
screenRect.y = this->TopLeftPos.y;
|
||||
|
@ -435,7 +435,7 @@ void CViewport::AdjustFogSurface()
|
|||
32, RMASK, GMASK, BMASK, AMASK);
|
||||
SDL_SetSurfaceBlendMode(this->FogSurface, SDL_BLENDMODE_NONE);
|
||||
|
||||
const uint32_t fogColorSolid = FogOfWar.GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
||||
const uint32_t fogColorSolid = FogOfWar->GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
||||
SDL_FillRect(this->FogSurface, NULL, fogColorSolid);
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ void CMinimap::Create()
|
|||
|
||||
SDL_SetSurfaceBlendMode(MinimapFogSurface, SDL_BLENDMODE_BLEND);
|
||||
|
||||
const uint32_t fogColorSolid = FogOfWar.GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
||||
const uint32_t fogColorSolid = FogOfWar->GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
||||
SDL_FillRect(MinimapFogSurface, NULL, fogColorSolid);
|
||||
|
||||
UpdateTerrain();
|
||||
|
@ -392,7 +392,7 @@ void CMinimap::Update()
|
|||
if (WithTerrain) {
|
||||
SDL_BlitSurface(MinimapTerrainSurface, NULL, MinimapSurface, NULL);
|
||||
}
|
||||
const uint32_t fogColorSDL = FogOfWar.GetFogColorSDL();
|
||||
const uint32_t fogColorSDL = FogOfWar->GetFogColorSDL();
|
||||
if (!ReplayRevealMap) {
|
||||
uint32_t *const minimapFog = static_cast<uint32_t *>(MinimapFogSurface->pixels);
|
||||
size_t index = 0;
|
||||
|
@ -400,7 +400,7 @@ void CMinimap::Update()
|
|||
for (uint16_t mx = 0; mx < W; ++mx) {
|
||||
|
||||
const Vec2i tilePos(Minimap2MapX[mx], Minimap2MapY[my] / Map.Info.MapWidth);
|
||||
const uint8_t vis = FogOfWar.GetVisibilityForTile(tilePos);
|
||||
const uint8_t vis = FogOfWar->GetVisibilityForTile(tilePos);
|
||||
|
||||
const uint32_t fogAlpha = vis == 0 ? (GameSettings.RevealMap != MapRevealModes::cHidden ? Settings.FogRevealedOpacity : Settings.FogUnseenOpacity)
|
||||
: vis == 1 ? Settings.FogExploredOpacity
|
||||
|
|
|
@ -346,8 +346,8 @@ static int CclSetFieldOfViewType(lua_State *l)
|
|||
if (!strcmp(type_name, "shadow-casting")) {
|
||||
new_type = FieldOfViewTypes::cShadowCasting;
|
||||
/// Tiled types of FOW don't work with shadow casting
|
||||
if (FogOfWar.GetType() != FogOfWarTypes::cEnhanced) {
|
||||
FogOfWar.SetType(FogOfWarTypes::cEnhanced);
|
||||
if (FogOfWar->GetType() != FogOfWarTypes::cEnhanced) {
|
||||
FogOfWar->SetType(FogOfWarTypes::cEnhanced);
|
||||
}
|
||||
} else if (!strcmp(type_name, "simple-radial")) {
|
||||
new_type = FieldOfViewTypes::cSimpleRadial;
|
||||
|
@ -501,7 +501,7 @@ static int CclSetFogOfWarType(lua_State *l)
|
|||
fprintf(stdout, "Accessible Fog of War types: \"tiled\", \"enhanced\" and \"fast\".\n");
|
||||
return 1;
|
||||
}
|
||||
FogOfWar.SetType(new_type);
|
||||
FogOfWar->SetType(new_type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -511,7 +511,7 @@ static int CclSetFogOfWarType(lua_State *l)
|
|||
static int CclGetFogOfWarType(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 0);
|
||||
lua_pushinteger(l, int(FogOfWar.GetType()));
|
||||
lua_pushinteger(l, int(FogOfWar->GetType()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -544,7 +544,7 @@ static int CclSetFogOfWarOpacityLevels(lua_State *l)
|
|||
return 1;
|
||||
}
|
||||
|
||||
FogOfWar.SetOpacityLevels(explored, revealed, unseen);
|
||||
FogOfWar->SetOpacityLevels(explored, revealed, unseen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ static int CclSetFogOfWarBlur(lua_State *l)
|
|||
PrintFunction();
|
||||
fprintf(stdout, "Number of box blur iterations should be greater than 0. Blur is disabled.\n");
|
||||
}
|
||||
FogOfWar.InitBlurer(radiusSimple, radiusBilinear, iterations);
|
||||
FogOfWar->InitBlurer(radiusSimple, radiusBilinear, iterations);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ static int CclSetFogOfWarBlur(lua_State *l)
|
|||
static int CclSetFogOfWarBilinear(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 1);
|
||||
FogOfWar.EnableBilinearUpscale(LuaToBoolean(l, 1));
|
||||
FogOfWar->EnableBilinearUpscale(LuaToBoolean(l, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -601,7 +601,7 @@ static int CclSetFogOfWarBilinear(lua_State *l)
|
|||
static int CclGetIsFogOfWarBilinear(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 0);
|
||||
lua_pushboolean(l, FogOfWar.IsBilinearUpscaleEnabled());
|
||||
lua_pushboolean(l, FogOfWar->IsBilinearUpscaleEnabled());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -668,7 +668,7 @@ static int CclSetFogOfWarColor(lua_State *l)
|
|||
LuaError(l, "Arguments must be in the range 0-255");
|
||||
}
|
||||
|
||||
FogOfWar.SetFogColor(r, g, b);
|
||||
FogOfWar->SetFogColor(r, g, b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ static void DisplayLoop()
|
|||
// program, as we now still have a game on the background and
|
||||
// need to go through the game-menu or supply a map file
|
||||
|
||||
FogOfWar.Update(FastForwardCycle > GameCycle ? true : false);
|
||||
FogOfWar->Update(FastForwardCycle > GameCycle ? true : false);
|
||||
|
||||
UpdateDisplay();
|
||||
RealizeVideoMemory();
|
||||
|
|
|
@ -746,6 +746,7 @@ int stratagusMain(int argc, char **argv)
|
|||
}
|
||||
|
||||
UnitManager = new CUnitManager();
|
||||
FogOfWar = new CFogOfWar();
|
||||
|
||||
LoadCcl(parameters.luaStartFilename, parameters.luaScriptArguments);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue