home · contact · privacy
In server test script, update path of server executable.
[plomrogue] / libplomrogue.c
index 384c81db0094fd512a5e2eb8b6e7407cea2926c5..9a4e69a7cdd2158374b16a77102a41b46b69798e 100644 (file)
@@ -1,3 +1,4 @@
+#include <math.h> /* pow() */
 #include <stddef.h> /* NULL */
 #include <stdint.h> /* ?(u)int(8|16|32)_t, ?(U)INT8_(MIN|MAX) */
 #include <stdlib.h> /* free, malloc */
@@ -448,20 +449,6 @@ extern uint8_t set_map_score(uint16_t pos, uint16_t score)
         return 1;
     }
     score_map[pos] = score;
-/*
-    uint32_t mup_size = maplength * maplength;
-    uint32_t pus;
-    FILE * file = fopen("test_set", "w");
-    for (pus = 0; pus < mup_size; pus++)
-    {
-        fprintf(file, "%d ", score_map[pus]);
-        if (0 == pus % maplength)
-        {
-            fprintf(file, "\n");
-        }
-    }
-    fclose(file);
-*/
     return 0;
 }
 
@@ -573,3 +560,40 @@ extern uint8_t dijkstra_map()
     }
     return 0;
 }
+
+extern uint8_t zero_score_map_where_char_on_memdepthmap(char c,
+                                                        char * memdepthmap)
+{
+    if (!score_map)
+    {
+        return 1;
+    }
+    uint32_t map_size = maplength * maplength;
+    uint16_t pos;
+    for (pos = 0; pos < map_size; pos++)
+    {
+        if (c == memdepthmap[pos])
+        {
+            score_map[pos] = 0;
+        }
+    }
+    return 0;
+}
+
+extern void age_some_memdepthmap_on_nonfov_cells(char * memdepthmap,
+                                                     char * fovmap)
+{
+    uint32_t map_size = maplength * maplength;
+    uint16_t pos;
+    for (pos = 0; pos < map_size; pos++)
+    {
+        if ('v' != fovmap[pos])
+        {
+            char c = memdepthmap[pos];
+            if( '0' <= c && '9' > c && !(rrand() % (uint16_t) pow(2, c - 48)))
+            {
+                memdepthmap[pos]++;
+            }
+        }
+    }
+}