X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Finit.c;h=97eaf2bf17ddfbb20f4f3d76c932626cf9a18978;hp=770d88c82c9818512a5ee2eb2f48795a9dd0831d;hb=92452198bec9ed9273bb24f542367359029470a3;hpb=4d3b0d040b3c5d397ac3b7a15f3d48c44d50e9dd diff --git a/src/init.c b/src/init.c index 770d88c8..97eaf2bf 100644 --- a/src/init.c +++ b/src/init.c @@ -195,22 +195,23 @@ void InitElementSmallImages() print_timestamp_time("getImageListPropertyMapping/Size"); print_timestamp_init("InitElementSmallImagesScaledUp (1)"); - /* initialize normal images from static configuration */ + /* initialize normal element images from static configuration */ for (i = 0; element_to_graphic[i].element > -1; i++) InitElementSmallImagesScaledUp(element_to_graphic[i].graphic); print_timestamp_done("InitElementSmallImagesScaledUp (1)"); - /* initialize special images from static configuration */ + /* initialize special element images from static configuration */ for (i = 0; element_to_special_graphic[i].element > -1; i++) InitElementSmallImagesScaledUp(element_to_special_graphic[i].graphic); print_timestamp_time("InitElementSmallImagesScaledUp (2)"); - /* initialize images from dynamic configuration (may be elements or other) */ + /* initialize element images from dynamic configuration */ for (i = 0; i < num_property_mappings; i++) - InitElementSmallImagesScaledUp(property_mapping[i].artwork_index); + if (property_mapping[i].base_index < MAX_NUM_ELEMENTS) + InitElementSmallImagesScaledUp(property_mapping[i].artwork_index); print_timestamp_time("InitElementSmallImagesScaledUp (3)"); - /* initialize special images from above list (non-element images) */ + /* initialize special non-element images from above list */ for (i = 0; special_graphics[i] > -1; i++) InitElementSmallImagesScaledUp(special_graphics[i]); print_timestamp_time("InitElementSmallImagesScaledUp (4)"); @@ -218,13 +219,26 @@ void InitElementSmallImages() print_timestamp_done("InitElementSmallImages"); } +inline static void InitScaledImagesScaledUp(int graphic) +{ + struct GraphicInfo *g = &graphic_info[graphic]; + + ScaleImage(graphic, g->scale_up_factor); +} + void InitScaledImages() { + struct PropertyMapping *property_mapping = getImageListPropertyMapping(); + int num_property_mappings = getImageListPropertyMappingSize(); int i; /* scale normal images from static configuration, if not already scaled */ for (i = 0; i < NUM_IMAGE_FILES; i++) - ScaleImage(i, graphic_info[i].scale_up_factor); + InitScaledImagesScaledUp(i); + + /* scale images from dynamic configuration, if not already scaled */ + for (i = 0; i < num_property_mappings; i++) + InitScaledImagesScaledUp(property_mapping[i].artwork_index); } void InitBitmapPointers() @@ -936,14 +950,12 @@ void InitElementGraphicInfo() (move_dir == MV_BIT_UP && !front_is_left_or_upper) || (move_dir == MV_BIT_RIGHT && front_is_left_or_upper) || (move_dir == MV_BIT_DOWN && front_is_left_or_upper))); - Bitmap *dummy; /* swap frontside and backside graphic tile coordinates, if needed */ if (swap_movement_tiles_always || swap_movement_tiles_autodetected) { /* get current (wrong) backside tile coordinates */ - getFixedGraphicSourceExt(graphic, 0, &dummy, - &src_x_back, &src_y_back, TRUE); + getGraphicSourceXY(graphic, 0, &src_x_back, &src_y_back, TRUE); /* set frontside tile coordinates to backside tile coordinates */ g->src_x = src_x_back; @@ -1345,13 +1357,13 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, if (parameter[GFX_ARG_TILE_SIZE] != ARG_UNDEFINED_VALUE) { - anim_frames_per_row = src_image_width / g->tile_size; - anim_frames_per_col = src_image_height / g->tile_size; + anim_frames_per_row = MAX(1, src_image_width / g->tile_size); + anim_frames_per_col = MAX(1, src_image_height / g->tile_size); } else { - anim_frames_per_row = src_image_width / g->width; - anim_frames_per_col = src_image_height / g->height; + anim_frames_per_row = MAX(1, src_image_width / g->width); + anim_frames_per_col = MAX(1, src_image_height / g->height); } g->src_image_width = src_image_width; @@ -1698,6 +1710,9 @@ static void InitGraphicInfo() src_x = graphic_info[i].src_x; src_y = graphic_info[i].src_y; + if (program.headless) + continue; + if (src_x < 0 || src_y < 0 || src_x + width > src_bitmap_width || src_y + height > src_bitmap_height) @@ -1707,6 +1722,7 @@ static void InitGraphicInfo() Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); Error(ERR_INFO, "- config token: '%s'", getTokenFromImageID(i)); Error(ERR_INFO, "- image file: '%s'", src_bitmap->source_filename); + Error(ERR_INFO, "- frame size: %d, %d", width, height); Error(ERR_INFO, "error: first animation frame out of bounds (%d, %d) [%d, %d]", src_x, src_y, src_bitmap_width, src_bitmap_height); @@ -1735,10 +1751,10 @@ static void InitGraphicInfo() Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); Error(ERR_INFO, "- config token: '%s'", getTokenFromImageID(i)); Error(ERR_INFO, "- image file: '%s'", src_bitmap->source_filename); + Error(ERR_INFO, "- frame size: %d, %d", width, height); Error(ERR_INFO, "error: last animation frame (%d) out of bounds (%d, %d) [%d, %d]", last_frame, src_x, src_y, src_bitmap_width, src_bitmap_height); - Error(ERR_INFO, "::: %d, %d", width, height); Error(ERR_INFO, "custom graphic rejected for this element/action"); if (i == fallback_graphic) @@ -1784,7 +1800,8 @@ static void InitGraphicCompatibilityInfo() { // printf("::: special treatment needed for token '%s'\n", fi->token); - graphic_info[i].bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap; + graphic_info[i].bitmaps = graphic_info[IMG_GLOBAL_DOOR].bitmaps; + graphic_info[i].bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap; } } } @@ -4904,13 +4921,17 @@ void Execute_Command(char *command) } else if (strPrefix(command, "autotest ") || strPrefix(command, "autoplay ") || - strPrefix(command, "autoffwd ")) + strPrefix(command, "autoffwd ") || + strPrefix(command, "autowarp ")) { char *str_ptr = getStringCopy(&command[9]); /* read command parameters */ - global.autoplay_mode = (strPrefix(command, "autotest") ? AUTOPLAY_TEST : - strPrefix(command, "autoplay") ? AUTOPLAY_PLAY : - strPrefix(command, "autoffwd") ? AUTOPLAY_FFWD : 0); + global.autoplay_mode = + (strPrefix(command, "autotest") ? AUTOPLAY_MODE_TEST : + strPrefix(command, "autoplay") ? AUTOPLAY_MODE_PLAY : + strPrefix(command, "autoffwd") ? AUTOPLAY_MODE_FFWD : + strPrefix(command, "autowarp") ? AUTOPLAY_MODE_WARP : + AUTOPLAY_MODE_NONE); while (*str_ptr != '\0') /* continue parsing string */ { @@ -4943,6 +4964,9 @@ void Execute_Command(char *command) while (*str_ptr != ' ' && *str_ptr != '\t' && *str_ptr != '\0') str_ptr++; } + + if (global.autoplay_mode == AUTOPLAY_MODE_TEST) + program.headless = TRUE; } else if (strPrefix(command, "convert ")) { @@ -4957,6 +4981,8 @@ void Execute_Command(char *command) *str_ptr++ = '\0'; /* terminate leveldir string */ global.convert_level_nr = atoi(str_ptr); /* get level_nr value */ } + + program.headless = TRUE; } else if (strPrefix(command, "create images ")) { @@ -5380,7 +5406,7 @@ static void InitLevelInfo() LoadLevelSetup_SeriesInfo(); /* last played level info */ if (global.autoplay_leveldir && - global.autoplay_mode != AUTOPLAY_TEST) + global.autoplay_mode != AUTOPLAY_MODE_TEST) { leveldir_current = getTreeInfoFromIdentifier(leveldir_first, global.autoplay_leveldir); @@ -5451,6 +5477,9 @@ static void InitImages() ReinitializeGraphics(); print_timestamp_time("ReinitializeGraphics"); + LoadMenuDesignSettings_AfterGraphics(); + print_timestamp_time("LoadMenuDesignSettings_AfterGraphics"); + UPDATE_BUSY_STATE(); print_timestamp_done("InitImages"); @@ -5496,6 +5525,9 @@ static void InitMusic(char *identifier) static void InitArtworkDone() { + if (program.headless) + return; + InitGlobalAnimations(); } @@ -5883,6 +5915,8 @@ void OpenAll() print_timestamp_time("[init setup/config stuff (1)]"); + InitScoresInfo(); + if (options.execute_command) Execute_Command(options.execute_command); @@ -5918,7 +5952,7 @@ void OpenAll() InitVideoDisplay(); InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); - InitEventFilter(FilterEvents); + InitOverlayInfo(); print_timestamp_time("[init video stuff]");