Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto dev
  • Loading branch information
zer0k-z committed Nov 27, 2024
2 parents ce38b44 + f32206e commit e3df04d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
4 changes: 3 additions & 1 deletion AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ class MMSPluginConfig(object):
if builder.options.opt == '1':
cxx.defines += ['NDEBUG']
if cxx.behavior == 'gcc':
cxx.cflags += ['-O3']
cxx.cflags += ['-O3', '-flto']
cxx.cxxflags += ['-g1'] # override ambuild's default -g3 flag.
cxx.linkflags += ['-flto']
elif cxx.behavior == 'msvc':
cxx.cflags += ['/Ox', '/Zo']
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
Expand Down
31 changes: 16 additions & 15 deletions src/movement/mv_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ void MovementPlayer::OnProcessMovement()
this->walkMoved = false;
this->takeoffFromLadder = false;
this->collidingWithWorld = false;

bool onGround = this->GetPlayerPawn()->m_fFlags() & FL_ONGROUND;
if (!this->previousOnGround && onGround)
{
Vector velocity;
this->GetVelocity(&velocity);
this->RegisterLanding(velocity, false);
this->OnStartTouchGround();
}
else if (this->previousOnGround && !onGround)
{
this->RegisterTakeoff(false);
this->takeoffFromLadder = false;
this->OnStopTouchGround();
}
}

void MovementPlayer::OnProcessMovementPost()
Expand All @@ -26,6 +41,7 @@ void MovementPlayer::OnProcessMovementPost()
this->oldAngles = this->moveDataPost.m_vecViewAngles;
}
this->oldWalkMoved = this->walkMoved;
this->previousOnGround = this->GetPlayerPawn()->m_fFlags() & FL_ONGROUND;
}

CCSPlayer_MovementServices *MovementPlayer::GetMoveServices()
Expand Down Expand Up @@ -407,24 +423,9 @@ void MovementPlayer::OnPhysicsSimulate()
{
this->OnChangeMoveType(this->lastKnownMoveType);
}
bool onGround = this->GetPlayerPawn()->m_fFlags() & FL_ONGROUND;
if (!this->previousOnGround && onGround)
{
Vector velocity;
this->GetVelocity(&velocity);
this->RegisterLanding(velocity, false);
this->OnStartTouchGround();
}
else if (this->previousOnGround && !onGround)
{
this->RegisterTakeoff(false);
this->takeoffFromLadder = false;
this->OnStopTouchGround();
}
}

void MovementPlayer::OnPhysicsSimulatePost()
{
this->lastKnownMoveType = this->GetMoveType();
this->previousOnGround = this->GetPlayerPawn()->m_fFlags() & FL_ONGROUND;
}
9 changes: 7 additions & 2 deletions src/utils/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "sdk/entity/cbasetrigger.h"

#include "vprof.h"

#include "memdbgon.h"

extern CSteamGameServerAPIContext g_steamAPI;
Expand Down Expand Up @@ -173,7 +175,7 @@ void hooks::Initialize()
SH_ADD_HOOK(ISource2GameClients, OnClientConnected, g_pSource2GameClients, SH_STATIC(Hook_OnClientConnected), false);
SH_ADD_HOOK(ISource2GameClients, ClientFullyConnect, g_pSource2GameClients, SH_STATIC(Hook_ClientFullyConnect), false);
SH_ADD_HOOK(ISource2GameClients, ClientPutInServer, g_pSource2GameClients, SH_STATIC(Hook_ClientPutInServer), false);
SH_ADD_HOOK(ISource2GameClients, ClientActive, g_pSource2GameClients, SH_STATIC(Hook_ClientActive), false);
SH_ADD_HOOK(ISource2GameClients, ClientActive, g_pSource2GameClients, SH_STATIC(Hook_ClientActive), true);
SH_ADD_HOOK(ISource2GameClients, ClientDisconnect, g_pSource2GameClients, SH_STATIC(Hook_ClientDisconnect), true);
SH_ADD_HOOK(ISource2GameClients, ClientVoice, g_pSource2GameClients, SH_STATIC(Hook_ClientVoice), false);
SH_ADD_HOOK(ISource2GameClients, ClientCommand, g_pSource2GameClients, SH_STATIC(Hook_ClientCommand), false);
Expand Down Expand Up @@ -464,6 +466,7 @@ static_function void Hook_CheckTransmit(CCheckTransmitInfo **pInfo, int infoCoun
// ISource2Server
static_function void Hook_GameFrame(bool simulating, bool bFirstTick, bool bLastTick)
{
VPROF_BUDGET(__func__, "CS2KZ");
g_KZPlugin.serverGlobals = *(g_pKZUtils->GetGlobals());
KZ::timer::CheckAnnounceQueue();
KZ::timer::CheckPBRequests();
Expand Down Expand Up @@ -519,7 +522,7 @@ static_function void Hook_ClientActive(CPlayerSlot slot, bool bLoadGame, const c
}
else
{
Warning("WARNING: Player pawn for slot %i not found!\n", slot.Get());
Warning("[KZ] WARNING: Player pawn for slot %i not found!\n", slot.Get());
}
RETURN_META(MRES_IGNORED);
}
Expand Down Expand Up @@ -555,6 +558,7 @@ static_function void Hook_ClientVoice(CPlayerSlot slot)

static_function void Hook_ClientCommand(CPlayerSlot slot, const CCommand &args)
{
VPROF_BUDGET(__func__, "CS2KZ");
if (META_RES result = KZ::misc::CheckBlockedRadioCommands(args[0]))
{
RETURN_META(result);
Expand Down Expand Up @@ -625,6 +629,7 @@ static_function bool Hook_FireEvent(IGameEvent *event, bool bDontBroadcast)
// ICvar
static_function void Hook_DispatchConCommand(ConCommandHandle cmd, const CCommandContext &ctx, const CCommand &args)
{
VPROF_BUDGET(__func__, "CS2KZ");
if (META_RES result = KZ::misc::CheckBlockedRadioCommands(args[0]))
{
RETURN_META(result);
Expand Down

0 comments on commit e3df04d

Please sign in to comment.