X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fmain.c;h=a0483461e302bf798c45bba8f6c3ae446f9a1f53;hp=66f85d38f8505d7c5405c917ec9e27cf2be0cdf4;hb=50c422d96b6da2c0412b6bd3763e9d1a029a6014;hpb=29014045f4de045f8452fdf7ab32622c94b37eef diff --git a/src/main.c b/src/main.c index 66f85d38..a0483461 100644 --- a/src/main.c +++ b/src/main.c @@ -31,7 +31,7 @@ GC gc, clip_gc[NUM_PIXMAPS], tile_clip_gc; Pixmap pix[NUM_PIXMAPS]; Pixmap clipmask[NUM_PIXMAPS], tile_clipmask[NUM_TILES]; -#ifdef XPM_INCLUDE_FILE +#ifdef USE_XPM_LIBRARY XpmAttributes xpm_att[NUM_PICTURES]; #endif @@ -42,55 +42,45 @@ int sound_pipe[2]; int sound_device; char *sound_device_name = SOUND_DEVICE; int joystick_device = 0; -char *joystick_device_name[2] = { DEV_JOYSTICK_0, DEV_JOYSTICK_1 }; -char *level_directory = LEVEL_PATH; -int width, height; +char *joystick_device_name[MAX_PLAYERS] = +{ + DEV_JOYSTICK_0, + DEV_JOYSTICK_1, + DEV_JOYSTICK_2, + DEV_JOYSTICK_3 +}; -char *display_name = NULL; -char *server_host = NULL; -int server_port = 0; -int networking = FALSE; -int standalone = TRUE; -int verbose = FALSE; +char *program_name = NULL; int game_status = MAINMENU; -int game_emulation = EMU_NONE; -int button_status = MB_NOT_PRESSED, motion_status = FALSE; +boolean network_playing = FALSE; +int button_status = MB_NOT_PRESSED; +boolean motion_status = FALSE; int key_joystick_mapping = 0; int global_joystick_status = JOYSTICK_STATUS; int joystick_status = JOYSTICK_STATUS; -int sound_status = SOUND_STATUS, sound_on = TRUE; -int sound_loops_allowed = FALSE, sound_loops_on = FALSE; -int sound_music_on = FALSE; -int sound_simple_on = FALSE; -int toons_on = TRUE; -int direct_draw_on = FALSE; -int scroll_delay_on = FALSE; -int soft_scrolling_on = TRUE; -int fading_on = FALSE; -int autorecord_on = FALSE; -int joystick_nr = 0; -int quick_doors = FALSE; +int sound_status = SOUND_STATUS; +boolean sound_loops_allowed = FALSE; -BOOL redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; int redraw_x1 = 0, redraw_y1 = 0; int redraw_mask; int redraw_tiles; -int Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int AmoebaCnt[MAX_NUM_AMOEBA], AmoebaCnt2[MAX_NUM_AMOEBA]; -long Elementeigenschaften[MAX_ELEMENTS]; +short Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +boolean Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short AmoebaCnt[MAX_NUM_AMOEBA], AmoebaCnt2[MAX_NUM_AMOEBA]; +unsigned long Elementeigenschaften[MAX_ELEMENTS]; int level_nr, leveldir_nr, num_leveldirs; int lev_fieldx,lev_fieldy, scroll_x,scroll_y; @@ -98,30 +88,27 @@ int lev_fieldx,lev_fieldy, scroll_x,scroll_y; int FX = SX, FY = SY, ScrollStepSize = TILEX/8; int ScreenMovDir = MV_NO_MOVING, ScreenMovPos = 0; int ScreenGfxPos = 0; -int GameFrameDelay = GAME_FRAME_DELAY, MoveSpeed = 8; +int GameFrameDelay = GAME_FRAME_DELAY; +int FfwdFrameDelay = FFWD_FRAME_DELAY; +int MoveSpeed = 8; int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1; int ZX,ZY, ExitX,ExitY; int AllPlayersGone; int FrameCounter, TimeFrames, TimeLeft; int MampferNr, SiebAktiv; -int TestPlayer = 0; +boolean network_player_action_received = FALSE; struct LevelDirInfo leveldir[MAX_LEVDIR_ENTRIES]; struct LevelInfo level; -struct PlayerInfo stored_player[MAX_PLAYERS+1]; -struct PlayerInfo *local_player; +struct PlayerInfo stored_player[MAX_PLAYERS], *local_player = NULL; struct HiScore highscore[MAX_SCORE_ENTRIES]; struct SoundInfo Sound[NUM_SOUNDS]; -struct RecordingInfo tape; - -struct JoystickInfo joystick[2] = -{ - { JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE, - JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE }, - { JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE, - JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE } -}; +struct TapeInfo tape; +struct OptionInfo options; +struct SetupInfo setup; +struct SetupFileList *setup_list = NULL; +struct SetupFileList *level_setup_list = NULL; /* data needed for playing sounds */ char *sound_name[NUM_SOUNDS] = @@ -193,174 +180,17 @@ int background_loop[] = }; int num_bg_loops = sizeof(background_loop)/sizeof(int); -char *program_name; - -#define MAX_OPTION_LEN 1024 - -static void fatal_option() -{ - fprintf(stderr,"Try '%s --help' for more information.\n", - program_name); - exit(1); -} - -static void fatal_unrecognized_option(char *option) -{ - fprintf(stderr,"%s: unrecognized option '%s'\n", - program_name, option); - fatal_option(); -} - -static void fatal_option_requires_argument(char *option) -{ - fprintf(stderr,"%s: option '%s' requires an argument\n", - program_name, option); - fatal_option(); -} - -static void fatal_invalid_option_argument(char *option) -{ - fprintf(stderr,"%s: option '%s' has invalid argument\n", - program_name, option); - fatal_option(); -} - -static void fatal_too_many_arguments() -{ - fprintf(stderr,"%s: too many arguments\n", - program_name); - fatal_option(); -} - -extern void fatal(char *); - int main(int argc, char *argv[]) { - char **options_left = &argv[1]; - program_name = (strrchr(argv[0],'/') ? strrchr(argv[0],'/') + 1 : argv[0]); - while (*options_left) - { - char option_str[MAX_OPTION_LEN]; - char *option = options_left[0]; - char *next_option = options_left[1]; - char *option_arg = NULL; - int option_len = strlen(option); - - strcpy(option_str, option); /* copy argument into buffer */ - option = option_str; - - if (strcmp(option, "--") == 0) /* stop scanning arguments */ - break; - - if (option_len >= MAX_OPTION_LEN) - fatal_unrecognized_option(option); - - if (strncmp(option, "--", 2) == 0) /* treat '--' like '-' */ - option++; - - option_arg = strchr(option, '='); - if (option_arg == NULL) /* no '=' in option */ - option_arg = next_option; - else - { - *option_arg++ = '\0'; /* cut argument from option */ - if (*option_arg == '\0') /* no argument after '=' */ - fatal_invalid_option_argument(option); - } - - option_len = strlen(option); - - if (strcmp(option, "-") == 0) - fatal_unrecognized_option(option); - else if (strncmp(option, "-help", option_len) == 0) - { - printf("Usage: %s [options] [server.name [port]]\n" - "Options:\n" - " -d, --display machine:0 X server display\n" - " -l, --levels directory alternative level directory\n" - " -v, --verbose verbose mode\n", - program_name); - exit(0); - } - else if (strncmp(option, "-display", option_len) == 0) - { - if (option_arg == NULL) - fatal_option_requires_argument(option_str); - - display_name = option_arg; - if (option_arg == next_option) - options_left++; - - printf("--display == '%s'\n", display_name); - } - else if (strncmp(option, "-levels", option_len) == 0) - { - if (option_arg == NULL) - fatal_option_requires_argument(option_str); - - level_directory = option_arg; - if (option_arg == next_option) - options_left++; - - printf("--levels == '%s'\n", level_directory); - } - else if (strncmp(option, "-verbose", option_len) == 0) - { - printf("--verbose\n"); - - verbose = TRUE; - } - else if (*option == '-') - fatal_unrecognized_option(option_str); - else if (server_host == NULL) - { - server_host = *options_left; - - printf("server.name == '%s'\n", server_host); - } - else if (server_port == 0) - { - server_port = atoi(*options_left); - if (server_port < 1024) - fatal("Bad port number"); - - printf("port == %d\n", server_port); - } - else - fatal_too_many_arguments(); - - options_left++; - } - - /* - printf("All went fine -- exiting\n"); - exit(0); - */ - - /* - if (argc>1) - level_directory = argv[1]; - */ - - - /* - if (argc > 1) - server_host = argv[1]; - - if (argc > 2) - server_port = atoi(argv[2]); - */ - - #ifdef MSDOS _fmode = O_BINARY; #endif + GetOptions(argv); OpenAll(argc,argv); EventLoop(); - CloseAll(); - - exit(0); + CloseAllAndExit(0); + exit(0); /* to keep compilers happy */ }