X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=57c03bd0ab3060a5160435c13259012377558537;hb=f648fc704c75dcfb0e7721a723c7c7391e708370;hp=ae1ada3a53b39b2488baf49d300e846436e7c24d;hpb=04575ef0d5f1551715fca1d1def889fd63b5c3ad;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index ae1ada3a..57c03bd0 100644 --- a/src/init.c +++ b/src/init.c @@ -238,12 +238,25 @@ void InitFontGraphicInfo() getImageListEntryFromImageID(base_graphic)->redefined; boolean special_redefined = getImageListEntryFromImageID(graphic)->redefined; + boolean special_cloned = (graphic_info[graphic].clone_from != -1); + +#if 0 + printf("::: %d, %d, %d / %d, %d, %d\n", + font_nr, special, graphic, + base_redefined, special_redefined, special_cloned); +#endif + +#if 0 + // special_cloned = 0; +#endif /* if the base font ("font.title_1", for example) has been redefined, but not the special font ("font.title_1.LEVELS", for example), do not use an existing (in this case considered obsolete) special font anymore, but use the automatically determined default font */ - if (base_redefined && !special_redefined) + /* special case: cloned special fonts must be explicitly redefined, + but are not automatically redefined by redefining base font */ + if (base_redefined && !special_redefined && !special_cloned) continue; font_info[font_nr].special_graphic[special] = graphic; @@ -270,6 +283,87 @@ void InitFontGraphicInfo() } } +#if 0 + printf("-0- T3.P: %d, %d\n", + font_info[FONT_TEXT_3].special_graphic[GFX_SPECIAL_ARG_PREVIEW], + font_info[FONT_TEXT_3].special_bitmap_id[GFX_SPECIAL_ARG_PREVIEW]); + + printf("-0- T4.M: %d, %d\n", + font_info[FONT_TEXT_4].special_graphic[GFX_SPECIAL_ARG_MAIN], + font_info[FONT_TEXT_4].special_bitmap_id[GFX_SPECIAL_ARG_MAIN]); +#endif + +#if 1 + /* correct special font/graphic mapping for cloned fonts + (per definition only needed for static configuration) */ + for (i = 0; font_to_graphic[i].font_nr > -1; i++) + { + int font_nr = font_to_graphic[i].font_nr; + int special = font_to_graphic[i].special; + int graphic = font_to_graphic[i].graphic; +#if 0 + int base_graphic = font2baseimg(font_nr); +#endif + + if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS) + { +#if 0 + boolean base_redefined = + getImageListEntryFromImageID(base_graphic)->redefined; +#endif + boolean special_redefined = + getImageListEntryFromImageID(graphic)->redefined; + boolean special_cloned = (graphic_info[graphic].clone_from != -1); + + if (special_cloned && !special_redefined) + { + int j; + +#if 0 + printf(":2: %d, %d, %d / %d, %d, %d\n", + font_nr, special, graphic, + base_redefined, special_redefined, special_cloned); +#endif + + for (j = 0; font_to_graphic[j].font_nr > -1; j++) + { + int font_nr2 = font_to_graphic[j].font_nr; + int special2 = font_to_graphic[j].special; + int graphic2 = font_to_graphic[j].graphic; +#if 0 + int base_graphic2 = font2baseimg(font_nr2); +#endif + + if (graphic2 == graphic_info[graphic].clone_from) + { +#if 0 + printf(":2.1: %d, %d, %d, %d\n", + font_nr2, special2, graphic2, base_graphic2); +#endif + +#if 1 + font_info[font_nr].special_graphic[special] = + font_info[font_nr2].special_graphic[special2]; + font_info[font_nr].special_bitmap_id[special] = + font_info[font_nr2].special_bitmap_id[special2]; +#else +#if 1 + font_info[font_nr].special_graphic[special] = graphic2; + font_info[font_nr].special_bitmap_id[special] = + font_info[font_nr2].special_bitmap_id[special2]; +#else + font_info[font_nr].special_graphic[special] = graphic2; + font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps; + num_font_bitmaps++; +#endif +#endif + } + } + } + } + } +#endif + /* reset non-redefined ".active" font graphics if normal font is redefined */ /* (this different treatment is needed because normal and active fonts are independently defined ("active" is not a property of font definitions!) */ @@ -318,6 +412,24 @@ void InitFontGraphicInfo() } } +#if 0 + printf("-1- T4.M: %d, %d\n", + font_info[FONT_TEXT_4].special_graphic[GFX_SPECIAL_ARG_MAIN], + font_info[FONT_TEXT_4].special_bitmap_id[GFX_SPECIAL_ARG_MAIN]); + + font_info[FONT_TEXT_4].special_graphic[GFX_SPECIAL_ARG_MAIN] = + IMG_FONT_TEXT_3; + font_info[FONT_TEXT_4].special_bitmap_id[GFX_SPECIAL_ARG_MAIN] = + FONT_TEXT_3; + +#if 0 + font_info[FONT_TEXT_4].special_graphic[GFX_SPECIAL_ARG_MAIN] = + IMG_FONT_TEXT_3_PREVIEW; + font_info[FONT_TEXT_4].special_bitmap_id[GFX_SPECIAL_ARG_MAIN] = + FONT_TEXT_3; +#endif +#endif + /* ---------- initialize font bitmap array ---------- */ if (font_bitmap_info != NULL) @@ -368,6 +480,16 @@ void InitFontGraphicInfo() } InitFontInfo(font_bitmap_info, num_font_bitmaps, getFontBitmapID); + +#if 0 + printf("-X- T3.P: %d, %d\n", + font_info[FONT_TEXT_3].special_graphic[GFX_SPECIAL_ARG_PREVIEW], + font_info[FONT_TEXT_3].special_bitmap_id[GFX_SPECIAL_ARG_PREVIEW]); + + printf("-4- T4.M: %d, %d\n", + font_info[FONT_TEXT_4].special_graphic[GFX_SPECIAL_ARG_MAIN], + font_info[FONT_TEXT_4].special_bitmap_id[GFX_SPECIAL_ARG_MAIN]); +#endif } void InitElementGraphicInfo() @@ -815,7 +937,7 @@ void InitElementGraphicInfo() for (i = 0; i < MAX_NUM_ELEMENTS; i++) if (element_info[i].graphic[ACTION_DEFAULT] == IMG_UNKNOWN && i != EL_UNKNOWN) - Error(ERR_RETURN, "warning: no graphic for element '%s' (%d)", + Error(ERR_INFO, "warning: no graphic for element '%s' (%d)", element_info[i].token_name, i); } #endif @@ -1192,18 +1314,18 @@ static void set_cloned_graphic_parameters(int graphic) if (num_references_followed >= max_num_images) { - Error(ERR_RETURN_LINE, "-"); - Error(ERR_RETURN, "warning: error found in config file:"); - Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(graphic)); - Error(ERR_RETURN, "error: loop discovered when resolving cloned graphics"); - Error(ERR_RETURN, "custom graphic rejected for this element/action"); + Error(ERR_INFO_LINE, "-"); + Error(ERR_INFO, "warning: error found in config file:"); + Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); + Error(ERR_INFO, "- config token: '%s'", getTokenFromImageID(graphic)); + Error(ERR_INFO, "error: loop discovered when resolving cloned graphics"); + 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_RETURN, "fallback done to 'char_exclam' for this graphic"); - Error(ERR_RETURN_LINE, "-"); + Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); + Error(ERR_INFO_LINE, "-"); graphic_info[graphic] = graphic_info[fallback_graphic]; } @@ -1344,21 +1466,21 @@ static void InitGraphicInfo() src_x + width > src_bitmap_width || src_y + height > src_bitmap_height) { - Error(ERR_RETURN_LINE, "-"); - Error(ERR_RETURN, "warning: error found in config file:"); - Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(i)); - Error(ERR_RETURN, "- image file: '%s'", src_bitmap->source_filename); - Error(ERR_RETURN, + Error(ERR_INFO_LINE, "-"); + Error(ERR_INFO, "warning: error found in config file:"); + 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, "error: first animation frame out of bounds (%d, %d) [%d, %d]", src_x, src_y, src_bitmap_width, src_bitmap_height); - Error(ERR_RETURN, "custom graphic rejected for this element/action"); + 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_RETURN, "fallback done to 'char_exclam' for this graphic"); - Error(ERR_RETURN_LINE, "-"); + Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); + Error(ERR_INFO_LINE, "-"); graphic_info[i] = graphic_info[fallback_graphic]; } @@ -1372,21 +1494,21 @@ static void InitGraphicInfo() src_x + width > src_bitmap_width || src_y + height > src_bitmap_height) { - Error(ERR_RETURN_LINE, "-"); - Error(ERR_RETURN, "warning: error found in config file:"); - Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(i)); - Error(ERR_RETURN, "- image file: '%s'", src_bitmap->source_filename); - Error(ERR_RETURN, + Error(ERR_INFO_LINE, "-"); + Error(ERR_INFO, "warning: error found in config file:"); + 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, "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_RETURN, "custom graphic rejected for this element/action"); + 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_RETURN, "fallback done to 'char_exclam' for this graphic"); - Error(ERR_RETURN_LINE, "-"); + Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); + Error(ERR_INFO_LINE, "-"); graphic_info[i] = graphic_info[fallback_graphic]; } @@ -1965,7 +2087,7 @@ boolean getBitfieldProperty(int *bitfield, int property_bit_nr, int element) return FALSE; } -static void resolve_group_element(int group_element, int recursion_depth) +static void ResolveGroupElementExt(int group_element, int recursion_depth) { static int group_nr; static struct ElementGroupInfo *group; @@ -1989,10 +2111,13 @@ static void resolve_group_element(int group_element, int recursion_depth) if (recursion_depth == 0) /* initialization */ { group = actual_group; - group_nr = group_element - EL_GROUP_START; + group_nr = GROUP_NR(group_element); group->num_elements_resolved = 0; group->choice_pos = 0; + + for (i = 0; i < MAX_NUM_ELEMENTS; i++) + element_info[i].in_group[group_nr] = FALSE; } for (i = 0; i < actual_group->num_elements; i++) @@ -2003,7 +2128,7 @@ static void resolve_group_element(int group_element, int recursion_depth) break; if (IS_GROUP_ELEMENT(element)) - resolve_group_element(element, recursion_depth + 1); + ResolveGroupElementExt(element, recursion_depth + 1); else { group->element_resolved[group->num_elements_resolved++] = element; @@ -2012,6 +2137,11 @@ static void resolve_group_element(int group_element, int recursion_depth) } } +void ResolveGroupElement(int group_element) +{ + ResolveGroupElementExt(group_element, 0); +} + void InitElementPropertiesStatic() { static int ep_diggable[] = @@ -3457,6 +3587,17 @@ void InitElementPropertiesStatic() -1 }; + static int ep_acid_pool[] = + { + EL_ACID_POOL_TOPLEFT, + EL_ACID_POOL_TOPRIGHT, + EL_ACID_POOL_BOTTOMLEFT, + EL_ACID_POOL_BOTTOM, + EL_ACID_POOL_BOTTOMRIGHT, + + -1 + }; + static int ep_keygate[] = { EL_GATE_1, @@ -3926,6 +4067,7 @@ void InitElementPropertiesStatic() { ep_belt_active, EP_BELT_ACTIVE }, { ep_belt_switch, EP_BELT_SWITCH }, { ep_tube, EP_TUBE }, + { ep_acid_pool, EP_ACID_POOL }, { ep_keygate, EP_KEYGATE }, { ep_amoeboid, EP_AMOEBOID }, { ep_amoebalive, EP_AMOEBALIVE }, @@ -4011,14 +4153,9 @@ void InitElementPropertiesEngine(int engine_version) property (which means that conditional property changes must be set to a reliable default value before) */ - /* ---------- recursively resolve group elements ------------------------- */ - - for (i = 0; i < MAX_NUM_ELEMENTS; i++) - for (j = 0; j < NUM_GROUP_ELEMENTS; j++) - element_info[i].in_group[j] = FALSE; - + /* resolve group elements */ for (i = 0; i < NUM_GROUP_ELEMENTS; i++) - resolve_group_element(EL_GROUP_START + i, 0); + ResolveGroupElement(EL_GROUP_START + i); /* set all special, combined or engine dependent element properties */ for (i = 0; i < MAX_NUM_ELEMENTS; i++)