mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +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
This commit is contained in:
parent
8f00eb54d8
commit
e93de62f98
6 changed files with 11 additions and 19 deletions
|
@ -1599,7 +1599,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)
|
||||
|
@ -1624,7 +1624,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.
|
||||
|
@ -1637,11 +1637,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)
|
||||
{
|
||||
|
|
|
@ -5788,7 +5788,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
|||
case ACSF_GetCVarString:
|
||||
if (argCount == 1)
|
||||
{
|
||||
return DoGetCVar(GetCVar(activator, Level->Behaviors.LookupString(args[0])), true);
|
||||
return DoGetCVar(GetCVar(activator && activator->player ? int(activator->player - players) : -1, Level->Behaviors.LookupString(args[0])), true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -9733,7 +9733,8 @@ scriptwait:
|
|||
break;
|
||||
|
||||
case PCD_GETCVAR:
|
||||
STACK(1) = DoGetCVar(GetCVar(activator, Level->Behaviors.LookupString(STACK(1))), false);
|
||||
// This should not use Level->PlayerNum!
|
||||
STACK(1) = DoGetCVar(GetCVar(activator && activator->player? int(activator->player - players) : -1, Level->Behaviors.LookupString(STACK(1))), false);
|
||||
break;
|
||||
|
||||
case PCD_SETHUDSIZE:
|
||||
|
|
|
@ -383,7 +383,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);
|
||||
|
@ -413,7 +413,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("");
|
||||
|
|
|
@ -101,10 +101,6 @@ bool UseKnownFolders()
|
|||
|
||||
bool GetKnownFolder(int shell_folder, REFKNOWNFOLDERID known_folder, bool create, FString &path)
|
||||
{
|
||||
using OptWin32::SHGetKnownFolderPath;
|
||||
|
||||
WCHAR pathstr[MAX_PATH];
|
||||
|
||||
// SHGetKnownFolderPath knows about more folders than SHGetFolderPath, but is
|
||||
// new to Vista, hence the reason we support both.
|
||||
if (!SHGetKnownFolderPath)
|
||||
|
|
Loading…
Reference in a new issue