Skip to content

Commit fbc2442

Browse files
committed
Tweak CG_Fov Behavior
1 parent 8e74844 commit fbc2442

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

components/game_mod/dvar.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,26 @@ void Dvar_SetFromStringByName(const char *dvarName, const char *string)
154154
if (dvarName && string)
155155
{
156156
if (!_stricmp(dvarName, "cg_fov") && !_stricmp(string, "65"))
157+
{
158+
if (cg_fov == NULL || cg_fov_default == NULL)
159+
return;
160+
161+
#if _DEBUG
162+
Com_Printf(0, "CG_FOV_DEFAULT: %p\n", cg_fov_default);
163+
Com_Printf(0, "CG_FOV_DEFAULT: %f\n", cg_fov_default->current.value);
164+
#endif
165+
166+
//
167+
// Note: If we run Dvar_SetFloat *every* time the game crashes
168+
//
169+
if (cg_fov->current.value != cg_fov_default->current.value)
170+
{
171+
Dvar_SetFloat(cg_fov, cg_fov_default->current.value);
172+
return;
173+
}
174+
157175
return;
176+
}
158177

159178
if (!_stricmp(dvarName, "cg_default_fov") && !_stricmp(string, "65"))
160179
return;

components/game_mod/dvar.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ static Dvar_RegisterString_t* Dvar_RegisterString = (Dvar_RegisterString_t*)0x00
222222
typedef dvar_s *__cdecl Dvar_RegisterInt_t(const char *dvarName, int value, int min, int max, unsigned __int16 flags, const char *description);
223223
static Dvar_RegisterInt_t* Dvar_RegisterInt = (Dvar_RegisterInt_t*)0x00651910;
224224

225+
typedef dvar_s *(__cdecl* Dvar_RegisterFloat_t)(const char *dvarName, float value, float min, float max, unsigned __int16 flags, const char *description);
226+
static Dvar_RegisterFloat_t Dvar_RegisterFloat = (Dvar_RegisterFloat_t)0x00679020;
227+
225228
typedef dvar_s *(__cdecl* Dvar_RegisterBool_t)(const char *dvarName, bool value, unsigned __int16 flags, const char *description);
226229
static Dvar_RegisterBool_t Dvar_RegisterBool = (Dvar_RegisterBool_t)0x0045BB20;
227230

0 commit comments

Comments
 (0)