Rewrite EDuke32's -d<demofile> 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
This commit is contained in:
helixhorned 2011-12-25 15:31:46 +00:00
parent be84374899
commit 24e4d93226
3 changed files with 10 additions and 5 deletions

View file

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "menus.h" #include "menus.h"
#include "savegame.h" #include "savegame.h"
char firstdemofile[80]; char firstdemofile[BMAX_PATH];
FILE *g_demo_filePtr = (FILE *)NULL; FILE *g_demo_filePtr = (FILE *)NULL;
int32_t g_demo_cnt; int32_t g_demo_cnt;

View file

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define __demo_h__ #define __demo_h__
extern FILE *g_demo_filePtr; extern FILE *g_demo_filePtr;
extern char firstdemofile[80]; extern char firstdemofile[BMAX_PATH];
extern int32_t demoplay_diffs; extern int32_t demoplay_diffs;
extern int32_t demoplay_showsync; extern int32_t demoplay_showsync;

View file

@ -8770,12 +8770,17 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
ud.m_coop--; ud.m_coop--;
break; break;
case 'd': case 'd':
{
char *dot;
c++; c++;
if (strchr(c,'.') == 0)
Bstrcat(c,".edm");
initprintf("Play demo %s.\n",c);
Bstrcpy(firstdemofile,c); Bstrcpy(firstdemofile,c);
dot = Bstrchr(firstdemofile,'.');
if (!dot && Bstrlen(firstdemofile)+4 < sizeof(firstdemofile))
Bstrcat(firstdemofile,".edm");
initprintf("Play demo %s.\n",firstdemofile);
break; break;
}
case 'g': case 'g':
c++; c++;
if (!*c) break; if (!*c) break;