From 7b30f9350cfe8b0c15ca35cc080983eafdc7c8e6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2025 13:19:26 +0100 Subject: [PATCH] fix automap display for keys that were altered by Dehacked. --- src/am_map.cpp | 9 ++++++++- src/gamedata/a_keys.cpp | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index c547884b2e..ec63817549 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2910,11 +2910,18 @@ void DAutomap::drawKeys () mpoint_t p; DAngle angle; - auto it = Level->GetThinkerIterator(NAME_Key); + auto it = Level->GetThinkerIterator(NAME_Inventory); AActor *key; while ((key = it.Next()) != nullptr) { + auto cls = key->GetClass(); + if (cls->IsDescendantOf(NAME_DehackedPickup)) + { + cls = cls->ActorInfo()->Replacee; + } + if (!cls->IsDescendantOf(NAME_Key)) continue; + DVector3 pos = key->PosRelative(MapPortalGroup); p.x = pos.X; p.y = pos.Y; diff --git a/src/gamedata/a_keys.cpp b/src/gamedata/a_keys.cpp index 32f680a423..369f9c5ed1 100644 --- a/src/gamedata/a_keys.cpp +++ b/src/gamedata/a_keys.cpp @@ -62,6 +62,16 @@ struct OneKey // P_GetMapColorForKey() checks the key directly if (owner->IsA(key) || owner->GetSpecies() == key->TypeName) return true; + if (owner->IsKindOf(NAME_DehackedPickup)) + { + auto cls = owner->GetClass()->ActorInfo()->Replacee; + if (cls == key || owner->Species == key->TypeName) + { + return true; + } + } + + // Other calls check an actor that may have a key in its inventory. for (AActor *item = owner->Inventory; item != NULL; item = item->Inventory) {