home · contact · privacy
Server: Minor refactoring, removal of unneeded is_passable().
[plomrogue] / src / server / things.c
index bbe9dbffe39388399b741965c7ead8bb2aa61baa..ebecf6d59e1cb0c5d93ad31b8f16508b413c8256 100644 (file)
@@ -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 */
@@ -28,9 +27,6 @@ struct NextAndId
 
 
 
-/* Free ThingsInMemory chain starting at "tm". */
-static void free_things_in_memory(struct ThingInMemory * tm);
-
 /* To linked list of NextAndId structs (or rather structs whose start region is
  * compatible to it) starting at "start", add newly allocated element of
  * "n_size" and an ID that is either "id" or, if "id" is <= UINT8_MAX and >=
@@ -43,18 +39,6 @@ static struct NextAndId * add_to_struct_list(size_t n_size, uint8_t start_id,
 
 
 
-static void free_things_in_memory(struct ThingInMemory * tm)
-{
-    if (!tm)
-    {
-        return;
-    }
-    free_things_in_memory(tm->next);
-    free(tm);
-}
-
-
-
 static struct NextAndId * add_to_struct_list(size_t n_size, uint8_t start_id,
                                              int16_t id, uint8_t struct_id,
                                              struct NextAndId ** start)
@@ -195,6 +179,18 @@ extern void free_things(struct Thing * t)
 
 
 
+extern void free_things_in_memory(struct ThingInMemory * tm)
+{
+    if (!tm)
+    {
+        return;
+    }
+    free_things_in_memory(tm->next);
+    free(tm);
+}
+
+
+
 extern struct ThingAction * get_thing_action(uint8_t id)
 {
     struct ThingAction * ta = world.thing_actions;
@@ -270,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;