Merge branch 'master' of https://github.com/nullworks/cathook
This commit is contained in:
commit
4426e2b8a8
@ -16,6 +16,7 @@ extern std::array<Timer, 32> timers;
|
|||||||
extern Timer DelayTimer;
|
extern Timer DelayTimer;
|
||||||
extern bool firstcm;
|
extern bool firstcm;
|
||||||
|
|
||||||
|
extern bool calculated_can_shoot;
|
||||||
extern float prevflow;
|
extern float prevflow;
|
||||||
extern int prevflowticks;
|
extern int prevflowticks;
|
||||||
#if ENABLE_VISUALS
|
#if ENABLE_VISUALS
|
||||||
@ -31,6 +32,3 @@ extern settings::Bool disable_visuals;
|
|||||||
extern settings::Int print_r;
|
extern settings::Int print_r;
|
||||||
extern settings::Int print_g;
|
extern settings::Int print_g;
|
||||||
extern settings::Int print_b;
|
extern settings::Int print_b;
|
||||||
|
|
||||||
void SetCanshootStatus();
|
|
||||||
extern bool CanShootException;
|
|
||||||
|
22
src/MiscTemporary.cpp
Normal file → Executable file
22
src/MiscTemporary.cpp
Normal file → Executable file
@ -11,28 +11,12 @@ int spectator_target;
|
|||||||
CLC_VoiceData *voicecrash{};
|
CLC_VoiceData *voicecrash{};
|
||||||
bool firstcm = false;
|
bool firstcm = false;
|
||||||
Timer DelayTimer{};
|
Timer DelayTimer{};
|
||||||
float prevflow = 0.0f;
|
float prevflow = 0.0f;
|
||||||
int prevflowticks = 0;
|
int prevflowticks = 0;
|
||||||
|
bool calculated_can_shoot = false;
|
||||||
|
|
||||||
bool *bSendPackets{ nullptr };
|
bool *bSendPackets{ nullptr };
|
||||||
|
|
||||||
bool CanShootException = false;
|
|
||||||
void SetCanshootStatus()
|
|
||||||
{
|
|
||||||
static int lastammo = -1;
|
|
||||||
static int prevweaponclass = -1;
|
|
||||||
if (LOCAL_W->m_iClassID() != prevweaponclass)
|
|
||||||
lastammo = -1;
|
|
||||||
if (GetWeaponMode() != weapon_melee && lastammo == 0 && CE_INT(LOCAL_W, netvar.m_iClip1))
|
|
||||||
{
|
|
||||||
CanShootException = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
CanShootException = false;
|
|
||||||
lastammo = CE_INT(LOCAL_W, netvar.m_iClip1);
|
|
||||||
prevweaponclass = LOCAL_W->m_iClassID();
|
|
||||||
}
|
|
||||||
|
|
||||||
settings::Bool crypt_chat{ "chat.crypto", "true" };
|
settings::Bool crypt_chat{ "chat.crypto", "true" };
|
||||||
settings::Bool clean_screenshots{ "visual.clean-screenshots", "false" };
|
settings::Bool clean_screenshots{ "visual.clean-screenshots", "false" };
|
||||||
settings::Bool nolerp{ "misc.no-lerp", "false" };
|
settings::Bool nolerp{ "misc.no-lerp", "false" };
|
||||||
|
@ -108,7 +108,7 @@ void critical_error_handler(int signum)
|
|||||||
std::ofstream out(strfmt("/tmp/cathook-%s-%d-segfault.log", pwd->pw_name, getpid()).get());
|
std::ofstream out(strfmt("/tmp/cathook-%s-%d-segfault.log", pwd->pw_name, getpid()).get());
|
||||||
|
|
||||||
Dl_info info;
|
Dl_info info;
|
||||||
if (!dladdr(reinterpret_cast<void *>(SetCanshootStatus), &info))
|
if (!dladdr(reinterpret_cast<void *>(hack::ExecuteCommand), &info))
|
||||||
return;
|
return;
|
||||||
unsigned int baseaddr = (unsigned int) info.dli_fbase - 1;
|
unsigned int baseaddr = (unsigned int) info.dli_fbase - 1;
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "MiscTemporary.hpp"
|
|
||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <settings/Bool.hpp>
|
#include "settings/Bool.hpp"
|
||||||
|
#include "MiscTemporary.hpp"
|
||||||
|
|
||||||
static settings::Bool tcm{ "debug.tcm", "true" };
|
static settings::Bool tcm{ "debug.tcm", "true" };
|
||||||
|
|
||||||
@ -1321,19 +1321,8 @@ bool CanHeadshot()
|
|||||||
|
|
||||||
bool CanShoot()
|
bool CanShoot()
|
||||||
{
|
{
|
||||||
static float servertime, lastfire, nextattack;
|
// PrecalculateCanShoot() CreateMove.cpp
|
||||||
|
return calculated_can_shoot;
|
||||||
float currfire = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flLastFireTime);
|
|
||||||
|
|
||||||
if (lastfire != currfire || GetWeaponMode() == weapon_melee)
|
|
||||||
{
|
|
||||||
lastfire = currfire;
|
|
||||||
nextattack = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack);
|
|
||||||
}
|
|
||||||
servertime = (float) (CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * g_GlobalVars->interval_per_tick;
|
|
||||||
if (CanShootException)
|
|
||||||
return true;
|
|
||||||
return nextattack <= servertime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QAngle VectorToQAngle(Vector in)
|
QAngle VectorToQAngle(Vector in)
|
||||||
|
@ -89,6 +89,37 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
|
|||||||
}
|
}
|
||||||
} // namespace engine_prediction
|
} // namespace engine_prediction
|
||||||
|
|
||||||
|
void PrecalculateCanShoot()
|
||||||
|
{
|
||||||
|
auto weapon = g_pLocalPlayer->weapon();
|
||||||
|
// Check if player and weapon are good
|
||||||
|
if (CE_BAD(g_pLocalPlayer->entity) || CE_BAD(weapon))
|
||||||
|
{
|
||||||
|
calculated_can_shoot = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// flNextPrimaryAttack without reload
|
||||||
|
static float next_attack = 0.0f;
|
||||||
|
// Last shot fired using weapon
|
||||||
|
static float last_attack = 0.0f;
|
||||||
|
// Last weapon used
|
||||||
|
static CachedEntity *last_weapon = nullptr;
|
||||||
|
float server_time = (float) (CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * g_GlobalVars->interval_per_tick;
|
||||||
|
float new_next_attack = CE_FLOAT(weapon, netvar.flNextPrimaryAttack);
|
||||||
|
float new_last_attack = CE_FLOAT(weapon, netvar.flLastFireTime);
|
||||||
|
|
||||||
|
// Reset everything if using a new weapon/shot fired
|
||||||
|
if (new_last_attack != last_attack || last_weapon != weapon)
|
||||||
|
{
|
||||||
|
next_attack = new_next_attack;
|
||||||
|
last_attack = new_last_attack;
|
||||||
|
last_weapon = weapon;
|
||||||
|
}
|
||||||
|
// Check if can shoot
|
||||||
|
calculated_can_shoot = next_attack <= server_time;
|
||||||
|
}
|
||||||
|
|
||||||
static int attackticks = 0;
|
static int attackticks = 0;
|
||||||
|
|
||||||
namespace hooked_methods
|
namespace hooked_methods
|
||||||
@ -252,8 +283,7 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs
|
|||||||
PROF_SECTION(CM_LocalPlayer);
|
PROF_SECTION(CM_LocalPlayer);
|
||||||
g_pLocalPlayer->Update();
|
g_pLocalPlayer->Update();
|
||||||
}
|
}
|
||||||
if (CE_GOOD(LOCAL_E) && !g_pLocalPlayer->life_state && CE_GOOD(LOCAL_W))
|
PrecalculateCanShoot();
|
||||||
SetCanshootStatus();
|
|
||||||
if (firstcm)
|
if (firstcm)
|
||||||
{
|
{
|
||||||
DelayTimer.update();
|
DelayTimer.update();
|
||||||
|
@ -74,7 +74,13 @@ void zerokernel::Text::recalculateSize()
|
|||||||
BaseMenuObject::recalculateSize();
|
BaseMenuObject::recalculateSize();
|
||||||
|
|
||||||
float w, h;
|
float w, h;
|
||||||
font->stringSize(data, &w, &h);
|
if (data.empty() || !font)
|
||||||
|
{
|
||||||
|
w = 0.0f;
|
||||||
|
h = 0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
font->stringSize(data, &w, &h);
|
||||||
text_size_x = int(w);
|
text_size_x = int(w);
|
||||||
text_size_y = int(h);
|
text_size_y = int(h);
|
||||||
|
|
||||||
|
2
update
2
update
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
if [ $EUID == 0 ]; then
|
if [ $EUID == 0 ]; then
|
||||||
echo "\033[1;31m\nThis script must not be run as root\n\033[0m"
|
echo -e "\033[1;31m\nThis script must not be run as root\n\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#Get updated source code
|
#Get updated source code
|
||||||
|
Reference in New Issue
Block a user