mirror of
https://github.com/zeldaret/tww.git
synced 2026-06-17 14:56:48 -04:00
Fix BOW_JNT ambiguity in res_arc.py script
This commit is contained in:
@@ -217,19 +217,19 @@ enum BOTTLECAP_JNT {
|
||||
BOTTLECAP_JNT_BOTTLECAP_e=0x0,
|
||||
};
|
||||
|
||||
enum BOW_JNT {
|
||||
BOW_JNT_CL_BOW_e=0x0,
|
||||
BOW_JNT_BOW_JNT_e=0x1,
|
||||
BOW_JNT_AA_JNT_e=0x2,
|
||||
BOW_JNT_AB_JNT_e=0x3,
|
||||
BOW_JNT_ACJNT_e=0x4,
|
||||
BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
BOW_JNT_BA_JNT_e=0x7,
|
||||
BOW_JNT_BB_JNT_e=0x8,
|
||||
BOW_JNT_BC_JNT_e=0x9,
|
||||
BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
enum LINK_BOW_JNT {
|
||||
LINK_BOW_JNT_CL_BOW_e=0x0,
|
||||
LINK_BOW_JNT_BOW_JNT_e=0x1,
|
||||
LINK_BOW_JNT_AA_JNT_e=0x2,
|
||||
LINK_BOW_JNT_AB_JNT_e=0x3,
|
||||
LINK_BOW_JNT_ACJNT_e=0x4,
|
||||
LINK_BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
LINK_BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
LINK_BOW_JNT_BA_JNT_e=0x7,
|
||||
LINK_BOW_JNT_BB_JNT_e=0x8,
|
||||
LINK_BOW_JNT_BC_JNT_e=0x9,
|
||||
LINK_BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
LINK_BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
};
|
||||
|
||||
enum CAMERA_JNT {
|
||||
|
||||
@@ -122,4 +122,4 @@ enum PZ_JNT {
|
||||
PZ_JNT_SKIRT_3_e=0x1A,
|
||||
};
|
||||
|
||||
#endif /* !RES_PZ_H */
|
||||
#endif /* !RES_PZ_H */
|
||||
@@ -217,19 +217,19 @@ enum BOTTLECAP_JNT {
|
||||
BOTTLECAP_JNT_BOTTLECAP_e=0x0,
|
||||
};
|
||||
|
||||
enum BOW_JNT {
|
||||
BOW_JNT_CL_BOW_e=0x0,
|
||||
BOW_JNT_BOW_JNT_e=0x1,
|
||||
BOW_JNT_AA_JNT_e=0x2,
|
||||
BOW_JNT_AB_JNT_e=0x3,
|
||||
BOW_JNT_ACJNT_e=0x4,
|
||||
BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
BOW_JNT_BA_JNT_e=0x7,
|
||||
BOW_JNT_BB_JNT_e=0x8,
|
||||
BOW_JNT_BC_JNT_e=0x9,
|
||||
BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
enum LINK_BOW_JNT {
|
||||
LINK_BOW_JNT_CL_BOW_e=0x0,
|
||||
LINK_BOW_JNT_BOW_JNT_e=0x1,
|
||||
LINK_BOW_JNT_AA_JNT_e=0x2,
|
||||
LINK_BOW_JNT_AB_JNT_e=0x3,
|
||||
LINK_BOW_JNT_ACJNT_e=0x4,
|
||||
LINK_BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
LINK_BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
LINK_BOW_JNT_BA_JNT_e=0x7,
|
||||
LINK_BOW_JNT_BB_JNT_e=0x8,
|
||||
LINK_BOW_JNT_BC_JNT_e=0x9,
|
||||
LINK_BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
LINK_BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
};
|
||||
|
||||
enum CAMERA_JNT {
|
||||
|
||||
@@ -122,4 +122,4 @@ enum PZ_JNT {
|
||||
PZ_JNT_SKIRT_3_e=0x1A,
|
||||
};
|
||||
|
||||
#endif /* !RES_PZ_H */
|
||||
#endif /* !RES_PZ_H */
|
||||
@@ -217,19 +217,19 @@ enum BOTTLECAP_JNT {
|
||||
BOTTLECAP_JNT_BOTTLECAP_e=0x0,
|
||||
};
|
||||
|
||||
enum BOW_JNT {
|
||||
BOW_JNT_CL_BOW_e=0x0,
|
||||
BOW_JNT_BOW_JNT_e=0x1,
|
||||
BOW_JNT_AA_JNT_e=0x2,
|
||||
BOW_JNT_AB_JNT_e=0x3,
|
||||
BOW_JNT_ACJNT_e=0x4,
|
||||
BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
BOW_JNT_BA_JNT_e=0x7,
|
||||
BOW_JNT_BB_JNT_e=0x8,
|
||||
BOW_JNT_BC_JNT_e=0x9,
|
||||
BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
enum LINK_BOW_JNT {
|
||||
LINK_BOW_JNT_CL_BOW_e=0x0,
|
||||
LINK_BOW_JNT_BOW_JNT_e=0x1,
|
||||
LINK_BOW_JNT_AA_JNT_e=0x2,
|
||||
LINK_BOW_JNT_AB_JNT_e=0x3,
|
||||
LINK_BOW_JNT_ACJNT_e=0x4,
|
||||
LINK_BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
LINK_BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
LINK_BOW_JNT_BA_JNT_e=0x7,
|
||||
LINK_BOW_JNT_BB_JNT_e=0x8,
|
||||
LINK_BOW_JNT_BC_JNT_e=0x9,
|
||||
LINK_BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
LINK_BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
};
|
||||
|
||||
enum CAMERA_JNT {
|
||||
|
||||
@@ -122,4 +122,4 @@ enum PZ_JNT {
|
||||
PZ_JNT_SKIRT_3_e=0x1A,
|
||||
};
|
||||
|
||||
#endif /* !RES_PZ_H */
|
||||
#endif /* !RES_PZ_H */
|
||||
@@ -217,19 +217,19 @@ enum BOTTLECAP_JNT {
|
||||
BOTTLECAP_JNT_BOTTLECAP_e=0x0,
|
||||
};
|
||||
|
||||
enum BOW_JNT {
|
||||
BOW_JNT_CL_BOW_e=0x0,
|
||||
BOW_JNT_BOW_JNT_e=0x1,
|
||||
BOW_JNT_AA_JNT_e=0x2,
|
||||
BOW_JNT_AB_JNT_e=0x3,
|
||||
BOW_JNT_ACJNT_e=0x4,
|
||||
BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
BOW_JNT_BA_JNT_e=0x7,
|
||||
BOW_JNT_BB_JNT_e=0x8,
|
||||
BOW_JNT_BC_JNT_e=0x9,
|
||||
BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
enum LINK_BOW_JNT {
|
||||
LINK_BOW_JNT_CL_BOW_e=0x0,
|
||||
LINK_BOW_JNT_BOW_JNT_e=0x1,
|
||||
LINK_BOW_JNT_AA_JNT_e=0x2,
|
||||
LINK_BOW_JNT_AB_JNT_e=0x3,
|
||||
LINK_BOW_JNT_ACJNT_e=0x4,
|
||||
LINK_BOW_JNT_LINEAA_JNT_e=0x5,
|
||||
LINK_BOW_JNT_LINEAB_JNT_e=0x6,
|
||||
LINK_BOW_JNT_BA_JNT_e=0x7,
|
||||
LINK_BOW_JNT_BB_JNT_e=0x8,
|
||||
LINK_BOW_JNT_BC_JNT_e=0x9,
|
||||
LINK_BOW_JNT_LINEBA_JNT_e=0xA,
|
||||
LINK_BOW_JNT_LINEBB_JNT_e=0xB,
|
||||
};
|
||||
|
||||
enum CAMERA_JNT {
|
||||
|
||||
@@ -122,4 +122,4 @@ enum PZ_JNT {
|
||||
PZ_JNT_SKIRT_3_e=0x1A,
|
||||
};
|
||||
|
||||
#endif /* !RES_PZ_H */
|
||||
#endif /* !RES_PZ_H */
|
||||
@@ -24,10 +24,10 @@ BOOL daPy_lk_c::bowJointCB(int param_0) {
|
||||
|
||||
if (param_0 == 6) {
|
||||
mDoMtx_stack_c::transS(0.0f, 4.5f, 4.5f);
|
||||
mDoMtx_stack_c::revConcat(mpEquipItemModel->getAnmMtx(BOW_JNT_LINEAB_JNT_e));
|
||||
mDoMtx_stack_c::revConcat(mpEquipItemModel->getAnmMtx(LINK_BOW_JNT_LINEAB_JNT_e));
|
||||
mpEquipItemModel->setAnmMtx(param_0, mDoMtx_stack_c::get());
|
||||
} else {
|
||||
mpEquipItemModel->setAnmMtx(BOW_JNT_LINEBB_JNT_e, mpEquipItemModel->getAnmMtx(BOW_JNT_LINEAB_JNT_e));
|
||||
mpEquipItemModel->setAnmMtx(LINK_BOW_JNT_LINEBB_JNT_e, mpEquipItemModel->getAnmMtx(LINK_BOW_JNT_LINEAB_JNT_e));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -223,12 +223,12 @@ void daPy_lk_c::setBowModel() {
|
||||
}
|
||||
mDoExt_setCurrentHeap(oldHeap);
|
||||
m35EC = 0.0f;
|
||||
J3DMaterial* lineMat_mtl = mpEquipItemModel->getModelData()->getJointNodePointer(BOW_JNT_CL_BOW_e)->getMesh()->getNext();
|
||||
J3DMaterial* lineMat_mtl = mpEquipItemModel->getModelData()->getJointNodePointer(LINK_BOW_JNT_CL_BOW_e)->getMesh()->getNext();
|
||||
J3DMaterial* lineDamMAT_mtl = lineMat_mtl->getNext();
|
||||
lineMat_mtl->getShape()->show();
|
||||
lineDamMAT_mtl->getShape()->hide();
|
||||
tmp_modelData->getJointNodePointer(BOW_JNT_LINEAB_JNT_e)->setCallBack(daPy_bowJointCB);
|
||||
tmp_modelData->getJointNodePointer(BOW_JNT_LINEBB_JNT_e)->setCallBack(daPy_bowJointCB);
|
||||
tmp_modelData->getJointNodePointer(LINK_BOW_JNT_LINEAB_JNT_e)->setCallBack(daPy_bowJointCB);
|
||||
tmp_modelData->getJointNodePointer(LINK_BOW_JNT_LINEBB_JNT_e)->setCallBack(daPy_bowJointCB);
|
||||
mpEquipItemModel->setUserArea(reinterpret_cast<u32>(this));
|
||||
}
|
||||
|
||||
|
||||
+22
-12
@@ -32,6 +32,10 @@ SKIP_FILES_WITH_AT_SIGN = True
|
||||
# get when this file was modified last, used to detect if we should re-extract enums
|
||||
THIS_MTIME = Path(__file__).stat().st_mtime
|
||||
|
||||
AMBIGUOUS_JOINT_ENUM_NAMES = [
|
||||
"BOW_JNT",
|
||||
]
|
||||
|
||||
class ArcFile(NamedTuple):
|
||||
file_name:str
|
||||
index:int
|
||||
@@ -81,7 +85,7 @@ def make_enum(e:ArcEnum):
|
||||
|
||||
return out_enum
|
||||
|
||||
def parse_bmd(src_path:Path):
|
||||
def parse_bmd(src_path:Path, arc_name: str):
|
||||
global ADD_EXT_TO_ENUM
|
||||
with src_path.open("rb") as binf:
|
||||
header_magic = binf.read(4)
|
||||
@@ -109,6 +113,9 @@ def parse_bmd(src_path:Path):
|
||||
else:
|
||||
out_enum_name = sanitize_string(src_path.name.split(".")[0]).upper() + "_JNT"
|
||||
|
||||
if out_enum_name in AMBIGUOUS_JOINT_ENUM_NAMES:
|
||||
out_enum_name = arc_name + "_" + out_enum_name
|
||||
|
||||
for i in range(num_strings):
|
||||
binf.seek(name_table + 6 + i * 4)
|
||||
string_offset = read_u16(binf)
|
||||
@@ -122,18 +129,21 @@ def parse_bmd(src_path:Path):
|
||||
return None
|
||||
|
||||
def extract_joint_enums(src_path:Path):
|
||||
if ((SKIP_FILES_WITH_AT_SIGN and "@" in str(src_path)) or
|
||||
if ((SKIP_FILES_WITH_AT_SIGN and "@" in str(src_path)) or
|
||||
(SKIP_STAGE_ARCS and "Stage" in src_path.parts) or
|
||||
(SKIP_DEMO_ARCS and any(x.startswith("Demo") for x in src_path.parts))):
|
||||
return JointParsedEnums([])
|
||||
|
||||
file_stem = src_path.name.split(".")[0]
|
||||
arc_name = sanitize_string(file_stem.upper())
|
||||
|
||||
out_jnt_enums:list[ArcEnum] = []
|
||||
internal_files = subprocess.run([DTK_PATH, "vfs", "ls", "-r", f"{src_path}:"], stdout=subprocess.PIPE, text=True).stdout
|
||||
output_folder = Path(str(src_path).replace(".", "__"))
|
||||
for line in internal_files.split("\n"):
|
||||
parts = line.split(" | ")
|
||||
if len(parts) != 3: continue
|
||||
|
||||
|
||||
internal_file = parts[1].strip(" ")
|
||||
internal_file_parts = internal_file.split(".")
|
||||
if len(internal_file_parts) < 2: continue
|
||||
@@ -151,14 +161,14 @@ def extract_joint_enums(src_path:Path):
|
||||
ensure_dir(internal_file_path.parent)
|
||||
subprocess.run([DTK_PATH, "vfs", "cp", f"{src_path}:{internal_file}", internal_file_path], stdout=subprocess.PIPE)
|
||||
|
||||
out_enums = parse_bmd(internal_file_path)
|
||||
out_enums = parse_bmd(internal_file_path, arc_name)
|
||||
assert out_enums is not None
|
||||
|
||||
out_jnt_enums.append(out_enums)
|
||||
|
||||
return JointParsedEnums(out_jnt_enums)
|
||||
|
||||
def convert_binary_to_resource_enum(src_path: Path, dest_path: Path) -> None:
|
||||
def convert_binary_to_resource_enum(src_path: Path, dest_path: Path) -> None:
|
||||
joint_enums = extract_joint_enums(src_path)
|
||||
|
||||
with src_path.open("rb") as binf:
|
||||
@@ -212,10 +222,10 @@ def convert_binary_to_resource_enum(src_path: Path, dest_path: Path) -> None:
|
||||
|
||||
out_lines:list[str] = []
|
||||
file_stem = src_path.name.split(".")[0]
|
||||
file_stem_upper = sanitize_string(file_stem.upper())
|
||||
arc_name = sanitize_string(file_stem.upper())
|
||||
|
||||
out_lines.append(f"#ifndef RES_{file_stem_upper}_H")
|
||||
out_lines.append(f"#define RES_{file_stem_upper}_H\n")
|
||||
out_lines.append(f"#ifndef RES_{arc_name}_H")
|
||||
out_lines.append(f"#define RES_{arc_name}_H\n")
|
||||
|
||||
out_ids:list[str] = []
|
||||
out_idxs:list[str] = []
|
||||
@@ -235,7 +245,7 @@ def convert_binary_to_resource_enum(src_path: Path, dest_path: Path) -> None:
|
||||
if len(parts) > 1:
|
||||
ext = sanitize_string(parts[1].upper())
|
||||
|
||||
file_str = f"{file_stem_upper}_{ext}_{santitized_file_name}"
|
||||
file_str = f"{arc_name}_{ext}_{santitized_file_name}"
|
||||
|
||||
idx = f"dRes_INDEX_{file_str}"
|
||||
seen_count = appearance_count[idx]
|
||||
@@ -253,18 +263,18 @@ def convert_binary_to_resource_enum(src_path: Path, dest_path: Path) -> None:
|
||||
out_idxs.append(f"{INDENT}{idx}_e=0x{file.index:X},")
|
||||
out_ids.append(f"{INDENT}{id}_e=0x{file.id:X},")
|
||||
|
||||
out_lines.append(f"enum dRes_INDEX_{file_stem_upper} {{")
|
||||
out_lines.append(f"enum dRes_INDEX_{arc_name} {{")
|
||||
out_lines.extend(out_idxs)
|
||||
out_lines.append("};\n")
|
||||
|
||||
out_lines.append(f"enum dRes_ID_{file_stem_upper} {{")
|
||||
out_lines.append(f"enum dRes_ID_{arc_name} {{")
|
||||
out_lines.extend(out_ids)
|
||||
out_lines.append("};\n")
|
||||
|
||||
for joint_enum in joint_enums.enums:
|
||||
out_lines.append(make_enum(joint_enum) + "\n")
|
||||
|
||||
out_lines.append(f"#endif /* !RES_{file_stem_upper}_H */")
|
||||
out_lines.append(f"#endif /* !RES_{arc_name}_H */")
|
||||
|
||||
out = "\n".join(out_lines)
|
||||
ensure_dir(dest_path.parent)
|
||||
|
||||
Reference in New Issue
Block a user