+def soundmapset(str_int, mapline):
+ def valid_map_line(str_int, mapline):
+ from server.utils import integer_test
+ val = integer_test(str_int, 0, 255)
+ if None != val:
+ if val >= world_db["MAP_LENGTH"]:
+ print("Illegal value for map line number.")
+ elif len(mapline) != world_db["MAP_LENGTH"]:
+ print("Map line length is unequal map width.")
+ else:
+ return val
+ return None
+ val = valid_map_line(str_int, mapline)
+ if None != val:
+ length = world_db["MAP_LENGTH"]
+ if not world_db["soundmap"]:
+ m = bytearray(b' ' * (length ** 2))
+ else:
+ m = world_db["soundmap"]
+ m[val * length:(val * length) + length] = mapline.encode()
+ if not world_db["soundmap"]:
+ world_db["soundmap"] = m
+
+