Skip to content

Conversation

@Thar0
Copy link
Contributor

@Thar0 Thar0 commented Jun 7, 2025

Many files still unnamed, help wanted

@fig02 fig02 mentioned this pull request Jun 8, 2025
Copy link
Contributor

@AngheloAlf AngheloAlf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense for massive objects like gameplay_keep to keep headers separated, so actors can only include what they use.

What kind of help are you looking for?

@@ -660,7 +665,7 @@ def write_source(self):
referenced_file,
)
assert hasattr(referenced_file, "source_h_path")
file_include_paths_complete.append(referenced_file.source_h_path)
file_include_paths_complete.append(strip_extracted_prefix(referenced_file.source_h_path))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

referenced_file.source_h_path is the path to the generated .h, including the leading extracted/VERSION/
so currently the #includes of other assets in generated source look like

#include "extracted/gc-eu-mq-dbg/assets/objects/gameplay_keep/gameplay_keep.h"

instead of

#include "assets/objects/gameplay_keep/gameplay_keep.h"

(see eg extracted/gc-eu-mq-dbg/assets/objects/object_fish/object_fish.c)

this is a fix/workaround for that behavior

@Dragorn421
Copy link
Collaborator

Dragorn421 commented Jun 8, 2025

That's a lot of work done already ( 👏 ) and there's a lot to unpack
Thoughts on making subfolders of gkeep?
For example put together arrow_anims.c (maybe further split into each anim) and arrow_skel.c into an "arrow" folder with a single "arrow.h" ?

I made a little script for renaming gkeep files:

Usage: any of

./rename_gkeepfile.py assets/objects/gameplay_keep/gameplay_keep_0x3A150.h flat_rot_block_model
./rename_gkeepfile.py gameplay_keep_0x3A150.h flat_rot_block_model
./rename_gkeepfile.py gameplay_keep_0x3A150 flat_rot_block_model
#!/usr/bin/env python3

# SPDX-FileCopyrightText: 2024 Dragorn421
# SPDX-License-Identifier: CC0-1.0

import argparse
from pathlib import Path


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("from_name")
    parser.add_argument("to_name")
    args = parser.parse_args()

    from_name = Path(args.from_name).stem
    to_name = Path(args.to_name).stem

    p = Path("assets/objects/gameplay_keep") / from_name
    h_p = p.with_suffix(".h")

    lines = h_p.read_text().splitlines(keepends=True)
    assert lines[0].startswith("#ifndef ")
    assert lines[1].startswith("#define ")
    include_guard = "GAMEPLAY_KEEP_" + to_name.upper() + "_H"
    h_p.write_text(
        "".join(
            [
                f"#ifndef {include_guard}\n",
                f"#define {include_guard}\n",
            ]
            + lines[2:]
        )
    )

    h_p.rename(p.with_name(f"{to_name}.h"))
    p.with_suffix(".c").rename(p.with_name(f"{to_name}.c"))

    from_name = from_name.encode()
    to_name = to_name.encode()

    for root_p in (
        Path("src"),
        Path("include"),
        Path("assets"),
        Path("spec"),
    ):
        for dir_p, dirnames, filenames in root_p.walk():
            for filename in filenames:
                file_p = dir_p / filename
                contents = file_p.read_bytes()
                if from_name in contents:
                    contents_new = contents.replace(from_name, to_name)
                    file_p.write_bytes(contents_new)


if __name__ == "__main__":
    main()

@Dragorn421
Copy link
Collaborator

I made some commits naming a few more things (feel free to force-push them away if you don't like them)

Copy link
Collaborator

@Dragorn421 Dragorn421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the gArrowSkelLimbN, gDoorSkelLimbN, gFairySkelLimbN, gFishSkelLimbN, gBugSkelLimbN names final?
If not I'd like to name them Limb_N (with an underscore), as I've been using "has an underscore in the name" as a heuristic for "is undocumented"

@Thar0
Copy link
Contributor Author

Thar0 commented Jun 9, 2025

Limb names are not final, I just needed to rename them in at least one xml to avoid ifdefs, and figured I'd do something at least better than "gameplay_keep_0x..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants