From: Christian Heller Date: Wed, 21 Aug 2013 19:17:15 +0000 (+0200) Subject: Pass pointers to yx_uint16 structs to yx_uint16_cmp() instead of structs themselves. X-Git-Tag: tce~1072 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/task?a=commitdiff_plain;h=289154889af25ebb05f5ad1149cafd8e82b0b0fa;p=plomrogue Pass pointers to yx_uint16 structs to yx_uint16_cmp() instead of structs themselves. --- diff --git a/src/map_object_actions.c b/src/map_object_actions.c index 58915f6..ff1ea90 100644 --- a/src/map_object_actions.c +++ b/src/map_object_actions.c @@ -19,7 +19,7 @@ extern void move_monster(struct World * world, struct Monster * monster) struct MapObjDef * mod = get_map_obj_def(world, monster->map_obj.type); char * desc = mod->desc; char * desc_other; - if (yx_uint16_cmp(t, world->player->pos)) + if (yx_uint16_cmp(&t, &world->player->pos)) { sprintf(msg, "\nThe %s hits you.", desc); update_log(world, msg); @@ -39,7 +39,7 @@ extern void move_monster(struct World * world, struct Monster * monster) { continue; } - if (yx_uint16_cmp(t, other_monster->map_obj.pos)) + if (yx_uint16_cmp(&t, &other_monster->map_obj.pos)) { mod = get_map_obj_def(world, other_monster->map_obj.type); desc_other = mod->desc; @@ -68,7 +68,7 @@ extern void move_player (struct World * world, enum dir d) monster != 0; monster = monster->map_obj.next) { - if (yx_uint16_cmp(t, monster->map_obj.pos)) + if (yx_uint16_cmp(&t, &monster->map_obj.pos)) { mod = get_map_obj_def(world, monster->map_obj.type); desc = mod->desc; diff --git a/src/yx_uint16.c b/src/yx_uint16.c index 0f44473..54274f4 100644 --- a/src/yx_uint16.c +++ b/src/yx_uint16.c @@ -6,9 +6,9 @@ -extern uint8_t yx_uint16_cmp(struct yx_uint16 a, struct yx_uint16 b) +extern uint8_t yx_uint16_cmp(struct yx_uint16 * a, struct yx_uint16 * b) { - if (a.y == b.y && a.x == b.x) + if (a->y == b->y && a->x == b->x) { return 1; } diff --git a/src/yx_uint16.h b/src/yx_uint16.h index 2a5b3ac..e5249b0 100644 --- a/src/yx_uint16.h +++ b/src/yx_uint16.h @@ -29,8 +29,8 @@ enum dir WEST }; -/* Return 1 if two yx_uint16 coordinates a and b are equal, else 0. */ -extern uint8_t yx_uint16_cmp(struct yx_uint16 a, struct yx_uint16 b); +/* Return 1 if two yx_uint16 coordinates at "a" and "b" are equal, else 0. */ +extern uint8_t yx_uint16_cmp(struct yx_uint16 * a, struct yx_uint16 * b); /* Return yx_uint16 coordinate one step from coordinate yx in direction dir. */ extern struct yx_uint16 mv_yx_in_dir(enum dir d, struct yx_uint16 yx);