| 
									
										
										
										
											2023-07-22 16:27:40 +02:00
										 |  |  | #ifndef UTIL_H_
 | 
					
						
							|  |  |  | #define UTIL_H_
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-23 01:18:24 +02:00
										 |  |  | #include <stdint.h>
 | 
					
						
							| 
									
										
										
										
											2023-07-23 15:49:34 +02:00
										 |  |  | #include <math.h>
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | #include "sdk.h"
 | 
					
						
							|  |  |  | #include "globals.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Vector 2 for 2d points */ | 
					
						
							|  |  |  | typedef float vec2_t[2]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-23 01:18:24 +02:00
										 |  |  | /* RGB color */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |     uint8_t r, g, b; | 
					
						
							|  |  |  | } rgb_t; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-29 16:23:26 +02:00
										 |  |  | #define DEG2RAD(n) ((n)*M_PI / 180.0f)
 | 
					
						
							|  |  |  | #define RAD2DEG(n) ((n)*180.0f / M_PI)
 | 
					
						
							| 
									
										
										
										
											2023-07-24 10:14:50 +02:00
										 |  |  | #define CLAMP(val, min, max) \
 | 
					
						
							|  |  |  |     (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) | 
					
						
							| 
									
										
										
										
											2023-07-23 15:49:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-23 14:35:52 +02:00
										 |  |  | #define gl_drawline_points(p0, p1, w, col) \
 | 
					
						
							|  |  |  |     gl_drawline(p0[0], p0[1], p1[0], p1[1], w, col); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-29 17:34:18 +02:00
										 |  |  | #define vec_copy(dst, src) \
 | 
					
						
							|  |  |  |     dst.x = src.x;         \ | 
					
						
							|  |  |  |     dst.y = src.y;         \ | 
					
						
							|  |  |  |     dst.z = src.z; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | /*----------------------------------------------------------------------------*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-24 17:06:06 +02:00
										 |  |  | cl_entity_t* get_player(int ent_idx); | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | bool is_alive(cl_entity_t* ent); | 
					
						
							| 
									
										
										
										
											2023-07-24 17:06:06 +02:00
										 |  |  | bool valid_player(cl_entity_t* ent); | 
					
						
							| 
									
										
										
										
											2023-07-27 21:27:01 +02:00
										 |  |  | bool is_friend(cl_entity_t* ent); | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | char* get_name(int ent_idx); | 
					
						
							| 
									
										
										
										
											2023-07-28 15:43:51 +02:00
										 |  |  | game_id get_cur_game(void); | 
					
						
							| 
									
										
										
										
											2023-07-23 00:27:16 +02:00
										 |  |  | vec3_t vec3(float x, float y, float z); | 
					
						
							| 
									
										
										
										
											2023-07-28 21:56:35 +02:00
										 |  |  | vec3_t vec_add(vec3_t a, vec3_t b); | 
					
						
							| 
									
										
										
										
											2023-07-29 16:23:26 +02:00
										 |  |  | vec3_t vec_sub(vec3_t a, vec3_t b); | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | bool vec_is_zero(vec3_t v); | 
					
						
							| 
									
										
										
										
											2023-07-23 16:21:53 +02:00
										 |  |  | float vec_len2d(vec3_t v); | 
					
						
							| 
									
										
										
										
											2023-07-24 10:14:50 +02:00
										 |  |  | void vec_clamp(vec3_t v); | 
					
						
							| 
									
										
										
										
											2023-07-29 16:23:26 +02:00
										 |  |  | void vec_norm(vec3_t v); | 
					
						
							| 
									
										
										
										
											2023-07-23 16:21:53 +02:00
										 |  |  | float angle_delta_rad(float a, float b); | 
					
						
							| 
									
										
										
										
											2023-07-29 16:23:26 +02:00
										 |  |  | vec3_t vec_to_ang(vec3_t v); | 
					
						
							| 
									
										
										
										
											2023-07-28 23:10:54 +02:00
										 |  |  | vec3_t matrix_3x4_origin(matrix_3x4 m); | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | bool world_to_screen(vec3_t vec, vec2_t screen); | 
					
						
							| 
									
										
										
										
											2023-07-25 22:50:29 +02:00
										 |  |  | void engine_draw_text(int x, int y, char* s, rgb_t c); | 
					
						
							| 
									
										
										
										
											2023-07-23 01:47:52 +02:00
										 |  |  | void gl_drawbox(int x, int y, int w, int h, rgb_t c); | 
					
						
							| 
									
										
										
										
											2023-07-23 01:18:24 +02:00
										 |  |  | void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col); | 
					
						
							| 
									
										
										
										
											2023-07-25 18:49:34 +02:00
										 |  |  | bool protect_addr(void* ptr, int new_flags); | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:27:40 +02:00
										 |  |  | #endif /* UTIL_H_ */
 |