Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- added boolean CVar ZScript commands contributed by Nero: https://fo… #378

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/c_cvars.cpp
Expand Up @@ -183,6 +183,14 @@ void FBaseCVar::SetGenericRep (UCVarValue value, ECVarType type)
}
}

// ADDED BY NERO
DEFINE_ACTION_FUNCTION(_CVar, GetBool)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
auto v = self->GetGenericRep(CVAR_Bool);
ACTION_RETURN_BOOL(v.Bool);
}

DEFINE_ACTION_FUNCTION(_CVar, GetInt)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
Expand All @@ -204,6 +212,18 @@ DEFINE_ACTION_FUNCTION(_CVar, GetString)
ACTION_RETURN_STRING(v.String);
}

//ADDED BY NERO
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;
}

DEFINE_ACTION_FUNCTION(_CVar, SetInt)
{
// Only menus are allowed to change CVARs.
Expand Down
2 changes: 2 additions & 0 deletions wadsrc/static/zscript/base.txt
Expand Up @@ -301,9 +301,11 @@ struct CVar native

native static CVar FindCVar(Name name);
native static CVar GetCVar(Name name, PlayerInfo player = null);
native bool GetBool();
native int GetInt();
native double GetFloat();
native String GetString();
native void SetBool(bool b);
native void SetInt(int v);
native void SetFloat(double v);
native void SetString(String s);
Expand Down