Skip to content

Commit 109a9f1

Browse files
authored
Tails Npc Crash Fix (#126)
* Null * tails_npc Crash Fix Sonicteam::Player::State::*Context IDynamicLink::Init, Removed, due std::vector<T> order. Replaced with Score module + check .lua file. * Correction * Correction #2 * Correction * Correction #2
1 parent 2beda28 commit 109a9f1

2 files changed

Lines changed: 12 additions & 21 deletions

File tree

MarathonRecomp/api/Sonicteam/Player/Object.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ namespace Sonicteam::Player
88
class Object : public Actor
99
{
1010
public:
11-
MARATHON_INSERT_PADDING(0x40);
11+
stdx::string m_PlayerLua;
12+
stdx::string m_PlayerPackage;
13+
MARATHON_INSERT_PADDING(0x8);
1214
be<uint32_t> m_PlayerIndex;
1315
MARATHON_INSERT_PADDING(0x48);
1416
boost::shared_ptr<State::Machine2> m_spStateMachine;

MarathonRecomp/patches/player_patches.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,14 @@ PPC_FUNC(sub_8221A7D8)
4141
__imp__sub_8221A7D8(ctx, base);
4242
}
4343

44-
// Sonicteam::Player::State::*Context IDynamicLink::Init
45-
PPC_FUNC_IMPL(__imp__sub_8220F330);
46-
PPC_FUNC(sub_8220F330)
44+
// Sonicteam::Player::State::*Context IDynamicLink::Init, Removed
45+
// SonicTeam::Player::Score::ctor
46+
PPC_FUNC_IMPL(__imp__sub_821E8C48);
47+
PPC_FUNC(sub_821E8C48)
4748
{
48-
if (!Config::TailsGauge)
49+
auto pPlayer = (Sonicteam::Player::Object*)(base + ctx.r4.u32);
50+
if (pPlayer->m_PlayerLua == "player/tails.lua")
4951
{
50-
__imp__sub_8220F330(ctx, base);
51-
return;
52-
}
53-
54-
auto pDynamicLink = (Sonicteam::Player::IDynamicLink*)(base + ctx.r3.u32);
55-
auto spPlugin = (boost::shared_ptr<Sonicteam::Player::IPlugIn>*)(base + ctx.r4.u32);
56-
57-
// If this call is from TailsContext and this plugin is Sonicteam::Player::Score, set up the action gauge.
58-
// This is typically set up by OpenGauge in Lua, but we can't do this here.
59-
if (pDynamicLink->m_pVftable.ptr == 0x8200B7F4 && spPlugin->get()->m_Name == "score")
60-
{
61-
auto pScore = (Sonicteam::Player::Score*)spPlugin->get();
6252
auto pSonicGauge = GuestToHostFunction<Sonicteam::Player::SonicGauge*>(sub_8223F208, g_userHeap.Alloc(sizeof(Sonicteam::Player::SonicGauge)));
6353

6454
guest_stack_var<boost::shared_ptr<Sonicteam::Player::IGauge>> spSonicGauge;
@@ -67,12 +57,11 @@ PPC_FUNC(sub_8220F330)
6757
GuestToHostFunction<void>(sub_821BEAB0, spSonicGauge.get(), pSonicGauge);
6858

6959
// Add gauge plugin to player.
70-
GuestToHostFunction<void>(sub_821BECE0, pScore->m_pPlayer.get(), spSonicGauge.get(), 1);
60+
GuestToHostFunction<void>(sub_821BECE0, pPlayer, spSonicGauge.get(), 1);
7161

72-
pScore->m_pPlayer->m_spGauge = *spSonicGauge.get();
62+
pPlayer->m_spGauge = *spSonicGauge.get();
7363
}
74-
75-
__imp__sub_8220F330(ctx, base);
64+
__imp__sub_821E8C48(ctx, base);
7665
}
7766

7867
bool MidairMachSpeedControl1()

0 commit comments

Comments
 (0)