diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index a62f2fa95..20d854498 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -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; } diff --git a/src/c_cvars.h b/src/c_cvars.h index 11166098b..a74a4c0e4 100644 --- a/src/c_cvars.h +++ b/src/c_cvars.h @@ -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 diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index d96ca66ec..f415cf2df 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -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) { diff --git a/src/p_acs.cpp b/src/p_acs.cpp index ab64fcb89..d9061f762 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -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: diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index afd704909..114fd3f7e 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -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(""); diff --git a/src/win32/i_specialpaths.cpp b/src/win32/i_specialpaths.cpp index d7a9e7c2e..00631645c 100644 --- a/src/win32/i_specialpaths.cpp +++ b/src/win32/i_specialpaths.cpp @@ -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)