From 35e1d498f9da61b628a861fbf5a46b49a384a208 Mon Sep 17 00:00:00 2001 From: attilavs2 Date: Sun, 11 Aug 2024 10:34:07 +0200 Subject: [PATCH] npc : remove_npc() parfait --- src/game.c | 6 ------ src/npc.c | 10 ++++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/game.c b/src/game.c index c5f94fd..8eb7c92 100644 --- a/src/game.c +++ b/src/game.c @@ -279,15 +279,9 @@ void game_get_inputs(Game *game) { mynpc->xpath = NULL; mynpc->ypath = NULL; } - while(keydown(KEY_F1)) { - clearevents(); - } } if(keydown(KEY_F2)) { npc_remove_pos(0); - while(keydown(KEY_F2)) { - clearevents(); - } } /* Display Debug Information on screen */ diff --git a/src/npc.c b/src/npc.c index 50bbaea..00da67a 100644 --- a/src/npc.c +++ b/src/npc.c @@ -48,8 +48,6 @@ void npc_remove(NPC *npc) { return; } uint32_t move_size = sizeof(NPC) * (npc_count - pos); - if(move_size + pos > NPC_STACK_SIZE) - move_size = NPC_STACK_SIZE - pos; memmove(npc, &npc_stack[++pos], move_size); if(npc_count) @@ -132,8 +130,8 @@ int npc_pathfind(int32_t dest_x, int32_t dest_y, Map *full_map, NPC *npc) { dest_x /= PXSIZE; dest_y /= PXSIZE; - if(dest_x < 0 || dest_y < 0 || dest_x >= w * T_WIDTH || - dest_y >= h * T_HEIGHT) + if(dest_x < 0 || dest_y < 0 || dest_x >= (int32_t)(w * T_WIDTH) || + dest_y >= (int32_t)(h * T_HEIGHT)) return 2; /*if(map[(dest_y/T_HEIGHT)*w + dest_x/T_WIDTH]) @@ -179,9 +177,9 @@ int as_reconstruct_path(int16_t *came_from, int w, int h, int16_t start, goto as_recons_fail; } - uint16_t tx, ty; + /*uint16_t tx, ty;*/ - // Flip the path because it started from the end + /* Flip the path because it started from the end */ /*for(i = 0; i < npc->path_length / 2; i++) { tx = npc->xpath[i];