Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LayoutResourceMgr #130

Merged
merged 1 commit into from
Oct 20, 2024
Merged

Conversation

Pistonight
Copy link
Contributor

@Pistonight Pistonight commented Aug 8, 2024

All LayoutResourceMgr functions should match except for 3 that depend on eui which are undecompiled
Needs open-ead/sead#143 for sead::EnvUtil::getRegion
Needs #129 for nn::pl - then the forward decl I added temporarily can be deleted


Also sorted data_symbols.py by address and added a script to do that


This change is Reviewable

@Pistonight Pistonight changed the title LayoutResourceMgr (WIP) LayoutResourceMgr Aug 11, 2024
@Pistonight Pistonight marked this pull request as ready for review August 11, 2024 02:12
@leoetlino
Copy link
Collaborator

sorry for the delay in reviewing this! could you rebase and fix the build failure?

@Pistonight
Copy link
Contributor Author

sorry for the delay in reviewing this! could you rebase and fix the build failure?

Need open-ead/nnheaders#33 for one extra function, I will rebase again with the lib update

@Pistonight Pistonight force-pushed the layout_resource_mgr branch 4 times, most recently from 137f40f to 1fdcd46 Compare September 7, 2024 17:10
Copy link
Collaborator

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 3 files at r6, 1 of 4 files at r7, 2 of 6 files at r11, 2 of 4 files at r12, 1 of 1 files at r16, 1 of 3 files at r17, 2 of 3 files at r18, all commit messages.
Reviewable status: 10 of 12 files reviewed, 10 unresolved discussions (waiting on @Pistonight)


src/KingSystem/ksys.h line 21 at r18 (raw file):

// 0x0000007100f3a8d8
void preInitializeApp(InitParams* params);

can this be a const ref instead of a pointer?


src/KingSystem/ksys.cpp line 35 at r18 (raw file):

void preInitializeApp(InitParams* params) {
    ksys::BasicProfiler::push("ksys::PreInitializeApp");

nit: could you use ksys::BasicProfiler::Scope instead of pushing/popping manually?


src/KingSystem/System/UI/ArcResourceMgr.h line 20 at r18 (raw file):

    virtual void sub_10();
    virtual void loadArchive(sead::ExpHeap* heap, const sead::SafeString& path);

are you sure this takes an ExpHeap and not a Heap? I'd be inclined to make this a Heap unless there's evidence that we need to use an ExpHeap (e.g. calling an ExpHeap member function).


src/KingSystem/System/UI/LayoutResourceMgr.h line 15 at r18 (raw file):

namespace ksys::ui {

class LayoutResourceMgr final : sead::hostio::Node {

public sead::hostio::Node


src/KingSystem/System/UI/LayoutResourceMgr.h line 96 at r18 (raw file):

};
KSYS_CHECK_SIZE_NX150(LayoutResourceMgr, 0x168);
constexpr const char* sExtraLangFontFiles[LayoutResourceMgr::cExtraLangCount *

can this be moved to the .cpp?


src/KingSystem/System/UI/LayoutResourceMgr.cpp line 156 at r18 (raw file):

    if (mVersionHandle->isReady()) {
        auto* resource = sead::DynamicCast<sead::DirectResource>(mVersionHandle->getResource());
        instance()->mVersionString.copy(reinterpret_cast<const char*>(resource->getRawData()),

wait what? they used the singleton instance pointer instead of just... setting mVersionString directly? lol


src/KingSystem/System/UI/LayoutResourceMgr.cpp line 214 at r18 (raw file):

bool LayoutResourceMgr::loadHorseLayoutResource() {
    sead::ScopedLock<sead::CriticalSection> lock(&mCriticalSection);

nit: use sead::makeScopedLock so you don't have to write sead::ScopedLock<sead::CriticalSection>

(ideally this would be sead::ScopedLock lock(...) but CTAD is a C++17 feature that unfortunately isn't implemented in Clang 4.0...)


src/KingSystem/System/UI/LayoutResourceMgr.cpp line 228 at r18 (raw file):

bool LayoutResourceMgr::unloadHorseLayout() {
    sead::ScopedLock<sead::CriticalSection> lock(&mCriticalSection);

nit: sead::makeScopedLock


src/KingSystem/System/UI/LayoutResourceMgr.cpp line 240 at r18 (raw file):

bool LayoutResourceMgr::loadArcResource(Archive& archive, const char* name) {
    if (!archive.getResource()) {

nit: can we invert some of these if statements to return early?


tools/format_data_symbols.py line 13 at r18 (raw file):

            if not line:
                continue
            hex = "0x" + (line[2:18].upper())

the parsing is a bit rough here heh - consider using the (built-in) csv module?

Copy link
Contributor Author

@Pistonight Pistonight left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 of 12 files reviewed, 8 unresolved discussions (waiting on @leoetlino)


src/KingSystem/System/UI/ArcResourceMgr.h line 20 at r18 (raw file):

Previously, leoetlino (Léo Lam) wrote…

are you sure this takes an ExpHeap and not a Heap? I'd be inclined to make this a Heap unless there's evidence that we need to use an ExpHeap (e.g. calling an ExpHeap member function).

It's only used in new and assigning to sead::ResourceMgr::LoadArg. Will change to Heap


src/KingSystem/System/UI/LayoutResourceMgr.h line 15 at r18 (raw file):

Previously, leoetlino (Léo Lam) wrote…

public sead::hostio::Node

Done.


src/KingSystem/System/UI/LayoutResourceMgr.h line 96 at r18 (raw file):

Previously, leoetlino (Léo Lam) wrote…

can this be moved to the .cpp?

Done.


src/KingSystem/System/UI/LayoutResourceMgr.cpp line 156 at r18 (raw file):

Previously, leoetlino (Léo Lam) wrote…

wait what? they used the singleton instance pointer instead of just... setting mVersionString directly? lol

yes, I checked specifically using mVersionString does not match


tools/format_data_symbols.py line 13 at r18 (raw file):

Previously, leoetlino (Léo Lam) wrote…

the parsing is a bit rough here heh - consider using the (built-in) csv module?

Done.

Copy link
Contributor Author

@Pistonight Pistonight left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 of 12 files reviewed, 7 unresolved discussions (waiting on @leoetlino)


src/KingSystem/ksys.h line 21 at r18 (raw file):

Previously, leoetlino (Léo Lam) wrote…

can this be a const ref instead of a pointer?

Yeah, doesn't look like it's mutated in the function


src/KingSystem/System/UI/LayoutResourceMgr.cpp line 240 at r18 (raw file):

Previously, leoetlino (Léo Lam) wrote…

nit: can we invert some of these if statements to return early?

Simplied 1 level of nesting

@leoetlino leoetlino self-requested a review October 18, 2024 16:21
Copy link
Collaborator

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 3 files at r18, 5 of 5 files at r19, 3 of 3 files at r20, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Pistonight)

@leoetlino leoetlino merged commit aa3914c into zeldaret:master Oct 20, 2024
4 checks passed
@Pistonight Pistonight deleted the layout_resource_mgr branch November 1, 2024 01:30
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.

2 participants