| 
									
										
										
										
											2023-07-24 17:03:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "features.h"
 | 
					
						
							|  |  |  | #include "../include/globals.h"
 | 
					
						
							|  |  |  | #include "../include/cvars.h"
 | 
					
						
							|  |  |  | #include "../include/util.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <GL/gl.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-26 16:34:14 +02:00
										 |  |  | enum chams_settings { | 
					
						
							|  |  |  |     DISABLED     = 0, | 
					
						
							| 
									
										
										
										
											2023-07-27 21:39:01 +02:00
										 |  |  |     PLAYER_CHAMS = 1, | 
					
						
							|  |  |  |     HAND_CHAMS   = 2, | 
					
						
							|  |  |  |     /* ALL is 3, but we can OR player and hands */ | 
					
						
							| 
									
										
										
										
											2023-07-26 16:34:14 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2023-07-25 14:46:25 +02:00
										 |  |  | visible_flags visible_mode; | 
					
						
							| 
									
										
										
										
											2023-07-24 17:03:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool chams(void* this_ptr) { | 
					
						
							| 
									
										
										
										
											2023-09-19 10:45:57 -04:00
										 |  |  |     const int setting = dz_chams->value == 5.0f ? 7 : dz_chams->value; | 
					
						
							| 
									
										
										
										
											2023-07-26 16:34:14 +02:00
										 |  |  |     if (setting == DISABLED) | 
					
						
							| 
									
										
										
										
											2023-07-24 17:03:22 +02:00
										 |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cl_entity_t* ent = i_enginestudio->GetCurrentEntity(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-26 16:34:14 +02:00
										 |  |  |     if (ent->index == localplayer->index && setting & HAND_CHAMS) { | 
					
						
							|  |  |  |         /* If we are rendering hands and setting is on, render them */ | 
					
						
							|  |  |  |         glDisable(GL_TEXTURE_2D); | 
					
						
							|  |  |  |         visible_mode = HANDS; /* Set for this call */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         i_studiomodelrenderer->StudioRenderFinal(this_ptr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         visible_mode = NONE; /* Reset for future calls */ | 
					
						
							|  |  |  |         glEnable(GL_TEXTURE_2D); | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2023-07-27 21:39:01 +02:00
										 |  |  |     } else if (!(setting & PLAYER_CHAMS) || !valid_player(ent) || | 
					
						
							|  |  |  |                !is_alive(ent)) { | 
					
						
							| 
									
										
										
										
											2023-07-26 16:34:14 +02:00
										 |  |  |         /* If we don't want player chams, or this is not a player, stop */ | 
					
						
							| 
									
										
										
										
											2023-07-24 17:03:22 +02:00
										 |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-27 21:28:40 +02:00
										 |  |  |     const bool friendly = is_friend(ent); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-24 17:03:22 +02:00
										 |  |  |     /* If we got here it means we are rendering a valid player */ | 
					
						
							|  |  |  |     glDisable(GL_TEXTURE_2D); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     glDisable(GL_DEPTH_TEST); /* Ignore depth (walls between target) */ | 
					
						
							| 
									
										
										
										
											2023-07-27 21:28:40 +02:00
										 |  |  |     visible_mode = friendly ? FRIEND_NOT_VISIBLE : ENEMY_NOT_VISIBLE; | 
					
						
							| 
									
										
										
										
											2023-07-24 17:03:22 +02:00
										 |  |  |     i_studiomodelrenderer->StudioRenderFinal(this_ptr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     glEnable(GL_DEPTH_TEST); /* Don't ignore depth, different color chams */ | 
					
						
							| 
									
										
										
										
											2023-07-27 21:28:40 +02:00
										 |  |  |     visible_mode = friendly ? FRIEND_VISIBLE : ENEMY_VISIBLE; | 
					
						
							| 
									
										
										
										
											2023-07-24 17:03:22 +02:00
										 |  |  |     i_studiomodelrenderer->StudioRenderFinal(this_ptr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Reset for future calls to glColor4f (from here or somewhere else) */ | 
					
						
							|  |  |  |     visible_mode = NONE; | 
					
						
							|  |  |  |     glEnable(GL_TEXTURE_2D); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* StudioRenderModel hook doesn't need to call original */ | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } |