home · contact · privacy
Server: Add -n option to regenerate world.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 13 Mar 2016 11:29:15 +0000 (12:29 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 13 Mar 2016 11:29:15 +0000 (12:29 +0100)
roguelike-server
server/utils.py

index c8bf3f71d28f47b95d3a14631ad45c8c60c23731..414f765a29f356ce35dada5916be0ce2ecebcd73 100755 (executable)
@@ -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:
index c80c1d0288933b85f71c1aab915c73a16a6651d7..f7128916f37abbef0fb4136c9123c450fc233740 100644 (file)
@@ -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',