Add custom_crosshair function

This commit is contained in:
8dcc 2023-07-27 14:19:07 +02:00
parent e1a56c7fb6
commit 07473c30b4
2 changed files with 34 additions and 0 deletions

View File

@ -24,4 +24,7 @@ void correct_movement(usercmd_t* cmd, vec3_t old_angles);
extern visible_flags visible_mode; extern visible_flags visible_mode;
bool chams(void* this_ptr); bool chams(void* this_ptr);
/* src/features/misc.c */
void custom_crosshair(void);
#endif /* FEATURES_H_ */ #endif /* FEATURES_H_ */

31
src/features/misc.c Normal file
View File

@ -0,0 +1,31 @@
#include "features.h"
#include "../include/sdk.h"
#include "../include/globals.h"
#include "../include/cvars.h"
#include "../include/util.h"
void custom_crosshair(void) {
if (!CVAR_ON(crosshair))
return;
/* Get window size, and then the center. */
int mx = game_info->m_width / 2;
int my = game_info->m_height / 2;
/* The real length is sqrt(2 * (len^2)) */
const int len = cv_crosshair->value;
const int gap = 1;
const float w = 1;
const rgb_t col = { 255, 255, 255 };
/*
* 1\ /2
* X
* 3/ \4
*/
gl_drawline(mx - gap, my - gap, mx - gap - len, my - gap - len, w, col);
gl_drawline(mx + gap, my - gap, mx + gap + len, my - gap - len, w, col);
gl_drawline(mx - gap, my + gap, mx - gap - len, my + gap + len, w, col);
gl_drawline(mx + gap, my + gap, mx + gap + len, my + gap + len, w, col);
}