forked from NotAShelf/rogged
fix: null check guard against target
This commit is contained in:
parent
62a4442844
commit
0cb0ca17ff
1 changed files with 4 additions and 2 deletions
|
|
@ -446,8 +446,10 @@ static int handle_movement_input(GameState *gs) {
|
|||
MoveResult result =
|
||||
try_move_entity(&gs->player.position, direction, &gs->map, &gs->player, gs->enemies, gs->enemy_count, true);
|
||||
if (result == MOVE_RESULT_MOVED) {
|
||||
player_on_move(&gs->player);
|
||||
action = 1;
|
||||
if (target != NULL) {
|
||||
player_on_move(&gs->player);
|
||||
action = 1;
|
||||
}
|
||||
} else if (result == MOVE_RESULT_BLOCKED_ENEMY) {
|
||||
target = player_find_enemy_at(gs->enemies, gs->enemy_count, new_x, new_y);
|
||||
player_attack(&gs->player, target);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue