Util: Implement PlayerPuppetFunction - #1316
Conversation
0d28879 to
0e5d872
Compare
Match all 82 functions in PlayerPuppetFunction.o: the rs:: player-puppet utility wrappers around IUsePlayerPuppet and the concrete PlayerPuppet. Notable supporting changes: - Member-accessing wrappers cast IUsePlayerPuppet* to PlayerPuppet*; add the corresponding accessors and name the previously-placeholder flag members (mIsValidLookAt/ForceLookAt/SeparateMode/RecoveryArea/ GuideArrow/WaterSurfaceShadow, mIsInvalidReceivePush, mIsCopyDitherAlpha, mForceLookAtDir, mJudgePreInputJump). - Add the BindKeepDemoInfo struct. - PlayerInput::getStickMoveRaw now returns sead::Vector2f by value; it was declared as a const reference, but the function returns it in s0/s1, and the by-value return is required for rs::getPuppetMoveStick to match. - Carve a bool flag out of PlayerEffect for rs::clearStainEffect. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0e5d872 to
204c822
Compare
Util/PlayerPuppetFunction.o
Util/PlayerPuppetFunction.oPlayerPuppetFunction
MonsterDruide1
left a comment
There was a problem hiding this comment.
@MonsterDruide1 reviewed 6 files and all commit messages, and made 12 comments.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on c4nvm).
src/Util/PlayerPuppetFunction.cpp line 32 at r1 (raw file):
sead::Vector3f mTrans; sead::Quatf mQuat; };
[..]Info and no functions usually means it's a struct - the difference between class and struct is never visible, but this project follows the rule of "classes may never have member variables as public". So if things usually access the members directly instead of going through a getter, it's a struct.
Suggestion:
struct BindKeepDemoInfo {
bool mIsActive = false;
sead::Vector3f mTrans = {0.0f, 0.0f, 0.0f};
sead::Quatf mQuat = sead::Quatf::unit;
};src/Util/PlayerPuppetFunction.cpp line 132 at r1 (raw file):
return true; } return false;
Suggestion:
if (!al::isMsgBindCancel(msg))
return false;
*playerPuppet = nullptr;
return true;src/Util/PlayerPuppetFunction.cpp line 145 at r1 (raw file):
bool tryStartBindKeepDemo(BindKeepDemoInfo* bindKeepDemoInfo, const al::SensorMsg* msg, const IUsePlayerPuppet* playerPuppet) { if (isMsgBindKeepDemoStart(msg)) {
Flip this condition
src/Util/PlayerPuppetFunction.cpp line 153 at r1 (raw file):
playerPuppet->calcFront(&front); playerPuppet->calcUp(&up); al::makeQuatUpFront(quat, up, front);
Suggestion:
calcPuppetQuat(&bindKeepDemoInfo->mQuat, playerPuppet);src/Util/PlayerPuppetFunction.cpp line 161 at r1 (raw file):
bool tryEndBindKeepDemo(BindKeepDemoInfo* bindKeepDemoInfo, const al::SensorMsg* msg, IUsePlayerPuppet* playerPuppet) { if (isMsgBindKeepDemoEnd(msg)) {
Flip this condition
src/Util/PlayerPuppetFunction.cpp line 166 at r1 (raw file):
bindKeepDemoInfo->mIsActive = false; bindKeepDemoInfo->mTrans.set(0.0f, 0.0f, 0.0f); bindKeepDemoInfo->mQuat.set(1.0f, 0.0f, 0.0f, 0.0f);
might mismatch, please report if it does
Suggestion:
bindKeepDemoInfo->mTrans = {0.0f, 0.0f, 0.0f};
bindKeepDemoInfo->mQuat = {1.0f, 0.0f, 0.0f, 0.0f};src/Util/PlayerPuppetFunction.cpp line 402 at r1 (raw file):
void setPuppetFront(IUsePlayerPuppet* playerPuppet, const sead::Vector3f& front) { sead::Vector3f up(0.0f, 0.0f, 0.0f);
Suggestion:
sead::Vector3f up = {0.0f, 0.0f, 0.0f};src/Util/PlayerPuppetFunction.cpp line 410 at r1 (raw file):
void setPuppetUp(IUsePlayerPuppet* playerPuppet, const sead::Vector3f& up) { sead::Vector3f front(0.0f, 0.0f, 0.0f);
Suggestion:
sead::Vector3f front = {0.0f, 0.0f, 0.0f};src/Util/PlayerPuppetFunction.cpp line 419 at r1 (raw file):
void calcPuppetQuat(sead::Quatf* quat, const IUsePlayerPuppet* playerPuppet) { sead::Vector3f front(0.0f, 0.0f, 0.0f); sead::Vector3f up(0.0f, 0.0f, 0.0f);
Suggestion:
sead::Vector3f front = {0.0f, 0.0f, 0.0f};
sead::Vector3f up = {0.0f, 0.0f, 0.0f};src/Util/PlayerPuppetFunction.cpp line 465 at r1 (raw file):
al::HitSensor* hitSensor = puppet->getHitSensor(); sead::Vector3f safetyPoint(0.0f, 0.0f, 0.0f); sead::Vector3f safetyPointNormal(0.0f, 0.0f, 0.0f);
Suggestion:
sead::Vector3f safetyPoint = {0.0f, 0.0f, 0.0f};
sead::Vector3f safetyPointNormal = {0.0f, 0.0f, 0.0f};src/Util/PlayerPuppetFunction.cpp line 472 at r1 (raw file):
puppet->requestUpdateRecoveryInfo(true, false, safetyPoint, safetyPointNormal, areaObj); } else { bool collisionCode = false;
Suggestion:
bool isInAir = false;src/Util/PlayerPuppetFunction.cpp line 477 at r1 (raw file):
playerCollision); puppet->requestUpdateRecoveryInfo(false, collisionCode, safetyPoint, safetyPointNormal, areaObj);
Suggestion:
// NOTE: might pass {0,0,0} as normal into this function
puppet->requestUpdateRecoveryInfo(false, collisionCode, safetyPoint, safetyPointNormal,
areaObj);
Implements the whole
Util/PlayerPuppetFunction.oobject — all 82 functions matching (tools/checkclean,check-format.pyreports no issues).These are the
rs::player-puppet utility functions: wrappers around theIUsePlayerPuppetinterface, and — where they touch state — the concretePlayerPuppet.(This replaces the earlier partial version of this PR: per feedback that objects should be implemented whole rather than cherry-picking the easy functions, the object is now complete in a single PR.)
Supporting changes worth a closer look
IUsePlayerPuppetstays a pure interface; the member-accessing wrappersstatic_casttoPlayerPuppetand go through accessors. I named the previously-placeholder flag members onPlayerPuppet(mIsValidLookAt,mIsValidForceLookAt,mIsValidSeparateMode,mIsValidRecoveryArea,mIsValidGuideArrow,mIsValidWaterSurfaceShadow,mIsInvalidReceivePush,mIsCopyDitherAlpha,mForceLookAtDir,mJudgePreInputJump) — happy to adjust any of these.BindKeepDemoInfostruct.PlayerInput::getStickMoveRawwas declared asconst sead::Vector2f&, but the function returns the vector by value (ins0/s1); changed it to returnsead::Vector2f. This is required forrs::getPuppetMoveStickto match — clang 3.9.1 won't tail-call a reference-returning forward, but does for a value return.boolflag out ofPlayerEffect(previously an opaquechar filler) forrs::clearStainEffect; the field name is inferred.Tracker: MonsterDruide1/OdysseyDecompTracker#1530
This change is
Report for 1.0 (ae6bf40 - 204c822)
📈 Matched code: 15.34% (+0.02%, +2860 bytes)
✅ 82 new matches
Util/PlayerPuppetFunctionrs::requestUpdateSafetyPoint(IUsePlayerPuppet*, al::LiveActor const*, IUsePlayerCollision const*)Util/PlayerPuppetFunctionrs::addPuppetVelocityFall(IUsePlayerPuppet*)Util/PlayerPuppetFunctionrs::tryStartBindKeepDemo(BindKeepDemoInfo*, al::SensorMsg const*, IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::tryEndBindKeepDemo(BindKeepDemoInfo*, al::SensorMsg const*, IUsePlayerPuppet*)Util/PlayerPuppetFunctionrs::setPuppetFront(IUsePlayerPuppet*, sead::Vector3<float> const&)Util/PlayerPuppetFunctionrs::setPuppetUp(IUsePlayerPuppet*, sead::Vector3<float> const&)Util/PlayerPuppetFunctionrs::calcPuppetQuat(sead::Quat<float>*, IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::syncPuppetVisibility(al::LiveActor*, IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::forcePutOnPuppetCapWithEffect(IUsePlayerPuppet*)Util/PlayerPuppetFunctionrs::startPuppet(al::HitSensor*, al::HitSensor*)Util/PlayerPuppetFunctionrs::isPuppetInputSwing(IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::endBindOnGroundAndPuppetNull(IUsePlayerPuppet**)Util/PlayerPuppetFunctionrs::endBindJumpAndPuppetNull(IUsePlayerPuppet**, sead::Vector3<float> const&, int)Util/PlayerPuppetFunctionrs::endBindWallJumpAndPuppetNull(IUsePlayerPuppet**, sead::Vector3<float> const&, int)Util/PlayerPuppetFunctionrs::isPuppetTriggerAnyButton(IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::isPuppetHoldAnyButton(IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::endBindCapThrow(IUsePlayerPuppet**)Util/PlayerPuppetFunctionrs::tryReceiveBindCancelMsgAndPuppetNull(IUsePlayerPuppet**, al::SensorMsg const*)Util/PlayerPuppetFunctionrs::startPuppetAction(IUsePlayerPuppet*, char const*)Util/PlayerPuppetFunctionrs::copyPuppetDitherAlpha(IUsePlayerPuppet*, al::LiveActor const*)Util/PlayerPuppetFunctionrs::initBindKeepDemoInfo()Util/PlayerPuppetFunctionrs::endBindAndPuppetNull(IUsePlayerPuppet**)Util/PlayerPuppetFunctionrs::forcePutOnPuppetCap(IUsePlayerPuppet*)Util/PlayerPuppetFunctionrs::validatePuppetForceLookAt(IUsePlayerPuppet*, sead::Vector3<float> const&)Util/PlayerPuppetFunctionrs::requestForceSafetyPoint(IUsePlayerPuppet*, sead::Vector3<float> const&, sead::Vector3<float> const&)Util/PlayerPuppetFunctionrs::getPuppetGravity(IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::getPuppetVelocity(IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::getPuppetTrans(IUsePlayerPuppet const*)Util/PlayerPuppetFunctionrs::getCollidedPuppetGroundNormal(IUsePlayerPuppet*)Util/PlayerPuppetFunctionrs::calcPuppetUp(sead::Vector3<float>*, IUsePlayerPuppet const*)...and 52 more new matches