From 1dc11c5032430292bb7a983d7f1d8f820ede2ed5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Jan 2019 14:31:23 +0100 Subject: [PATCH] - changed infighting check so that the static skill checker does not access the level Instead the level needs to be queried now. --- src/g_game.h | 2 -- src/g_level.cpp | 13 +++++++++++++ src/g_levellocals.h | 1 + src/g_skill.cpp | 3 --- src/p_interaction.cpp | 2 +- src/p_map.cpp | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 03658c106..b1b18d5c8 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -64,8 +64,6 @@ void G_PlayDemo (char* name); void G_TimeDemo (const char* name); bool G_CheckDemoStatus (void); -void G_WorldDone (void); - void G_Ticker (void); bool G_Responder (event_t* ev); diff --git a/src/g_level.cpp b/src/g_level.cpp index 5cc253a6d..c619ec76f 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2052,6 +2052,19 @@ void FLevelLocals::SetMusicVolume(float f) I_SetMusicVolume(f); } +//============================================================================ +// +// +// +//============================================================================ + +int FLevelLocals::GetInfighting() +{ + if (flags2 & LEVEL2_TOTALINFIGHTING) return 1; + if (flags2 & LEVEL2_NOINFIGHTING) return -1; + return G_SkillProperty(SKILLP_Infight); +} + //========================================================================== // IsPointInMap // diff --git a/src/g_levellocals.h b/src/g_levellocals.h index de6ff2331..f95b38f5c 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -174,6 +174,7 @@ struct FLevelLocals : public FLevelData int GetConversation(FName classname); void SetConversation(int convid, PClassActor *Class, int dlgindex); int FindNode (const FStrifeDialogueNode *node); + int GetInfighting(); void Init(); private: diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 287d862f7..897ffdc76 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -393,9 +393,6 @@ int G_SkillProperty(ESkillProperty prop) return AllSkills[gameskill].NoPain; case SKILLP_Infight: - // This property also needs to consider the level flags for the same info. - if (level.flags2 & LEVEL2_TOTALINFIGHTING) return 1; - if (level.flags2 & LEVEL2_NOINFIGHTING) return -1; if (AllSkills[gameskill].Infighting == LEVEL2_TOTALINFIGHTING) return 1; if (AllSkills[gameskill].Infighting == LEVEL2_NOINFIGHTING) return -1; return infighting; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index a4916e5cf..dfaeebea8 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1622,7 +1622,7 @@ bool AActor::OkayToSwitchTarget(AActor *other) int infight; if (flags7 & MF7_FORCEINFIGHTING) infight = 1; else if (flags5 & MF5_NOINFIGHTING) infight = -1; - else infight = G_SkillProperty(SKILLP_Infight); + else infight = Level->GetInfighting(); if (infight < 0 && other->player == NULL && !IsHostile (other)) { diff --git a/src/p_map.cpp b/src/p_map.cpp index 2166831c5..68275cf0b 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1163,7 +1163,7 @@ static bool CanAttackHurt(AActor *victim, AActor *shooter) // to harm / be harmed by anything. if (!victim->player && !shooter->player) { - int infight = G_SkillProperty(SKILLP_Infight); + int infight = victim->Level->GetInfighting(); if (infight < 0 && (victim->flags7 & MF7_FORCEINFIGHTING)) infight = 0; // This must override the 'no infight' setting to take effect. if (infight < 0)