From 5b0c9b194a5a219450d09a84131d4feaba5c4ff1 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 13 Feb 2020 02:04:22 +0100 Subject: [PATCH] moved initial cave data to level structure for EM engine --- src/files.c | 8 ++++---- src/game_em/convert.c | 4 ++-- src/game_em/emerald.h | 2 ++ src/game_em/export.h | 2 -- src/game_em/reademc.c | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/files.c b/src/files.c index b2856c69..04151ff1 100644 --- a/src/files.c +++ b/src/files.c @@ -3575,7 +3575,7 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) // first fill the complete playfield with the default border element for (y = 0; y < EM_MAX_CAVE_HEIGHT; y++) for (x = 0; x < EM_MAX_CAVE_WIDTH; x++) - level_em->cave[x][y] = Zborder; + cav->cave_raw[x][y] = Zborder; // then copy the real level contents from level file into the playfield for (y = 0; y < cav->height; y++) for (x = 0; x < cav->width; x++) @@ -3585,7 +3585,7 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) if (level->field[x][y] == EL_AMOEBA_DEAD) new_element = map_element_RND_to_EM(EL_AMOEBA_WET); - level_em->cave[x][y] = new_element; + cav->cave_raw[x][y] = new_element; } for (i = 0; i < MAX_PLAYERS; i++) @@ -3604,7 +3604,7 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) cav->player_x[player_nr] = x; cav->player_y[player_nr] = y; - level_em->cave[x][y] = map_element_RND_to_EM(EL_EMPTY); + cav->cave_raw[x][y] = map_element_RND_to_EM(EL_EMPTY); } } } @@ -3684,7 +3684,7 @@ static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) // convert the playfield (some elements need special treatment) for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) { - int new_element = map_element_EM_to_RND(level_em->cave[x][y]); + int new_element = map_element_EM_to_RND(cav->cave_raw[x][y]); if (new_element == EL_AMOEBA_WET && level->amoeba_speed == 0) new_element = EL_AMOEBA_DEAD; diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 581c93ee..56075c2b 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -38,7 +38,7 @@ void prepare_em_level(void) for (x = 0; x < lev.width; x++) for (y = 0; y < lev.height; y++) - lev.cave[lev.left + x][lev.top + y] = native_em_level.cave[x][y]; + lev.cave[lev.left + x][lev.top + y] = lev.cave_raw[x][y]; for (x = lev.left; x < lev.right; x++) for (y = lev.top; y < lev.bottom; y++) @@ -114,7 +114,7 @@ void prepare_em_level(void) int x = lev.player_x[i]; int y = lev.player_y[i]; - native_em_level.cave[x][y] = Xblank; + lev.cave_raw[x][y] = Xblank; lev.cave[lev.left + x][lev.top + y] = Xblank; lev.next[lev.left + x][lev.top + y] = Xblank; diff --git a/src/game_em/emerald.h b/src/game_em/emerald.h index 7806f3e6..8e17761d 100644 --- a/src/game_em/emerald.h +++ b/src/game_em/emerald.h @@ -707,6 +707,8 @@ struct LEVEL short ball_array[8][8]; /* ball data */ short android_array[TILE_MAX]; /* android clone table */ + short cave_raw[CAVE_WIDTH][CAVE_HEIGHT]; + short cavebuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT]; short nextbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT]; short drawbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT]; diff --git a/src/game_em/export.h b/src/game_em/export.h index 7379479f..a1a0d10b 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -47,8 +47,6 @@ struct LevelInfo_EM { int file_version; - short cave[CAVE_WIDTH][CAVE_HEIGHT]; - struct LEVEL *cav; }; diff --git a/src/game_em/reademc.c b/src/game_em/reademc.c index f8f10124..ed86409b 100644 --- a/src/game_em/reademc.c +++ b/src/game_em/reademc.c @@ -456,18 +456,18 @@ void convert_em_level(unsigned char *src, int file_version) /* first fill the complete playfield with the default border element */ for (y = 0; y < CAVE_HEIGHT; y++) for (x = 0; x < CAVE_WIDTH; x++) - native_em_level.cave[x][y] = Zborder; + lev.cave_raw[x][y] = Zborder; /* then copy the real level contents from level file into the playfield */ temp = 0; for (y = 0; y < lev.height; y++) for (x = 0; x < lev.width; x++) - native_em_level.cave[x][y] = map_emc[src[temp++]]; + lev.cave_raw[x][y] = map_emc[src[temp++]]; /* at last, set the two players at their positions in the playfield */ /* (native EM[C] levels always have exactly two players in a level) */ for (i = 0; i < 2; i++) - native_em_level.cave[lev.player_x[i]][lev.player_y[i]] = Zplayer; + lev.cave_raw[lev.player_x[i]][lev.player_y[i]] = Zplayer; native_em_level.file_version = file_version; } -- 2.34.1