X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=f0f528ce1ca3093e12bdf3ca0538f21d616357f2;hb=f47cd4b09952aaf95d16542f6b53f2d8bf9e1d7d;hp=04067389c78194fc1ec30a5e7419f2bbe761e157;hpb=60aac4d0fa635b69e498dcb174f3fe9b2cacc1c9;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 04067389..f0f528ce 100644 --- a/src/init.c +++ b/src/init.c @@ -239,6 +239,11 @@ void InitGadgets() gadgets_initialized = TRUE; } +inline void InitElementSmallImagesScaledUp(int graphic) +{ + CreateImageWithSmallImages(graphic, graphic_info[graphic].scale_up_factor); +} + void InitElementSmallImages() { struct PropertyMapping *property_mapping = getImageListPropertyMapping(); @@ -247,17 +252,32 @@ void InitElementSmallImages() /* initialize normal images from static configuration */ for (i = 0; element_to_graphic[i].element > -1; i++) - CreateImageWithSmallImages(element_to_graphic[i].graphic); + InitElementSmallImagesScaledUp(element_to_graphic[i].graphic); /* initialize special images from static configuration */ for (i = 0; element_to_special_graphic[i].element > -1; i++) - CreateImageWithSmallImages(element_to_special_graphic[i].graphic); + InitElementSmallImagesScaledUp(element_to_special_graphic[i].graphic); /* initialize images from dynamic configuration */ for (i = 0; i < num_property_mappings; i++) if (property_mapping[i].artwork_index < MAX_NUM_ELEMENTS) - CreateImageWithSmallImages(property_mapping[i].artwork_index); + InitElementSmallImagesScaledUp(property_mapping[i].artwork_index); + +#if 1 + /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */ + for (i = IMG_EMC_OBJECT; i <= IMG_EMC_SPRITE; i++) + InitElementSmallImagesScaledUp(i); +#endif +} + +#if 1 +/* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */ +void SetBitmaps_EM(Bitmap **em_bitmap) +{ + em_bitmap[0] = graphic_info[IMG_EMC_OBJECT].bitmap; + em_bitmap[1] = graphic_info[IMG_EMC_SPRITE].bitmap; } +#endif static int getFontBitmapID(int font_nr) { @@ -560,6 +580,11 @@ void InitElementGraphicInfo() } } +#if 1 + /* set hardcoded definitions for some runtime elements without graphic */ + element_info[EL_AMOEBA_TO_DIAMOND].graphic[ACTION_DEFAULT] = IMG_AMOEBA_DEAD; +#endif + #if 1 /* now set all undefined/invalid graphics to -1 to set to default after it */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) @@ -646,6 +671,7 @@ void InitElementGraphicInfo() default_action_crumbled = element_info[EL_SB_DEFAULT].crumbled[act]; #if 1 + /* !!! needed because EL_EMPTY_SPACE treated as IS_SP_ELEMENT !!! */ /* !!! make this better !!! */ if (i == EL_EMPTY_SPACE) { @@ -840,6 +866,7 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) graphic_info[graphic].crumbled_like = -1; /* do not use clone element */ graphic_info[graphic].diggable_like = -1; /* do not use clone element */ graphic_info[graphic].border_size = TILEX / 8; /* "CRUMBLED" border size */ + graphic_info[graphic].scale_up_factor = 1; /* default: no scaling up */ graphic_info[graphic].anim_delay_fixed = 0; graphic_info[graphic].anim_delay_random = 0; graphic_info[graphic].post_delay_fixed = 0; @@ -863,10 +890,21 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE) graphic_info[graphic].height = parameter[GFX_ARG_HEIGHT]; + /* optional zoom factor for scaling up the image to a larger size */ + if (parameter[GFX_ARG_SCALE_UP_FACTOR] != ARG_UNDEFINED_VALUE) + graphic_info[graphic].scale_up_factor = parameter[GFX_ARG_SCALE_UP_FACTOR]; + if (graphic_info[graphic].scale_up_factor < 1) + graphic_info[graphic].scale_up_factor = 1; /* no scaling */ + if (src_bitmap) { - anim_frames_per_row = src_bitmap->width / graphic_info[graphic].width; - anim_frames_per_col = src_bitmap->height / graphic_info[graphic].height; + /* bitmap is not scaled at this stage, so calculate final size */ + int scale_up_factor = graphic_info[graphic].scale_up_factor; + int src_bitmap_width = src_bitmap->width * scale_up_factor; + int src_bitmap_height = src_bitmap->height * scale_up_factor; + + anim_frames_per_row = src_bitmap_width / graphic_info[graphic].width; + anim_frames_per_col = src_bitmap_height / graphic_info[graphic].height; } /* correct x or y offset dependent of vertical or horizontal frame order */ @@ -1011,6 +1049,7 @@ static void InitGraphicInfo() Bitmap *src_bitmap; int src_x, src_y; int first_frame, last_frame; + int scale_up_factor, src_bitmap_width, src_bitmap_height; #if 0 printf("::: image: '%s' [%d]\n", image->token, i); @@ -1029,11 +1068,16 @@ static void InitGraphicInfo() if (graphic_info[i].bitmap == NULL) continue; /* skip check for optional images that are undefined */ + /* bitmap is not scaled at this stage, so calculate final size */ + scale_up_factor = graphic_info[i].scale_up_factor; + src_bitmap_width = graphic_info[i].bitmap->width * scale_up_factor; + src_bitmap_height = graphic_info[i].bitmap->height * scale_up_factor; + first_frame = 0; getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); if (src_x < 0 || src_y < 0 || - src_x + TILEX > src_bitmap->width || - src_y + TILEY > src_bitmap->height) + src_x + TILEX > src_bitmap_width || + src_y + TILEY > src_bitmap_height) { Error(ERR_RETURN_LINE, "-"); Error(ERR_RETURN, "warning: error found in config file:"); @@ -1048,6 +1092,10 @@ static void InitGraphicInfo() src_x, src_y); Error(ERR_RETURN, "custom graphic rejected for this element/action"); +#if 1 + Error(ERR_RETURN, "scale_up_factor == %d", scale_up_factor); +#endif + if (i == fallback_graphic) Error(ERR_EXIT, "fatal error: no fallback graphic available"); @@ -1061,8 +1109,8 @@ static void InitGraphicInfo() last_frame = graphic_info[i].anim_frames - 1; getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y); if (src_x < 0 || src_y < 0 || - src_x + TILEX > src_bitmap->width || - src_y + TILEY > src_bitmap->height) + src_x + TILEX > src_bitmap_width || + src_y + TILEY > src_bitmap_height) { Error(ERR_RETURN_LINE, "-"); Error(ERR_RETURN, "warning: error found in config file:"); @@ -1212,6 +1260,13 @@ static void InitElementSoundInfo() default_action_sound = element_info[i].sound[ACTION_DEFAULT]; #endif +#if 1 + /* !!! needed because EL_EMPTY_SPACE treated as IS_SP_ELEMENT !!! */ + /* !!! make this better !!! */ + if (i == EL_EMPTY_SPACE) + default_action_sound = element_info[EL_DEFAULT].sound[act]; +#endif + /* no sound for this specific action -- use default action sound */ if (element_info[i].sound[act] == -1) element_info[i].sound[act] = default_action_sound; @@ -1266,6 +1321,12 @@ static void set_sound_parameters(int sound, char **parameter_raw) /* explicit loop mode setting in configuration overrides default value */ if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE) sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP]; + + /* sound volume to change the original volume when loading the sound file */ + sound_info[sound].volume = parameter[SND_ARG_VOLUME]; + + /* sound priority to give certain sounds a higher or lower priority */ + sound_info[sound].volume = parameter[SND_ARG_VOLUME]; } static void InitSoundInfo() @@ -1546,7 +1607,7 @@ static void ReinitializeGraphics() InitElementGraphicInfo(); /* element game graphic mapping */ InitElementSpecialGraphicInfo(); /* element special graphic mapping */ - InitElementSmallImages(); /* create editor and preview images */ + InitElementSmallImages(); /* scale images to all needed sizes */ InitFontGraphicInfo(); /* initialize text drawing functions */ SetMainBackgroundImage(IMG_BACKGROUND); @@ -2071,14 +2132,14 @@ void InitElementPropertiesStatic() -1 }; - static int ep_can_explode_by_fire[] = + static int ep_explodes_by_fire[] = { - /* same elements as in 'ep_can_explode_impact' */ + /* same elements as in 'ep_explodes_impact' */ EL_BOMB, EL_SP_DISK_ORANGE, EL_DX_SUPABOMB, - /* same elements as in 'ep_can_explode_smashed' */ + /* same elements as in 'ep_explodes_smashed' */ EL_SATELLITE, EL_PIG, EL_DRAGON, @@ -2107,9 +2168,9 @@ void InitElementPropertiesStatic() -1 }; - static int ep_can_explode_smashed[] = + static int ep_explodes_smashed[] = { - /* same elements as in 'ep_can_explode_impact' */ + /* same elements as in 'ep_explodes_impact' */ EL_BOMB, EL_SP_DISK_ORANGE, EL_DX_SUPABOMB, @@ -2122,7 +2183,7 @@ void InitElementPropertiesStatic() -1 }; - static int ep_can_explode_impact[] = + static int ep_explodes_impact[] = { EL_BOMB, EL_SP_DISK_ORANGE, @@ -2201,6 +2262,14 @@ void InitElementPropertiesStatic() EL_SP_GRAVITY_PORT_RIGHT, EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN, + EL_SP_GRAVITY_ON_PORT_LEFT, + EL_SP_GRAVITY_ON_PORT_RIGHT, + EL_SP_GRAVITY_ON_PORT_UP, + EL_SP_GRAVITY_ON_PORT_DOWN, + EL_SP_GRAVITY_OFF_PORT_LEFT, + EL_SP_GRAVITY_OFF_PORT_RIGHT, + EL_SP_GRAVITY_OFF_PORT_UP, + EL_SP_GRAVITY_OFF_PORT_DOWN, -1 }; @@ -2214,7 +2283,7 @@ void InitElementPropertiesStatic() -1 }; - static int ep_can_explode_1x1[] = + static int ep_explodes_1x1_old[] = { -1 }; @@ -2238,13 +2307,27 @@ void InitElementPropertiesStatic() -1 }; - static int ep_can_explode_cross[] = + static int ep_explodes_cross_old[] = { -1 }; static int ep_protected[] = { + /* same elements as in 'ep_walkable_inside' */ + EL_TUBE_ANY, + EL_TUBE_VERTICAL, + EL_TUBE_HORIZONTAL, + EL_TUBE_VERTICAL_LEFT, + EL_TUBE_VERTICAL_RIGHT, + EL_TUBE_HORIZONTAL_UP, + EL_TUBE_HORIZONTAL_DOWN, + EL_TUBE_LEFT_UP, + EL_TUBE_LEFT_DOWN, + EL_TUBE_RIGHT_UP, + EL_TUBE_RIGHT_DOWN, + + /* same elements as in 'ep_passable_over' */ EL_EM_GATE_1, EL_EM_GATE_2, EL_EM_GATE_3, @@ -2255,6 +2338,27 @@ void InitElementPropertiesStatic() EL_EM_GATE_4_GRAY, EL_SWITCHGATE_OPEN, EL_TIMEGATE_OPEN, + + /* same elements as in 'ep_passable_inside' */ + EL_SP_PORT_LEFT, + EL_SP_PORT_RIGHT, + EL_SP_PORT_UP, + EL_SP_PORT_DOWN, + EL_SP_PORT_HORIZONTAL, + EL_SP_PORT_VERTICAL, + EL_SP_PORT_ANY, + EL_SP_GRAVITY_PORT_LEFT, + EL_SP_GRAVITY_PORT_RIGHT, + EL_SP_GRAVITY_PORT_UP, + EL_SP_GRAVITY_PORT_DOWN, + EL_SP_GRAVITY_ON_PORT_LEFT, + EL_SP_GRAVITY_ON_PORT_RIGHT, + EL_SP_GRAVITY_ON_PORT_UP, + EL_SP_GRAVITY_ON_PORT_DOWN, + EL_SP_GRAVITY_OFF_PORT_LEFT, + EL_SP_GRAVITY_OFF_PORT_RIGHT, + EL_SP_GRAVITY_OFF_PORT_UP, + EL_SP_GRAVITY_OFF_PORT_DOWN, -1 }; @@ -2263,6 +2367,71 @@ void InitElementPropertiesStatic() -1 }; + static int ep_can_explode[] = + { + /* same elements as in 'ep_explodes_impact' */ + EL_BOMB, + EL_SP_DISK_ORANGE, + EL_DX_SUPABOMB, + + /* same elements as in 'ep_explodes_smashed' */ + EL_SATELLITE, + EL_PIG, + EL_DRAGON, + EL_MOLE, + + /* elements that can explode by explosion or by dragonfire */ + EL_DYNAMITE_ACTIVE, + EL_DYNAMITE, + EL_DYNABOMB_PLAYER_1_ACTIVE, + EL_DYNABOMB_PLAYER_2_ACTIVE, + EL_DYNABOMB_PLAYER_3_ACTIVE, + EL_DYNABOMB_PLAYER_4_ACTIVE, + EL_DYNABOMB_INCREASE_NUMBER, + EL_DYNABOMB_INCREASE_SIZE, + EL_DYNABOMB_INCREASE_POWER, + EL_SP_DISK_RED_ACTIVE, + EL_BUG, + EL_PENGUIN, + EL_SP_DISK_RED, + EL_SP_DISK_YELLOW, + EL_SP_SNIKSNAK, + EL_SP_ELECTRON, + + /* elements that can explode only by explosion */ + EL_BLACK_ORB, + -1 + }; + + static int ep_gravity_reachable[] = + { + EL_SAND, + EL_SP_BASE, + EL_TRAP, + EL_INVISIBLE_SAND, + EL_INVISIBLE_SAND_ACTIVE, + EL_SP_PORT_LEFT, + EL_SP_PORT_RIGHT, + EL_SP_PORT_UP, + EL_SP_PORT_DOWN, + EL_SP_PORT_HORIZONTAL, + EL_SP_PORT_VERTICAL, + EL_SP_PORT_ANY, + EL_SP_GRAVITY_PORT_LEFT, + EL_SP_GRAVITY_PORT_RIGHT, + EL_SP_GRAVITY_PORT_UP, + EL_SP_GRAVITY_PORT_DOWN, + EL_SP_GRAVITY_ON_PORT_LEFT, + EL_SP_GRAVITY_ON_PORT_RIGHT, + EL_SP_GRAVITY_ON_PORT_UP, + EL_SP_GRAVITY_ON_PORT_DOWN, + EL_SP_GRAVITY_OFF_PORT_LEFT, + EL_SP_GRAVITY_OFF_PORT_RIGHT, + EL_SP_GRAVITY_OFF_PORT_UP, + EL_SP_GRAVITY_OFF_PORT_DOWN, + -1 + }; + static int ep_player[] = { EL_PLAYER_1, @@ -2357,6 +2526,7 @@ void InitElementPropertiesStatic() /* should always be valid */ EL_EMPTY, + /* standard classic Supaplex elements */ EL_SP_EMPTY, EL_SP_ZONK, EL_SP_BASE, @@ -2398,11 +2568,24 @@ void InitElementPropertiesStatic() EL_SP_HARDWARE_BASE_6, EL_SP_CHIP_TOP, EL_SP_CHIP_BOTTOM, + /* additional elements that appeared in newer Supaplex levels */ EL_INVISIBLE_WALL, - /* more than one murphy in a level results in an inactive clone */ + + /* additional gravity port elements (not switching, but setting gravity) */ + EL_SP_GRAVITY_ON_PORT_LEFT, + EL_SP_GRAVITY_ON_PORT_RIGHT, + EL_SP_GRAVITY_ON_PORT_UP, + EL_SP_GRAVITY_ON_PORT_DOWN, + EL_SP_GRAVITY_OFF_PORT_LEFT, + EL_SP_GRAVITY_OFF_PORT_RIGHT, + EL_SP_GRAVITY_OFF_PORT_UP, + EL_SP_GRAVITY_OFF_PORT_DOWN, + + /* more than one Murphy in a level results in an inactive clone */ EL_SP_MURPHY_CLONE, - /* runtime elements*/ + + /* runtime Supaplex elements */ EL_SP_DISK_RED_ACTIVE, EL_SP_TERMINAL_ACTIVE, EL_SP_BUGGY_BASE_ACTIVATING, @@ -2428,14 +2611,6 @@ void InitElementPropertiesStatic() -1 }; - static int ep_sp_buggy_base[] = - { - EL_SP_BUGGY_BASE, - EL_SP_BUGGY_BASE_ACTIVATING, - EL_SP_BUGGY_BASE_ACTIVE, - -1 - }; - static int ep_gem[] = { EL_BD_DIAMOND, @@ -2985,6 +3160,14 @@ void InitElementPropertiesStatic() EL_SP_HARDWARE_BASE_4, EL_SP_HARDWARE_BASE_5, EL_SP_HARDWARE_BASE_6, + EL_SP_GRAVITY_ON_PORT_LEFT, + EL_SP_GRAVITY_ON_PORT_RIGHT, + EL_SP_GRAVITY_ON_PORT_UP, + EL_SP_GRAVITY_ON_PORT_DOWN, + EL_SP_GRAVITY_OFF_PORT_LEFT, + EL_SP_GRAVITY_OFF_PORT_RIGHT, + EL_SP_GRAVITY_OFF_PORT_UP, + EL_SP_GRAVITY_OFF_PORT_DOWN, EL_CONVEYOR_BELT_1_SWITCH_LEFT, EL_CONVEYOR_BELT_1_SWITCH_MIDDLE, EL_CONVEYOR_BELT_1_SWITCH_RIGHT, @@ -3058,9 +3241,9 @@ void InitElementPropertiesStatic() { ep_can_smash_player, EP_CAN_SMASH_PLAYER }, { ep_can_smash_enemies, EP_CAN_SMASH_ENEMIES }, { ep_can_smash_everything, EP_CAN_SMASH_EVERYTHING }, - { ep_can_explode_by_fire, EP_CAN_EXPLODE_BY_FIRE }, - { ep_can_explode_smashed, EP_CAN_EXPLODE_SMASHED }, - { ep_can_explode_impact, EP_CAN_EXPLODE_IMPACT }, + { ep_explodes_by_fire, EP_EXPLODES_BY_FIRE }, + { ep_explodes_smashed, EP_EXPLODES_SMASHED }, + { ep_explodes_impact, EP_EXPLODES_IMPACT }, { ep_walkable_over, EP_WALKABLE_OVER }, { ep_walkable_inside, EP_WALKABLE_INSIDE }, { ep_walkable_under, EP_WALKABLE_UNDER }, @@ -3068,11 +3251,13 @@ void InitElementPropertiesStatic() { ep_passable_inside, EP_PASSABLE_INSIDE }, { ep_passable_under, EP_PASSABLE_UNDER }, { ep_droppable, EP_DROPPABLE }, - { ep_can_explode_1x1, EP_CAN_EXPLODE_1X1 }, + { ep_explodes_1x1_old, EP_EXPLODES_1X1_OLD }, { ep_pushable, EP_PUSHABLE }, - { ep_can_explode_cross, EP_CAN_EXPLODE_CROSS }, + { ep_explodes_cross_old, EP_EXPLODES_CROSS_OLD }, { ep_protected, EP_PROTECTED }, { ep_throwable, EP_THROWABLE }, + { ep_can_explode, EP_CAN_EXPLODE }, + { ep_gravity_reachable, EP_GRAVITY_REACHABLE }, { ep_player, EP_PLAYER }, { ep_can_pass_magic_wall, EP_CAN_PASS_MAGIC_WALL }, @@ -3080,7 +3265,6 @@ void InitElementPropertiesStatic() { ep_bd_element, EP_BD_ELEMENT }, { ep_sp_element, EP_SP_ELEMENT }, { ep_sb_element, EP_SB_ELEMENT }, - { ep_sp_buggy_base, EP_SP_BUGGY_BASE }, { ep_gem, EP_GEM }, { ep_food_dark_yamyam, EP_FOOD_DARK_YAMYAM }, { ep_food_penguin, EP_FOOD_PENGUIN }, @@ -3184,7 +3368,7 @@ void InitElementPropertiesEngine(int engine_version) EP_DONT_TOUCH, EP_DONT_RUN_INTO, EP_GEM, - EP_CAN_EXPLODE_BY_FIRE, + EP_EXPLODES_BY_FIRE, EP_PUSHABLE, EP_PLAYER, EP_HAS_CONTENT, @@ -3304,7 +3488,7 @@ void InitElementPropertiesEngine(int engine_version) !IS_DIGGABLE(i) && !IS_COLLECTIBLE(i))); -#if 1 +#if 0 /* ---------- PROTECTED ------------------------------------------------ */ if (IS_ACCESSIBLE_INSIDE(i)) SET_PROPERTY(i, EP_PROTECTED, TRUE); @@ -3361,11 +3545,14 @@ void InitElementPropertiesEngine(int engine_version) CAN_SMASH_ENEMIES(i) || CAN_SMASH_EVERYTHING(i))); +#if 0 /* ---------- CAN_EXPLODE ---------------------------------------------- */ SET_PROPERTY(i, EP_CAN_EXPLODE, (CAN_EXPLODE_BY_FIRE(i) || CAN_EXPLODE_SMASHED(i) || CAN_EXPLODE_IMPACT(i))); +#endif +#if 0 /* ---------- CAN_EXPLODE_3X3 ------------------------------------------ */ #if 0 SET_PROPERTY(i, EP_CAN_EXPLODE_3X3, (!CAN_EXPLODE_1X1(i) && @@ -3375,6 +3562,19 @@ void InitElementPropertiesEngine(int engine_version) !CAN_EXPLODE_1X1(i) && !CAN_EXPLODE_CROSS(i))); #endif +#endif + + /* ---------- CAN_EXPLODE_BY_FIRE -------------------------------------- */ + SET_PROPERTY(i, EP_CAN_EXPLODE_BY_FIRE, (CAN_EXPLODE(i) && + EXPLODES_BY_FIRE(i))); + + /* ---------- CAN_EXPLODE_SMASHED -------------------------------------- */ + SET_PROPERTY(i, EP_CAN_EXPLODE_SMASHED, (CAN_EXPLODE(i) && + EXPLODES_SMASHED(i))); + + /* ---------- CAN_EXPLODE_IMPACT --------------------------------------- */ + SET_PROPERTY(i, EP_CAN_EXPLODE_IMPACT, (CAN_EXPLODE(i) && + EXPLODES_IMPACT(i))); /* ---------- CAN_EXPLODE_BY_DRAGONFIRE -------------------------------- */ SET_PROPERTY(i, EP_CAN_EXPLODE_BY_DRAGONFIRE, CAN_EXPLODE_BY_FIRE(i)); @@ -3392,10 +3592,6 @@ void InitElementPropertiesEngine(int engine_version) SET_PROPERTY(i, EP_MAYBE_DONT_COLLIDE_WITH, (i == EL_SP_SNIKSNAK || i == EL_SP_ELECTRON)); - /* ---------- DIGGABLE_WITH_GRAVITY ------------------------------------ */ - SET_PROPERTY(i, EP_DIGGABLE_WITH_GRAVITY, (IS_DIGGABLE(i) && - !IS_SP_BUGGY_BASE(i))); - /* ---------- CAN_MOVE_INTO_ACID --------------------------------------- */ if (COULD_MOVE_INTO_ACID(i) && !IS_CUSTOM_ELEMENT(i)) SET_PROPERTY(i, EP_CAN_MOVE_INTO_ACID, @@ -3410,15 +3606,6 @@ void InitElementPropertiesEngine(int engine_version) SET_PROPERTY(i, EP_SP_PORT, (IS_SP_ELEMENT(i) && IS_PASSABLE_INSIDE(i))); -#if 0 - if (i == EL_CUSTOM_START + 253) - printf("::: %d, %d, %d -> %d\n", - CAN_EXPLODE_1X1(i), - CAN_EXPLODE_3X3(i), - CAN_EXPLODE_CROSS(i), - CAN_EXPLODE(i)); -#endif - /* ---------- CAN_CHANGE ----------------------------------------------- */ SET_PROPERTY(i, EP_CAN_CHANGE, FALSE); /* default: cannot change */ for (j = 0; j < element_info[i].num_change_pages; j++) @@ -3529,7 +3716,21 @@ void InitElementPropertiesEngine(int engine_version) static void InitGlobal() { + int i; + + for (i = 0; i < MAX_NUM_ELEMENTS + 1; i++) + { + /* check if element_name_info entry defined for each element in "main.h" */ + if (i < MAX_NUM_ELEMENTS && element_name_info[i].token_name == NULL) + Error(ERR_EXIT, "undefined 'element_name_info' entry for element %d", i); + + element_info[i].token_name = element_name_info[i].token_name; + element_info[i].class_name = element_name_info[i].class_name; + element_info[i].editor_description=element_name_info[i].editor_description; + } + global.autoplay_leveldir = NULL; + global.convert_leveldir = NULL; global.frames_per_second = 0; global.fps_slowdown = FALSE; @@ -3665,6 +3866,20 @@ void Execute_Command(char *command) global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */ } } + else if (strncmp(command, "convert ", 8) == 0) + { + char *str_copy = getStringCopy(&command[8]); + char *str_ptr = strchr(str_copy, ' '); + + global.convert_leveldir = str_copy; + global.convert_level_nr = -1; + + if (str_ptr != NULL) + { + *str_ptr++ = '\0'; /* terminate leveldir string */ + global.convert_level_nr = atoi(str_ptr); /* get level_nr value */ + } + } else { Error(ERR_EXIT_HELP, "unrecognized command '%s'", command); @@ -4006,14 +4221,14 @@ static void InitMusic(char *identifier) void InitNetworkServer() { -#if defined(PLATFORM_UNIX) +#if defined(NETWORK_AVALIABLE) int nr_wanted; #endif if (!options.network) return; -#if defined(PLATFORM_UNIX) +#if defined(NETWORK_AVALIABLE) nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); if (!ConnectToServer(options.server_host, options.server_port)) @@ -4270,9 +4485,18 @@ void OpenAll() AutoPlayTape(); return; } + else if (global.convert_leveldir) + { + ConvertLevels(); + return; + } game_status = GAME_MODE_MAIN; +#if 1 + em_open_all(); +#endif + DrawMainMenu(); InitNetworkServer(); @@ -4285,9 +4509,18 @@ void CloseAllAndExit(int exit_value) FreeAllMusic(); CloseAudio(); /* called after freeing sounds (needed for SDL) */ +#if 1 + em_close_all(); +#endif + FreeAllImages(); FreeTileClipmasks(); +#if defined(TARGET_SDL) + if (network_server) /* terminate network server */ + SDL_KillThread(server_thread); +#endif + CloseVideoDisplay(); ClosePlatformDependentStuff();