From: Christian Heller Date: Sat, 6 Feb 2016 00:26:24 +0000 (+0100) Subject: Server: Make world initialization conf file choosable. X-Git-Tag: tce~205 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/%7B%7Btodo.comment%7D%7D?a=commitdiff_plain;h=9395575b648ff4de26be94020dddf796c988db73;p=plomrogue Server: Make world initialization conf file choosable. --- diff --git a/SERVER_COMMANDS b/SERVER_COMMANDS index 156cd43..e959f25 100644 --- a/SERVER_COMMANDS +++ b/SERVER_COMMANDS @@ -6,9 +6,10 @@ Normal mode In normal mode, the server on start up checks for the existence of ./save and, on success, reads all commands from it. If no save file exists, commands from -./confserver/world are read instead – and written to the file ./record_save. -Afterwards, the command "MAKE_WORLD" with the current Unix time as argument is -interpreted (and also written to ./record_save). +./confserver/world (or any file defined with the -w argument) are read instead +– and written to the file ./record_save. Afterwards, the command "MAKE_WORLD" +with the current Unix time as argument is interpreted (and also written to +./record_save). In any case, from then on, further commands are read in from ./server_run/in. New commands must be appended to the file – which is what the client does. All diff --git a/roguelike-server b/roguelike-server index abd2f2f..ac6601e 100755 --- a/roguelike-server +++ b/roguelike-server @@ -47,11 +47,10 @@ def play_game(): if os.access(io_db["path_save"], os.F_OK): obey_lines_in_file(io_db["path_save"], "save") else: - if not os.access(io_db["path_worldconf"], os.F_OK): + if not os.access(opts.worldconf, os.F_OK): msg = "No world config file from which to start a new world." raise SystemExit(msg) - obey_lines_in_file(io_db["path_worldconf"], "world config ", - do_record=True) + obey_lines_in_file(opts.worldconf, "world config ", do_record=True) obey("MAKE_WORLD " + str(int(time.time())), "in file", do_record=True) while True: try_worldstate_update() diff --git a/server/config/io.py b/server/config/io.py index e134b2f..ec6a8ae 100644 --- a/server/config/io.py +++ b/server/config/io.py @@ -7,7 +7,6 @@ io_db = { "path_save": "save", "path_record": "record_save", - "path_worldconf": "confserver/world", "path_server": "server_run/", "path_in": "server_run/in", "path_out": "server_run/out", diff --git a/server/utils.py b/server/utils.py index 22e2454..db33eba 100644 --- a/server/utils.py +++ b/server/utils.py @@ -95,6 +95,8 @@ def parse_command_line_arguments(): action='store') parser.add_argument('-l', nargs="?", const="save", dest='savefile', action="store") + parser.add_argument('-w', type=str, default="confserver/world", + dest='worldconf', action='store') parser.add_argument('-v', dest='verbose', action='store_true') opts, unknown = parser.parse_known_args() return opts