Skip to content

Commit fc76668

Browse files
Decomped GetChebyshevDistance
Decomped by @SethBarberee
1 parent 33662d7 commit fc76668

File tree

8 files changed

+18
-30
lines changed

8 files changed

+18
-30
lines changed

asm/include/overlay_29_022E908C.inc

Lines changed: 0 additions & 2 deletions
This file was deleted.

asm/overlay_29_022E908C.s

Lines changed: 0 additions & 24 deletions
This file was deleted.

include/dungeon_range.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33

44
#include "dungeon_mode.h"
55

6+
// Checks if a given target position is in sight from a given origin position.
7+
// If the origin position is on a hallway or r2 is true, checks if both positions are within <dungeon::display_data::visibility_range> tiles of each other.
8+
// If the origin position is on a room, checks that the target position is within the boundaries of said room.
9+
// origin: Origin position
10+
// target: Target position
11+
// user_has_dropeye: True to assume the entity standing on the origin position has the dropeye status
12+
// return: True if the target position is in sight from the origin position
613
bool8 IsPositionActuallyInSight(struct position *origin, struct position *target, bool8 user_has_dropeye);
714

815
#endif //PMDSKY_DUNGEON_RANGE_H

include/position_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55

66
// Gets the direction in which a monster should move to go from the origin position to the target position
77
s32 GetDirectionTowardsPosition(struct position *origin, struct position *target);
8+
// Returns the Chebyshev distance between two positions. Calculated as max(abs(x0-x1), abs(y0-y1)).
9+
s32 GetChebyshevDistance(struct position *position_a, struct position *position_b);
810

911
#endif //PMDSKY_POSITION_UTIL_H

main.lsf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ Overlay OVY_29
374374
Object asm/overlay_29_022E37DC.o
375375
Object src/position_util.o
376376
Object asm/overlay_29_rodata_02351628.o
377-
Object asm/overlay_29_022E908C.o
378377
Object src/dungeon_range.o
379378
Object asm/overlay_29_022E91A4.o
380379
Object src/dg_uty.o

src/dungeon_ai_movement.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const s32 FACING_DIRECTION_INCREMENTS[] = {0, 1, -1, 2, -2, 3, -3, 4};
4747

4848
extern bool8 CanTargetEntity(struct entity *user, struct entity *target);
4949
extern bool8 CanTargetPosition(struct entity *monster, struct position *position);
50-
extern s32 GetChebyshevDistance(struct position *position_a, struct position *position_b);
5150
extern bool8 IsBagFull();
5251
extern bool8 ShouldMonsterFollowLeader(struct entity *monster);
5352
extern bool8 IsPositionWithinTwoTiles(struct position *origin, struct position *target);

src/overlay_29_022FA430.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#include "overlay_29_022F7364.h"
66
#include "overlay_29_023018AC.h"
77
#include "overlay_29_02336428.h"
8-
9-
extern s32 GetChebyshevDistance(struct position *position_a, struct position *position_b);
8+
#include "position_util.h"
109

1110
bool8 ShouldMonsterHeadToStairs(struct entity *entity)
1211
{

src/position_util.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "position_util.h"
2+
#include "main_0208655C.h"
23

34
const s32 POSITION_DISPLACEMENT_TO_DIRECTION[3][3] =
45
{
@@ -28,3 +29,10 @@ s32 GetDirectionTowardsPosition(struct position *origin, struct position *target
2829

2930
return POSITION_DISPLACEMENT_TO_DIRECTION[++y_diff][++x_diff];
3031
}
32+
33+
s32 GetChebyshevDistance(struct position *position_a, struct position *position_b)
34+
{
35+
s32 var1 = abs(position_a->x - position_b->x);
36+
s32 var0 = abs(position_a->y - position_b->y);
37+
return MAX(var1, var0);
38+
}

0 commit comments

Comments
 (0)