X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=server%2Futils.py;h=c8f1c380bafba5cab203895d81d6a189c1dae34c;hb=a4e6c51b2e9aa85dc5f5e3067b602c01953a6d43;hp=22e2454d0f40a46f0384c7852ce2f88ab7475111;hpb=08f8592f1a1e5d340b6c2372551f0a3da28a07d8;p=plomrogue diff --git a/server/utils.py b/server/utils.py index 22e2454..c8f1c38 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,8 +84,14 @@ 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(): @@ -95,6 +102,9 @@ 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/PleaseTheIslandGod", + dest='worldconf', action='store') parser.add_argument('-v', dest='verbose', action='store_true') opts, unknown = parser.parse_known_args() return opts