Formats/Common:LOC

From SSX Modding Wiki
Jump to navigation Jump to search

LOC File (Localization/Language File)

Overview

An LOC file contains most of the text used in the games. They're consistent across games, other than a new section and the amount of null terminated UTF16 characters for the strings.

An LOC file is divide into three sections, one of them only available in some games

LOCH (Unofficial name: LOC Header)

This section lives on top of the file. It doesn't do much other than hold the offset for the LOCL section.

struct LOCH {
    char Magic[4]; // "LOCH"
    le u32 Size; // Always 20
    le u32 Unk0;
    le u32 Unk1;
    le u32 LoclOffset;
};

LOCT (Unofficial name: LOC Table)

LOCT stores a hash table for UI elements.

This section appears in the games SSX3, SSX OnTour, and SSX Blur. The games SSX 2000, and SSX Tricky ignore this part and proceed as if LOCL was this section.

struct LOCT {
    char Magic[4]; // "LOCT"
    le u32 HeaderSize; // Always 16
    le float Unk0;
    le u32 Unk1;
    HashData HashTable[]; // Size is LOCL.TextEntryCount
}

struct HashData {
    le u32 Hash;
    le u32 ID; // The index of the text entry in LOCL
}

LOCL (Unofficial name: LOC Language)

This section holds almost all text data. It keeps a count of how many UTF16 strings there are, and an array with offsets to them.

The Strings are UTF16 null terminated, each character takes 2 bytes. The number of null termination characters is inconsistent across games. They vary from 1 to 4 characters long, and at times have an extra one at the end of the section.

struct LOCL {
    char Magic[4]; // "LOCL"
    le u32 Size;
    le u32 Unk0;
    le u32 TextEntryCount;
    le u32 TextEntryOffsets[TextEntryCount]; // Offsets are relative to the start of LOCL
    String TextEntries[TextEntryCount];
};

struct String {
    le char16 Text[];
    
    // The number of terminations varies from 1 to 4.
    // For SSX Tricky, 2 nulls are standard.
    le char16 Termination[]; 
};