summaryrefslogtreecommitdiff
path: root/src/heal_location.c
blob: da2e466a9c11b7cd6113bf2c56d5f885aa0bd175 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "global.h"

#define NUM_HEAL_LOCATIONS 22

struct HealLocation
{
    s8 group;
    s8 map;
    u16 x;
    u16 y;
};

extern const struct HealLocation gHealLocations[];

u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum)
{
    u32 i;
    
    for (i = 0; i < NUM_HEAL_LOCATIONS; i++)
    {
        if(gHealLocations[i].group == mapGroup && gHealLocations[i].map == mapNum)
            return i + 1;
    }
    return 0;
}

const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum)
{
    u32 index = GetHealLocationIndexByMap(mapGroup, mapNum);
    
    if (index == 0)
        return NULL;
    else
        return &gHealLocations[index - 1];
}

const struct HealLocation *GetHealLocation(u32 index)
{
    if (index == 0)
        return NULL;
    else if (index > NUM_HEAL_LOCATIONS)
        return NULL;
    else
        return &gHealLocations[index - 1];
}