From: Holger Schemel Date: Wed, 10 Apr 2024 16:46:52 +0000 (+0200) Subject: fixed empty default level according to default game engine type X-Git-Tag: 4.4.0.0-test-1~76 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fcdf2e3609be480300b60bba21e3257c666b8fdd;p=rocksndiamonds.git fixed empty default level according to default game engine type --- diff --git a/src/files.c b/src/files.c index 38f14258..2694c2d9 100644 --- a/src/files.c +++ b/src/files.c @@ -2334,6 +2334,11 @@ void setElementChangeInfoToDefaults(struct ElementChangeInfo *change) static void setLevelInfoToDefaults_Level(struct LevelInfo *level) { + boolean add_border = FALSE; + int x1 = 0; + int y1 = 0; + int x2 = STD_LEV_FIELDX - 1; + int y2 = STD_LEV_FIELDY - 1; int i, x, y; li = *level; // copy level data into temporary buffer @@ -2372,15 +2377,35 @@ static void setLevelInfoToDefaults_Level(struct LevelInfo *level) // set default game engine type level->game_engine_type = setup.default_game_engine_type; + // some game engines should have a default playfield with border elements + if (level->game_engine_type == GAME_ENGINE_TYPE_BD || + level->game_engine_type == GAME_ENGINE_TYPE_EM || + level->game_engine_type == GAME_ENGINE_TYPE_SP) + { + add_border = TRUE; + x1++; + y1++; + x2--; + y2--; + } + // set level playfield to playable default level with player and exit for (x = 0; x < MAX_LEV_FIELDX; x++) + { for (y = 0; y < MAX_LEV_FIELDY; y++) - level->field[x][y] = EL_SAND; + { + if (add_border && (x == 0 || x == STD_LEV_FIELDX - 1 || + y == 0 || y == STD_LEV_FIELDY - 1)) + level->field[x][y] = getEngineElement(EL_STEELWALL); + else + level->field[x][y] = getEngineElement(EL_SAND); + } + } - level->field[0][0] = EL_PLAYER_1; - level->field[STD_LEV_FIELDX - 1][STD_LEV_FIELDY - 1] = EL_EXIT_CLOSED; + level->field[x1][y1] = getEngineElement(EL_PLAYER_1); + level->field[x2][y2] = getEngineElement(EL_EXIT_CLOSED); - BorderElement = EL_STEELWALL; + BorderElement = getEngineElement(EL_STEELWALL); // detect custom elements when loading them level->file_has_custom_elements = FALSE; diff --git a/src/tools.c b/src/tools.c index d83cb75a..1fe6fccc 100644 --- a/src/tools.c +++ b/src/tools.c @@ -6012,6 +6012,88 @@ static void HandleToolButtons(struct GadgetInfo *gi) request_gadget_id = gi->custom_id; } +static int getEngineElement_Ext(int element, int game_engine_type, boolean is_drawing_element) +{ + int el_empty; + int el_player; + int el_sand; + int el_wall; + int el_steelwall; + int el_exit_closed; + + if (game_engine_type == -1) + game_engine_type = level.game_engine_type; + + if (level.game_engine_type == GAME_ENGINE_TYPE_BD) + { + el_empty = EL_EMPTY; + el_player = EL_BD_PLAYER; + el_sand = EL_BD_SAND; + el_wall = EL_BD_WALL; + el_steelwall = EL_BD_STEELWALL; + el_exit_closed = EL_BD_EXIT_CLOSED; + } + else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + { + el_empty = EL_EMPTY; + el_player = EL_PLAYER_1; + el_sand = EL_SAND; + el_wall = EL_WALL; + el_steelwall = EL_STEELWALL; + el_exit_closed = EL_EM_EXIT_CLOSED; + } + else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + { + el_empty = EL_EMPTY; + el_player = EL_SP_MURPHY; + el_sand = EL_SP_BASE; + el_wall = EL_SP_CHIP_SINGLE; + el_steelwall = EL_SP_HARDWARE_GRAY; + el_exit_closed = EL_SP_EXIT_CLOSED; + } + else if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + { + el_empty = EL_EMPTY; + el_player = EL_MM_MCDUFFIN_DOWN; + el_sand = EL_EMPTY; + el_wall = EL_MM_WOODEN_WALL; + el_steelwall = EL_MM_STEEL_WALL; + el_exit_closed = EL_MM_EXIT_CLOSED; + + if (is_drawing_element) + { + el_wall = EL_MM_MIRROR_START; + el_sand = EL_MM_WOODEN_WALL; + } + } + else + { + el_empty = EL_EMPTY; + el_player = EL_PLAYER_1; + el_sand = EL_SAND; + el_wall = EL_WALL; + el_steelwall = EL_STEELWALL; + el_exit_closed = EL_EXIT_CLOSED; + } + + return (element == EL_EMPTY ? el_empty : + element == EL_PLAYER_1 ? el_player : + element == EL_SAND ? el_sand : + element == EL_WALL ? el_wall : + element == EL_STEELWALL ? el_steelwall : + element == EL_EXIT_CLOSED ? el_exit_closed : EL_EMPTY); +} + +int getEngineElement(int element) +{ + return getEngineElement_Ext(element, -1, FALSE); +} + +int getDrawingElement(int element) +{ + return getEngineElement_Ext(element, -1, TRUE); +} + static struct Mapping_BD_to_RND_object { int element_bd; diff --git a/src/tools.h b/src/tools.h index afad2e37..cc503c0a 100644 --- a/src/tools.h +++ b/src/tools.h @@ -229,6 +229,9 @@ void UndrawSpecialEditorDoor(void); void CreateToolButtons(void); void FreeToolButtons(void); +int getEngineElement(int); +int getDrawingElement(int); + int map_element_RND_to_BD_cave(int); int map_element_RND_to_BD_effect(int, int); int map_element_BD_to_RND_cave(int);