Skip to content

Commit

Permalink
Merge pull request #314 from DizzyEggg/sub_8070564
Browse files Browse the repository at this point in the history
fix nonmatching in sub_8070564
  • Loading branch information
SethBarberee authored Dec 28, 2024
2 parents 556a950 + 5e576d2 commit 6020a3d
Showing 1 changed file with 88 additions and 84 deletions.
172 changes: 88 additions & 84 deletions src/dungeon_movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,38 @@ u8 sub_80703A0(Entity *pokemon, DungeonPos *pos)
return TRUE;
if (pos->x >= DUNGEON_MAX_SIZE_X || pos->y >= DUNGEON_MAX_SIZE_Y)
return TRUE;
if (tile->monster == NULL && ((tile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL) == 0)) {
if ((IsCurrentFixedRoomBossFight()) || ((entityInfo->invisibleClassStatus.status != STATUS_MOBILE && (!HasHeldItem(pokemon, ITEM_MOBILE_SCARF))))) {
crossableTerrain = GetCrossableTerrain(entityInfo->id);
tileFlags = tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) {
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) {
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
switch(crossableTerrain)
{
case CROSSABLE_TERRAIN_LIQUID:
if(tileFlags == TERRAIN_TYPE_SECONDARY) return FALSE;
case CROSSABLE_TERRAIN_REGULAR:
if(tileFlags == TERRAIN_TYPE_NORMAL) return FALSE;
break;
case CROSSABLE_TERRAIN_WALL:
default:
return FALSE;
case CROSSABLE_TERRAIN_CREVICE:
if(tileFlags != 0) return FALSE;
}
if (tile->monster != NULL)
return TRUE;
if (tile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL)
return TRUE;

if ((IsCurrentFixedRoomBossFight()) || ((entityInfo->invisibleClassStatus.status != STATUS_MOBILE && (!HasHeldItem(pokemon, ITEM_MOBILE_SCARF))))) {
crossableTerrain = GetCrossableTerrain(entityInfo->id);
tileFlags = tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) {
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
else {
return FALSE;
if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) {
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
switch(crossableTerrain)
{
case CROSSABLE_TERRAIN_LIQUID:
if(tileFlags == TERRAIN_TYPE_SECONDARY) return FALSE;
case CROSSABLE_TERRAIN_REGULAR:
if(tileFlags == TERRAIN_TYPE_NORMAL) return FALSE;
break;
case CROSSABLE_TERRAIN_WALL:
default:
return FALSE;
case CROSSABLE_TERRAIN_CREVICE:
if(tileFlags != 0) return FALSE;
}
}
else {
return FALSE;
}

return TRUE;
}

Expand Down Expand Up @@ -141,78 +145,78 @@ bool8 sub_807049C(Entity *pokemon, DungeonPos *pos)
return TRUE;
if (pos->x >= DUNGEON_MAX_SIZE_X || pos->y >= DUNGEON_MAX_SIZE_Y)
return TRUE;
if (((tile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL) == 0) && (tile->monster == NULL || (GetEntityType(tile->monster) == ENTITY_MONSTER))) {
if (IsCurrentFixedRoomBossFight() || (entityInfo->invisibleClassStatus.status != STATUS_MOBILE && !HasHeldItem(pokemon, ITEM_MOBILE_SCARF))) {
crossableTerrain = GetCrossableTerrain(entityInfo->id);
tileFlags = tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) {
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) {
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
switch(crossableTerrain)
{
case CROSSABLE_TERRAIN_LIQUID:
if(tileFlags == TERRAIN_TYPE_SECONDARY) return FALSE;
case CROSSABLE_TERRAIN_REGULAR:
if(tileFlags == TERRAIN_TYPE_NORMAL) return FALSE;
break;
case CROSSABLE_TERRAIN_WALL:
default:
return FALSE;
case CROSSABLE_TERRAIN_CREVICE:
if(tileFlags != 0) return FALSE;
}
if (tile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL)
return TRUE;
if (tile->monster != NULL && GetEntityType(tile->monster) != ENTITY_MONSTER)
return TRUE;

if (IsCurrentFixedRoomBossFight() || (entityInfo->invisibleClassStatus.status != STATUS_MOBILE && !HasHeldItem(pokemon, ITEM_MOBILE_SCARF))) {
crossableTerrain = GetCrossableTerrain(entityInfo->id);
tileFlags = tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) {
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
else return FALSE;
if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) {
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
switch(crossableTerrain)
{
case CROSSABLE_TERRAIN_LIQUID:
if(tileFlags == TERRAIN_TYPE_SECONDARY) return FALSE;
case CROSSABLE_TERRAIN_REGULAR:
if(tileFlags == TERRAIN_TYPE_NORMAL) return FALSE;
break;
case CROSSABLE_TERRAIN_WALL:
default:
return FALSE;
case CROSSABLE_TERRAIN_CREVICE:
if(tileFlags != 0) return FALSE;
}
}
else {
return FALSE;
}

return TRUE;
}

bool8 sub_8070564(Entity *pokemon, DungeonPos *pos)
{
u8 crossableTerrain;
const Tile *tile;
u16 tileFlags;
EntityInfo *entityInfo;
#ifndef NONMATCHING
register s32 tileFlags_0 asm("r0");
register s32 crossableTerrain2 asm("r3");
#else
s32 tileFlags_0;
s32 crossableTerrain2;
#endif
u16 crossableTerrain;
u32 tileFlags;

EntityInfo *entityInfo = GetEntInfo(pokemon);
const Tile *tile = GetTile(pos->x,pos->y);

entityInfo = GetEntInfo(pokemon);
tile = GetTile(pos->x,pos->y);
if (pos->x < 0 || pos->y < 0)
return TRUE;
if (pos->x >= DUNGEON_MAX_SIZE_X || pos->y >= DUNGEON_MAX_SIZE_Y)
return TRUE;
if ((((tile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL) == 0)) && (tile->monster == NULL || (GetEntityType(tile->monster) == ENTITY_MONSTER))) {
crossableTerrain2 = crossableTerrain = GetCrossableTerrain(entityInfo->id);
tileFlags_0 = tileFlags = tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY);
switch(crossableTerrain)
{
case CROSSABLE_TERRAIN_WALL: // 3
case CROSSABLE_TERRAIN_CREVICE: // 2
case 4 ... INT_MAX:
if (crossableTerrain2 > CROSSABLE_TERRAIN_WALL) return FALSE;
if(tileFlags != 0)
return FALSE;
break;
case CROSSABLE_TERRAIN_REGULAR: // 0
if(tileFlags == TERRAIN_TYPE_NORMAL)
default:
return FALSE;
break;
case CROSSABLE_TERRAIN_LIQUID: // 1
if(tileFlags == TERRAIN_TYPE_SECONDARY) return FALSE;
if (tileFlags_0 == TERRAIN_TYPE_NORMAL) return FALSE;
return TRUE;
}
if (tile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL)
return TRUE;
if (tile->monster != NULL && GetEntityType(tile->monster) != ENTITY_MONSTER)
return TRUE;

crossableTerrain = GetCrossableTerrain(entityInfo->id);
tileFlags = GetTerrainType(tile);

switch (crossableTerrain)
{
default:
return FALSE;
case CROSSABLE_TERRAIN_WALL:
case CROSSABLE_TERRAIN_CREVICE:
if (tileFlags != TERRAIN_TYPE_WALL) return FALSE;
break;
case CROSSABLE_TERRAIN_REGULAR:
if (tileFlags == TERRAIN_TYPE_NORMAL) return FALSE;
break;
case CROSSABLE_TERRAIN_LIQUID:
if (tileFlags == TERRAIN_TYPE_SECONDARY) return FALSE;
if (tileFlags == TERRAIN_TYPE_NORMAL) return FALSE;
break;
}

return TRUE;
}

Expand Down

0 comments on commit 6020a3d

Please sign in to comment.