From: Holger Schemel Date: Sun, 6 Jun 2004 15:07:53 +0000 (+0200) Subject: rnd-20040606-1-src X-Git-Tag: 3.1.0^2~1 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=3e7289558277c65b6ddcbef0f663d100e7d237fc;p=rocksndiamonds.git rnd-20040606-1-src * added option "convert LEVELDIR [NR]" to command line batch commands * re-converted Supaplex levels to apply latest engine fixes * changed "use graphic/sound of element" to "use graphic of element" due to compatibility problems with some levels ("bug machine" etc.) --- diff --git a/ChangeLog b/ChangeLog index 41bf977b..4c579db9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-06-06 + * added option "convert LEVELDIR [NR]" to command line batch commands + * re-converted Supaplex levels to apply latest engine fixes + * changed "use graphic/sound of element" to "use graphic of element" + due to compatibility problems with some levels ("bug machine" etc.) + 2004-05-23 * fixed bug with CE change replacing player with same or other player diff --git a/src/conftime.h b/src/conftime.h index 90af2d01..e2b33e8d 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-05-23 22:37]" +#define COMPILE_DATE_STRING "[2004-06-06 16:37]" diff --git a/src/editor.c b/src/editor.c index 89363f8f..9236f0a9 100644 --- a/src/editor.c +++ b/src/editor.c @@ -2039,7 +2039,11 @@ static struct ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1), GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE, &custom_element.use_gfx_element, +#if 0 NULL, "use graphic/sound of element:", "use existing graphic and sound" +#else + NULL, "use graphic of element:", "use existing element graphic" +#endif }, { ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2), diff --git a/src/files.c b/src/files.c index 956a8df4..3d4670f0 100644 --- a/src/files.c +++ b/src/files.c @@ -4821,3 +4821,117 @@ void LoadHelpTextInfo() END_HASH_ITERATION(hash, itr) #endif } + + +/* ------------------------------------------------------------------------- * + * convert levels + * ------------------------------------------------------------------------- */ + +#define MAX_NUM_CONVERT_LEVELS 1000 + +void ConvertLevels() +{ + static LevelDirTree *convert_leveldir = NULL; + static int convert_level_nr = -1; + static int num_levels_handled = 0; + static int num_levels_converted = 0; + static boolean levels_failed[MAX_NUM_CONVERT_LEVELS]; + int i; + + convert_leveldir = getTreeInfoFromIdentifier(leveldir_first, + global.convert_leveldir); + + if (convert_leveldir == NULL) + Error(ERR_EXIT, "no such level identifier: '%s'", + global.convert_leveldir); + + leveldir_current = convert_leveldir; + + if (global.convert_level_nr != -1) + { + convert_leveldir->first_level = global.convert_level_nr; + convert_leveldir->last_level = global.convert_level_nr; + } + + convert_level_nr = convert_leveldir->first_level; + + printf_line("=", 79); + printf("Converting levels\n"); + printf_line("-", 79); + printf("Level series identifier: '%s'\n", convert_leveldir->identifier); + printf("Level series name: '%s'\n", convert_leveldir->name); + printf("Level series author: '%s'\n", convert_leveldir->author); + printf("Number of levels: %d\n", convert_leveldir->levels); + printf_line("=", 79); + printf("\n"); + + for (i = 0; i < MAX_NUM_CONVERT_LEVELS; i++) + levels_failed[i] = FALSE; + + while (convert_level_nr <= convert_leveldir->last_level) + { + char *level_filename; + boolean new_level; + + level_nr = convert_level_nr++; + + printf("Level %03d: ", level_nr); + + LoadLevel(level_nr); + if (level.no_valid_file) + { + printf("(no level)\n"); + continue; + } + + printf("converting level ... "); + + level_filename = getDefaultLevelFilename(level_nr); + new_level = !fileExists(level_filename); + + if (new_level) + { + SaveLevel(level_nr); + + num_levels_converted++; + + printf("converted.\n"); + } + else + { + if (level_nr >= 0 && level_nr < MAX_NUM_CONVERT_LEVELS) + levels_failed[level_nr] = TRUE; + + printf("NOT CONVERTED -- LEVEL ALREADY EXISTS.\n"); + } + + num_levels_handled++; + } + + printf("\n"); + printf_line("=", 79); + printf("Number of levels handled: %d\n", num_levels_handled); + printf("Number of levels converted: %d (%d%%)\n", num_levels_converted, + (num_levels_handled ? + num_levels_converted * 100 / num_levels_handled : 0)); + printf_line("-", 79); + printf("Summary (for automatic parsing by scripts):\n"); + printf("LEVELDIR '%s', CONVERTED %d/%d (%d%%)", + convert_leveldir->identifier, num_levels_converted, + num_levels_handled, + (num_levels_handled ? + num_levels_converted * 100 / num_levels_handled : 0)); + + if (num_levels_handled != num_levels_converted) + { + printf(", FAILED:"); + for (i = 0; i < MAX_NUM_CONVERT_LEVELS; i++) + if (levels_failed[i]) + printf(" %03d", i); + } + + printf("\n"); + printf_line("=", 79); + + CloseAllAndExit(0); +} diff --git a/src/files.h b/src/files.h index fe7be5ca..1dffbe61 100644 --- a/src/files.h +++ b/src/files.h @@ -47,4 +47,6 @@ void LoadMusicInfo(); void LoadHelpAnimInfo(); void LoadHelpTextInfo(); +void ConvertLevels(void); + #endif /* FILES_H */ diff --git a/src/init.c b/src/init.c index bbc20e0d..02b29cdc 100644 --- a/src/init.c +++ b/src/init.c @@ -3656,6 +3656,7 @@ void InitElementPropertiesEngine(int engine_version) static void InitGlobal() { global.autoplay_leveldir = NULL; + global.convert_leveldir = NULL; global.frames_per_second = 0; global.fps_slowdown = FALSE; @@ -3791,6 +3792,20 @@ void Execute_Command(char *command) global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */ } } + else if (strncmp(command, "convert ", 8) == 0) + { + char *str_copy = getStringCopy(&command[8]); + char *str_ptr = strchr(str_copy, ' '); + + global.convert_leveldir = str_copy; + global.convert_level_nr = -1; + + if (str_ptr != NULL) + { + *str_ptr++ = '\0'; /* terminate leveldir string */ + global.convert_level_nr = atoi(str_ptr); /* get level_nr value */ + } + } else { Error(ERR_EXIT_HELP, "unrecognized command '%s'", command); @@ -4396,6 +4411,11 @@ void OpenAll() AutoPlayTape(); return; } + else if (global.convert_leveldir) + { + ConvertLevels(); + return; + } game_status = GAME_MODE_MAIN; diff --git a/src/main.c b/src/main.c index e36ce905..81319ed6 100644 --- a/src/main.c +++ b/src/main.c @@ -4151,7 +4151,7 @@ static void print_usage() " --serveronly only start network server\n" " -v, --verbose verbose mode\n" " --debug display debugging information\n" - " -e, --execute COMMAND execute batch COMMAND:\n" + " -e, --execute COMMAND execute batch COMMAND\n" "\n" "Valid commands for '--execute' option:\n" " \"print graphicsinfo.conf\" print default graphics config\n" @@ -4162,7 +4162,8 @@ static void print_usage() " \"print helptext.conf\" print default helptext config\n" " \"dump level FILE\" dump level data from FILE\n" " \"dump tape FILE\" dump tape data from FILE\n" - " \"autoplay LEVELDIR\" play level tapes for LEVELDIR\n" + " \"autoplay LEVELDIR [NR]\" play level tapes for LEVELDIR\n" + " \"convert LEVELDIR [NR]\" convert levels in LEVELDIR\n" "\n", program.command_basename); } diff --git a/src/main.h b/src/main.h index 64698879..0bf9a365 100644 --- a/src/main.h +++ b/src/main.h @@ -436,7 +436,13 @@ #define GFX_ELEMENT(e) (element_info[e].use_gfx_element ? \ element_info[e].gfx_element : e) +/* !!! "use sound" deactivated due to problems with level "bug machine" !!! */ +/* (solution: add separate "use sound of element" to level file and editor) */ +#if 0 #define SND_ELEMENT(e) GFX_ELEMENT(e) +#else +#define SND_ELEMENT(e) (e) +#endif #define IS_PLAYER(x, y) (ELEM_IS_PLAYER(StorePlayer[x][y])) @@ -1585,6 +1591,9 @@ struct GlobalInfo char *autoplay_leveldir; int autoplay_level_nr; + char *convert_leveldir; + int convert_level_nr; + int num_toons; float frames_per_second; diff --git a/src/tape.c b/src/tape.c index fb705a9f..66ca33c0 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1304,6 +1304,7 @@ void AutoPlayTape() printf("LEVELDIR '%s', SOLVED %d/%d (%d%%)", autoplay_leveldir->identifier, num_levels_solved, num_levels_played, (num_levels_played ? num_levels_solved * 100 / num_levels_played :0)); + if (num_levels_played != num_levels_solved) { printf(", FAILED:"); @@ -1311,6 +1312,7 @@ void AutoPlayTape() if (levels_failed[i]) printf(" %03d", i); } + printf("\n"); printf_line("=", 79);