+def read_worldstate():
+ if not os.access(io["path_worldstate"], os.F_OK):
+ msg = "No world state file found at " + io["path_worldstate"] + "."
+ raise SystemExit(msg)
+ read_anew = False
+ worldstate_file = open(io["path_worldstate"], "r")
+ turn_string = worldstate_file.readline()
+ if int(turn_string) != world_data["turn"]:
+ read_anew = True
+ if not read_anew: # In rare cases, world may change, but not turn number.
+ mtime = os.stat(io["path_worldstate"])
+ if mtime != read_worldstate.last_checked_mtime:
+ read_worldstate.last_checked_mtime = mtime
+ read_anew = True
+ if read_anew:
+ cursed_main.redraw = True
+ world_data["turn"] = int(turn_string)
+ worldstate_file.close()
+read_worldstate.last_checked_mtime = -1