From f991df6de36a3407a6e899a18ef359cb0522e41c Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 13 Mar 2016 12:29:15 +0100 Subject: [PATCH] Server: Add -n option to regenerate world. --- roguelike-server | 7 ++++++- server/utils.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/roguelike-server b/roguelike-server index c8bf3f7..414f765 100755 --- a/roguelike-server +++ b/roguelike-server @@ -64,11 +64,16 @@ try: if opts.savefile: io_db["path_save"] = opts.savefile io_db["path_record"] = "record_" + opts.savefile + import os + if opts.new: + if os.access(io_db["path_record"], os.F_OK): + os.remove(io_db["path_record"]) + if os.access(io_db["path_save"], os.F_OK): + os.remove(io_db["path_save"]) from server.io import setup_server_io setup_server_io() if opts.verbose: io_db["verbose"] = True - import os from server.config.world_data import world_db from server.io import read_command, try_worldstate_update, obey if None != opts.replay: diff --git a/server/utils.py b/server/utils.py index c80c1d0..f712891 100644 --- a/server/utils.py +++ b/server/utils.py @@ -98,6 +98,7 @@ def parse_command_line_arguments(): """Return settings values read from command line arguments.""" import argparse parser = argparse.ArgumentParser() + parser.add_argument('-n', dest='new', action='store_true') parser.add_argument('-s', nargs='?', type=int, dest='replay', const=1, action='store') parser.add_argument('-l', nargs="?", const="save", dest='savefile', -- 2.30.2