From 24e4d9322675de0722d50c5bd0c5ca731dd73d4b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 25 Dec 2011 15:31:46 +0000 Subject: [PATCH] Rewrite EDuke32's -d option parsing code. Writing into argv[i] isn't very wise. Also resize firstdemofile[] to BMAX_PATH bytes. git-svn-id: https://svn.eduke32.com/eduke32@2199 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/demo.c | 2 +- polymer/eduke32/source/demo.h | 2 +- polymer/eduke32/source/game.c | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/source/demo.c b/polymer/eduke32/source/demo.c index 6ebc08ee9..7e6a4c6ab 100644 --- a/polymer/eduke32/source/demo.c +++ b/polymer/eduke32/source/demo.c @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "menus.h" #include "savegame.h" -char firstdemofile[80]; +char firstdemofile[BMAX_PATH]; FILE *g_demo_filePtr = (FILE *)NULL; int32_t g_demo_cnt; diff --git a/polymer/eduke32/source/demo.h b/polymer/eduke32/source/demo.h index 0763cb16e..006d24c04 100644 --- a/polymer/eduke32/source/demo.h +++ b/polymer/eduke32/source/demo.h @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __demo_h__ extern FILE *g_demo_filePtr; -extern char firstdemofile[80]; +extern char firstdemofile[BMAX_PATH]; extern int32_t demoplay_diffs; extern int32_t demoplay_showsync; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 96a25f0d0..a2e4c42f8 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8770,12 +8770,17 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) ud.m_coop--; break; case 'd': + { + char *dot; + c++; - if (strchr(c,'.') == 0) - Bstrcat(c,".edm"); - initprintf("Play demo %s.\n",c); Bstrcpy(firstdemofile,c); + dot = Bstrchr(firstdemofile,'.'); + if (!dot && Bstrlen(firstdemofile)+4 < sizeof(firstdemofile)) + Bstrcat(firstdemofile,".edm"); + initprintf("Play demo %s.\n",firstdemofile); break; + } case 'g': c++; if (!*c) break;