1 # This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
2 # or any later version. For details on its copyright, license, and warranties,
3 # see the file NOTICE in the root directory of the PlomRogue source package.
6 def update_map_memory(t, age_map=True):
7 """Update t's T_MEMMAP with what's in its FOV now,age its T_MEMMEPTHMAP."""
8 from server.utils import c_pointer_to_bytearray, libpr
9 from server.config.world_data import world_db
11 def age_some_memdepthmap_on_nonfov_cells():
12 # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
16 # for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
17 # if not ord_v == t["fovmap"][pos]
18 # if ord_0 <= t["T_MEMDEPTHMAP"][pos]
19 # if ord_9 > t["T_MEMDEPTHMAP"][pos]
20 # if not rand.next() % (2 **
21 # (t["T_MEMDEPTHMAP"][pos] - 48))]:
22 # t["T_MEMDEPTHMAP"][pos] += 1
23 memdepthmap = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
24 fovmap = c_pointer_to_bytearray(t["fovmap"])
25 libpr.age_some_memdepthmap_on_nonfov_cells(memdepthmap, fovmap)
28 t["T_MEMMAP"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
29 if not t["T_MEMDEPTHMAP"]:
30 t["T_MEMDEPTHMAP"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
33 for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
34 if ord_v == t["fovmap"][pos]]:
35 t["T_MEMDEPTHMAP"][pos] = ord_0
36 t["T_MEMMAP"][pos] = world_db["MAP"][pos]
38 age_some_memdepthmap_on_nonfov_cells()
39 t["T_MEMTHING"] = [mt for mt in t["T_MEMTHING"]
40 if ord_v != t["fovmap"][(mt[1] * world_db["MAP_LENGTH"])
42 for id in [id for id in world_db["Things"]
43 if not world_db["Things"][id]["carried"]]:
44 type = world_db["Things"][id]["T_TYPE"]
45 if not world_db["ThingTypes"][type]["TT_LIFEPOINTS"]:
46 y = world_db["Things"][id]["T_POSY"]
47 x = world_db["Things"][id]["T_POSX"]
48 if ord_v == t["fovmap"][(y * world_db["MAP_LENGTH"]) + x]:
49 t["T_MEMTHING"].append((type, y, x))