From 4227b9020c630f7e8095d5a97bd4b12ddb8db87b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 9 Jan 2019 18:59:41 +0100 Subject: [PATCH] - moved bglobal.freeze to FLevelLocals, because this flag has nothing specific to do with bots as it freezes the entire level. --- src/b_bot.cpp | 3 ++- src/b_bot.h | 4 +--- src/decallib.cpp | 8 ++++---- src/g_game.cpp | 1 - src/g_levellocals.h | 4 ++++ src/hwrenderer/scene/hw_sprites.cpp | 2 +- src/m_cheat.cpp | 7 +++++-- src/p_effect.cpp | 2 +- src/p_mobj.cpp | 4 ++-- src/p_saveg.cpp | 4 +++- src/p_tick.cpp | 10 +++++----- src/polyrenderer/scene/poly_particle.cpp | 2 +- src/scripting/vmthunks.cpp | 2 ++ src/swrenderer/things/r_particle.cpp | 2 +- wadsrc/static/zscript/base.txt | 2 +- wadsrc/static/zscript/shared/fastprojectile.txt | 2 +- 16 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/b_bot.cpp b/src/b_bot.cpp index f02184282b..60272fc4cc 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -49,6 +49,7 @@ #include "d_player.h" #include "w_wad.h" #include "vm.h" +#include "g_levellocals.h" IMPLEMENT_CLASS(DBot, false, true) @@ -138,7 +139,7 @@ void DBot::Tick () { Super::Tick (); - if (player->mo == nullptr || bglobal.freeze) + if (player->mo == nullptr || Level->freeze) { return; } diff --git a/src/b_bot.h b/src/b_bot.h index d0fe3ece0a..0f5fda16fd 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -116,7 +116,7 @@ public: void ClearPlayer (int playernum, bool keepTeam); //(b_game.cpp) - void Main (); + void Main (FLevelLocals *Level); void Init (); void End(); bool SpawnBot (const char *name, int color = NOCOLOR); @@ -139,8 +139,6 @@ public: bool IsDangerous (sector_t *sec); TArray getspawned; //Array of bots (their names) which should be spawned when starting a game. - uint8_t freeze; //Game in freeze mode. - uint8_t changefreeze; //Game wants to change freeze mode. int botnum; botinfo_t *botinfo; int spawn_tries; diff --git a/src/decallib.cpp b/src/decallib.cpp index 010e76b6b9..ad9f61f421 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -1178,7 +1178,7 @@ void DDecalFader::Tick () } else { - if (Level->maptime < TimeToStartDecay || bglobal.freeze) + if (Level->maptime < TimeToStartDecay || Level->freeze) { return; } @@ -1265,7 +1265,7 @@ void DDecalStretcher::Tick () Destroy (); return; } - if (Level->maptime < TimeToStart || bglobal.freeze) + if (Level->maptime < TimeToStart || Level->freeze) { return; } @@ -1333,7 +1333,7 @@ void DDecalSlider::Tick () Destroy (); return; } - if (Level->maptime < TimeToStart || bglobal.freeze) + if (Level->maptime < TimeToStart || Level->freeze) { return; } @@ -1401,7 +1401,7 @@ void DDecalColorer::Tick () } else { - if (Level->maptime < TimeToStartDecay || bglobal.freeze) + if (Level->maptime < TimeToStartDecay || Level->freeze) { return; } diff --git a/src/g_game.cpp b/src/g_game.cpp index f2f9274a56..ee39061e03 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2873,7 +2873,6 @@ DEFINE_GLOBAL(multiplayer) DEFINE_GLOBAL(gameaction) DEFINE_GLOBAL(gamestate) DEFINE_GLOBAL(skyflatnum) -DEFINE_GLOBAL_NAMED(bglobal.freeze, globalfreeze) DEFINE_GLOBAL(gametic) DEFINE_GLOBAL(demoplayback) DEFINE_GLOBAL(automapactive); diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 49a0545de3..c4db5a2c6f 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -218,6 +218,10 @@ struct FLevelLocals : public FLevelData int airsupply; int DefaultEnvironment; // Default sound environment. + uint8_t freeze; //Game in freeze mode. + uint8_t changefreeze; //Game wants to change freeze mode. + + TArray Scrolls; // NULL if no DScrollers in this level int8_t WallVertLight; // Light diffs for vert/horiz walls diff --git a/src/hwrenderer/scene/hw_sprites.cpp b/src/hwrenderer/scene/hw_sprites.cpp index 49ced7dfe7..63b63c6996 100644 --- a/src/hwrenderer/scene/hw_sprites.cpp +++ b/src/hwrenderer/scene/hw_sprites.cpp @@ -1198,7 +1198,7 @@ void GLSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t * const auto &vp = di->Viewpoint; double timefrac = vp.TicFrac; - if (paused || bglobal.freeze || (di->Level->flags2 & LEVEL2_FROZEN)) + if (paused || Level->freeze || (di->Level->flags2 & LEVEL2_FROZEN)) timefrac = 0.; float xvf = (particle->Vel.X) * timefrac; float yvf = (particle->Vel.Y) * timefrac; diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index e120ba4514..c2c116c8d3 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -514,8 +514,10 @@ void cht_DoCheat (player_t *player, int cheat) break; case CHT_FREEZE: - bglobal.changefreeze ^= 1; - if (bglobal.freeze ^ bglobal.changefreeze) + { + auto Level = player->mo->Level; + Level->changefreeze ^= 1; + if (Level->freeze ^ Level->changefreeze) { msg = GStrings("TXT_FREEZEON"); } @@ -525,6 +527,7 @@ void cht_DoCheat (player_t *player, int cheat) } break; } + } if (!*msg) // [SO] Don't print blank lines! return; diff --git a/src/p_effect.cpp b/src/p_effect.cpp index c15ec03750..e92b7f04f0 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -243,7 +243,7 @@ void P_ThinkParticles () { particle = &Particles[i]; i = particle->tnext; - if (!particle->notimefreeze && ((bglobal.freeze) || (level.flags2 & LEVEL2_FROZEN))) + if (!particle->notimefreeze && ((level.freeze) || (level.flags2 & LEVEL2_FROZEN))) { prev = particle; continue; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 46e971b7fc..984600afa1 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3522,7 +3522,7 @@ void AActor::Tick () if (!(flags5 & MF5_NOTIMEFREEZE)) { //Added by MC: Freeze mode. - if (bglobal.freeze || Level->flags2 & LEVEL2_FROZEN) + if (Level->freeze || Level->flags2 & LEVEL2_FROZEN) { // Boss cubes shouldn't be accelerated by timefreeze if (flags6 & MF6_BOSSCUBE) @@ -3577,7 +3577,7 @@ void AActor::Tick () special2++; } //Added by MC: Freeze mode. - if (bglobal.freeze && !(player && player->Bot == NULL)) + if (Level->freeze && !(player && player->Bot == NULL)) { return; } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index c86e76f149..f6afdff65d 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -984,7 +984,9 @@ void G_SerializeLevel(FSerializer &arc, FLevelLocals *Level, bool hubload) ("spotstate", Level->SpotState) ("fragglethinker", Level->FraggleScriptThinker) ("acsthinker", Level->ACSThinker) - ("impactdecalcount", Level->ImpactDecalCount); + ("impactdecalcount", Level->ImpactDecalCount) + ("freeze", Level->freeze) + ("changefreeze", Level->changefreeze // Hub transitions must keep the current total time if (!hubload) diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 6d750b9423..7030a8d05d 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -109,10 +109,10 @@ void FLevelLocals::Tick() // [RH] Frozen mode is only changed every 4 tics, to make it work with A_Tracer(). if ((maptime & 3) == 0) { - if (bglobal.changefreeze) + if (changefreeze) { - bglobal.freeze ^= 1; - bglobal.changefreeze = 0; + freeze ^= 1; + changefreeze = 0; } } @@ -136,7 +136,7 @@ void FLevelLocals::Tick() for (int i = 0; iLevel->flags2 & LEVEL2_FROZEN)) + if (paused || PolyRenderer::Instance()->Level->freeze || (PolyRenderer::Instance()->Level->flags2 & LEVEL2_FROZEN)) timefrac = 0.; DVector3 pos = particle->Pos + (particle->Vel * timefrac); double psize = particle->size / 8.0; diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 3b638de571..34dcfd48a6 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2748,6 +2748,8 @@ DEFINE_FIELD(FLevelLocals, outsidefogdensity) DEFINE_FIELD(FLevelLocals, skyfog) DEFINE_FIELD(FLevelLocals, pixelstretch) DEFINE_FIELD(FLevelLocals, deathsequence) +DEFINE_FIELD(FLevelLocals, freeze) + DEFINE_FIELD_BIT(FLevelLocals, flags, noinventorybar, LEVEL_NOINVENTORYBAR) DEFINE_FIELD_BIT(FLevelLocals, flags, monsterstelefrag, LEVEL_MONSTERSTELEFRAG) DEFINE_FIELD_BIT(FLevelLocals, flags, actownspecial, LEVEL_ACTOWNSPECIAL) diff --git a/src/swrenderer/things/r_particle.cpp b/src/swrenderer/things/r_particle.cpp index 54fc158913..2a51b35630 100644 --- a/src/swrenderer/things/r_particle.cpp +++ b/src/swrenderer/things/r_particle.cpp @@ -79,7 +79,7 @@ namespace swrenderer sector_t* heightsec = NULL; double timefrac = r_viewpoint.TicFrac; - if (paused || bglobal.freeze || (sector->Level->flags2 & LEVEL2_FROZEN)) + if (paused || sector->Level->freeze || (sector->Level->flags2 & LEVEL2_FROZEN)) timefrac = 0.; double ippx = particle->Pos.X + particle->Vel.X * timefrac; diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index e33849c6ff..e3206b343d 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -20,7 +20,6 @@ struct _ native // These are the global variables, the struct is only here to av native play uint gameaction; native readonly int gamestate; native readonly TextureID skyflatnum; - native readonly uint8 globalfreeze; native readonly int consoleplayer; native readonly Font smallfont; native readonly Font smallfont2; @@ -690,6 +689,7 @@ struct LevelLocals native native readonly int skyfog; native readonly float pixelstretch; native name deathsequence; + native readonly uint8 globalfreeze; // level_info_t *info cannot be done yet. native String GetUDMFString(int type, int index, Name key); diff --git a/wadsrc/static/zscript/shared/fastprojectile.txt b/wadsrc/static/zscript/shared/fastprojectile.txt index 003fe57d82..15fcf14669 100644 --- a/wadsrc/static/zscript/shared/fastprojectile.txt +++ b/wadsrc/static/zscript/shared/fastprojectile.txt @@ -53,7 +53,7 @@ class FastProjectile : Actor if (!bNoTimeFreeze) { //Added by MC: Freeze mode. - if (globalfreeze || Level.Frozen) + if (Level.freeze || Level.Frozen) { return; }