Skip to content

Commit

Permalink
fix pLocal/pWeapon being nullptr on first tick of joining a map (#22)
Browse files Browse the repository at this point in the history
* fix pLocal/pWeapon being nullptr on first tick of joining a map

* just, don't ask please

* Update ClientModeShared_CreateMove.cpp
  • Loading branch information
whohyno authored Sep 27, 2024
1 parent f8c0064 commit 559c665
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Fusion/src/Hooks/ClientModeShared_CreateMove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ MAKE_HOOK(ClientModeShared_CreateMove, U::Memory.GetVFunc(I::ClientModeShared, 2

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

auto pLocal = H::Entities.GetLocal();
auto pWeapon = H::Entities.GetWeapon();

G::CurrentUserCmd = pCmd;
if (!G::LastUserCmd)
if (!G::LastUserCmd) {
G::LastUserCmd = pCmd;
pLocal = I::ClientEntityList->GetClientEntity(I::EngineClient->GetLocalPlayer())->As<CTFPlayer>();
pWeapon = pLocal->m_hActiveWeapon().Get()->As<CTFWeaponBase>();
}

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

auto pLocal = H::Entities.GetLocal();
auto pWeapon = H::Entities.GetWeapon();
if (pLocal && pWeapon)
{ // Update Global Info
int nOldDefIndex = G::WeaponDefIndex;
Expand Down

0 comments on commit 559c665

Please sign in to comment.