2019-01-31 01:05:16 +00:00
|
|
|
/*
|
|
|
|
** g_cvars.cpp
|
|
|
|
** collects all the CVARs that were scattered all across the code before
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2016 Randy Heit
|
|
|
|
** Copyright 2003-2018 Christoph Oelckers
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "c_cvars.h"
|
|
|
|
#include "g_levellocals.h"
|
2019-01-31 23:14:31 +00:00
|
|
|
#include "g_game.h"
|
2019-02-24 08:57:46 +00:00
|
|
|
#include "gstrings.h"
|
|
|
|
#include "i_system.h"
|
2019-04-21 10:38:43 +00:00
|
|
|
#include "v_font.h"
|
|
|
|
#include "utf8.h"
|
2019-01-31 01:05:16 +00:00
|
|
|
|
2019-01-31 01:27:54 +00:00
|
|
|
CVAR (Bool, cl_spreaddecals, true, CVAR_ARCHIVE)
|
2019-01-31 01:50:12 +00:00
|
|
|
CVAR(Bool, var_pushers, true, CVAR_SERVERINFO);
|
2019-01-31 02:03:56 +00:00
|
|
|
CVAR(Bool, gl_cachenodes, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
|
|
CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
2019-02-24 08:57:46 +00:00
|
|
|
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);
|
|
|
|
|
2019-03-16 07:46:48 +00:00
|
|
|
// Option Search
|
|
|
|
CVAR(Bool, os_isanyof, true, CVAR_ARCHIVE);
|
|
|
|
|
2019-02-24 08:57:46 +00:00
|
|
|
|
2019-01-31 01:27:54 +00:00
|
|
|
|
|
|
|
|
2019-01-31 01:05:16 +00:00
|
|
|
CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
|
|
|
{
|
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
if (self) Level->RecreateAllAttachedLights();
|
|
|
|
else Level->DeleteAllAttachedLights();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-24 08:57:46 +00:00
|
|
|
CUSTOM_CVAR(Int, sv_corpsequeuesize, 64, CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_NOINITCALL)
|
2019-01-31 01:27:54 +00:00
|
|
|
{
|
|
|
|
if (self > 0)
|
|
|
|
{
|
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
auto &corpsequeue = Level->CorpseQueue;
|
|
|
|
while (corpsequeue.Size() > (unsigned)self)
|
|
|
|
{
|
|
|
|
AActor *corpse = corpsequeue[0];
|
|
|
|
if (corpse) corpse->Destroy();
|
|
|
|
corpsequeue.Delete(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-24 08:57:46 +00:00
|
|
|
CUSTOM_CVAR (Int, cl_maxdecals, 1024, CVAR_ARCHIVE|CVAR_NOINITCALL)
|
2019-01-31 01:27:54 +00:00
|
|
|
{
|
|
|
|
if (self < 0)
|
|
|
|
{
|
|
|
|
self = 0;
|
|
|
|
}
|
|
|
|
else for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
while (Level->ImpactDecalCount > self)
|
|
|
|
{
|
|
|
|
DThinker *thinker = Level->FirstThinker(STAT_AUTODECAL);
|
|
|
|
if (thinker != NULL)
|
|
|
|
{
|
|
|
|
thinker->Destroy();
|
2019-03-02 11:58:28 +00:00
|
|
|
Level->ImpactDecalCount--;
|
2019-01-31 01:27:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-31 23:14:31 +00:00
|
|
|
// [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!).
|
2019-02-24 08:57:46 +00:00
|
|
|
CUSTOM_CVAR(Int, r_maxparticles, 4000, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
2019-01-31 23:14:31 +00:00
|
|
|
{
|
|
|
|
if (self == 0)
|
|
|
|
self = 4000;
|
|
|
|
else if (self > 65535)
|
|
|
|
self = 65535;
|
|
|
|
else if (self < 100)
|
|
|
|
self = 100;
|
2019-01-31 01:27:54 +00:00
|
|
|
|
2019-01-31 23:14:31 +00:00
|
|
|
if (gamestate != GS_STARTUP)
|
|
|
|
{
|
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
P_InitParticles(Level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-31 01:05:16 +00:00
|
|
|
|
2019-02-24 08:57:46 +00:00
|
|
|
CUSTOM_CVAR(Float, teamdamage, 0.f, CVAR_SERVERINFO | CVAR_NOINITCALL)
|
|
|
|
{
|
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
Level->teamdamage = self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:20:42 +00:00
|
|
|
bool generic_ui;
|
|
|
|
|
2019-04-21 10:38:43 +00:00
|
|
|
bool CheckFontComplete(FFont *font)
|
|
|
|
{
|
|
|
|
// Also check if the SmallFont contains all characters this language needs.
|
|
|
|
// If not, switch back to the original one.
|
|
|
|
const uint8_t* checkstr = (const uint8_t*)GStrings["REQUIRED_CHARACTERS"];
|
|
|
|
bool incomplete = false;
|
|
|
|
|
|
|
|
if (!checkstr) return true;
|
|
|
|
while (int c = GetCharFromString(checkstr))
|
|
|
|
{
|
|
|
|
bool redirected;
|
|
|
|
int cc = font->GetCharCode(c, true);
|
|
|
|
if (c != cc && (c != 0x1e9e || cc != 0xdf))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:20:42 +00:00
|
|
|
void UpdateGenericUI(bool cvar)
|
|
|
|
{
|
|
|
|
auto switchstr = GStrings["USE_GENERIC_FONT"];
|
|
|
|
generic_ui = (cvar || (switchstr && strtoll(switchstr, nullptr, 0)));
|
2019-04-21 10:38:43 +00:00
|
|
|
if (!generic_ui)
|
|
|
|
{
|
|
|
|
// Use the mod's SmallFont if it is complete.
|
|
|
|
// Otherwise use the stock Smallfont if it is complete.
|
|
|
|
// If none is complete, fall back to the VGA font.
|
|
|
|
// The font being set here will be used in 3 places: Notifications, centered messages and menu confirmations.
|
|
|
|
if (CheckFontComplete(SmallFont))
|
|
|
|
{
|
|
|
|
AlternativeSmallFont = SmallFont;
|
|
|
|
}
|
|
|
|
else if (OriginalSmallFont && CheckFontComplete(OriginalSmallFont))
|
|
|
|
{
|
|
|
|
AlternativeSmallFont = OriginalSmallFont;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AlternativeSmallFont = NewSmallFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Todo: Do the same for the BigFont
|
|
|
|
}
|
2019-04-11 22:20:42 +00:00
|
|
|
}
|
|
|
|
|
2019-04-21 10:38:43 +00:00
|
|
|
CUSTOM_CVAR(Bool, ui_generic, false, CVAR_NOINITCALL) // This is for allowing to test the generic font system with all languages
|
2019-04-11 22:20:42 +00:00
|
|
|
{
|
|
|
|
UpdateGenericUI(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-03 06:49:21 +00:00
|
|
|
CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
|
2019-02-24 08:57:46 +00:00
|
|
|
{
|
|
|
|
GStrings.UpdateLanguage();
|
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
// does this even make sense on secondary levels...?
|
|
|
|
if (Level->info != nullptr) Level->LevelName = Level->info->LookupLevelName();
|
|
|
|
}
|
2019-04-11 22:20:42 +00:00
|
|
|
UpdateGenericUI(ui_generic);
|
2019-02-24 08:57:46 +00:00
|
|
|
}
|