#include <std_include.hpp>
#include <utils/string.hpp>

#include "game.hpp"

namespace dvars
{
	game::dvar_t* con_inputBoxColor = nullptr;
	game::dvar_t* con_inputHintBoxColor = nullptr;
	game::dvar_t* con_outputBarColor = nullptr;
	game::dvar_t* con_outputSliderColor = nullptr;
	game::dvar_t* con_outputWindowColor = nullptr;
	game::dvar_t* con_inputDvarMatchColor = nullptr;
	game::dvar_t* con_inputDvarValueColor = nullptr;
	game::dvar_t* con_inputDvarInactiveValueColor = nullptr;
	game::dvar_t* con_inputCmdMatchColor = nullptr;

	game::dvar_t* jump_enableFallDamage;

	game::dvar_t* r_fullbright;

	game::dvar_t* cg_legacyCrashHandling;

	std::string dvar_get_vector_domain(const int components, const game::dvar_limits& domain)
	{
		if (domain.vector.min == -FLT_MAX)
		{
			if (domain.vector.max == FLT_MAX)
			{
				return utils::string::va("Domain is any %iD vector", components);
			}
			else
			{
				return utils::string::va("Domain is any %iD vector with components %g or smaller", components,
				                         domain.vector.max);
			}
		}
		else if (domain.vector.max == FLT_MAX)
		{
			return utils::string::va("Domain is any %iD vector with components %g or bigger", components,
			                         domain.vector.min);
		}
		else
		{
			return utils::string::va("Domain is any %iD vector with components from %g to %g", components,
			                         domain.vector.min, domain.vector.max);
		}
	}

	std::string dvar_get_domain(const game::dvar_type type, const game::dvar_limits& domain)
	{
		std::string str;

		switch (type)
		{
		case game::dvar_type::boolean:
			return "Domain is 0 or 1"s;

		case game::dvar_type::value:
			if (domain.value.min == -FLT_MAX)
			{
				if (domain.value.max == FLT_MAX)
				{
					return "Domain is any number"s;
				}

				return utils::string::va("Domain is any number %g or smaller", domain.value.max);
			}

			if (domain.value.max == FLT_MAX)
			{
				return utils::string::va("Domain is any number %g or bigger", domain.value.min);
			}

			return utils::string::va("Domain is any number from %g to %g", domain.value.min, domain.value.max);

		case game::dvar_type::vec2:
			return dvar_get_vector_domain(2, domain);

		case game::dvar_type::rgb:
		case game::dvar_type::vec3:
			return dvar_get_vector_domain(3, domain);

		case game::dvar_type::vec4:
			return dvar_get_vector_domain(4, domain);

		case game::dvar_type::integer:
			if (domain.enumeration.stringCount == INT_MIN)
			{
				if (domain.integer.max == INT_MAX)
				{
					return "Domain is any integer"s;
				}

				return utils::string::va("Domain is any integer %i or smaller", domain.integer.max);
			}

			if (domain.integer.max == INT_MAX)
			{
				return utils::string::va("Domain is any integer %i or bigger", domain.integer.min);
			}

			return utils::string::va("Domain is any integer from %i to %i", domain.integer.min, domain.integer.max);

		case game::dvar_type::color:
			return "Domain is any 4-component color, in RGBA format"s;

		case game::dvar_type::enumeration:
			str = "Domain is one of the following:"s;

			for (auto string_index = 0; string_index < domain.enumeration.stringCount; ++string_index)
			{
				str += utils::string::va("\n  %2i: %s", string_index, domain.enumeration.strings[string_index]);
			}

			return str;

		case game::dvar_type::string:
			return "Domain is any text"s;

		default:
			return utils::string::va("unhandled dvar type '%i'", type);
		}
	}

	std::vector<std::string> dvar_list = 
	{
		"ai_corpseLimit",
		"band_12players",
		"band_18players",
		"band_2players",
		"band_4players",
		"band_8players",
		"ca_auto_signin",
		"ca_do_mlc",
		"ca_intra_only",
		"ca_require_signin",
		"ca_show_signup_request",
		"cg_blood",
		"cg_brass",
		"cg_cursorHints",
		"cg_drawBuildName",
		"cg_drawCrosshair",
		"cg_drawFPS",
		"cg_drawFPSLabels",
		"cg_drawMantleHint",
		"cg_drawTurretCrosshair",
		"cg_drawViewpos",
		"cg_fov",
		"cg_gameBoldMessageWidth",
		"cg_gameMessageWidth",
		"cg_headIconMinScreenRadius",
		"cg_hintFadeTime",
		"cg_hudDamageIconHeight",
		"cg_hudDamageIconInScope",
		"cg_hudDamageIconOffset",
		"cg_hudDamageIconWidth",
		"cg_hudGrenadeIconEnabledFlash",
		"cg_hudGrenadeIconInScope",
		"cg_hudGrenadeIconMaxRangeFlash",
		"cg_hudGrenadeIconMaxRangeFrag",
		"cg_invalidCmdHintDuration",
		"cg_mapLocationSelectionCursorSpeed",
		"cg_marks_ents_player_only",
		"cg_scriptIconSize",
		"cg_sprintMeterDisabledColor",
		"cg_sprintMeterEmptyColor",
		"cg_sprintMeterFullColor",
		"cg_subtitleMinTime",
		"cg_viewZSmoothingMax",
		"cg_viewZSmoothingMin",
		"cg_viewZSmoothingTime",
		"cg_waterSheeting_distortionScaleFactor",
		"cg_waterSheeting_magnitude",
		"cg_waterSheeting_radius",
		"cg_weaponCycleDelay",
		"cl_anglespeedkey",
		"cl_dirSelConvergenceTime",
		"cl_force_paused",
		"cl_freelook",
		"cl_lessprint",
		"cl_maxpackets",
		"cl_modifiedDebugPlacement",
		"cl_mouseAccel",
		"cl_noprint",
		"cl_packetdup",
		"cl_paused",
		"cl_pitchspeed",
		"cl_showmouserate",
		"cl_yawspeed",
		"com_animCheck",
		"com_cinematicEndInWhite",
		"com_completionResolveCommand",
		"com_errorResolveCommand",
		"com_filter_output",
		"com_maxfps",
		"com_maxFrameTime",
		"com_playerProfile",
		"com_recommendedSet",
		"commerce_dl_retry_step",
		"commerce_manifest_file_max_retry_time",
		"commerce_manifest_file_retry_step",
		"commerce_max_dl_retry_time",
		"commerce_max_retry_time",
		"commerce_retry_step",
		"compassSize",
		"comscore_active",
		"comscore_backoff",
		"con_gameMsgWindow0FadeInTime",
		"con_gameMsgWindow0FadeOutTime",
		"con_gameMsgWindow0Filter",
		"con_gameMsgWindow0LineCount",
		"con_gameMsgWindow0MsgTime",
		"con_gameMsgWindow0ScrollTime",
		"con_gameMsgWindow1FadeInTime",
		"con_gameMsgWindow1FadeOutTime",
		"con_gameMsgWindow1Filter",
		"con_gameMsgWindow1LineCount",
		"con_gameMsgWindow1MsgTime",
		"con_gameMsgWindow1ScrollTime",
		"con_gameMsgWindow2FadeInTime",
		"con_gameMsgWindow2FadeOutTime",
		"con_gameMsgWindow2Filter",
		"con_gameMsgWindow2LineCount",
		"con_gameMsgWindow2MsgTime",
		"con_gameMsgWindow2ScrollTime",
		"con_gameMsgWindow3FadeInTime",
		"con_gameMsgWindow3FadeOutTime",
		"con_gameMsgWindow3Filter",
		"con_gameMsgWindow3LineCount",
		"con_gameMsgWindow3MsgTime",
		"con_gameMsgWindow3ScrollTime",
		"con_inputBoxColor",
		"con_inputCmdMatchColor",
		"con_inputDvarInactiveValueColor",
		"con_inputDvarMatchColor",
		"con_inputDvarValueColor",
		"con_inputHintBoxColor",
		"con_outputBarColor",
		"con_outputSliderColor",
		"con_outputWindowColor",
		"con_typewriterColorGlowCheckpoint",
		"con_typewriterColorGlowCompleted",
		"con_typewriterColorGlowFailed",
		"con_typewriterColorGlowUpdated",
		"con_typewriterDecayDuration",
		"con_typewriterDecayStartTime",
		"con_typewriterPrintSpeed",
		"counterDownloadInterval",
		"counterUploadInterval",
		"dc_lobbymerge",
		"dedicated_dhclient",
		"demonwareConsideredConnectedTime",
		"developer",
		"discard_playerstats_on_suspend",
		"dw_addrHandleTimeout",
		"dw_leaderboard_write_active",
		"dw_presence_active",
		"dw_presence_coop_join_active",
		"dw_presence_get_delay",
		"dw_presence_get_rate",
		"dw_presence_put_delay",
		"dw_presence_put_rate",
		"dw_shared_presence_active",
		"dw_shared_presence_get_delay",
		"dw_shared_presence_get_rate",
		"dw_shared_presence_put_delay",
		"dw_shared_presence_put_rate",
		"dwBandwidthTestTaskTimeout",
		"dynEnt_active",
		"elite_clan_active",
		"elite_clan_cool_off_time",
		"elite_clan_delay",
		"elite_clan_division_icon_active",
		"elite_clan_get_blob_profile_max_retry_time",
		"elite_clan_get_blob_profile_retry_step",
		"elite_clan_get_clan_max_retry_time",
		"elite_clan_get_clan_retry_step",
		"elite_clan_get_members_max_retry_time",
		"elite_clan_get_members_retry_step",
		"elite_clan_get_private_member_profile_max_retry_time",
		"elite_clan_get_private_member_profile_retry_step",
		"elite_clan_get_public_profile_max_retry_time",
		"elite_clan_get_public_profile_retry_step",
		"elite_clan_get_team_stats_max_retry_time",
		"elite_clan_get_team_stats_retry_step",
		"elite_clan_motd_throttle_time",
		"elite_clan_send_message_to_members_max_retry_time",
		"elite_clan_send_message_to_members_retry_step",
		"elite_clan_set_private_member_profile_max_retry_time",
		"elite_clan_set_private_member_profile_retry_step",
		"elite_clan_single_task_popup_text",
		"elite_clan_using_title",
		"enable_recordRecentActivity",
		"enable_video_options_preload_shader_controls",
		"entitlements_active",
		"entitlements_config_file_max_retry_time",
		"entitlements_config_file_retry_step",
		"entitlements_cool_off_time",
		"entitlements_delay",
		"entitlements_key_archive_max_retry_time",
		"entitlements_key_archive_retry_step",
		"entitlementSystemOk",
		"facebook_active",
		"facebook_delay",
		"facebook_friends_active",
		"facebook_friends_max_retry_time",
		"facebook_friends_refresh_time",
		"facebook_friends_retry_step",
		"facebook_friends_showing_count",
		"facebook_friends_throttle_time",
		"facebook_max_retry_time",
		"facebook_password",
		"facebook_password_asterisk",
		"facebook_popup_text",
		"facebook_retry_step",
		"facebook_upload_photo_active",
		"facebook_upload_video_active",
		"facebook_username",
		"fixedtime",
		"fs_basegame",
		"fs_basepath",
		"fs_basepath_output",
		"fs_cdpath",
		"fs_copyfiles",
		"fs_debug",
		"fs_game",
		"fs_homepath",
		"fs_ignoreLocalized",
		"fx_alphaThreshold",
		"fx_cast_shadow",
		"fx_cull_elem_draw",
		"fx_cull_elem_spawn",
		"fx_deferelem",
		"fx_draw",
		"fx_draw_omniLight",
		"fx_draw_spotLight",
		"fx_drawClouds",
		"fx_enable",
		"fx_flare",
		"fx_killEffectOnRewind",
		"fx_lightGridSampleOffset",
		"fx_mark_profile",
		"fx_marks",
		"fx_marks_ents",
		"fx_marks_nearlimit",
		"fx_marks_smodels",
		"fx_physicsImpactVelocityThreshold",
		"fx_profile",
		"fx_profileFilter",
		"fx_profileFilterElemCountZero",
		"fx_profileSkip",
		"fx_profileSort",
		"fx_visMinTraceDist",
		"gamedvr_active",
		"gameMode",
		"glass_angular_vel",
		"glass_break",
		"glass_crack_pattern_scale",
		"glass_edge_angle",
		"glass_fall_delay",
		"glass_fall_gravity",
		"glass_fall_ratio",
		"glass_fringe_maxcoverage",
		"glass_fringe_maxsize",
		"glass_fx_chance",
		"glass_hinge_friction",
		"glass_linear_vel",
		"glass_max_pieces_per_frame",
		"glass_max_shatter_fx_per_frame",
		"glass_physics_chance",
		"glass_physics_maxdist",
		"glass_shard_maxsize",
		"glass_shattered_scale",
		"glass_trace_interval",
		"gpad_button_deadzone",
		"gpad_dpadDebounceTime",
		"gpad_menu_scroll_delay_first",
		"gpad_menu_scroll_delay_rest_accel",
		"gpad_menu_scroll_delay_rest_end",
		"gpad_menu_scroll_delay_rest_start",
		"gpad_stick_deadzone_max",
		"gpad_stick_deadzone_min",
		"gpad_stick_pressed",
		"gpad_stick_pressed_hysteresis",
		"groupDownloadInterval",
		"groupUploadInterval",
		"hiDef",
		"hud_deathQuoteFadeTime",
		"hud_fade_healthbar",
		"hud_fade_sprint",
		"hud_flash_period_offhand",
		"hud_flash_time_offhand",
		"hud_health_pulserate_critical",
		"hud_health_pulserate_injured",
		"hud_health_startpulse_critical",
		"hud_health_startpulse_injured",
		"igs_sosp",
		"igs_td",
		"in_mouse",
		"intro",
		"lb_filter",
		"lb_maxrows",
		"lb_minrefresh",
		"lb_readDelay",
		"lb_throttle_time",
		"lb_times_in_window",
		"lb_window",
		"live_displayVACSpecificLogOnMsg",
		"live_qosec_firstupdatems",
		"live_qosec_lastupdatems",
		"live_qosec_minpercent",
		"live_qosec_minprobes",
		"liveanticheatunknowndvar",
		"livestreaming_active",
		"loading_sre_fatal",
		"loc_language",
		"loc_translate",
		"log_host_migration_chance",
		"lsp_enumertion_max_retry_time",
		"lsp_enumertion_retry_step",
		"lui_FFotDSupportEnabled",
		"lui_hud_motion_angle_ease_speed",
		"lui_hud_motion_bob_scale",
		"lui_hud_motion_enabled",
		"lui_hud_motion_perspective",
		"lui_hud_motion_rotation_max",
		"lui_hud_motion_rotation_scale",
		"lui_hud_motion_trans_ease_speed",
		"lui_hud_motion_translation_max",
		"lui_hud_motion_translation_scale",
		"LUI_MemErrorsFatal",
		"lui_menuFlowEnabled",
		"lui_splitscreensignin_menu",
		"lui_splitscreenupscaling",
		"lui_systemlink_menu",
		"lui_waitingforgavelmessagesconfirmed",
		"lui_waitingfornetworktype",
		"lui_waitingforonlinedatafetch_controller",
		"LUI_WorkerCmdGC",
		"lui_xboxlive_menu",
		"m_filter",
		"m_forward",
		"m_pitch",
		"m_side",
		"m_yaw",
		"mapname",
		"marketing_active",
		"marketing_refresh_time",
		"matchdata_active",
		"matchdata_maxcompressionbuffer",
		"matchmaking_debug",
		"maxPrestigeOverride",
		"maxVoicePacketsPerSec",
		"maxVoicePacketsPerSecForServer",
		"mdsd",
		"monkeytoy",
		"motd",
		"motd_store_link",
		"name",
		"net_ip",
		"net_noudp",
		"net_port",
		"net_socksEnabled",
		"net_socksPassword",
		"net_socksPort",
		"net_socksServer",
		"net_socksUsername",
		"nextmap",
		"num_available_map_packs",
		"phys_autoDisableLinear",
		"phys_autoDisableTime",
		"phys_bulletSpinScale",
		"phys_bulletUpBias",
		"phys_dragAngular",
		"phys_dragLinear",
		"phys_gravity",
		"phys_gravity_ragdoll",
		"phys_gravityChangeWakeupRadius",
		"phys_jitterMaxMass",
		"physVeh_explodeForce",
		"physVeh_explodeSpinScale",
		"physVeh_jump",
		"physVeh_minContactImpulse",
		"physVeh_minImpactMomentum",
		"physVeh_StepsPerFrame",
		"prestige30EasterEggEnabled",
		"prestige_shop_active",
		"profileMenuOption_blacklevel",
		"profileMenuOption_offensiveContentMode",
		"profileMenuOption_safeAreaHorz",
		"profileMenuOption_safeAreaVert",
		"profileMenuOption_volume",
		"publisherFileFetchTimeout",
		"r_aaMaxQuality",
		"r_aaSamples",
		"r_adapter",
		"r_adapterName",
		"r_adaptiveSubdiv",
		"r_adaptiveSubdivBaseFactor",
		"r_adaptiveSubdivPatchFactor",
		"r_amdGPU",
		"r_aoBlurSharpness",
		"r_aoBlurStep",
		"r_aoDiminish",
		"r_aoPower",
		"r_aoStrength",
		"r_aoUseTweaks",
		"r_artUseTweaks",
		"r_aspectRatio",
		"r_asyncCompute",
		"r_atlasAnimFPS",
		"r_autoPriority",
		"r_balanceLightmapOpaqueLists",
		"r_blacklevel",
		"r_blur",
		"r_blurdstGaussianBlurLevel",
		"r_blurdstGaussianBlurRadius",
		"r_brightness",
		"r_cacheModelLighting",
		"r_cacheSModelLighting",
		"r_charLightAmbient",
		"r_clampLodScale",
		"r_clear",
		"r_clearColor",
		"r_clearColor2",
		"r_clutCompositeVisionSet",
		"r_cmdbuf_worker",
		"r_colorGradingEnable",
		"r_colorMap",
		"r_colorScaleUseTweaks",
		"r_combinePostOpaqueFx",
		"r_contrast",
		"r_darkBlur",
		"r_darkBlurPower",
		"r_darkBlurRadius",
		"r_darkColor",
		"r_darkColorPower",
		"r_debugLineWidth",
		"r_defaultPatchCount",
		"r_depthPrepass",
		"r_depthSortEnable",
		"r_depthSortRange",
		"r_desaturation",
		"r_detailMap",
		"r_diffuseColorScale",
		"r_displacementMap",
		"r_displacementPatchCount",
		"r_distortion",
		"r_distortion_script_force_off",
		"r_dlightForceLimit",
		"r_dlightLimit",
		"r_dof_bias",
		"r_dof_enable",
		"r_dof_farBlur",
		"r_dof_farEnd",
		"r_dof_farStart",
		"r_dof_limit",
		"r_dof_nearBlur",
		"r_dof_nearEnd",
		"r_dof_nearStart",
		"r_dof_physical_adsFocusSpeed",
		"r_dof_physical_adsMaxFstop",
		"r_dof_physical_adsMinFstop",
		"r_dof_physical_bokehEnable",
		"r_dof_physical_bokehPreset",
		"r_dof_physical_bokehRotation",
		"r_dof_physical_bokehShape",
		"r_dof_physical_bokehSharpness",
		"r_dof_physical_enable",
		"r_dof_physical_filmDiagonal",
		"r_dof_physical_focusDistance",
		"r_dof_physical_fstop",
		"r_dof_physical_hipEnable",
		"r_dof_physical_hipFocusSpeed",
		"r_dof_physical_hipFstop",
		"r_dof_physical_hipSharpCocDiameter",
		"r_dof_physical_maxCocDiameter",
		"r_dof_physical_minFocusDistance",
		"r_dof_physical_viewModelFocusDistance",
		"r_dof_physical_viewModelFstop",
		"r_dof_tweak",
		"r_dof_viewModelEnd",
		"r_dof_viewModelStart",
		"r_drawWater",
		"r_dynamicOPL",
		"r_dynamicSpotLightShadows",
		"r_elevatedPriority",
		"r_emblemBrightnessScale",
		"r_emissiveMap",
		"r_envBrdfLutMap",
		"r_envMapExponent",
		"r_envMapMaxIntensity",
		"r_envMapMinIntensity",
		"r_envMapOverride",
		"r_envMapSunIntensity",
		"r_eyePupil",
		"r_eyeRedness",
		"r_eyeWetness",
		"r_fastModelPrimaryLightCheck",
		"r_fastModelPrimaryLightLink",
		"r_fill_texture_memory",
		"r_filmAltShader",
		"r_filmTweakBrightness",
		"r_filmTweakContrast",
		"r_filmTweakDarkTint",
		"r_filmTweakDesaturation",
		"r_filmTweakDesaturationDark",
		"r_filmTweakEnable",
		"r_filmTweakInvert",
		"r_filmTweakLightTint",
		"r_filmTweakMediumTint",
		"r_filmUseTweaks",
		"r_floatZCopy",
		"r_flushAfterExecute",
		"r_fog",
		"r_fog_depthhack_scale",
		"r_fog_ev_adjust",
		"r_forceLod",
		"r_fullscreen",
		"r_fullscreenWindow",
		"r_fxaaSubpixel",
		"r_FXAverageColorFunc",
		"r_globalGenericMaterialScale",
		"r_glow_allowed",
		"r_glow_allowed_script_forced",
		"r_gunSightColorEntityScale",
		"r_gunSightColorNoneScale",
		"r_hbaoBias",
		"r_hbaoBlurEnable",
		"r_hbaoBlurSharpness",
		"r_hbaoCoarseAO",
		"r_hbaoDetailAO",
		"r_hbaoRadius",
		"r_hbaoSceneScale",
		"r_hbaoStrengthBlend",
		"r_hbaoStrengthFixed",
		"r_hbaoStrengthScale",
		"r_hemiAoBlurTolerance",
		"r_hemiAoCombineResolutionsBeforeBlur",
		"r_hemiAoCombineResolutionsWithMul",
		"r_hemiAoDepthSquash",
		"r_hemiAoEnable",
		"r_hemiAoHierarchyDepth",
		"r_hemiAoMaxDepthDownsample",
		"r_hemiAoNoiseFilterTolerance",
		"r_hemiAoPower",
		"r_hemiAoQualityLevel",
		"r_hemiAoRejectionFalloff",
		"r_hemiAoStrength",
		"r_hemiAoUpsampleTolerance",
		"r_heroLighting",
		"r_highLodDist",
		"r_hudFx",
		"r_ignore",
		"r_ignoref",
		"r_image_cache_copy_memory_budget",
		"r_image_cache_copy_number_budget",
		"r_image_cache_create_memory_budget",
		"r_image_cache_delay_ms",
		"r_image_cache_delete_until_available",
		"r_image_cache_keep_lower_mips",
		"r_image_cache_make_staging_texture",
		"r_image_cache_mass_remove_threshold",
		"r_image_cache_throttle_ms",
		"r_inGameVideo",
		"r_lateAllocParamCacheAllowed",
		"r_lateAllocParamCacheDefault",
		"r_lateAllocParamCacheDisplacement",
		"r_lateAllocParamCacheSubdiv",
		"r_lightCacheLessFrequentMaxDistance",
		"r_lightCacheLessFrequentPeriod",
		"r_lightGridAvgApplyPrimaryLight",
		"r_lightGridAvgFollowCamera",
		"r_lightGridAvgProbeCount",
		"r_lightGridAvgTraceGround",
		"r_lightGridContrast",
		"r_lightGridDefaultFXLightingLookup",
		"r_lightGridDefaultModelLightingLookup",
		"r_lightGridEnableTweaks",
		"r_lightGridIntensity",
		"r_lightGridSHBands",
		"r_lightGridUseTweakedValues",
		"r_lightMap",
		"r_litSurfaceHDRScalar",
		"r_loadForRenderer",
		"r_lockPvs",
		"r_lod4Dist",
		"r_lod5Dist",
		"r_lodBiasRigid",
		"r_lodBiasSkinned",
		"r_lodLimit",
		"r_lodScaleRigid",
		"r_lodScaleSkinned",
		"r_lowestLodDist",
		"r_lowLodDist",
		"r_mbFastEnable",
		"r_mbFastPreset",
		"r_mbLimit",
		"r_mdao",
		"r_mdaoAsyncOccluderGen",
		"r_mdaoBoneInfluenceRadiusScale",
		"r_mdaoCapsuleStrength",
		"r_mdaoLimit",
		"r_mdaoMinBoneBoundsToOcclude",
		"r_mdaoOccluderCullDistance",
		"r_mdaoOccluderFadeOutStartDistance",
		"r_mdaoUseTweaks",
		"r_mdaoVolumeStrength",
		"r_mediumLodDist",
		"r_mode",
		"r_modelLightingMap",
		"r_monitor",
		"r_mpRimColor",
		"r_mpRimDiffuseTint",
		"r_mpRimStrength",
		"r_msaa_downsample",
		"r_multiGPU",
		"r_normalMap",
		"r_numGPUs",
		"r_nvidiaGPU",
		"r_offchipTessellationAllowed",
		"r_offchipTessellationTfThreshold",
		"r_offchipTessellationWaveThreshold",
		"r_omitUnusedRenderTargets",
		"r_outdoor",
		"r_outdoorFeather",
		"r_particleHdr",
		"r_patchCountAllowed",
		"r_picmip",
		"r_picmip_bump",
		"r_picmip_spec",
		"r_picmip_water",
		"r_polygonOffsetBias",
		"r_polygonOffsetClamp",
		"r_polygonOffsetScale",
		"r_portalBevels",
		"r_portalBevelsOnly",
		"r_portalMinClipArea",
		"r_portalMinRecurseDepth",
		"r_portalWalkLimit",
		"r_postAA",
		"r_postfx_enable",
		"r_preloadShaders",
		"r_preloadShadersWNDTOO",
		"r_primaryLightTweakDiffuseStrength",
		"r_primaryLightTweakSpecularStrength",
		"r_primaryLightUseTweaks",
		"r_reactiveMotionActorRadius",
		"r_reactiveMotionActorVelocityMax",
		"r_reactiveMotionActorZOffset",
		"r_reactiveMotionEffectorStrengthScale",
		"r_reactiveMotionHelicopterLimit",
		"r_reactiveMotionHelicopterRadius",
		"r_reactiveMotionHelicopterStrength",
		"r_reactiveMotionPlayerHeightAdjust",
		"r_reactiveMotionPlayerRadius",
		"r_reactiveMotionPlayerZOffset",
		"r_reactiveMotionVelocityTailScale",
		"r_reactiveMotionWindAmplitudeScale",
		"r_reactiveMotionWindAreaScale",
		"r_reactiveMotionWindDir",
		"r_reactiveMotionWindFrequencyScale",
		"r_reactiveMotionWindStrength",
		"r_reflectionProbeMap",
		"r_reflectionProbeNmlLuminance",
		"r_refreshRate",
		"r_rimLight0Color",
		"r_rimLight0Heading",
		"r_rimLight0Pitch",
		"r_rimLightBias",
		"r_rimLightDiffuseIntensity",
		"r_rimLightFalloffMaxDistance",
		"r_rimLightFalloffMinDistance",
		"r_rimLightFalloffMinIntensity",
		"r_rimLightPower",
		"r_rimLightSpecIntensity",
		"r_rimLightUseTweaks",
		"r_scaleViewport",
		"r_sceneMipShowOverlay",
		"r_showLightGrid",
		"r_showLightGridAvgProbes",
		"r_showLightGridDetailInfo",
		"r_showLightProbes",
		"r_showMissingLightGrid",
		"r_showModelLightingLowWaterMark",
		"r_showPortals",
		"r_showPortalsOverview",
		"r_showReflectionProbeSelection",
		"r_skipPvs",
		"r_skyFogUseTweaks",
		"r_smaaFilmicStrength",
		"r_smaaThreshold",
		"r_smodelInstancedRenderer",
		"r_smodelInstancedThreshold",
		"r_smp_backend",
		"r_smp_worker",
		"r_smp_worker_thread0",
		"r_smp_worker_thread1",
		"r_smp_worker_thread2",
		"r_smp_worker_thread3",
		"r_smp_worker_thread4",
		"r_smp_worker_thread5",
		"r_smp_worker_thread6",
		"r_smp_worker_thread7",
		"r_specOccMap",
		"r_specularColorScale",
		"r_specularMap",
		"r_spotLightEntityShadows",
		"r_spotLightShadows",
		"r_ssaaSamples",
		"r_ssao",
		"r_ssaoDebug",
		"r_ssaoDebugMip",
		"r_ssaoDepthScale",
		"r_ssaoDepthScaleViewModel",
		"r_ssaoDownsample",
		"r_ssaoFadeDepth",
		"r_ssaoGapFalloff",
		"r_ssaoGradientFalloff",
		"r_ssaoLimit",
		"r_ssaoMaxStrengthDepth",
		"r_ssaoMethod",
		"r_ssaoMinPixelWidth",
		"r_ssaoMinStrengthDepth",
		"r_ssaoMultiRes",
		"r_ssaoPower",
		"r_ssaoRejectDepth",
		"r_ssaoSampleCount",
		"r_ssaoScriptScale",
		"r_ssaoStrength",
		"r_ssaoUseTweaks",
		"r_ssaoWidth",
		"r_sse_skinning",
		"r_ssrBlendScale",
		"r_ssrFadeInDuration",
		"r_ssrPositionCorrection",
		"r_ssrRoughnessMipParameters",
		"r_sssBlendWeight",
		"r_sssDebugMaterial",
		"r_sssEnable",
		"r_sssGlobalRadius",
		"r_sssJitterRadius",
		"r_sssLimit",
		"r_sssNarrowRadius",
		"r_sssPreset",
		"r_sssWideRadius",
		"r_subdiv",
		"r_subdivLimit",
		"r_subdivPatchCount",
		"r_subdomainLimit",
		"r_subdomainScale",
		"r_subwindow",
		"r_sun_from_dvars",
		"r_sun_fx_position",
		"r_sunblind_fadein",
		"r_sunblind_fadeout",
		"r_sunblind_max_angle",
		"r_sunblind_max_darken",
		"r_sunblind_min_angle",
		"r_sunflare_fadein",
		"r_sunflare_fadeout",
		"r_sunflare_max_alpha",
		"r_sunflare_max_angle",
		"r_sunflare_max_size",
		"r_sunflare_min_angle",
		"r_sunflare_min_size",
		"r_sunflare_shader",
		"r_sunglare_fadein",
		"r_sunglare_fadeout",
		"r_sunglare_max_angle",
		"r_sunglare_max_lighten",
		"r_sunglare_min_angle",
		"r_sunInfDist",
		"r_sunshadowmap_cmdbuf_worker",
		"r_sunsprite_shader",
		"r_sunsprite_size",
		"r_surfaceHDRScalarUseTweaks",
		"r_tessellation",
		"r_tessellationCutoffDistance",
		"r_tessellationCutoffFalloff",
		"r_tessellationEyeScale",
		"r_tessellationFactor",
		"r_tessellationHeightAuto",
		"r_tessellationHeightScale",
		"r_tessellationHybrid",
		"r_tessellationLodBias",
		"r_texFilterAnisoMax",
		"r_texFilterAnisoMin",
		"r_texFilterDisable",
		"r_texFilterMipBias",
		"r_texFilterMipMode",
		"r_texFilterProbeBilinear",
		"r_texShowMipMode",
		"r_thermalColorOffset",
		"r_thermalColorScale",
		"r_thermalDetailScale",
		"r_thermalFadeColor",
		"r_thermalFadeControl",
		"r_thermalFadeMax",
		"r_thermalFadeMin",
		"r_tonemap",
		"r_tonemapAdaptSpeed",
		"r_tonemapAuto",
		"r_tonemapAutoExposureAdjust",
		"r_tonemapBlack",
		"r_tonemapBlend",
		"r_tonemapCrossover",
		"r_tonemapDarkEv",
		"r_tonemapDarkExposureAdjust",
		"r_tonemapExposure",
		"r_tonemapExposureAdjust",
		"r_tonemapGamma",
		"r_tonemapHighlightRange",
		"r_tonemapLightEv",
		"r_tonemapLightExposureAdjust",
		"r_tonemapLockAutoExposureAdjust",
		"r_tonemapMaxExposure",
		"r_tonemapMaxExposureAdjust",
		"r_tonemapMidEv",
		"r_tonemapMidExposureAdjust",
		"r_tonemapMinExposureAdjust",
		"r_tonemapShoulder",
		"r_tonemapToe",
		"r_tonemapUseCS",
		"r_tonemapUseTweaks",
		"r_tonemapWhite",
		"r_uav_overlap",
		"r_ui3d_debug_display",
		"r_ui3d_h",
		"r_ui3d_use_debug_values",
		"r_ui3d_w",
		"r_ui3d_x",
		"r_ui3d_y",
		"r_uiBlurDstMode",
		"r_umbra",
		"r_umbraAccurateOcclusionThreshold",
		"r_umbraExclusive",
		"r_umbraQueryParts",
		"r_umbraUseDpvsCullDist",
		"r_unlitSurfaceHDRScalar",
		"r_useComputeSkinning",
		"r_useLayeredMaterials",
		"r_useLightGridDefaultFXLightingLookup",
		"r_useLightGridDefaultModelLightingLookup",
		"r_useShadowGeomOpt",
		"r_useXAnimIK",
		"r_vc_makelog",
		"r_vc_showlog",
		"r_veil",
		"r_veilAntialiasing",
		"r_veilBackgroundStrength",
		"r_veilFalloffScale1",
		"r_veilFalloffScale2",
		"r_veilFalloffWeight1",
		"r_veilFalloffWeight2",
		"r_veilFilter",
		"r_veilPreset",
		"r_veilRadius",
		"r_veilStrength",
		"r_veilUseTweaks",
		"r_velocityPrepass",
		"r_videoMemoryScale",
		"r_viewModelLightAmbient",
		"r_viewModelPrimaryLightTweakDiffuseStrength",
		"r_viewModelPrimaryLightTweakSpecularStrength",
		"r_viewModelPrimaryLightUseTweaks",
		"r_volumeLightScatter",
		"r_volumeLightScatterAngularAtten",
		"r_volumeLightScatterBackgroundDistance",
		"r_volumeLightScatterColor",
		"r_volumeLightScatterDepthAttenFar",
		"r_volumeLightScatterDepthAttenNear",
		"r_volumeLightScatterEv",
		"r_volumeLightScatterLinearAtten",
		"r_volumeLightScatterQuadraticAtten",
		"r_volumeLightScatterUseTweaks",
		"r_vsync",
		"r_warningRepeatDelay",
		"r_zfar",
		"r_znear",
		"ragdoll_baselerp_time",
		"ragdoll_bullet_force",
		"ragdoll_bullet_upbias",
		"ragdoll_dump_anims",
		"ragdoll_enable",
		"ragdoll_explode_force",
		"ragdoll_explode_upbias",
		"ragdoll_exploding_bullet_force",
		"ragdoll_exploding_bullet_upbias",
		"ragdoll_idle_min_velsq",
		"ragdoll_jitter_scale",
		"ragdoll_jointlerp_time",
		"ragdoll_max_life",
		"ragdoll_max_simulating",
		"ragdoll_max_stretch_pct",
		"ragdoll_resolve_penetration_bias",
		"ragdoll_rotvel_scale",
		"ragdoll_self_collision_scale",
		"ragdoll_stretch_iters",
		"rankedPlayEndMatchKeepLobby",
		"safeArea_adjusted_horizontal",
		"safeArea_adjusted_vertical",
		"safeArea_horizontal",
		"safeArea_vertical",
		"screenshots_active",
		"sensitivity",
		"session_immediateDeleteTinySessions",
		"session_modify_retry_on_failure",
		"session_nonblocking",
		"showPlaylistTotalPlayers",
		"sm_cacheSpotShadows",
		"sm_cacheSunShadow",
		"sm_cameraOffset",
		"sm_dynlightAllSModels",
		"sm_enable",
		"sm_fastSunShadow",
		"sm_lightScore_eyeProjectDist",
		"sm_lightScore_spotProjectFrac",
		"sm_maxLightsWithShadows",
		"sm_minSpotLightScore",
		"sm_polygonOffsetBias",
		"sm_polygonOffsetClamp",
		"sm_polygonOffsetPreset",
		"sm_polygonOffsetScale",
		"sm_qualitySpotShadow",
		"sm_shadowUseTweaks",
		"sm_spotDistCull",
		"sm_spotEnable",
		"sm_spotFilterRadius",
		"sm_spotLightScoreModelScale",
		"sm_spotLightScoreRadiusPower",
		"sm_spotLimit",
		"sm_spotShadowFadeTime",
		"sm_strictCull",
		"sm_sunEnable",
		"sm_sunFilterRadius",
		"sm_sunSampleSizeNear",
		"sm_sunShadowBoundsMax",
		"sm_sunShadowBoundsMin",
		"sm_sunShadowBoundsOverride",
		"sm_sunShadowCenter",
		"sm_sunShadowCenterMode",
		"sm_sunShadowScale",
		"sm_sunShadowScaleLocked",
		"sm_tileResolution",
		"sm_usedSunCascadeCount",
		"snd_allowHeadphoneHRTF",
		"snd_announcerVoicePrefix",
		"snd_cinematicVolumeScale",
		"snd_detectedSpeakerConfig",
		"snd_dopplerAuditionEnable",
		"snd_dopplerBaseSpeedOfSound",
		"snd_dopplerEnable",
		"snd_dopplerPitchMax",
		"snd_dopplerPitchMin",
		"snd_dopplerPlayerVelocityScale",
		"snd_dopplerSmoothing",
		"snd_draw3D",
		"snd_enable2D",
		"snd_enable3D",
		"snd_enableEq",
		"snd_enableReverb",
		"snd_enableStream",
		"snd_envFollowerBuffScale",
		"snd_errorOnMissing",
		"snd_hitsoundDisabled",
		"snd_inheritSecondaryPitchVol",
		"snd_levelFadeTime",
		"snd_loadFadeTime",
		"snd_loopFadeTime",
		"snd_musicDisabledForCustomSoundtrack",
		"snd_occlusionDelay",
		"snd_occlusionLerpTime",
		"snd_peakLimiterCompression",
		"snd_peakLimiterDecay",
		"snd_peakLimiterSustainFrames",
		"snd_premixVolume",
		"snd_slaveFadeTime",
		"snd_speakerConfig",
		"snd_touchStreamFilesOnLoad",
		"snd_useOldPanning",
		"snd_virtualMinDur",
		"snd_virtualMinPri",
		"snd_virtualMinTimeLeftToRevive",
		"snd_virtualReviveVoices",
		"snd_virtualWaitToReviveTime",
		"snd_volume",
		"speech_active",
		"splitscreen",
		"stringtable_debug",
		"sv_running",
		"svwp",
		"syncTimeTimeout",
		"sys_configSum",
		"sys_configureGHz",
		"sys_cpuGHz",
		"sys_cpuName",
		"sys_gpu",
		"sys_lockThreads",
		"sys_smp_allowed",
		"sys_SSE",
		"sys_sysMB",
		"systemlink",
		"systemlink_host",
		"theater_active",
		"tokensEnabled",
		"triggerDLCEnumerationOnSocialConfigLoad",
		"ui_autodetectGamepad",
		"ui_autodetectGamepadDone",
		"ui_blurAmount",
		"ui_blurDarkenAmount",
		"ui_blurTime",
		"ui_borderLowLightScale",
		"ui_buildLocation",
		"ui_buildSize",
		"ui_cinematicsTimestamp",
		"ui_contextualMenuLocation",
		"ui_disableInGameStore",
		"ui_disableTokenRedemption",
		"ui_gametype",
		"ui_inGameStoreOpen",
		"ui_mapname",
		"ui_mousePitch",
		"ui_multiplayer",
		"ui_selectedFeederMap",
		"ui_showList",
		"ui_showMenuOnly",
		"ui_sliderSteps",
		"ui_textScrollFadeTime",
		"ui_textScrollPauseEnd",
		"ui_textScrollPauseStart",
		"ui_textScrollSpeed",
		"uiscript_debug",
		"uno_current_tos_version",
		"useCPMarkerForCPOwnership",
		"useonlinestats",
		"userFileFetchTimeout",
		"userGroup_active",
		"userGroup_cool_off_time",
		"userGroup_coop_delay",
		"userGroup_max_retry_time",
		"userGroup_refresh_time_secs",
		"userGroup_retry_step",
		"userGroup_RetryTime",
		"useStatsGroups",
		"using_mlg",
		"version",
		"vid_height",
		"vid_width",
		"vid_xpos",
		"vid_ypos",
		"virtualLobbyActive",
		"virtualLobbyAllocated",
		"wideScreen",
		"win_printMessages",
		"xblive_hostingprivateparty",
		"xblive_loggedin",
		"xblive_privatematch",
		"xblive_privatematch_solo"
	};

	game::dvar_t* register_int(const std::string& name, int value, int min, int max, 
		game::DvarFlags flags, bool add_to_list)
	{
		const auto hash = game::generateHashValue(name.data());

		if (add_to_list)
		{
			dvar_list.push_back(name);
		}

		return game::Dvar_RegisterInt(hash, "", value, min, max, flags);
	}

	game::dvar_t* register_bool(const std::string& name, bool value, 
		game::DvarFlags flags, bool add_to_list)
	{
		const auto hash = game::generateHashValue(name.data());

		if (add_to_list)
		{
			dvar_list.push_back(name);
		}

		return game::Dvar_RegisterBool(hash, "", value, flags);
	}

	game::dvar_t* register_float(const std::string& name, float value, float min, 
		float max, game::DvarFlags flags, bool add_to_list)
	{
		const auto hash = game::generateHashValue(name.data());

		if (add_to_list)
		{
			dvar_list.push_back(name);
		}

		return game::Dvar_RegisterFloat(hash, "", value, min, max, flags);
	}

	game::dvar_t* register_vec4(const std::string& name, float x, float y, float z, 
		float w, float min, float max, game::DvarFlags flags, bool add_to_list)
	{
		const auto hash = game::generateHashValue(name.data());

		if (add_to_list)
		{
			dvar_list.push_back(name);
		}

		return game::Dvar_RegisterVec4(hash, "", x, y, z, w, min, max, flags);
	}
}
