npc : remove_npc() parfait

This commit is contained in:
attilavs2 2024-08-11 10:34:07 +02:00
parent 1c978dbefa
commit 35e1d498f9
2 changed files with 4 additions and 12 deletions

View file

@ -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 */

View file

@ -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];