From: JadingTsunami Date: Fri, 26 Jul 2024 17:54:09 -0700 Subject: [PATCH] [Credit to dsda-doom] Fix cl11+ monster search time bug. * Credit to dsda-doom: https://github.com/kraflab/dsda-doom/ * Fix cl11+ bug that slows down maps with large monster counts. * See here for details: https://github.com/kraflab/dsda-doom/commit/\ dc29f0ce801f6ff910ae3fc3e6b1210ac79e87cf --- prboom-plus.old/prboom2/src/p_enemy.c +++ prboom-plus/prboom2/src/p_enemy.c @@ -922,6 +922,18 @@ current_actor = actor; current_allaround = allaround; + // credit - from dsda-doom + // https://github.com/kraflab/dsda-doom/commit/dc29f0ce801f6ff910ae3fc3e6b1210ac79e87cf + // 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))