home · contact · privacy
The player is now a map object like any other. All actor contacts now lead to violenc...
[plomrogue] / src / map.c
index a9750434281c32d97ac2679b6ba074747ae7b631..368c0e2c0ac6d8d8fe08f7c9e08ddd7ec0f10a78 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -1,22 +1,23 @@
 #include "map.h"
-#include <stdlib.h>      /* for malloc() */
 #include <stdint.h>      /* for uint16_t, uint32_t */
-#include "misc.h"        /* for center_offset() */
+#include "misc.h"        /* for try_malloc(), center_offset() */
 #include "map_objects.h" /* for Player struct */
 #include "yx_uint16.h"   /* for yx_uint16 and dir enums */
 #include "rrand.h"       /* for rrand() */
+struct World;
 
 
 
-struct Map init_map ()
+struct Map init_map(struct World * world)
 {
+    char * f_name = "init_map()";
     struct Map map;
     map.size.x = 64;
     map.size.y = 64;
     map.offset.x = 0;
     map.offset.y = 0;
     uint32_t size = map.size.x * map.size.y;
-    map.cells = malloc(size);
+    map.cells = try_malloc(size, world, f_name);
     uint16_t y, x;
     for (y = 0; y < map.size.y; y++)
     {
@@ -76,9 +77,9 @@ void map_scroll (struct Map * map, enum dir d, struct yx_uint16 win_size)
 
 
 
-void map_center_player(struct Map * map, struct Player * player,
+void map_center_object(struct Map * map, struct MapObj * object,
                        struct yx_uint16 win_size)
 {
-    map->offset.y = center_offset (player->pos.y, map->size.y, win_size.y);
-    map->offset.x = center_offset (player->pos.x, map->size.x, win_size.x);
+    map->offset.y = center_offset(object->pos.y, map->size.y, win_size.y);
+    map->offset.x = center_offset(object->pos.x, map->size.x, win_size.x);
 }