home · contact · privacy
Server: Remove barely used and not very useful yx_to_map_pos().
authorChristian Heller <c.heller@plomlompom.de>
Wed, 23 Jul 2014 03:25:46 +0000 (05:25 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 23 Jul 2014 03:25:46 +0000 (05:25 +0200)
src/server/field_of_view.c
src/server/io.c
src/server/map.c
src/server/map.h

index 278cc8b8d5b4a34c46f92319db35d0ddf9161b6b..1a9acd588654f6d44b523ff18180a2201493fab9 100644 (file)
@@ -6,7 +6,6 @@
 #include <string.h> /* 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)
     {
index 62284153ace342dd035d72b0c258df60df3e5e50..17110d324c804e047bcd3a212fccd4165982ee35 100644 (file)
@@ -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;
                 }
             }
         }
index 7eececab5a74257d44b98ab3dad31351f3d3b85f..8ed37d9b50cbd017baf0cb2c0464e5e547aebeab 100644 (file)
@@ -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;
-}
index 641cb797edca08f8d9ef95692901777d84eb6fd3..b1ad4c716b1ddd9ef64c5ebd58219454ea02eeac 100644 (file)
@@ -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