Add map_scr_remove_all_spatials

This commit is contained in:
Alexander Batalov 2023-07-25 11:14:41 +03:00
parent 1de7ef0151
commit 8329d2fcf6
2 changed files with 65 additions and 0 deletions

55
src/mapper/mp_scrpt.cc Normal file
View File

@ -0,0 +1,55 @@
#include "mapper/mp_scrpt.h"
#include "art.h"
#include "object.h"
#include "scripts.h"
#include "tile.h"
namespace fallout {
// 0x49B214
int map_scr_remove_all_spatials()
{
int elevation;
Script* scr;
Object* obj;
int sid;
for (elevation = 0; elevation < ELEVATION_COUNT; elevation++) {
scr = scriptGetFirstSpatialScript(elevation);
while (scr != NULL) {
scriptRemove(scr->sid);
scr = scriptGetFirstSpatialScript(elevation);
}
obj = objectFindFirstAtElevation(elevation);
while (obj != NULL) {
if (buildFid(OBJ_TYPE_INTERFACE, 3, 0, 0, 0) == obj->fid) {
objectDestroy(obj, NULL);
obj = objectFindFirstAtElevation(elevation);
continue;
}
obj = objectFindNextAtElevation();
}
}
tileWindowRefresh();
for (sid = 0; sid < 15000; sid++) {
if (scriptGetScript(sid, &scr) != -1) {
if (scr->owner != NULL) {
if (scr->owner->pid == 0x500000C) {
scr->owner->sid = -1;
scriptRemove(sid);
}
}
}
}
return 0;
}
} // namespace fallout

10
src/mapper/mp_scrpt.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef FALLOUT_MAPPER_MP_SCRPTR_H_
#define FALLOUT_MAPPER_MP_SCRPTR_H_
namespace fallout {
int map_scr_remove_all_spatials();
} // namespace fallout
#endif /* FALLOUT_MAPPER_MP_SCRPTR_H_ */