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

index 2bbd5dc4f74a3bdb2f7c463f91a03685a3b3629a..b36ab4300229fe2590c0c495dde8f3657c55d8f2 100644 (file)
 #define MM_MAX_PLAYFIELD_SIZE          (MM_MAX_PLAYFIELD_WIDTH *       \
                                         MM_MAX_PLAYFIELD_HEIGHT)
 
-#define MAX_NUM_AMOEBA         100
-#define MAX_NUM_BEAMERS                8
+#define MAX_NUM_AMOEBA                 100
+#define MAX_NUM_BEAMERS                        8
 
-#define MAX_LASER_LEN          256
-#define MAX_LASER_ENERGY       100
-#define MAX_LASER_OVERLOAD     100
+#define MAX_LASER_LEN                  256
+#define MAX_LASER_ENERGY               100
+#define MAX_LASER_OVERLOAD             100
 
-#define MM_LEVEL_SCORE_ELEMENTS        16
+#define MM_LEVEL_SCORE_ELEMENTS                16
 
-#define MM_MAX_LEVEL_NAME_LEN  32
-#define MM_MAX_LEVEL_AUTHOR_LEN        32
+#define MM_MAX_LEVEL_NAME_LEN          32
+#define MM_MAX_LEVEL_AUTHOR_LEN                32
+
+
+#define EL_EMPTY_NATIVE_MM             0
+#define EL_DF_EMPTY_NATIVE_MM          304
+
+#define EL_MM_START_NATIVE_MM          0
+#define EL_MM_END_NATIVE_MM            430
+
+#define EL_CHAR_START_NATIVE_MM                160
+#define EL_CHAR_END_NATIVE_MM          239
+
+#define EL_DF_START_NATIVE_MM          240
+#define EL_DF_END_NATIVE_MM            355
+
+#define EL_MM_RUNTIME_START_NATIVE_MM  500
+#define EL_MM_RUNTIME_END_NATIVE_MM    504
+
+#define EL_MM_DUMMY_START_NATIVE_MM    700
+#define EL_MM_DUMMY_END_NATIVE_MM      709
 
 
 /* ------------------------------------------------------------------------- */
index fcc82f30f17919c995a146f877de3287c0607863..fb1fc5ed620303db01503aedfb186a2113a50884 100644 (file)
@@ -7230,12 +7230,56 @@ int map_action_SP_to_RND(int action_sp)
 
 int map_element_RND_to_MM(int element_rnd)
 {
-  return (element_rnd > 1000 ? element_rnd - 1000 : 0);
+  return (element_rnd >= EL_CHAR_START &&
+         element_rnd <= EL_CHAR_END ?
+         EL_CHAR_START_NATIVE_MM + element_rnd - EL_CHAR_START :
+
+         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 &&
+         element_rnd <= EL_MM_END ?
+         EL_MM_START_NATIVE_MM + element_rnd - EL_MM_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 :
+
+         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_EMPTY_NATIVE_MM);
 }
 
 int map_element_MM_to_RND(int element_mm)
 {
-  return 1000 + element_mm;
+  return (element_mm == EL_EMPTY_NATIVE_MM ||
+         element_mm == EL_DF_EMPTY_NATIVE_MM ?
+         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_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_NATIVE_MM &&
+         element_mm <= EL_MM_END_NATIVE_MM ?
+         EL_MM_START + element_mm - EL_MM_START_NATIVE_MM :
+
+         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_DUMMY_START_NATIVE_MM &&
+         element_mm <= EL_MM_DUMMY_END_NATIVE_MM ?
+         EL_MM_DUMMY_START + element_mm - EL_MM_DUMMY_START_NATIVE_MM :
+
+         EL_EMPTY);
 }
 
 int get_next_element(int element)