From: Holger Schemel Date: Wed, 2 Sep 2020 18:28:23 +0000 (+0200) Subject: fixed wrong eater content when loading native EM levels X-Git-Tag: 4.2.0.2~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=9e3b9d32e82663858c54a3884a2bb7680d458218;p=rocksndiamonds.git fixed wrong eater content when loading native EM levels This fixes a regression bug from commit baf962d5 that causes wrong eater content when loading native EM levels. Native Emerald Mine levels before version V5 only supported 28 eater objects, but some levels contained object codes above that, which are now mapped to empty space. (Before, they were mapped to the first 32 eater objects (28 objects, padded with four empty space objects) using "mod 32" operation, which lead to completely wrong eater objects for nearly all affected levels.) Mapping these eater objects to empty space is the best solution for now, as nearly all affected levels are solvable when using empty space objects instead (as most of these objects originally mapped to doors or letter elements). --- diff --git a/src/game_em/reademc.c b/src/game_em/reademc.c index e26289a3..5184d8d7 100644 --- a/src/game_em/reademc.c +++ b/src/game_em/reademc.c @@ -558,12 +558,12 @@ static const unsigned char map_v4[256] = 240,241,153,153, 153,153,153,153, 153,153,153,153, 153,153,153,153 // 240 }; -static const unsigned char map_v4_eater[32] = +static const unsigned char map_v4_eater[28] = { /* filter for v4 eater */ 128,18,2,0, 4,8,16,20, 28,37,41,45, 189,180,179,252, // 0 - 133,134,135,136, 146,147,175,65, 66,64,2,18, 128,128,128,128 // 16 + 133,134,135,136, 146,147,175,65, 66,64,2,18 // 16 }; static boolean filename_has_v1_format(char *filename) @@ -676,7 +676,7 @@ int cleanup_em_level(unsigned char *src, int length, char *filename) for (i = 0; i < 2048; i++) /* cave */ src[i] = map_v4[src[i]]; for (i = 2048; i < 2084; i++) /* eaters */ - src[i] = map_v4_eater[src[i] % 32]; + src[i] = map_v4_eater[src[i] < 28 ? src[i] : 0]; for (i = 2112; i < 2148; i++) /* eaters */ src[i] = src[i - 64];