rnd-20040822-3-src
authorHolger Schemel <info@artsoft.org>
Sun, 22 Aug 2004 13:54:57 +0000 (15:54 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:47:53 +0000 (10:47 +0200)
src/conftime.h
src/files.c
src/files.h
src/game.c
src/game_em/game_em.h
src/game_em/global.h
src/game_em/input.c
src/game_em/main.c
src/main.h
src/screens.c

index 00bdd0291789f2e527a3b526447122d125bd612d..4f6bd76c4f1f58046f64374fd338e012e8f5bb91 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-08-22 01:50]"
+#define COMPILE_DATE_STRING "[2004-08-22 15:51]"
index e9d2cb5968a1677854bb94e2bc38ab6a6de243b6..0fd7a18ade6db1691778942d270aee3e8f15ecb7 100644 (file)
 #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)
index 1dffbe610ef77a0af56582303f241aab4d088e72..0918ac91aae5af0b0b922565991d1acfb89606d2 100644 (file)
 
 #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 *);
 
index 1d2396b025837c2238432b4b4c30261876cec9e3..7d0c60eb83580239c4ea956f11e205189bbc1409 100644 (file)
@@ -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,
index 77d001723b81e5197e3ee0edeec700649f27d4d0..08854a1298a84c257908d8752dd2bed4b2304176 100644 (file)
@@ -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 */
index c2a13e894016b11a8746f66d9ecb26668638ca35..746fa129a4f122d88731db11a7b83d7b65321da8 100644 (file)
@@ -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);
index 9c1681ffded48cf3e199ddab69ab451bc28c1dda..81fa95ea4af8f4524e37312f746839ce6b859f41 100644 (file)
@@ -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;
     }
   }
index 7ae2810a67b236ad30fd2c040f246c0944e28d0f..39975801d7e46911998be5577381593b95df7b39 100644 (file)
@@ -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
index cf06472772eddc6dfaf243b48c13352489bf0ba9..1e620fb99bc83d03838c59d4f8300963b31b8fd8 100644 (file)
@@ -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 */
 
index d3728d2c2a298ba18a29f04c4f9bc56107f7529b..425c35e86f014dfbc4c079166e7bb76c1d7ccdd7 100644 (file)
@@ -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 -------------------------------------- */