fixed -demo and -autodemo switches to work with DEMO_DIR

This commit is contained in:
zicodxx 2007-02-06 15:03:10 +00:00
parent b15b093caa
commit c7db8ea672
4 changed files with 17 additions and 11 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20070206
--------
main/inferno.c, main/menu.c, main/newdemo.c: fixed -demo and -autodemo switches to work with DEMO_DIR
20070202
--------
arch/ogl/ogl.c: let ogl_ubitblt not return alpha channel to ogl_ubitblt_i

View file

@ -658,6 +658,7 @@ int main(int argc,char **argv)
Game_mode = GM_GAME_OVER;
if (Auto_demo) {
printf("DEMO: %s\n",start_demo);
newdemo_start_playback((start_demo[0] ? start_demo : "descent.dem"));
if (Newdemo_state == ND_STATE_PLAYBACK )
Function_mode = FMODE_GAME;

View file

@ -336,12 +336,8 @@ void do_option ( int select)
case MENU_DEMO_PLAY:
{
char demo_file[16];
char demo_full[16 + sizeof(DEMO_DIR)];
if (newmenu_get_filename( TXT_SELECT_DEMO, DEMO_DIR "*.dem", demo_file, 1 )) {
strcpy(demo_full,DEMO_DIR);
strcat(demo_full,demo_file);
newdemo_start_playback(demo_full);
}
if (newmenu_get_filename( TXT_SELECT_DEMO, DEMO_DIR "*.dem", demo_file, 1 ))
newdemo_start_playback(demo_file);
}
break;
case MENU_LOAD_GAME:

View file

@ -2874,16 +2874,21 @@ void newdemo_start_playback(char * filename)
#endif
int rnd_demo = 0;
d_glob_t glob_ret;
char * fullname;
if (filename == NULL) {
rnd_demo = 1;
if (!d_glob("*.dem", &glob_ret) && glob_ret.gl_pathc) {
infile = fopen( glob_ret.gl_pathv[d_rand() % glob_ret.gl_pathc],
if (!d_glob(DEMO_DIR "*.dem", &glob_ret) && glob_ret.gl_pathc) {
infile = fopen(glob_ret.gl_pathv[d_rand() % glob_ret.gl_pathc],
"rb" );
d_globfree(&glob_ret);
}
} else
infile = fopen( filename, "rb" );
} else {
strcpy(fullname,DEMO_DIR);
strcat(fullname,filename);
printf("FULLNAME: %s\n",fullname);
infile = fopen( fullname, "rb" );
}
if (infile == NULL) {
mprintf( (0, "Error reading '%s'\n", filename ));