-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add support for currently spectated ghost #7
base: main
Are you sure you want to change the base?
Conversation
Internal/Impl.as
Outdated
#if TMNEXT | ||
if (vis is null) { | ||
auto gameTerminal = GetGameTerminal(); | ||
if (gameTerminal !is null) { | ||
auto type = Reflection::GetType("CGameTerminal"); | ||
if (type !is null) { | ||
auto offset = type.GetMember("MediaAmbianceClipPlayer").Offset + 0x68; | ||
bool isWatchingGhost = Dev::GetOffsetUint8(gameTerminal, offset) > 0; | ||
auto ghostVisEntId = Dev::GetOffsetUint32(gameTerminal, offset + 0x4); | ||
if (isWatchingGhost && ghostVisEntId & 0x04000000 > 0) { | ||
@vis = GetVis(sceneVis, ghostVisEntId); | ||
} | ||
} | ||
} | ||
} | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of problems here:
- Types and member offsets are not cached, this causes unnecessary overhead
- This offset of
+ 0x68
is in my opinion too large to use reliably as it will introduce a lot of new maintenance work - we should consider requesting Nadeo for a native property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types and member offsets are not cached, this causes unnecessary overhead
Yep, obvs easily fixable.
This offset of + 0x68 is in my opinion too large to use reliably as it will introduce a lot of new maintenance work - we should consider requesting Nadeo for a native property
Yeah okay. I agree it's large enough that it might get updated, but I disagree with the maintenance cost.
- There is no chance of a crash since the offset is well within CGameTerminal's in-memory size and no pointers are followed.
- There are 2 checks (note: updated the first one), the bool == 1 and the 0x04000000 bit is set on the 'entity ID'. even after that, nothing will be returned from the other methods if no ent id matches.
So the worst that happens is the feature stops working. In rare cases it might use an incorrect ent ID.
The overhead for updating the offset is just opening the game terminal in cheat engine and watching for somewhere near that offset that changes in the way that's expected, which is like a 5 minute job.
I'm not sure if I'm missing anything about why it would be high-overhead tho (wrt maintenance). I'm not counting openplanet releases, tho, so mb that's it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I agree with asking nadeo for an exposed property btw, that is easily the best solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest maintenance overhead is actually finding out that it is broken. We currently do not have any automated tests in place to detect when these things are broken (unlike some built-in Openplanet stuff). It would be nice to get some kind of test suite for all of these dev things so they can be caught early whenever a game update comes out.
Alternate solution for #4.
I noticed that there was an entity ID set under game terminal which is the current ghost you're spectating. it's 0 otherwise. Additionally there's a flag right before it that's true/false depending on whether you're watching a ghost or not.