[openjk] 21/32: MP UI: Only update ui_screenshotType cvar when changed

Simon McVittie smcv at debian.org
Sun Mar 12 18:03:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit e2c254b28cd52a0ab19f7171f07d1c6542a883fb
Author: Ensiform <ensiform at gmail.com>
Date:   Sat Mar 11 16:43:23 2017 -0600

    MP UI: Only update ui_screenshotType cvar when changed
    
    This fixes an issue where it would potentially repeatedly call the cvar set and update functions.
---
 codemp/ui/ui_cvar.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/codemp/ui/ui_cvar.c b/codemp/ui/ui_cvar.c
index 3108594..3b9cf3b 100644
--- a/codemp/ui/ui_cvar.c
+++ b/codemp/ui/ui_cvar.c
@@ -54,6 +54,7 @@ static const char *UI_GetScreenshotFormatString( int format )
 
 static void UI_UpdateScreenshot( void )
 {
+	qboolean changed = qfalse;
 	// check some things
 	if ( ui_screenshotType.string[0] && isalpha( ui_screenshotType.string[0] ) )
 	{
@@ -62,6 +63,7 @@ static void UI_UpdateScreenshot( void )
 		{
 			trap->Print( "UI Screenshot Format Type '%s' unrecognised, defaulting to JPEG\n", ui_screenshotType.string );
 			uiInfo.uiDC.screenshotFormat = SSF_JPEG;
+			changed = qtrue;
 		}
 		else
 			uiInfo.uiDC.screenshotFormat = ssf;
@@ -70,12 +72,17 @@ static void UI_UpdateScreenshot( void )
 	{
 		trap->Print( "ui_screenshotType %i is out of range, defaulting to 0 (JPEG)\n", ui_screenshotType.integer );
 		uiInfo.uiDC.screenshotFormat = SSF_JPEG;
+		changed = qtrue;
 	}
-	else
+	else {
 		uiInfo.uiDC.screenshotFormat = atoi( ui_screenshotType.string );
+		changed = qtrue;
+	}
 
-	trap->Cvar_Set( "ui_screenshotType", UI_GetScreenshotFormatString( uiInfo.uiDC.screenshotFormat ) );
-	trap->Cvar_Update( &ui_screenshotType );
+	if ( changed ) {
+		trap->Cvar_Set( "ui_screenshotType", UI_GetScreenshotFormatString( uiInfo.uiDC.screenshotFormat ) );
+		trap->Cvar_Update( &ui_screenshotType );
+	}
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list