In -d command line arg, allow specifying demo number in addition to file name.

git-svn-id: https://svn.eduke32.com/eduke32@3045 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-10-01 17:52:40 +00:00
parent 54167d4c7e
commit 13599f56b8
4 changed files with 22 additions and 14 deletions

View file

@ -90,7 +90,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine
}
else
{
Bsprintf(demofn, "edemo%03d.edm", g_whichDemo);
Bsprintf(demofn, DEMOFN_FMT, g_whichDemo);
demofnptr = demofn;
}
@ -175,10 +175,10 @@ void G_OpenDemoWrite(void)
do
{
if (demonum == 1000)
if (demonum == MAXDEMOS)
return;
if (G_ModDirSnprintf(demofn, sizeof(demofn), "edemo%03d.edm", demonum))
if (G_ModDirSnprintf(demofn, sizeof(demofn), DEMOFN_FMT, demonum))
{
initprintf("Couldn't start demo writing: INTERNAL ERROR: file name too long\n");
goto error_wopen_demo;
@ -238,6 +238,17 @@ void Demo_PlayFirst(int32_t prof, int32_t exitafter)
g_demo_profile = -prof; // prepare
}
void Demo_SetFirst(const char *demostr)
{
char *tailptr;
int32_t i = Bstrtol(demostr, &tailptr, 10);
if (tailptr==demostr+Bstrlen(demostr) && (unsigned)i < MAXDEMOS) // demo number passed
Bsprintf(g_firstDemoFile, DEMOFN_FMT, i);
else // demo file name passed
maybe_append_ext(g_firstDemoFile, sizeof(g_firstDemoFile), demostr, ".edm");
}
static uint8_t g_demo_seedbuf[RECSYNCBUFSIZ];
@ -520,7 +531,7 @@ RECHECK:
ud.recstat = 2;
g_whichDemo++;
if (g_whichDemo == 1000)
if (g_whichDemo == MAXDEMOS)
g_whichDemo = 1;
g_player[myconnectindex].ps->gm &= ~MODE_GAME;

View file

@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __demo_h__
#define __demo_h__
#define DEMOFN_FMT "edemo%03d.edm"
#define MAXDEMOS 1000
extern FILE *g_demo_filePtr;
extern char g_firstDemoFile[BMAX_PATH];
@ -49,6 +52,7 @@ void G_DemoRecord(void);
void G_OpenDemoWrite(void);
void Demo_PlayFirst(int32_t prof, int32_t exitafter);
void Demo_SetFirst(const char *demostr);
int32_t Demo_IsProfiling(void);

View file

@ -8075,7 +8075,7 @@ static void G_ShowParameterHelp(void)
#endif
"-connect [host]\tConnect to a multiplayer game\n"
"-c#\t\tUse MP mode #, 1 = Dukematch, 2 = Coop, 3 = Dukematch(no spawn)\n"
"-d[file.edm]\tPlay a demo\n"
"-d[file.edm or demonum]\tPlay a demo\n"
"-g[file.grp]\tLoad additional game data\n"
"-h[file.def]\tLoad an alternate definitions file\n"
"-j[dir]\t\tAdds a directory to EDuke32's search list\n"
@ -8957,7 +8957,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
Bsscanf(colon, "%u,%u", &framespertic, &numrepeats);
}
maybe_append_ext(g_firstDemoFile, sizeof(g_firstDemoFile), c, ".edm");
Demo_SetFirst(c);
if (framespertic < 0)
{

View file

@ -322,16 +322,9 @@ static int32_t osdcmd_demo(const osdfuncparm_t *parm)
return OSDCMD_SHOWHELP;
{
char *tailptr;
const char *demostr = parm->parms[0];
int32_t i = Bstrtol(demostr, &tailptr, 10);
int32_t prof = parm->numparms==2 ? Batoi(parm->parms[1]) : -1;
if (tailptr!=demostr && i>=0 && i<=999) // demo number passed
Bsprintf(g_firstDemoFile, "edemo%03d.edm", i);
else // demo file name passed
maybe_append_ext(g_firstDemoFile, sizeof(g_firstDemoFile), parm->parms[0], ".edm");
Demo_SetFirst(parm->parms[0]);
Demo_PlayFirst(clamp(prof, -1, 8)+1, 0);
}