mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-19 07:00:52 +00:00
- eliminated dependency of CVar code on AActor.
As a low level feature, the CVAR management should not access game structures like actors, just to retrieve a player index. The index should be calculated by the calling code instead and passed into the function. # Conflicts: # src/win32/i_specialpaths.cpp # Conflicts: # src/p_acs.cpp
This commit is contained in:
parent
bb946348da
commit
1697e6ff3a
5 changed files with 10 additions and 15 deletions
|
@ -1606,7 +1606,7 @@ DEFINE_ACTION_FUNCTION(_CVar, GetCVar)
|
|||
PARAM_PROLOGUE;
|
||||
PARAM_NAME(name);
|
||||
PARAM_POINTER(plyr, player_t);
|
||||
ACTION_RETURN_POINTER(GetCVar(plyr ? plyr->mo : nullptr, name));
|
||||
ACTION_RETURN_POINTER(GetCVar(plyr ? int(plyr - players) : -1, name));
|
||||
}
|
||||
|
||||
FBaseCVar *FindCVarSub (const char *var_name, int namelen)
|
||||
|
@ -1631,7 +1631,7 @@ FBaseCVar *FindCVarSub (const char *var_name, int namelen)
|
|||
return var;
|
||||
}
|
||||
|
||||
FBaseCVar *GetCVar(AActor *activator, const char *cvarname)
|
||||
FBaseCVar *GetCVar(int playernum, const char *cvarname)
|
||||
{
|
||||
FBaseCVar *cvar = FindCVar(cvarname, nullptr);
|
||||
// Either the cvar doesn't exist, or it's for a mod that isn't loaded, so return nullptr.
|
||||
|
@ -1644,11 +1644,7 @@ FBaseCVar *GetCVar(AActor *activator, const char *cvarname)
|
|||
// For userinfo cvars, redirect to GetUserCVar
|
||||
if (cvar->GetFlags() & CVAR_USERINFO)
|
||||
{
|
||||
if (activator == nullptr || activator->player == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return GetUserCVar(int(activator->player - players), cvarname);
|
||||
return GetUserCVar(playernum, cvarname);
|
||||
}
|
||||
return cvar;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ enum ECVarType
|
|||
};
|
||||
|
||||
class FConfigFile;
|
||||
class AActor;
|
||||
|
||||
class FxCVar;
|
||||
|
||||
|
@ -194,7 +193,7 @@ FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev);
|
|||
FBaseCVar *FindCVarSub (const char *var_name, int namelen);
|
||||
|
||||
// Used for ACS and DECORATE.
|
||||
FBaseCVar *GetCVar(AActor *activator, const char *cvarname);
|
||||
FBaseCVar *GetCVar(int playernum, const char *cvarname);
|
||||
FBaseCVar *GetUserCVar(int playernum, const char *cvarname);
|
||||
|
||||
// Create a new cvar with the specified name and type
|
||||
|
|
|
@ -1484,7 +1484,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
break;
|
||||
case INTCVAR:
|
||||
{
|
||||
FBaseCVar *CVar = GetCVar(statusBar->CPlayer->mo, cvarName);
|
||||
FBaseCVar *CVar = GetCVar(int(statusBar->CPlayer - players), cvarName);
|
||||
if (CVar != nullptr)
|
||||
{
|
||||
ECVarType cvartype = CVar->GetRealType();
|
||||
|
@ -3534,7 +3534,7 @@ class CommandIfCVarInt : public SBarInfoNegatableFlowControl
|
|||
SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged);
|
||||
|
||||
bool result = false;
|
||||
cvar = GetCVar(statusBar->CPlayer->mo, cvarname);
|
||||
cvar = GetCVar(int(statusBar->CPlayer - players), cvarname);
|
||||
|
||||
if (cvar != nullptr)
|
||||
{
|
||||
|
|
|
@ -5919,7 +5919,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
|||
case ACSF_GetCVarString:
|
||||
if (argCount == 1)
|
||||
{
|
||||
return DoGetCVar(GetCVar(activator, FBehavior::StaticLookupString(args[0])), true);
|
||||
return DoGetCVar(GetCVar(activator && activator->player ? int(activator->player - players) : -1, FBehavior::StaticLookupString(args[0])), true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -9869,7 +9869,7 @@ scriptwait:
|
|||
break;
|
||||
|
||||
case PCD_GETCVAR:
|
||||
STACK(1) = DoGetCVar(GetCVar(activator, FBehavior::StaticLookupString(STACK(1))), false);
|
||||
STACK(1) = DoGetCVar(GetCVar(activator && activator->player? int(activator->player - players) : -1, FBehavior::StaticLookupString(STACK(1))), false);
|
||||
break;
|
||||
|
||||
case PCD_SETHUDSIZE:
|
||||
|
|
|
@ -401,7 +401,7 @@ DEFINE_ACTION_FUNCTION(AActor, GetCVar)
|
|||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_STRING(cvarname);
|
||||
|
||||
FBaseCVar *cvar = GetCVar(self, cvarname);
|
||||
FBaseCVar *cvar = GetCVar(self->player ? int(self->player - players) : -1, cvarname);
|
||||
if (cvar == nullptr)
|
||||
{
|
||||
ret->SetFloat(0);
|
||||
|
@ -431,7 +431,7 @@ DEFINE_ACTION_FUNCTION(AActor, GetCVarString)
|
|||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_STRING(cvarname);
|
||||
|
||||
FBaseCVar *cvar = GetCVar(self, cvarname);
|
||||
FBaseCVar *cvar = GetCVar(self->player? int(self->player - players) : -1, cvarname);
|
||||
if (cvar == nullptr)
|
||||
{
|
||||
ret->SetString("");
|
||||
|
|
Loading…
Reference in a new issue