From 69cefa99e9c954d82aab4738ddceeed4b9a673e1 Mon Sep 17 00:00:00 2001 From: ReimousTH <51449880+ReimousTH@users.noreply.github.com> Date: Tue, 5 Aug 2025 21:53:55 +0300 Subject: [PATCH 1/8] Gauge --- MarathonRecomp/api/Marathon.h | 3 + MarathonRecomp/api/Sonicteam/GameImp.h | 2 +- .../api/Sonicteam/Player/INotification.h | 12 + MarathonRecomp/api/Sonicteam/Player/Object.h | 44 +++- .../api/Sonicteam/Player/Object.inl | 6 +- MarathonRecomp/api/Sonicteam/Player/Score.h | 1 + .../api/Sonicteam/Player/SonicGauge.h | 11 +- .../Sonicteam/Player/State/CommonContext.h | 29 ++- .../Player/State/ContextSpeedAndJump.h | 8 +- .../Sonicteam/Player/State/ICommonContext.h | 21 +- .../api/Sonicteam/Player/State/Machine2.h | 1 + .../api/Sonicteam/Player/State/SonicContext.h | 54 ++++- .../Sonicteam/Player/Weapon/SonicWeapons.h | 38 +++ MarathonRecomp/api/stdx/vector.h | 2 +- MarathonRecomp/patches/player_patches.cpp | 225 ++++++++++++++++++ MarathonRecomp/user/config_def.h | 1 + MarathonRecompLib/config/Marathon.toml | 21 ++ MarathonRecompResources | 2 +- thirdparty/SDL | 2 +- thirdparty/ddspp | 2 +- thirdparty/plume | 2 +- tools/XenonRecomp | 2 +- tools/XenosRecomp | 2 +- 23 files changed, 460 insertions(+), 31 deletions(-) create mode 100644 MarathonRecomp/api/Sonicteam/Player/INotification.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 491e34b18..85079466e 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -42,6 +42,7 @@ #include "Sonicteam/Player/IExportWeaponRequestFlag.h" #include "Sonicteam/Player/IFlagCommunicator.h" #include "Sonicteam/Player/IGauge.h" +#include "Sonicteam/Player/INotification.h" #include "Sonicteam/Player/IPlugIn.h" #include "Sonicteam/Player/IScore.h" #include "Sonicteam/Player/IStepable.h" @@ -69,6 +70,8 @@ #include "Sonicteam/SaveDataTask.h" #include "Sonicteam/SaveDataTaskXENON.h" #include "Sonicteam/SelectWindowTask.h" +#include "Sonicteam/Player/State/TailsContext.h" +#include "Sonicteam/Player/Weapon/SonicWeapons.h" #include "Sonicteam/SoX/AI/StateMachine.h" #include "Sonicteam/SoX/Audio/IAudioEngine.h" #include "Sonicteam/SoX/Component.h" diff --git a/MarathonRecomp/api/Sonicteam/GameImp.h b/MarathonRecomp/api/Sonicteam/GameImp.h index 9b1459c01..5055bdcaa 100644 --- a/MarathonRecomp/api/Sonicteam/GameImp.h +++ b/MarathonRecomp/api/Sonicteam/GameImp.h @@ -27,7 +27,7 @@ namespace Sonicteam { be ActorID; be RingCount; - MARATHON_INSERT_PADDING(4); + be TownRingCount; be LifeCount; be ScoreCount; be AliveTime; diff --git a/MarathonRecomp/api/Sonicteam/Player/INotification.h b/MarathonRecomp/api/Sonicteam/Player/INotification.h new file mode 100644 index 000000000..0a2ea3dd9 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/INotification.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class INotification + { + public: + xpointer m_pVftable; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.h b/MarathonRecomp/api/Sonicteam/Player/Object.h index 8ea599e9e..f22f58ba1 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.h +++ b/MarathonRecomp/api/Sonicteam/Player/Object.h @@ -8,38 +8,66 @@ #include #include #include +#include +#include +#include +#include namespace Sonicteam::Player { - class Object : public Actor + #pragma pack(push, 1) + class __declspec(align(1)) Object : public Actor { + struct ObjectPlayerUpgrade { + uint32_t global_flag; + uint32_t equip_flag; + }; + public: stdx::string m_PlayerLua; stdx::string m_PlayerPackage; - MARATHON_INSERT_PADDING(8); + be m_CameramanActorID; + xpointer m_Cameraman; be m_PlayerIndex; - MARATHON_INSERT_PADDING(0x2C); + be m_PlayerControllerIndex; + SoX::Math::Quaternion m_SpawnRotation; + SoX::Math::Vector m_SpawnPosition; + be m_SpawnRing; + SoX::RefSharedPointer m_spSpawnSource; // REF_TYPE(RefCountObject) bool m_IsPlayer; bool m_IsPosture; bool m_IsAmigo; MARATHON_INSERT_PADDING(1); SoX::RefSharedPointer m_spRootFrame; - MARATHON_INSERT_PADDING(0x14); + SoX::RefSharedPointer m_spPackageBinary; + boost::shared_ptr m_spPlayerModel; + boost::shared_ptr m_spPlayerPosture; boost::shared_ptr m_spStateMachine; - MARATHON_INSERT_PADDING(0x10); + boost::shared_ptr m_spPlayerGravity; + boost::shared_ptr m_spPlayerImpulse; be m_SetupModuleIndexPrefix; be m_SetupModuleIndexPostfix; boost::shared_ptr m_spGauge; MARATHON_INSERT_PADDING(8); stdx::vector> m_vspPlayerPlugins; - MARATHON_INSERT_PADDING(0x1F4); - + MARATHON_INSERT_PADDING(0x58); + be m_PlayerDelta; + MARATHON_INSERT_PADDING(0x48); + stdx::vector m_PlayerUpgrade; + stdx::string m_PlayerName; + MARATHON_INSERT_PADDING(0x134); + template inline T* GetGauge(); - + template inline T* GetPlugin(const char* pluginName); + + template + inline T* GetPlugin(const char* v_name); + }; + #pragma pack(pop) } #include diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.inl b/MarathonRecomp/api/Sonicteam/Player/Object.inl index ed6ce292a..1ad2d0fef 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.inl +++ b/MarathonRecomp/api/Sonicteam/Player/Object.inl @@ -1,3 +1,4 @@ +#include "Object.h" namespace Sonicteam::Player { template @@ -7,6 +8,7 @@ namespace Sonicteam::Player } template + inline T* Object::GetPlugin(const char* pluginName) { for (auto& spPlugin : m_vspPlayerPlugins) @@ -14,7 +16,5 @@ namespace Sonicteam::Player if (spPlugin->m_Name == pluginName) return static_cast(spPlugin.get()); } - - return nullptr; - } + } } diff --git a/MarathonRecomp/api/Sonicteam/Player/Score.h b/MarathonRecomp/api/Sonicteam/Player/Score.h index ff270c709..5ee4d79c2 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Score.h +++ b/MarathonRecomp/api/Sonicteam/Player/Score.h @@ -2,6 +2,7 @@ #include + namespace Sonicteam::Player { class Score : public IScore, public IVariable, public IStepable diff --git a/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h b/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h index 07b7dd9d0..d628e4114 100644 --- a/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h +++ b/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h @@ -12,6 +12,15 @@ namespace Sonicteam::Player be m_Flags; be m_GroundedFlags; be m_Maximum; - MARATHON_INSERT_PADDING(0x28); + be m_Green; + be m_Red; + be m_Blue; + be m_White; + be m_Sky; + be m_Yellow; + be m_Purple; + be m_Super; + be m_Heal; + be m_HealDelay; }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h b/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h index 11922870c..9335afe76 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h @@ -1,5 +1,4 @@ #pragma once - #include #include #include @@ -8,10 +7,36 @@ namespace Sonicteam::Player::State { + + + class CommonContext : public ICommonContext, public IExportPostureRequestFlag, public IExportWeaponRequestFlag { public: - MARATHON_INSERT_PADDING(0x90); + + //(Gordon Ramsay) + enum PostureEnum:uint32_t + { + CC_GROUND = 0x1, // detects Ground + CC_WALLBRUSHING = 0x8, // detects brushing against a wall + CC_HEADONWALL = 0x10, // detects head-on wall collision (will always be enabled w/ 2^3) + CC_RAILGRIND = 0x40, // Rail grinding + CC_BEFOREFALL = 0x100, // seems like Neutral or Pre-Fall? The moment before transitioning from the Jump to Fall animation + CC_FALL = 0x200, // FALL + CC_WATERLCOL = 0x800, // Water collision (making you slide down an incline)? 2^8(CC_BEFOREFALL) is often set with this + CC_LIGHTDASHIN = 0x4000, // Light Dashing (2 ^ 14) + CC_QUICKROTATE = 0x8000, // is moving the control stick in a non-forward direction (usually only active for a frame since the character instantly rotates) + CC_TENTATIVE = 0x10000, // is Tentative collision + CC_WATERSLIDE = 0x20000, // Water sliding (2^17) + CC_GRASS = 0x100000, // grass 2^20 + CC_DIRTCLAY = 0x200000, // dirt/clay (2^21) + CC_STONE = 0x400000, // stone (2^22) + CC_SHORELINE = 0x1000000, // shoreline? sand? Uncertain (2^24) + }; + + MARATHON_INSERT_PADDING(0x2C); + be m_PostureFlags; + MARATHON_INSERT_PADDING(0x60); xpointer m_pScore; MARATHON_INSERT_PADDING(0x104); }; diff --git a/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h b/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h index 8a9f012a7..13be6b6d5 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h @@ -4,5 +4,11 @@ namespace Sonicteam::Player::State { - class ContextSpeedAndJump {}; + class ContextSpeedAndJump + { + be m_BaseSpeedForward; + be m_GimmickSpeedForward; + be m_BaseSpeedVertical; + be m_GimmickSpeedVertical; + }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h b/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h index 989ac55d5..096649107 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h @@ -1,21 +1,28 @@ #pragma once - #include #include #include #include +#include +#include + namespace Sonicteam::Player::State { class ICommonContext : public IContext, public ICommonContextIF, public ContextSpeedAndJump { public: - MARATHON_INSERT_PADDING(0x10); - be m_StateID; - MARATHON_INSERT_PADDING(0x10); + be m_AnimationID; + be m_LockButtons; + be m_LastVelocityForward; + be m_LastVelocityVertical; + be m_LastLockButtons; be m_Buttons; - MARATHON_INSERT_PADDING(0x18); - be m_Field70; - MARATHON_INSERT_PADDING(0x1C); + be m_CurrentStickBorder; // 0 .. 1.0 + MARATHON_INSERT_PADDING(4); + be m_AnimationState; // & 2 == 0 (Animation End, no any idea about others) + MARATHON_INSERT_PADDING(0x1C); }; + //0x90 + } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h b/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h index 3fe896e79..522397b79 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace Sonicteam::Player::State { diff --git a/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h b/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h index 47ab0fe37..f14efaad5 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h @@ -1,8 +1,60 @@ #pragma once #include +#include +#include +#include namespace Sonicteam::Player::State { - class SonicContext : public CommonContext {}; + class SonicContext : public CommonContext + { + public: + //Sprite + enum GemsS:uint32_t + { + SGreen = 1, + SRed, + SBlue, + SWhite, + SSky, + SYellow, + SPurple, + SSuper + }; + + enum Gems:uint32_t + { + Blue = 1, + Red, + Green, + Purple, + Sky, + White, + Yellow, + Super + }; + + be m_CurrentGemSprite; + boost::shared_ptr m_Gauge; + uint8_t m_HomingLockOn; + uint8_t m_DisablePlayerMovement; + uint8_t m_AntigravityHitBox; + uint8_t m_23F; + uint8_t m_BoundAttackHitBox; + uint8_t m_241; + uint8_t m_Shrink; + uint8_t m_ThunderGuard; + uint8_t m_Tornado; + uint8_t m_FPS; + uint8_t m_ThrowGem; + uint8_t m_SlowTime; + uint8_t m_MachAura; + uint8_t m_GemsEnabled; + uint8_t m_24A; + uint8_t m_24B; + be m_HomingFlip; + be m_CurrentGem; + MARATHON_INSERT_PADDING(0x58); + }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h b/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h new file mode 100644 index 000000000..6760ddace --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h @@ -0,0 +1,38 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + + + + +namespace Sonicteam::Player::Weapon +{ + template + struct LinkSoxNode + { + xpointer> m_Prev; + xpointer> m_Next; + Type* m_This; + }; + + template + struct EntityContainer + { + xpointer Entity; + LinkSoxNode m_Link; + }; + + class SonicWeapons : public IPlugIn, public IFlagCommunicator, public IStepable, public IDynamicLink, public IVariable, public INotification + { + public: + MARATHON_INSERT_PADDING(0x4C); + EntityContainer m_GunDrive; + MARATHON_INSERT_PADDING(0x24); + }; +} diff --git a/MarathonRecomp/api/stdx/vector.h b/MarathonRecomp/api/stdx/vector.h index c58a904ab..8a3e6c59c 100644 --- a/MarathonRecomp/api/stdx/vector.h +++ b/MarathonRecomp/api/stdx/vector.h @@ -514,4 +514,4 @@ namespace stdx { return !(lhs < rhs); } -} +} \ No newline at end of file diff --git a/MarathonRecomp/patches/player_patches.cpp b/MarathonRecomp/patches/player_patches.cpp index a3104b170..b894ca76f 100644 --- a/MarathonRecomp/patches/player_patches.cpp +++ b/MarathonRecomp/patches/player_patches.cpp @@ -183,3 +183,228 @@ bool ControllableSpinkick() { return Config::ControllableSpinkick; } + + +/////////////////////////////////////////////////////// +///////////// Sonic Gauge Restoration //////////////// +//////////////////////////////////////////////////////// + +const Sonicteam::Player::State::SonicContext::GemsS gemConversionTable[] = { + Sonicteam::Player::State::SonicContext::GemsS::SBlue, + Sonicteam::Player::State::SonicContext::GemsS::SRed, + Sonicteam::Player::State::SonicContext::GemsS::SGreen, + Sonicteam::Player::State::SonicContext::GemsS::SPurple, + Sonicteam::Player::State::SonicContext::GemsS::SSky, + Sonicteam::Player::State::SonicContext::GemsS::SWhite, + Sonicteam::Player::State::SonicContext::GemsS::SYellow, + Sonicteam::Player::State::SonicContext::GemsS::SSuper +}; + +//Check Gauge Drain +//SonicTeam::Player::SonicGauge (IVariable), IVariable::Init(REF_TYPE(SonicTeam::LuaSystem)) +PPC_FUNC_IMPL(__imp__sub_82217FC0); +PPC_FUNC(sub_82217FC0) { + + if (!Config::SonicGauge) + { + __imp__sub_82217FC0(ctx, base); + return; + } + + auto context = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(ctx.r3.u32); + auto gauge = context->m_Gauge.get(); + + using enum Sonicteam::Player::State::SonicContext::Gems; + auto gem_id = (Sonicteam::Player::State::SonicContext::Gems)(ctx.r4.u32); + + switch (gem_id) + { + case Yellow: + if (context->m_ThunderGuard) break; + case Blue: + case Green: + case Sky: + case White: + case Super: + { + size_t index = gemConversionTable[gem_id - 1] - 1; + if (gauge->m_Value >= (&gauge->m_Green)[index].get()) + { + ctx.r3.u64 = 1; + return; + } + break; + } + case Red: + case Purple: + if (context->m_24A == 0) + { + ctx.r3.u64 = 1; + return; + } + break; + } + ctx.r3.u64 = 0; + return; + +} +//Gauge Drain +PPC_FUNC_IMPL(__imp__sub_82218068); +PPC_FUNC(sub_82218068) { + + if (!Config::SonicGauge) + { + __imp__sub_82217FC0(ctx, base); + return; + } + + auto context = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(ctx.r3.u32); + auto gauge = context->m_Gauge.get(); + + using enum Sonicteam::Player::State::SonicContext::Gems; + auto gem_id = (Sonicteam::Player::State::SonicContext::Gems)(ctx.r4.u32); + double delta = ctx.f1.f64; + + switch (gem_id) + { + case Blue: + case Green: + case Yellow: + case Sky: + case White: + case Super: + { + uint32_t index = gemConversionTable[gem_id - 1] - 1; + gauge->m_Value = gauge->m_Value.get() - (&gauge->m_Green)[index].get(); + gauge->m_GroundedTime = 0.0; + break; + } + case Red: + case Purple: + { + uint32_t index = gemConversionTable[gem_id - 1] - 1; + gauge->m_Value = gauge->m_Value.get() - (&gauge->m_Green)[index].get() * delta; + gauge->m_GroundedTime = 0.0; + if (gauge->m_Value <= 0) + { + gauge->m_Value = 0.0; + context->m_Shrink = 0; + context->m_SlowTime = 0; + context->m_24A = 1; + + } + break; + } + } +} + + +PPC_FUNC_IMPL(__imp__sub_8223F360); +PPC_FUNC(sub_8223F360) { + + auto IVariable = ctx.r3.u32; + auto RefTypeLuaSystem = ctx.r4.u32; + __imp__sub_8223F360(ctx, base); + if (!Config::SonicGauge) + return; + + auto gauge = (Sonicteam::Player::SonicGauge*)g_memory.Translate(IVariable - 0x20); + auto buffer = g_userHeap.Alloc(); + + // if (gauge->m_Gem == 0.0) if m_Gem not intitialized by __imp__sub_8223F360 + *buffer = "c_gauge_green"; + if (gauge->m_Green.get() == 0.0) + gauge->m_Green = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_red"; + if (gauge->m_Red.get()== 0.0) + gauge->m_Red = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_blue"; + if (gauge->m_Blue.get() == 0.0) + gauge->m_Blue = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_white"; + if (gauge->m_White.get() == 0.0) + gauge->m_White = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_sky"; + if (gauge->m_Sky.get() == 0.0) + gauge->m_Sky = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_yellow"; + if (gauge->m_Yellow.get() == 0.0) + gauge->m_Yellow = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_purple"; + if (gauge->m_Purple.get() == 0.0) + gauge->m_Purple = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_super"; + if (gauge->m_Super.get() == 0.0) + gauge->m_Super = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + + buffer->~string(); + g_userHeap.Free(buffer); + + /* For Testing + gauge->m_Green = 10; + gauge->m_Blue = 20; + gauge->m_White = 40; + gauge->m_Sky = 60; + gauge->m_Yellow = 80; + gauge->m_Super = 100; + gauge->m_Red = 20; + gauge->m_Purple = 40; + */ +} + +void SonicGaugeRestorationGaugeGemSpriteResetFix(PPCRegister& r_GameImp) { + + Sonicteam::GameImp* pGameImp = (Sonicteam::GameImp*)g_memory.Translate(r_GameImp.u32); + for (int i = 0; i < 4; i++) + pGameImp->m_PlayerData[i].GemIndex = 0; +} + +void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_context) { + + if (!Config::SonicGauge || !r_gauge.u32) + return; + + auto pGauge = (Sonicteam::Player::SonicGauge*)g_memory.Translate(r_gauge.u32); + auto PContext = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(r_context.u32); + if ((uint32_t)(static_cast(pGauge)->m_pVftable.get()) != 0x8200D4D8) // != SonicGauge + return; + + auto weapons = PContext->m_pScore->m_pPlayer->GetPlugin("sonic_weapons"); + if (PContext->m_Tornado != 0 || PContext->m_CurrentAnimation == 0xCB || PContext->m_CurrentAnimation == 0xCC || PContext->m_CurrentAnimation == 0x46 || PContext->m_CurrentAnimation == 0xCE || weapons->m_GunDrive.Entity != 0) + { + pGauge->m_GroundedFlags = 1; // Lock game + } + else + { + using enum Sonicteam::Player::State::SonicContext::Gems; + if ((PContext->m_Input.get() & 0x10000) != 0) { + PContext->m_24A = 0; + } + + if ((PContext->m_Input.get() & 0x20000) != 0 && (PContext->m_CurrentGem == Red || PContext->m_CurrentGem == Purple)) + { + pGauge->m_GroundedFlags = 1; + if (PContext->m_24A) + { + pGauge->m_GroundedFlags = 0; + PContext->m_Shrink = 0; + PContext->m_SlowTime = 0; + } + } + else if ((PContext->m_PostureFlags.get() & Sonicteam::Player::State::CommonContext::CC_GROUND) != 0 || PContext->m_24A) + { + pGauge->m_GroundedFlags = 0; + + } + } + +} +//Sonic Gauge Restoration \ No newline at end of file diff --git a/MarathonRecomp/user/config_def.h b/MarathonRecomp/user/config_def.h index 6ff529718..086d68b18 100644 --- a/MarathonRecomp/user/config_def.h +++ b/MarathonRecomp/user/config_def.h @@ -86,6 +86,7 @@ CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreContextualHUDColours, false); CONFIG_DEFINE_HIDDEN("Codes", bool, DisableEdgeGrabLeftover, false); CONFIG_DEFINE_HIDDEN("Codes", bool, TailsGauge, false); CONFIG_DEFINE_HIDDEN("Codes", bool, PlayerDebugMode, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, SonicGauge, false); CONFIG_DEFINE_HIDDEN("Codes", bool, MidairControlForMachSpeed, false); CONFIG_DEFINE_HIDDEN("Codes", bool, MidairControlForSnowboards, false); CONFIG_DEFINE_HIDDEN("Codes", bool, ControllableTeleportDash, false); diff --git a/MarathonRecompLib/config/Marathon.toml b/MarathonRecompLib/config/Marathon.toml index 852886a90..6f7d2a697 100644 --- a/MarathonRecompLib/config/Marathon.toml +++ b/MarathonRecompLib/config/Marathon.toml @@ -117,6 +117,7 @@ name = "ContextualHUD_LIFE_BER_ANIME_1" address = 0x824D8F2C registers = ["r5", "r31"] + [[midasm_hook]] name = "ContextualHUD_RING_1" address = 0x824DEB38 @@ -337,3 +338,23 @@ jump_address = 0x8258E308 name = "NOP" address = 0x8258E600 jump_address = 0x8258E604 + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeFlagFix" +address = 0x822196EC +registers = ["r3","r31"] + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeGemSpriteResetFix" +address = 0x82185768 +registers = ["r30"] + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeGemSpriteResetFix" +address = 0x821855A4 +registers = ["r29"] + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeGemSpriteResetFix" +address = 0x82177DFC +registers = ["r31"] diff --git a/MarathonRecompResources b/MarathonRecompResources index e0c15da29..ceb0bdcf5 160000 --- a/MarathonRecompResources +++ b/MarathonRecompResources @@ -1 +1 @@ -Subproject commit e0c15da298954b8046af761af731ed1b9ff14412 +Subproject commit ceb0bdcf5bce7bd694433d0c8208366480b0e8fb diff --git a/thirdparty/SDL b/thirdparty/SDL index 98d1f3a45..1edaad172 160000 --- a/thirdparty/SDL +++ b/thirdparty/SDL @@ -1 +1 @@ -Subproject commit 98d1f3a45aae568ccd6ed5fec179330f47d4d356 +Subproject commit 1edaad17218d67b567c149badce9ef0fc67f65fa diff --git a/thirdparty/ddspp b/thirdparty/ddspp index 98ce1d384..1390499ec 160000 --- a/thirdparty/ddspp +++ b/thirdparty/ddspp @@ -1 +1 @@ -Subproject commit 98ce1d384706c8d7121876742a786f4eb89a23ef +Subproject commit 1390499ec9f7b82e7a9cbdeb2e6191808e981f84 diff --git a/thirdparty/plume b/thirdparty/plume index 61e19e19d..2f72b6714 160000 --- a/thirdparty/plume +++ b/thirdparty/plume @@ -1 +1 @@ -Subproject commit 61e19e19dcf4f44fbe7f7445f21904b0e27fbb3d +Subproject commit 2f72b6714e2e36d19df876e7238f2361cc2a3284 diff --git a/tools/XenonRecomp b/tools/XenonRecomp index c3714b8d7..b3d25ae01 160000 --- a/tools/XenonRecomp +++ b/tools/XenonRecomp @@ -1 +1 @@ -Subproject commit c3714b8d7d35d202df293c4965b52bd74ae9df02 +Subproject commit b3d25ae01db833d58168a0d2a7cb6b7c71a4c4c1 diff --git a/tools/XenosRecomp b/tools/XenosRecomp index 3938ef646..2d3320dba 160000 --- a/tools/XenosRecomp +++ b/tools/XenosRecomp @@ -1 +1 @@ -Subproject commit 3938ef6464e08542f31b3941ee4543c3df6d20d1 +Subproject commit 2d3320dba5dbdfb3abd6d67ae6111918fbd8377b From 62fb488df2a79c46e905c5fedd252e15ef670142 Mon Sep 17 00:00:00 2001 From: ReimousTH <51449880+ReimousTH@users.noreply.github.com> Date: Tue, 5 Aug 2025 22:00:26 +0300 Subject: [PATCH 2/8] Ex2 --- MarathonRecomp/api/Sonicteam/Player/Object.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.h b/MarathonRecomp/api/Sonicteam/Player/Object.h index f22f58ba1..16ea13f96 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.h +++ b/MarathonRecomp/api/Sonicteam/Player/Object.h @@ -18,7 +18,8 @@ namespace Sonicteam::Player #pragma pack(push, 1) class __declspec(align(1)) Object : public Actor { - struct ObjectPlayerUpgrade { + struct ObjectPlayerUpgrade + { uint32_t global_flag; uint32_t equip_flag; }; From 4c9a90e095a37e716ecc83caa20618b6183a1308 Mon Sep 17 00:00:00 2001 From: ReimousTH Date: Fri, 5 Sep 2025 15:43:17 +0300 Subject: [PATCH 3/8] TODO --- MarathonRecomp/api/Marathon.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 85079466e..583c25ad9 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -66,12 +66,11 @@ #include "Sonicteam/Player/State/SonicObject.h" #include "Sonicteam/Player/State/SonicSpinDash.h" #include "Sonicteam/Player/State/TailsContext.h" +#include "Sonicteam/Player/Weapon/SonicWeapons.h" #include "Sonicteam/Player/Zock.h" #include "Sonicteam/SaveDataTask.h" #include "Sonicteam/SaveDataTaskXENON.h" #include "Sonicteam/SelectWindowTask.h" -#include "Sonicteam/Player/State/TailsContext.h" -#include "Sonicteam/Player/Weapon/SonicWeapons.h" #include "Sonicteam/SoX/AI/StateMachine.h" #include "Sonicteam/SoX/Audio/IAudioEngine.h" #include "Sonicteam/SoX/Component.h" From 8b0af47ad58c3d9a90ae22ff96ea120edd2c0605 Mon Sep 17 00:00:00 2001 From: ReimousTH <51449880+ReimousTH@users.noreply.github.com> Date: Sat, 6 Sep 2025 15:33:04 +0300 Subject: [PATCH 4/8] Rebase #1 --- MarathonRecomp/api/Marathon.h | 11 ++++ MarathonRecomp/api/Sonicteam/ActorManager.h | 16 ++++++ .../api/Sonicteam/Player/GroundRayListener.h | 14 +++++ .../api/Sonicteam/Player/IPostureControl.h | 51 +++++++++++++++++++ .../api/Sonicteam/Player/IPosturePlugIn.h | 12 +++++ .../Sonicteam/Player/IPostureSupportEdge.h | 13 +++++ .../Sonicteam/Player/IPostureSupportInput.h | 13 +++++ .../Sonicteam/Player/IPostureSupportOttoto.h | 13 +++++ .../Player/IPostureSupportRayTemplate.h | 21 ++++++++ .../Sonicteam/Player/IPostureSupportSphere.h | 13 +++++ MarathonRecomp/api/Sonicteam/Player/Object.h | 16 +++--- .../api/Sonicteam/Player/Object.inl | 2 +- .../api/Sonicteam/Player/PostureControl.h | 38 ++++++++++++++ .../Sonicteam/Player/State/CommonContext.h | 44 ++++++---------- .../Sonicteam/Player/State/ICommonContext.h | 2 +- .../api/Sonicteam/Player/Unit/ITestCase.h | 12 +++++ MarathonRecomp/patches/player_patches.cpp | 11 ++-- 17 files changed, 257 insertions(+), 45 deletions(-) create mode 100644 MarathonRecomp/api/Sonicteam/ActorManager.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/IPostureControl.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/IPosturePlugIn.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/IPostureSupportEdge.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/IPostureSupportInput.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/IPostureSupportOttoto.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/IPostureSupportSphere.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/PostureControl.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/Unit/ITestCase.h diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 583c25ad9..42769d5b0 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -16,6 +16,7 @@ #include "CSD/Manager/csdmSubjectBase.h" #include "CSD/Platform/csdTexList.h" #include "Sonicteam/Actor.h" +#include "Sonicteam/ActorManager.h" #include "Sonicteam/AlertWindowTask.h" #include "Sonicteam/AppMarathon.h" #include "Sonicteam/AudioEngineXenon.h" @@ -36,6 +37,7 @@ #include "Sonicteam/MyGraphicsDevice.h" #include "Sonicteam/MyPhantom.h" #include "Sonicteam/MyTexture.h" +#include "Sonicteam/Player/GroundRayListener.h" #include "Sonicteam/Player/IDynamicLink.h" #include "Sonicteam/Player/IExportExternalFlag.h" #include "Sonicteam/Player/IExportPostureRequestFlag.h" @@ -44,11 +46,19 @@ #include "Sonicteam/Player/IGauge.h" #include "Sonicteam/Player/INotification.h" #include "Sonicteam/Player/IPlugIn.h" +#include "Sonicteam/Player/IPostureControl.h" +#include "Sonicteam/Player/IPosturePlugIn.h" +#include "Sonicteam/Player/IPostureSupportEdge.h" +#include "Sonicteam/Player/IPostureSupportInput.h" +#include "Sonicteam/Player/IPostureSupportOttoto.h" +#include "Sonicteam/Player/IPostureSupportRayTemplate.h" +#include "Sonicteam/Player/IPostureSupportSphere.h" #include "Sonicteam/Player/IScore.h" #include "Sonicteam/Player/IStepable.h" #include "Sonicteam/Player/IVariable.h" #include "Sonicteam/Player/IZock.h" #include "Sonicteam/Player/Object.h" +#include "Sonicteam/Player/PostureControl.h" #include "Sonicteam/Player/RootFrame.h" #include "Sonicteam/Player/Score.h" #include "Sonicteam/Player/SonicGauge.h" @@ -66,6 +76,7 @@ #include "Sonicteam/Player/State/SonicObject.h" #include "Sonicteam/Player/State/SonicSpinDash.h" #include "Sonicteam/Player/State/TailsContext.h" +#include "Sonicteam/Player/Unit/ITestCase.h" #include "Sonicteam/Player/Weapon/SonicWeapons.h" #include "Sonicteam/Player/Zock.h" #include "Sonicteam/SaveDataTask.h" diff --git a/MarathonRecomp/api/Sonicteam/ActorManager.h b/MarathonRecomp/api/Sonicteam/ActorManager.h new file mode 100644 index 000000000..8e294b7f9 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/ActorManager.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace Sonicteam +{ + class ActorManager + { + public: + be m_ActorID[0xFFFF]; + xpointer m_Actor[0xFFFF]; + be m_LastActorID; + be m_LastActorIndex; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h new file mode 100644 index 000000000..9c576f9df --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + //Sonicteam::Player::ICollisionListener, Sonicteam::Player::ICollisionListenerTemplate + class GroundRayListener + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0x7C); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h b/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h new file mode 100644 index 000000000..281cb428c --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h @@ -0,0 +1,51 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Sonicteam::Player +{ + class IPostureControl : public IVariable, public IDynamicLink, public Unit::ITestCase, public IFlagCommunicator + { + public: + SoX::RefSharedPointer m_spRootFrame; + SoX::Math::Quaternion m_RotationFixed; + SoX::Math::Vector m_PositionFixed; + SoX::RefSharedPointer m_spWorld; + boost::shared_ptr m_spGravity; + boost::shared_ptr m_spInputListener; + boost::shared_ptr m_spAmigoListener; + boost::shared_ptr m_ContextIF; + boost::shared_ptr m_spActorManager; + xpointer m_pTask; + boost::shared_ptr m_spPosturePlugIn; + SoX::Math::Vector m_GravityDirection; + be m_GravityForce; + SoX::Math::Vector m_NormalizedSurface; //ground normal? + SoX::Math::Vector m_Position; + SoX::Math::Quaternion m_Rotation; + MARATHON_INSERT_PADDING(0x20); + be m_PostureFlag; + be m_ImpulseForward; + be m_ImpulseVertical; + SoX::Math::Vector m_ImpulseUP; + be m_ContextIFFlag; + be m_PostureRequestFlag; + be m_PostureFlag118; + be m_PostureFlag11C; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPosturePlugIn.h b/MarathonRecomp/api/Sonicteam/Player/IPosturePlugIn.h new file mode 100644 index 000000000..fea96f109 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPosturePlugIn.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPosturePlugIn + { + public: + xpointer m_pVftable; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportEdge.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportEdge.h new file mode 100644 index 000000000..1ea8aae53 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportEdge.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportEdge + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0x70 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportInput.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportInput.h new file mode 100644 index 000000000..261f1d5a4 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportInput.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportInput + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0x30 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportOttoto.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportOttoto.h new file mode 100644 index 000000000..6c2cef413 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportOttoto.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportOttoto + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0x70 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h new file mode 100644 index 000000000..561b04e0a --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include +#include +#include +#include + + +namespace Sonicteam::Player +{ + template + class IPostureSupportRayTemplate + { + public: + xpointer m_pVftable; + SoX::RefSharedPointer m_spWorld; + boost::shared_ptr m_spCollisionListener; + xpointer m_pRootFrame; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportSphere.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportSphere.h new file mode 100644 index 000000000..02228ea5a --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportSphere.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportSphere + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0xD0 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.h b/MarathonRecomp/api/Sonicteam/Player/Object.h index 16ea13f96..218f2f08a 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.h +++ b/MarathonRecomp/api/Sonicteam/Player/Object.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -40,12 +41,12 @@ namespace Sonicteam::Player bool m_IsAmigo; MARATHON_INSERT_PADDING(1); SoX::RefSharedPointer m_spRootFrame; - SoX::RefSharedPointer m_spPackageBinary; - boost::shared_ptr m_spPlayerModel; - boost::shared_ptr m_spPlayerPosture; + SoX::RefSharedPointer m_spPackageBinary; + boost::shared_ptr m_spPlayerModel; + boost::shared_ptr m_spPlayerPosture; boost::shared_ptr m_spStateMachine; - boost::shared_ptr m_spPlayerGravity; - boost::shared_ptr m_spPlayerImpulse; + boost::shared_ptr m_spPlayerGravity; + boost::shared_ptr m_spPlayerImpulse; be m_SetupModuleIndexPrefix; be m_SetupModuleIndexPostfix; boost::shared_ptr m_spGauge; @@ -63,10 +64,7 @@ namespace Sonicteam::Player template inline T* GetPlugin(const char* pluginName); - - template - inline T* GetPlugin(const char* v_name); - + }; #pragma pack(pop) } diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.inl b/MarathonRecomp/api/Sonicteam/Player/Object.inl index 1ad2d0fef..9c9c7d512 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.inl +++ b/MarathonRecomp/api/Sonicteam/Player/Object.inl @@ -9,7 +9,7 @@ namespace Sonicteam::Player template - inline T* Object::GetPlugin(const char* pluginName) + T* Object::GetPlugin(const char* pluginName) { for (auto& spPlugin : m_vspPlayerPlugins) { diff --git a/MarathonRecomp/api/Sonicteam/Player/PostureControl.h b/MarathonRecomp/api/Sonicteam/Player/PostureControl.h new file mode 100644 index 000000000..22e2507bd --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/PostureControl.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Sonicteam::Player +{ + class PostureControl : public IPostureControl, public IPostureSupportSphere, public IPostureSupportOttoto, public IPostureSupportEdge, public IPostureSupportInput, public IPostureSupportRayTemplate + { + public: + //Gordon Ramsay + enum ePostureFlag + { + ePostureFlag_Ground = 0x1, // detects Ground + ePostureFlag_WallBrushing = 0x8, // detects brushing against a wall + ePostureFlag_HeadOnWall = 0x10, // detects head-on wall collision (will always be enabled w/ WallBrushing) + ePostureFlag_RailGrind = 0x40, // Rail grinding + ePostureFlag_BeforeFall = 0x100, // seems like Neutral or Pre-Fall? The moment before transitioning from the Jump to Fall animation + ePostureFlag_Fall = 0x200, // FALL + ePostureFlag_WaterCollision = 0x800, // Water collision (making you slide down an incline)? BeforeFall is often set with this + ePostureFlag_LightDash = 0x4000, // Light Dashing + ePostureFlag_QuickRotate = 0x8000, // is moving the control stick in a non-forward direction (usually only active for a frame since the character instantly rotates) + ePostureFlag_Tentative = 0x10000, // is Tentative collision + ePostureFlag_WaterSlide = 0x20000, // Water sliding + ePostureFlag_Grass = 0x100000, // grass + ePostureFlag_DirtClay = 0x200000, // dirt/clay + ePostureFlag_Stone = 0x400000, // stone + ePostureFlag_Shoreline = 0x1000000 // shoreline? sand? Uncertain + }; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h b/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h index 9335afe76..d2f141149 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h @@ -4,40 +4,26 @@ #include #include #include +#include namespace Sonicteam::Player::State { - - - class CommonContext : public ICommonContext, public IExportPostureRequestFlag, public IExportWeaponRequestFlag { public: - - //(Gordon Ramsay) - enum PostureEnum:uint32_t - { - CC_GROUND = 0x1, // detects Ground - CC_WALLBRUSHING = 0x8, // detects brushing against a wall - CC_HEADONWALL = 0x10, // detects head-on wall collision (will always be enabled w/ 2^3) - CC_RAILGRIND = 0x40, // Rail grinding - CC_BEFOREFALL = 0x100, // seems like Neutral or Pre-Fall? The moment before transitioning from the Jump to Fall animation - CC_FALL = 0x200, // FALL - CC_WATERLCOL = 0x800, // Water collision (making you slide down an incline)? 2^8(CC_BEFOREFALL) is often set with this - CC_LIGHTDASHIN = 0x4000, // Light Dashing (2 ^ 14) - CC_QUICKROTATE = 0x8000, // is moving the control stick in a non-forward direction (usually only active for a frame since the character instantly rotates) - CC_TENTATIVE = 0x10000, // is Tentative collision - CC_WATERSLIDE = 0x20000, // Water sliding (2^17) - CC_GRASS = 0x100000, // grass 2^20 - CC_DIRTCLAY = 0x200000, // dirt/clay (2^21) - CC_STONE = 0x400000, // stone (2^22) - CC_SHORELINE = 0x1000000, // shoreline? sand? Uncertain (2^24) - }; - - MARATHON_INSERT_PADDING(0x2C); - be m_PostureFlags; - MARATHON_INSERT_PADDING(0x60); - xpointer m_pScore; - MARATHON_INSERT_PADDING(0x104); + xpointer m_spComboAttackManager; + be m_ContextIFFlag1; + be m_ContextIFFlag2; + be m_ContextIFFlag3; + be m_ExportPostureRequestFlag; + be m_ExportWeaponRequestFlag; + MARATHON_INSERT_PADDING(0x14); + be m_PostureFlag; + be m_ExternalFlag; + be m_VehicleFlag; + be m_AmigoFlag; + MARATHON_INSERT_PADDING(0x50); + boost::shared_ptr m_pScore; //on merge, rename to spScore also do not forget about player_patches.cpp + MARATHON_INSERT_PADDING(0x100); }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h b/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h index 096649107..583c06b4e 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h @@ -21,7 +21,7 @@ namespace Sonicteam::Player::State be m_CurrentStickBorder; // 0 .. 1.0 MARATHON_INSERT_PADDING(4); be m_AnimationState; // & 2 == 0 (Animation End, no any idea about others) - MARATHON_INSERT_PADDING(0x1C); + MARATHON_INSERT_PADDING(0x2C); }; //0x90 diff --git a/MarathonRecomp/api/Sonicteam/Player/Unit/ITestCase.h b/MarathonRecomp/api/Sonicteam/Player/Unit/ITestCase.h new file mode 100644 index 000000000..64786d9fb --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/Unit/ITestCase.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Sonicteam::Player::Unit +{ + class ITestCase + { + public: + xpointer m_pVftable; + }; +} diff --git a/MarathonRecomp/patches/player_patches.cpp b/MarathonRecomp/patches/player_patches.cpp index b894ca76f..b0dda76b2 100644 --- a/MarathonRecomp/patches/player_patches.cpp +++ b/MarathonRecomp/patches/player_patches.cpp @@ -374,22 +374,23 @@ void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_cont auto pGauge = (Sonicteam::Player::SonicGauge*)g_memory.Translate(r_gauge.u32); auto PContext = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(r_context.u32); + if ((uint32_t)(static_cast(pGauge)->m_pVftable.get()) != 0x8200D4D8) // != SonicGauge return; auto weapons = PContext->m_pScore->m_pPlayer->GetPlugin("sonic_weapons"); - if (PContext->m_Tornado != 0 || PContext->m_CurrentAnimation == 0xCB || PContext->m_CurrentAnimation == 0xCC || PContext->m_CurrentAnimation == 0x46 || PContext->m_CurrentAnimation == 0xCE || weapons->m_GunDrive.Entity != 0) + if (PContext->m_Tornado != 0 || PContext->m_AnimationID == 0xCB || PContext->m_AnimationID == 0xCC || PContext->m_AnimationID == 0x46 || PContext->m_AnimationID == 0xCE || weapons->m_GunDrive.Entity != 0) { pGauge->m_GroundedFlags = 1; // Lock game } else { using enum Sonicteam::Player::State::SonicContext::Gems; - if ((PContext->m_Input.get() & 0x10000) != 0) { + if ((PContext->m_Buttons.get() & 0x10000) != 0) { PContext->m_24A = 0; } - if ((PContext->m_Input.get() & 0x20000) != 0 && (PContext->m_CurrentGem == Red || PContext->m_CurrentGem == Purple)) + if ((PContext->m_Buttons.get() & 0x20000) != 0 && (PContext->m_CurrentGem == Red || PContext->m_CurrentGem == Purple)) { pGauge->m_GroundedFlags = 1; if (PContext->m_24A) @@ -399,7 +400,7 @@ void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_cont PContext->m_SlowTime = 0; } } - else if ((PContext->m_PostureFlags.get() & Sonicteam::Player::State::CommonContext::CC_GROUND) != 0 || PContext->m_24A) + else if ((PContext->m_PostureFlag.get() & Sonicteam::Player::PostureControl::ePostureFlag_Ground) != 0 || PContext->m_24A) { pGauge->m_GroundedFlags = 0; @@ -407,4 +408,4 @@ void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_cont } } -//Sonic Gauge Restoration \ No newline at end of file +//Sonic Gauge Restoration From 15ec780f741b9b5879484e950780b6fd6d6a4dd9 Mon Sep 17 00:00:00 2001 From: ReimousTH <51449880+ReimousTH@users.noreply.github.com> Date: Sat, 6 Sep 2025 23:55:21 +0300 Subject: [PATCH 5/8] EXStuff --- MarathonRecomp/api/Marathon.h | 8 ++ .../api/Sonicteam/Player/GroundRayListener.h | 16 +++- .../api/Sonicteam/Player/ICollisionListener.h | 20 +++++ .../Player/ICollisionListenerTemplate.h | 17 +++++ .../api/Sonicteam/Player/IPostureControl.h | 1 - .../api/Sonicteam/Player/PostureControl.h | 34 ++++----- .../api/Sonicteam/Player/State/SonicContext.h | 40 +++++----- MarathonRecomp/api/Sonicteam/SoX/LinkNode.h | 19 +++++ .../api/Sonicteam/SoX/Physics/EntityRef.h | 15 ++++ .../Sonicteam/SoX/Physics/IntersectEvent.h | 9 +++ .../Sonicteam/SoX/Physics/IntersectListener.h | 9 +++ .../Sonicteam/SoX/Physics/ShapeCastEvent.h | 9 +++ .../Sonicteam/SoX/Physics/ShapeCastListener.h | 9 +++ MarathonRecomp/patches/player_patches.cpp | 74 +++++++++---------- 14 files changed, 202 insertions(+), 78 deletions(-) create mode 100644 MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h create mode 100644 MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h create mode 100644 MarathonRecomp/api/Sonicteam/SoX/LinkNode.h create mode 100644 MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h create mode 100644 MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectEvent.h create mode 100644 MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectListener.h create mode 100644 MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastEvent.h create mode 100644 MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastListener.h diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 42769d5b0..11d98f638 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -62,6 +62,8 @@ #include "Sonicteam/Player/RootFrame.h" #include "Sonicteam/Player/Score.h" #include "Sonicteam/Player/SonicGauge.h" +#include "Sonicteam/Player/ICollisionListener.h" +#include "Sonicteam/Player/ICollisionListenerTemplate.h" #include "Sonicteam/Player/State/CommonContext.h" #include "Sonicteam/Player/State/CommonFall.h" #include "Sonicteam/Player/State/CommonObject.h" @@ -82,6 +84,7 @@ #include "Sonicteam/SaveDataTask.h" #include "Sonicteam/SaveDataTaskXENON.h" #include "Sonicteam/SelectWindowTask.h" +#include "Sonicteam/SoX/LinkNode.h" #include "Sonicteam/SoX/AI/StateMachine.h" #include "Sonicteam/SoX/Audio/IAudioEngine.h" #include "Sonicteam/SoX/Component.h" @@ -102,6 +105,11 @@ #include "Sonicteam/SoX/MessageReceiver.h" #include "Sonicteam/SoX/Object.h" #include "Sonicteam/SoX/Physics/Entity.h" +#include "Sonicteam/SoX/Physics/EntityRef.h" +#include "Sonicteam/SoX/Physics/IntersectEvent.h" +#include "Sonicteam/SoX/Physics/IntersectListener.h" +#include "Sonicteam/SoX/Physics/ShapeCastEvent.h" +#include "Sonicteam/SoX/Physics/ShapeCastListener.h" #include "Sonicteam/SoX/Physics/Havok/EntityHavok.h" #include "Sonicteam/SoX/Physics/Havok/EntityHavokImp.h" #include "Sonicteam/SoX/Physics/Havok/PhantomHavok.h" diff --git a/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h index 9c576f9df..4fa7afe7c 100644 --- a/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h +++ b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h @@ -1,14 +1,24 @@ #pragma once #include +#include +#include +#include +#include +#include +#include namespace Sonicteam::Player { //Sonicteam::Player::ICollisionListener, Sonicteam::Player::ICollisionListenerTemplate - class GroundRayListener + class GroundRayListener:public ICollisionListenerTemplate { public: - xpointer m_pVftable; - MARATHON_INSERT_PADDING(0x7C); + SoX::Math::Vector m_ContactPosition; + SoX::Math::Vector m_ContactNormal; + be m_RayDistance; //not sure + be m_RayFlag; //not sure + SoX::Physics::EntityRef m_ContactEntity; + MARATHON_INSERT_PADDING(0xC); }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h b/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h new file mode 100644 index 000000000..52adc7405 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +namespace Sonicteam::Player +{ + //Sonicteam::Player::ICollisionListener, Sonicteam::Player::ICollisionListenerTemplate + class ICollisionListener + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0xC); + be m_Flag1; + be m_Flag2; + be m_Flag3; + MARATHON_INSERT_PADDING(0x4); + SoX::Math::Vector m_CollisionNormal; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h b/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h new file mode 100644 index 000000000..e3cbcd4a6 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +namespace Sonicteam::Player +{ + //Sonicteam::Player::ICollisionListener, Sonicteam::Player::ICollisionListenerTemplate + + template + class ICollisionListenerTemplate:ICollisionListener,Cast + { + public: + + + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h b/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h index 281cb428c..f5447b869 100644 --- a/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h @@ -16,7 +16,6 @@ #include #include - namespace Sonicteam::Player { class IPostureControl : public IVariable, public IDynamicLink, public Unit::ITestCase, public IFlagCommunicator diff --git a/MarathonRecomp/api/Sonicteam/Player/PostureControl.h b/MarathonRecomp/api/Sonicteam/Player/PostureControl.h index 22e2507bd..001a41d41 100644 --- a/MarathonRecomp/api/Sonicteam/Player/PostureControl.h +++ b/MarathonRecomp/api/Sonicteam/Player/PostureControl.h @@ -9,30 +9,30 @@ #include #include - namespace Sonicteam::Player { class PostureControl : public IPostureControl, public IPostureSupportSphere, public IPostureSupportOttoto, public IPostureSupportEdge, public IPostureSupportInput, public IPostureSupportRayTemplate { public: //Gordon Ramsay - enum ePostureFlag + enum PostureFlag { - ePostureFlag_Ground = 0x1, // detects Ground - ePostureFlag_WallBrushing = 0x8, // detects brushing against a wall - ePostureFlag_HeadOnWall = 0x10, // detects head-on wall collision (will always be enabled w/ WallBrushing) - ePostureFlag_RailGrind = 0x40, // Rail grinding - ePostureFlag_BeforeFall = 0x100, // seems like Neutral or Pre-Fall? The moment before transitioning from the Jump to Fall animation - ePostureFlag_Fall = 0x200, // FALL - ePostureFlag_WaterCollision = 0x800, // Water collision (making you slide down an incline)? BeforeFall is often set with this - ePostureFlag_LightDash = 0x4000, // Light Dashing - ePostureFlag_QuickRotate = 0x8000, // is moving the control stick in a non-forward direction (usually only active for a frame since the character instantly rotates) - ePostureFlag_Tentative = 0x10000, // is Tentative collision - ePostureFlag_WaterSlide = 0x20000, // Water sliding - ePostureFlag_Grass = 0x100000, // grass - ePostureFlag_DirtClay = 0x200000, // dirt/clay - ePostureFlag_Stone = 0x400000, // stone - ePostureFlag_Shoreline = 0x1000000 // shoreline? sand? Uncertain + PostureFlag_Ground = 0x1, // detects Ground + PostureFlag_WallBrushing = 0x8, // detects brushing against a wall + PostureFlag_HeadOnWall = 0x10, // detects head-on wall collision (will always be enabled w/ WallBrushing) + PostureFlag_RailGrind = 0x40, // Rail grinding + PostureFlag_BeforeFall = 0x100, // seems like Neutral or Pre-Fall? The moment before transitioning from the Jump to Fall animation + PostureFlag_Fall = 0x200, // FALL + PostureFlag_WaterCollision = 0x800, // Water collision (making you slide down an incline)? BeforeFall is often set with this + PostureFlag_LightDash = 0x4000, // Light Dashing + PostureFlag_QuickRotate = 0x8000, // is moving the control stick in a non-forward direction (usually only active for a frame since the character instantly rotates) + PostureFlag_Tentative = 0x10000, // is Tentative collision + PostureFlag_WaterSlide = 0x20000, // Water sliding + PostureFlag_Grass = 0x100000, // grass + PostureFlag_DirtClay = 0x200000, // dirt/clay + PostureFlag_Stone = 0x400000, // stone + PostureFlag_Shoreline = 0x1000000 // shoreline? sand? Uncertain }; + // 0x314 ... 0x400 }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h b/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h index f14efaad5..0d5f65059 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h @@ -11,31 +11,31 @@ namespace Sonicteam::Player::State { public: //Sprite - enum GemsS:uint32_t + enum GemSprite:uint32_t { - SGreen = 1, - SRed, - SBlue, - SWhite, - SSky, - SYellow, - SPurple, - SSuper + GemSprite_Green = 1, + GemSprite_Red, + GemSprite_Blue, + GemSprite_White, + GemSprite_Sky, + GemSprite_Yellow, + GemSprite_Purple, + GemSprite_Super }; - enum Gems:uint32_t + enum Gem:uint32_t { - Blue = 1, - Red, - Green, - Purple, - Sky, - White, - Yellow, - Super + Gem_Blue = 1, + Gem_Red, + Gem_Green, + Gem_Purple, + Gem_Sky, + Gem_White, + Gem_Yellow, + Gem_Super }; - be m_CurrentGemSprite; + be m_CurrentGemSprite; boost::shared_ptr m_Gauge; uint8_t m_HomingLockOn; uint8_t m_DisablePlayerMovement; @@ -54,7 +54,7 @@ namespace Sonicteam::Player::State uint8_t m_24A; uint8_t m_24B; be m_HomingFlip; - be m_CurrentGem; + be m_CurrentGem; MARATHON_INSERT_PADDING(0x58); }; } diff --git a/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h b/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h new file mode 100644 index 000000000..e1c4234ca --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h @@ -0,0 +1,19 @@ +#pragma once + +namespace Sonicteam::SoX +{ + template + class LinkNodeTemplate + { + public: + xpointer m_pPrev; + xpointer m_pNext; + }; + + template + class LinkNode : public LinkNodeTemplate> + { + public: + xpointer> m_pThis; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h new file mode 100644 index 000000000..527894665 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include +#include + +namespace Sonicteam::SoX::Physics +{ + struct EntityRef + { + public: + xpointer m_pEntity; + Sonicteam::SoX::LinkNode m_lnEntity; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectEvent.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectEvent.h new file mode 100644 index 000000000..2156724c1 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectEvent.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class IntersectEvent {}; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectListener.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectListener.h new file mode 100644 index 000000000..247b6763b --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectListener.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class IntersectListener : public SoX::RefCountObject {}; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastEvent.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastEvent.h new file mode 100644 index 000000000..14e9e4a91 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastEvent.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class ShapeCastEvent {}; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastListener.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastListener.h new file mode 100644 index 000000000..281a2c81a --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastListener.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class ShapeCastListener : public SoX::RefCountObject {}; +} diff --git a/MarathonRecomp/patches/player_patches.cpp b/MarathonRecomp/patches/player_patches.cpp index b0dda76b2..8c219e736 100644 --- a/MarathonRecomp/patches/player_patches.cpp +++ b/MarathonRecomp/patches/player_patches.cpp @@ -185,23 +185,23 @@ bool ControllableSpinkick() } -/////////////////////////////////////////////////////// -///////////// Sonic Gauge Restoration //////////////// +///////////////////////////////////////////////////////// +////////// Sonic Gauge Restoration EX Version ///////// //////////////////////////////////////////////////////// -const Sonicteam::Player::State::SonicContext::GemsS gemConversionTable[] = { - Sonicteam::Player::State::SonicContext::GemsS::SBlue, - Sonicteam::Player::State::SonicContext::GemsS::SRed, - Sonicteam::Player::State::SonicContext::GemsS::SGreen, - Sonicteam::Player::State::SonicContext::GemsS::SPurple, - Sonicteam::Player::State::SonicContext::GemsS::SSky, - Sonicteam::Player::State::SonicContext::GemsS::SWhite, - Sonicteam::Player::State::SonicContext::GemsS::SYellow, - Sonicteam::Player::State::SonicContext::GemsS::SSuper +const Sonicteam::Player::State::SonicContext::GemSprite gemConversionTable[] = { + Sonicteam::Player::State::SonicContext::GemSprite_Blue, + Sonicteam::Player::State::SonicContext::GemSprite_Red, + Sonicteam::Player::State::SonicContext::GemSprite_Green, + Sonicteam::Player::State::SonicContext::GemSprite_Purple, + Sonicteam::Player::State::SonicContext::GemSprite_Sky, + Sonicteam::Player::State::SonicContext::GemSprite_White, + Sonicteam::Player::State::SonicContext::GemSprite_Yellow, + Sonicteam::Player::State::SonicContext::GemSprite_Super }; //Check Gauge Drain -//SonicTeam::Player::SonicGauge (IVariable), IVariable::Init(REF_TYPE(SonicTeam::LuaSystem)) +//SonicTeam::Player::SonicGauge (IVariable), IVariable::Init(RefSharedPointer) PPC_FUNC_IMPL(__imp__sub_82217FC0); PPC_FUNC(sub_82217FC0) { @@ -214,18 +214,18 @@ PPC_FUNC(sub_82217FC0) { auto context = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(ctx.r3.u32); auto gauge = context->m_Gauge.get(); - using enum Sonicteam::Player::State::SonicContext::Gems; - auto gem_id = (Sonicteam::Player::State::SonicContext::Gems)(ctx.r4.u32); + using enum Sonicteam::Player::State::SonicContext::Gem; + auto gem_id = (Sonicteam::Player::State::SonicContext::Gem)(ctx.r4.u32); switch (gem_id) { - case Yellow: - if (context->m_ThunderGuard) break; - case Blue: - case Green: - case Sky: - case White: - case Super: + case Gem_Yellow: + if (context->m_ThunderGuard) break; //Prevent Yellow Gem spam, useless anyway + case Gem_Blue: + case Gem_Green: + case Gem_Sky: + case Gem_White: + case Gem_Super: { size_t index = gemConversionTable[gem_id - 1] - 1; if (gauge->m_Value >= (&gauge->m_Green)[index].get()) @@ -235,8 +235,8 @@ PPC_FUNC(sub_82217FC0) { } break; } - case Red: - case Purple: + case Gem_Red: + case Gem_Purple: if (context->m_24A == 0) { ctx.r3.u64 = 1; @@ -261,26 +261,26 @@ PPC_FUNC(sub_82218068) { auto context = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(ctx.r3.u32); auto gauge = context->m_Gauge.get(); - using enum Sonicteam::Player::State::SonicContext::Gems; - auto gem_id = (Sonicteam::Player::State::SonicContext::Gems)(ctx.r4.u32); + using enum Sonicteam::Player::State::SonicContext::Gem; + auto gem_id = (Sonicteam::Player::State::SonicContext::Gem)(ctx.r4.u32); double delta = ctx.f1.f64; switch (gem_id) { - case Blue: - case Green: - case Yellow: - case Sky: - case White: - case Super: + case Gem_Blue: + case Gem_Green: + case Gem_Yellow: + case Gem_Sky: + case Gem_White: + case Gem_Super: { uint32_t index = gemConversionTable[gem_id - 1] - 1; gauge->m_Value = gauge->m_Value.get() - (&gauge->m_Green)[index].get(); gauge->m_GroundedTime = 0.0; break; } - case Red: - case Purple: + case Gem_Red: + case Gem_Purple: { uint32_t index = gemConversionTable[gem_id - 1] - 1; gauge->m_Value = gauge->m_Value.get() - (&gauge->m_Green)[index].get() * delta; @@ -381,16 +381,16 @@ void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_cont auto weapons = PContext->m_pScore->m_pPlayer->GetPlugin("sonic_weapons"); if (PContext->m_Tornado != 0 || PContext->m_AnimationID == 0xCB || PContext->m_AnimationID == 0xCC || PContext->m_AnimationID == 0x46 || PContext->m_AnimationID == 0xCE || weapons->m_GunDrive.Entity != 0) { - pGauge->m_GroundedFlags = 1; // Lock game + pGauge->m_GroundedFlags = 1; // Lock gauge } else { - using enum Sonicteam::Player::State::SonicContext::Gems; + using enum Sonicteam::Player::State::SonicContext::Gem; if ((PContext->m_Buttons.get() & 0x10000) != 0) { PContext->m_24A = 0; } - if ((PContext->m_Buttons.get() & 0x20000) != 0 && (PContext->m_CurrentGem == Red || PContext->m_CurrentGem == Purple)) + if ((PContext->m_Buttons.get() & 0x20000) != 0 && (PContext->m_CurrentGem == Gem_Red || PContext->m_CurrentGem == Gem_Purple)) { pGauge->m_GroundedFlags = 1; if (PContext->m_24A) @@ -400,7 +400,7 @@ void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_cont PContext->m_SlowTime = 0; } } - else if ((PContext->m_PostureFlag.get() & Sonicteam::Player::PostureControl::ePostureFlag_Ground) != 0 || PContext->m_24A) + else if ((PContext->m_PostureFlag.get() & Sonicteam::Player::PostureControl::PostureFlag_Ground) != 0 || PContext->m_24A) { pGauge->m_GroundedFlags = 0; From 7b0c0077e4217446193425eca6e40ef75913b021 Mon Sep 17 00:00:00 2001 From: ReimousTH <51449880+ReimousTH@users.noreply.github.com> Date: Sun, 7 Sep 2025 00:41:13 +0300 Subject: [PATCH 6/8] adjustments #1 --- MarathonRecomp/api/Marathon.h | 2 +- .../api/Sonicteam/Player/GroundRayListener.h | 5 ++-- .../api/Sonicteam/Player/ICollisionListener.h | 1 - .../Player/ICollisionListenerTemplate.h | 9 +------ .../Player/IPostureSupportRayTemplate.h | 1 - .../api/Sonicteam/Player/Object.inl | 4 ++-- .../Sonicteam/Player/Weapon/SonicWeapons.h | 24 ++++--------------- MarathonRecomp/api/Sonicteam/SoX/LinkNode.h | 14 ++++++++--- .../api/Sonicteam/SoX/Physics/EntityRef.h | 15 ------------ MarathonRecomp/patches/player_patches.cpp | 2 +- 10 files changed, 22 insertions(+), 55 deletions(-) delete mode 100644 MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 11d98f638..bd2c0e7dd 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -104,8 +104,8 @@ #include "Sonicteam/SoX/Math/Vector.h" #include "Sonicteam/SoX/MessageReceiver.h" #include "Sonicteam/SoX/Object.h" +#include "Sonicteam/SoX/LinkNode.h" #include "Sonicteam/SoX/Physics/Entity.h" -#include "Sonicteam/SoX/Physics/EntityRef.h" #include "Sonicteam/SoX/Physics/IntersectEvent.h" #include "Sonicteam/SoX/Physics/IntersectListener.h" #include "Sonicteam/SoX/Physics/ShapeCastEvent.h" diff --git a/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h index 4fa7afe7c..948c47527 100644 --- a/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h +++ b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h @@ -6,11 +6,10 @@ #include #include #include -#include +#include namespace Sonicteam::Player { - //Sonicteam::Player::ICollisionListener, Sonicteam::Player::ICollisionListenerTemplate class GroundRayListener:public ICollisionListenerTemplate { public: @@ -18,7 +17,7 @@ namespace Sonicteam::Player SoX::Math::Vector m_ContactNormal; be m_RayDistance; //not sure be m_RayFlag; //not sure - SoX::Physics::EntityRef m_ContactEntity; + SoX::LinkRef m_ContactEntity; MARATHON_INSERT_PADDING(0xC); }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h b/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h index 52adc7405..5ed0e9b80 100644 --- a/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h +++ b/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h @@ -5,7 +5,6 @@ namespace Sonicteam::Player { - //Sonicteam::Player::ICollisionListener, Sonicteam::Player::ICollisionListenerTemplate class ICollisionListener { public: diff --git a/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h b/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h index e3cbcd4a6..66c0747f7 100644 --- a/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h +++ b/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h @@ -5,13 +5,6 @@ namespace Sonicteam::Player { - //Sonicteam::Player::ICollisionListener, Sonicteam::Player::ICollisionListenerTemplate - template - class ICollisionListenerTemplate:ICollisionListener,Cast - { - public: - - - }; + class ICollisionListenerTemplate:ICollisionListener,Cast {}; } diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h index 561b04e0a..59536ec5a 100644 --- a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h @@ -6,7 +6,6 @@ #include #include - namespace Sonicteam::Player { template diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.inl b/MarathonRecomp/api/Sonicteam/Player/Object.inl index 9c9c7d512..5324da751 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.inl +++ b/MarathonRecomp/api/Sonicteam/Player/Object.inl @@ -8,13 +8,13 @@ namespace Sonicteam::Player } template - - T* Object::GetPlugin(const char* pluginName) + inline T* Object::GetPlugin(const char* pluginName) { for (auto& spPlugin : m_vspPlayerPlugins) { if (spPlugin->m_Name == pluginName) return static_cast(spPlugin.get()); } + return nullptr; } } diff --git a/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h b/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h index 6760ddace..5fadba8a3 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h +++ b/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h @@ -1,4 +1,5 @@ #pragma once + #include #include #include @@ -7,32 +8,15 @@ #include #include #include - - - +#include namespace Sonicteam::Player::Weapon -{ - template - struct LinkSoxNode - { - xpointer> m_Prev; - xpointer> m_Next; - Type* m_This; - }; - - template - struct EntityContainer - { - xpointer Entity; - LinkSoxNode m_Link; - }; - +{ class SonicWeapons : public IPlugIn, public IFlagCommunicator, public IStepable, public IDynamicLink, public IVariable, public INotification { public: MARATHON_INSERT_PADDING(0x4C); - EntityContainer m_GunDrive; + SoX::LinkRef m_GunDrive; MARATHON_INSERT_PADDING(0x24); }; } diff --git a/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h b/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h index e1c4234ca..92280d7d1 100644 --- a/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h +++ b/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h @@ -5,15 +5,23 @@ namespace Sonicteam::SoX template class LinkNodeTemplate { - public: + public: xpointer m_pPrev; xpointer m_pNext; - }; + }; template - class LinkNode : public LinkNodeTemplate> + class LinkNode : public LinkNodeTemplate> { public: xpointer> m_pThis; }; + + template + class LinkRef + { + public: + xpointer m_pElement; + SoX::LinkNode m_lnElement; + }; } diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h deleted file mode 100644 index 527894665..000000000 --- a/MarathonRecomp/api/Sonicteam/SoX/Physics/EntityRef.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace Sonicteam::SoX::Physics -{ - struct EntityRef - { - public: - xpointer m_pEntity; - Sonicteam::SoX::LinkNode m_lnEntity; - }; -} diff --git a/MarathonRecomp/patches/player_patches.cpp b/MarathonRecomp/patches/player_patches.cpp index 8c219e736..c06e3edbb 100644 --- a/MarathonRecomp/patches/player_patches.cpp +++ b/MarathonRecomp/patches/player_patches.cpp @@ -379,7 +379,7 @@ void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_cont return; auto weapons = PContext->m_pScore->m_pPlayer->GetPlugin("sonic_weapons"); - if (PContext->m_Tornado != 0 || PContext->m_AnimationID == 0xCB || PContext->m_AnimationID == 0xCC || PContext->m_AnimationID == 0x46 || PContext->m_AnimationID == 0xCE || weapons->m_GunDrive.Entity != 0) + if (PContext->m_Tornado != 0 || PContext->m_AnimationID == 0xCB || PContext->m_AnimationID == 0xCC || PContext->m_AnimationID == 0x46 || PContext->m_AnimationID == 0xCE || weapons->m_GunDrive.m_pElement.get() != nullptr) { pGauge->m_GroundedFlags = 1; // Lock gauge } From 2ca4637554a1bc2ae79890764c940db1fac420a4 Mon Sep 17 00:00:00 2001 From: ReimousTH <51449880+ReimousTH@users.noreply.github.com> Date: Sun, 7 Sep 2025 00:42:19 +0300 Subject: [PATCH 7/8] adjustments #2 --- MarathonRecomp/patches/player_patches.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/MarathonRecomp/patches/player_patches.cpp b/MarathonRecomp/patches/player_patches.cpp index c06e3edbb..fc3806f9f 100644 --- a/MarathonRecomp/patches/player_patches.cpp +++ b/MarathonRecomp/patches/player_patches.cpp @@ -406,6 +406,5 @@ void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_cont } } - } //Sonic Gauge Restoration From 87c289ba9ce93b827b87696c787ee823a23d8ae0 Mon Sep 17 00:00:00 2001 From: ReimousTH <51449880+ReimousTH@users.noreply.github.com> Date: Sun, 7 Sep 2025 00:52:47 +0300 Subject: [PATCH 8/8] ?> --- MarathonRecompResources | 2 +- thirdparty/plume | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MarathonRecompResources b/MarathonRecompResources index ceb0bdcf5..e0c15da29 160000 --- a/MarathonRecompResources +++ b/MarathonRecompResources @@ -1 +1 @@ -Subproject commit ceb0bdcf5bce7bd694433d0c8208366480b0e8fb +Subproject commit e0c15da298954b8046af761af731ed1b9ff14412 diff --git a/thirdparty/plume b/thirdparty/plume index 2f72b6714..61e19e19d 160000 --- a/thirdparty/plume +++ b/thirdparty/plume @@ -1 +1 @@ -Subproject commit 2f72b6714e2e36d19df876e7238f2361cc2a3284 +Subproject commit 61e19e19dcf4f44fbe7f7445f21904b0e27fbb3d