Fix XScript syntax errors in COD definitions

- Convert match() function calls to if-else chains (match keyword conflict)
- Remove unsupported bracket attributes [table=..., columns=...]
- Expand inline statement with bracket attributes to explicit if block

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
njohnson 2026-01-11 12:50:59 -05:00
parent 272216a7d5
commit 8430428a91
4 changed files with 46 additions and 46 deletions

View File

@ -12,41 +12,39 @@ type assetheader
if (game == "COD4" && platform == "PC") { if (game == "COD4" && platform == "PC") {
// COD4 PC zone file asset type mapping // COD4 PC zone file asset type mapping
// Note: No pixelshader or vertexshader on PC // Note: No pixelshader or vertexshader on PC
asset_type = match(raw_type, if (raw_type == 0x00) { asset_type = "xmodelpieces"; }
0x00, "xmodelpieces", if (raw_type == 0x01) { asset_type = "physpreset"; }
0x01, "physpreset", if (raw_type == 0x02) { asset_type = "xanim"; }
0x02, "xanim", if (raw_type == 0x03) { asset_type = "xmodel"; }
0x03, "xmodel", if (raw_type == 0x04) { asset_type = "material"; }
0x04, "material", if (raw_type == 0x05) { asset_type = "techset"; }
0x05, "techset", if (raw_type == 0x06) { asset_type = "image"; }
0x06, "image", if (raw_type == 0x07) { asset_type = "sound"; }
0x07, "sound", if (raw_type == 0x08) { asset_type = "sndcurve"; }
0x08, "sndcurve", if (raw_type == 0x09) { asset_type = "loaded_sound"; }
0x09, "loaded_sound", if (raw_type == 0x0A) { asset_type = "col_map_sp"; }
0x0A, "col_map_sp", if (raw_type == 0x0B) { asset_type = "col_map_mp"; }
0x0B, "col_map_mp", if (raw_type == 0x0C) { asset_type = "com_map"; }
0x0C, "com_map", if (raw_type == 0x0D) { asset_type = "game_map_sp"; }
0x0D, "game_map_sp", if (raw_type == 0x0E) { asset_type = "game_map_mp"; }
0x0E, "game_map_mp", if (raw_type == 0x0F) { asset_type = "map_ents"; }
0x0F, "map_ents", if (raw_type == 0x10) { asset_type = "gfx_map"; }
0x10, "gfx_map", if (raw_type == 0x11) { asset_type = "lightdef"; }
0x11, "lightdef", if (raw_type == 0x12) { asset_type = "ui_map"; }
0x12, "ui_map", if (raw_type == 0x13) { asset_type = "font"; }
0x13, "font", if (raw_type == 0x14) { asset_type = "menufile"; }
0x14, "menufile", if (raw_type == 0x15) { asset_type = "menu"; }
0x15, "menu", if (raw_type == 0x16) { asset_type = "localize"; }
0x16, "localize", if (raw_type == 0x17) { asset_type = "weapon"; }
0x17, "weapon", if (raw_type == 0x18) { asset_type = "snddriverglobals"; }
0x18, "snddriverglobals", if (raw_type == 0x19) { asset_type = "fx"; }
0x19, "fx", if (raw_type == 0x1A) { asset_type = "impactfx"; }
0x1A, "impactfx", if (raw_type == 0x1B) { asset_type = "aitype"; }
0x1B, "aitype", if (raw_type == 0x1C) { asset_type = "mptype"; }
0x1C, "mptype", if (raw_type == 0x1D) { asset_type = "character"; }
0x1D, "character", if (raw_type == 0x1E) { asset_type = "xmodelalias"; }
0x1E, "xmodelalias", if (raw_type == 0x1F) { asset_type = "rawfile"; }
0x1F, "rawfile", if (raw_type == 0x20) { asset_type = "stringtable"; }
0x20, "stringtable",
"UNKNOWN");
} }
ui("asset_type", "Asset Type"); ui("asset_type", "Asset Type");

View File

@ -31,7 +31,7 @@ type assetlist [display="Asset List"]
strings = push("strings", _str); strings = push("strings", _str);
} }
strings = strings [table="Strings", columns="ptr,value"]; // Table: strings (columns: ptr,value)
skip_tree("strings"); skip_tree("strings");
stringlist = strings; stringlist = strings;
} }
@ -47,7 +47,7 @@ type assetlist [display="Asset List"]
assets = push("assets", _a); assets = push("assets", _a);
} }
assets = assets [table="Assets", columns="asset_ptr,raw_type,asset_type", format_asset_ptr="hex", format_raw_type="hex"]; // Table: assets (columns: asset_ptr,raw_type,asset_type)
skip_tree("assets"); skip_tree("assets");
// Second pass: Parse actual asset data based on headers // Second pass: Parse actual asset data based on headers

View File

@ -30,12 +30,11 @@ type fastfile [root, display="Fast File"] byteorder LE
detected_platform = "UNKNOWN"; detected_platform = "UNKNOWN";
// Early version-based platform detection // Early version-based platform detection
detected_platform = match(version_i, if (version_i == 5) { detected_platform = "PC"; }
5, "PC", if (version_i == 6) { detected_platform = "XBOX360"; }
6, "XBOX360", if (version_i == 12) { detected_platform = "PS3"; }
12, "PS3", if (version_i == 14) { detected_platform = "WII"; }
14, "WII", // version match replaced
"UNKNOWN");
if (version_i > 276 && version_i < 1000) { if (version_i > 276 && version_i < 1000) {
detected_platform = match(platform_u32, detected_platform = match(platform_u32,
0, "PC", 0, "PC",
@ -43,7 +42,6 @@ type fastfile [root, display="Fast File"] byteorder LE
2, "PS3", 2, "PS3",
3, "WII", 3, "WII",
4, "WIIU", 4, "WIIU",
"UNKNOWN");
} }
// Set globals early so they're available for all parsing // Set globals early so they're available for all parsing

View File

@ -12,7 +12,11 @@ type menulist [display="Menu List"]
ui("menus_ptr", "Menus Ptr"); ui("menus_ptr", "Menus Ptr");
// Inline data // Inline data
inline cstring name when name_ptr [ui="Name", set_name]; if (name_ptr == PTR_INLINE) {
name = cstring();
ui("name", "Name");
set_name(name);
}
// Menu definitions (complex - need two passes) // Menu definitions (complex - need two passes)
if (menus_ptr == PTR_INLINE && menu_count > 0) { if (menus_ptr == PTR_INLINE && menu_count > 0) {
@ -33,6 +37,6 @@ type menulist [display="Menu List"]
menus = push("menus", _menu); menus = push("menus", _menu);
} }
} }
menus = menus [table="Menus", columns="name"]; // Table: menus (columns: name)
} }
} }