- removed all access to the consoleplayer variable from the play code

There is one exception in ACS for a net arbitrator check.
Aside from this the bot_observer CVAR was also removed. This was never implemented properly and could stomp upon custom player settings.
This commit is contained in:
Christoph Oelckers 2019-02-01 17:02:10 +01:00
commit d358e401ee
16 changed files with 101 additions and 110 deletions

View file

@ -4966,7 +4966,8 @@ int DLevelScript::SetUserCVar(int playernum, const char *cvarname, int value, bo
{
return 0;
}
FBaseCVar **cvar_p = Level->Players[playernum]->userinfo.CheckKey(FName(cvarname, true));
auto player = Level->Players[playernum];
FBaseCVar **cvar_p = player->userinfo.CheckKey(FName(cvarname, true));
FBaseCVar *cvar;
// Only mod-created cvars may be set.
if (cvar_p == NULL || (cvar = *cvar_p) == NULL || (cvar->GetFlags() & CVAR_IGNORE) || !(cvar->GetFlags() & CVAR_MOD))
@ -4976,7 +4977,7 @@ int DLevelScript::SetUserCVar(int playernum, const char *cvarname, int value, bo
DoSetCVar(cvar, value, is_string);
// If we are this player, then also reflect this change in the local version of this cvar.
if (playernum == consoleplayer && Level->isPrimaryLevel())
if (player && player == Level->GetConsolePlayer())
{
FBaseCVar *cvar = FindCVar(cvarname, NULL);
// If we can find it in the userinfo, then we should also be able to find it in the normal cvar list,
@ -8623,8 +8624,7 @@ scriptwait:
{
screen = screen->target;
}
if (Level->isPrimaryLevel() && (pcd == PCD_ENDHUDMESSAGEBOLD || screen == NULL ||
players[consoleplayer].mo == screen))
if (Level->isPrimaryLevel() && (pcd == PCD_ENDHUDMESSAGEBOLD || screen == NULL || Level->isConsolePlayer(screen)))
{
int type = Stack[optstart-6];
int id = Stack[optstart-5];
@ -9307,7 +9307,7 @@ scriptwait:
break;
case PCD_LOCALSETMUSIC:
if (activator == players[consoleplayer].mo)
if (Level->isConsolePlayer(activator))
{
S_ChangeMusic (Level->Behaviors.LookupString (STACK(3)), STACK(2));
}
@ -9315,7 +9315,7 @@ scriptwait:
break;
case PCD_LOCALSETMUSICDIRECT:
if (activator == players[consoleplayer].mo)
if (Level->isConsolePlayer(activator))
{
S_ChangeMusic (Level->Behaviors.LookupString (TAGSTR(uallong(pc[0]))), uallong(pc[1]));
}
@ -10402,7 +10402,7 @@ int P_StartScript (FLevelLocals *Level, AActor *who, line_t *where, int script,
}
else
{
if (!(flags & ACS_NET) || (who && who->player == &players[consoleplayer]))
if (!(flags & ACS_NET) || (who && Level->isConsolePlayer(who->player->mo))) // The indirection is necessary here.
{
Printf("P_StartScript: Unknown %s\n", ScriptPresentation(script).GetChars());
}