From: Christian Heller Date: Sun, 13 Mar 2016 11:29:15 +0000 (+0100) Subject: Server: Add -n option to regenerate world. X-Git-Tag: tce~17 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/coming?a=commitdiff_plain;h=f991df6de36a3407a6e899a18ef359cb0522e41c;p=plomrogue Server: Add -n option to regenerate world. --- 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',