- reworked CVARs to not use a linked list and to be initialized manually.

This solves two problems:

* The linked list is too slow, a map is better. A map cannot be used with statically allocated CVARs because order of initialization is undefined.
* The current CVAR system is an unordered mishmash of static variables and dynamically allocated ones and the means of identification are unsafe. With this everything is allocated on the heap so it can all be handled the same by the cleanup code.
This commit is contained in:
Christoph Oelckers 2022-10-21 18:28:28 +02:00
commit 453688ccc6
28 changed files with 369 additions and 203 deletions

View file

@ -6715,12 +6715,12 @@ FxExpression *FxCVar::Resolve(FCompileContext &ctx)
switch (CVar->GetRealType())
{
case CVAR_Bool:
case CVAR_DummyBool:
case CVAR_Flag:
ValueType = TypeBool;
break;
case CVAR_Int:
case CVAR_DummyInt:
case CVAR_Mask:
ValueType = TypeSInt32;
break;
@ -6776,7 +6776,7 @@ ExpEmit FxCVar::Emit(VMFunctionBuilder *build)
build->Emit(OP_LS, dest.RegNum, addr.RegNum, nul);
break;
case CVAR_DummyBool:
case CVAR_Flag:
{
int *pVal;
auto cv = static_cast<FFlagCVar *>(CVar);
@ -6789,7 +6789,7 @@ ExpEmit FxCVar::Emit(VMFunctionBuilder *build)
break;
}
case CVAR_DummyInt:
case CVAR_Mask:
{
auto cv = static_cast<FMaskCVar *>(CVar);
build->Emit(OP_LKP, addr.RegNum, build->GetConstantAddress(&cv->ValueVar.Value));