-#define COMPILE_DATE_STRING "[2004-08-22 01:50]"
+#define COMPILE_DATE_STRING "[2004-08-22 15:51]"
#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 */
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;
return &level_file_info;
}
-
+#endif
/* ------------------------------------------------------------------------- */
/* functions for loading R'n'D level */
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;
LoadLevelFromFilename_RND(&level_template, filename);
#endif
+#endif
#if 1
LoadLevel_InitVersion(&level_template, filename);
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;
char *filename = getLevelFilename(nr);
LoadLevelFromFilename_RND(&level, filename);
+#endif
#endif
if (level.use_custom_template)
#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 *);
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,
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 */
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);
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();
/* 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;
}
}
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
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 */
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;
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 -------------------------------------- */