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

Active Game Camera Detection #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

XertroV
Copy link

@XertroV XertroV commented Apr 21, 2023

Fixes #1

Here is a PR for a first review.

I've been running this code for a week and it seems reliable in all situations. I had some monitoring code (excluded from PR) in there to check for crashes due to this code and it seems like no crashes during that time were due to the code in the PR.

I left in some debug stuff so you can easily test it if you want.

Oh, I also added some code to expose camera rotation and stuff direction since I needed it for a thing. Might also worth be exposing rotation at the same time?

@XertroV XertroV requested a review from codecat April 21, 2023 04:43
Copy link
Member

@codecat codecat left a comment

Choose a reason for hiding this comment

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

Thanks for the research into this! I'm not really comfortable merging this until we have more of an understanding of what we're really doing here.

Additionally, I want to move the visual managers API from VehicleState to Openplanet itself, as it seems to be useful here, as well.

Main.as Outdated Show resolved Hide resolved
ExportShared.as Show resolved Hide resolved
Impl.as Outdated Show resolved Hide resolved
Main.as Outdated Show resolved Hide resolved
CamDetection.as Outdated
Comment on lines 26 to 30
auto camModelNod = Dev::GetOffsetNod(gameCameraNod, 0x58);
auto camControlNod = Dev::GetOffsetNod(gameCameraNod, 0x68);

// Always 4 when backwards, and seemingly always 0 otherwise
bool isBackwards = Dev::GetOffsetUint32(gameCameraNod, 0xB0) == 0x4;
Copy link
Member

Choose a reason for hiding this comment

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

Couple things: gameCameraNod is not a "nod", so that could be a bit confusing. In fact, this structure is NGameCamera_SCamSys, which is part of NGameCamera_SMgr.

This will crash the game on startup if any of these pointers are not valid (this function will be called every frame). That's not necessarily a bad thing (we have a killswitch at any time for these situations). But these offsets are deep enough that I'm not sure if I'm comfortable having them in there as it increases the maintenance burden quite a bit.

For starters, we might want to get the SCamSys structure using the visual managers (well defined in VehicleState, but might wanna move this to Openplanet's main API) instead of getting it from some random offset in the game.

Copy link
Author

Choose a reason for hiding this comment

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

Ahh cool, yeah getting it via managers seems better (I just used the shortest pointer path).

The .GameScene + 0x10 offset pointed to a .GameCamera object in MP4 (mb turbo too, cant remember), so I felt okay about it but if openplanet adds managers support then that definitely seems the best way.

I also found a pointer at .GameTerminals[0] + 0x28 which might be an alternative (than .GameScene + 0x10). I haven't looked at NGameCamera_SMgr much, though I'm curious to see a buffer of NGameCamera_SCamSys under the mgr (I wonder if it's ever >1, might try splitscreen and check it out).

Copy link
Author

Choose a reason for hiding this comment

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

I confirmed there are 2 SCamSys in splitscreen and the current method still worked fine.

Might it be possible to add manager support to the next openplanet version? If so, I can update to use that when there's an edge build.

CamDetection.as Outdated Show resolved Hide resolved
CamDetection.as Outdated Show resolved Hide resolved
CamDetection.as Outdated Show resolved Hide resolved
CamDetection.as Outdated Show resolved Hide resolved
@XertroV XertroV requested a review from codecat July 23, 2023 05:53
@XertroV
Copy link
Author

XertroV commented Jul 23, 2023

Updated the code and addressed most/all comments, ready for re-review

Comment on lines +26 to +34
auto camModelNod = Dev::GetOffsetNod(gameCameraNod, 0x58);
auto camControlNod = Dev::GetOffsetNod(gameCameraNod, 0x68);
// 0x1 for std, 0x2 for alt.
bool cam1Alt = Dev::GetOffsetUint8(gameCameraNod, 0x24) == 0x2;
bool cam2Alt = Dev::GetOffsetUint8(gameCameraNod, 0x25) == 0x2;
bool cam3Alt = Dev::GetOffsetUint8(gameCameraNod, 0x26) == 0x2;

// Always 4 when backwards, and seemingly always 0 otherwise
bool isBackwards = Dev::GetOffsetUint32(gameCameraNod, 0xB0) == 0x4;
Copy link
Member

@codecat codecat Jul 23, 2023

Choose a reason for hiding this comment

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

Still not a fan of all these offsets tbh. Have you checked these offsets across game updates? How stable are they?

I'm afraid that Nadeo is going to release an update and make these offsets moot, and we will be forced to spend a long time on updating the offsets, or finding different methods of getting this information, or maybe we even need to remove the feature altogether. (And maybe only 1 plugin will ever need to use this functionality.)

This is my general view of using the Dev API btw, nothing specifically against this. I'm just wondering how stable it is, because it will add a lot of maintenance work. (Perhaps we need a checklist that we manually go through every game update.)

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.

Camera Detection
2 participants