From 64e1bc2a874308530b7b45c33ed5d37f34f5f8be Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 24 Jun 2013 00:37:15 +0200 Subject: [PATCH] Moved basic yx_uint16 handling into its own library. --- src/roguelike.c | 5 ----- src/roguelike.h | 1 - src/windows.h | 4 +--- src/yx_uint16.c | 8 ++++++++ src/yx_uint16.h | 6 ++++++ 5 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 src/yx_uint16.c create mode 100644 src/yx_uint16.h diff --git a/src/roguelike.c b/src/roguelike.c index c8fbf5a..058ed07 100644 --- a/src/roguelike.c +++ b/src/roguelike.c @@ -80,11 +80,6 @@ struct yx_uint16 mv_yx_in_dir (char d, struct yx_uint16 yx) { else if (d == WEST) yx.x--; return yx; } -char yx_uint16_cmp (struct yx_uint16 a, struct yx_uint16 b) { -// Compare two coordinates of type yx_uint16. - if (a.y == b.y && a.x == b.x) return 1; - else return 0; } - void next_turn (struct World * world) { // Increment turn and move enemy. world->turn++; diff --git a/src/roguelike.h b/src/roguelike.h index bb6088c..a6c154a 100644 --- a/src/roguelike.h +++ b/src/roguelike.h @@ -29,7 +29,6 @@ struct Map init_map (); void save_game(struct World *); void record_action (char); struct yx_uint16 mv_yx_in_dir (char, struct yx_uint16); -char yx_uint16_cmp (struct yx_uint16, struct yx_uint16); void next_turn (struct World *); void update_log (struct World *, char *); void move_player (struct World *, char); diff --git a/src/windows.h b/src/windows.h index c194907..a597ebb 100644 --- a/src/windows.h +++ b/src/windows.h @@ -1,6 +1,4 @@ -struct yx_uint16 { - uint16_t y; - uint16_t x; }; +#include "yx_uint16.h" struct Frame { WINDOW * curses_win; diff --git a/src/yx_uint16.c b/src/yx_uint16.c new file mode 100644 index 0000000..afcab4d --- /dev/null +++ b/src/yx_uint16.c @@ -0,0 +1,8 @@ +#include "stdint.h" +#include "yx_uint16.h" + +extern char yx_uint16_cmp (struct yx_uint16 a, struct yx_uint16 b) { +// Compare two coordinates of type yx_uint16. + if (a.y == b.y && a.x == b.x) return 1; + else return 0; } + diff --git a/src/yx_uint16.h b/src/yx_uint16.h new file mode 100644 index 0000000..c1479c0 --- /dev/null +++ b/src/yx_uint16.h @@ -0,0 +1,6 @@ +struct yx_uint16 { + uint16_t y; + uint16_t x; }; + +extern char yx_uint16_cmp (struct yx_uint16, struct yx_uint16); + -- 2.30.2