mirror of
https://github.com/Wesley-DeMontigny/WLUS.git
synced 2026-02-09 03:28:37 -06:00
VE now has all of its game objects. Server no longer runs through the GUI because it was slowing everything down
76 lines
1.7 KiB
Python
76 lines
1.7 KiB
Python
from bitstream import *
|
|
|
|
def readOffsetBitstream(data, arg, offset, allocatedLength=33):
|
|
x = BitStream(data[offset:])
|
|
value = x.read(arg, allocated_length=allocatedLength)
|
|
return value
|
|
|
|
def getFormatName(x):
|
|
if(x == 0):
|
|
return "Variable String"
|
|
if(x == 1):
|
|
return "Signed Long"
|
|
if(x == 2):
|
|
return "Signed Long"
|
|
if(x == 3):
|
|
return "Float"
|
|
if(x == 4):
|
|
return "Double"
|
|
if(x == 5):
|
|
return "Unsigned Long"
|
|
if(x == 6):
|
|
return "Unsigned Long"
|
|
if(x == 7):
|
|
return "Boolean"
|
|
if(x == 8):
|
|
return "Signed Long Long"
|
|
if(x == 9):
|
|
return "Signed Long Long"
|
|
if(x == 13):
|
|
return "XML"
|
|
return "???"
|
|
|
|
#This function is from lcdr util
|
|
#All I really use it for is for debugging
|
|
def from_ldf(ldf):
|
|
ldf_dict = {}
|
|
if isinstance(ldf, BitStream):
|
|
for _ in range(ldf.read(c_uint)):
|
|
encoded_key = ldf.read(bytes, length=ldf.read(c_ubyte))
|
|
key = encoded_key.decode("utf-16-le")
|
|
data_type_id = ldf.read(c_ubyte)
|
|
if data_type_id == 0:
|
|
value = ldf.read(str, length_type=c_uint)
|
|
elif data_type_id == 1:
|
|
value = ldf.read(c_int)
|
|
elif data_type_id == 3:
|
|
value = ldf.read(c_float)
|
|
elif data_type_id == 5:
|
|
value = ldf.read(c_uint)
|
|
elif data_type_id == 7:
|
|
value = ldf.read(c_bool)
|
|
elif data_type_id in (8, 9):
|
|
value = ldf.read(c_int64)
|
|
elif data_type_id == 13:
|
|
value = ldf.read(bytes, length=ldf.read(c_uint))
|
|
else:
|
|
raise NotImplementedError(key, data_type_id)
|
|
ldf_dict[key] = data_type_id, value
|
|
else:
|
|
pass
|
|
|
|
return ldf_dict
|
|
|
|
#Get LDF from lvl files
|
|
def from_lvlLDF(ldf):
|
|
ldf_dict = {}
|
|
keySets = ldf.split("\n")
|
|
for x in keySets:
|
|
key = x.split("=")[0]
|
|
value = x.split(":")[1]
|
|
ldf_dict[key] = value
|
|
return ldf_dict
|
|
|
|
|
|
|