From ddab2c3e780f867b81036f1c030d98ff03c3c430 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Jan 2019 03:29:25 +0100 Subject: [PATCH] - 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. --- src/actor.h | 2 +- src/bbannouncer.cpp | 12 ++++++------ src/fragglescript/t_func.cpp | 8 ++++---- src/g_inventory/a_keys.cpp | 2 +- src/p_acs.cpp | 6 +++--- src/p_actionfunctions.cpp | 12 ++++++------ src/p_interaction.cpp | 2 +- src/p_lnspec.cpp | 2 +- src/p_map.cpp | 10 +++++----- src/p_mobj.cpp | 6 +++--- src/p_spec.cpp | 2 +- src/p_user.cpp | 2 +- src/r_data/r_interpolate.cpp | 19 +++---------------- src/r_data/r_interpolate.h | 10 ++++++---- src/s_sound.cpp | 2 +- wadsrc/static/zscript/inventory/inv_misc.txt | 2 +- wadsrc/static/zscript/inventory/inventory.txt | 6 +++--- wadsrc/static/zscript/strife/strifeitems.txt | 6 +++--- 18 files changed, 50 insertions(+), 61 deletions(-) diff --git a/src/actor.h b/src/actor.h index 2436cdaaa8..3394789fb5 100644 --- a/src/actor.h +++ b/src/actor.h @@ -752,7 +752,7 @@ public: void ClearInventory(); // 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. AActor *FindInventory (PClassActor *type, bool subclass=false); diff --git a/src/bbannouncer.cpp b/src/bbannouncer.cpp index 7c7d0e12a7..58243ea5c1 100644 --- a/src/bbannouncer.cpp +++ b/src/bbannouncer.cpp @@ -224,7 +224,7 @@ bool AnnounceKill (AActor *killer, AActor *killee) if (cl_bbannounce && deathmatch) { - bool playSound = killee->CheckLocalView (consoleplayer); + bool playSound = killee->CheckLocalView(); if (killer == NULL) { // 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 // computer. I think it sounds neater to also hear it on // the killee's machine. - playSound |= killer->CheckLocalView (consoleplayer); + playSound |= killer->CheckLocalView(); } message = GStrings(choice->Message); @@ -302,8 +302,8 @@ bool AnnounceTelefrag (AActor *killer, AActor *killee) killee->player->userinfo.GetName(), killer->player->userinfo.GetName()); Printf (PRINT_MEDIUM, "%s\n", assembled); } - if (killee->CheckLocalView (consoleplayer) || - killer->CheckLocalView (consoleplayer)) + if (killee->CheckLocalView() || + killer->CheckLocalView()) { DoVoiceAnnounce (TelefragSounds[rannum % 7]); } @@ -337,7 +337,7 @@ bool AnnounceSpreeLoss (AActor *who) { if (cl_bbannounce) { - if (who->CheckLocalView (consoleplayer)) + if (who->CheckLocalView()) { DoVoiceAnnounce (TooBadSounds[M_Random() % 3]); } @@ -357,7 +357,7 @@ bool AnnounceMultikill (AActor *who) { if (cl_bbannounce) { - if (who->CheckLocalView (consoleplayer)) + if (who->CheckLocalView()) { DoVoiceAnnounce (GoodJobSounds[M_Random() % 3]); } diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 828da8d1e6..c2843665b3 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -621,7 +621,7 @@ void FParser::SF_ExitLevel(void) void FParser::SF_Tip(void) { if (t_argc>0 && Script->trigger && - Script->trigger->CheckLocalView(consoleplayer)) + Script->trigger->CheckLocalView()) { C_MidPrint(SmallFont, GetFormatString(0).GetChars()); } @@ -660,7 +660,7 @@ void FParser::SF_PlayerTip(void) if (CheckArgs(1)) { 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()); } @@ -676,7 +676,7 @@ void FParser::SF_PlayerTip(void) void FParser::SF_Message(void) { if (t_argc>0 && Script->trigger && - Script->trigger->CheckLocalView(consoleplayer)) + Script->trigger->CheckLocalView()) { Printf(PRINT_HIGH, "%s\n", GetFormatString(0).GetChars()); } @@ -693,7 +693,7 @@ void FParser::SF_PlayerMsg(void) if (CheckArgs(1)) { 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()); } diff --git a/src/g_inventory/a_keys.cpp b/src/g_inventory/a_keys.cpp index ad0e85404d..1024f216a1 100644 --- a/src/g_inventory/a_keys.cpp +++ b/src/g_inventory/a_keys.cpp @@ -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 (owner->CheckLocalView(consoleplayer)) + if (owner->CheckLocalView()) { PrintMessage(failtext); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 8b54e9798d..723f89c670 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8588,7 +8588,7 @@ scriptwait: screen = screen->target; } if (pcd == PCD_ENDPRINTBOLD || screen == NULL || - screen->CheckLocalView (consoleplayer)) + screen->CheckLocalView()) { if (pcd == PCD_ENDPRINTBOLD && (gameinfo.correctprintbold || (Level->flags2 & LEVEL2_HEXENHACK))) C_MidPrintBold(activefont, work); @@ -8837,7 +8837,7 @@ scriptwait: case PCD_LOCALAMBIENTSOUND: lookup = Level->Behaviors.LookupString (STACK(2)); - if (lookup != NULL && activator->CheckLocalView (consoleplayer)) + if (lookup != NULL && activator->CheckLocalView()) { S_Sound (CHAN_AUTO, lookup, @@ -9966,7 +9966,7 @@ scriptwait: } case PCD_SETMUGSHOTSTATE: - if (!multiplayer || (activator != nullptr && activator->CheckLocalView(consoleplayer))) + if (!multiplayer || (activator != nullptr && activator->CheckLocalView())) { StatusBar->SetMugShotState(Level->Behaviors.LookupString(STACK(1))); } diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 3983436339..54d8432685 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1294,8 +1294,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Print) PARAM_NAME (fontname); if (text[0] == '$') text = GStrings(&text[1]); - if (self->CheckLocalView (consoleplayer) || - (self->target != NULL && self->target->CheckLocalView (consoleplayer))) + if (self->CheckLocalView() || + (self->target != NULL && self->target->CheckLocalView())) { float saved = con_midtime; FFont *font = NULL; @@ -1358,7 +1358,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Log) PARAM_STRING_VAL(text); PARAM_BOOL(local); - if (local && !self->CheckLocalView(consoleplayer)) return 0; + if (local && !self->CheckLocalView()) return 0; if (text[0] == '$') text = GStrings(&text[1]); FString formatted = strbin1(text); @@ -1378,7 +1378,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LogInt) PARAM_INT(num); PARAM_BOOL(local); - if (local && !self->CheckLocalView(consoleplayer)) return 0; + if (local && !self->CheckLocalView()) return 0; Printf("%d\n", num); return 0; } @@ -1395,7 +1395,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LogFloat) PARAM_FLOAT(num); PARAM_BOOL(local); - if (local && !self->CheckLocalView(consoleplayer)) return 0; + if (local && !self->CheckLocalView()) return 0; IGNORE_FORMAT_PRE Printf("%H\n", num); IGNORE_FORMAT_POST @@ -4925,7 +4925,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetMugshotState) { PARAM_SELF_PROLOGUE(AActor); PARAM_STRING(name); - if (self->CheckLocalView(consoleplayer)) + if (self->CheckLocalView()) StatusBar->SetMugShotState(name); return 0; } diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index a8e3c0acca..d5fb79cc38 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -498,7 +498,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf } if (deathmatch && - source->CheckLocalView (consoleplayer) && + source->CheckLocalView() && cl_showmultikills) { const char *multimsg; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 2b180955f4..08513304b1 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3200,7 +3200,7 @@ FUNC(LS_SendToCommunicator) it->player->SetLogNumber (arg0); } - if (it->CheckLocalView (consoleplayer)) + if (it->CheckLocalView()) { S_StopSound (CHAN_VOICE); S_Sound (CHAN_VOICE, name, 1, ATTN_NORM); diff --git a/src/p_map.cpp b/src/p_map.cpp index eeb11b5450..ebdd824347 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6274,7 +6274,7 @@ int P_PushUp(AActor *thing, FChangePosition *cpos) if (cpos->instant) { intersect->Prev.Z += intersect->Z() - oldz; - if (intersect->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + if (intersect->CheckLocalView()) R_ResetViewInterpolation(); } intersect->UpdateRenderSectorList(); @@ -6371,7 +6371,7 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) if (cpos->instant) { thing->Prev.Z += thing->floorz - oldz; - if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + if (thing->CheckLocalView()) R_ResetViewInterpolation(); } thing->SetZ(thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); @@ -6385,7 +6385,7 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) if (cpos->instant) { thing->Prev.Z += -oldfloorz + thing->floorz; - if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + if (thing->CheckLocalView()) R_ResetViewInterpolation(); } thing->AddZ(-oldfloorz + thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); @@ -6425,7 +6425,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) if (cpos->instant) { thing->Prev.Z += thing->floorz - thing->Z(); - if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + if (thing->CheckLocalView()) R_ResetViewInterpolation(); } thing->SetZ(thing->floorz); @@ -6439,7 +6439,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) if (cpos->instant) { thing->Prev.Z += -oldfloorz + thing->floorz; - if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + if (thing->CheckLocalView()) R_ResetViewInterpolation(); } } else return; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index dca94497a3..94255229db 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -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) { return true; @@ -966,7 +966,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckLocalView) { PARAM_SELF_PROLOGUE(AActor); PARAM_INT(cp); - ACTION_RETURN_BOOL(self->CheckLocalView(cp)); + ACTION_RETURN_BOOL(self->CheckLocalView()); } //============================================================================ diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 65f10d0cd7..b2ebd2cfbb 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -594,7 +594,7 @@ void P_GiveSecret(FLevelLocals *Level, AActor *actor, bool printmessage, bool pl ret.IntAt(&retval); VMCall(func, params, countof(params), &ret, 1); } - if (retval && cl_showsecretmessage && actor->CheckLocalView(consoleplayer)) + if (retval && cl_showsecretmessage && actor->CheckLocalView()) { if (printmessage) { diff --git a/src/p_user.cpp b/src/p_user.cpp index 4fb9a0f6d3..487a688065 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -438,7 +438,7 @@ void player_t::SetLogText (const char *text) { LogText = text; - if (mo->CheckLocalView(consoleplayer)) + if (mo->CheckLocalView()) { // Print log text to console AddToConsole(-1, TEXTCOLOR_GOLD); diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 5edf79df4d..874159c027 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -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() { return ++refcount; @@ -404,7 +391,7 @@ void DInterpolation::Serialize(FSerializer &arc) //========================================================================== DSectorPlaneInterpolation::DSectorPlaneInterpolation(sector_t *_sector, bool _plane, bool attach) -: DInterpolation(sector->Level) +: DInterpolation(_sector->Level) { sector = _sector; ceiling = _plane; @@ -570,7 +557,7 @@ size_t DSectorPlaneInterpolation::PropagateMark() //========================================================================== DSectorScrollInterpolation::DSectorScrollInterpolation(sector_t *_sector, bool _plane) -: DInterpolation(sector->Level) +: DInterpolation(_sector->Level) { sector = _sector; ceiling = _plane; @@ -676,7 +663,7 @@ void DSectorScrollInterpolation::Serialize(FSerializer &arc) //========================================================================== DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part) -: DInterpolation(side->GetLevel()) +: DInterpolation(_side->GetLevel()) { side = _side; part = _part; diff --git a/src/r_data/r_interpolate.h b/src/r_data/r_interpolate.h index 0854fca8c7..701d8c318e 100644 --- a/src/r_data/r_interpolate.h +++ b/src/r_data/r_interpolate.h @@ -2,6 +2,8 @@ #define R_INTERPOLATE_H #include "dobject.h" + +struct FLevelLocals; //========================================================================== // // @@ -15,14 +17,14 @@ class DInterpolation : public DObject DECLARE_ABSTRACT_CLASS(DInterpolation, DObject) HAS_OBJECT_POINTERS - TObjPtr Next; - TObjPtr Prev; + TObjPtr Next = nullptr; + TObjPtr Prev = nullptr; protected: FLevelLocals *Level; - int refcount; + int refcount = 0; - DInterpolation(FLevelLocals *l) : Level(l) {} + DInterpolation(FLevelLocals *l = nullptr) : Level(l) {} public: int AddRef(); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 7bcff4d675..766821c8d8 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1420,7 +1420,7 @@ void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool } else { - if (a->CheckLocalView(consoleplayer)) + if (a->CheckLocalView()) { S_Sound(chan, sid, vol, ATTN_NONE); } diff --git a/wadsrc/static/zscript/inventory/inv_misc.txt b/wadsrc/static/zscript/inventory/inv_misc.txt index 7aa60227dd..f401a3e2db 100644 --- a/wadsrc/static/zscript/inventory/inv_misc.txt +++ b/wadsrc/static/zscript/inventory/inv_misc.txt @@ -125,7 +125,7 @@ class PuzzleItem : Inventory } // [RH] Always play the sound if the use fails. Owner.A_PlaySound ("*puzzfail", CHAN_VOICE); - if (Owner.CheckLocalView (consoleplayer)) + if (Owner.CheckLocalView()) { Console.MidPrint ("SmallFont", PuzzFailMessage, true); } diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index f89bb74938..ecafdf66c9 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -765,7 +765,7 @@ class Inventory : Actor toucher = player.mo; } - bool localview = toucher.CheckLocalView(consoleplayer); + bool localview = toucher.CheckLocalView(); bool res; [res, toucher] = CallTryPickup(toucher); @@ -1049,7 +1049,7 @@ class Inventory : Actor } /* else if ((ItemFlags & IF_FANCYPICKUPSOUND) && - (toucher == NULL || toucher->CheckLocalView(consoleplayer))) + (toucher == NULL || toucher->CheckLocalView())) { atten = ATTN_NONE; } @@ -1059,7 +1059,7 @@ class Inventory : Actor atten = ATTN_NORM; } - if (toucher != NULL && toucher.CheckLocalView(consoleplayer)) + if (toucher != NULL && toucher.CheckLocalView()) { chan = CHAN_PICKUP|CHAN_NOPAUSE; } diff --git a/wadsrc/static/zscript/strife/strifeitems.txt b/wadsrc/static/zscript/strife/strifeitems.txt index 65ccb7ccb7..9b6935566c 100644 --- a/wadsrc/static/zscript/strife/strifeitems.txt +++ b/wadsrc/static/zscript/strife/strifeitems.txt @@ -529,7 +529,7 @@ class Scanner : PowerupGiver { if (!level.AllMap) { - if (Owner.CheckLocalView (consoleplayer)) + if (Owner.CheckLocalView()) { Console.MidPrint("SmallFont", "$TXT_NEEDMAP"); } @@ -630,7 +630,7 @@ class RaiseAlarm : DummyStrifeItem if (dropper.target != null) { dropper.target.SoundAlert(dropper.target); - if (dropper.target.CheckLocalView(consoleplayer)) + if (dropper.target.CheckLocalView()) { Console.MidPrint(SmallFont, "$TXT_YOUFOOL"); } @@ -670,7 +670,7 @@ class CloseDoor222 : DummyStrifeItem Door_Close(222, 16); if (dropper.target != null) { - if (dropper.target.CheckLocalView(consoleplayer)) + if (dropper.target.CheckLocalView()) { Console.MidPrint(SmallFont, "$TXT_YOUREDEAD"); }