Sound and scripts are opt-in, to speed up loading and closing

This commit is contained in:
Simon
2011-02-21 16:24:03 +00:00
parent 064579c9e4
commit 383eaff5b2

View File

@@ -169,7 +169,8 @@ int FPSB = 0;
int MSIGN =-1; int MSIGN =-1;
//int CGOL = 0; //int CGOL = 0;
//int GSPEED = 1;//causes my .exe to crash.. //int GSPEED = 1;//causes my .exe to crash..
int sound_enable; int sound_enable = 0;
int file_script = 0;
sign signs[MAXSIGNS]; sign signs[MAXSIGNS];
@@ -1214,16 +1215,7 @@ int main(int argc, char *argv[])
fmt.samples = 512; fmt.samples = 512;
fmt.callback = mixaudio; fmt.callback = mixaudio;
fmt.userdata = NULL; fmt.userdata = NULL;
/* Open the audio device and start playing sound! */
if ( SDL_OpenAudio(&fmt, NULL) < 0 )
{
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
}
else
{
sound_enable = 1;
SDL_PauseAudio(0);
}
#ifdef MT #ifdef MT
numCores = core_count(); numCores = core_count();
#endif #endif
@@ -1276,6 +1268,24 @@ int main(int argc, char *argv[])
//sdl_scale = 2; //Removed because some displays cannot handle the resolution //sdl_scale = 2; //Removed because some displays cannot handle the resolution
hud_enable = 0; hud_enable = 0;
} }
else if (!strncmp(argv[i], "sound", 5))
{
/* Open the audio device and start playing sound! */
if ( SDL_OpenAudio(&fmt, NULL) < 0 )
{
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
}
else
{
sound_enable = 1;
SDL_PauseAudio(0);
}
}
else if (!strncmp(argv[i], "scripts", 5))
{
file_script = 1;
}
} }
save_presets(0); save_presets(0);
@@ -2767,6 +2777,7 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
} }
else if(strcmp(console2, "file")==0 && console3) else if(strcmp(console2, "file")==0 && console3)
{ {
if(file_script){
FILE *f=fopen(console3, "r"); FILE *f=fopen(console3, "r");
if(f) if(f)
{ {
@@ -2844,8 +2855,16 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
fclose(f); fclose(f);
} }
else else
{
sprintf(console_error, "%s does not exist", console3); sprintf(console_error, "%s does not exist", console3);
} }
}
else
{
sprintf(console_error, "Scripts are not enabled");
}
}
else if(strcmp(console2, "sound")==0 && console3) else if(strcmp(console2, "sound")==0 && console3)
{ {
if (sound_enable) play_sound(console3); if (sound_enable) play_sound(console3);