Skip to content

Commit

Permalink
Fix bomb explosion / round end crashing. Disable drawing of inaccurac…
Browse files Browse the repository at this point in the history
…y circle and recoil crosshair for observer targets
  • Loading branch information
degeneratehyperbola committed Sep 25, 2021
1 parent 41f4075 commit a941f96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions NEPS/GameData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,12 @@ void LocalPlayerData::update() noexcept
origin = obs->getAbsOrigin();
velocity = obs->velocity();
eyePosition = obs->getEyePosition();
aimPunch = eyePosition + Vector::fromAngle(interfaces->engine->getViewAngles() + obs->getAimPunch()) * 1000;
// Calling Entity::getAimPunch() not on the local player sometimes causes crashing
//aimPunch = eyePosition + Vector::fromAngle(interfaces->engine->getViewAngles() + obs->getAimPunch()) * 1000;

if (const auto activeWeapon = obs->getActiveWeapon(); activeWeapon && obs->isAlive())
{
inaccuracy = eyePosition + Vector::fromAngle(interfaces->engine->getViewAngles() + Vector{Helpers::radiansToDegrees(activeWeapon->getInaccuracy() + activeWeapon->getSpread()), 0.0f, 0.0f}) * 1000;
//inaccuracy = eyePosition + Vector::fromAngle(interfaces->engine->getViewAngles() + Vector{Helpers::radiansToDegrees(activeWeapon->getInaccuracy() + activeWeapon->getSpread()), 0.0f, 0.0f}) * 1000;
shooting = obs->shotsFired() > 1;
reloading = activeWeapon->isInReload();
nextAttack = std::fmaxf(activeWeapon->nextPrimaryAttack(), obs->nextAttack());
Expand Down
6 changes: 3 additions & 3 deletions NEPS/Hacks/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void Misc::recoilCrosshair(ImDrawList *drawList) noexcept
GameData::Lock lock;
const auto &local = GameData::local();

if (!local.exists)
if (!local.exists || !local.alive)
return;

if (ImVec2 recoil; Helpers::worldToScreen(local.aimPunch, recoil, false))
Expand All @@ -238,7 +238,7 @@ void Misc::visualizeInaccuracy(ImDrawList *drawList) noexcept
GameData::Lock lock;
const auto &local = GameData::local();

if (!local.exists || !local.inaccuracy.notNull())
if (!local.exists || !local.alive || !local.inaccuracy.notNull())
return;

if (ImVec2 edge; Helpers::worldToScreen(local.inaccuracy, edge))
Expand All @@ -251,7 +251,7 @@ void Misc::visualizeInaccuracy(ImDrawList *drawList) noexcept

const auto inaccuracy = std::sqrtf(ImLengthSqr((edge - displaySize / 2) / displaySize)) * 200;
const auto color = Helpers::calculateColor(config->visuals.inaccuracyCircle);
char text[9];
char text[0xF];
std::sprintf(text, "%.6f%%", inaccuracy);
drawList->AddText(edge, color, text);
drawList->AddCircleFilled(displaySize / 2, radius, color);
Expand Down

0 comments on commit a941f96

Please sign in to comment.