diff --git a/engine/inc/C4Game.h b/engine/inc/C4Game.h index ef314ddd8..84ce19968 100644 --- a/engine/inc/C4Game.h +++ b/engine/inc/C4Game.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -74,7 +73,6 @@ class C4Game C4PlayerInfoList &PlayerInfos; // Shortcut C4PlayerInfoList &RestorePlayerInfos; // Shortcut C4RoundResults RoundResults; - C4Weather Weather; C4GameObjects Objects; C4ObjectList BackObjects; // objects in background (C4D_Background) C4ObjectList ForeObjects; // objects in foreground (C4D_Foreground) diff --git a/engine/inc/C4Weather.h b/engine/inc/C4Weather.h index b1e43fc52..c8ba97247 100644 --- a/engine/inc/C4Weather.h +++ b/engine/inc/C4Weather.h @@ -22,6 +22,7 @@ #ifndef INC_C4Weather #define INC_C4Weather +#include class C4Weather { public: @@ -53,5 +54,11 @@ class C4Weather void SetSeasonGamma(); // set gamma adjustment for season void CompileFunc(StdCompiler *pComp); }; +extern C4Weather Weather; + +inline int32_t GBackWind(int32_t x, int32_t y) + { + return GBackIFT(x, y) ? 0: ::Weather.Wind; + } #endif diff --git a/engine/inc/C4Wrappers.h b/engine/inc/C4Wrappers.h index 463724bea..5f094bafd 100644 --- a/engine/inc/C4Wrappers.h +++ b/engine/inc/C4Wrappers.h @@ -211,11 +211,6 @@ inline bool GBackLiquid(int32_t x, int32_t y) return DensityLiquid(GBackDensity(x,y)); } -inline int32_t GBackWind(int32_t x, int32_t y) - { - return GBackIFT(x, y) ? 0: Game.Weather.Wind; - } - //==================================== StdCompiler ========================================= void StdCompilerWarnCallback(void *pData, const char *szPosition, const char *szError); diff --git a/engine/src/C4Game.cpp b/engine/src/C4Game.cpp index 25d3b257b..95035093d 100644 --- a/engine/src/C4Game.cpp +++ b/engine/src/C4Game.cpp @@ -65,6 +65,7 @@ #include #include #include +#include #endif #include diff --git a/engine/src/C4Landscape.cpp b/engine/src/C4Landscape.cpp index 8608d7848..89d7c4bdb 100644 --- a/engine/src/C4Landscape.cpp +++ b/engine/src/C4Landscape.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #endif #include @@ -122,7 +123,7 @@ void C4Landscape::ExecuteScan() int32_t cy,mat; // Check: Scan needed? - const int32_t iTemperature = Game.Weather.GetTemperature(); + const int32_t iTemperature = ::Weather.GetTemperature(); for(mat = 0; mat < ::MaterialMap.Num; mat++) if(MatCount[mat]) if(::MaterialMap.Map[mat].BelowTempConvertTo && @@ -173,7 +174,7 @@ void C4Landscape::ExecuteScan() int32_t C4Landscape::DoScan(int32_t cx, int32_t cy, int32_t mat, int32_t dir) { int32_t conv_to_tex = 0; - int32_t iTemperature = Game.Weather.GetTemperature(); + int32_t iTemperature = ::Weather.GetTemperature(); // Check below conv if(::MaterialMap.Map[mat].BelowTempConvertDir == dir) if (::MaterialMap.Map[mat].BelowTempConvertTo) diff --git a/engine/src/C4PXS.cpp b/engine/src/C4PXS.cpp index 8f8dea102..b0d706c61 100644 --- a/engine/src/C4PXS.cpp +++ b/engine/src/C4PXS.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #endif static const FIXED WindDrift_Factor = itofix(1, 800); diff --git a/engine/src/C4Particles.cpp b/engine/src/C4Particles.cpp index c30e122dd..b0c2770ba 100644 --- a/engine/src/C4Particles.cpp +++ b/engine/src/C4Particles.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #endif void C4ParticleDefCore::CompileFunc(StdCompiler * pComp) @@ -591,7 +592,7 @@ bool fxSmokeExec(C4Particle *pPrt, C4Object *pTarget) // wind to float if (!(pPrt->b%12) || fBuilding) { - pPrt->xdir=0.025f*Game.Weather.GetWind(int32_t(pPrt->x),int32_t(pPrt->y)); + pPrt->xdir=0.025f*::Weather.GetWind(int32_t(pPrt->x),int32_t(pPrt->y)); if (pPrt->xdir<-2.0f) pPrt->xdir=-2.0f; else if (pPrt->xdir>2.0f) pPrt->xdir=2.0f; pPrt->xdir+=0.1f*SafeRandom(41)-2.0f; } diff --git a/engine/src/C4Script.cpp b/engine/src/C4Script.cpp index c74ca09b2..dceb0dd56 100644 --- a/engine/src/C4Script.cpp +++ b/engine/src/C4Script.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #endif //========================== Some Support Functions ======================================= @@ -3082,49 +3083,49 @@ static long FnSetCrewStatus(C4AulContext *cthr, long iPlr, bool fInCrew, C4Objec static long FnGetWind(C4AulContext *cthr, long x, long y, bool fGlobal) { // global wind - if (fGlobal) return Game.Weather.Wind; + if (fGlobal) return ::Weather.Wind; // local wind if (cthr->Obj) { x+=cthr->Obj->GetX(); y+=cthr->Obj->GetY(); } - return Game.Weather.GetWind(x,y); + return ::Weather.GetWind(x,y); } static bool FnSetWind(C4AulContext *cthr, long iWind) { - Game.Weather.SetWind(iWind); + ::Weather.SetWind(iWind); return TRUE; } static bool FnSetTemperature(C4AulContext *cthr, long iTemperature) { - Game.Weather.SetTemperature(iTemperature); + ::Weather.SetTemperature(iTemperature); return TRUE; } static long FnGetTemperature(C4AulContext *cthr) { - return Game.Weather.GetTemperature(); + return ::Weather.GetTemperature(); } static bool FnSetSeason(C4AulContext *cthr, long iSeason) { - Game.Weather.SetSeason(iSeason); + ::Weather.SetSeason(iSeason); return TRUE; } static long FnGetSeason(C4AulContext *cthr) { - return Game.Weather.GetSeason(); + return ::Weather.GetSeason(); } static bool FnSetClimate(C4AulContext *cthr, long iClimate) { - Game.Weather.SetClimate(iClimate); + ::Weather.SetClimate(iClimate); return TRUE; } static long FnGetClimate(C4AulContext *cthr) { - return Game.Weather.GetClimate(); + return ::Weather.GetClimate(); } static bool FnSetSkyFade(C4AulContext *cthr, long iFromRed, long iFromGreen, long iFromBlue, long iToRed, long iToGreen, long iToBlue) @@ -3173,12 +3174,12 @@ static long FnLandscapeHeight(C4AulContext *cthr) static long FnLaunchLightning(C4AulContext *cthr, long x, long y, long xdir, long xrange, long ydir, long yrange, bool fDoGamma) { - return Game.Weather.LaunchLightning(x,y,xdir,xrange,ydir,yrange, fDoGamma); + return ::Weather.LaunchLightning(x,y,xdir,xrange,ydir,yrange, fDoGamma); } static long FnLaunchVolcano(C4AulContext *cthr, long x) { - return Game.Weather.LaunchVolcano( + return ::Weather.LaunchVolcano( ::MaterialMap.Get("Lava"), x,GBackHgt-1, BoundBy(15*GBackHgt/500+Random(10),10,60)); @@ -3186,7 +3187,7 @@ static long FnLaunchVolcano(C4AulContext *cthr, long x) static bool FnLaunchEarthquake(C4AulContext *cthr, long x, long y) { - Game.Weather.LaunchEarthquake(x,y); + ::Weather.LaunchEarthquake(x,y); return 1; } diff --git a/engine/src/C4Sky.cpp b/engine/src/C4Sky.cpp index 2c7afdc5e..e9ec525ff 100644 --- a/engine/src/C4Sky.cpp +++ b/engine/src/C4Sky.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #endif static BOOL SurfaceEnsureSize(C4Surface **ppSfc, int iMinWdt, int iMinHgt) @@ -218,7 +219,7 @@ void C4Sky::Execute() if (x>=itofix(Width)) x-=itofix(Width); if (y>=itofix(Height)) y-=itofix(Height); // update speed - if (ParallaxMode == C4SkyPM_Wind) xdir=FIXED100(Game.Weather.Wind); + if (ParallaxMode == C4SkyPM_Wind) xdir=FIXED100(::Weather.Wind); } void C4Sky::Draw(C4TargetFacet &cgo) diff --git a/engine/src/C4Weather.cpp b/engine/src/C4Weather.cpp index 10fadb280..16f470b02 100644 --- a/engine/src/C4Weather.cpp +++ b/engine/src/C4Weather.cpp @@ -302,3 +302,5 @@ void C4Weather::CompileFunc(StdCompiler *pComp) } pComp->Value(mkNamingAdapt(mkArrayAdaptM(::GraphicsSystem.dwGamma), "Gamma", dwGammaDefaults)); } + +C4Weather Weather;