added more support for native Boulder Dash game engine code
authorHolger Schemel <info@artsoft.org>
Sat, 23 Dec 2023 13:02:51 +0000 (14:02 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 18 Feb 2024 14:57:39 +0000 (15:57 +0100)
src/editor.c
src/files.c
src/game_bd/export.h
src/main.h

index 671ac61de7551324c23e7c14ecf4d6dd8b83eb3d..5160b02fa26407e62147577176c9f63310352132 100644 (file)
@@ -5859,6 +5859,22 @@ static void ReinitializeElementList_EnableSections(void)
     setup_editor_el_mirror_magic       = FALSE;
     setup_editor_el_deflektor          = FALSE;
   }
+  else if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
+  {
+    setup_editor_el_emerald_mine       = FALSE;
+    setup_editor_el_emerald_mine_club  = FALSE;
+    setup_editor_el_more               = FALSE;
+    setup_editor_el_sokoban            = FALSE;
+    setup_editor_el_supaplex           = FALSE;
+    setup_editor_el_diamond_caves      = FALSE;
+    setup_editor_el_dx_boulderdash     = FALSE;
+    setup_editor_el_mirror_magic       = FALSE;
+    setup_editor_el_deflektor          = FALSE;
+    setup_editor_el_chars              = FALSE;
+    setup_editor_el_steel_chars                = FALSE;
+
+    setup_editor_el_custom             = FALSE;
+  }
   else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
   {
     setup_editor_el_boulderdash                = FALSE;
@@ -12766,6 +12782,7 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
       lev_fieldx = level.fieldx = brush_width;
       lev_fieldy = level.fieldy = brush_height;
 
+      boolean use_bd_engine = TRUE;
       boolean use_em_engine = TRUE;
       boolean use_sp_engine = TRUE;
       boolean use_mm_engine = TRUE;
@@ -12776,6 +12793,9 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
        {
          int element = Tile[x][y];
 
+         if (!IS_BD_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
+           use_bd_engine = FALSE;
+
          if (!IS_EM_ELEMENT(element) && !IS_PLAYER_ELEMENT(element))
            use_em_engine = FALSE;
 
@@ -12787,7 +12807,8 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
        }
       }
 
-      level.game_engine_type = (use_em_engine ? GAME_ENGINE_TYPE_EM :
+      level.game_engine_type = (use_bd_engine ? GAME_ENGINE_TYPE_BD :
+                               use_em_engine ? GAME_ENGINE_TYPE_EM :
                                use_sp_engine ? GAME_ENGINE_TYPE_SP :
                                use_mm_engine ? GAME_ENGINE_TYPE_MM :
                                GAME_ENGINE_TYPE_RND);
index 3480ed7458e11af0d36f8b1989f1a3f8c687448b..994d854dc798cc24220323457d618165f1ad58c6 100644 (file)
@@ -3650,6 +3650,27 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level,
 }
 
 
+// ----------------------------------------------------------------------------
+// functions for loading BD level
+// ----------------------------------------------------------------------------
+
+static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
+{
+  struct LevelInfo_BD *level_bd = level->native_bd_level;
+
+  level_bd->width  = MIN(level->fieldx, MAX_PLAYFIELD_WIDTH);
+  level_bd->height = MIN(level->fieldy, MAX_PLAYFIELD_HEIGHT);
+}
+
+static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
+{
+  struct LevelInfo_BD *level_bd = level->native_bd_level;
+
+  level->fieldx = MIN(level_bd->width,  MAX_LEV_FIELDX);
+  level->fieldy = MIN(level_bd->height, MAX_LEV_FIELDY);
+}
+
+
 // ----------------------------------------------------------------------------
 // functions for loading EM level
 // ----------------------------------------------------------------------------
@@ -6323,7 +6344,9 @@ static void LoadLevelFromFileInfo_MM(struct LevelInfo *level,
 
 void CopyNativeLevel_RND_to_Native(struct LevelInfo *level)
 {
-  if (level->game_engine_type == GAME_ENGINE_TYPE_EM)
+  if (level->game_engine_type == GAME_ENGINE_TYPE_BD)
+    CopyNativeLevel_RND_to_BD(level);
+  else if (level->game_engine_type == GAME_ENGINE_TYPE_EM)
     CopyNativeLevel_RND_to_EM(level);
   else if (level->game_engine_type == GAME_ENGINE_TYPE_SP)
     CopyNativeLevel_RND_to_SP(level);
@@ -6333,7 +6356,9 @@ void CopyNativeLevel_RND_to_Native(struct LevelInfo *level)
 
 void CopyNativeLevel_Native_to_RND(struct LevelInfo *level)
 {
-  if (level->game_engine_type == GAME_ENGINE_TYPE_EM)
+  if (level->game_engine_type == GAME_ENGINE_TYPE_BD)
+    CopyNativeLevel_BD_to_RND(level);
+  else if (level->game_engine_type == GAME_ENGINE_TYPE_EM)
     CopyNativeLevel_EM_to_RND(level);
   else if (level->game_engine_type == GAME_ENGINE_TYPE_SP)
     CopyNativeLevel_SP_to_RND(level);
index 54a85d5aee5cf9167fc6e7bd7f13e05979751365..07d3ff3f12b0c51050e3dd4a392072c4ef62a515 100644 (file)
@@ -5,11 +5,13 @@
 // functions and definitions exported from game_bd to main program
 // ============================================================================
 
+
 // ----------------------------------------------------------------------------
 // constant definitions
 // ----------------------------------------------------------------------------
 
-// ...
+#define BD_MAX_CAVE_WIDTH              MAX_PLAYFIELD_WIDTH
+#define BD_MAX_CAVE_HEIGHT             MAX_PLAYFIELD_HEIGHT
 
 
 // ----------------------------------------------------------------------------
 
 struct GameInfo_BD
 {
+  boolean level_solved;
+  boolean game_over;
+
+  // needed for updating panel
+  int time_played;
+  int gems_still_needed;
+  int score;
 };
 
 struct LevelInfo_BD
 {
+  int width;
+  int height;
+
+  int cave[BD_MAX_CAVE_WIDTH][BD_MAX_CAVE_HEIGHT];
 };
 
 struct EngineSnapshotInfo_BD
index 91c9e81ac7bd567b91dfc10dcc331318aaf64c6c..497a9a769b87ae9f41eab67f3eaca77e12ecbe08 100644 (file)
@@ -21,6 +21,7 @@
 #include <fcntl.h>
 
 #include "libgame/libgame.h"
+#include "game_bd/game_bd.h"
 #include "game_em/game_em.h"
 #include "game_sp/game_sp.h"
 #include "game_mm/game_mm.h"