X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fserver%2Fai.c;h=dd11f38deab002a4694d84f649ba4fe348dbf8be;hb=165a82baaba4f4ca2fd74cb3a3eac744d93b0239;hp=cdefca844bb78dc87277b409d25f2f12ce183137;hpb=3dedf6344c941891491773d1cc5d647aa664b218;p=plomrogue diff --git a/src/server/ai.c b/src/server/ai.c index cdefca8..dd11f38 100644 --- a/src/server/ai.c +++ b/src/server/ai.c @@ -1,7 +1,11 @@ -/* src/server/ai.c */ +/* src/server/ai.c + * + * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3 + * or any later version. For details on its copyright, license, and warranties, + * see the file NOTICE in the root directory of the PlomRogue source package. + */ #include "ai.h" -#include /* NULL */ #include /* uint8_t, uint16_t, uint32_t, int16_t, UINT16_MAX */ #include /* free() */ #include "../common/try_malloc.h" /* try_malloc() */ @@ -191,7 +195,7 @@ static void init_score_map(char filter, uint16_t * score_map, uint32_t map_size, static uint8_t get_dir_to_nearest_thing(struct Thing * t_eye, char filter) { - char dir_to_nearest_enemy = 0; + char dir_to_nearest_thing = 0; if (seeing_thing(t_eye, filter)) { uint32_t map_size = world.map.length * world.map.length; @@ -210,14 +214,14 @@ static uint8_t get_dir_to_nearest_thing(struct Thing * t_eye, char filter) if (min_neighbor > neighbors[i]) { min_neighbor = neighbors[i]; - dir_to_nearest_enemy = dirs[i]; + dir_to_nearest_thing = dirs[i]; } } } - if (dir_to_nearest_enemy) + if (dir_to_nearest_thing) { t_eye->command = get_thing_action_id_by_name(s[S_CMD_MOVE]); - t_eye->arg = dir_to_nearest_enemy; + t_eye->arg = dir_to_nearest_thing; return 1; } return 0; @@ -268,7 +272,7 @@ static int16_t get_inventory_slot_to_consume(struct Thing * t_owner) int16_t selection = -1; struct Thing * t = t_owner->owns;; uint8_t i; - for (i = 0; t != NULL; t = t->next, i++) + for (i = 0; t; t = t->next, i++) { struct ThingType * tt = get_thing_type(t->type); if (tt->consumable > compare_consumability) @@ -285,7 +289,7 @@ static int16_t get_inventory_slot_to_consume(struct Thing * t_owner) static uint8_t standing_on_consumable(struct Thing * t_standing) { struct Thing * t = world.things; - for (; t != NULL; t = t->next) + for (; t; t = t->next) { if ( t != t_standing && t->pos.y == t_standing->pos.y && t->pos.x == t_standing->pos.x)