Fix loc packer to use int based string ids (static mode)

This commit is contained in:
Pyogenics 2026-03-07 13:16:19 +00:00 committed by JuiceyDev
parent 8ed5a8440c
commit a624c136fb
2 changed files with 12 additions and 6 deletions

View file

@ -113,7 +113,7 @@ colour_table = custom_target('Minecraft.Client_Colour_Table',
movies_path = meson.current_source_dir() / 'Build/Assets/movies'
archive_sources = [
meson.current_source_dir() / 'Platform/Windows64Media/Media/languages.loc',
localisation, #meson.current_source_dir() / 'Platform/Windows64Media/Media/languages.loc',
colour_table,
asset_dir / 'splashes.txt',
asset_dir / 'graphics\SaveChest.png',

View file

@ -74,9 +74,9 @@ for lang_file_path in lang_file_paths:
print(f"Processed {len(langs)} languages")
# Write loc file
# TODO: allow switching version and handle actually writing those versions
TARGET_LOC_VERSION = 0
TARGET_LANG_VERSION = 0
TARGET_LANG_VERSION = 1
TARGET_LANG_STATIC = True
with open(output_file_path, "wb") as loc_file:
# Write header
pack_stream(">2I", loc_file,
@ -93,13 +93,19 @@ with open(output_file_path, "wb") as loc_file:
# Write header
pack_stream(">I", lang_stream, TARGET_LANG_VERSION) # version
if TARGET_LANG_VERSION > 0:
pack_stream("?", lang_stream, TARGET_LANG_STATIC)
write_string(lang_name, lang_stream) # lang name
pack_stream(">I", lang_stream, len(strings)) # string count
# Write strings
for string_name, string in strings.items():
write_string(string_name, lang_stream)
write_string(string, lang_stream)
if TARGET_LANG_STATIC:
for string in strings.values():
write_string(string, lang_stream)
else:
for string_name, string in strings.items():
write_string(string_name, lang_stream)
write_string(string, lang_stream)
lang_sizes[lang_name] = lang_stream.tell() - old_stream_pos