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

lots of AreaObj.* functions #23

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

whaleymar
Copy link
Contributor

@whaleymar whaleymar commented Mar 8, 2024

pasted PR comment from the other repo:

This covers

  • Reversed AreaObjDirector's methods and fixed some errors in its header
  • AreaObjFactory header + reversed both methods
  • Headers for AreaObjMtxConnecter and AreaObjMtxConnecterHolder
  • 2 inlined functions in Factory to get AreaObj + AreaObjDirector stuff matching
  • Headers for area objects used in the factory (includes TrafficArea, CameraStartParam, SeBarrierArea, SePlayArea, ViewCtrlArea, BirdGatheringSpotArea, ExtForceArea, ForceRecoveryKidsArea, MoveArea2D, NpcForceMaterialCodeArea, RouteGuideArea, and StainArea)
  • ProjectAreaFactory header and a non-matching constructor

Things to sanity check:

  • AreaObjDirector::getAreaObjGroup did not match when using the inlined _getAreaObjGroup. Instead, it only matches when I paste the exact same code into the public method. Inlining the binary search was necessary for several functions to match, but having 2 identical functions feels wrong.
  • I don't know if I defined BirdGatheringSpotArea::AreaClippingInfo in the right spot

This change is Reviewable

@whaleymar
Copy link
Contributor Author

I'll deal with the linting stuff later I'm going to bed

@MonsterDruide1
Copy link
Owner

Alright, I'll review when the linter is (mostly) fixed.

Copy link
Owner

@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.

Reviewed 2 of 29 files at r1, 26 of 26 files at r2.
Reviewable status: 28 of 29 files reviewed, 26 unresolved discussions (waiting on @whaleymar)


lib/al/include/Library/Area/AreaInitInfo.h line 6 at r2 (raw file):

namespace al {
class PlacementInfo;

It has to be included either way (to be able to inherit from it), so this is useless.


lib/al/include/Library/Area/AreaInitInfo.h line 12 at r2 (raw file):

class AreaInitInfo : public PlacementInfo {
public:
    AreaInitInfo(){};

Defining it in the header means that the function is not generated in the binary. As this constructor does exist in the game, this seems wrong.


lib/al/include/Library/Area/AreaObj.h line 25 at r2 (raw file):

    virtual void init(const AreaInitInfo& initInfo);
    virtual bool isInVolume(const sead::Vector3f& position) const;
    virtual bool isInVolumeOffset(const sead::Vector3f&, f32 offset) const;

Naming this as position for consistency across the functions?

Code quote:

const sead::Vector3f&

lib/al/include/Library/Area/AreaObjDirector.h line 37 at r2 (raw file):

    u32 mAreaGroupCount = 0;

    AreaObjGroup* _getAreaObjGroup(const char* name) const {

I don't think this belongs in the header, but I'll do some experiments later.


lib/al/include/Library/Area/AreaObjMtxConnecter.h line 41 at r2 (raw file):

private:
    MtxConnector** mMtxConnectors;

Isn't this a al::AreaObjMtxConnecter**?


lib/al/include/Library/Area/TrafficArea.h line 17 at r2 (raw file):

    bool mNpcFull = false;
    bool mNpcUnavailable = false;
    char mUnkChar = '\0';

Considering the above is mNpcUnavailable, this should probably be bool mCarUnavailable.


lib/al/include/Library/Factory/Factory.h line 35 at r2 (raw file):

    s32 getNumFactoryEntries() const { return mNumFactoryEntries; }

    s32 getEntryIndex(const char* entryName, T* creationPtr) const {

If that still matches, I would prefer to swap the two parameters to have T*, const char*. Other functions in this game have it that way around (out, in1, in2, ...).


lib/al/include/Library/Play/Area/ViewCtrlArea.h line 4 at r2 (raw file):

#include "Library/Area/AreaObj.h"
#include "Library/Placement/PlacementId.h"

Do not include, but just declare as class PlacementId;


lib/al/src/Library/Area/AreaObj.cpp line 44 at r2 (raw file):

    mAreaShape->setBaseMtxPtr(&mMatrixTR);
    sead::Vector3f scale({1.0, 1.0, 1.0});

sead::Vector3f scale = {1.0, 1.0, 1.0}; for consistency with = nullptr from above


lib/al/src/Library/Area/AreaObjDirector.cpp line 19 at r2 (raw file):

    mMtxConnecterHolder = new AreaObjMtxConnecterHolder(0x100);
    s32 nFactoryEntries = mFactory->getNumFactoryEntries();
    s32 areaGroupsSize = nFactoryEntries;

Is this double-copying required?


lib/al/src/Library/Area/AreaObjDirector.cpp line 79 at r2 (raw file):

void AreaObjDirector::createAreaObjGroupBuffer() {
    for (s32 i = 0; i < mFactory->getAreaGroupCount(); i++) {
        AreaGroupInfo* addBuffer = mFactory->getAreaGroupInfo() + i;

Ugly pointer arithmetic.
Suggestion: AreaGroupInfo& addBuffer = mFactory->getAreaGroupInfo()[i];, if that matches.


lib/al/src/Library/Area/AreaObjDirector.cpp line 108 at r2 (raw file):

void AreaObjDirector::placementAreaObj(const AreaInitInfo& initInfo) {
    PlacementInfo pInfo(initInfo);

Should not be required, I think - just using initInfo everywhere should be fine, as it is the superclass


lib/al/src/Library/Area/AreaObjDirector.cpp line 127 at r2 (raw file):

        areaObj->init(initInfo2);

        AreaObjGroup* areaGroup = _getAreaObjGroup(pInfoName);

Maybe calling getAreaObjGroup instead, removing the need for _getAreaObjGroup in the first place?


lib/al/src/Library/Area/AreaObjDirector.cpp line 135 at r2 (raw file):

AreaObjGroup* AreaObjDirector::getAreaObjGroup(const char* name) const {
    // return _getAreaObjGroup(name); // doesn't match

(see above)


lib/al/src/Library/Area/AreaObjDirector.cpp line 152 at r2 (raw file):

bool AreaObjDirector::isExistAreaGroup(const char* name) const {
    return _getAreaObjGroup(name) != nullptr;

(see above)


lib/al/src/Library/Area/AreaObjDirector.cpp line 156 at r2 (raw file):

AreaObj* AreaObjDirector::getInVolumeAreaObj(const char* name, const sead::Vector3f& position) {
    AreaObjGroup* areaGroup = _getAreaObjGroup(name);

(see above)


lib/al/src/Library/Area/AreaObjFactory.cpp line 19 at r2 (raw file):

            return 0;
    }
    return mAreaGroupInfo[offset].size;

Using a for-loop instead?

for (s32 i=0; i<mNumBuffers; i++) {
  if (isEqualString(...)) return mAreaGroupInfo[offset].size;
}
return 0;

Code quote:

    s32 offset = 0;
    while (!isEqualString(bufferName, mAreaGroupInfo[offset].name)) {
        if (++offset >= mNumBuffers)
            return 0;
    }
    return mAreaGroupInfo[offset].size;

lib/al/src/Library/Area/AreaObjGroup.cpp line 10 at r2 (raw file):

void AreaObjGroup::createBuffer() {
    if (mCapacity < 1) {

Is this required, or does it auto-generate?


lib/al/src/Library/Area/AreaObjGroup.cpp line 40 at r2 (raw file):

void AreaObjGroup::incrementCount() {
    mCapacity += 1;

Uhh, are you sure about this?


src/AreaObj/BirdGatheringSpotArea.h line 23 at r2 (raw file):

    void init(const al::AreaInitInfo& initInfo) override;

    void calcRandomGroundTrans(sead::Vector3f trans) const;

sead::Vector3f*


src/AreaObj/ExtForceArea.h line 11 at r2 (raw file):

    void init(const al::AreaInitInfo& areaInitInfo) override;

    void calcExtForce(sead::Vector3f, sead::Vector3f, sead::Vector3f, sead::Vector3f);

Pointers for all of them


src/AreaObj/ForceRecoveryKidsArea.h line 3 at r2 (raw file):

#pragma once

#include <math/seadVectorFwd.h>

Should be normal seadVector.h, not Fwd


src/AreaObj/MoveArea2D.h line 3 at r2 (raw file):

#pragma once

#include <math/seadVectorFwd.h>

seadVector.h


src/AreaObj/RouteGuideArea.h line 3 at r2 (raw file):

#pragma once

#include <math/seadVectorFwd.h>

seadVector.h


src/Scene/ProjectAreaFactory.cpp line 3 at r2 (raw file):

#include "Scene/ProjectAreaFactory.h"

#include "AreaObj/BirdGatheringSpotArea.h"

See linter: Swap the blocks


src/Scene/ProjectAreaFactory.cpp line 169 at r2 (raw file):

static al::AreaGroupInfo sAreaGroupInfo[] = {{"GraphicsArea", 1}};

// not matching

decomp.me?

@whaleymar
Copy link
Contributor Author

lib/al/src/Library/Area/AreaObjGroup.cpp line 40 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Uhh, are you sure about this?

we've been over this one before odyssey-modding/odyssey#19 (comment)

Copy link
Contributor Author

@whaleymar whaleymar 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: 28 of 29 files reviewed, 26 unresolved discussions (waiting on @MonsterDruide1)


lib/al/include/Library/Area/AreaInitInfo.h line 6 at r2 (raw file):

Previously, MonsterDruide1 wrote…

It has to be included either way (to be able to inherit from it), so this is useless.

Done.


lib/al/include/Library/Area/AreaInitInfo.h line 12 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Defining it in the header means that the function is not generated in the binary. As this constructor does exist in the game, this seems wrong.

idk what I was on


lib/al/include/Library/Area/AreaObj.h line 25 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Naming this as position for consistency across the functions?

Done.


lib/al/include/Library/Area/AreaObjDirector.h line 37 at r2 (raw file):

Previously, MonsterDruide1 wrote…

I don't think this belongs in the header, but I'll do some experiments later.

is gone


lib/al/include/Library/Area/AreaObjMtxConnecter.h line 41 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Isn't this a al::AreaObjMtxConnecter**?

yup


lib/al/include/Library/Area/TrafficArea.h line 17 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Considering the above is mNpcUnavailable, this should probably be bool mCarUnavailable.

Done.


lib/al/include/Library/Factory/Factory.h line 35 at r2 (raw file):

Previously, MonsterDruide1 wrote…

If that still matches, I would prefer to swap the two parameters to have T*, const char*. Other functions in this game have it that way around (out, in1, in2, ...).

Done.


lib/al/include/Library/Play/Area/ViewCtrlArea.h line 4 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Do not include, but just declare as class PlacementId;

Done.


lib/al/src/Library/Area/AreaObj.cpp line 44 at r2 (raw file):

Previously, MonsterDruide1 wrote…

sead::Vector3f scale = {1.0, 1.0, 1.0}; for consistency with = nullptr from above

Done.


lib/al/src/Library/Area/AreaObjDirector.cpp line 19 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Is this double-copying required?

nope idk why I did that


lib/al/src/Library/Area/AreaObjDirector.cpp line 79 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Ugly pointer arithmetic.
Suggestion: AreaGroupInfo& addBuffer = mFactory->getAreaGroupInfo()[i];, if that matches.

works


lib/al/src/Library/Area/AreaObjDirector.cpp line 108 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Should not be required, I think - just using initInfo everywhere should be fine, as it is the superclass

doesn't match


lib/al/src/Library/Area/AreaObjDirector.cpp line 127 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Maybe calling getAreaObjGroup instead, removing the need for _getAreaObjGroup in the first place?

that worked i feel so dumb


lib/al/src/Library/Area/AreaObjDirector.cpp line 135 at r2 (raw file):

Previously, MonsterDruide1 wrote…

(see above)

Done.


lib/al/src/Library/Area/AreaObjDirector.cpp line 152 at r2 (raw file):

Previously, MonsterDruide1 wrote…

(see above)

Done.


lib/al/src/Library/Area/AreaObjDirector.cpp line 156 at r2 (raw file):

Previously, MonsterDruide1 wrote…

(see above)

Done.


lib/al/src/Library/Area/AreaObjFactory.cpp line 19 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Using a for-loop instead?

for (s32 i=0; i<mNumBuffers; i++) {
  if (isEqualString(...)) return mAreaGroupInfo[offset].size;
}
return 0;

not very close to matching


lib/al/src/Library/Area/AreaObjGroup.cpp line 10 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Is this required, or does it auto-generate?

required.


src/AreaObj/BirdGatheringSpotArea.h line 23 at r2 (raw file):

Previously, MonsterDruide1 wrote…

sead::Vector3f*

Done.


src/AreaObj/ExtForceArea.h line 11 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Pointers for all of them

const + references for vectors 2, 3, and 4


src/AreaObj/ForceRecoveryKidsArea.h line 3 at r2 (raw file):

Previously, MonsterDruide1 wrote…

Should be normal seadVector.h, not Fwd

Done.


src/AreaObj/MoveArea2D.h line 3 at r2 (raw file):

Previously, MonsterDruide1 wrote…

seadVector.h

Done.


src/AreaObj/RouteGuideArea.h line 3 at r2 (raw file):

Previously, MonsterDruide1 wrote…

seadVector.h

Done.


src/Scene/ProjectAreaFactory.cpp line 3 at r2 (raw file):

Previously, MonsterDruide1 wrote…

See linter: Swap the blocks

Done.


src/Scene/ProjectAreaFactory.cpp line 169 at r2 (raw file):

Previously, MonsterDruide1 wrote…

decomp.me?

is genning an empty function, not entirely sure why. Decompme is timing out I'll try again later

Copy link
Owner

@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.

Reviewed 13 of 15 files at r3.
Reviewable status: 26 of 29 files reviewed, 4 unresolved discussions


lib/al/src/Library/Area/AreaObjGroup.cpp line 10 at r2 (raw file):

Previously, whaleymar (whaley) wrote…

required.

Alright, then just leave it like that.


src/AreaObj/ExtForceArea.h line 11 at r2 (raw file):

Previously, whaleymar (whaley) wrote…

const + references for vectors 2, 3, and 4

Alright, I just noticed that pass-by-value seems wrong, without checking further. Thanks for confirming.

Copy link
Owner

@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.

Reviewable status: 26 of 29 files reviewed, 3 unresolved discussions (waiting on @whaleymar)


lib/al/src/Library/Area/AreaObjDirector.cpp line 108 at r2 (raw file):

Previously, whaleymar (whaley) wrote…

doesn't match

Hmm, weird, but I can't get a better match either.


lib/al/src/Library/Area/AreaObjFactory.cpp line 19 at r2 (raw file):

Previously, whaleymar (whaley) wrote…

not very close to matching

Missed the reference to offset, which should've been changed to i:

s32 AreaObjFactory::tryFindAddBufferSize(const char* bufferName) const {
    if (mAreaGroupInfo == nullptr || mNumBuffers < 1)
        return 0;

    for (s32 i=0; i<mNumBuffers; i++) {
        if (isEqualString(bufferName, mAreaGroupInfo[i].name))
            return mAreaGroupInfo[i].size;
    }
    return 0;
}

This matches for me.


lib/al/src/Library/Area/AreaObjGroup.cpp line 40 at r2 (raw file):

Previously, whaleymar (whaley) wrote…

we've been over this one before odyssey-modding/odyssey#19 (comment)

I mean... is there something wrong about my logic here, or does increasing the mCapacity here mean that more objects can be added in registerAreaObj than actually allowed, so the game can write out-of-bounds?

If my line of thought is correct, we might want to keep track of stuff like that as a starting point for research, in case anyone might want to look into trying to find some ROP/ACE entry points - or just a collection to point out what N does wrong sometimes in general.


src/Scene/ProjectAreaFactory.cpp line 169 at r2 (raw file):

Previously, whaleymar (whaley) wrote…

is genning an empty function, not entirely sure why. Decompme is timing out I'll try again later

Change the CSV to contain C1 instead of C2, that will give you the function. It doesn't match and I'm not able to get a proper match though, but please do make that change and mark it as one of the mismatching states for a better tracking.

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