From 61d2bf27904c05c2bb6dd68bd83cab9bba9c9385 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 23 Jul 2014 05:25:46 +0200 Subject: [PATCH] Server: Remove barely used and not very useful yx_to_map_pos(). --- src/server/field_of_view.c | 3 +-- src/server/io.c | 6 +++--- src/server/map.c | 7 ------- src/server/map.h | 3 --- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/server/field_of_view.c b/src/server/field_of_view.c index 278cc8b..1a9acd5 100644 --- a/src/server/field_of_view.c +++ b/src/server/field_of_view.c @@ -6,7 +6,6 @@ #include /* memset() */ #include "../common/rexit.h" /* exit_trouble() */ #include "../common/try_malloc.h" /* try_malloc() */ -#include "map.h" /* yx_to_map_pos() */ #include "things.h" /* Thing */ #include "yx_uint8.h" /* yx_uint8 */ #include "world.h" /* world */ @@ -317,7 +316,7 @@ static void eval_position(uint16_t dist, uint16_t hex_i, uint8_t * fov_map, uint32_t left_angle = correct_angle(left_angle_uncorrected); uint32_t right_angle = correct_angle(right_angle_uncorrected); uint32_t right_angle_1st = right_angle > left_angle ? 0 : right_angle; - uint16_t pos_in_map = yx_to_map_pos(test_pos); + uint16_t pos_in_map = test_pos->y * world.map.length + test_pos->x; set_shadow(left_angle, right_angle_1st, shadows, pos_in_map, fov_map); if (right_angle_1st != right_angle) { diff --git a/src/server/io.c b/src/server/io.c index 6228415..17110d3 100644 --- a/src/server/io.c +++ b/src/server/io.c @@ -19,7 +19,6 @@ #include "cleanup.h" /* set_cleanup_flag() */ #include "field_of_view.h" /* VISIBLE */ #include "hardcoded_strings.h" /* s */ -#include "map.h" /* yx_to_map_pos() */ #include "things.h" /* Thing, ThingType, ThingAction, get_thing_type(), * get_player() */ @@ -277,13 +276,14 @@ static char * build_visible_map(struct Thing * player) { for (t = world.things; t != 0; t = t->next) { - if ( player->fov_map[yx_to_map_pos(&t->pos)] & VISIBLE + if ( ( player->fov_map[t->pos.y * world.map.length +t->pos.x] + & VISIBLE) && ( (0 == i && 0 == t->lifepoints) || (1 == i && 0 < t->lifepoints))) { tt = get_thing_type(t->type); c = tt->char_on_map; - visible_map[yx_to_map_pos(&t->pos)] = c; + visible_map[t->pos.y * world.map.length + t->pos.x] = c; } } } diff --git a/src/server/map.c b/src/server/map.c index 7eececa..8ed37d9 100644 --- a/src/server/map.c +++ b/src/server/map.c @@ -160,10 +160,3 @@ extern uint8_t is_passable(struct yx_uint8 pos) } return passable; } - - - -extern uint16_t yx_to_map_pos(struct yx_uint8 * yx) -{ - return (yx->y * world.map.length) + yx->x; -} diff --git a/src/server/map.h b/src/server/map.h index 641cb79..b1ad4c7 100644 --- a/src/server/map.h +++ b/src/server/map.h @@ -26,9 +26,6 @@ extern void remake_map(); */ extern uint8_t is_passable(struct yx_uint8 pos); -/* Transform "yx" to an index position in the world map. */ -extern uint16_t yx_to_map_pos(struct yx_uint8 * yx); - #endif -- 2.30.2