mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-28 20:43:42 +01:00
npc : correction de warnings
This commit is contained in:
parent
49303ba6ad
commit
52da4be1af
2 changed files with 9 additions and 9 deletions
14
src/npc.c
14
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<nbNPC; u++ )
|
||||
{
|
||||
update_npc(&npcRPG[u]);
|
||||
|
|
|
@ -16,7 +16,7 @@ enum
|
|||
NPC_HOSTILE = 2, //to the player
|
||||
NPC_ALL = 3
|
||||
|
||||
} NPC_groups;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ int npc_append_path(uint16_t x, uint16_t y, NPC *npc);
|
|||
//Clears the NPCs path and creates a new one going to dest,
|
||||
//avoiding non-walkable tiles
|
||||
//Returns non-zero on failure
|
||||
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);
|
||||
|
||||
/* Draws the player player. This function should be called after drawing the
|
||||
* map! */
|
||||
|
|
Loading…
Reference in a new issue