diff options
author | Andrey Nazarov <skuller@skuller.net> | 2012-12-24 14:36:22 +0400 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2012-12-26 12:01:13 +0400 |
commit | 684f1da306df799561c132fe18bed5315aa211b9 (patch) | |
tree | 007c616b0df5d62bbff955ddc9003ba13b0526c7 | |
parent | 941dbcd016b3daeb49d3b88d6625e6257118f5e2 (diff) |
Fix default value of ‘uf’ variable.
Make it empty by default to prevent it from uselessy cluttering
userinfo. Change semantics of the empty value.
Add UF_PLAYERFOV bit to make it possible to force player FOV, an
opposite to UF_LOCALFOV that forces local FOV. If neither of these bits
are set (the default), player FOV >= 90 degrees is ignored. This gives
zooms a chance to be properly displayed.
Also fix dynamic ‘fov’ variable updates for freefloat MVD observers.
-rw-r--r-- | inc/shared/shared.h | 1 | ||||
-rw-r--r-- | src/client/entities.c | 40 | ||||
-rw-r--r-- | src/client/main.c | 2 | ||||
-rw-r--r-- | src/server/mvd/game.c | 29 |
4 files changed, 43 insertions, 29 deletions
diff --git a/inc/shared/shared.h b/inc/shared/shared.h index 761bfb8..ba3b87d 100644 --- a/inc/shared/shared.h +++ b/inc/shared/shared.h @@ -1389,6 +1389,7 @@ ROGUE - VERSIONS #define UF_MUTE_PLAYERS 8 #define UF_MUTE_OBSERVERS 16 #define UF_MUTE_MISC 32 +#define UF_PLAYERFOV 64 /* ========================================================== diff --git a/src/client/entities.c b/src/client/entities.c index 7356f72..f5cdbf4 100644 --- a/src/client/entities.c +++ b/src/client/entities.c @@ -1105,6 +1105,30 @@ static inline float LerpShort(int a2, int a1, float frac) } #endif +static inline float lerp_client_fov(float ofov, float nfov, float lerp) +{ + if (cls.demo.playback) { + float fov = info_fov->value; + + if (fov < 1) + fov = 90; + else if (fov > 160) + fov = 160; + + if (info_uf->integer & UF_LOCALFOV) + return fov; + + if (!(info_uf->integer & UF_PLAYERFOV)) { + if (ofov >= 90) + ofov = fov; + if (nfov >= 90) + nfov = fov; + } + } + + return ofov + lerp * (nfov - ofov); +} + /* =============== CL_CalcViewValues @@ -1118,7 +1142,7 @@ void CL_CalcViewValues(void) { player_state_t *ps, *ops; vec3_t viewoffset; - float fov, lerp; + float lerp; // find states to interpolate between ps = &cl.frame.ps; @@ -1177,18 +1201,8 @@ void CL_CalcViewValues(void) cl.delta_angles[2] = LerpShort(ops->pmove.delta_angles[2], ps->pmove.delta_angles[2], lerp); #endif - if (cls.demo.playback && (info_uf->integer & UF_LOCALFOV)) { - fov = info_fov->value; - if (fov < 1) { - fov = 90; - } else if (fov > 160) { - fov = 160; - } - cl.fov_x = fov; - } else { - // interpolate field of view - cl.fov_x = ops->fov + lerp * (ps->fov - ops->fov); - } + // interpolate field of view + cl.fov_x = lerp_client_fov(ops->fov, ps->fov, lerp); // don't interpolate blend color Vector4Copy(ps->blend, cl.refdef.blend); diff --git a/src/client/main.c b/src/client/main.c index dbcf870..d3f2f69 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -2689,7 +2689,7 @@ static void CL_InitLocal(void) info_fov = Cvar_Get("fov", "90", CVAR_USERINFO | CVAR_ARCHIVE); info_gender = Cvar_Get("gender", "male", CVAR_USERINFO | CVAR_ARCHIVE); info_gender->modified = qfalse; // clear this so we know when user sets it manually - info_uf = Cvar_Get("uf", va("%d", UF_LOCALFOV), CVAR_USERINFO); + info_uf = Cvar_Get("uf", "", CVAR_USERINFO); // diff --git a/src/server/mvd/game.c b/src/server/mvd/game.c index 569617d..e2eb54c 100644 --- a/src/server/mvd/game.c +++ b/src/server/mvd/game.c @@ -232,6 +232,7 @@ static void MVD_LayoutChannels(mvd_client_t *client) #define MENU_ITEMS 10 #define YES "\xD9\xE5\xF3" #define NO "\xCE\xEF" +#define DEFAULT "\xC4\xE5\xE6\xE1\xF5\xEC\xF4" static int clamp_menu_cursor(mvd_client_t *client) { @@ -256,7 +257,7 @@ static void MVD_LayoutMenu(mvd_client_t *client) "yv 96 string \"%cIgnore spectator chat: %s\"" "yv 104 string \"%cIgnore connect msgs: %s\"" "yv 112 string \"%cIgnore player chat: %s\"" - "yv 120 string \"%cIgnore player FOV: %s\"" + "yv 120 string \"%cIgnore player FOV: %7s\"" "yv 128 string \" (use 'set uf %d u' in cfg)\"" "yv 144 string2 \"%cExit menu\"" "%s xv %d yv 172 string2 " VERSION; @@ -274,7 +275,8 @@ static void MVD_LayoutMenu(mvd_client_t *client) cur[5], (client->uf & UF_MUTE_OBSERVERS) ? YES : NO, cur[6], (client->uf & UF_MUTE_MISC) ? YES : NO, cur[7], (client->uf & UF_MUTE_PLAYERS) ? YES : NO, - cur[8], (client->uf & UF_LOCALFOV) ? YES : NO, + cur[8], (client->uf & UF_LOCALFOV) ? YES : + (client->uf & UF_PLAYERFOV) ? NO " " : DEFAULT, client->uf, cur[9], client->mvd->state == MVD_WAITING ? "xv 0 yv 160 cstring [BUFFERING]" : "", @@ -642,7 +644,8 @@ static void MVD_UpdateClient(mvd_client_t *client) copy: // copy entire player state client->ps = target->ps; - if (client->uf & UF_LOCALFOV) { + if ((client->uf & UF_LOCALFOV) || (!(client->uf & UF_PLAYERFOV) + && client->ps.fov >= 90)) { client->ps.fov = client->fov; } client->ps.pmove.pm_flags |= PMF_NO_PREDICTION; @@ -1089,7 +1092,11 @@ static void MVD_Invuse_f(mvd_client_t *client) client->uf ^= UF_MUTE_PLAYERS; break; case 8: - client->uf ^= UF_LOCALFOV; + client->uf &= ~(UF_LOCALFOV | UF_PLAYERFOV); + if (uf & UF_LOCALFOV) + client->uf |= UF_PLAYERFOV; + else if (!(uf & UF_PLAYERFOV)) + client->uf |= UF_LOCALFOV; break; case 9: MVD_SetDefaultLayout(client); @@ -1670,27 +1677,19 @@ static void MVD_GameClientBegin(edict_t *ent) static void MVD_GameClientUserinfoChanged(edict_t *ent, char *userinfo) { mvd_client_t *client = EDICT_MVDCL(ent); - char *s; float fov; - s = Info_ValueForKey(userinfo, "uf"); - if (*s) { - client->uf = atoi(s); - } else { - client->uf = UF_LOCALFOV; - } + client->uf = atoi(Info_ValueForKey(userinfo, "uf")); - s = Info_ValueForKey(userinfo, "fov"); - fov = atof(s); + fov = atof(Info_ValueForKey(userinfo, "fov")); if (fov < 1) { fov = 90; } else if (fov > 160) { fov = 160; } client->fov = fov; - if (client->uf & UF_LOCALFOV) { + if (!client->target) client->ps.fov = fov; - } } void MVD_GameClientNameChanged(edict_t *ent, const char *name) |