X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ffiles.c;h=38f50f8808f56b4f291bd4d10182022acb8aaedb;hb=73dd81c85be90e466493bcc6f45c402d29bc7f20;hp=c684ab843bd5e854d309063eb5bd7c3b1d4ae616;hpb=da8f8eaa9d466f33d94ff884230a613b3f239700;p=rocksndiamonds.git diff --git a/src/files.c b/src/files.c index c684ab84..38f50f88 100644 --- a/src/files.c +++ b/src/files.c @@ -114,6 +114,8 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) int i, j, x, y; + level->native_em_level = &native_em_level; + level->game_engine_type = GAME_ENGINE_TYPE_RND; level->file_version = FILE_VERSION_ACTUAL; @@ -1765,6 +1767,128 @@ static void OLD_LoadLevelFromFileInfo_EM(struct LevelInfo *level, #else +void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) +{ + struct LevelInfo_EM *level_em = level->native_em_level; + struct LEVEL *lev = level_em->lev; + struct PLAYER *ply1 = level_em->ply1; + struct PLAYER *ply2 = level_em->ply2; + int i, x, y; + + lev->width = MIN(level->fieldx, EM_MAX_CAVE_WIDTH); + lev->height = MIN(level->fieldy, EM_MAX_CAVE_HEIGHT); + + lev->time_initial = level->time; + lev->required_initial = level->gems_needed; + + lev->emerald_score = level->score[SC_EMERALD]; + lev->diamond_score = level->score[SC_DIAMOND]; + lev->alien_score = level->score[SC_ROBOT]; + lev->tank_score = level->score[SC_SPACESHIP]; + lev->bug_score = level->score[SC_BUG]; + lev->eater_score = level->score[SC_YAMYAM]; + lev->nut_score = level->score[SC_NUT]; + lev->dynamite_score = level->score[SC_DYNAMITE]; + lev->key_score = level->score[SC_TIME_BONUS]; /* ??? CHECK THIS */ + + for (i = 0; i < MAX_ELEMENT_CONTENTS; i++) + for (y = 0; y < 3; y++) + for (x = 0; x < 3; x++) + lev->eater_array[i][y * 3 + x] = + map_element_RND_to_EM(level->yamyam_content[i][x][y]); + + lev->amoeba_time = level->amoeba_speed; + lev->wonderwall_time_initial = level->time_magic_wall; + lev->wheel_time = level->time_wheel; + + /* 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; + + /* then copy the real level contents from level file into the playfield */ + for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++) + { + int new_element = map_element_RND_to_EM(level->field[x][y]); + + level_em->cave[x + 1][y + 1] = new_element; + } + + ply1->x_initial = 0; + ply1->y_initial = 0; + + ply2->x_initial = 0; + ply2->y_initial = 0; + + /* at last, set the two players to their positions in the playfield */ + for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++) + { + if (level->field[x][y] == EL_PLAYER_1) + { + ply1->x_initial = x + 1; + ply1->y_initial = y + 1; + } + else if (level->field[x][y] == EL_PLAYER_2) + { + ply2->x_initial = x + 1; + ply2->y_initial = y + 1; + } + } +} + +void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) +{ + struct LevelInfo_EM *level_em = level->native_em_level; + struct LEVEL *lev = level_em->lev; + struct PLAYER *ply1 = level_em->ply1; + struct PLAYER *ply2 = level_em->ply2; + int i, x, y; + + level->fieldx = MIN(lev->width, MAX_LEV_FIELDX); + level->fieldy = MIN(lev->height, MAX_LEV_FIELDY); + + level->time = lev->time_initial; + level->gems_needed = lev->required_initial; + + sprintf(level->name, "Level %d", level->file_info.nr); + + level->score[SC_EMERALD] = lev->emerald_score; + level->score[SC_DIAMOND] = lev->diamond_score; + level->score[SC_ROBOT] = lev->alien_score; + level->score[SC_SPACESHIP] = lev->tank_score; + level->score[SC_BUG] = lev->bug_score; + level->score[SC_YAMYAM] = lev->eater_score; + level->score[SC_NUT] = lev->nut_score; + level->score[SC_DYNAMITE] = lev->dynamite_score; + level->score[SC_TIME_BONUS] = lev->key_score; /* ??? CHECK THIS */ + + level->num_yamyam_contents = MAX_ELEMENT_CONTENTS; + + for (i = 0; i < level->num_yamyam_contents; i++) + for (y = 0; y < 3; y++) + for (x = 0; x < 3; x++) + level->yamyam_content[i][x][y] = + map_element_EM_to_RND(lev->eater_array[i][y * 3 + x]); + + level->amoeba_speed = lev->amoeba_time; + level->time_magic_wall = lev->wonderwall_time_initial; + level->time_wheel = lev->wheel_time; + + 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]); + + if (new_element == EL_AMOEBA_WET && level->amoeba_speed == 0) + new_element = EL_AMOEBA_DEAD; + + level->field[x][y] = new_element; + } + + /* if both players are set to the same field, use the first player */ + level->field[ply2->x_initial - 1][ply2->y_initial - 1] = EL_PLAYER_2; + level->field[ply1->x_initial - 1][ply1->y_initial - 1] = EL_PLAYER_1; +} + static void LoadLevelFromFileInfo_EM(struct LevelInfo *level, struct LevelFileInfo *level_file_info) { @@ -1774,6 +1898,18 @@ static void LoadLevelFromFileInfo_EM(struct LevelInfo *level, #endif +void CopyNativeLevel_RND_to_Native(struct LevelInfo *level) +{ + if (level->game_engine_type == GAME_ENGINE_TYPE_EM) + CopyNativeLevel_RND_to_EM(level); +} + +void CopyNativeLevel_Native_to_RND(struct LevelInfo *level) +{ + if (level->game_engine_type == GAME_ENGINE_TYPE_EM) + CopyNativeLevel_EM_to_RND(level); +} + /* ------------------------------------------------------------------------- */ /* functions for loading SP level */ @@ -2147,6 +2283,8 @@ void LoadLevelFromFileInfo(struct LevelInfo *level, if (level->game_engine_type == GAME_ENGINE_TYPE_UNKNOWN) level->game_engine_type = GAME_ENGINE_TYPE_RND; + + CopyNativeLevel_Native_to_RND(level); } void LoadLevelFromFilename(struct LevelInfo *level, char *filename) @@ -3819,18 +3957,19 @@ void SaveScore(int nr) /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 #define SETUP_TOKEN_EDITOR_EL_EMERALD_MINE 1 -#define SETUP_TOKEN_EDITOR_EL_MORE 2 -#define SETUP_TOKEN_EDITOR_EL_SOKOBAN 3 -#define SETUP_TOKEN_EDITOR_EL_SUPAPLEX 4 -#define SETUP_TOKEN_EDITOR_EL_DIAMOND_CAVES 5 -#define SETUP_TOKEN_EDITOR_EL_DX_BOULDERDASH 6 -#define SETUP_TOKEN_EDITOR_EL_CHARS 7 -#define SETUP_TOKEN_EDITOR_EL_CUSTOM 8 -#define SETUP_TOKEN_EDITOR_EL_CUSTOM_MORE 9 -#define SETUP_TOKEN_EDITOR_EL_HEADLINES 10 -#define SETUP_TOKEN_EDITOR_EL_USER_DEFINED 11 - -#define NUM_EDITOR_SETUP_TOKENS 12 +#define SETUP_TOKEN_EDITOR_EL_EMERALD_MINE_CLUB 2 +#define SETUP_TOKEN_EDITOR_EL_MORE 3 +#define SETUP_TOKEN_EDITOR_EL_SOKOBAN 4 +#define SETUP_TOKEN_EDITOR_EL_SUPAPLEX 5 +#define SETUP_TOKEN_EDITOR_EL_DIAMOND_CAVES 6 +#define SETUP_TOKEN_EDITOR_EL_DX_BOULDERDASH 7 +#define SETUP_TOKEN_EDITOR_EL_CHARS 8 +#define SETUP_TOKEN_EDITOR_EL_CUSTOM 9 +#define SETUP_TOKEN_EDITOR_EL_CUSTOM_MORE 10 +#define SETUP_TOKEN_EDITOR_EL_HEADLINES 11 +#define SETUP_TOKEN_EDITOR_EL_USER_DEFINED 12 + +#define NUM_EDITOR_SETUP_TOKENS 13 /* shortcut setup */ #define SETUP_TOKEN_SHORTCUT_SAVE_GAME 0 @@ -3908,6 +4047,7 @@ static struct TokenInfo editor_setup_tokens[] = { { TYPE_SWITCH, &sei.el_boulderdash, "editor.el_boulderdash" }, { TYPE_SWITCH, &sei.el_emerald_mine, "editor.el_emerald_mine" }, + { TYPE_SWITCH, &sei.el_emerald_mine_club,"editor.el_emerald_mine_club"}, { TYPE_SWITCH, &sei.el_more, "editor.el_more" }, { TYPE_SWITCH, &sei.el_sokoban, "editor.el_sokoban" }, { TYPE_SWITCH, &sei.el_supaplex, "editor.el_supaplex" }, @@ -4004,16 +4144,17 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->override_level_sounds = FALSE; si->override_level_music = FALSE; - si->editor.el_boulderdash = TRUE; - si->editor.el_emerald_mine = TRUE; - si->editor.el_more = TRUE; - si->editor.el_sokoban = TRUE; - si->editor.el_supaplex = TRUE; - si->editor.el_diamond_caves = TRUE; - si->editor.el_dx_boulderdash = TRUE; - si->editor.el_chars = TRUE; - si->editor.el_custom = TRUE; - si->editor.el_custom_more = FALSE; + si->editor.el_boulderdash = TRUE; + si->editor.el_emerald_mine = TRUE; + si->editor.el_emerald_mine_club = TRUE; + si->editor.el_more = TRUE; + si->editor.el_sokoban = TRUE; + si->editor.el_supaplex = TRUE; + si->editor.el_diamond_caves = TRUE; + si->editor.el_dx_boulderdash = TRUE; + si->editor.el_chars = TRUE; + si->editor.el_custom = TRUE; + si->editor.el_custom_more = FALSE; si->editor.el_headlines = TRUE; si->editor.el_user_defined = FALSE;