From 0c34a5081c38f0a2fa99b10cad1625e04808cea4 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 3 Nov 2019 13:16:05 +0500 Subject: [PATCH] engine: client: make the code that generates screenshots and demos names simpler. --- engine/client/cl_cmds.c | 24 ++---------------------- engine/client/cl_demo.c | 12 +----------- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/engine/client/cl_cmds.c b/engine/client/cl_cmds.c index d9a63434..5073ed33 100644 --- a/engine/client/cl_cmds.c +++ b/engine/client/cl_cmds.c @@ -147,23 +147,13 @@ CL_ScreenshotGetName */ qboolean CL_ScreenshotGetName( int lastnum, char *filename ) { - int a, b, c, d; - if( lastnum < 0 || lastnum > 9999 ) { Con_Printf( S_ERROR "unable to write screenshot\n" ); return false; } - a = lastnum / 1000; - lastnum -= a * 1000; - b = lastnum / 100; - lastnum -= b * 100; - c = lastnum / 10; - lastnum -= c * 10; - d = lastnum; - - Q_sprintf( filename, "scrshots/%s_shot%i%i%i%i.png", clgame.mapname, a, b, c, d ); + Q_sprintf( filename, "scrshots/%s_shot%0004d.png", clgame.mapname, lastnum ); return true; } @@ -175,8 +165,6 @@ CL_SnapshotGetName */ qboolean CL_SnapshotGetName( int lastnum, char *filename ) { - int a, b, c, d; - if( lastnum < 0 || lastnum > 9999 ) { Con_Printf( S_ERROR "unable to write snapshot\n" ); @@ -184,15 +172,7 @@ qboolean CL_SnapshotGetName( int lastnum, char *filename ) return false; } - a = lastnum / 1000; - lastnum -= a * 1000; - b = lastnum / 100; - lastnum -= b * 100; - c = lastnum / 10; - lastnum -= c * 10; - d = lastnum; - - Q_sprintf( filename, "../%s_%i%i%i%i.png", clgame.mapname, a, b, c, d ); + Q_sprintf( filename, "../%s_%0004d.png", clgame.mapname, lastnum ); return true; } diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index eb33081c..3977231b 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -1304,8 +1304,6 @@ CL_DemoGetName */ static void CL_DemoGetName( int lastnum, char *filename ) { - int a, b, c, d; - if( lastnum < 0 || lastnum > 9999 ) { // bound @@ -1313,15 +1311,7 @@ static void CL_DemoGetName( int lastnum, char *filename ) return; } - a = lastnum / 1000; - lastnum -= a * 1000; - b = lastnum / 100; - lastnum -= b * 100; - c = lastnum / 10; - lastnum -= c * 10; - d = lastnum; - - Q_sprintf( filename, "demo%i%i%i%i", a, b, c, d ); + Q_sprintf( filename, "demo%0004d", lastnum ); } /*