Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
few optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
rbl-dot committed May 6, 2023
1 parent a26e7e1 commit 472d624
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 566 deletions.
65 changes: 37 additions & 28 deletions sakura/source/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ int HUD_Key_Event(int down, int keynum, const char* pszCurrentBinding)
{
if (keystrafetoggle && down)
{
Strafe = !Strafe;
Toast::Create({ 3, /*Strafe %s*/XorStr<0xBB,10,0xB6AE3E40>("\xE8\xC8\xCF\xDF\xD9\xA5\xE1\xE7\xB0" + 0xB6AE3E40).s, Strafe ? /*activated*/XorStr<0xE0,10,0x0EEE144D>("\x81\x82\x96\x8A\x92\x84\x92\x82\x8C" + 0x0EEE144D).s : /*deactivated*/XorStr<0x81,12,0x76BE5F91>("\xE5\xE7\xE2\xE7\xF1\xEF\xF1\xE9\xFD\xEF\xEF" + 0x76BE5F91).s });
Sakura::HNS::Strafe::Active = !Sakura::HNS::Strafe::Active;
Toast::Create({ 3, /*Strafe %s*/XorStr<0xBB,10,0xB6AE3E40>("\xE8\xC8\xCF\xDF\xD9\xA5\xE1\xE7\xB0" + 0xB6AE3E40).s, Sakura::HNS::Strafe::Active ? /*activated*/XorStr<0xE0,10,0x0EEE144D>("\x81\x82\x96\x8A\x92\x84\x92\x82\x8C" + 0x0EEE144D).s : /*deactivated*/XorStr<0x81,12,0x76BE5F91>("\xE5\xE7\xE2\xE7\xF1\xEF\xF1\xE9\xFD\xEF\xEF" + 0x76BE5F91).s });
}

if (thirdpersonkey && down)
Expand All @@ -125,19 +125,19 @@ int HUD_Key_Event(int down, int keynum, const char* pszCurrentBinding)
}

if (keystrafe)
Strafe = down;
Sakura::HNS::Strafe::Active = down;

if (keyfast)
Fastrun = down;
Sakura::HNS::Fastrun::Active = down;

if (keygstrafe)
Gstrafe = down;
Sakura::HNS::Groundstrafe::Active = down;

if (keybhop)
Bhop = down;
Sakura::HNS::BunnyHop::Active = down;

if (keyjump)
Jumpbug = down;
Sakura::HNS::Jumpbug::Active = down;

if (keyrage)
Sakura::Aimbot::Rage::RageKeyStatus = down;
Expand All @@ -163,34 +163,43 @@ void CL_CreateMove(float frametime, usercmd_s* cmd, int active)
g_Client.CL_CreateMove(frametime, cmd, active);

AdjustSpeed(cvar.misc_wav_speed);
UpdateWeaponData();
Sakura::Player::Local::Update(frametime, cmd);
Sakura::Aimbot::Logic(cmd);
ContinueFire(cmd);
ItemPostFrame(cmd);
Kz(frametime, cmd);
NoRecoil(cmd);
NoSpread(cmd);
Route(cmd);
AntiAim::Local(cmd);
FakeLag(frametime, cmd);
Sakura::AntiAfk::Run(cmd);

BulletTrace::Local(cmd);

Sakura::Name::Stealer();
Sakura::ChatSpammer::Logic();

g_Sequences.Update();

if (Sakura::Player::Local::InGame() && Sakura::Player::Local::IsAlive())
if (Sakura::Player::Local::IsAlive())
{
Backtrack::FakeLatency();
UpdateWeaponData();
Sakura::Aimbot::Logic(cmd);
ContinueFire(cmd);
ItemPostFrame(cmd);
NoRecoil(cmd);
NoSpread(cmd);
Route(cmd);
AntiAim::Local(cmd);
FakeLag(frametime, cmd);
Sakura::Name::Stealer();

Sakura::HNS::BunnyHop::Logic(cmd);
Sakura::HNS::Jumpbug::Logic(frametime, cmd);
Sakura::HNS::Groundstrafe::Logic(cmd);
Sakura::HNS::Fastrun::Logic(cmd);
Sakura::HNS::Strafe::Logic(cmd);

if (Sakura::Player::Local::InGame())
{
Sakura::Fakelatency::Logic();

if (cvar.visual_weapon_noanim)
g_Engine.pfnWeaponAnim(0, 0);
if (cvar.visual_weapon_noanim)
g_Engine.pfnWeaponAnim(0, 0);
}
}

Kz(frametime, cmd);
Sakura::AntiAfk::Run(cmd);
BulletTrace::Local(cmd);
Sakura::ChatSpammer::Logic();

for (size_t i = 0; i < Sakura::Lua::scripts.size(); ++i)
{
auto& script = Sakura::Lua::scripts[i];
Expand Down Expand Up @@ -415,7 +424,7 @@ int HUD_AddEntity(int type, cl_entity_s* ent, const char* modelname)
if (cvar.misc_fakelatency)
{
Vector entTempOrigin;
if (Backtrack::BacktrackPlayer(ent, g_Local.sLerpMSec, entTempOrigin))
if (Sakura::Backtrack::Player(ent, g_Local.sLerpMSec, entTempOrigin))
{
memcpy(&g_Player[ent->index].playerHistory, ent, sizeof(*ent));
g_Player[ent->index].playerHistory.origin = entTempOrigin;
Expand Down
2 changes: 1 addition & 1 deletion sakura/source/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace Sakura
#include "features/sound/soundesp.h"
#include "helpers/weapons.h"
#include "player.h"
#include "config/cvar.h"
#include "config/cvar.hpp"
#include "helpers/color.h"
#include "features/hns/strafe.h"
#include "features/hns/fastrun.h"
Expand Down
4 changes: 2 additions & 2 deletions sakura/source/features/aimbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void Sakura::Aimbot::Logic(usercmd_s* cmd)
Sakura::Knifebot::iTargetKnife = 0;
Sakura::Aimbot::Rage::iTargetRage = 0;

if (Sakura::Player::Local::IsAlive() && GetTickCount() - HudRedraw <= 100)
if (GetTickCount() - HudRedraw <= 100)
{
if (cvar.rage_active)
{
Expand Down Expand Up @@ -303,7 +303,7 @@ void Sakura::Aimbot::Draws()

void ContinueFire(usercmd_s* cmd) // auto pistol
{
if (cvar.rage_active && cmd->buttons & IN_ATTACK && IsCurWeaponPistol() && !g_Local.weapon.m_iInReload && Sakura::Player::Local::IsAlive())
if (cvar.rage_active && cmd->buttons & IN_ATTACK && IsCurWeaponPistol() && !g_Local.weapon.m_iInReload)
{
static bool bFire = false;

Expand Down
3 changes: 0 additions & 3 deletions sakura/source/features/rage/antiaim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ void AntiAim::Local(usercmd_s* cmd)
if (!cvar.rage_antiaim_active)
return;

if (!Sakura::Player::Local::IsAlive())
return;

int localUse = (cmd->buttons & IN_USE);
int localIsAttacking = (cmd->buttons & IN_ATTACK);
int localIsKnifeAttacking = (cmd->buttons & IN_ATTACK2) && IsCurWeaponKnife();
Expand Down
2 changes: 1 addition & 1 deletion sakura/source/features/rage/autoroute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ void RouteDirection(usercmd_s* cmd)
{
static int iTurnMove = false;
static int iJumpMove = false;
if (cvar.misc_wav_speed > 1 && Sakura::Player::Local::IsAlive() && !IsFreezePeriod())
if (cvar.misc_wav_speed > 1 && !IsFreezePeriod())
{
if (InMove(cmd) && MySpeed() < 30)
{
Expand Down
4 changes: 2 additions & 2 deletions sakura/source/features/rage/fakelag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

void FakeLag(float frametime, struct usercmd_s* cmd)
{
if (cvar.fakelag_active && Sakura::Player::Local::IsAlive())
if (cvar.fakelag_active)
{
int m_InAttack = (cmd->buttons & IN_ATTACK);

Expand All @@ -26,7 +26,7 @@ void FakeLag(float frametime, struct usercmd_s* cmd)
}
else if (cvar.fakelag_move == 2)//In air
{
if (HeightOrigin() <= 0)
if (g_Local.flHeightorigin <= 0)
fakelag = false;
}

Expand Down
2 changes: 1 addition & 1 deletion sakura/source/features/rage/norecoil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ void V_CalcRefdefRecoil(struct ref_params_s *pparams)

void NoRecoil(struct usercmd_s *cmd)
{
if (cvar.rage_active && cvar.rage_no_recoil && IsCurWeaponGun() && Sakura::Player::Local::IsAlive() && cmd->buttons & IN_ATTACK && CanAttack())
if (cvar.rage_active && cvar.rage_no_recoil && IsCurWeaponGun() && cmd->buttons & IN_ATTACK && CanAttack())
cmd->viewangles -= g_Local.vNoRecoilAngle;
}
2 changes: 1 addition & 1 deletion sakura/source/features/rage/nospread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void MakeAngle(float *angles, struct usercmd_s *cmd)

void NoSpread(usercmd_s *cmd)
{
if (Sakura::Player::Local::IsAlive() && IsCurWeaponGun() && cmd->buttons & IN_ATTACK && CanAttack())
if (IsCurWeaponGun() && cmd->buttons & IN_ATTACK && CanAttack())
{
Vector vAngles;
GetSpreadOffset(g_Local.weapon.random_seed, 1, cmd->viewangles, vAngles);
Expand Down
2 changes: 1 addition & 1 deletion sakura/source/features/visuals/light/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void Sakura::DynamicLight::Impulse()
const float speed = cvar.visual_player_dynamiclight_fading_speed;

impulseRadius += plus_or_minus ? speed * g_Local.m_flFrameTime : -speed * g_Local.m_flFrameTime;
impulseRadius = Backtrack::clamp(impulseRadius, 0.f, 1.f);
impulseRadius = Sakura::Math::Clamp(impulseRadius, 0.f, 1.f);
}

void Sakura::DynamicLight::Light(const cl_entity_s* ent, const ImRGBA color)
Expand Down
Loading

0 comments on commit 472d624

Please sign in to comment.