home · contact · privacy
Server: Remove unneeded library includes.
[plomrogue] / src / server / map.c
index 1c9a2f1881fdbac990dcd48ffe3bc9232aaa479d..ae907d2327363fef50919575440a27a6a094a702 100644 (file)
@@ -2,10 +2,12 @@
 
 #include "map.h"
 #include <stdint.h> /* uint8_t, uint16_t, uint32_t, UINT16_MAX */
+#include <stdlib.h> /* free() */
 #include "../common/rexit.h" /* exit_err() */
 #include "../common/try_malloc.h" /* try_malloc() */
-#include "../common/yx_uint8.h" /* struct yx_uint8 */
+#include "../common/yx_uint8.h" /* yx_uint8 */
 #include "rrand.h" /* rrand() */
+#include "yx_uint8.h" /* mv_yx_in_dir_wrap() */
 #include "world.h" /* global world */
 
 
@@ -136,30 +138,26 @@ static void make_trees()
 
 
 
-extern void init_map()
+extern void remake_map()
 {
-    char * f_name = "init_map()";
-    world.map.cells = try_malloc(world.map.length * world.map.length, f_name);
+    free(world.map.cells);
+    world.map.cells = try_malloc(world.map.length * world.map.length, __func__);
+    uint32_t store_seed = world.seed;
+    world.seed = world.seed_map;
     make_sea();
     make_island();
     make_trees();
+    world.seed = store_seed;
 }
 
 
 
-extern uint8_t is_passable(struct yx_uint8 pos)
+extern uint8_t mv_yx_in_dir_legal(char dir, struct yx_uint8 * yx)
 {
-    uint8_t passable = 0;
-    if (pos.x < world.map.length && pos.y < world.map.length)
+    uint8_t wraptest = mv_yx_in_dir_wrap(dir, yx, 0);
+    if (!wraptest && yx->x < world.map.length && yx->y < world.map.length)
     {
-        passable = ('.' == world.map.cells[(pos.y * world.map.length) + pos.x]);
+        return 1;
     }
-    return passable;
-}
-
-
-
-extern uint16_t yx_to_map_pos(struct yx_uint8 * yx)
-{
-    return (yx->y * world.map.length) + yx->x;
+    return 0;
 }