X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=aea5c31bd576c806c7519a320cd8f7525ab10075;hb=983d4e27852f9c81935bf4ae36482f6084264e15;hp=401e59ea370e7c40f7dcde5a6536ace53ce10a04;hpb=76ae1ac5119938169d8201d94bd44fedaa4e298b;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 401e59ea..aea5c31b 100644 --- a/src/init.c +++ b/src/init.c @@ -953,13 +953,36 @@ static int get_graphic_parameter_value(char *value_raw, char *suffix, int type) { char *value = getHashEntry(element_token_hash, value_raw); + if (value == NULL) + { + Error(ERR_INFO_LINE, "-"); + Error(ERR_INFO, "warning: error found in config file:"); + Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); + Error(ERR_INFO, "error: invalid element token '%s'", value_raw); + Error(ERR_INFO, "custom graphic rejected for this element/action"); + Error(ERR_INFO, "fallback done to undefined element for this graphic"); + Error(ERR_INFO_LINE, "-"); + } + return (value != NULL ? atoi(value) : EL_UNDEFINED); } else if (type == TYPE_GRAPHIC) { char *value = getHashEntry(graphic_token_hash, value_raw); + int fallback_graphic = IMG_CHAR_EXCLAM; - return (value != NULL ? atoi(value) : IMG_UNDEFINED); + if (value == NULL) + { + Error(ERR_INFO_LINE, "-"); + Error(ERR_INFO, "warning: error found in config file:"); + Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); + Error(ERR_INFO, "error: invalid graphic token '%s'", value_raw); + Error(ERR_INFO, "custom graphic rejected for this element/action"); + Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); + Error(ERR_INFO_LINE, "-"); + } + + return (value != NULL ? atoi(value) : fallback_graphic); } return -1; @@ -1055,11 +1078,17 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->height = get_scaled_graphic_height(graphic); } + /* optional width and height of each animation frame */ + if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE) + g->width = parameter[GFX_ARG_WIDTH]; + if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE) + g->height = parameter[GFX_ARG_HEIGHT]; + /* optional x and y tile position of animation frame sequence */ if (parameter[GFX_ARG_XPOS] != ARG_UNDEFINED_VALUE) - g->src_x = parameter[GFX_ARG_XPOS] * TILEX; + g->src_x = parameter[GFX_ARG_XPOS] * g->width; if (parameter[GFX_ARG_YPOS] != ARG_UNDEFINED_VALUE) - g->src_y = parameter[GFX_ARG_YPOS] * TILEY; + g->src_y = parameter[GFX_ARG_YPOS] * g->height; /* optional x and y pixel position of animation frame sequence */ if (parameter[GFX_ARG_X] != ARG_UNDEFINED_VALUE) @@ -1067,12 +1096,6 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, if (parameter[GFX_ARG_Y] != ARG_UNDEFINED_VALUE) g->src_y = parameter[GFX_ARG_Y]; - /* optional width and height of each animation frame */ - if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE) - g->width = parameter[GFX_ARG_WIDTH]; - if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE) - g->height = parameter[GFX_ARG_HEIGHT]; - if (src_bitmap) { if (g->width <= 0) @@ -1315,7 +1338,7 @@ static void set_cloned_graphic_parameters(int graphic) Error(ERR_INFO, "custom graphic rejected for this element/action"); if (graphic == fallback_graphic) - Error(ERR_EXIT, "fatal error: no fallback graphic available"); + Error(ERR_EXIT, "no fallback graphic available"); Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); Error(ERR_INFO_LINE, "-"); @@ -1461,7 +1484,7 @@ static void InitGraphicInfo() Error(ERR_INFO, "custom graphic rejected for this element/action"); if (i == fallback_graphic) - Error(ERR_EXIT, "fatal error: no fallback graphic available"); + Error(ERR_EXIT, "no fallback graphic available"); Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); Error(ERR_INFO_LINE, "-"); @@ -1490,7 +1513,7 @@ static void InitGraphicInfo() Error(ERR_INFO, "custom graphic rejected for this element/action"); if (i == fallback_graphic) - Error(ERR_EXIT, "fatal error: no fallback graphic available"); + Error(ERR_EXIT, "no fallback graphic available"); Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); Error(ERR_INFO_LINE, "-"); @@ -4446,6 +4469,33 @@ static void InitGlobal() font_info[i].token_name, int2str(i, 0)); + /* set default filenames for all cloned graphics in static configuration */ + for (i = 0; image_config[i].token != NULL; i++) + { + if (strEqual(image_config[i].value, UNDEFINED_FILENAME)) + { + char *token = image_config[i].token; + char *token_clone_from = getStringCat2(token, ".clone_from"); + char *token_cloned = getHashEntry(image_config_hash, token_clone_from); + + if (token_cloned != NULL) + { + char *value_cloned = getHashEntry(image_config_hash, token_cloned); + + if (value_cloned != NULL) + { + /* set default filename in static configuration */ + image_config[i].value = value_cloned; + + /* set default filename in image config hash */ + setHashEntry(image_config_hash, token, value_cloned); + } + } + + free(token_clone_from); + } + } + /* always start with reliable default values (all elements) */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) ActiveElement[i] = i; @@ -5017,12 +5067,11 @@ void InitGfx() font_height = getFontHeight(FC_RED); - DrawInitTextAlways(getProgramInitString(), 20, FC_YELLOW); - DrawInitTextAlways(PROGRAM_COPYRIGHT_STRING, 50, FC_RED); - DrawInitTextAlways(PROGRAM_WEBSITE_STRING, WIN_YSIZE - 20 - font_height, - FC_RED); + DrawInitText(getProgramInitString(), 20, FC_YELLOW); + DrawInitText(PROGRAM_COPYRIGHT_STRING, 50, FC_RED); + DrawInitText(PROGRAM_WEBSITE_STRING, WIN_YSIZE - 20 - font_height, FC_RED); - DrawInitTextAlways("Loading graphics", 120, FC_GREEN); + DrawInitText("Loading graphics", 120, FC_GREEN); /* initialize busy animation with default values */ int parameter[NUM_GFX_ARGS]; @@ -5577,6 +5626,9 @@ void DisplayExitMessage(char *format, va_list ap) redraw_mask = REDRAW_ALL; + /* force drawing exit message even if screen updates are currently limited */ + LimitScreenUpdates(FALSE); + BackToFront(); /* deactivate toons on error message screen */