From: Christian Heller Date: Thu, 21 Aug 2014 23:35:41 +0000 (+0200) Subject: Server: Minor refactoring, removal of unneeded is_passable(). X-Git-Tag: tce~648 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/%27%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28escapeHTML%28span%5B2%5D%29%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28%27?a=commitdiff_plain;h=58486c337a7b1f04311801d902fed41ed3f67315;p=plomrogue Server: Minor refactoring, removal of unneeded is_passable(). --- diff --git a/src/server/map.c b/src/server/map.c index 50c7bf1..d98a61f 100644 --- a/src/server/map.c +++ b/src/server/map.c @@ -152,18 +152,6 @@ extern void remake_map() -extern uint8_t is_passable(struct yx_uint8 pos) -{ - uint8_t passable = 0; - if (pos.x < world.map.length && pos.y < world.map.length) - { - passable = ('.' == world.map.cells[(pos.y * world.map.length) + pos.x]); - } - return passable; -} - - - extern uint8_t mv_yx_in_dir_legal(char dir, struct yx_uint8 * yx) { uint8_t wraptest = mv_yx_in_dir_wrap(dir, yx, 0); diff --git a/src/server/map.h b/src/server/map.h index e3a28f9..5407daf 100644 --- a/src/server/map.h +++ b/src/server/map.h @@ -21,11 +21,6 @@ */ extern void remake_map(); -/* Check if coordinate "pos" on (or beyond) world.map is accessible to thing - * movement. - */ -extern uint8_t is_passable(struct yx_uint8 pos); - /* Wrapper to mv_yx_in_dir_wrap(), returns 1 if the wrapped function moved "yx" * within the wrap borders and the map size, else 0. */ diff --git a/src/server/thing_actions.c b/src/server/thing_actions.c index d120876..9f1f572 100644 --- a/src/server/thing_actions.c +++ b/src/server/thing_actions.c @@ -15,7 +15,7 @@ * set_thing_position(), get_thing_type(), * free_things_in_memory() */ -#include "map.h" /* mv_yx_in_dir_legal(), is_passable() */ +#include "map.h" /* mv_yx_in_dir_legal() */ #include "yx_uint8.h" /* mv_yx_in_dir_wrap(), yx_uint8_cmp() */ #include "world.h" /* global world */ @@ -278,7 +278,8 @@ extern void actor_move(struct Thing * t) } } } - uint8_t passable = legal_move && is_passable(target); + char target_cell = world.map.cells[target.y * world.map.length + target.x]; + uint8_t passable = legal_move && '.' == target_cell; if (passable) { set_thing_position(t, target); diff --git a/src/server/things.c b/src/server/things.c index ffa30b0..ebecf6d 100644 --- a/src/server/things.c +++ b/src/server/things.c @@ -11,7 +11,6 @@ #include "../common/yx_uint8.h" /* yx_uint8 */ #include "cleanup.h" /* set_cleanup_flag() */ #include "hardcoded_strings.h" /* s */ -#include "map.h" /* is_passable() */ #include "rrand.h" /* rrand() */ #include "thing_actions.h" /* actor_wait */ #include "world.h" /* world */ @@ -267,10 +266,11 @@ extern void add_things(uint8_t type, uint8_t n) struct yx_uint8 pos; while (1) { - char * err = "Space to put thing on too hard to find." - "Map too small?"; + char * err="Space to put thing on too hard to find. Map too small?"; uint16_t i_pos = 0; - for (pos.y = pos.x = 0; 0 == is_passable(pos); i_pos++) + for (pos.y = pos.x = 0; + '.' != world.map.cells[pos.y * world.map.length + pos.x]; + i_pos++) { exit_err(UINT16_MAX == i_pos, err); pos.y = rrand() % world.map.length;