From b7f1eba4068e1a9bf305f76a4ff6f58dfe7c04e2 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Tue, 30 Jul 2024 11:49:29 +0200 Subject: [PATCH] Short circuit friend list error (#1805) Co-authored-by: kraflab --- src/p_enemy.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/p_enemy.c b/src/p_enemy.c index 21b280b22..ffde72293 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -944,6 +944,17 @@ static boolean P_LookForMonsters(mobj_t *actor, boolean allaround) current_actor = actor; current_allaround = allaround; + // There is a bug in cl11+ that causes the player to get added + // to the monster friend list when damaged to below 50% health. + // This causes all monsters to believe friend monsters exist. + // The search algorithm is expensive and massively so on maps with many monsters. + // We still need to match rng calls for demo sync, but PIT_FindTarget is a no op. + if (((mobj_t *) cap->cnext)->player && cap->cnext == cap->cprev) + { + P_Random(pr_friends); + return false; + } + // Search first in the immediate vicinity. if (!P_BlockThingsIterator(x, y, PIT_FindTarget))