X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=plomrogue-server.py;h=d9593f854f166196ee4f039c3692e24bff827fc7;hb=0891d236075c217eb7e32a38c8da354a6419a1c3;hp=3bcb166ebe3c98bac6900707aee3e47832042d87;hpb=168d6669e5d524b6c41781c6ed03bc181919957a;p=plomrogue diff --git a/plomrogue-server.py b/plomrogue-server.py index 3bcb166..d9593f8 100755 --- a/plomrogue-server.py +++ b/plomrogue-server.py @@ -77,6 +77,7 @@ def obey(cmd, io_db, prefix): def record(cmd, path_recordfile): """Append cmd string plus newline to file at path_recordfile.""" + # Doesn't yet replace old record() fully. file = open(path_recordfile, "a") file.write(cmd + "\n") file.close() @@ -99,19 +100,21 @@ try: " (if so late a turn is to be found).") if not os.access(io_db["path_record"], os.F_OK): raise SystemExit("No record file found to replay.") - elif os.access(io_db["path_save"], os.F_OK): - print(open(io_db["path_save"], "r").read()) else: - if not os.access(io_db["path_worldconf"], os.F_OK): - msg = "No world config file from which to start a new world." - raise SystemExit(msg) - file = open(io_db["path_worldconf"]) - line_n = 1 - for line in file.readlines(): - obey(line.rstrip(), io_db, "worldconfig file line " + str(line_n)) - line_n = line_n + 1 - file.close() - obey("MAKE_WORLD " + str(int(time.time())), io_db, "in file") + if os.access(io_db["path_save"], os.F_OK): + print(open(io_db["path_save"], "r").read()) + else: + if not os.access(io_db["path_worldconf"], os.F_OK): + msg = "No world config file from which to start a new world." + raise SystemExit(msg) + file = open(io_db["path_worldconf"]) + line_n = 1 + for line in file.readlines(): + obey(line.rstrip(), io_db, "worldconfig line " + str(line_n)) + line_n = line_n + 1 + file.close() + obey("MAKE_WORLD " + str(int(time.time())), io_db, "in file") + # print("DUMMY: Run io_loop().") except SystemExit as exit: print("ABORTING: " + exit.args[0]) except: