struct stat filestat;
if (stat(filename, &filestat) == -1)
{
- return NO;
+ return false;
}
else
{
if(S_ISREG(filestat.st_mode))
- return YES;
+ return true;
else
- return NO;
+ return false;
}
}
fi = fopen(filename, "wa");
if (fi == NULL)
{
- return NO;
+ return false;
}
- return YES;
+ return true;
}
/* Makes sure a directory is created in either the SuperTux base directory or the SuperTux base directory.*/
snprintf(path, 1024, "%s/%s/", datadir.c_str(), relative_dir);
if(mkdir(path,0755) != 0)
{
- return NO;
+ return false;
}
else
{
- return YES;
+ return true;
}
}
else
{
- return YES;
+ return true;
}
}
menu_additem(&options_menu, MN_LABEL,"Options",0,0);
menu_additem(&options_menu, MN_HL,"",0,0);
menu_additem(&options_menu, MN_TOGGLE,"Fullscreen",use_fullscreen,0);
- if(audio_device == YES)
+ if(audio_device)
{
menu_additem(&options_menu, MN_TOGGLE,"Sound ",use_sound,0);
menu_additem(&options_menu, MN_TOGGLE,"Music ",use_music,0);
default:
if(slot != -1)
{
- if(save == YES)
+ if(save == true)
{
savegame(slot - 1);
}
else
{
- if(game_started == NO)
+ if(game_started == false)
{
gameloop("default",slot - 1,ST_GL_LOAD_GAME);
- show_menu = YES;
+ show_menu = true;
menu_set_current(&main_menu);
}
else
case 4:
if(use_music != options_menu.item[4].toggled)
{
- if(use_music == YES)
+ if(use_music == true)
{
if(playing_music())
{
halt_music();
}
- use_music = NO;
+ use_music = false;
}
else
{
- use_music = YES;
+ use_music = true;
if (!playing_music())
{
play_current_music();
{
SDL_FreeSurface(screen);
- if (use_fullscreen == YES)
+ if (use_fullscreen == true)
{
screen = SDL_SetVideoMode(640, 480, 0, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */
if (screen == NULL)
"640x480 mode.\n"
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
- use_fullscreen = NO;
+ use_fullscreen = false;
}
}
else
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if (use_fullscreen == YES)
+ if (use_fullscreen == true)
{
screen = SDL_SetVideoMode(640, 480, 0, SDL_FULLSCREEN | SDL_OPENGL) ; /* | SDL_HWSURFACE); */
if (screen == NULL)
"640x480 mode.\n"
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
- use_fullscreen = NO;
+ use_fullscreen = false;
}
}
else
/* Init Joystick: */
- use_joystick = YES;
+ use_joystick = true;
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
{
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
- use_joystick = NO;
+ use_joystick = false;
}
else
{
{
fprintf(stderr, "Warning: No joysticks are available.\n");
- use_joystick = NO;
+ use_joystick = false;
}
else
{
- js = SDL_JoystickOpen(0);
+ js = SDL_JoystickOpen(joystick_num);
if (js == NULL)
{
- fprintf(stderr, "Warning: Could not open joystick 1.\n"
+ fprintf(stderr, "Warning: Could not open joystick %d.\n"
"The Simple DirectMedia error that occured was:\n"
- "%s\n\n", SDL_GetError());
+ "%s\n\n", joystick_num, SDL_GetError());
- use_joystick = NO;
+ use_joystick = false;
}
else
{
fprintf(stderr,
"Warning: Joystick does not have enough axes!\n");
- use_joystick = NO;
+ use_joystick = false;
}
else
{
"Warning: "
"Joystick does not have enough buttons!\n");
- use_joystick = NO;
+ use_joystick = false;
}
}
}
/* Init SDL Audio silently even if --disable-sound : */
- if (audio_device == YES)
+ if (audio_device == true)
{
if (SDL_Init(SDL_INIT_AUDIO) < 0)
{
/* only print out message if sound or music
was not disabled at command-line
*/
- if (use_sound == YES || use_music == YES)
+ if (use_sound || use_music)
{
fprintf(stderr,
"\nWarning: I could not initialize audio!\n"
because in this case, use_sound & use_music' values are ignored
when there's no available audio device
*/
- use_sound = NO;
- use_music = NO;
- audio_device = NO;
+ use_sound = false;
+ use_music = false;
+ audio_device = false;
}
}
/* Open sound silently regarless the value of "use_sound": */
- if (audio_device == YES)
+ if (audio_device == true)
{
if (open_audio(44100, AUDIO_S16, 2, 2048) < 0)
{
/* only print out message if sound or music
was not disabled at command-line
*/
- if ((use_sound == YES) || (use_music == YES))
+ if ((use_sound == true) || (use_music == true))
{
fprintf(stderr,
"\nWarning: I could not set up audio for 44100 Hz "
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
}
- use_sound = NO;
- use_music = NO;
- audio_device = NO;
+ use_sound = false;
+ use_music = false;
+ audio_device = false;
}
}
/* Set defaults: */
- debug_mode = NO;
- use_fullscreen = NO;
- show_fps = NO;
- use_gl = NO;
+ debug_mode = false;
+ use_fullscreen = false;
+ show_fps = false;
+ use_gl = false;
- use_sound = YES;
- use_music = YES;
- audio_device = YES;
+ use_sound = true;
+ use_music = true;
+ audio_device = true;
/* Parse arguments: */
{
/* Use full screen: */
- use_fullscreen = YES;
+ use_fullscreen = true;
+ }
+ else if (strcmp(argv[i], "--joystick") == 0 || strcmp(argv[i], "-j") == 0)
+ {
+ assert(i+1 < argc);
+ joystick_num = atoi(argv[++i]);
}
else if (strcmp(argv[i], "--worldmap") == 0)
{
|| strcmp(argv[i], "-d") == 0 )
{
assert(i+1 < argc);
- datadir = argv[i+1];
+ datadir = argv[++i];
}
else if (strcmp(argv[i], "--show-fps") == 0)
{
/* Use full screen: */
- show_fps = YES;
+ show_fps = true;
}
else if (strcmp(argv[i], "--opengl") == 0 ||
strcmp(argv[i], "-gl") == 0)
#ifndef NOOPENGL
/* Use OpengGL: */
- use_gl = YES;
+ use_gl = true;
#endif
}
{
/* Disable the compiled in sound feature */
printf("Sounds disabled \n");
- use_sound = NO;
+ use_sound = false;
}
else if (strcmp(argv[i], "--disable-music") == 0)
{
/* Disable the compiled in sound feature */
printf("Music disabled \n");
- use_music = NO;
+ use_music = false;
}
else if (strcmp(argv[i], "--debug-mode") == 0)
{
/* Enable the debug-mode */
- debug_mode = YES;
+ debug_mode = true;
}
else if (strcmp(argv[i], "--help") == 0)
" Please see the file \"README.txt\" for more details.\n");
printf("Usage: %s [OPTIONS] FILENAME\n\n", argv[0]);
puts("Display Options:\n"
- " --fullscreen Run in fullscreen mode.\n"
- " --opengl If opengl support was compiled in, this will enable\n"
- " the EXPERIMENTAL OpenGL mode.\n"
+ " --fullscreen Run in fullscreen mode.\n"
+ " --opengl If opengl support was compiled in, this will enable\n"
+ " the EXPERIMENTAL OpenGL mode.\n"
"\n"
"Sound Options:\n"
- " --disable-sound If sound support was compiled in, this will\n"
- " disable sound for this session of the game.\n"
- " --disable-music Like above, but this will disable music.\n"
+ " --disable-sound If sound support was compiled in, this will\n"
+ " disable sound for this session of the game.\n"
+ " --disable-music Like above, but this will disable music.\n"
"\n"
"Misc Options:\n"
- " --worldmap Start in worldmap-mode (EXPERIMENTAL)\n"
- " -d, --datadir DIR Load Game data from DIR (default: automatic)\n"
- " --debug-mode Enables the debug-mode, which is useful for developers.\n"
- " --help Display a help message summarizing command-line\n"
- " options, license and game controls.\n"
- " --usage Display a brief message summarizing command-line options.\n"
- " --version Display the version of SuperTux you're running.\n\n"
+ " -j, --joystick NUM Use joystick NUM (default: 0)\n"
+ " --worldmap Start in worldmap-mode (EXPERIMENTAL)\n"
+ " -d, --datadir DIR Load Game data from DIR (default: automatic)\n"
+ " --debug-mode Enables the debug-mode, which is useful for developers.\n"
+ " --help Display a help message summarizing command-line\n"
+ " options, license and game controls.\n"
+ " --usage Display a brief message summarizing command-line options.\n"
+ " --version Display the version of SuperTux you're running.\n\n"
);
exit(0);
}