diff options
author | scnorton <scnorton@biociphers.org> | 2017-09-06 16:14:55 -0400 |
---|---|---|
committer | scnorton <scnorton@biociphers.org> | 2017-09-06 16:14:55 -0400 |
commit | 6448563ede13d51682cbf1988a2072291f3b3df0 (patch) | |
tree | 500d56e2727881bd3ff284955e8db2a99bc8e7d3 /src | |
parent | 9498dfa71c811b09f319bc9c9656c08f3182c9dc (diff) |
unref_sub_808D77C
Diffstat (limited to 'src')
-rw-r--r-- | src/field_map_obj.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b97d5c0dc..b33cf0669 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4,6 +4,9 @@ #include "sprite.h" #include "rom4.h" #include "field_player_avatar.h" +#include "event_data.h" +#include "rom_818CFC8.h" +#include "rom_81BE66C.h" #include "field_map_obj.h" // Static struct declarations @@ -352,3 +355,35 @@ __attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTempl ".pool"); } #endif + +u8 unref_sub_808D77C(u8 localId) +{ + u8 i; + u8 nObjects; + struct MapObjectTemplate *template; + + if (gMapHeader.events != NULL) + { + if (InBattlePyramid()) + { + nObjects = sub_81AAA40(); + } + else if (InTrainerHill()) + { + nObjects = 2; + } + else + { + nObjects = gMapHeader.events->mapObjectCount; + } + for (i = 0; i < nObjects; i ++) + { + template = &gSaveBlock1Ptr->mapObjectTemplates[i]; + if (template->localId == localId && !FlagGet(template->flagId)) + { + return InitFieldObjectStateFromTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + } + } + } + return ARRAY_COUNT(gMapObjects); +} |