diff options
Diffstat (limited to 'src/fov.c')
| -rw-r--r-- | src/fov.c | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -18,6 +18,7 @@ // TODO(linux): theoretically, probably ifdef out the cvar-replacement stuff; we // expect any game that's been ported to linux to already have fov_desired +#include "chunklets/x86.h" #include "con_.h" #include "engineapi.h" #include "errmsg.h" @@ -31,7 +32,6 @@ #include "mem.h" #include "sst.h" #include "vcall.h" -#include "x86.h" #include "x86util.h" FEATURE("extended FOV range") @@ -42,7 +42,7 @@ REQUEST(ent) DEF_CVAR_MINMAX_UNREG(fov_desired, "Set the base field of view (SST reimplementation)", 75, 75, 120, - CON_HIDDEN | CON_ARCHIVE) + CON_INIT_HIDDEN | CON_ARCHIVE) static struct con_var *real_fov_desired; // engine's if it has it, or ours typedef void (*VCALLCONV SetDefaultFOV_func)(void *, int); @@ -88,8 +88,10 @@ INIT { if_cold (!cmd_fov) return FEAT_INCOMPAT; // shouldn't happen, but who knows! if (real_fov_desired = con_findvar("fov_desired")) { // latest steampipe already goes up to 120 fov - if (real_fov_desired->parent->maxval == 120) return FEAT_SKIP; - real_fov_desired->parent->maxval = 120; + struct con_var *p = con_getvarcommon(real_fov_desired)->parent; + struct con_var_common *c = con_getvarcommon(p); + if (c->maxval == 120) return FEAT_SKIP; + c->maxval = 120; } else { if (!has_ent) return FEAT_INCOMPAT; @@ -109,26 +111,27 @@ INIT { // we might not be using our cvar but simpler to do this unconditionally fov_desired->cb = &fovcb; - fov_desired->parent->base.flags &= ~CON_HIDDEN; + con_unhide(&fov_desired->base); // hide the original fov command since we've effectively broken it anyway :) - cmd_fov->base.flags |= CON_DEVONLY; + // NOTE: assumes NE. fine for now because we're GAMESPECIFIC. + cmd_fov->base.flags |= _CON_NE_DEVONLY; return FEAT_OK; } END { if_hot (!sst_userunloaded) return; if (real_fov_desired && real_fov_desired != fov_desired) { - real_fov_desired->parent->maxval = 90; - if (con_getvarf(real_fov_desired) > 90) { - con_setvarf(real_fov_desired, 90); // blegh. - } + struct con_var *p = con_getvarcommon(real_fov_desired)->parent; + struct con_var_common *c = con_getvarcommon(p); + c->maxval = 90; + if (c->fval > 90) con_setvarf(real_fov_desired, 90); // blegh. } else { void *player = ent_get(1); // also singleplayer only if (player) orig_SetDefaultFOV(player, 75); } unhook_inline((void *)orig_SetDefaultFOV); - cmd_fov->base.flags &= ~CON_DEVONLY; + cmd_fov->base.flags &= ~_CON_NE_DEVONLY; } // vi: sw=4 ts=4 noet tw=80 cc=80 |
