Advertisement
Guest User

config.cpp

a guest
Jun 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.50 KB | None | 0 0
  1. #include "config.hpp"
  2. #include "options.hpp"
  3. #include "helpers/math.hpp"
  4. #include "helpers/utils.hpp"
  5. #include "menu.hpp"
  6. #include "helpers/input.hpp"
  7.  
  8. // For ints, chars, floats, and bools
  9. void CConfig::SetupValue( int& value, int def, std::string category, std::string name ) { value = def; ints.push_back( new ConfigValue< int >( category, name, &value, def ) ); }
  10. void CConfig::SetupValue( char* value, char* def, std::string category, std::string name ) { value = def; chars.push_back( new ConfigValue< char >( category, name, value, *def ) ); }
  11. void CConfig::SetupValue( float& value, float def, std::string category, std::string name ) { value = def; floats.push_back( new ConfigValue< float >( category, name, &value, def ) ); }
  12. void CConfig::SetupValue( bool& value, bool def, std::string category, std::string name ) { value = def; bools.push_back( new ConfigValue< bool >( category, name, &value, def ) ); }
  13. void CConfig::SetupColor( float value[4], std::string name ) {
  14. SetupValue( value[0], value[0], ( "colors" ), name + "_r" );
  15. SetupValue( value[1], value[1], ( "colors" ), name + "_g" );
  16. SetupValue( value[2], value[2], ( "colors" ), name + "_b" );
  17. SetupValue( value[3], value[3], ( "colors" ), name + "_a" );
  18. }
  19.  
  20. void CConfig::SetupLegit( ) {
  21. for( auto&[key, val] : weapon_names ) {
  22. SetupValue( g_Options.legitbot_items[key].enabled, false, ( val ), ( "enabled" ) );
  23. SetupValue( g_Options.legitbot_items[key].deathmatch, false, ( val ), ( "deathmatch" ) );
  24. SetupValue( g_Options.legitbot_items[key].autopistol, false, ( val ), ( "autopistol" ) );
  25. SetupValue( g_Options.legitbot_items[key].smoke_check, false, ( val ), ( "smoke_check" ) );
  26. SetupValue( g_Options.legitbot_items[key].flash_check, false, ( val ), ( "flash_check" ) );
  27. SetupValue( g_Options.legitbot_items[key].jump_check, false, ( val ), ( "jump_check" ) );
  28. SetupValue( g_Options.legitbot_items[key].autowall, false, ( val ), ( "autowall" ) );
  29. SetupValue( g_Options.legitbot_items[key].silent, false, ( val ), ( "silent" ) );
  30. SetupValue( g_Options.legitbot_items[key].autofire, false, (val), ("autofire") );
  31. SetupValue( g_Options.legitbot_items[key].on_key, true, (val), ("on_key") );
  32. SetupValue( g_Options.legitbot_items[key].rcs, false, ( val ), ( "rcs" ) );
  33. SetupValue( g_Options.legitbot_items[key].rcs_fov_enabled, false, ( val ), ( "rcs_fov_enabled" ) );
  34. SetupValue( g_Options.legitbot_items[key].rcs_smooth_enabled, false, ( val ), ( "rcs_smooth_enabled" ) );
  35. SetupValue( g_Options.legitbot_items[key].autostop, false, ( val ), ( "autostop" ) );
  36. SetupValue( g_Options.legitbot_items[key].backtrack_time, 0.0f, ( val ), ( "backtrack_time" ) );
  37. SetupValue( g_Options.legitbot_items[key].only_in_zoom, false, ( val ), ( "only_in_zoom" ) );
  38. SetupValue( g_Options.legitbot_items[key].autofire_key, 1, (val), ("autofire_key") );
  39. SetupValue( g_Options.legitbot_items[key].key, 1, (val), ("key") );
  40. SetupValue( g_Options.legitbot_items[key].aim_type, 1, ( val ), ( "aim_type" ) );
  41. SetupValue( g_Options.legitbot_items[key].priority, 0, ( val ), ( "priority" ) );
  42. SetupValue( g_Options.legitbot_items[key].fov_type, 0, ( val ), ( "fov_type" ) );
  43. SetupValue( g_Options.legitbot_items[key].rcs_type, 0, ( val ), ( "rcs_type" ) );
  44. SetupValue( g_Options.legitbot_items[key].smooth_type, 0, ( val ), ( "smooth_type" ) );
  45. SetupValue( g_Options.legitbot_items[key].hitbox, 1, ( val ), ( "hitbox" ) );
  46. SetupValue( g_Options.legitbot_items[key].fov, 0.f, ( val ), ( "fov" ) );
  47. SetupValue( g_Options.legitbot_items[key].silent_fov, 0.f, ( val ), ( "silent_fov" ) );
  48. SetupValue( g_Options.legitbot_items[key].rcs_fov, 0.f, ( val ), ( "rcs_fov" ) );
  49. SetupValue( g_Options.legitbot_items[key].smooth, 1, ( val ), ( "smooth" ) );
  50. SetupValue( g_Options.legitbot_items[key].rcs_smooth, 1, ( val ), ( "rcs_smooth" ) );
  51. SetupValue( g_Options.legitbot_items[key].shot_delay, 0, ( val ), ( "shot_delay" ) );
  52. SetupValue( g_Options.legitbot_items[key].kill_delay, 0, ( val ), ( "kill_delay" ) );
  53. SetupValue( g_Options.legitbot_items[key].rcs_x, 100, ( val ), ( "rcs_x" ) );
  54. SetupValue( g_Options.legitbot_items[key].rcs_y, 100, ( val ), ( "rcs_y" ) );
  55. SetupValue( g_Options.legitbot_items[key].rcs_start, 1, ( val ), ( "rcs_start" ) );
  56. SetupValue( g_Options.legitbot_items[key].min_damage, 1, ( val ), ( "min_damage" ) );
  57. }
  58. }
  59.  
  60. void CConfig::SetupVisuals( ) {
  61. SetupValue( g_Options.esp_enabled, false, ( "esp" ), ( "enabled" ) );
  62. SetupValue( g_Options.esp_enemies_only, false, ( "esp" ), ( "enemies_only" ) );
  63. SetupValue( g_Options.esp_player_skeleton, false, ( "esp" ), ( "player_skeleton" ) );
  64. SetupValue( g_Options.esp_player_boxes, false, ( "esp" ), ( "player_boxes" ) );
  65. SetupValue( g_Options.esp_player_boxes_type, 0, ( "esp" ), ( "player_boxes_type" ) );
  66. SetupValue( g_Options.esp_player_names, false, ( "esp" ), ( "player_names" ) );
  67. SetupValue( g_Options.esp_player_health, false, ( "esp" ), ( "player_health" ) );
  68. SetupValue( g_Options.esp_player_armour, false, ( "esp" ), ( "player_armour" ) );
  69. SetupValue( g_Options.esp_player_weapons, false, ( "esp" ), ( "player_weapons" ) );
  70. SetupValue( g_Options.esp_dropped_weapons, false, ( "esp" ), ( "dropped_weapons" ) );
  71. SetupValue( g_Options.esp_defuse_kit, false, ( "esp" ), ( "defuse_kit" ) );
  72. SetupValue( g_Options.esp_planted_c4, false, ( "esp" ), ( "planted_c4" ) );
  73. SetupValue( g_Options.esp_items, false, ( "esp" ), ( "items" ) );
  74. SetupValue( g_Options.esp_grenade_prediction, false, ( "esp" ), ( "grenade_prediction" ) );
  75. SetupValue( g_Options.esp_backtrack, false, ( "esp" ), ( "backtrack" ) );
  76. SetupValue( g_Options.esp_sounds, false, ( "esp" ), ( "sounds" ) );
  77. SetupValue( g_Options.esp_sounds_time, 0.5f, ( "esp" ), ( "sounds_time" ) );
  78. SetupValue( g_Options.esp_sounds_radius, 15.0f, ( "esp" ), ( "sounds_radius" ) );
  79. SetupValue( g_Options.esp_choke_indicator, false, ( "esp" ), ( "choke_indicator" ) );
  80. SetupValue( g_Options.esp_angle_lines, false, ( "esp" ), ( "angle_lines" ) );
  81. SetupValue( g_Options.esp_hitmarker, false, ( "esp" ), ( "hitmarker" ) );
  82.  
  83. SetupValue( g_Options.glow_enabled, false, ( "glow" ), ( "enabled" ) );
  84. SetupValue( g_Options.glow_enemies_only, false, ( "glow" ), ( "enemies_only" ) );
  85. SetupValue( g_Options.glow_players, false, ( "glow" ), ( "players" ) );
  86. SetupValue( g_Options.glow_chickens, false, ( "glow" ), ( "chickens" ) );
  87. SetupValue( g_Options.glow_c4_carrier, false, ( "glow" ), ( "c4_carrier" ) );
  88. SetupValue( g_Options.glow_planted_c4, false, ( "glow" ), ( "planted_c4" ) );
  89. SetupValue( g_Options.glow_defuse_kits, false, ( "glow" ), ( "defuse_kits" ) );
  90. SetupValue( g_Options.glow_weapons, false, ( "glow" ), ( "weapons" ) );
  91.  
  92. SetupValue( g_Options.chams_player_enabled, false, ( "chams" ), ( "player_enabled" ) );
  93. SetupValue( g_Options.chams_player_enemies_only, false, ( "chams" ), ( "player_enemies_only" ) );
  94. SetupValue( g_Options.chams_player_wireframe, false, ( "chams" ), ( "player_wireframe" ) );
  95. SetupValue( g_Options.chams_player_flat, false, ( "chams" ), ( "player_flat" ) );
  96. SetupValue( g_Options.chams_player_ignorez, false, ( "chams" ), ( "player_ignorez" ) );
  97. SetupValue( g_Options.chams_player_glass, false, ( "chams" ), ( "player_glass" ) );
  98. SetupValue( g_Options.chams_disable_occulusion, false, ( "chams" ), ( "disable_occulusion" ) );
  99. SetupValue( g_Options.chams_backtrack, 0, ( "chams" ), ( "backtrack" ) );
  100. SetupValue( g_Options.chams_backtrack_flat, false, ( "chams" ), ( "backtrack_flat" ) );
  101. SetupValue( g_Options.chams_desync, false, ( "chams" ), ( "desync" ) );
  102.  
  103. SetupValue(g_Options.other_nightmode, false, ("other"), ("nightmode"));
  104. SetupValue(g_Options.other_nightmode_size, 0.2f, ("other"), ("nightmode_size"));
  105. SetupValue(g_Options.other_mat_ambient_light_r, false, ("other"), ("mat_ambient_light_r"));
  106. SetupValue(g_Options.other_mat_ambient_light_g, false, ("other"), ("mat_ambient_light_g"));
  107. SetupValue(g_Options.other_mat_ambient_light_b, false, ("other"), ("mat_ambient_light_b"));
  108. SetupValue(g_Options.other_mat_ambient_light_rainbow, false, ("other"), ("mat_ambient_light_rainbow"));
  109.  
  110. SetupValue( g_Options.other_drawfov, false, ( "other" ), ( "drawfov" ) );
  111. SetupValue( g_Options.other_no_hands, false, ( "other" ), ( "no_hands" ) );
  112. SetupValue( g_Options.other_no_smoke, false, ( "other" ), ( "no_smoke" ) );
  113. SetupValue( g_Options.other_no_flash, false, ( "other" ), ( "no_flash" ) );
  114. }
  115.  
  116. void CConfig::SetupMisc( ) {
  117. SetupValue( g_Options.misc_bhop, false, ( "misc" ), ( "bhop" ) );
  118. SetupValue( g_Options.misc_autostrafe, false, ( "misc" ), ( "autostrafe" ) );
  119. SetupValue( g_Options.misc_edgejump, false, ( "misc" ), ( "edgejump" ) );
  120. SetupValue( g_Options.misc_spectatorlist, false, ( "misc" ), ( "spectatorlist" ) );
  121. SetupValue( g_Options.misc_radar, false, ( "misc" ), ( "radar" ) );
  122. SetupValue( g_Options.misc_radar_enemyonly, false, ( "misc" ), ( "radar_enemyonly" ) );
  123. SetupValue( g_Options.misc_thirdperson, false, ( "misc" ), ( "thirdperson" ) );
  124. SetupValue( g_Options.misc_thirdperson_bind, 0, ( "misc" ), ( "thirdperson_bind" ) );
  125. SetupValue( g_Options.misc_showranks, false, ( "misc" ), ( "showranks" ) );
  126. SetupValue( g_Options.misc_clantag, false, ("misc"), ("clantag"));
  127. SetupValue( g_Options.misc_watermark, false, ( "misc" ), ( "watermark" ) );
  128. SetupValue( g_Options.misc_desync, 0, ( "misc" ), ( "desync" ) );
  129. SetupValue( g_Options.misc_desync_bind, 0, ( "misc" ), ( "desync_bind" ) );
  130. //SetupValue( g_Options.misc_fakeduck_bind, false, ( "misc" ), ( "fakeduck_bind" ) );
  131. //SetupValue( g_Options.misc_fakeduck_ticks, 0, ( "misc" ), ( "fakeduck_ticks" ) );
  132. //SetupValue( g_Options.misc_block_ducked_attack, false, ( "misc" ), ( "block_ducked_attack" ) );
  133. SetupValue( g_Options.misc_thirdperson_dist, 50.f, ( "misc" ), ( "thirdperson_dist" ) );
  134. SetupValue( g_Options.misc_override_fov, 90, ( "misc" ), ( "override_fov" ) );
  135. SetupValue( g_Options.misc_viewmodel_fov, 68, ( "misc" ), ( "viewmodel_fov" ) );
  136. SetupValue( g_Options.misc_retrack_speed, 2.f, ( "misc" ), ( "misc_retrack_speed" ) );
  137.  
  138. SetupValue( g_Options.misc_slowwalk_bind, false, ( "misc" ), ( "slowwalk_bind" ) );
  139. SetupValue( g_Options.misc_slowwalk_speed, 1.0f, ( "misc" ), ( "slowwalk_speed" ) );
  140.  
  141. SetupValue( g_Options.fakelag_enabled, false, ( "fakelag" ), ( "enabled" ) );
  142. SetupValue( g_Options.fakelag_standing, false, ( "fakelag" ), ( "standing" ) );
  143. SetupValue( g_Options.fakelag_moving, false, ( "fakelag" ), ( "moving" ) );
  144. SetupValue( g_Options.fakelag_unducking, false, ( "fakelag" ), ( "unducking" ) );
  145. SetupValue( g_Options.fakelag_mode, 0, ( "fakelag" ), ( "mode" ) );
  146. SetupValue( g_Options.fakelag_factor, 0, ( "fakelag" ), ( "factor" ) );
  147. }
  148.  
  149. void CConfig::SetupSkins() {
  150. //for (auto&[key, val] : k_weapon_names) {
  151. for (auto& key : k_weapon_names) {
  152. SetupValue(g_Options.skins.m_items[key.definition_index].name, "Default",( key.name ), ("name"));
  153. SetupValue(g_Options.skins.m_items[key.definition_index].enabled, 0, (key.name), ("enabled"));
  154. SetupValue(g_Options.skins.m_items[key.definition_index].definition_vector_index, 0, ( key.name ), ("definition_vector_index"));
  155. SetupValue(g_Options.skins.m_items[key.definition_index].definition_index, 1, (key.name), ("definition_index"));
  156. SetupValue(g_Options.skins.m_items[key.definition_index].paint_kit_vector_index, 0, (key.name), ("paint_kit_vector_index"));
  157. SetupValue(g_Options.skins.m_items[key.definition_index].paint_kit_index, 0, (key.name), ("paint_kit_index"));
  158. SetupValue(g_Options.skins.m_items[key.definition_index].definition_override_vector_index, 0, (key.name), ("definition_override_vector_index"));
  159. SetupValue(g_Options.skins.m_items[key.definition_index].definition_override_index, 0, (key.name), ("definition_override_index"));
  160. SetupValue(g_Options.skins.m_items[key.definition_index].seed, 0, (key.name), ("seed"));
  161. SetupValue(g_Options.skins.m_items[key.definition_index].stat_trak, 0, (key.name), ("stat_trak"));
  162. SetupValue(g_Options.skins.m_items[key.definition_index].wear, 0.0f, (key.name), ("wear"));
  163. //SetupValue(g_Options.skins.m_items[key.definition_index].custom_name, "", (key.name), ("custom_name"));
  164. }
  165. }
  166.  
  167. void CConfig::SetupColors( ) {
  168. SetupColor( g_Options.color_esp_ally_visible, "color_esp_ally_visible" );
  169. SetupColor( g_Options.color_esp_enemy_visible, "color_esp_enemy_visible" );
  170. SetupColor( g_Options.color_esp_ally_occluded, "color_esp_ally_occluded" );
  171. SetupColor( g_Options.color_esp_enemy_occluded, "color_esp_enemy_occluded" );
  172. SetupColor( g_Options.color_esp_enemy_occluded, "color_esp_enemy_occluded" );
  173. SetupColor( g_Options.color_esp_weapons, "color_esp_weapons" );
  174. SetupColor( g_Options.color_esp_defuse, "color_esp_defuse" );
  175. SetupColor( g_Options.color_esp_c4, "color_esp_c4" );
  176. SetupColor( g_Options.color_esp_item, "color_esp_item" );
  177. SetupColor( g_Options.color_glow_ally, "color_glow_ally" );
  178. SetupColor( g_Options.color_glow_enemy, "color_glow_enemy" );
  179. SetupColor( g_Options.color_glow_chickens, "color_glow_chickens" );
  180. SetupColor( g_Options.color_glow_c4_carrier, "color_glow_c4_carrier" );
  181. SetupColor( g_Options.color_glow_planted_c4, "color_glow_planted_c4" );
  182. SetupColor( g_Options.color_glow_defuse, "color_glow_defuse" );
  183. SetupColor( g_Options.color_glow_weapons, "color_glow_weapons" );
  184. SetupColor( g_Options.color_chams_player_ally_visible, "color_chams_player_ally_visible" );
  185. SetupColor( g_Options.color_chams_player_ally_occluded, "color_chams_player_ally_occluded" );
  186. SetupColor( g_Options.color_chams_player_enemy_visible, "color_chams_player_enemy_visible" );
  187. SetupColor( g_Options.color_chams_player_enemy_occluded, "color_chams_player_enemy_occluded" );
  188. SetupColor( g_Options.color_chams_backtrack, "color_chams_backtrack" );
  189. SetupColor( g_Options.color_chams_desync, "color_chams_desync" );
  190. SetupColor( g_Options.color_grenade_prediction, "color_grenade_prediction" );
  191. SetupColor( g_Options.color_esp_sounds, "color_esp_sounds" );
  192. }
  193.  
  194. void CConfig::Setup( ) {
  195. CConfig::SetupLegit( );
  196. CConfig::SetupVisuals( );
  197. CConfig::SetupMisc( );
  198. CConfig::SetupSkins();
  199. CConfig::SetupColors( );
  200. }
  201.  
  202. #include "helpers/utils.hpp"
  203. void CConfig::Save( const std::string& name ) {
  204. if( name.empty( ) )
  205. return;
  206.  
  207. CreateDirectoryA( u8"C:\\Hypeware\\", NULL );
  208. std::string file = u8"C:\\Hypeware\\" + name;
  209.  
  210. for( auto value : ints ) {
  211. WritePrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), std::to_string( *value->value ).c_str( ), file.c_str( ) );
  212. }
  213.  
  214. for( auto value : floats ) WritePrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), std::to_string( *value->value ).c_str( ), file.c_str( ) );
  215. for( auto value : bools ) WritePrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), *value->value ? "true" : "false", file.c_str( ) );
  216. }
  217.  
  218. void CConfig::Load( const std::string& name ) {
  219. if( name.empty( ) )
  220. return;
  221.  
  222. g_ClientState->ForceFullUpdate();
  223.  
  224. CreateDirectoryA( u8"C:\\Hypeware\\", NULL );
  225. std::string file = u8"C:\Hypeware\\" + name;
  226.  
  227. char value_l[32] = { '\0' };
  228. for( auto value : ints ) {
  229. GetPrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), "0", value_l, 32, file.c_str( ) ); *value->value = atoi( value_l );
  230. }
  231.  
  232. for( auto value : floats ) {
  233. GetPrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), "0.0f", value_l, 32, file.c_str( ) ); *value->value = atof( value_l );
  234. }
  235.  
  236. for( auto value : bools ) {
  237. GetPrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), "false", value_l, 32, file.c_str( ) ); *value->value = !strcmp( value_l, "true" );
  238. }
  239. }
  240.  
  241. CConfig* Config = new CConfig( );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement