Skip to content

prim: Add specific RTTI implementation for mods#251

Open
Fuzzy2319 wants to merge 2 commits into
open-ead:masterfrom
Fuzzy2319:sead-target
Open

prim: Add specific RTTI implementation for mods#251
Fuzzy2319 wants to merge 2 commits into
open-ead:masterfrom
Fuzzy2319:sead-target

Conversation

@Fuzzy2319
Copy link
Copy Markdown
Contributor

@Fuzzy2319 Fuzzy2319 commented Mar 5, 2026

This PR add specific RTTI implementation for mods that allow the modding framework to call game functions instead of redefining them in your mod. To use this feature, you have to define SEAD_TARGET to 2 and then use SEAD_RTTI_BASE_CUSTOM or SEAD_RTTI_OVERRIDE_CUSTOM in your mod headers.


This change is Reviewable

Copy link
Copy Markdown
Contributor

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

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

@MonsterDruide1 reviewed 2 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on Fuzzy2319).


include/prim/seadRuntimeTypeInfo.h line 182 at r2 (raw file):

                this->BASE::checkDerivedRuntimeTypeInfo(typeInfo)) ?                               \
                   this :                                                                          \
                   nullptr;                                                                        \

Why did you move this from the main SEAD_RTTI macro into this one?

Code quote:

        return (checkDerivedRuntimeTypeInfoStatic(typeInfo) ||                                     \
                this->BASE::checkDerivedRuntimeTypeInfo(typeInfo)) ?                               \
                   this :                                                                          \
                   nullptr;                                                                        \

include/prim/seadRuntimeTypeInfo.h line 207 at r2 (raw file):

    {                                                                                              \
        return checkDerivedRuntimeTypeInfoStatic(typeInfo) ||                                      \
               this->BASE::checkDerivedRuntimeTypeInfo(typeInfo);                                  \

same here

Code quote:

        return checkDerivedRuntimeTypeInfoStatic(typeInfo) ||                                      \
               this->BASE::checkDerivedRuntimeTypeInfo(typeInfo);                                  \

include/prim/seadRuntimeTypeInfo.h line 262 at r2 (raw file):

    {                                                                                              \
        const sead::RuntimeTypeInfo::Interface* clsTypeInfo = CLASS::getRuntimeTypeInfoStatic();   \
        return typeInfo == clsTypeInfo;                                                            \

(this is the location I would have expected the BASE:: check)

Code quote:

        const sead::RuntimeTypeInfo::Interface* clsTypeInfo = CLASS::getRuntimeTypeInfoStatic();   \
        return typeInfo == clsTypeInfo;                                                            \

Copy link
Copy Markdown
Contributor Author

@Fuzzy2319 Fuzzy2319 left a comment

Choose a reason for hiding this comment

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

@Fuzzy2319 made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on MonsterDruide1).


include/prim/seadRuntimeTypeInfo.h line 182 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Why did you move this from the main SEAD_RTTI macro into this one?

checkDerivedRuntimeTypeInfoStatic is defined in the header, it is inlined and never appear in the base game so I moved the check here for compatibilty reasons between a class that uses SEAD_RTTI_BASE and a class with SEAD_RTTI_OVERRIDE_CUSTOM


include/prim/seadRuntimeTypeInfo.h line 207 at r2 (raw file):

Previously, MonsterDruide1 wrote…

same here

same as above


include/prim/seadRuntimeTypeInfo.h line 262 at r2 (raw file):

Previously, MonsterDruide1 wrote…

(this is the location I would have expected the BASE:: check)

I can't do the base check here because this function is static, I can't use this in a static context.

Copy link
Copy Markdown
Contributor

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

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

@MonsterDruide1 made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on Fuzzy2319).


include/prim/seadRuntimeTypeInfo.h line 262 at r2 (raw file):

Previously, Fuzzy2319 wrote…

I can't do the base check here because this function is static, I can't use this in a static context.

You should still be able to use BASE::, as it's a template parameter.

Copy link
Copy Markdown
Contributor Author

@Fuzzy2319 Fuzzy2319 left a comment

Choose a reason for hiding this comment

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

@Fuzzy2319 made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on MonsterDruide1).


include/prim/seadRuntimeTypeInfo.h line 262 at r2 (raw file):

Previously, MonsterDruide1 wrote…

You should still be able to use BASE::, as it's a template parameter.

yes but that would cause incompatibility between a class that uses SEAD_RTTI_BASE and a class with SEAD_RTTI_OVERRIDE_CUSTOM for exemple: In SMO, I want to make a custom message, al::SensorMsg use SEAD_RTTI_BASE my custom message extends that class and use SEAD_RTTI_OVERRIDE_CUSTOM, if I can't do the check here because checkDerivedRuntimeTypeInfoStatic doesn't exist for the parent class

Copy link
Copy Markdown
Contributor

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

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

@MonsterDruide1 made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on Fuzzy2319).


include/prim/seadRuntimeTypeInfo.h line 262 at r2 (raw file):

Previously, Fuzzy2319 wrote…

yes but that would cause incompatibility between a class that uses SEAD_RTTI_BASE and a class with SEAD_RTTI_OVERRIDE_CUSTOM for exemple: In SMO, I want to make a custom message, al::SensorMsg use SEAD_RTTI_BASE my custom message extends that class and use SEAD_RTTI_OVERRIDE_CUSTOM, if I can't do the check here because checkDerivedRuntimeTypeInfoStatic doesn't exist for the parent class

Ah, oh. I see. Why not use Base::checkDerivedRuntimeTypeInfo(...) (non-static version) instead?

Copy link
Copy Markdown
Contributor Author

@Fuzzy2319 Fuzzy2319 left a comment

Choose a reason for hiding this comment

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

@Fuzzy2319 made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on MonsterDruide1).


include/prim/seadRuntimeTypeInfo.h line 262 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Ah, oh. I see. Why not use Base::checkDerivedRuntimeTypeInfo(...) (non-static version) instead?

I don't understand your comment. I can't access an instance method without an instance object and checkDerivedRuntimeTypeInfoStatic is static so I can't use this and no instance are passed to the function. That's why I moved the call in the non-static function.

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