From cba1fc8f61fb7bb5f4ef5c386356c9c7a6eef694 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 25 Jul 2023 11:56:20 +0300 Subject: [PATCH] Add map_scr_remove_spatial --- src/mapper/mp_scrpt.cc | 35 +++++++++++++++++++++++++++++++++++ src/mapper/mp_scrpt.h | 1 + 2 files changed, 36 insertions(+) diff --git a/src/mapper/mp_scrpt.cc b/src/mapper/mp_scrpt.cc index 5a100f9..eb2f9c6 100644 --- a/src/mapper/mp_scrpt.cc +++ b/src/mapper/mp_scrpt.cc @@ -7,6 +7,41 @@ namespace fallout { +// 0x49B170 +int map_scr_remove_spatial(int tile, int elevation) +{ + Script* scr; + Object* obj; + Rect rect; + + scr = scriptGetFirstSpatialScript(elevation); + while (scr != NULL) { + if (builtTileGetTile(scr->sp.built_tile) == tile) { + scriptRemove(scr->sid); + + scr = scriptGetFirstSpatialScript(elevation); + continue; + } + + scr = scriptGetNextSpatialScript(); + } + + obj = objectFindFirstAtElevation(elevation); + while (obj != NULL) { + if (obj->tile == tile && buildFid(OBJ_TYPE_INTERFACE, 3, 0, 0, 0) == obj->fid) { + objectDestroy(obj, &rect); + tileWindowRefreshRect(&rect, elevation); + + obj = objectFindFirstAtElevation(elevation); + continue; + } + + obj = objectFindNextAtElevation(); + } + + return 0; +} + // 0x49B214 int map_scr_remove_all_spatials() { diff --git a/src/mapper/mp_scrpt.h b/src/mapper/mp_scrpt.h index 6912a8e..64c2d59 100644 --- a/src/mapper/mp_scrpt.h +++ b/src/mapper/mp_scrpt.h @@ -3,6 +3,7 @@ namespace fallout { +int map_scr_remove_spatial(int tile, int elevation); int map_scr_remove_all_spatials(); } // namespace fallout