If newdemo_start_playback fails if random file is given set -autodemo to 0 to prevent endless loop

This commit is contained in:
zicodxx 2010-07-16 13:03:12 +00:00
parent ac840f306b
commit 06cf80ab18
2 changed files with 8 additions and 0 deletions

View file

@ -4,6 +4,7 @@ D1X-Rebirth Changelog
--------
main/gamecntl.c: Fixing showing options menu in demos - was still called (or rather not) by obsolete variable
main/newmenu.c, main/newmenu.h, main/automap.c, main/game.c, main/kconfig.c, arch/sdl/event.c, arch/sdl/joy.c, arch/sdl/init.c, arch/sdl/key.c, arch/sdl/mouse.c, arch/include/mouse.h: Only use one single call of timer_get_fixed_seconds() for whole SDL event loop; Abstracted grabbing mouse and mouse cursor toogle to mouse functions instead of calling SDL functions inside of non-arch code; Automatically hide mouse cursor if it's not used for more than 3 seconds; Reworked placement of mouse grabbing toggle; Do not read any mouse input if -nomouse is given
main/newdemo.c: If newdemo_start_playback fails if random file is given set -autodemo to 0 to prevent endless loop
20100715

View file

@ -3319,6 +3319,7 @@ void newdemo_start_playback(char * filename)
NumFiles = newdemo_count_demos();
if ( NumFiles == 0 ) {
GameArg.SysAutoDemo = 0;
return; // No files found!
}
RandFileNum = d_rand() % NumFiles;
@ -3339,11 +3340,17 @@ void newdemo_start_playback(char * filename)
PHYSFS_freeList(find);
if (NumFiles > RandFileNum)
{
GameArg.SysAutoDemo = 0;
return;
}
// if in random mode, PhysFS may look for all possible files, so check if filename actually points to be a demo file...
if (strnicmp(".dem",&filename2[strlen(filename2)-4],4))
{
GameArg.SysAutoDemo = 0;
return;
}
}
infile = PHYSFSX_openReadBuffered(filename2);