From: Holger Schemel Date: Sat, 18 Feb 2017 15:09:07 +0000 (+0100) Subject: fixed mapping level file game elements between RND and MM formats (again) X-Git-Tag: 4.1.0.0~210 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2f383683929484fed45a21020ae241302ddd0ecd;p=rocksndiamonds.git fixed mapping level file game elements between RND and MM formats (again) --- diff --git a/src/game_mm/export.h b/src/game_mm/export.h index 5ca618cd..ede401f3 100644 --- a/src/game_mm/export.h +++ b/src/game_mm/export.h @@ -31,23 +31,24 @@ #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 /* ------------------------------------------------------------------------- */ diff --git a/src/game_mm/mm_main.h b/src/game_mm/mm_main.h index b553a1f8..f20a412d 100644 --- a/src/game_mm/mm_main.h +++ b/src/game_mm/mm_main.h @@ -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 diff --git a/src/game_mm/mm_tools.c b/src/game_mm/mm_tools.c index 5c67bbe4..fc35608b 100644 --- a/src/game_mm/mm_tools.c +++ b/src/game_mm/mm_tools.c @@ -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: diff --git a/src/main.h b/src/main.h index 5a1b3f77..8b09f5d9 100644 --- a/src/main.h +++ b/src/main.h @@ -1487,6 +1487,8 @@ #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) @@ -1618,7 +1620,10 @@ #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 @@ -1829,7 +1834,8 @@ #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 diff --git a/src/tools.c b/src/tools.c index 151fd94b..165120c0 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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); }