Skip to content

Commit

Permalink
fix: client process movement
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisAMJ committed Aug 24, 2024
1 parent eba941c commit d061342
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/Event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ namespace Event {
bool server;
void *player;
CMoveData *move;
CUserCmd *cmd;
bool grounded;
};
template <>
Expand Down
14 changes: 3 additions & 11 deletions src/Modules/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,8 @@ DETOUR(Client::DecodeUserCmdFromBuffer, int nSlot, int buf, signed int sequence_
void *player = client->GetPlayer(nSlot + 1);
if (player) {
bool grounded = CE(player)->ground_entity();
groundFramesCounter->HandleMovementFrame(nSlot, grounded);
strafeQualityHud->OnMovement(nSlot, grounded);
strafeHud.SetData(nSlot, player, cmd, false);
Event::Trigger<Event::PROCESS_MOVEMENT>({nSlot, false}); // There isn't really one, just pretend it's here lol
Event::Trigger<Event::PROCESS_MOVEMENT>({nSlot, false, player, nullptr, cmd, grounded}); // There isn't really one, just pretend it's here lol
}

if (cmd->buttons & IN_ATTACK) {
Expand Down Expand Up @@ -714,14 +712,8 @@ DETOUR(Client::ProcessMovement, void *player, CMoveData *move) {
if (tick != lastTick) {
bool grounded = CE(player)->ground_entity();
slot = client->GetSplitScreenPlayerSlot(player);
groundFramesCounter->HandleMovementFrame(slot, grounded);
rhythmGameHud->HandleGroundframeLogic(slot, grounded);
strafeQualityHud->OnMovement(slot, grounded);
if (move->m_nButtons & IN_JUMP) scrollSpeedHud->OnJump(slot, grounded);
if (move->m_nButtons & IN_JUMP && grounded) rhythmGameHud->OnJump(slot);


Event::Trigger<Event::PROCESS_MOVEMENT>({slot, false});

Event::Trigger<Event::PROCESS_MOVEMENT>({slot, false, player, move, nullptr, grounded});
lastTick = tick;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Hook g_ViewPunch_Hook(&Server::ViewPunch_Hook);
DETOUR(Server::ProcessMovement, void *player, CMoveData *move) {
int slot = server->GetSplitScreenPlayerSlot(player);
bool grounded = SE(player)->ground_entity();
Event::Trigger<Event::PROCESS_MOVEMENT>({ slot, true, player, move, grounded });
Event::Trigger<Event::PROCESS_MOVEMENT>({ slot, true, player, move, nullptr, grounded });

auto res = Server::ProcessMovement(thisptr, player, move);

Expand Down Expand Up @@ -759,7 +759,7 @@ Variable sar_fix_viewmodel_bug("sar_fix_viewmodel_bug", "0", "Fixes the viewmode
ON_EVENT(SESSION_START) {
g_sendResetDoneAt = -1;

/* spawn viewmodel if it doesnt exist */
/* spawn viewmodel if it doesn't exist */
if (sar_fix_viewmodel_bug.GetBool())
if (CreateViewModel && !engine->IsCoop() && !entityList->GetEntityInfoByClassName("viewmodel") && !engine->demoplayer->IsPlaying())
CreateViewModel(server->GetPlayer(1), 0);
Expand Down

0 comments on commit d061342

Please sign in to comment.