X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=f0f528ce1ca3093e12bdf3ca0538f21d616357f2;hb=f47cd4b09952aaf95d16542f6b53f2d8bf9e1d7d;hp=903cd8d93274cd215bb34c85fcad961d2d3dee38;hpb=7d171d862abdecced79f60535b49a686386cefe1;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 903cd8d9..f0f528ce 100644 --- a/src/init.c +++ b/src/init.c @@ -890,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 */ @@ -966,12 +977,6 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) if (parameter[GFX_ARG_BORDER_SIZE] != ARG_UNDEFINED_VALUE) graphic_info[graphic].border_size = parameter[GFX_ARG_BORDER_SIZE]; - /* optional zoom factor for scaling up the image to a larger size */ - if (parameter[GFX_ARG_SCALE_UP] != ARG_UNDEFINED_VALUE) - graphic_info[graphic].scale_up_factor = parameter[GFX_ARG_SCALE_UP]; - if (graphic_info[graphic].scale_up_factor < 1) - graphic_info[graphic].scale_up_factor = 1; /* no scaling */ - /* this is only used for player "boring" and "sleeping" actions */ if (parameter[GFX_ARG_ANIM_DELAY_FIXED] != ARG_UNDEFINED_VALUE) graphic_info[graphic].anim_delay_fixed = @@ -1044,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); @@ -1062,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:"); @@ -1081,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"); @@ -1094,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:"); @@ -1245,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; @@ -1585,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); @@ -3698,6 +3720,10 @@ static void InitGlobal() 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;