mirror of
https://github.com/qwerfd2/Groove_Coaster_2_Server.git
synced 2026-10-04 12:48:09 +03:00
fix
This commit is contained in:
@@ -23,7 +23,7 @@ def read_byte(f):
|
||||
|
||||
def parse_pak_file(file_path, output_xlsx):
|
||||
with open(file_path, "rb") as f:
|
||||
num_elements = read_int_old(f, 2)
|
||||
num_elements = read_int_old(f, 2) # Read header (2 bytes)
|
||||
data = []
|
||||
|
||||
for _ in range(num_elements):
|
||||
@@ -39,12 +39,7 @@ def parse_pak_file(file_path, output_xlsx):
|
||||
"String4": read_string(f),
|
||||
"String5": read_string(f),
|
||||
"String6": read_string(f),
|
||||
"Field5": read_int(f),
|
||||
"Float1": read_int(f, 1),
|
||||
"Float2": read_int(f, 1),
|
||||
"Float3": read_int(f, 1),
|
||||
"Float4": read_int(f, 1),
|
||||
"Field6": read_byte(f),
|
||||
"Field5": read_int(f, 9),
|
||||
"Field7": read_byte(f),
|
||||
"Field8": read_int(f),
|
||||
"Field9": read_byte(f),
|
||||
@@ -76,13 +71,9 @@ def parse_pak_file(file_path, output_xlsx):
|
||||
"Field35": read_int(f),
|
||||
"Field36": read_int(f),
|
||||
"Field37": read_int(f),
|
||||
"Field38": read_byte(f)
|
||||
"Field38": read_int(f, 2)
|
||||
}
|
||||
# This is a hack (not derived from IDA) but there are discrepancies here that can be addressed this way
|
||||
if (entry["String5"] != "" or entry["String6"] != "" ):
|
||||
entry["Field39"] = read_int(f)
|
||||
|
||||
entry["Field40"] = read_byte(f)
|
||||
|
||||
data.append(entry)
|
||||
|
||||
df = pd.DataFrame(data)
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
Converts player.dat to and from xlsx sheets.
|
||||
|
||||
The data format is definitely not 100% correct here, and there is a bodge to address the 4 redundant bytes on the first few rows.
|
||||
|
||||
But it works!
|
||||
@@ -3,7 +3,7 @@ import pandas as pd
|
||||
|
||||
def write_string(f, s):
|
||||
if pd.isna(s):
|
||||
f.write(struct.pack("B", 0))
|
||||
f.write(struct.pack("B", 0)) # Write 00 if string is empty
|
||||
else:
|
||||
encoded = s.encode("utf-8")
|
||||
f.write(struct.pack("B", len(encoded)))
|
||||
@@ -14,7 +14,7 @@ def write_int(f, value, size=4):
|
||||
|
||||
def write_byte(f, value):
|
||||
if pd.isna(value):
|
||||
f.write(struct.pack("B", 0))
|
||||
f.write(struct.pack("B", 0)) # Write 00 if string is empty
|
||||
else:
|
||||
f.write(bytes.fromhex(value))
|
||||
|
||||
@@ -23,7 +23,7 @@ def convert_xlsx_to_dat(input_xlsx, output_dat):
|
||||
|
||||
with open(output_dat, "wb") as f:
|
||||
num_elements = len(df)
|
||||
write_int(f, f"{num_elements:04X}", 2)
|
||||
write_int(f, f"{num_elements:04X}", 2) # Header (2 bytes for number of elements)
|
||||
|
||||
for _, row in df.iterrows():
|
||||
write_int(f, row["Field1"])
|
||||
@@ -37,11 +37,6 @@ def convert_xlsx_to_dat(input_xlsx, output_dat):
|
||||
write_string(f, row["String5"])
|
||||
write_string(f, row["String6"])
|
||||
write_int(f, row["Field5"])
|
||||
write_byte(f, row["Float1"])
|
||||
write_byte(f, row["Float2"])
|
||||
write_byte(f, row["Float3"])
|
||||
write_byte(f, row["Float4"])
|
||||
write_byte(f, row["Field6"])
|
||||
write_byte(f, row["Field7"])
|
||||
write_int(f, row["Field8"])
|
||||
write_byte(f, row["Field9"])
|
||||
@@ -75,9 +70,5 @@ def convert_xlsx_to_dat(input_xlsx, output_dat):
|
||||
write_int(f, row["Field37"])
|
||||
write_byte(f, row["Field38"])
|
||||
|
||||
if pd.notna(row.get("Field39")):
|
||||
write_int(f, row["Field39"])
|
||||
|
||||
write_byte(f, row["Field40"])
|
||||
|
||||
convert_xlsx_to_dat("player.xlsx", "out_player.dat")
|
||||
|
||||
Reference in New Issue
Block a user