home · contact · privacy
Server: Outsource part of update_map_memory to C library.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 24 Feb 2016 23:25:13 +0000 (00:25 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 24 Feb 2016 23:25:13 +0000 (00:25 +0100)
libplomrogue.c
server/update_map_memory.py

index d0b656b657f23c225cd0fafe140dcfe92660ca6c..37cc8ef0085d6f4f341c7f9a05a2a27fba10a742 100644 (file)
@@ -618,3 +618,20 @@ extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map,
     }
     return 0;
 }
+
+
+extern void update_mem_and_memdepthmap_via_fovmap(char * map, char * fovmap,
+                                                  char * memdepthmap,
+                                                  char * memmap)
+{
+    uint32_t map_size = maplength * maplength;
+    uint16_t pos;
+    for (pos = 0; pos < map_size; pos++)
+    {
+        if ('v' == fovmap[pos])
+        {
+            memdepthmap[pos] = '0';
+            memmap[pos] = map[pos];
+        }
+    }
+}
index d018e84d01ee60f8d108071514a54d4c83a3fa1f..5d6ae68e57103d85350777530d010581ca9f53ae 100644 (file)
@@ -24,18 +24,27 @@ def update_map_memory(t, age_map=True):
         fovmap = c_pointer_to_bytearray(t["fovmap"])
         libpr.age_some_memdepthmap_on_nonfov_cells(memdepthmap, fovmap)
 
+    def update_mem_and_memdepthmap_via_fovmap():
+        # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
+        # for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
+        #             if ord_v == t["fovmap"][pos]]:
+        #     t["T_MEMDEPTHMAP"][pos] = ord_0
+        #     t["T_MEMMAP"][pos] = world_db["MAP"][pos]
+        memdepthmap = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
+        memmap = c_pointer_to_bytearray(t["T_MEMMAP"])
+        fovmap = c_pointer_to_bytearray(t["fovmap"])
+        map = c_pointer_to_bytearray(world_db["MAP"])
+        libpr.update_mem_and_memdepthmap_via_fovmap(map, fovmap, memdepthmap,
+                                                    memmap)
+
     if not t["T_MEMMAP"]:
         t["T_MEMMAP"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
     if not t["T_MEMDEPTHMAP"]:
         t["T_MEMDEPTHMAP"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
-    ord_v = ord("v")
-    ord_0 = ord("0")
-    for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
-                if ord_v == t["fovmap"][pos]]:
-        t["T_MEMDEPTHMAP"][pos] = ord_0
-        t["T_MEMMAP"][pos] = world_db["MAP"][pos]
+    update_mem_and_memdepthmap_via_fovmap()
     if age_map:
         age_some_memdepthmap_on_nonfov_cells()
+    ord_v = ord("v")
     t["T_MEMTHING"] = [mt for mt in t["T_MEMTHING"]
                        if ord_v != t["fovmap"][(mt[1] * world_db["MAP_LENGTH"])
                                                + mt[2]]]