fixed mapping level file game elements between RND and MM formats (again)
authorHolger Schemel <info@artsoft.org>
Sat, 18 Feb 2017 15:09:07 +0000 (16:09 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 23 Mar 2018 22:21:08 +0000 (23:21 +0100)
src/game_mm/export.h
src/game_mm/mm_main.h
src/game_mm/mm_tools.c
src/main.h
src/tools.c

index 5ca618cdd30a231cd35f544c37da81f14674dfd3..ede401f3071ff6e75e5688ce6dc0c90e1c90b48a 100644 (file)
 #define MM_MAX_LEVEL_AUTHOR_LEN                32
 
 
-#define EL_EMPTY_NATIVE_MM             0
-#define EL_DF_EMPTY_NATIVE_MM          304
+#define EL_MM_START_1_NATIVE           0
+#define EL_MM_END_1_NATIVE             155
 
-#define EL_MM_START_NATIVE_MM          0
-#define EL_MM_END_NATIVE_MM            430
+#define EL_MM_CHAR_START_NATIVE                160
+#define EL_MM_CHAR_END_NATIVE          239
 
-#define EL_CHAR_START_NATIVE_MM                160
-#define EL_CHAR_END_NATIVE_MM          239
+#define EL_MM_START_2_NATIVE           240
+#define EL_MM_END_2_NATIVE             430
 
-#define EL_DF_START_NATIVE_MM          240
-#define EL_DF_END_NATIVE_MM            355
+#define EL_MM_RUNTIME_START_NATIVE     500
+#define EL_MM_RUNTIME_END_NATIVE       504
 
-#define EL_MM_RUNTIME_START_NATIVE_MM  500
-#define EL_MM_RUNTIME_END_NATIVE_MM    504
+#define EL_MM_DUMMY_START_NATIVE       700
+#define EL_MM_DUMMY_END_NATIVE         709
 
-#define EL_MM_DUMMY_START_NATIVE_MM    700
-#define EL_MM_DUMMY_END_NATIVE_MM      709
+/* elements to be specially mapped */
+#define EL_MM_EMPTY_NATIVE             0
+#define EL_DF_EMPTY_NATIVE             304
 
 
 /* ------------------------------------------------------------------------- */
index b553a1f8756550e3a33807fb8c472ea6d0dc4de6..f20a412daa179a555758249f29ffd978580c1ce5 100644 (file)
@@ -317,6 +317,8 @@ extern int          num_element_info;
 */
 /* "real" level elements */
 #define EL_MM_START            0
+#define EL_MM_START_1          EL_MM_START
+
 #define EL_EMPTY               0
 #define EL_MIRROR_START                1
 #define EL_MIRROR_00           (EL_MIRROR_START + 0)
@@ -451,6 +453,8 @@ extern int          num_element_info;
 #define EL_GRID_WOOD_END       EL_GRID_WOOD_03
 #define EL_FUEL_EMPTY          155
 
+#define EL_MM_END_1            155
+
 #define EL_CHAR_START          160
 #define EL_CHAR_ASCII0         (EL_CHAR_START-32)
 #define EL_CHAR_AUSRUF         (EL_CHAR_ASCII0+33)
@@ -490,8 +494,10 @@ extern int         num_element_info;
                                 (x) == CHAR_BYTE_UMLAUT_U ? EL_CHAR_UE : \
                                 EL_CHAR_A + (x) - 'A')
 
+#define EL_MM_START_2          240
+
 /* elements for "Deflektor" style levels */
-#define EL_DF_START            240
+#define EL_DF_START            EL_MM_START_2
 
 #define EL_DF_MIRROR_START     EL_DF_START
 #define EL_DF_MIRROR_00                (EL_DF_MIRROR_START + 0)
@@ -639,7 +645,8 @@ extern int          num_element_info;
 #define EL_DF_STEEL_WALL       429
 #define EL_DF_WOODEN_WALL      430
 
-#define EL_MM_END              430
+#define EL_MM_END_2            430
+#define EL_MM_END              EL_MM_END_2
 
 /* "real" (and therefore drawable) runtime elements */
 #define EL_EXIT_OPENING                500
index 5c67bbe42b4b7b7e503111c2d43e329830832c40..fc35608b2ec006410e38b780a56f60b34d1885b5 100644 (file)
@@ -722,8 +722,25 @@ int get_rotated_element(int element, int step)
   return base_element + (element_phase + step + num_elements) % num_elements;
 }
 
+static int map_element(int element)
+{
+  switch (element)
+  {
+    case EL_WALL_STEEL:                return EL_STEEL_WALL;
+    case EL_WALL_WOOD:         return EL_WOODEN_WALL;
+    case EL_WALL_ICE:          return EL_ICE_WALL;
+    case EL_WALL_AMOEBA:       return EL_AMOEBA_WALL;
+    case EL_DF_WALL_STEEL:     return EL_DF_STEEL_WALL;
+    case EL_DF_WALL_WOOD:      return EL_DF_WOODEN_WALL;
+
+    default:                   return element;
+  }
+}
+
 int el2gfx(int element)
 {
+  element = map_element(element);
+
   switch (element)
   {
     case EL_LIGHTBALL:
index 5a1b3f77bd48b52300edbb15287eebfbec5fb557..8b09f5d9e0422115561225d61f876924b1abab11 100644 (file)
 #define EL_FROM_LEVEL_TEMPLATE         863
 
 #define EL_MM_START                    864
+#define EL_MM_START_1                  EL_MM_START
+
 #define EL_MM_EMPTY_SPACE              (EL_MM_START + 0)
 #define EL_MM_EMPTY                    EL_MM_EMPTY_SPACE
 #define EL_MM_MIRROR_START             (EL_MM_START + 1)
 #define EL_MM_WOODEN_GRID_FIXED_END    EL_MM_WOODEN_GRID_FIXED_03
 #define EL_MM_FUEL_EMPTY               (EL_MM_START + 155)
 
-#define EL_DF_START                    (EL_MM_START + 156)
+#define EL_MM_END_1                    (EL_MM_START + 155)
+#define EL_MM_START_2                  (EL_MM_START + 156)
+
+#define EL_DF_START                    EL_MM_START_2
 #define EL_DF_START2                   (EL_DF_START - 240)
 
 #define EL_DF_MIRROR_START             EL_DF_START
 #define EL_DF_STEEL_WALL               1209
 #define EL_DF_WOODEN_WALL              1210
 
-#define EL_MM_END                      (EL_DF_START2 + 430)
+#define EL_MM_END_2                    (EL_DF_START2 + 430)
+#define EL_MM_END                      EL_MM_END_2
 
 #define NUM_FILE_ELEMENTS              1211
 
index 151fd94b1f4baad0b403d3b5c72254d6fdb71f88..165120c050021a75ef5cc199d4118cbc396a762b 100644 (file)
@@ -7230,54 +7230,54 @@ int map_action_SP_to_RND(int action_sp)
 
 int map_element_RND_to_MM(int element_rnd)
 {
-  return (element_rnd >= EL_CHAR_START &&
-         element_rnd <= EL_CHAR_END ?
-         EL_CHAR_START_NATIVE_MM + element_rnd - EL_CHAR_START :
+  return (element_rnd >= EL_MM_START_1 &&
+         element_rnd <= EL_MM_END_1 ?
+         EL_MM_START_1_NATIVE + element_rnd - EL_MM_START_1 :
 
-         element_rnd >= EL_DF_START &&
-         element_rnd <= EL_DF_END ?
-         EL_DF_START_NATIVE_MM + element_rnd - EL_DF_START :
+         element_rnd >= EL_MM_START_2 &&
+         element_rnd <= EL_MM_END_2 ?
+         EL_MM_START_2_NATIVE + element_rnd - EL_MM_START_2 :
 
-         element_rnd >= EL_MM_START &&
-         element_rnd <= EL_MM_END ?
-         EL_MM_START_NATIVE_MM + element_rnd - EL_MM_START :
+         element_rnd >= EL_CHAR_START &&
+         element_rnd <= EL_CHAR_END ?
+         EL_MM_CHAR_START_NATIVE + element_rnd - EL_CHAR_START :
 
          element_rnd >= EL_MM_RUNTIME_START &&
          element_rnd <= EL_MM_RUNTIME_END ?
-         EL_MM_RUNTIME_START_NATIVE_MM + element_rnd - EL_MM_RUNTIME_START :
+         EL_MM_RUNTIME_START_NATIVE + element_rnd - EL_MM_RUNTIME_START :
 
          element_rnd >= EL_MM_DUMMY_START &&
          element_rnd <= EL_MM_DUMMY_END ?
-         EL_MM_DUMMY_START_NATIVE_MM + element_rnd - EL_MM_DUMMY_START :
+         EL_MM_DUMMY_START_NATIVE + element_rnd - EL_MM_DUMMY_START :
 
-         EL_EMPTY_NATIVE_MM);
+         EL_MM_EMPTY_NATIVE);
 }
 
 int map_element_MM_to_RND(int element_mm)
 {
-  return (element_mm == EL_EMPTY_NATIVE_MM ||
-         element_mm == EL_DF_EMPTY_NATIVE_MM ?
+  return (element_mm == EL_MM_EMPTY_NATIVE ||
+         element_mm == EL_DF_EMPTY_NATIVE ?
          EL_EMPTY :
 
-         element_mm >= EL_CHAR_START_NATIVE_MM &&
-         element_mm <= EL_CHAR_END_NATIVE_MM ?
-         EL_CHAR_START + element_mm - EL_CHAR_START_NATIVE_MM :
+         element_mm >= EL_MM_START_1_NATIVE &&
+         element_mm <= EL_MM_END_1_NATIVE ?
+         EL_MM_START_1 + element_mm - EL_MM_START_1_NATIVE :
 
-         element_mm >= EL_DF_START_NATIVE_MM &&
-         element_mm <= EL_DF_END_NATIVE_MM ?
-         EL_DF_START + element_mm - EL_DF_START_NATIVE_MM :
+         element_mm >= EL_MM_START_2_NATIVE &&
+         element_mm <= EL_MM_END_2_NATIVE ?
+         EL_MM_START_2 + element_mm - EL_MM_START_2_NATIVE :
 
-         element_mm >= EL_MM_START_NATIVE_MM &&
-         element_mm <= EL_MM_END_NATIVE_MM ?
-         EL_MM_START + element_mm - EL_MM_START_NATIVE_MM :
+         element_mm >= EL_MM_CHAR_START_NATIVE &&
+         element_mm <= EL_MM_CHAR_END_NATIVE ?
+         EL_CHAR_START + element_mm - EL_MM_CHAR_START_NATIVE :
 
-         element_mm >= EL_MM_RUNTIME_START_NATIVE_MM &&
-         element_mm <= EL_MM_RUNTIME_END_NATIVE_MM ?
-         EL_MM_RUNTIME_START + element_mm - EL_MM_RUNTIME_START_NATIVE_MM :
+         element_mm >= EL_MM_RUNTIME_START_NATIVE &&
+         element_mm <= EL_MM_RUNTIME_END_NATIVE ?
+         EL_MM_RUNTIME_START + element_mm - EL_MM_RUNTIME_START_NATIVE :
 
-         element_mm >= EL_MM_DUMMY_START_NATIVE_MM &&
-         element_mm <= EL_MM_DUMMY_END_NATIVE_MM ?
-         EL_MM_DUMMY_START + element_mm - EL_MM_DUMMY_START_NATIVE_MM :
+         element_mm >= EL_MM_DUMMY_START_NATIVE &&
+         element_mm <= EL_MM_DUMMY_END_NATIVE ?
+         EL_MM_DUMMY_START + element_mm - EL_MM_DUMMY_START_NATIVE :
 
          EL_EMPTY);
 }