Skip to content

Commit 559c665

Browse files
author
whohyno
authored
fix pLocal/pWeapon being nullptr on first tick of joining a map (#22)
* fix pLocal/pWeapon being nullptr on first tick of joining a map * just, don't ask please * Update ClientModeShared_CreateMove.cpp
1 parent f8c0064 commit 559c665

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Fusion/src/Hooks/ClientModeShared_CreateMove.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,21 @@ MAKE_HOOK(ClientModeShared_CreateMove, U::Memory.GetVFunc(I::ClientModeShared, 2
2626

2727
I::Prediction->Update(I::ClientState->m_nDeltaTick, I::ClientState->m_nDeltaTick > 0, I::ClientState->last_command_ack, I::ClientState->lastoutgoingcommand + I::ClientState->chokedcommands);
2828

29+
auto pLocal = H::Entities.GetLocal();
30+
auto pWeapon = H::Entities.GetWeapon();
31+
2932
G::CurrentUserCmd = pCmd;
30-
if (!G::LastUserCmd)
33+
if (!G::LastUserCmd) {
3134
G::LastUserCmd = pCmd;
35+
pLocal = I::ClientEntityList->GetClientEntity(I::EngineClient->GetLocalPlayer())->As<CTFPlayer>();
36+
pWeapon = pLocal->m_hActiveWeapon().Get()->As<CTFWeaponBase>();
37+
}
3238

3339
// correct tick_count for fakeinterp / nointerp
3440
pCmd->tick_count += TICKS_TO_TIME(F::Backtrack.flFakeInterp) - (Vars::Visuals::Removals::Interpolation.Value ? 0 : TICKS_TO_TIME(G::Lerp));
3541
if (G::Buttons & IN_DUCK) // lol
3642
pCmd->buttons |= IN_DUCK;
3743

38-
auto pLocal = H::Entities.GetLocal();
39-
auto pWeapon = H::Entities.GetWeapon();
4044
if (pLocal && pWeapon)
4145
{ // Update Global Info
4246
int nOldDefIndex = G::WeaponDefIndex;

0 commit comments

Comments
 (0)