Skip to content

Commit

Permalink
Add map_scr_remove_spatial
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbatalov committed Jul 25, 2023
1 parent 8329d2f commit cba1fc8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/mapper/mp_scrpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions src/mapper/mp_scrpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace fallout {

int map_scr_remove_spatial(int tile, int elevation);
int map_scr_remove_all_spatials();

} // namespace fallout
Expand Down

0 comments on commit cba1fc8

Please sign in to comment.