From: Holger Schemel Date: Sun, 22 Aug 2004 13:54:57 +0000 (+0200) Subject: rnd-20040822-3-src X-Git-Tag: 3.1.1^2~70 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=cee436b68cda95e13abc810235a11ce94bc79c95;p=rocksndiamonds.git rnd-20040822-3-src --- diff --git a/src/conftime.h b/src/conftime.h index 00bdd029..4f6bd76c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-08-22 01:50]" +#define COMPILE_DATE_STRING "[2004-08-22 15:51]" diff --git a/src/files.c b/src/files.c index e9d2cb59..0fd7a18a 100644 --- a/src/files.c +++ b/src/files.c @@ -49,22 +49,6 @@ #define TAPE_COOKIE_TMPL "ROCKSNDIAMONDS_TAPE_FILE_VERSION_x.x" #define SCORE_COOKIE "ROCKSNDIAMONDS_SCORE_FILE_VERSION_1.2" -/* values for level file type identifier */ -#define LEVEL_FILE_TYPE_UNKNOWN 0 -#define LEVEL_FILE_TYPE_RND 1 -#define LEVEL_FILE_TYPE_BD 2 -#define LEVEL_FILE_TYPE_EM 3 -#define LEVEL_FILE_TYPE_SP 4 -#define LEVEL_FILE_TYPE_DX 5 -#define LEVEL_FILE_TYPE_SB 6 -#define LEVEL_FILE_TYPE_DC 7 - -#define LEVEL_FILE_TYPE_RND_PACKED (10 + LEVEL_FILE_TYPE_RND) -#define LEVEL_FILE_TYPE_EM_PACKED (10 + LEVEL_FILE_TYPE_EM) - -#define IS_SINGLE_LEVEL_FILE(x) (x < 10) -#define IS_PACKED_LEVEL_FILE(x) (x > 10) - /* ========================================================================= */ /* level file functions */ @@ -551,6 +535,20 @@ static void determineLevelFileInfo_Filetype(struct LevelFileInfo *lfi) lfi->type = getFileTypeFromBasename(lfi->basename); } +#if 1 +static void setLevelFileInfo(struct LevelFileInfo *level_file_info, int nr) +{ + /* always start with reliable default values */ + setFileInfoToDefaults(level_file_info); + + level_file_info->nr = nr; /* set requested level number */ + + determineLevelFileInfo_Filename(level_file_info); + determineLevelFileInfo_Filetype(level_file_info); +} + +#else + static struct LevelFileInfo *getLevelFileInfo(int nr) { static struct LevelFileInfo level_file_info; @@ -565,7 +563,7 @@ static struct LevelFileInfo *getLevelFileInfo(int nr) return &level_file_info; } - +#endif /* ------------------------------------------------------------------------- */ /* functions for loading R'n'D level */ @@ -2500,6 +2498,16 @@ static void LoadLevel_InitPlayfield(struct LevelInfo *level, char *filename) void LoadLevelTemplate(int nr) { +#if 1 + char *filename; + + setLevelFileInfo(&level_template.file_info, nr); + filename = level_template.file_info.filename; + + LoadLevelFromFileInfo(&level_template, &level_template.file_info); + +#else + #if 1 struct LevelFileInfo *level_file_info = getLevelFileInfo(nr); char *filename = level_file_info->filename; @@ -2510,6 +2518,7 @@ void LoadLevelTemplate(int nr) LoadLevelFromFilename_RND(&level_template, filename); #endif +#endif #if 1 LoadLevel_InitVersion(&level_template, filename); @@ -2524,6 +2533,16 @@ void LoadLevelTemplate(int nr) void LoadLevel(int nr) { +#if 1 + char *filename; + + setLevelFileInfo(&level.file_info, nr); + filename = level.file_info.filename; + + LoadLevelFromFileInfo(&level, &level.file_info); + +#else + #if 1 struct LevelFileInfo *level_file_info = getLevelFileInfo(nr); char *filename = level_file_info->filename; @@ -2533,6 +2552,7 @@ void LoadLevel(int nr) char *filename = getLevelFilename(nr); LoadLevelFromFilename_RND(&level, filename); +#endif #endif if (level.use_custom_template) diff --git a/src/files.h b/src/files.h index 1dffbe61..0918ac91 100644 --- a/src/files.h +++ b/src/files.h @@ -16,6 +16,29 @@ #include "main.h" + +/* values for level file type identifier */ +#define LEVEL_FILE_TYPE_UNKNOWN 0 +#define LEVEL_FILE_TYPE_RND 1 +#define LEVEL_FILE_TYPE_BD 2 +#define LEVEL_FILE_TYPE_EM 3 +#define LEVEL_FILE_TYPE_SP 4 +#define LEVEL_FILE_TYPE_DX 5 +#define LEVEL_FILE_TYPE_SB 6 +#define LEVEL_FILE_TYPE_DC 7 + +#define NUM_LEVEL_FILE_TYPES 8 + +#define LEVEL_PACKED_START 100 +#define PACKED_LEVELS(x) (LEVEL_PACKED_START + x) + +#define LEVEL_FILE_TYPE_RND_PACKED PACKED_LEVELS(LEVEL_FILE_TYPE_RND) +#define LEVEL_FILE_TYPE_EM_PACKED PACKED_LEVELS(LEVEL_FILE_TYPE_EM) + +#define IS_SINGLE_LEVEL_FILE(x) (x < LEVEL_PACKED_START) +#define IS_PACKED_LEVEL_FILE(x) (x > LEVEL_PACKED_START) + + void setElementChangePages(struct ElementInfo *, int); void setElementChangeInfoToDefaults(struct ElementChangeInfo *); diff --git a/src/game.c b/src/game.c index 1d2396b0..7d0c60eb 100644 --- a/src/game.c +++ b/src/game.c @@ -2060,32 +2060,33 @@ void InitGame() CloseDoor(DOOR_CLOSE_1); -#if 1 - - if (em_main_init_game(level_nr) != 0) + /* !!! FIX THIS (START) !!! */ + if (level.file_info.type == LEVEL_FILE_TYPE_EM) { - game_status = GAME_MODE_MAIN; - DrawMainMenu(); + if (em_main_init_game(level_nr, level.file_info.filename) != 0) + { + game_status = GAME_MODE_MAIN; + DrawMainMenu(); - return; + return; + } } + else + { + DrawLevel(); + DrawAllPlayers(); -#else - - DrawLevel(); - DrawAllPlayers(); - - /* after drawing the level, correct some elements */ - if (game.timegate_time_left == 0) - CloseAllOpenTimegates(); - - if (setup.soft_scrolling) - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); + /* after drawing the level, correct some elements */ + if (game.timegate_time_left == 0) + CloseAllOpenTimegates(); - redraw_mask |= REDRAW_FROM_BACKBUFFER; - FadeToFront(); + if (setup.soft_scrolling) + BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); -#endif + redraw_mask |= REDRAW_FROM_BACKBUFFER; + FadeToFront(); + } + /* !!! FIX THIS (END) !!! */ /* copy default game door content to main double buffer */ BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, diff --git a/src/game_em/game_em.h b/src/game_em/game_em.h index 77d00172..08854a12 100644 --- a/src/game_em/game_em.h +++ b/src/game_em/game_em.h @@ -19,7 +19,7 @@ extern void em_open_all(); extern void em_close_all(); -extern int em_main_init_game(int); +extern int em_main_init_game(int, char *); extern int em_main_handle_game(byte); #endif /* GAME_EM_H */ diff --git a/src/game_em/global.h b/src/game_em/global.h index c2a13e89..746fa129 100644 --- a/src/game_em/global.h +++ b/src/game_em/global.h @@ -55,7 +55,7 @@ void sound_play(void); int cave_convert(char *filename); void game_init_vars(void); -int game_play_init(int); +int game_play_init(int, char *); int game_loop(byte); void synchro_1(void); diff --git a/src/game_em/input.c b/src/game_em/input.c index 9c1681ff..81fa95ea 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -150,18 +150,28 @@ void game_init_vars(void) input_pause = 1 * 0; } -int game_play_init(int player_level) +int game_play_init(int level_nr, char *filename) { - char name[MAXNAME+2]; + if (filename != NULL) + { + player_level = level_nr; + + if (cave_convert(filename) != 0) + return 1; + } + else /* !!! SOON OBSOLETE !!! */ + { + char name[MAXNAME+2]; - name[MAXNAME] = 0; - snprintf(name, MAXNAME+2, "%s/lev%02d", EM_LVL_DIR, player_level); + name[MAXNAME] = 0; + snprintf(name, MAXNAME+2, "%s/lev%02d", EM_LVL_DIR, player_level); - if (name[MAXNAME]) - snprintf_overflow("read a level in cave/"); + if (name[MAXNAME]) + snprintf_overflow("read a level in cave/"); - if (cave_convert(name) != 0) - return 1; + if (cave_convert(name) != 0) + return 1; + } game_initscreen(); game_blitscore(); @@ -321,7 +331,7 @@ int game_loop(byte action) /* start playing */ em_game_status = EM_GAME_STATUS_PLAY; - if (game_play_init(player_level) != 0) + if (game_play_init(player_level, NULL) != 0) em_game_status = EM_GAME_STATUS_MENU; } } diff --git a/src/game_em/main.c b/src/game_em/main.c index 7ae2810a..39975801 100644 --- a/src/game_em/main.c +++ b/src/game_em/main.c @@ -52,12 +52,12 @@ void em_close_all() close_all(); } -int em_main_init_game(int level_nr) +int em_main_init_game(int level_nr, char *filename) { if (skip_menu) { em_game_status = EM_GAME_STATUS_PLAY; - if (game_play_init(level_nr) != 0) + if (game_play_init(level_nr, filename) != 0) return 1; } else diff --git a/src/main.h b/src/main.h index cf064727..1e620fb9 100644 --- a/src/main.h +++ b/src/main.h @@ -1475,6 +1475,8 @@ struct LevelFileInfo struct LevelInfo { + struct LevelFileInfo file_info; + int file_version; /* file format version the level is stored with */ int game_version; /* game release version the level was created with */ diff --git a/src/screens.c b/src/screens.c index d3728d2c..425c35e8 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2944,8 +2944,8 @@ void HandleGameActions() if (game_status != GAME_MODE_PLAYING) return; -#if 1 - + /* !!! FIX THIS (START) !!! */ + if (level.file_info.type == LEVEL_FILE_TYPE_EM) { byte summarized_player_action = 0; int i; @@ -2959,22 +2959,20 @@ void HandleGameActions() DrawMainMenu(); } } + else + { + if (local_player->LevelSolved) + GameWon(); -#else - - if (local_player->LevelSolved) - GameWon(); - - if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) - TapeStop(); - - GameActions(); - BackToFront(); + if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) + TapeStop(); - if (tape.auto_play && !tape.playing) - AutoPlayTape(); /* continue automatically playing next tape */ + GameActions(); + BackToFront(); -#endif + if (tape.auto_play && !tape.playing) + AutoPlayTape(); /* continue automatically playing next tape */ + } } /* ---------- new screen button stuff -------------------------------------- */