From 52da4be1af781d3775966d1c83e4ad6c8de37c6e Mon Sep 17 00:00:00 2001 From: attilavs2 Date: Tue, 23 Jul 2024 18:17:02 +0200 Subject: [PATCH] npc : correction de warnings --- src/npc.c | 14 +++++++------- src/npc.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/npc.c b/src/npc.c index 752aad6..12dd57b 100644 --- a/src/npc.c +++ b/src/npc.c @@ -69,7 +69,7 @@ int as_reconstruct_path(int16_t *came_from, int w, int h, int16_t spos, int16_t next = came_from[dest]; - int i; + unsigned int i; for(i = 0; i < 64; i++) { @@ -112,9 +112,9 @@ int as_reconstruct_path(int16_t *came_from, int w, int h, int16_t spos, //Returns non zero error code on failure //Custom a* implemetation //Unoptimized, may become an issue -int npc_pathfind(int dest_x, int dest_y, Map *full_map, NPC *npc) +int npc_pathfind(uint32_t dest_x, uint32_t dest_y, Map *full_map, NPC *npc) { - int i, j; + uint32_t i, j; uint32_t w = full_map->w; uint32_t h = full_map->h; @@ -143,8 +143,8 @@ int npc_pathfind(int dest_x, int dest_y, Map *full_map, NPC *npc) fscore[spos] = length(dest_x-x, dest_y-y); uint8_t bscore; - int bx = x; - int by = y; + uint32_t bx = x; + uint32_t by = y; for(int iter=0; iter < 1024; iter++) { @@ -171,12 +171,10 @@ int npc_pathfind(int dest_x, int dest_y, Map *full_map, NPC *npc) for(i = bx-1; i < bx+2; i++) { - if(i < 0) continue; if(i > w) break; for(j = by-1; j < by+2; j++) { if(j > h ) break; - if(j < 0) continue; if(map[j*w+i]) continue; att_score = gscore[by*w+bx] + ceil(length(bx-i,by-j)); if(att_score < gscore[j*w+i]) @@ -199,6 +197,8 @@ int npc_pathfind(int dest_x, int dest_y, Map *full_map, NPC *npc) //Refactoring to make adding complexity cleaner void update_npcs([[maybe_unused]] Game *game) { + //npc_pathfind(game->player.x, game->player.y, game->map_level, &npcRPG[0]); + for( uint32_t u=0; u