+def update_map_memory(t):
+ """Update t's T_MEMMAP with what's in its FOV now,age its T_MEMMEPTHMAP."""
+ 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))
+ for pos in range(world_db["MAP_LENGTH"] ** 2):
+ if "v" == chr(t["fovmap"][pos]):
+ t["T_MEMDEPTHMAP"][pos] = ord("0")
+ if " " == chr(t["T_MEMMAP"][pos]):
+ t["T_MEMMAP"][pos] = world_db["MAP"][pos]
+ continue
+ # TODO: Aging of MEMDEPTHMAP.
+ for id in t["T_MEMTHING"]:
+ y = world_db["Things"][id]["T_POSY"]
+ x = world_db["Things"][id]["T_POSY"]
+ if "v" == chr(t["fovmap"][(y * world_db["MAP_LENGTH"]) + x]):
+ t["T_MEMTHING"].remove(id)
+ for id in world_db["Things"]:
+ type = world_db["Things"][id]["T_TYPE"]
+ if not world_db["ThingTypes"][type]["TT_LIFEPOINTS"]:
+ y = world_db["Things"][id]["T_POSY"]
+ x = world_db["Things"][id]["T_POSY"]
+ if "v" == chr(t["fovmap"][(y * world_db["MAP_LENGTH"]) + x]):
+ t["T_MEMTHING"] = (type, y, x)
+
+