Skip to content

Commit

Permalink
refactor: style
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisAMJ committed Aug 29, 2024
1 parent 516115d commit 162947d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions docs/cvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@
|sar_velocitygraph_font_index|21|Font index of velocity graph.|
|sar_velocitygraph_rainbow|0|Rainbow mode of velocity graph text.|
|sar_velocitygraph_show_speed_on_graph|1|Show speed between jumps.|
|sar_velocitygraph_x|-250|Velocity graph x axis offset.|
|sar_velocitygraph_y|-175|Velocity graph y axis offset.|
|sar_vphys_hud|0|Enables or disables the vphys HUD.|
|sar_vphys_hud_font|1|Sets font of the vphys HUD.|
|sar_vphys_hud_precision|3|Sets decimal precision of the vphys HUD.|
Expand Down
18 changes: 9 additions & 9 deletions src/Features/Hud/VelocityGraph.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "VelocityGraph.hpp"

#include "Event.hpp"
#include "Features/Session.hpp"
#include "Modules/Client.hpp"
#include "Modules/Engine.hpp"
#include "Modules/Scheme.hpp"
#include "Modules/Surface.hpp"
#include "Features/Session.hpp"
#include "Utils/SDK/FixedQueue.hpp"
#include "Variable.hpp"

#include "Utils/SDK/FixedQueue.hpp"
#include <vector>
#include <cmath>
#include <vector>

Variable sar_velocitygraph("sar_velocitygraph", "0", "Shows velocity graph.\n");
Variable sar_velocitygraph_font_index("sar_velocitygraph_font_index", "21", 0, "Font index of velocity graph.\n"); // 21 looks pretty good
Expand All @@ -33,7 +33,7 @@ struct VelocityData {
}
};

std::vector<FixedQueue<VelocityData>> velocityStamps(2, FixedQueue(500, VelocityData()));
std::vector<FixedQueue<VelocityData>> velocityStamps(2, FixedQueue(500, VelocityData()));

static int last_vel[2] = {0, 0};
static int tick_prev[2] = {0, 0};
Expand All @@ -57,7 +57,7 @@ void ClearData(int slot) {
}

void VelocityGraph::GatherData(int slot, bool on_ground) {
auto player = client->GetPlayer(slot + 1); //not sure how to get it properly with event
auto player = client->GetPlayer(slot + 1);
if (!player) return;

auto vel = client->GetLocalVelocity(player);
Expand All @@ -75,10 +75,10 @@ void VelocityGraph::GatherData(int slot, bool on_ground) {
void VelocityGraph::Paint(int slot) {
int speed = velocityStamps[slot].Last().speed;

int screenSizeX, y;
engine->GetScreenSize(nullptr, screenSizeX, y);
int x, y;
engine->GetScreenSize(nullptr, x, y);

const Vector2<int> graphPos = Vector2<int>(screenSizeX / 2, y) +
const Vector2<int> graphPos = Vector2<int>(x / 2, y) +
Vector2<int>(sar_velocitygraph_x.GetInt(), sar_velocitygraph_y.GetInt());

if (sar_velocitygraph_background.GetBool())
Expand Down Expand Up @@ -142,4 +142,4 @@ ON_EVENT(PROCESS_MOVEMENT) {
velocityGraph->GatherData(event.slot, event.grounded);
}

VelocityGraph *velocityGraph = new VelocityGraph();
VelocityGraph *velocityGraph = new VelocityGraph();
2 changes: 1 addition & 1 deletion src/Features/Hud/VelocityGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ extern Variable sar_velocitygraph_x;
extern Variable sar_velocitygraph_y;
extern Variable sar_velocitygraph_background;
extern Variable sar_velocitygraph_show_speed_on_graph;
extern Variable sar_velocitygraph_rainbow;
extern Variable sar_velocitygraph_rainbow;
10 changes: 5 additions & 5 deletions src/Utils/SDK.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

#include "SDK/BaseEntity.hpp"
#include "SDK/BitBuf.hpp"
#include "SDK/CViewSetup.hpp"
#include "SDK/Class.hpp"
#include "SDK/Color.hpp"
#include "SDK/Convar.hpp"
#include "SDK/CViewSetup.hpp"
#include "SDK/Datamap.hpp"
#include "SDK/EntityEdict.hpp"
#include "SDK/EventQueue.hpp"
#include "SDK/FixedQueue.hpp"
#include "SDK/GameEvents.hpp"
#include "SDK/GameMovement.hpp"
#include "SDK/GlobalVars.hpp"
#include "SDK/Handle.hpp"
#include "SDK/EventQueue.hpp"
#include "SDK/HostState.hpp"
#include "SDK/ICollideable.hpp"
#include "SDK/ILoggingListener.hpp"
Expand All @@ -20,13 +22,11 @@
#include "SDK/KeyValues.hpp"
#include "SDK/Math.hpp"
#include "SDK/MeshBuilder.hpp"
#include "SDK/GameMovement.hpp"
#include "SDK/PlayerLocalData.hpp"
#include "SDK/PortalPlacement.hpp"
#include "SDK/ServerPlugin.hpp"
#include "SDK/Trace.hpp"
#include "SDK/UserCmd.hpp"
#include "SDK/UtlMemory.hpp"
#include "SDK/Trace.hpp"
#include "SDK/FixedQueue.hpp"

#include "SDK/Other.hpp"
2 changes: 1 addition & 1 deletion src/Utils/SDK/FixedQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ class FixedQueue {
inline T &operator[](int index) {
return queue[BoundIndex(index + begin, 1)];
}
};
};

0 comments on commit 162947d

Please sign in to comment.