From 099d40b75ee1b06a80c1f8f83e8d1576b7dfadc1 Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:27:28 +0200 Subject: [PATCH] support custom types in `kill_recursive` and `destroy_recursive` --- src/game_api/entity.cpp | 5 +++-- src/game_api/entity_lookup.hpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game_api/entity.cpp b/src/game_api/entity.cpp index 36c58aae3..c8bc6fd11 100644 --- a/src/game_api/entity.cpp +++ b/src/game_api/entity.cpp @@ -17,6 +17,7 @@ #include "entities_chars.hpp" // for Player #include "entities_monsters.hpp" // #include "entity_hooks_info.hpp" // for EntityHooksInfo +#include "entity_lookup.hpp" // #include "memory.hpp" // for write_mem_prot #include "movable.hpp" // for Movable #include "movable_behavior.hpp" // for MovableBehavior @@ -542,7 +543,7 @@ void Entity::kill_recursive(bool destroy_corpse, Entity* responsible, std::optio { ent->kill(destroy_corpse, responsible); }; - if (!recursive(this, mask, ent_types, rec_mode, kill_func)) + if (!recursive(this, mask, get_proper_types(ent_types), rec_mode, kill_func)) kill(destroy_corpse, responsible); } @@ -552,6 +553,6 @@ void Entity::destroy_recursive(std::optional mask, const std::vectordestroy(); }; - if (!recursive(this, mask, ent_types, rec_mode, destroy_func)) + if (!recursive(this, mask, get_proper_types(ent_types), rec_mode, destroy_func)) destroy(); } diff --git a/src/game_api/entity_lookup.hpp b/src/game_api/entity_lookup.hpp index d9c67fa1e..c774cbb0a 100644 --- a/src/game_api/entity_lookup.hpp +++ b/src/game_api/entity_lookup.hpp @@ -31,3 +31,4 @@ std::vector entity_get_items_by(uint32_t uid, std::vector en std::vector entity_get_items_by(uint32_t uid, ENT_TYPE entity_type, uint32_t mask); std::vector get_entities_by_draw_depth(uint8_t draw_depth, LAYER l); std::vector get_entities_by_draw_depth(std::vector draw_depths, LAYER l); +std::vector get_proper_types(std::vector ent_types);