Document board/com files
Also did various cleanups
This commit is contained in:
parent
6f46d026ca
commit
83000dbb16
13 changed files with 645 additions and 673 deletions
|
|
@ -5,20 +5,19 @@
|
|||
|
||||
typedef struct {
|
||||
/* 0x00 */ struct {
|
||||
u8 unk00_field0 : 1;
|
||||
u8 unk00_field1 : 1;
|
||||
s8 unk00_field2 : 1;
|
||||
s8 unk00_field3 : 1;
|
||||
u8 unk00_field4 : 1;
|
||||
u8 unk00_field5 : 1;
|
||||
u8 used : 1;
|
||||
u8 star : 1;
|
||||
u8 pipe : 1;
|
||||
u8 shop : 1;
|
||||
u8 boo : 1;
|
||||
u8 lottery : 1;
|
||||
};
|
||||
/* 0x01 */ s8 unk01;
|
||||
/* 0x02 */ s8 unk02;
|
||||
/* 0x03 */ s8 unk03;
|
||||
/* 0x04 */ s16 unk04;
|
||||
/* 0x06 */ s16 unk06[2]; // array size unknown
|
||||
/* 0x0A */ char unk0A[0x3C];
|
||||
/* 0x46 */ s16 unk46[5];
|
||||
/* 0x01 */ s8 num_links;
|
||||
/* 0x02 */ s8 num_children;
|
||||
/* 0x03 */ s8 max_len;
|
||||
/* 0x04 */ s16 start;
|
||||
/* 0x06 */ s16 children[32];
|
||||
/* 0x46 */ s16 links[BOARD_SPACE_LINKMAX+1];
|
||||
} PathNode; // Size 0x50
|
||||
|
||||
static PathNode *SearchPathNodeSpace(s16 arg0);
|
||||
|
|
@ -30,7 +29,7 @@ static BOOL CheckPathSpace(BoardSpace *arg0);
|
|||
static s16 FindValidLink(BoardSpace *arg0);
|
||||
static BOOL CheckEndSpace(BoardSpace *arg0, PathNode *arg1);
|
||||
static BOOL CheckPath(PathNode *arg0);
|
||||
static BOOL CheckW20Path(PathNode *arg0, u32 arg1);
|
||||
static BOOL CheckPathFlag(PathNode *arg0, u32 arg1);
|
||||
|
||||
static PathNode pathNodeData[16];
|
||||
static PathNode *candidateNodes[16];
|
||||
|
|
@ -40,89 +39,89 @@ static s16 startPathSpace[16];
|
|||
static s16 numCandidates;
|
||||
static s16 childNodeCnt;
|
||||
|
||||
static PathNode *SearchPathNodeSpace(s16 arg0) {
|
||||
PathNode *var_r31;
|
||||
static PathNode *SearchPathNodeSpace(s16 space) {
|
||||
PathNode *node;
|
||||
s32 i;
|
||||
|
||||
for (var_r31 = pathNodeData, i = 0; i < 16; i++, var_r31++) {
|
||||
if (var_r31->unk04 == arg0) {
|
||||
for (node = pathNodeData, i = 0; i < 16; i++, node++) {
|
||||
if (node->start == space) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 16) {
|
||||
var_r31 = NULL;
|
||||
node = NULL;
|
||||
}
|
||||
return var_r31;
|
||||
return node;
|
||||
}
|
||||
|
||||
static s16 InitPathNode(PathNode *arg0) {
|
||||
BoardSpace *temp_r30;
|
||||
PathNode *var_r23;
|
||||
s32 var_r29;
|
||||
static s16 InitPathNode(PathNode *node) {
|
||||
BoardSpace *space_ptr;
|
||||
PathNode *child;
|
||||
s32 done;
|
||||
s16 i;
|
||||
s16 var_r27;
|
||||
s16 var_r26;
|
||||
s16 var_r25;
|
||||
s16 var_r24;
|
||||
s16 space;
|
||||
s16 num_links;
|
||||
s16 path_len;
|
||||
s16 space_link;
|
||||
|
||||
var_r24 = arg0->unk04;
|
||||
var_r29 = 0;
|
||||
arg0->unk02 = var_r25 = 0;
|
||||
space_link = node->start;
|
||||
done = 0;
|
||||
node->num_children = path_len = 0;
|
||||
do {
|
||||
var_r27 = var_r24;
|
||||
temp_r30 = BoardSpaceGet(0, var_r27);
|
||||
arg0->unk06[arg0->unk02] = var_r27;
|
||||
var_r23 = FindChildNode(var_r27, arg0);
|
||||
if (var_r23) {
|
||||
AddValidLinks(temp_r30, arg0);
|
||||
arg0->unk01 = 1;
|
||||
arg0->unk46[0] = var_r27;
|
||||
space = space_link;
|
||||
space_ptr = BoardSpaceGet(0, space);
|
||||
node->children[node->num_children] = space;
|
||||
child = FindChildNode(space, node);
|
||||
if (child) {
|
||||
AddValidLinks(space_ptr, node);
|
||||
node->num_links = 1;
|
||||
node->links[0] = space;
|
||||
for (i = 1; i < 5; i++) {
|
||||
arg0->unk46[i] = 0;
|
||||
node->links[i] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (temp_r30->link_cnt == 0) {
|
||||
var_r26 = 0;
|
||||
var_r29 = 1;
|
||||
if (space_ptr->link_cnt == 0) {
|
||||
num_links = 0;
|
||||
done = 1;
|
||||
} else {
|
||||
var_r26 = GetNumValidLinks(temp_r30, arg0);
|
||||
if (var_r26 == 1) {
|
||||
var_r24 = FindValidLink(temp_r30);
|
||||
num_links = GetNumValidLinks(space_ptr, node);
|
||||
if (num_links == 1) {
|
||||
space_link = FindValidLink(space_ptr);
|
||||
} else {
|
||||
var_r29 = 1;
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
if (CheckEndSpace(temp_r30, arg0)) {
|
||||
var_r25++;
|
||||
if (var_r25 >= arg0->unk03) {
|
||||
var_r26 = 0;
|
||||
var_r29 = 1;
|
||||
if (CheckEndSpace(space_ptr, node)) {
|
||||
path_len++;
|
||||
if (path_len >= node->max_len) {
|
||||
num_links = 0;
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
arg0->unk02++;
|
||||
} while (var_r29 == 0);
|
||||
AddValidLinks(temp_r30, arg0);
|
||||
arg0->unk01 = var_r26;
|
||||
return arg0->unk03 - var_r25;
|
||||
node->num_children++;
|
||||
} while (done == 0);
|
||||
AddValidLinks(space_ptr, node);
|
||||
node->num_links = num_links;
|
||||
return node->max_len - path_len;
|
||||
}
|
||||
|
||||
static PathNode *FindChildNode(s16 arg0, PathNode *arg1) {
|
||||
PathNode *temp_r31;
|
||||
s32 var_r28;
|
||||
PathNode *node;
|
||||
s32 node_idx;
|
||||
s32 i;
|
||||
s32 j;
|
||||
|
||||
var_r28 = NODE_INDEX(arg1);
|
||||
if (var_r28 == -1) {
|
||||
node_idx = NODE_INDEX(arg1);
|
||||
if (node_idx == -1) {
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < childNodeCnt; i++) {
|
||||
temp_r31 = &pathNodeData[i];
|
||||
if (temp_r31 != arg1) {
|
||||
for (j = 0; j < temp_r31->unk02; j++) {
|
||||
if (arg0 == temp_r31->unk06[j]) {
|
||||
return temp_r31;
|
||||
node = &pathNodeData[i];
|
||||
if (node != arg1) {
|
||||
for (j = 0; j < node->num_children; j++) {
|
||||
if (arg0 == node->children[j]) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -130,85 +129,85 @@ static PathNode *FindChildNode(s16 arg0, PathNode *arg1) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static s32 GetNumValidLinks(BoardSpace *arg0, PathNode *arg1) {
|
||||
BoardSpace *var_r28;
|
||||
static s32 GetNumValidLinks(BoardSpace *space, PathNode *node) {
|
||||
BoardSpace *link_space;
|
||||
s16 i;
|
||||
s16 var_r29;
|
||||
s16 invalid_links;
|
||||
|
||||
for (var_r29 = i = 0; i < arg0->link_cnt; i++) {
|
||||
var_r28 = BoardSpaceGet(0, arg0->link[i]);
|
||||
if (!CheckPathSpace(var_r28)) {
|
||||
var_r29++;
|
||||
for (invalid_links = i = 0; i < space->link_cnt; i++) {
|
||||
link_space = BoardSpaceGet(0, space->link[i]);
|
||||
if (!CheckPathSpace(link_space)) {
|
||||
invalid_links++;
|
||||
}
|
||||
}
|
||||
if (var_r29 >= arg0->link_cnt) {
|
||||
if (invalid_links >= space->link_cnt) {
|
||||
return 0;
|
||||
}
|
||||
return arg0->link_cnt - var_r29;
|
||||
return space->link_cnt - invalid_links;
|
||||
}
|
||||
|
||||
static void AddValidLinks(BoardSpace *arg0, PathNode *arg1) {
|
||||
BoardSpace *var_r27;
|
||||
s16 var_r30;
|
||||
s16 var_r31;
|
||||
static void AddValidLinks(BoardSpace *space, PathNode *node) {
|
||||
BoardSpace *link_space;
|
||||
s16 i;
|
||||
s16 link;
|
||||
|
||||
for (var_r31 = var_r30 = 0; var_r30 < arg0->link_cnt; var_r30++) {
|
||||
var_r27 = BoardSpaceGet(0, arg0->link[var_r30]);
|
||||
if (CheckPathSpace(var_r27)) {
|
||||
arg1->unk46[var_r31] = arg0->link[var_r30];
|
||||
var_r31++;
|
||||
for (link = i = 0; i < space->link_cnt; i++) {
|
||||
link_space = BoardSpaceGet(0, space->link[i]);
|
||||
if (CheckPathSpace(link_space)) {
|
||||
node->links[link] = space->link[i];
|
||||
link++;
|
||||
}
|
||||
}
|
||||
for (; var_r31 < 5; var_r31++) {
|
||||
arg1->unk46[var_r31] = 0;
|
||||
for (; link < BOARD_SPACE_LINKMAX+1; link++) {
|
||||
node->links[link] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL CheckPathSpace(BoardSpace *arg0) {
|
||||
if ((arg0->flag & 0x02000000) || (arg0->flag & 0x04000000)) {
|
||||
static BOOL CheckPathSpace(BoardSpace *space) {
|
||||
if ((space->flag & 0x02000000) || (space->flag & 0x04000000)) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static s16 FindValidLink(BoardSpace *arg0) {
|
||||
s16 var_r29;
|
||||
static s16 FindValidLink(BoardSpace *space) {
|
||||
s16 space_link;
|
||||
s16 i;
|
||||
BoardSpace *temp_r30;
|
||||
BoardSpace *space_ptr;
|
||||
|
||||
for (var_r29 = i = 0; i < arg0->link_cnt; i++) {
|
||||
var_r29 = arg0->link[i];
|
||||
temp_r30 = BoardSpaceGet(0, var_r29);
|
||||
if (CheckPathSpace(temp_r30)) {
|
||||
for (space_link = i = 0; i < space->link_cnt; i++) {
|
||||
space_link = space->link[i];
|
||||
space_ptr = BoardSpaceGet(0, space_link);
|
||||
if (CheckPathSpace(space_ptr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return var_r29;
|
||||
return space_link;
|
||||
}
|
||||
|
||||
static BOOL CheckEndSpace(BoardSpace *arg0, PathNode *arg1) {
|
||||
if (arg0->flag & 0x80000000) {
|
||||
static BOOL CheckEndSpace(BoardSpace *space, PathNode *node) {
|
||||
if (space->flag & 0x80000000) {
|
||||
}
|
||||
if (arg0->flag & 0x4000000) {
|
||||
if (space->flag & 0x4000000) {
|
||||
}
|
||||
if (arg0->flag & 0x2000000) {
|
||||
if (space->flag & 0x2000000) {
|
||||
}
|
||||
if (arg0->flag & 0x180000) {
|
||||
arg1->unk00_field3 = 1;
|
||||
if (space->flag & 0x180000) {
|
||||
node->shop = 1;
|
||||
}
|
||||
if (arg0->flag & 0x48000000) {
|
||||
arg1->unk00_field4 = 1;
|
||||
if (space->flag & 0x48000000) {
|
||||
node->boo = 1;
|
||||
}
|
||||
if (arg0->flag & 0x20000000) {
|
||||
arg1->unk00_field2 = 1;
|
||||
if (space->flag & 0x20000000) {
|
||||
node->pipe = 1;
|
||||
}
|
||||
if (arg0->flag & 0x10000000) {
|
||||
arg1->unk00_field5 = 1;
|
||||
if (space->flag & 0x10000000) {
|
||||
node->lottery = 1;
|
||||
}
|
||||
switch (arg0->type) {
|
||||
switch (space->type) {
|
||||
case 8:
|
||||
arg1->unk00_field1 = 1;
|
||||
node->star = 1;
|
||||
return FALSE;
|
||||
case 10:
|
||||
return FALSE;
|
||||
|
|
@ -218,151 +217,151 @@ static BOOL CheckEndSpace(BoardSpace *arg0, PathNode *arg1) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static inline void ComPathInlineFunc02(PathNode *arg0) {
|
||||
static inline void PushCandidate(PathNode *node) {
|
||||
if (numCandidates < 16) {
|
||||
candidateNodes[numCandidates] = arg0;
|
||||
candidateNodes[numCandidates] = node;
|
||||
numCandidates++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline PathNode *ComPathInlineFunc03(void) {
|
||||
PathNode *ret;
|
||||
static inline PathNode *PopCandidate(void) {
|
||||
PathNode *node;
|
||||
|
||||
numCandidates--;
|
||||
if (numCandidates < 0) {
|
||||
return NULL;
|
||||
} else {
|
||||
ret = candidateNodes[numCandidates];
|
||||
node = candidateNodes[numCandidates];
|
||||
candidateNodes[numCandidates] = NULL;
|
||||
return ret;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
static inline PathNode *ComPathInlineFunc04(s16 arg0, s16 arg1) {
|
||||
PathNode *var_r26;
|
||||
static inline PathNode *CreateNode(s16 start, s16 len) {
|
||||
PathNode *node;
|
||||
s32 i;
|
||||
|
||||
var_r26 = pathNodeData;
|
||||
for (i = 0; i < 16; i++, var_r26++) {
|
||||
if (var_r26->unk00_field0 == 0) {
|
||||
node = pathNodeData;
|
||||
for (i = 0; i < 16; i++, node++) {
|
||||
if (node->used == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 16) {
|
||||
return NULL;
|
||||
} else {
|
||||
var_r26->unk00_field0 = 1;
|
||||
var_r26->unk04 = arg0;
|
||||
var_r26->unk03 = arg1;
|
||||
node->used = 1;
|
||||
node->start = start;
|
||||
node->max_len = len;
|
||||
childNodeCnt++;
|
||||
return var_r26;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void ComPathInlineFunc05(s16 arg0, s16 arg1) {
|
||||
PathNode *var_r28;
|
||||
s32 var_r24;
|
||||
s32 temp_r17;
|
||||
static inline void PopulateCandidates(s16 start, s16 len) {
|
||||
PathNode *node;
|
||||
s32 num_paths;
|
||||
s32 lookahead;
|
||||
s32 i;
|
||||
PathNode *var_r23;
|
||||
PathNode *new_node;
|
||||
|
||||
memset(pathNodeData, 0, sizeof(pathNodeData));
|
||||
memset(candidateNodes, 0, sizeof(candidateNodes));
|
||||
numCandidates = 0;
|
||||
childNodeCnt = 0;
|
||||
var_r23 = ComPathInlineFunc04(arg0, arg1);
|
||||
ComPathInlineFunc02(var_r23);
|
||||
var_r24 = 1;
|
||||
temp_r17 = arg1;
|
||||
new_node = CreateNode(start, len);
|
||||
PushCandidate(new_node);
|
||||
num_paths = 1;
|
||||
lookahead = len;
|
||||
while (1) {
|
||||
if (var_r24 <= 0) {
|
||||
if (num_paths <= 0) {
|
||||
break;
|
||||
}
|
||||
var_r28 = ComPathInlineFunc03();
|
||||
if (!var_r28) {
|
||||
node = PopCandidate();
|
||||
if (!node) {
|
||||
break;
|
||||
}
|
||||
var_r24--;
|
||||
temp_r17 = InitPathNode(var_r28);
|
||||
if (temp_r17 != 0) {
|
||||
if (var_r28->unk01 <= 1) {
|
||||
num_paths--;
|
||||
lookahead = InitPathNode(node);
|
||||
if (lookahead != 0) {
|
||||
if (node->num_links <= 1) {
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < var_r28->unk01; var_r24++, i++) {
|
||||
var_r23 = ComPathInlineFunc04(var_r28->unk46[i], temp_r17);
|
||||
if (!var_r23) {
|
||||
for (i = 0; i < node->num_links; num_paths++, i++) {
|
||||
new_node = CreateNode(node->links[i], lookahead);
|
||||
if (!new_node) {
|
||||
break;
|
||||
}
|
||||
ComPathInlineFunc02(var_r23);
|
||||
PushCandidate(new_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s16 BoardComPathReachCheck(s16 arg0, u32 arg1, s32 arg2) {
|
||||
s16 sp80[10];
|
||||
s16 sp6C[10];
|
||||
PathNode *sp68;
|
||||
PathNode *var_r29;
|
||||
s16 sp1C;
|
||||
s16 sp1A;
|
||||
s16 temp_r20;
|
||||
s16 var_r22;
|
||||
s16 var_r28;
|
||||
s16 BoardComPathShortcutLenGet(s16 space, u32 type, s32 block_pipe) {
|
||||
s16 len_tbl[10];
|
||||
s16 node_tbl[10];
|
||||
PathNode *node_link;
|
||||
PathNode *node;
|
||||
s16 node_idx;
|
||||
s16 node_start_idx;
|
||||
s16 node_idx_link;
|
||||
s16 num_nodes;
|
||||
s16 len;
|
||||
s16 i;
|
||||
s32 var_r19;
|
||||
s32 search_child;
|
||||
|
||||
if (_CheckFlag(0x1000B)) {
|
||||
return 0;
|
||||
}
|
||||
ComPathInlineFunc05(arg0, 0x1E);
|
||||
PopulateCandidates(space, 30);
|
||||
memset(startPathSpaceSearch, 0, sizeof(startPathSpaceSearch));
|
||||
memset(sp80, 0, sizeof(sp80));
|
||||
memset(len_tbl, 0, sizeof(len_tbl));
|
||||
memset(candidateNodes, 0, sizeof(candidateNodes));
|
||||
numCandidates = 0;
|
||||
var_r29 = SearchPathNodeSpace(arg0);
|
||||
sp1A = NODE_INDEX(var_r29);
|
||||
ComPathInlineFunc02(var_r29);
|
||||
var_r28 = 0;
|
||||
var_r22 = 0;
|
||||
startPathSpaceSearch[sp1A] = var_r28;
|
||||
var_r19 = 0;
|
||||
node = SearchPathNodeSpace(space);
|
||||
node_start_idx = NODE_INDEX(node);
|
||||
PushCandidate(node);
|
||||
len = 0;
|
||||
num_nodes = 0;
|
||||
startPathSpaceSearch[node_start_idx] = len;
|
||||
search_child = 0;
|
||||
while (1) {
|
||||
var_r29 = ComPathInlineFunc03();
|
||||
sp1C = NODE_INDEX(var_r29);
|
||||
if (sp1C == -1) {
|
||||
if (var_r22 != 0) {
|
||||
node = PopCandidate();
|
||||
node_idx = NODE_INDEX(node);
|
||||
if (node_idx == -1) {
|
||||
if (num_nodes != 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
var_r19 = 0;
|
||||
var_r28 = startPathSpaceSearch[sp1C];
|
||||
for (i = 0; i < var_r29->unk02; i++) {
|
||||
if (arg2 == 0 && (BoardSpaceFlagGet(0, var_r29->unk06[i]) & 0x20000000)) {
|
||||
search_child = 0;
|
||||
len = startPathSpaceSearch[node_idx];
|
||||
for (i = 0; i < node->num_children; i++) {
|
||||
if (block_pipe == 0 && (BoardSpaceFlagGet(0, node->children[i]) & 0x20000000)) {
|
||||
break;
|
||||
}
|
||||
if (arg1 == BoardSpaceTypeGet(0, var_r29->unk06[i])) {
|
||||
sp80[var_r22] = var_r28;
|
||||
sp6C[var_r22] = sp1C;
|
||||
if (++var_r22 < 0xA) {
|
||||
var_r19 = 1;
|
||||
if (type == BoardSpaceTypeGet(0, node->children[i])) {
|
||||
len_tbl[num_nodes] = len;
|
||||
node_tbl[num_nodes] = node_idx;
|
||||
if (++num_nodes < 10) {
|
||||
search_child = 1;
|
||||
break;
|
||||
} else {
|
||||
goto return_r28;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if (var_r28++ >= 0x1E) {
|
||||
var_r19 = 1;
|
||||
if (len++ >= 30) {
|
||||
search_child = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (var_r19 == 0) {
|
||||
for (i = 0; i < var_r29->unk01; i++) {
|
||||
sp68 = SearchPathNodeSpace(var_r29->unk46[i]);
|
||||
temp_r20 = NODE_INDEX(sp68);
|
||||
if (temp_r20 != -1 && temp_r20 >= 0 && temp_r20 < 16) {
|
||||
startPathSpaceSearch[temp_r20] = var_r28;
|
||||
ComPathInlineFunc02(sp68);
|
||||
if (search_child == 0) {
|
||||
for (i = 0; i < node->num_links; i++) {
|
||||
node_link = SearchPathNodeSpace(node->links[i]);
|
||||
node_idx_link = NODE_INDEX(node_link);
|
||||
if (node_idx_link != -1 && node_idx_link >= 0 && node_idx_link < 16) {
|
||||
startPathSpaceSearch[node_idx_link] = len;
|
||||
PushCandidate(node_link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -370,89 +369,89 @@ s16 BoardComPathReachCheck(s16 arg0, u32 arg1, s32 arg2) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
return_r28:
|
||||
var_r28 = 10000;
|
||||
done:
|
||||
len = 10000;
|
||||
for (i = 0; i < 10; i++) {
|
||||
if (var_r28 > sp80[i] && sp80[i] != 0) {
|
||||
var_r28 = sp80[i];
|
||||
if (len > len_tbl[i] && len_tbl[i] != 0) {
|
||||
len = len_tbl[i];
|
||||
}
|
||||
}
|
||||
return var_r28;
|
||||
return len;
|
||||
}
|
||||
|
||||
s16 BoardComPathBestGet(s16 arg0) {
|
||||
PathNode *sp30;
|
||||
PathNode *sp2C;
|
||||
s16 BoardComPathBestGet(s16 space) {
|
||||
PathNode *link_node;
|
||||
PathNode *node;
|
||||
s32 i;
|
||||
|
||||
ComPathInlineFunc05(arg0, 0x1E);
|
||||
sp2C = SearchPathNodeSpace(arg0);
|
||||
if (sp2C->unk00_field1 != 0) {
|
||||
PopulateCandidates(space, 30);
|
||||
node = SearchPathNodeSpace(space);
|
||||
if (node->star != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (sp2C->unk01 <= 1) {
|
||||
if (node->num_links <= 1) {
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < sp2C->unk01; i++) {
|
||||
sp30 = SearchPathNodeSpace(sp2C->unk46[i]);
|
||||
if (sp30 && CheckPath(sp30)) {
|
||||
return sp2C->unk46[i];
|
||||
for (i = 0; i < node->num_links; i++) {
|
||||
link_node = SearchPathNodeSpace(node->links[i]);
|
||||
if (link_node && CheckPath(link_node)) {
|
||||
return node->links[i];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
s16 BoardComPathLenGet(s16 arg0, s16 arg1) {
|
||||
PathNode *var_r30;
|
||||
s16 temp_r21;
|
||||
s16 var_r25;
|
||||
s16 BoardComPathLenGet(s16 space, s16 space_other) {
|
||||
PathNode *node;
|
||||
s16 link_node_idx;
|
||||
s16 len;
|
||||
s16 sp16;
|
||||
s16 sp14;
|
||||
s16 sp12;
|
||||
s16 node_idx;
|
||||
s16 node_start_idx;
|
||||
s16 i;
|
||||
s32 sp5C;
|
||||
PathNode *sp58;
|
||||
s32 search_child;
|
||||
PathNode *link_node;
|
||||
|
||||
ComPathInlineFunc05(arg0, 0x1E);
|
||||
PopulateCandidates(space, 30);
|
||||
memset(startPathSpace, 0, sizeof(startPathSpace));
|
||||
memset(candidateNodes, 0, sizeof(candidateNodes));
|
||||
numCandidates = 0;
|
||||
var_r30 = SearchPathNodeSpace(arg0);
|
||||
sp12 = NODE_INDEX(var_r30);
|
||||
ComPathInlineFunc02(var_r30);
|
||||
var_r25 = 0;
|
||||
node = SearchPathNodeSpace(space);
|
||||
node_start_idx = NODE_INDEX(node);
|
||||
PushCandidate(node);
|
||||
len = 0;
|
||||
sp16 = 0;
|
||||
startPathSpace[sp12] = var_r25;
|
||||
sp5C = 0;
|
||||
startPathSpace[node_start_idx] = len;
|
||||
search_child = 0;
|
||||
while (1) {
|
||||
var_r30 = ComPathInlineFunc03();
|
||||
sp14 = NODE_INDEX(var_r30);
|
||||
if (sp14 == -1) {
|
||||
node = PopCandidate();
|
||||
node_idx = NODE_INDEX(node);
|
||||
if (node_idx == -1) {
|
||||
if (sp16 != 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sp5C = 0;
|
||||
var_r25 = startPathSpace[sp14];
|
||||
for (i = 0; i < var_r30->unk02; i++) {
|
||||
if (BoardSpaceFlagGet(0, var_r30->unk06[i]) & 0x20000000) {
|
||||
search_child = 0;
|
||||
len = startPathSpace[node_idx];
|
||||
for (i = 0; i < node->num_children; i++) {
|
||||
if (BoardSpaceFlagGet(0, node->children[i]) & 0x20000000) {
|
||||
break;
|
||||
}
|
||||
if (var_r30->unk06[i] == arg1) {
|
||||
goto return_r25;
|
||||
if (node->children[i] == space_other) {
|
||||
goto done;
|
||||
}
|
||||
if (var_r25++ >= 0x1E) {
|
||||
sp5C = 1;
|
||||
if (len++ >= 30) {
|
||||
search_child = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sp5C == 0) {
|
||||
for (i = 0; i < var_r30->unk01; i++) {
|
||||
sp58 = SearchPathNodeSpace(var_r30->unk46[i]);
|
||||
temp_r21 = NODE_INDEX(sp58);
|
||||
if (temp_r21 != -1 && temp_r21 >= 0 && temp_r21 < 16) {
|
||||
startPathSpace[temp_r21] = var_r25;
|
||||
ComPathInlineFunc02(sp58);
|
||||
if (search_child == 0) {
|
||||
for (i = 0; i < node->num_links; i++) {
|
||||
link_node = SearchPathNodeSpace(node->links[i]);
|
||||
link_node_idx = NODE_INDEX(link_node);
|
||||
if (link_node_idx != -1 && link_node_idx >= 0 && link_node_idx < 16) {
|
||||
startPathSpace[link_node_idx] = len;
|
||||
PushCandidate(link_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -460,84 +459,84 @@ s16 BoardComPathLenGet(s16 arg0, s16 arg1) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
return_r25:
|
||||
return var_r25;
|
||||
done:
|
||||
return len;
|
||||
}
|
||||
|
||||
static BOOL CheckPath(PathNode *arg0) {
|
||||
static BOOL CheckPath(PathNode *node) {
|
||||
s32 i;
|
||||
PathNode *sp1C;
|
||||
PathNode *link;
|
||||
|
||||
if (arg0->unk00_field1 != 0) {
|
||||
if (node->star != 0) {
|
||||
return TRUE;
|
||||
}
|
||||
if (arg0->unk01 <= 1) {
|
||||
if (node->num_links <= 1) {
|
||||
return FALSE;
|
||||
}
|
||||
for (i = 0; i < arg0->unk01; i++) {
|
||||
sp1C = SearchPathNodeSpace(arg0->unk46[i]);
|
||||
if (sp1C && CheckPath(sp1C)) {
|
||||
for (i = 0; i < node->num_links; i++) {
|
||||
link = SearchPathNodeSpace(node->links[i]);
|
||||
if (link && CheckPath(link)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s16 BoardComPathW20BestGet(s16 arg0, u32 arg1, s16 arg2) {
|
||||
PathNode *var_r31;
|
||||
PathNode *sp38;
|
||||
s16 BoardComPathBestGetFlag(s16 space, u32 flag, s16 len) {
|
||||
PathNode *node;
|
||||
PathNode *node_link;
|
||||
s32 i;
|
||||
|
||||
ComPathInlineFunc05(arg0, arg2);
|
||||
var_r31 = SearchPathNodeSpace(arg0);
|
||||
if (arg1 & 0x180000) {
|
||||
if (var_r31->unk00_field1 != 0) {
|
||||
PopulateCandidates(space, len);
|
||||
node = SearchPathNodeSpace(space);
|
||||
if (flag & 0x180000) {
|
||||
if (node->star != 0) {
|
||||
return -1;
|
||||
}
|
||||
} else if (arg1 & 0x08000000) {
|
||||
if (var_r31->unk00_field4 != 0) {
|
||||
} else if (flag & 0x08000000) {
|
||||
if (node->boo != 0) {
|
||||
return -1;
|
||||
}
|
||||
} else if (arg1 & 0x10000000) {
|
||||
if (var_r31->unk00_field5 != 0) {
|
||||
} else if (flag & 0x10000000) {
|
||||
if (node->lottery != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (var_r31->unk01 <= 1) {
|
||||
if (node->num_links <= 1) {
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < var_r31->unk01; i++) {
|
||||
sp38 = SearchPathNodeSpace(var_r31->unk46[i]);
|
||||
if (sp38 && CheckW20Path(sp38, arg1)) {
|
||||
return var_r31->unk46[i];
|
||||
for (i = 0; i < node->num_links; i++) {
|
||||
node_link = SearchPathNodeSpace(node->links[i]);
|
||||
if (node_link && CheckPathFlag(node_link, flag)) {
|
||||
return node->links[i];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static BOOL CheckW20Path(PathNode *arg0, u32 arg1) {
|
||||
static BOOL CheckPathFlag(PathNode *node, u32 flag) {
|
||||
s32 i;
|
||||
PathNode *sp1C;
|
||||
PathNode *link_node;
|
||||
|
||||
if (arg1 & 0x180000) {
|
||||
if (arg0->unk00_field1 != 0) {
|
||||
if (flag & 0x180000) {
|
||||
if (node->star != 0) {
|
||||
return TRUE;
|
||||
}
|
||||
} else if (arg1 & 0x08000000) {
|
||||
if (arg0->unk00_field4 != 0) {
|
||||
} else if (flag & 0x08000000) {
|
||||
if (node->boo != 0) {
|
||||
return TRUE;
|
||||
}
|
||||
} else if (arg1 & 0x10000000) {
|
||||
if (arg0->unk00_field5 != 0) {
|
||||
} else if (flag & 0x10000000) {
|
||||
if (node->lottery != 0) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (arg0->unk01 <= 1) {
|
||||
if (node->num_links <= 1) {
|
||||
return FALSE;
|
||||
}
|
||||
for (i = 0; i < arg0->unk01; i++) {
|
||||
sp1C = SearchPathNodeSpace(arg0->unk46[i]);
|
||||
if (sp1C && CheckW20Path(sp1C, arg1)) {
|
||||
for (i = 0; i < node->num_links; i++) {
|
||||
link_node = SearchPathNodeSpace(node->links[i]);
|
||||
if (link_node && CheckPathFlag(link_node, flag)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue