X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=server%2Futils.py;h=f7128916f37abbef0fb4136c9123c450fc233740;hb=aca74b23a81d4ecbd77e3e0da2de81574ab41358;hp=22e2454d0f40a46f0384c7852ce2f88ab7475111;hpb=08f8592f1a1e5d340b6c2372551f0a3da28a07d8;p=plomrogue diff --git a/server/utils.py b/server/utils.py index 22e2454..f712891 100644 --- a/server/utils.py +++ b/server/utils.py @@ -42,7 +42,8 @@ def integer_test(val_string, min, max=None): def id_setter(id, category, id_store=False, start_at_1=False): - """Set ID of object of category to manipulate ID. Unused? Create new one. + """Set ID of object of category to manipulate. ID unused? Create new one. + The ID is stored as id_store.id (if id_store is set). If the integer of the input is valid (if start_at_1, >= 0, else >= -1), but <0 or (if start_at_1) <1, calculate new ID: lowest unused ID >=0 or (if start_at_1) >= 1. None is @@ -83,18 +84,28 @@ def prep_library(): def c_pointer_to_bytearray(ba): """Return C char * pointer to ba.""" - type = ctypes.c_char * len(ba) - return type.from_buffer(ba) + ty = ctypes.c_char * len(ba) + return ty.from_buffer(ba) + + +def c_pointer_to_string(string): + """Return C char * pointer to string.""" + p = ctypes.c_char_p(string.encode("ascii")) + return p 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', action="store") + parser.add_argument('-w', type=str, + default="confserver/TheCrawlingEater", + dest='worldconf', action='store') parser.add_argument('-v', dest='verbose', action='store_true') opts, unknown = parser.parse_known_args() return opts