From: Holger Schemel Date: Wed, 29 Jan 2020 16:36:28 +0000 (+0100) Subject: changed storing native EM cave without internal border elements X-Git-Tag: 4.2.0.0~166 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=48e1901624a8e50765f16a6825ab0ccb7cfe819a;p=rocksndiamonds.git changed storing native EM cave without internal border elements The internal representaion of a native Emerald Mine cave (level) does not contain surrounding internal game engine elements anymore now (which are only needed for game engine logic when playing the level). The stored player positions were adjusted accordingly. --- diff --git a/src/files.c b/src/files.c index 0c0f2f9b..3539e822 100644 --- a/src/files.c +++ b/src/files.c @@ -3519,8 +3519,8 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) struct PLAYER **ply = level_em->ply; int i, j, x, y; - lev->width = MIN(level->fieldx, EM_MAX_CAVE_BUFFER_WIDTH); - lev->height = MIN(level->fieldy, EM_MAX_CAVE_BUFFER_HEIGHT); + lev->width = MIN(level->fieldx, MAX_PLAYFIELD_WIDTH); + lev->height = MIN(level->fieldy, MAX_PLAYFIELD_HEIGHT); lev->time_seconds = level->time; lev->required_initial = level->gems_needed; @@ -3574,15 +3574,15 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) map_android_clone_elements_RND_to_EM(level); // first fill the complete playfield with the default border element - for (y = 0; y < EM_MAX_CAVE_BUFFER_HEIGHT; y++) - for (x = 0; x < EM_MAX_CAVE_BUFFER_WIDTH; x++) + for (y = 0; y < EM_MAX_CAVE_HEIGHT; y++) + for (x = 0; x < EM_MAX_CAVE_WIDTH; x++) level_em->cave[x][y] = Zborder; if (BorderElement == EL_STEELWALL) { for (y = 0; y < lev->height + 2; y++) for (x = 0; x < lev->width + 2; x++) - level_em->cave[x + 1][y + 1] = map_element_RND_to_EM(EL_STEELWALL); + level_em->cave[x][y] = map_element_RND_to_EM(EL_STEELWALL); } // then copy the real level contents from level file into the playfield @@ -3590,8 +3590,8 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) { int new_element = map_element_RND_to_EM(level->field[x][y]); int offset = (BorderElement == EL_STEELWALL ? 1 : 0); - int xx = x + 1 + offset; - int yy = y + 1 + offset; + int xx = x + offset; + int yy = y + offset; if (level->field[x][y] == EL_AMOEBA_DEAD) new_element = map_element_RND_to_EM(EL_AMOEBA_WET); @@ -3601,8 +3601,8 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) for (i = 0; i < MAX_PLAYERS; i++) { - ply[i]->x_initial = 0; - ply[i]->y_initial = 0; + ply[i]->x_initial = -1; + ply[i]->y_initial = -1; } // initialize player positions and delete players from the playfield @@ -3612,8 +3612,8 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) { int player_nr = GET_PLAYER_NR(level->field[x][y]); int offset = (BorderElement == EL_STEELWALL ? 1 : 0); - int xx = x + 1 + offset; - int yy = y + 1 + offset; + int xx = x + offset; + int yy = y + offset; ply[player_nr]->x_initial = xx; ply[player_nr]->y_initial = yy; @@ -3705,7 +3705,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 + 1][y + 1]); + int new_element = map_element_EM_to_RND(level_em->cave[x][y]); if (new_element == EL_AMOEBA_WET && level->amoeba_speed == 0) new_element = EL_AMOEBA_DEAD; @@ -3717,8 +3717,8 @@ static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) { // in case of all players set to the same field, use the first player int nr = MAX_PLAYERS - i - 1; - int jx = ply[nr]->x_initial - 1; - int jy = ply[nr]->y_initial - 1; + int jx = ply[nr]->x_initial; + int jy = ply[nr]->y_initial; if (jx != -1 && jy != -1) level->field[jx][jy] = EL_PLAYER_1 + nr; diff --git a/src/game_em/cave.c b/src/game_em/cave.c index b89c42f3..cc863029 100644 --- a/src/game_em/cave.c +++ b/src/game_em/cave.c @@ -23,8 +23,8 @@ void setLevelInfoToDefaults_EM(void) for (i = 0; i < MAX_PLAYERS; i++) { - ply[i].x_initial = 0; - ply[i].y_initial = 0; + ply[i].x_initial = -1; + ply[i].y_initial = -1; } lev.lenses_cnt_initial = 0; diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 996f0d21..0b3f05aa 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -643,8 +643,8 @@ void convert_em_level(unsigned char *src, int file_version) for (i = 0; i < 2; i++) { temp = src[0x830 + i * 2] << 8 | src[0x831 + i * 2]; - ply[i].x_initial = (temp & 63) + 1; - ply[i].y_initial = (temp >> 6 & 31) + 1; + ply[i].x_initial = (temp & 63); + ply[i].y_initial = (temp >> 6 & 31); } temp = (src[0x834] << 8 | src[0x835]) * 28; @@ -911,15 +911,15 @@ 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_BUFFER_HEIGHT; y++) - for (x = 0; x < CAVE_BUFFER_WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) native_em_level.cave[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 + 1][y + 1] = + native_em_level.cave[x][y] = get_em_element(src[temp++], file_version); /* at last, set the two players at their positions in the playfield */ @@ -938,9 +938,10 @@ void prepare_em_level(void) /* reset all runtime variables to their initial values */ - for (y = 0; y < CAVE_BUFFER_HEIGHT; y++) - for (x = 0; x < CAVE_BUFFER_WIDTH; x++) - lev.cave[x][y] = native_em_level.cave[x][y]; + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) + lev.cave[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] = + native_em_level.cave[x][y]; for (y = 0; y < CAVE_BUFFER_HEIGHT; y++) for (x = 0; x < CAVE_BUFFER_WIDTH; x++) @@ -989,7 +990,7 @@ void prepare_em_level(void) ply[i].exists = 0; ply[i].alive_initial = FALSE; - if (ply[i].x_initial > 0 && ply[i].y_initial > 0) + if (ply[i].x_initial != -1 && ply[i].y_initial != -1) { ply[i].exists = 1; @@ -1021,7 +1022,9 @@ void prepare_em_level(void) native_em_level.cave[x][y] = Xblank; - lev.cave[x][y] = lev.next[x][y] = lev.draw[x][y] = Xblank; + lev.cave[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] = Xblank; + lev.next[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] = Xblank; + lev.draw[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] = Xblank; } } } @@ -1034,8 +1037,8 @@ void prepare_em_level(void) ply[i].dynamite_cnt = 0; ply[i].keys = 0; ply[i].anim = 0; - ply[i].oldx = ply[i].x = ply[i].x_initial; - ply[i].oldy = ply[i].y = ply[i].y_initial; + ply[i].oldx = ply[i].x = ply[i].x_initial + CAVE_BUFFER_XOFFSET; + ply[i].oldy = ply[i].y = ply[i].y_initial + CAVE_BUFFER_YOFFSET; ply[i].last_move_dir = MV_NONE; ply[i].joy_n = ply[i].joy_e = ply[i].joy_s = ply[i].joy_w = 0; ply[i].joy_snap = ply[i].joy_drop = 0; diff --git a/src/game_em/export.h b/src/game_em/export.h index 5ba8c5ce..9c0ff052 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -12,8 +12,8 @@ // constant definitions // ---------------------------------------------------------------------------- -#define EM_MAX_CAVE_BUFFER_WIDTH CAVE_BUFFER_WIDTH -#define EM_MAX_CAVE_BUFFER_HEIGHT CAVE_BUFFER_HEIGHT +#define EM_MAX_CAVE_WIDTH CAVE_WIDTH +#define EM_MAX_CAVE_HEIGHT CAVE_HEIGHT // ---------------------------------------------------------------------------- @@ -44,7 +44,7 @@ struct LevelInfo_EM { int file_version; - short cave[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT]; + short cave[CAVE_WIDTH][CAVE_HEIGHT]; struct LEVEL *lev; struct PLAYER *ply[MAX_PLAYERS];