Fix runner bug of not reaching water surface

Also fix bound checking in runner
scene_man
En Yi 2023-07-21 21:19:38 +08:00
parent 6e2ccfa875
commit 89d962d2bc
1 changed files with 25 additions and 27 deletions

View File

@ -63,20 +63,17 @@ static void runner_BFS(const TileGrid_t* tilemap, CWaterRunner_t* p_crunner, int
unsigned int next = curr_idx + p_crunner->bfs_tilemap.width; unsigned int next = curr_idx + p_crunner->bfs_tilemap.width;
Tile_t* next_tile = tilemap->tiles + next; Tile_t* next_tile = tilemap->tiles + next;
if (next < p_crunner->bfs_tilemap.len)
{
if ( if (
curr_height > curr_low curr_height > curr_low
&& curr_tile->water_level < tilemap->max_water_level && curr_tile->water_level < tilemap->max_water_level
&& next_tile->water_level < tilemap->max_water_level
) )
{ {
*lowest_tile = curr_idx; *lowest_tile = curr_idx;
} }
if (next < p_crunner->bfs_tilemap.len)
{
to_go[0] = next_tile->solid != SOLID; to_go[0] = next_tile->solid != SOLID;
}
if ( if (
next_tile->solid == SOLID next_tile->solid == SOLID
@ -97,6 +94,7 @@ static void runner_BFS(const TileGrid_t* tilemap, CWaterRunner_t* p_crunner, int
to_go[2] = next_tile->solid != SOLID; to_go[2] = next_tile->solid != SOLID;
} }
} }
}
if (curr_tile->water_level == tilemap->max_water_level) if (curr_tile->water_level == tilemap->max_water_level)
{ {