Since this request hasn't gotten much attention, I thought I'd give adding these methods a shot. And it appears I've succeeded!
These need added to
c_cvars.cpp:
GetBool()
Code: Select all
DEFINE_ACTION_FUNCTION(_CVar, GetBool)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
auto v = self->GetGenericRep(CVAR_Bool);
ACTION_RETURN_BOOL(v.Bool);
}
SetBool(bool)
Code: Select all
DEFINE_ACTION_FUNCTION(_CVar, SetBool)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
if (!(self->GetFlags() & CVAR_MOD) && CurrentMenu == nullptr) return 0;
PARAM_BOOL(val);
UCVarValue v;
v.Bool = val;
self->SetGenericRep(v, CVAR_Bool);
return 0;
}
Then they need added to the ZScript
base.txt in the CVar struct:
Code: Select all
struct CVar native
{
enum ECVarType
{
CVAR_Bool,
CVAR_Int,
CVAR_Float,
CVAR_String,
CVAR_Color,
};
native static CVar FindCVar(Name name);
native static CVar GetCVar(Name name, PlayerInfo player = null);
native bool GetBool(); // Addition
native int GetInt();
native double GetFloat();
native String GetString();
native void SetBool(bool b); // Addition
native void SetInt(int v);
native void SetFloat(double v);
native void SetString(String s);
native int GetRealType();
native int ResetToDefault();
}
*Disclaimer: I have tested GetBool and it looks like it works. I have not tested SetBool. Also I am terrible with Git so I'm gonna avoid making a pull request unless absolutely necessary; I tend to break things when trying to use Git.
One other thing I'm unsure of is in
vm.h. The final line of GetBool calls ACTION_RETURN_BOOL (macro right?), which is just a macro call to ACTION_RETURN_INT. I'm not sure if this is now wrong or not, so I need some input there.