- removed the playernum parameter from CheckLocalView

This was always used with 'consoleplayer' which really is the only thing making sense here. But this is a part of the global state which should be avoided in play code.

In particular, this makes no real sense in case of secondary maps where it should always return false.
This commit is contained in:
Christoph Oelckers 2019-01-31 03:29:25 +01:00
parent 7149d1d312
commit ddab2c3e78
18 changed files with 50 additions and 61 deletions

View file

@ -752,7 +752,7 @@ public:
void ClearInventory(); void ClearInventory();
// Returns true if this view is considered "local" for the player. // Returns true if this view is considered "local" for the player.
bool CheckLocalView (int playernum) const; bool CheckLocalView() const;
// Finds the first item of a particular type. // Finds the first item of a particular type.
AActor *FindInventory (PClassActor *type, bool subclass=false); AActor *FindInventory (PClassActor *type, bool subclass=false);

View file

@ -224,7 +224,7 @@ bool AnnounceKill (AActor *killer, AActor *killee)
if (cl_bbannounce && deathmatch) if (cl_bbannounce && deathmatch)
{ {
bool playSound = killee->CheckLocalView (consoleplayer); bool playSound = killee->CheckLocalView();
if (killer == NULL) if (killer == NULL)
{ // The world killed the player { // The world killed the player
@ -258,7 +258,7 @@ bool AnnounceKill (AActor *killer, AActor *killee)
// Blood only plays the announcement sound on the killer's // Blood only plays the announcement sound on the killer's
// computer. I think it sounds neater to also hear it on // computer. I think it sounds neater to also hear it on
// the killee's machine. // the killee's machine.
playSound |= killer->CheckLocalView (consoleplayer); playSound |= killer->CheckLocalView();
} }
message = GStrings(choice->Message); message = GStrings(choice->Message);
@ -302,8 +302,8 @@ bool AnnounceTelefrag (AActor *killer, AActor *killee)
killee->player->userinfo.GetName(), killer->player->userinfo.GetName()); killee->player->userinfo.GetName(), killer->player->userinfo.GetName());
Printf (PRINT_MEDIUM, "%s\n", assembled); Printf (PRINT_MEDIUM, "%s\n", assembled);
} }
if (killee->CheckLocalView (consoleplayer) || if (killee->CheckLocalView() ||
killer->CheckLocalView (consoleplayer)) killer->CheckLocalView())
{ {
DoVoiceAnnounce (TelefragSounds[rannum % 7]); DoVoiceAnnounce (TelefragSounds[rannum % 7]);
} }
@ -337,7 +337,7 @@ bool AnnounceSpreeLoss (AActor *who)
{ {
if (cl_bbannounce) if (cl_bbannounce)
{ {
if (who->CheckLocalView (consoleplayer)) if (who->CheckLocalView())
{ {
DoVoiceAnnounce (TooBadSounds[M_Random() % 3]); DoVoiceAnnounce (TooBadSounds[M_Random() % 3]);
} }
@ -357,7 +357,7 @@ bool AnnounceMultikill (AActor *who)
{ {
if (cl_bbannounce) if (cl_bbannounce)
{ {
if (who->CheckLocalView (consoleplayer)) if (who->CheckLocalView())
{ {
DoVoiceAnnounce (GoodJobSounds[M_Random() % 3]); DoVoiceAnnounce (GoodJobSounds[M_Random() % 3]);
} }

View file

@ -621,7 +621,7 @@ void FParser::SF_ExitLevel(void)
void FParser::SF_Tip(void) void FParser::SF_Tip(void)
{ {
if (t_argc>0 && Script->trigger && if (t_argc>0 && Script->trigger &&
Script->trigger->CheckLocalView(consoleplayer)) Script->trigger->CheckLocalView())
{ {
C_MidPrint(SmallFont, GetFormatString(0).GetChars()); C_MidPrint(SmallFont, GetFormatString(0).GetChars());
} }
@ -660,7 +660,7 @@ void FParser::SF_PlayerTip(void)
if (CheckArgs(1)) if (CheckArgs(1))
{ {
int plnum = T_GetPlayerNum(t_argv[0]); int plnum = T_GetPlayerNum(t_argv[0]);
if (plnum!=-1 && Level->Players[plnum]->mo->CheckLocalView(consoleplayer)) if (plnum!=-1 && Level->Players[plnum]->mo->CheckLocalView())
{ {
C_MidPrint(SmallFont, GetFormatString(1).GetChars()); C_MidPrint(SmallFont, GetFormatString(1).GetChars());
} }
@ -676,7 +676,7 @@ void FParser::SF_PlayerTip(void)
void FParser::SF_Message(void) void FParser::SF_Message(void)
{ {
if (t_argc>0 && Script->trigger && if (t_argc>0 && Script->trigger &&
Script->trigger->CheckLocalView(consoleplayer)) Script->trigger->CheckLocalView())
{ {
Printf(PRINT_HIGH, "%s\n", GetFormatString(0).GetChars()); Printf(PRINT_HIGH, "%s\n", GetFormatString(0).GetChars());
} }
@ -693,7 +693,7 @@ void FParser::SF_PlayerMsg(void)
if (CheckArgs(1)) if (CheckArgs(1))
{ {
int plnum = T_GetPlayerNum(t_argv[0]); int plnum = T_GetPlayerNum(t_argv[0]);
if (plnum!=-1 && Level->Players[plnum]->mo->CheckLocalView(consoleplayer)) if (plnum!=-1 && Level->Players[plnum]->mo->CheckLocalView())
{ {
Printf(PRINT_HIGH, "%s\n", GetFormatString(1).GetChars()); Printf(PRINT_HIGH, "%s\n", GetFormatString(1).GetChars());
} }

View file

@ -494,7 +494,7 @@ int P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet)
// If we get here, that means the actor isn't holding an appropriate key. // If we get here, that means the actor isn't holding an appropriate key.
if (owner->CheckLocalView(consoleplayer)) if (owner->CheckLocalView())
{ {
PrintMessage(failtext); PrintMessage(failtext);

View file

@ -8588,7 +8588,7 @@ scriptwait:
screen = screen->target; screen = screen->target;
} }
if (pcd == PCD_ENDPRINTBOLD || screen == NULL || if (pcd == PCD_ENDPRINTBOLD || screen == NULL ||
screen->CheckLocalView (consoleplayer)) screen->CheckLocalView())
{ {
if (pcd == PCD_ENDPRINTBOLD && (gameinfo.correctprintbold || (Level->flags2 & LEVEL2_HEXENHACK))) if (pcd == PCD_ENDPRINTBOLD && (gameinfo.correctprintbold || (Level->flags2 & LEVEL2_HEXENHACK)))
C_MidPrintBold(activefont, work); C_MidPrintBold(activefont, work);
@ -8837,7 +8837,7 @@ scriptwait:
case PCD_LOCALAMBIENTSOUND: case PCD_LOCALAMBIENTSOUND:
lookup = Level->Behaviors.LookupString (STACK(2)); lookup = Level->Behaviors.LookupString (STACK(2));
if (lookup != NULL && activator->CheckLocalView (consoleplayer)) if (lookup != NULL && activator->CheckLocalView())
{ {
S_Sound (CHAN_AUTO, S_Sound (CHAN_AUTO,
lookup, lookup,
@ -9966,7 +9966,7 @@ scriptwait:
} }
case PCD_SETMUGSHOTSTATE: case PCD_SETMUGSHOTSTATE:
if (!multiplayer || (activator != nullptr && activator->CheckLocalView(consoleplayer))) if (!multiplayer || (activator != nullptr && activator->CheckLocalView()))
{ {
StatusBar->SetMugShotState(Level->Behaviors.LookupString(STACK(1))); StatusBar->SetMugShotState(Level->Behaviors.LookupString(STACK(1)));
} }

View file

@ -1294,8 +1294,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Print)
PARAM_NAME (fontname); PARAM_NAME (fontname);
if (text[0] == '$') text = GStrings(&text[1]); if (text[0] == '$') text = GStrings(&text[1]);
if (self->CheckLocalView (consoleplayer) || if (self->CheckLocalView() ||
(self->target != NULL && self->target->CheckLocalView (consoleplayer))) (self->target != NULL && self->target->CheckLocalView()))
{ {
float saved = con_midtime; float saved = con_midtime;
FFont *font = NULL; FFont *font = NULL;
@ -1358,7 +1358,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Log)
PARAM_STRING_VAL(text); PARAM_STRING_VAL(text);
PARAM_BOOL(local); PARAM_BOOL(local);
if (local && !self->CheckLocalView(consoleplayer)) return 0; if (local && !self->CheckLocalView()) return 0;
if (text[0] == '$') text = GStrings(&text[1]); if (text[0] == '$') text = GStrings(&text[1]);
FString formatted = strbin1(text); FString formatted = strbin1(text);
@ -1378,7 +1378,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LogInt)
PARAM_INT(num); PARAM_INT(num);
PARAM_BOOL(local); PARAM_BOOL(local);
if (local && !self->CheckLocalView(consoleplayer)) return 0; if (local && !self->CheckLocalView()) return 0;
Printf("%d\n", num); Printf("%d\n", num);
return 0; return 0;
} }
@ -1395,7 +1395,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LogFloat)
PARAM_FLOAT(num); PARAM_FLOAT(num);
PARAM_BOOL(local); PARAM_BOOL(local);
if (local && !self->CheckLocalView(consoleplayer)) return 0; if (local && !self->CheckLocalView()) return 0;
IGNORE_FORMAT_PRE IGNORE_FORMAT_PRE
Printf("%H\n", num); Printf("%H\n", num);
IGNORE_FORMAT_POST IGNORE_FORMAT_POST
@ -4925,7 +4925,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetMugshotState)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_STRING(name); PARAM_STRING(name);
if (self->CheckLocalView(consoleplayer)) if (self->CheckLocalView())
StatusBar->SetMugShotState(name); StatusBar->SetMugShotState(name);
return 0; return 0;
} }

View file

@ -498,7 +498,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
} }
if (deathmatch && if (deathmatch &&
source->CheckLocalView (consoleplayer) && source->CheckLocalView() &&
cl_showmultikills) cl_showmultikills)
{ {
const char *multimsg; const char *multimsg;

View file

@ -3200,7 +3200,7 @@ FUNC(LS_SendToCommunicator)
it->player->SetLogNumber (arg0); it->player->SetLogNumber (arg0);
} }
if (it->CheckLocalView (consoleplayer)) if (it->CheckLocalView())
{ {
S_StopSound (CHAN_VOICE); S_StopSound (CHAN_VOICE);
S_Sound (CHAN_VOICE, name, 1, ATTN_NORM); S_Sound (CHAN_VOICE, name, 1, ATTN_NORM);

View file

@ -6274,7 +6274,7 @@ int P_PushUp(AActor *thing, FChangePosition *cpos)
if (cpos->instant) if (cpos->instant)
{ {
intersect->Prev.Z += intersect->Z() - oldz; intersect->Prev.Z += intersect->Z() - oldz;
if (intersect->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); if (intersect->CheckLocalView()) R_ResetViewInterpolation();
} }
intersect->UpdateRenderSectorList(); intersect->UpdateRenderSectorList();
@ -6371,7 +6371,7 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos)
if (cpos->instant) if (cpos->instant)
{ {
thing->Prev.Z += thing->floorz - oldz; thing->Prev.Z += thing->floorz - oldz;
if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); if (thing->CheckLocalView()) R_ResetViewInterpolation();
} }
thing->SetZ(thing->floorz); thing->SetZ(thing->floorz);
P_CheckFakeFloorTriggers(thing, oldz); P_CheckFakeFloorTriggers(thing, oldz);
@ -6385,7 +6385,7 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos)
if (cpos->instant) if (cpos->instant)
{ {
thing->Prev.Z += -oldfloorz + thing->floorz; thing->Prev.Z += -oldfloorz + thing->floorz;
if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); if (thing->CheckLocalView()) R_ResetViewInterpolation();
} }
thing->AddZ(-oldfloorz + thing->floorz); thing->AddZ(-oldfloorz + thing->floorz);
P_CheckFakeFloorTriggers(thing, oldz); P_CheckFakeFloorTriggers(thing, oldz);
@ -6425,7 +6425,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos)
if (cpos->instant) if (cpos->instant)
{ {
thing->Prev.Z += thing->floorz - thing->Z(); thing->Prev.Z += thing->floorz - thing->Z();
if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); if (thing->CheckLocalView()) R_ResetViewInterpolation();
} }
thing->SetZ(thing->floorz); thing->SetZ(thing->floorz);
@ -6439,7 +6439,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos)
if (cpos->instant) if (cpos->instant)
{ {
thing->Prev.Z += -oldfloorz + thing->floorz; thing->Prev.Z += -oldfloorz + thing->floorz;
if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); if (thing->CheckLocalView()) R_ResetViewInterpolation();
} }
} }
else return; else return;

View file

@ -943,9 +943,9 @@ DEFINE_ACTION_FUNCTION(AActor, GiveBody)
// //
//============================================================================ //============================================================================
bool AActor::CheckLocalView (int playernum) const bool AActor::CheckLocalView() const
{ {
auto p = &players[playernum]; auto p = &players[consoleplayer];
if (p->camera == this) if (p->camera == this)
{ {
return true; return true;
@ -966,7 +966,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckLocalView)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(cp); PARAM_INT(cp);
ACTION_RETURN_BOOL(self->CheckLocalView(cp)); ACTION_RETURN_BOOL(self->CheckLocalView());
} }
//============================================================================ //============================================================================

View file

@ -594,7 +594,7 @@ void P_GiveSecret(FLevelLocals *Level, AActor *actor, bool printmessage, bool pl
ret.IntAt(&retval); ret.IntAt(&retval);
VMCall(func, params, countof(params), &ret, 1); VMCall(func, params, countof(params), &ret, 1);
} }
if (retval && cl_showsecretmessage && actor->CheckLocalView(consoleplayer)) if (retval && cl_showsecretmessage && actor->CheckLocalView())
{ {
if (printmessage) if (printmessage)
{ {

View file

@ -438,7 +438,7 @@ void player_t::SetLogText (const char *text)
{ {
LogText = text; LogText = text;
if (mo->CheckLocalView(consoleplayer)) if (mo->CheckLocalView())
{ {
// Print log text to console // Print log text to console
AddToConsole(-1, TEXTCOLOR_GOLD); AddToConsole(-1, TEXTCOLOR_GOLD);

View file

@ -334,19 +334,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FIn
// //
//========================================================================== //==========================================================================
DInterpolation::DInterpolation()
{
Next = nullptr;
Prev = nullptr;
refcount = 0;
}
//==========================================================================
//
//
//
//==========================================================================
int DInterpolation::AddRef() int DInterpolation::AddRef()
{ {
return ++refcount; return ++refcount;
@ -404,7 +391,7 @@ void DInterpolation::Serialize(FSerializer &arc)
//========================================================================== //==========================================================================
DSectorPlaneInterpolation::DSectorPlaneInterpolation(sector_t *_sector, bool _plane, bool attach) DSectorPlaneInterpolation::DSectorPlaneInterpolation(sector_t *_sector, bool _plane, bool attach)
: DInterpolation(sector->Level) : DInterpolation(_sector->Level)
{ {
sector = _sector; sector = _sector;
ceiling = _plane; ceiling = _plane;
@ -570,7 +557,7 @@ size_t DSectorPlaneInterpolation::PropagateMark()
//========================================================================== //==========================================================================
DSectorScrollInterpolation::DSectorScrollInterpolation(sector_t *_sector, bool _plane) DSectorScrollInterpolation::DSectorScrollInterpolation(sector_t *_sector, bool _plane)
: DInterpolation(sector->Level) : DInterpolation(_sector->Level)
{ {
sector = _sector; sector = _sector;
ceiling = _plane; ceiling = _plane;
@ -676,7 +663,7 @@ void DSectorScrollInterpolation::Serialize(FSerializer &arc)
//========================================================================== //==========================================================================
DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part) DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part)
: DInterpolation(side->GetLevel()) : DInterpolation(_side->GetLevel())
{ {
side = _side; side = _side;
part = _part; part = _part;

View file

@ -2,6 +2,8 @@
#define R_INTERPOLATE_H #define R_INTERPOLATE_H
#include "dobject.h" #include "dobject.h"
struct FLevelLocals;
//========================================================================== //==========================================================================
// //
// //
@ -15,14 +17,14 @@ class DInterpolation : public DObject
DECLARE_ABSTRACT_CLASS(DInterpolation, DObject) DECLARE_ABSTRACT_CLASS(DInterpolation, DObject)
HAS_OBJECT_POINTERS HAS_OBJECT_POINTERS
TObjPtr<DInterpolation*> Next; TObjPtr<DInterpolation*> Next = nullptr;
TObjPtr<DInterpolation*> Prev; TObjPtr<DInterpolation*> Prev = nullptr;
protected: protected:
FLevelLocals *Level; FLevelLocals *Level;
int refcount; int refcount = 0;
DInterpolation(FLevelLocals *l) : Level(l) {} DInterpolation(FLevelLocals *l = nullptr) : Level(l) {}
public: public:
int AddRef(); int AddRef();

View file

@ -1420,7 +1420,7 @@ void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool
} }
else else
{ {
if (a->CheckLocalView(consoleplayer)) if (a->CheckLocalView())
{ {
S_Sound(chan, sid, vol, ATTN_NONE); S_Sound(chan, sid, vol, ATTN_NONE);
} }

View file

@ -125,7 +125,7 @@ class PuzzleItem : Inventory
} }
// [RH] Always play the sound if the use fails. // [RH] Always play the sound if the use fails.
Owner.A_PlaySound ("*puzzfail", CHAN_VOICE); Owner.A_PlaySound ("*puzzfail", CHAN_VOICE);
if (Owner.CheckLocalView (consoleplayer)) if (Owner.CheckLocalView())
{ {
Console.MidPrint ("SmallFont", PuzzFailMessage, true); Console.MidPrint ("SmallFont", PuzzFailMessage, true);
} }

View file

@ -765,7 +765,7 @@ class Inventory : Actor
toucher = player.mo; toucher = player.mo;
} }
bool localview = toucher.CheckLocalView(consoleplayer); bool localview = toucher.CheckLocalView();
bool res; bool res;
[res, toucher] = CallTryPickup(toucher); [res, toucher] = CallTryPickup(toucher);
@ -1049,7 +1049,7 @@ class Inventory : Actor
} }
/* /*
else if ((ItemFlags & IF_FANCYPICKUPSOUND) && else if ((ItemFlags & IF_FANCYPICKUPSOUND) &&
(toucher == NULL || toucher->CheckLocalView(consoleplayer))) (toucher == NULL || toucher->CheckLocalView()))
{ {
atten = ATTN_NONE; atten = ATTN_NONE;
} }
@ -1059,7 +1059,7 @@ class Inventory : Actor
atten = ATTN_NORM; atten = ATTN_NORM;
} }
if (toucher != NULL && toucher.CheckLocalView(consoleplayer)) if (toucher != NULL && toucher.CheckLocalView())
{ {
chan = CHAN_PICKUP|CHAN_NOPAUSE; chan = CHAN_PICKUP|CHAN_NOPAUSE;
} }

View file

@ -529,7 +529,7 @@ class Scanner : PowerupGiver
{ {
if (!level.AllMap) if (!level.AllMap)
{ {
if (Owner.CheckLocalView (consoleplayer)) if (Owner.CheckLocalView())
{ {
Console.MidPrint("SmallFont", "$TXT_NEEDMAP"); Console.MidPrint("SmallFont", "$TXT_NEEDMAP");
} }
@ -630,7 +630,7 @@ class RaiseAlarm : DummyStrifeItem
if (dropper.target != null) if (dropper.target != null)
{ {
dropper.target.SoundAlert(dropper.target); dropper.target.SoundAlert(dropper.target);
if (dropper.target.CheckLocalView(consoleplayer)) if (dropper.target.CheckLocalView())
{ {
Console.MidPrint(SmallFont, "$TXT_YOUFOOL"); Console.MidPrint(SmallFont, "$TXT_YOUFOOL");
} }
@ -670,7 +670,7 @@ class CloseDoor222 : DummyStrifeItem
Door_Close(222, 16); Door_Close(222, 16);
if (dropper.target != null) if (dropper.target != null)
{ {
if (dropper.target.CheckLocalView(consoleplayer)) if (dropper.target.CheckLocalView())
{ {
Console.MidPrint(SmallFont, "$TXT_YOUREDEAD"); Console.MidPrint(SmallFont, "$TXT_YOUREDEAD");
} }