diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-26 20:13:07 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-26 20:13:07 +0100 |
| commit | 300e7bc03b80dd4bac61330817bf6d9f04d4231b (patch) | |
| tree | 7c35877edc58dae47045c33f8e1ff39182ab67cf /src | |
| parent | Fonts: bundle Liberation Sans and register it with fontconfig (diff) | |
| download | hl2h-300e7bc03b80dd4bac61330817bf6d9f04d4231b.tar.gz hl2h-300e7bc03b80dd4bac61330817bf6d9f04d4231b.zip | |
Use one float-precision PI constant
- move PI_F into hl2h.h as constexpr 3.14159265f and remove the duplicated
long-double-style literals from hl2h.cpp/esp.cpp
- extra digits are compile-time only; float operations cost the same
Diffstat (limited to '')
| -rw-r--r-- | src/esp.cpp | 2 | ||||
| -rw-r--r-- | src/hl2h.cpp | 2 | ||||
| -rw-r--r-- | src/hl2h.h | 5 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index cd0ff36..7583f26 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -6,8 +6,6 @@ | |||
| 6 | #include <cstdlib> | 6 | #include <cstdlib> |
| 7 | #include <ctime> | 7 | #include <ctime> |
| 8 | 8 | ||
| 9 | static constexpr float PI_F = 3.14159265358979323846f; | ||
| 10 | |||
| 11 | // ISurface slots (binary = SDK header + 4, disassembly-confirmed) | 9 | // ISurface slots (binary = SDK header + 4, disassembly-confirmed) |
| 12 | enum SurfSlot { | 10 | enum SurfSlot { |
| 13 | SURF_DrawSetColor = 10, SURF_FilledRect = 12, SURF_OutlinedRect = 14, | 11 | SURF_DrawSetColor = 10, SURF_FilledRect = 12, SURF_OutlinedRect = 14, |
diff --git a/src/hl2h.cpp b/src/hl2h.cpp index f3aa26f..a49acc2 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp | |||
| @@ -39,8 +39,6 @@ Vector g_cam_view{0, 0, 0}; | |||
| 39 | // vector math | 39 | // vector math |
| 40 | // --------------------------------------------------------------------------- | 40 | // --------------------------------------------------------------------------- |
| 41 | 41 | ||
| 42 | static constexpr float PI_F = 3.14159265358979323846f; | ||
| 43 | |||
| 44 | QAngle vector_angles(const Vector &forward) { | 42 | QAngle vector_angles(const Vector &forward) { |
| 45 | QAngle a{}; | 43 | QAngle a{}; |
| 46 | a.z = 0; | 44 | a.z = 0; |
| @@ -11,6 +11,11 @@ | |||
| 11 | #include <pthread.h> | 11 | #include <pthread.h> |
| 12 | #include <unistd.h> | 12 | #include <unistd.h> |
| 13 | 13 | ||
| 14 | // Shared float-precision constant. More digits than a float can hold are | ||
| 15 | // rounded at compile time and have no runtime cost; a coarse value would only | ||
| 16 | // hurt angular accuracy, never performance. | ||
| 17 | constexpr float PI_F = 3.14159265f; | ||
| 18 | |||
| 14 | // --------------------------------------------------------------------------- | 19 | // --------------------------------------------------------------------------- |
| 15 | // logging | 20 | // logging |
| 16 | // --------------------------------------------------------------------------- | 21 | // --------------------------------------------------------------------------- |
