home · contact · privacy
Make PtIG default game, add documentation.
[plomrogue] / server / utils.py
index db33eba88ebe79c368f72baf6a38e32c00c63c2f..c8f1c380bafba5cab203895d81d6a189c1dae34c 100644 (file)
@@ -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,7 +102,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",
+    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()