diff --git a/src/d_main.cpp b/src/d_main.cpp index c6ee1dddc..d26ae1d0c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -388,7 +388,7 @@ void D_Render(std::function action, bool interpolate) // //========================================================================== -CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO) +CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO | CVAR_NOINITCALL) { // In case DF_NO_FREELOOK was changed, reinitialize the sky // map. (If no freelook, then no need to stretch the sky.) @@ -463,7 +463,7 @@ CVAR (Mask, sv_freelook, dmflags, DF_NO_FREELOOK|DF_YES_FREELOOK); // //========================================================================== -CUSTOM_CVAR (Int, dmflags2, 0, CVAR_SERVERINFO) +CUSTOM_CVAR (Int, dmflags2, 0, CVAR_SERVERINFO | CVAR_NOINITCALL) { // Stop the automap if we aren't allowed to use it. if ((self & DF2_NO_AUTOMAP) && automapactive) @@ -546,7 +546,7 @@ static int GetCompatibility2(FLevelLocals *Level, int mask) : (mask & ~Level->info->compatmask2) | (Level->info->compatflags2 & Level->info->compatmask2); } -CUSTOM_CVAR (Int, compatflags, 0, CVAR_ARCHIVE|CVAR_SERVERINFO) +CUSTOM_CVAR (Int, compatflags, 0, CVAR_ARCHIVE|CVAR_SERVERINFO | CVAR_NOINITCALL) { for (auto Level : AllLevels()) { @@ -559,7 +559,7 @@ CUSTOM_CVAR (Int, compatflags, 0, CVAR_ARCHIVE|CVAR_SERVERINFO) } } -CUSTOM_CVAR (Int, compatflags2, 0, CVAR_ARCHIVE|CVAR_SERVERINFO) +CUSTOM_CVAR (Int, compatflags2, 0, CVAR_ARCHIVE|CVAR_SERVERINFO | CVAR_NOINITCALL) { for (auto Level : AllLevels()) { diff --git a/src/doomstat.cpp b/src/doomstat.cpp index c9ff769b5..851948906 100644 --- a/src/doomstat.cpp +++ b/src/doomstat.cpp @@ -40,33 +40,6 @@ FStringTable GStrings; // Game speed EGameSpeed GameSpeed = SPEED_Normal; -// Show developer messages if true. -CVAR (Int, developer, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) - -// [RH] Feature control cvars -CVAR (Bool, var_friction, true, CVAR_SERVERINFO); - -CVAR (Bool, alwaysapplydmflags, false, CVAR_SERVERINFO); - -CUSTOM_CVAR (Float, teamdamage, 0.f, CVAR_SERVERINFO) -{ - for (auto Level : AllLevels()) - { - Level->teamdamage = self; - } -} - -CUSTOM_CVAR (String, language, "auto", CVAR_ARCHIVE|CVAR_NOINITCALL) -{ - SetLanguageIDs (); - GStrings.UpdateLanguage(); - for (auto Level : AllLevels()) - { - // does this even make sense on secondary levels...? - if (Level->info != nullptr) Level->LevelName = Level->info->LookupLevelName(); - } -} - // [RH] Network arbitrator int Net_Arbitrator = 0; diff --git a/src/g_cvars.cpp b/src/g_cvars.cpp index 67d18179f..a9e2ec311 100644 --- a/src/g_cvars.cpp +++ b/src/g_cvars.cpp @@ -36,11 +36,22 @@ #include "c_cvars.h" #include "g_levellocals.h" #include "g_game.h" +#include "gstrings.h" +#include "i_system.h" CVAR (Bool, cl_spreaddecals, true, CVAR_ARCHIVE) CVAR(Bool, var_pushers, true, CVAR_SERVERINFO); CVAR(Bool, gl_cachenodes, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, alwaysapplydmflags, false, CVAR_SERVERINFO); + +// Show developer messages if true. +CVAR(Int, developer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + +// [RH] Feature control cvars +CVAR(Bool, var_friction, true, CVAR_SERVERINFO); + + CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) @@ -52,7 +63,7 @@ CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN } } -CUSTOM_CVAR(Int, sv_corpsequeuesize, 64, CVAR_ARCHIVE|CVAR_SERVERINFO) +CUSTOM_CVAR(Int, sv_corpsequeuesize, 64, CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_NOINITCALL) { if (self > 0) { @@ -69,7 +80,7 @@ CUSTOM_CVAR(Int, sv_corpsequeuesize, 64, CVAR_ARCHIVE|CVAR_SERVERINFO) } } -CUSTOM_CVAR (Int, cl_maxdecals, 1024, CVAR_ARCHIVE) +CUSTOM_CVAR (Int, cl_maxdecals, 1024, CVAR_ARCHIVE|CVAR_NOINITCALL) { if (self < 0) { @@ -91,7 +102,7 @@ CUSTOM_CVAR (Int, cl_maxdecals, 1024, CVAR_ARCHIVE) // [BC] Allow the maximum number of particles to be specified by a cvar (so people // with lots of nice hardware can have lots of particles!). -CUSTOM_CVAR(Int, r_maxparticles, 4000, CVAR_ARCHIVE) +CUSTOM_CVAR(Int, r_maxparticles, 4000, CVAR_ARCHIVE | CVAR_NOINITCALL) { if (self == 0) self = 4000; @@ -109,3 +120,22 @@ CUSTOM_CVAR(Int, r_maxparticles, 4000, CVAR_ARCHIVE) } } +CUSTOM_CVAR(Float, teamdamage, 0.f, CVAR_SERVERINFO | CVAR_NOINITCALL) +{ + for (auto Level : AllLevels()) + { + Level->teamdamage = self; + } +} + +CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL) +{ + SetLanguageIDs(); + GStrings.UpdateLanguage(); + for (auto Level : AllLevels()) + { + // does this even make sense on secondary levels...? + if (Level->info != nullptr) Level->LevelName = Level->info->LookupLevelName(); + } +} + diff --git a/src/g_level.cpp b/src/g_level.cpp index 0d27c6d1a..1181d4559 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1551,6 +1551,7 @@ void FLevelLocals::Init() gravity = sv_gravity * 35/TICRATE; aircontrol = sv_aircontrol; + AirControlChanged(); teamdamage = ::teamdamage; flags = 0; flags2 = 0; diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 37b280b5d..fac345de0 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -109,6 +109,16 @@ struct FLevelLocals FLevelLocals(); ~FLevelLocals(); + void *operator new(size_t blocksize) + { + // Null the allocated memory before running the constructor. + // If we later allocate secondary levels they need to behave exactly like a global variable, i.e. start nulled. + auto block = ::operator new(blocksize); + memset(block, 0, blocksize); + return block; + } + + friend class MapLoader; void Tick(); diff --git a/src/gamedata/textures/texturemanager.cpp b/src/gamedata/textures/texturemanager.cpp index ff451dd17..d1f0ba91c 100644 --- a/src/gamedata/textures/texturemanager.cpp +++ b/src/gamedata/textures/texturemanager.cpp @@ -60,7 +60,7 @@ FTextureManager TexMan; -CUSTOM_CVAR(Bool, vid_nopalsubstitutions, false, CVAR_ARCHIVE) +CUSTOM_CVAR(Bool, vid_nopalsubstitutions, false, CVAR_ARCHIVE|CVAR_NOINITCALL) { // This is in case the sky texture has been substituted. R_InitSkyMap (); diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 8d7fb2470..e9eb6855d 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -256,7 +256,7 @@ void DIntermissionScreenText::Init(FIntermissionAction *desc, bool first) if (mTextX < 0) mTextX =gameinfo.TextScreenX; mTextY = static_cast(desc)->mTextY; if (mTextY < 0) mTextY =gameinfo.TextScreenY; - mTextLen = mText.CharacterCount(); + mTextLen = (int)mText.CharacterCount(); mTextDelay = static_cast(desc)->mTextDelay; mTextColor = static_cast(desc)->mTextColor; // For text screens, the duration only counts when the text is complete. diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 99e8192e5..44e8a97e9 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -143,7 +143,7 @@ static FRandom pr_uniquetid("UniqueTID"); FRandom pr_spawnmobj ("SpawnActor"); -CUSTOM_CVAR (Float, sv_gravity, 800.f, CVAR_SERVERINFO|CVAR_NOSAVE) +CUSTOM_CVAR (Float, sv_gravity, 800.f, CVAR_SERVERINFO|CVAR_NOSAVE|CVAR_NOINITCALL) { for (auto Level : AllLevels()) { diff --git a/src/p_user.cpp b/src/p_user.cpp index 87359c958..66d8d013f 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -973,7 +973,7 @@ void P_CheckPlayerSprite(AActor *actor, int &spritenum, DVector2 &scale) } } -CUSTOM_CVAR (Float, sv_aircontrol, 0.00390625f, CVAR_SERVERINFO|CVAR_NOSAVE) +CUSTOM_CVAR (Float, sv_aircontrol, 0.00390625f, CVAR_SERVERINFO|CVAR_NOSAVE|CVAR_NOINITCALL) { primaryLevel->aircontrol = self; primaryLevel->AirControlChanged (); diff --git a/src/r_sky.cpp b/src/r_sky.cpp index 7ff9973f0..f35d037d6 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -46,7 +46,7 @@ FTextureID skyflatnum; // [RH] Stretch sky texture if not taller than 128 pixels? // Also now controls capped skies. 0 = normal, 1 = stretched, 2 = capped -CUSTOM_CVAR (Int, r_skymode, 2, CVAR_ARCHIVE) +CUSTOM_CVAR (Int, r_skymode, 2, CVAR_ARCHIVE|CVAR_NOINITCALL) { R_InitSkyMap (); }