From: Holger Schemel Date: Fri, 27 Dec 2002 14:38:19 +0000 (+0100) Subject: rnd-20021227-1-src X-Git-Tag: 3.0.0^2~198 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=fa2a77aa4b53bb786e67f35d6c46f759ebe7823d rnd-20021227-1-src --- diff --git a/src/conftime.h b/src/conftime.h index c572f214..919b39ce 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-12-23 00:34]" +#define COMPILE_DATE_STRING "[2002-12-27 15:33]" diff --git a/src/files.c b/src/files.c index fac13d01..fad45178 100644 --- a/src/files.c +++ b/src/files.c @@ -846,9 +846,8 @@ static int LoadTape_BODY(FILE *file, int chunk_size, struct TapeInfo *tape) return chunk_size; } -void LoadTape(int level_nr) +void LoadTapeFromFilename(char *filename) { - char *filename = getTapeFilename(level_nr); char cookie[MAX_LINE_LEN]; char chunk_name[CHUNK_ID_LEN + 1]; FILE *file; @@ -964,6 +963,13 @@ void LoadTape(int level_nr) tape.length_seconds = GetTapeLength(); } +void LoadTape(int level_nr) +{ + char *filename = getTapeFilename(level_nr); + + LoadTapeFromFilename(filename); +} + static void SaveTape_VERS(FILE *file, struct TapeInfo *tape) { putFileVersion(file, tape->file_version); @@ -1073,17 +1079,18 @@ void DumpTape(struct TapeInfo *tape) return; } - printf("\n"); - printf("-------------------------------------------------------------------------------\n"); + printf_line('-', 79); printf("Tape of Level %d (file version %06d, game version %06d)\n", tape->level_nr, tape->file_version, tape->game_version); - printf("-------------------------------------------------------------------------------\n"); + printf_line('-', 79); for(i=0; ilength; i++) { if (i >= MAX_TAPELEN) break; + printf("%03d: ", i); + for(j=0; jplayer_participates[j]) @@ -1104,7 +1111,7 @@ void DumpTape(struct TapeInfo *tape) printf("(%03d)\n", tape->pos[i].delay); } - printf("-------------------------------------------------------------------------------\n"); + printf_line('-', 79); } diff --git a/src/files.h b/src/files.h index 1409ba9c..81985010 100644 --- a/src/files.h +++ b/src/files.h @@ -19,6 +19,7 @@ void LoadLevel(int); void SaveLevel(int); +void LoadTapeFromFilename(char *); void LoadTape(int); void SaveTape(int); void DumpTape(struct TapeInfo *); diff --git a/src/game.c b/src/game.c index 5a6a2489..28dde52a 100644 --- a/src/game.c +++ b/src/game.c @@ -2807,6 +2807,8 @@ static boolean JustBeingPushed(int x, int y) void StartMoving(int x, int y) { + static boolean use_spring_bug = TRUE; + boolean started_moving = FALSE; /* some elements can fall _and_ move */ int element = Feld[x][y]; if (Stop[x][y]) @@ -2814,7 +2816,7 @@ void StartMoving(int x, int y) GfxAction[x][y] = GFX_ACTION_DEFAULT; - if (CAN_FALL(element) && y0 && IS_PLAYER(x-1, y)) || (xmove_delay_value; #if DEBUG - printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES.\n"); + printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%ld]\n", + tape.counter); #endif /* scroll remaining steps with finest movement resolution */ diff --git a/src/init.c b/src/init.c index 926d429e..255cbc63 100644 --- a/src/init.c +++ b/src/init.c @@ -57,6 +57,7 @@ static char *image_filename[NUM_PICTURES] = static Bitmap *bitmap_font_initial = NULL; +static void InitGlobal(void); static void InitSetup(void); static void InitPlayerInfo(void); static void InitLevelInfo(void); @@ -73,16 +74,14 @@ static void InitElementProperties(void); static void InitElementInfo(void); static void InitGraphicInfo(void); static void InitSoundInfo(); -static void Execute_Debug_Command(char *); +static void Execute_Command(char *); void OpenAll(void) { - if (options.debug_command) - { - Execute_Debug_Command(options.debug_command); + InitGlobal(); /* initialize some global variables */ - exit(0); - } + if (options.execute_command) + Execute_Command(options.execute_command); if (options.serveronly) { @@ -130,11 +129,26 @@ void OpenAll(void) InitGfxBackground(); InitToons(); + if (global.autoplay_leveldir) + { + AutoPlayTape(); + return; + } + DrawMainMenu(); InitNetworkServer(); } +void InitGlobal() +{ + global.autoplay_leveldir = NULL; + + global.frames_per_second = 0; + global.fps_slowdown = FALSE; + global.fps_slowdown_factor = 1; +} + void InitSetup() { LoadSetup(); /* global setup info */ @@ -407,11 +421,6 @@ void InitGfx() int i; #endif - /* initialize some global variables */ - global.frames_per_second = 0; - global.fps_slowdown = FALSE; - global.fps_slowdown_factor = 1; - /* initialize screen properties */ InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); @@ -2078,9 +2087,9 @@ void InitElementProperties() Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE); } -void Execute_Debug_Command(char *command) +void Execute_Command(char *command) { - if (strcmp(command, "create graphicsinfo.conf") == 0) + if (strcmp(command, "print graphicsinfo.conf") == 0) { int i; @@ -2096,8 +2105,10 @@ void Execute_Debug_Command(char *command) printf("# %s\n", getFormattedSetupEntry(image_config[i].token, image_config[i].value)); + + exit(0); } - else if (strcmp(command, "create soundsinfo.conf") == 0) + else if (strcmp(command, "print soundsinfo.conf") == 0) { int i; @@ -2113,21 +2124,48 @@ void Execute_Debug_Command(char *command) printf("# %s\n", getFormattedSetupEntry(sound_config[i].token, sound_config[i].value)); + + exit(0); } - else if (strcmp(command, "create musicinfo.conf") == 0) + else if (strcmp(command, "print musicinfo.conf") == 0) { printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n"); printf("\n"); printf("%s\n", getFormattedSetupEntry("name", "Classic Music")); printf("\n"); printf("%s\n", getFormattedSetupEntry("sort_priority", "100")); + + exit(0); + } + else if (strncmp(command, "dump tape ", 10) == 0) + { + char *filename = &command[10]; + + if (access(filename, F_OK) != 0) + Error(ERR_EXIT, "cannot open file '%s'", filename); + + LoadTapeFromFilename(filename); + DumpTape(&tape); + + exit(0); + } + else if (strncmp(command, "autoplay ", 9) == 0) + { + char *str_copy = getStringCopy(&command[9]); + char *str_ptr = strchr(str_copy, ' '); + + global.autoplay_leveldir = str_copy; + global.autoplay_level_nr = -1; + + if (str_ptr != NULL) + { + *str_ptr++ = '\0'; /* terminate leveldir string */ + global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */ + } } - else if (strcmp(command, "help") == 0) + else { - printf("The following commands are recognized:\n"); - printf(" \"create graphicsinfo.conf\"\n"); - printf(" \"create soundsinfo.conf\"\n"); - printf(" \"create musicinfo.conf\"\n"); + Error(ERR_EXIT_HELP, "unrecognized command '%s'", command); } } diff --git a/src/libgame/misc.c b/src/libgame/misc.c index e439e71d..b5dfab4b 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -436,6 +436,34 @@ char *getStringToLower(char *s) return s_copy; } +static void printUsage() +{ + printf("\n" + "Usage: %s [OPTION]... [HOSTNAME [PORT]]\n" + "\n" + "Options:\n" + " -d, --display HOSTNAME[:SCREEN] specify X server display\n" + " -b, --basepath DIRECTORY alternative base DIRECTORY\n" + " -l, --level DIRECTORY alternative level DIRECTORY\n" + " -g, --graphics DIRECTORY alternative graphics DIRECTORY\n" + " -s, --sounds DIRECTORY alternative sounds DIRECTORY\n" + " -m, --music DIRECTORY alternative music DIRECTORY\n" + " -n, --network network multiplayer game\n" + " --serveronly only start network server\n" + " -v, --verbose verbose mode\n" + " --debug display debugging information\n" + " -e, --execute COMMAND execute batch COMMAND:\n" + "\n" + "Valid commands for '--execute' option:\n" + " \"print graphicsinfo.conf\" print default graphics config\n" + " \"print soundsinfo.conf\" print default sounds config\n" + " \"print musicinfo.conf\" print default music config\n" + " \"dump tape FILE\" dump tape data from FILE\n" + " \"autoplay LEVELDIR\" play level tapes for LEVELDIR\n" + "\n", + program.command_basename); +} + void GetOptions(char *argv[]) { char **options_left = &argv[1]; @@ -450,12 +478,11 @@ void GetOptions(char *argv[]) options.graphics_directory = RO_BASE_PATH "/" GRAPHICS_DIRECTORY; options.sounds_directory = RO_BASE_PATH "/" SOUNDS_DIRECTORY; options.music_directory = RO_BASE_PATH "/" MUSIC_DIRECTORY; - options.autoplay_leveldir = NULL; + options.execute_command = NULL; options.serveronly = FALSE; options.network = FALSE; options.verbose = FALSE; options.debug = FALSE; - options.debug_command = NULL; while (*options_left) { @@ -493,23 +520,7 @@ void GetOptions(char *argv[]) Error(ERR_EXIT_HELP, "unrecognized option '%s'", option); else if (strncmp(option, "-help", option_len) == 0) { - printf("Usage: %s [options] [ []]\n" - "Options:\n" - " -d, --display [:] X server display\n" - " -b, --basepath alternative base directory\n" - " -l, --level alternative level directory\n" - " -g, --graphics alternative graphics directory\n" - " -s, --sounds alternative sounds directory\n" - " -m, --music alternative music directory\n" - " -a, --autoplay automatically play level tapes\n" - " -n, --network network multiplayer game\n" - " --serveronly only start network server\n" - " -v, --verbose verbose mode\n" - " --debug display debugging information\n", - program.command_basename); - - if (options.debug) - printf(" --debug-command execute special command\n"); + printUsage(); exit(0); } @@ -573,15 +584,6 @@ void GetOptions(char *argv[]) if (option_arg == next_option) options_left++; } - else if (strncmp(option, "-autoplay", option_len) == 0) - { - if (option_arg == NULL) - Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str); - - options.autoplay_leveldir = option_arg; - if (option_arg == next_option) - options_left++; - } else if (strncmp(option, "-network", option_len) == 0) { options.network = TRUE; @@ -598,12 +600,12 @@ void GetOptions(char *argv[]) { options.debug = TRUE; } - else if (strncmp(option, "-debug-command", option_len) == 0) + else if (strncmp(option, "-execute", option_len) == 0) { if (option_arg == NULL) Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str); - options.debug_command = option_arg; + options.execute_command = option_arg; if (option_arg == next_option) options_left++; } @@ -1799,6 +1801,21 @@ void dumpErrorFile() #endif +/* ========================================================================= */ +/* some generic helper functions */ +/* ========================================================================= */ + +void printf_line(char line_char, int line_length) +{ + int i; + + for (i=0; i gfx.dx) diff --git a/src/libgame/system.h b/src/libgame/system.h index a28c0350..7dcc7e13 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -247,14 +247,12 @@ struct OptionInfo char *graphics_directory; char *sounds_directory; char *music_directory; - char *autoplay_leveldir; + char *execute_command; boolean serveronly; boolean network; boolean verbose; boolean debug; - - char *debug_command; }; struct VideoSystemInfo diff --git a/src/main.h b/src/main.h index 8b992511..7d1f74be 100644 --- a/src/main.h +++ b/src/main.h @@ -1618,6 +1618,9 @@ struct GameInfo struct GlobalInfo { + char *autoplay_leveldir; + int autoplay_level_nr; + float frames_per_second; boolean fps_slowdown; int fps_slowdown_factor; diff --git a/src/screens.c b/src/screens.c index ffb15a9f..0532cdd1 100644 --- a/src/screens.c +++ b/src/screens.c @@ -235,9 +235,6 @@ void DrawMainMenu() OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); - if (options.autoplay_leveldir) - AutoPlayTape(); - #if 0 ClearEventQueue(); #endif diff --git a/src/tape.c b/src/tape.c index 8ca52a03..8f5dd57a 100644 --- a/src/tape.c +++ b/src/tape.c @@ -326,7 +326,7 @@ static void TapeRewind() tape.playing = FALSE; tape.fast_forward = FALSE; tape.index_search = FALSE; - tape.auto_play = (options.autoplay_leveldir != NULL); + tape.auto_play = (global.autoplay_leveldir != NULL); tape.auto_play_level_solved = FALSE; tape.quick_resume = FALSE; tape.single_step = FALSE; @@ -614,7 +614,7 @@ static void TapeStartIndexSearch() { tape.pausing = FALSE; - SetDrawDeactivationMask(REDRAW_FIELD | REDRAW_DOOR_1); + SetDrawDeactivationMask(REDRAW_FIELD); audio.sound_deactivated = TRUE; } } @@ -687,26 +687,49 @@ void AutoPlayTape() static LevelDirTree *autoplay_leveldir = NULL; static boolean autoplay_initialized = FALSE; static int autoplay_level_nr = -1; + static int levels_played = 0; + static int levels_solved = 0; if (autoplay_initialized) { /* just finished auto-playing tape */ printf("%s.\n", tape.auto_play_level_solved ? "solved" : "NOT SOLVED"); + + levels_played++; + if (tape.auto_play_level_solved) + levels_solved++; } else { + DrawCompleteVideoDisplay(); + audio.sound_enabled = FALSE; + autoplay_leveldir = getTreeInfoFromIdentifier(leveldir_first, - options.autoplay_leveldir); + global.autoplay_leveldir); if (autoplay_leveldir == NULL) Error(ERR_EXIT, "no such level identifier: '%s'", - options.autoplay_leveldir); + global.autoplay_leveldir); leveldir_current = autoplay_leveldir; + if (global.autoplay_level_nr != -1) + { + autoplay_leveldir->first_level = global.autoplay_level_nr; + autoplay_leveldir->last_level = global.autoplay_level_nr; + } + autoplay_level_nr = autoplay_leveldir->first_level; - printf("Playing tapes of level series '%s'.\n", options.autoplay_leveldir); + printf_line('=', 79); + printf("Automatically playing level tapes\n"); + printf_line('-', 79); + printf("Level series identifier: '%s'\n", autoplay_leveldir->identifier); + printf("Level series name: '%s'\n", autoplay_leveldir->name); + printf("Level series author: '%s'\n", autoplay_leveldir->author); + printf("Number of levels: %d\n", autoplay_leveldir->levels); + printf_line('=', 79); + printf("\n"); autoplay_initialized = TRUE; } @@ -722,27 +745,35 @@ void AutoPlayTape() LoadLevel(level_nr); if (level.no_level_file) { - printf("(no level file)\n"); + printf("(no level)\n"); continue; } LoadTape(level_nr); if (TAPE_IS_EMPTY(tape)) { - printf("(no tape file)\n"); + printf("(no tape)\n"); continue; } - break; - } + printf("playing tape ... "); + + TapeStartGamePlaying(); + TapeStartIndexSearch(); - if (autoplay_level_nr >= autoplay_leveldir->last_level) - CloseAllAndExit(0); + return; + } - printf("playing tape ... "); + printf("\n"); + printf_line('=', 79); + printf("Summary\n"); + printf_line('-', 79); + printf("Number of levels played: %d\n", levels_played); + printf("Number of levels solved: %d (%d%%)\n", levels_solved, + levels_solved * 100 / levels_played); + printf_line('=', 79); - TapeStartGamePlaying(); - TapeStartIndexSearch(); + CloseAllAndExit(0); } diff --git a/src/tools.c b/src/tools.c index 7a99fd61..2e627abf 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2244,10 +2244,17 @@ unsigned int MoveDoor(unsigned int door_state) { stepsize = 20; door_delay_value = 0; + StopSound(SND_MENU_DOOR_OPENING); StopSound(SND_MENU_DOOR_CLOSING); } + if (global.autoplay_leveldir) + { + door_state |= DOOR_NO_DELAY; + door_state &= ~DOOR_CLOSE_ALL; + } + if (door_state & DOOR_ACTION) { if (!(door_state & DOOR_NO_DELAY)) @@ -2266,7 +2273,8 @@ unsigned int MoveDoor(unsigned int door_state) Bitmap *bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap; GC gc = bitmap->stored_clip_gc; - WaitUntilDelayReached(&door_delay, door_delay_value); + if (!(door_state & DOOR_NO_DELAY)) + WaitUntilDelayReached(&door_delay, door_delay_value); if (door_state & DOOR_ACTION_1) {