This is an automated email from the git hooks/post-receive script. smcv pushed a commit to annotated tag 1.42d in repository iortcw.
commit c60f99d9dae0fabf667a4ab8a8b79c51d306ac8c Author: MAN-AT-ARMS <[email protected]> Date: Wed Apr 15 18:45:31 2015 -0400 All: Add cg_fixedAspect cvar to maintain aspect in widescreen modes: Based on Knightmare's RTCW-SP --- MP/code/cgame/cg_local.h | 1 + MP/code/cgame/cg_main.c | 2 ++ MP/code/cgame/cg_view.c | 29 +++++++++++++++++++++++++++-- MP/code/cgame/cg_weapons.c | 2 +- SP/code/cgame/cg_local.h | 1 + SP/code/cgame/cg_main.c | 2 ++ SP/code/cgame/cg_view.c | 29 +++++++++++++++++++++++++++-- SP/code/cgame/cg_weapons.c | 2 +- 8 files changed, 62 insertions(+), 6 deletions(-) diff --git a/MP/code/cgame/cg_local.h b/MP/code/cgame/cg_local.h index d4fafef..61c74aa 100644 --- a/MP/code/cgame/cg_local.h +++ b/MP/code/cgame/cg_local.h @@ -1660,6 +1660,7 @@ extern vmCvar_t cg_autoswitch; extern vmCvar_t cg_ignore; extern vmCvar_t cg_simpleItems; extern vmCvar_t cg_fov; +extern vmCvar_t cg_fixedAspect; extern vmCvar_t cg_zoomFov; extern vmCvar_t cg_zoomDefaultBinoc; extern vmCvar_t cg_zoomDefaultSniper; diff --git a/MP/code/cgame/cg_main.c b/MP/code/cgame/cg_main.c index 6084681..6287dac 100644 --- a/MP/code/cgame/cg_main.c +++ b/MP/code/cgame/cg_main.c @@ -164,6 +164,7 @@ vmCvar_t cg_autoswitch; vmCvar_t cg_ignore; vmCvar_t cg_simpleItems; vmCvar_t cg_fov; +vmCvar_t cg_fixedAspect; vmCvar_t cg_zoomFov; vmCvar_t cg_zoomStepBinoc; vmCvar_t cg_zoomStepSniper; @@ -304,6 +305,7 @@ cvarTable_t cvarTable[] = { { &cg_zoomStepSnooper, "cg_zoomStepSnooper", "5", CVAR_ARCHIVE }, { &cg_zoomStepFG, "cg_zoomStepFG", "10", CVAR_ARCHIVE }, //----(SA) added { &cg_fov, "cg_fov", "90", CVAR_ARCHIVE }, + { &cg_fixedAspect, "cg_fixedAspect", "0", CVAR_ARCHIVE }, // Essentially the same as setting DF_FIXED_FOV for widescreen aspects { &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE }, { &cg_letterbox, "cg_letterbox", "0", CVAR_TEMP }, //----(SA) added { &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE }, diff --git a/MP/code/cgame/cg_view.c b/MP/code/cgame/cg_view.c index 81e7ea0..29a8c3c 100644 --- a/MP/code/cgame/cg_view.c +++ b/MP/code/cgame/cg_view.c @@ -805,6 +805,7 @@ Fixed fov at intermissions, otherwise account for fov variable and zooms. */ #define WAVE_AMPLITUDE 1 #define WAVE_FREQUENCY 0.4 +#define STANDARD_ASPECT_RATIO ( (float)640 / (float)480 ) static int CG_CalcFov( void ) { static float lastfov = 90; // for transitions back from zoomed in modes @@ -830,7 +831,7 @@ static int CG_CalcFov( void ) { fov_x = 90; } else { // user selectable - if ( cgs.dmflags & DF_FIXED_FOV ) { + if ( ( cgs.dmflags & DF_FIXED_FOV ) || cg_fixedAspect.value ) { // dmflag to prevent wide fov for all clients fov_x = 90; } else { @@ -893,6 +894,14 @@ static int CG_CalcFov( void ) { fov_x = 55; } + if ( cg_fixedAspect.value ) { + float aspectRatio = (float)cg.refdef.width / (float)cg.refdef.height; + + if ( aspectRatio > STANDARD_ASPECT_RATIO ) + fov_x = RAD2DEG( 2 * atan2( ( aspectRatio / STANDARD_ASPECT_RATIO ) * tan( DEG2RAD( fov_x ) * 0.5 ), 1 ) ); + fov_x = min( fov_x, 160 ); + } + x = cg.refdef.width / tan( fov_x / 360 * M_PI ); fov_y = atan2( cg.refdef.height, x ); fov_y = fov_y * 360 / M_PI; @@ -1124,6 +1133,14 @@ static int CG_CalcViewValues( void ) { VectorCopy( angles, cg.refdefViewAngles ); AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); + if ( cg_fixedAspect.value ) { + float aspectRatio = (float)cg.refdef.width / (float)cg.refdef.height; + + if ( aspectRatio > STANDARD_ASPECT_RATIO ) + fov = RAD2DEG( 2 * atan2( ( aspectRatio / STANDARD_ASPECT_RATIO ) * tan( DEG2RAD( fov ) * 0.5 ), 1 ) ); + fov = min( fov, 160 ); + } + x = cg.refdef.width / tan( fov / 360 * M_PI ); cg.refdef.fov_y = atan2( cg.refdef.height, x ); cg.refdef.fov_y = cg.refdef.fov_y * 360 / M_PI; @@ -1403,7 +1420,7 @@ void CG_DrawSkyBoxPortal( void ) { fov_x = 90; } else { // user selectable - if ( cgs.dmflags & DF_FIXED_FOV ) { + if ( ( cgs.dmflags & DF_FIXED_FOV ) || cg_fixedAspect.value ) { // dmflag to prevent wide fov for all clients fov_x = 90; } else { @@ -1458,6 +1475,14 @@ void CG_DrawSkyBoxPortal( void ) { fov_x = 55; } + if ( cg_fixedAspect.value ) { + float aspectRatio = (float)cg.refdef.width / (float)cg.refdef.height; + + if ( aspectRatio > STANDARD_ASPECT_RATIO ) + fov_x = RAD2DEG( 2 * atan2( ( aspectRatio / STANDARD_ASPECT_RATIO ) * tan( DEG2RAD( fov_x ) * 0.5 ), 1 ) ); + fov_x = min( fov_x, 160 ); + } + cg.refdef.time = cg.time; x = cg.refdef.width / tan( fov_x / 360 * M_PI ); diff --git a/MP/code/cgame/cg_weapons.c b/MP/code/cgame/cg_weapons.c index c1b15bd..7901e68 100644 --- a/MP/code/cgame/cg_weapons.c +++ b/MP/code/cgame/cg_weapons.c @@ -2817,7 +2817,7 @@ void CG_AddViewWeapon( playerState_t *ps ) { } // drop gun lower at higher fov - if ( cg_fov.integer > 90 ) { + if ( cg_fov.integer > 90 && !cg_fixedAspect.value ) { fovOffset = -0.2 * ( cg_fov.integer - 90 ); } else { fovOffset = 0; diff --git a/SP/code/cgame/cg_local.h b/SP/code/cgame/cg_local.h index e6ba0c2..9c4b557 100644 --- a/SP/code/cgame/cg_local.h +++ b/SP/code/cgame/cg_local.h @@ -1678,6 +1678,7 @@ extern vmCvar_t cg_autoswitch; extern vmCvar_t cg_ignore; extern vmCvar_t cg_simpleItems; extern vmCvar_t cg_fov; +extern vmCvar_t cg_fixedAspect; extern vmCvar_t cg_zoomFov; extern vmCvar_t cg_zoomDefaultBinoc; extern vmCvar_t cg_zoomDefaultSniper; diff --git a/SP/code/cgame/cg_main.c b/SP/code/cgame/cg_main.c index 6788e90..103186f 100644 --- a/SP/code/cgame/cg_main.c +++ b/SP/code/cgame/cg_main.c @@ -164,6 +164,7 @@ vmCvar_t cg_autoswitch; vmCvar_t cg_ignore; vmCvar_t cg_simpleItems; vmCvar_t cg_fov; +vmCvar_t cg_fixedAspect; vmCvar_t cg_zoomFov; vmCvar_t cg_zoomStepBinoc; vmCvar_t cg_zoomStepSniper; @@ -295,6 +296,7 @@ cvarTable_t cvarTable[] = { { &cg_zoomStepSnooper, "cg_zoomStepSnooper", "5", CVAR_ARCHIVE }, { &cg_zoomStepFG, "cg_zoomStepFG", "10", CVAR_ARCHIVE }, //----(SA) added { &cg_fov, "cg_fov", "90", CVAR_ARCHIVE }, // NOTE: there is already a dmflag (DF_FIXED_FOV) to allow server control of this cheat + { &cg_fixedAspect, "cg_fixedAspect", "0", CVAR_ARCHIVE }, // Essentially the same as setting DF_FIXED_FOV for widescreen aspects { &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE }, { &cg_letterbox, "cg_letterbox", "0", CVAR_TEMP }, //----(SA) added { &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE }, diff --git a/SP/code/cgame/cg_view.c b/SP/code/cgame/cg_view.c index 135f916..0e141f3 100644 --- a/SP/code/cgame/cg_view.c +++ b/SP/code/cgame/cg_view.c @@ -775,6 +775,7 @@ Fixed fov at intermissions, otherwise account for fov variable and zooms. */ #define WAVE_AMPLITUDE 1 #define WAVE_FREQUENCY 0.4 +#define STANDARD_ASPECT_RATIO ( (float)640 / (float)480 ) static int CG_CalcFov( void ) { static float lastfov = 90; // for transitions back from zoomed in modes @@ -804,7 +805,7 @@ static int CG_CalcFov( void ) { fov_x = 90; } else { // user selectable - if ( cgs.dmflags & DF_FIXED_FOV ) { + if ( ( cgs.dmflags & DF_FIXED_FOV ) || cg_fixedAspect.value ) { // dmflag to prevent wide fov for all clients fov_x = 90; } else { @@ -867,6 +868,14 @@ static int CG_CalcFov( void ) { fov_x = 55; } + if ( cg_fixedAspect.value ) { + float aspectRatio = (float)cg.refdef.width / (float)cg.refdef.height; + + if ( aspectRatio > STANDARD_ASPECT_RATIO ) + fov_x = RAD2DEG( 2 * atan2( ( aspectRatio / STANDARD_ASPECT_RATIO ) * tan( DEG2RAD( fov_x ) * 0.5 ), 1 ) ); + fov_x = min( fov_x, 160 ); + } + x = cg.refdef.width / tan( fov_x / 360 * M_PI ); fov_y = atan2( cg.refdef.height, x ); fov_y = fov_y * 360 / M_PI; @@ -1050,6 +1059,14 @@ static int CG_CalcViewValues( void ) { VectorCopy( angles, cg.refdefViewAngles ); AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); + if ( cg_fixedAspect.value ) { + float aspectRatio = (float)cg.refdef.width / (float)cg.refdef.height; + + if ( aspectRatio > STANDARD_ASPECT_RATIO ) + fov = RAD2DEG( 2 * atan2( ( aspectRatio / STANDARD_ASPECT_RATIO ) * tan( DEG2RAD( fov ) * 0.5 ), 1 ) ); + fov = min( fov, 160 ); + } + x = cg.refdef.width / tan( fov / 360 * M_PI ); cg.refdef.fov_y = atan2( cg.refdef.height, x ); cg.refdef.fov_y = cg.refdef.fov_y * 360 / M_PI; @@ -1299,7 +1316,7 @@ void CG_DrawSkyBoxPortal( void ) { fov_x = 90; } else { // user selectable - if ( cgs.dmflags & DF_FIXED_FOV ) { + if ( ( cgs.dmflags & DF_FIXED_FOV ) || cg_fixedAspect.value ) { // dmflag to prevent wide fov for all clients fov_x = 90; } else { @@ -1354,6 +1371,14 @@ void CG_DrawSkyBoxPortal( void ) { fov_x = 55; } + if ( cg_fixedAspect.value ) { + float aspectRatio = (float)cg.refdef.width / (float)cg.refdef.height; + + if ( aspectRatio > STANDARD_ASPECT_RATIO ) + fov_x = RAD2DEG( 2 * atan2( ( aspectRatio / STANDARD_ASPECT_RATIO ) * tan( DEG2RAD( fov_x ) * 0.5 ), 1 ) ); + fov_x = min( fov_x, 160 ); + } + x = cg.refdef.width / tan( fov_x / 360 * M_PI ); fov_y = atan2( cg.refdef.height, x ); fov_y = fov_y * 360 / M_PI; diff --git a/SP/code/cgame/cg_weapons.c b/SP/code/cgame/cg_weapons.c index f64c488..e6ea655 100644 --- a/SP/code/cgame/cg_weapons.c +++ b/SP/code/cgame/cg_weapons.c @@ -2997,7 +2997,7 @@ void CG_AddViewWeapon( playerState_t *ps ) { // drop gun lower at higher fov - if ( cg_fov.integer > 90 ) { + if ( cg_fov.integer > 90 && !cg_fixedAspect.value ) { fovOffset = -0.2 * ( cg_fov.integer - 90 ); } else { fovOffset = 0; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

