X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=4711b34394e3d88db8ca50e548abc47fdfcc3fbd;hb=56814df201c2d86273cf54e0e94c0448ce9bdd0f;hp=79c3d58815324d1e1a2dec1ed7feba7aa36b8085;hpb=6b64e704d628cdbf7a49d6025dce715dfd829125;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 79c3d588..4711b343 100644 --- a/src/init.c +++ b/src/init.c @@ -587,6 +587,58 @@ void InitFontGraphicInfo() getFontBitmapID, getFontFromToken); } +static void CheckArtworkConfigForCustomElements(char *filename) +{ + SetupFileHash *setup_file_hash; + boolean redefined_ce_found = FALSE; + + if ((setup_file_hash = loadSetupFileHash(filename)) != NULL) + { + BEGIN_HASH_ITERATION(setup_file_hash, itr) + { + char *token = HASH_ITERATION_TOKEN(itr); + + if (strPrefix(token, "custom_")) + redefined_ce_found = TRUE; + } + END_HASH_ITERATION(setup_file_hash, itr) + + freeSetupFileHash(setup_file_hash); + } + + printf("::: redefined_ce_found == %d [%s]\n", redefined_ce_found, filename); +} + +static void CheckCustomElementGraphicInfo() +{ + struct PropertyMapping *property_mapping = getImageListPropertyMapping(); + int num_property_mappings = getImageListPropertyMappingSize(); + boolean redefined_ce_found = FALSE; + int i; + + /* check normal element/graphic mapping from static configuration */ + for (i = 0; element_to_graphic[i].element > -1; i++) + { + int element = element_to_graphic[i].element; + int graphic = element_to_graphic[i].graphic; + + if (IS_CUSTOM_ELEMENT(element)) + if (getImageListEntryFromImageID(graphic)->redefined) + redefined_ce_found = TRUE; + } + + /* check normal element/graphic mapping from dynamic configuration */ + for (i = 0; i < num_property_mappings; i++) + { + int element = property_mapping[i].base_index; + + if (IS_CUSTOM_ELEMENT(element)) + redefined_ce_found = TRUE; + } + + printf("::: redefined_ce_found == %d\n", redefined_ce_found); +} + void InitElementGraphicInfo() { struct PropertyMapping *property_mapping = getImageListPropertyMapping(); @@ -2605,6 +2657,8 @@ void ResolveGroupElement(int group_element) void InitElementPropertiesStatic() { + static boolean clipboard_elements_initialized = FALSE; + static int ep_diggable[] = { EL_SAND, @@ -4553,9 +4607,12 @@ void InitElementPropertiesStatic() int i, j, k; /* always start with reliable default values (element has no properties) */ + /* (but never initialize clipboard elements after the very first time) */ + /* (to be able to use clipboard elements between several levels) */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) - for (j = 0; j < NUM_ELEMENT_PROPERTIES; j++) - SET_PROPERTY(i, j, FALSE); + if (!IS_CLIPBOARD_ELEMENT(i) || !clipboard_elements_initialized) + for (j = 0; j < NUM_ELEMENT_PROPERTIES; j++) + SET_PROPERTY(i, j, FALSE); /* set all base element properties from above array definitions */ for (i = 0; element_properties[i].elements != NULL; i++) @@ -4573,6 +4630,8 @@ void InitElementPropertiesStatic() /* set static element properties that are not listed in array definitions */ for (i = EL_STEEL_CHAR_START; i <= EL_STEEL_CHAR_END; i++) SET_PROPERTY(i, EP_INDESTRUCTIBLE, TRUE); + + clipboard_elements_initialized = TRUE; } void InitElementPropertiesEngine(int engine_version) @@ -4621,6 +4680,10 @@ void InitElementPropertiesEngine(int engine_version) /* set all special, combined or engine dependent element properties */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) { + /* do not change (already initialized) clipboard elements here */ + if (IS_CLIPBOARD_ELEMENT(i)) + continue; + /* ---------- INACTIVE ------------------------------------------------- */ SET_PROPERTY(i, EP_INACTIVE, ((i >= EL_CHAR_START && i <= EL_CHAR_END) || @@ -5402,6 +5465,7 @@ void InitGfx() bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); bitmap_db_panel = CreateBitmap(DXSIZE, DYSIZE, DEFAULT_DEPTH); bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); + bitmap_db_toons = CreateBitmap(FULL_SXSIZE, FULL_SYSIZE, DEFAULT_DEPTH); /* initialize screen properties */ InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE, @@ -5410,6 +5474,7 @@ void InitGfx() InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE); InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE); InitGfxScrollbufferInfo(FXSIZE, FYSIZE); + InitGfxCustomArtworkInfo(); bitmap_font_initial = LoadCustomImage(filename_font_initial); @@ -5651,7 +5716,11 @@ static char *getNewArtworkIdentifier(int type) static boolean last_has_level_artwork_set[3] = { FALSE, FALSE, FALSE }; static boolean initialized[3] = { FALSE, FALSE, FALSE }; TreeInfo *artwork_first_node = ARTWORK_FIRST_NODE(artwork, type); +#if 1 + boolean setup_override_artwork = GFX_OVERRIDE_ARTWORK(type); +#else boolean setup_override_artwork = SETUP_OVERRIDE_ARTWORK(setup, type); +#endif char *setup_artwork_set = SETUP_ARTWORK_SET(setup, type); char *leveldir_identifier = leveldir_current->identifier; #if 1 @@ -5768,6 +5837,44 @@ void ReloadCustomArtwork(int force_reload) boolean force_reload_mus = (force_reload & (1 << ARTWORK_TYPE_MUSIC)); boolean reload_needed; +#if 1 + gfx.draw_init_text = FALSE; + + gfx.override_level_graphics = FALSE; + gfx.override_level_sounds = FALSE; + gfx.override_level_music = FALSE; + +#if 0 + LoadImageConfig(); +#endif +#if 0 + CheckCustomElementGraphicInfo(); +#endif + +#if 1 + { + char *filename_base, *filename_local; + + /* first look for special artwork configured in level series config */ + filename_base = getCustomArtworkLevelConfigFilename(ARTWORK_TYPE_GRAPHICS); + + if (fileExists(filename_base)) + CheckArtworkConfigForCustomElements(filename_base); + + filename_local = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS); + + if (filename_local != NULL && !strEqual(filename_base, filename_local)) + CheckArtworkConfigForCustomElements(filename_local); + } +#endif + + gfx.override_level_graphics = setup.override_level_graphics; + gfx.override_level_sounds = setup.override_level_sounds; + gfx.override_level_music = setup.override_level_music; + + gfx.draw_init_text = TRUE; +#endif + force_reload_gfx |= AdjustGraphicsForEMC(); gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS); @@ -5830,6 +5937,11 @@ void ReloadCustomArtwork(int force_reload) game_status = last_game_status; /* restore current game status */ +#if 0 + printf("::: ----------------DELAY 1 ...\n"); + Delay(3000); +#endif + #if 0 printf("::: FadeOut @ ReloadCustomArtwork ...\n"); #endif @@ -5844,6 +5956,7 @@ void ReloadCustomArtwork(int force_reload) SetDoorState(DOOR_OPEN_ALL); CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); +#if 1 #if 1 #if 1 FadeSetEnterScreen(); @@ -5855,6 +5968,11 @@ void ReloadCustomArtwork(int force_reload) #else fading = fading_none; #endif +#endif + +#if 0 + redraw_mask = REDRAW_ALL; +#endif print_timestamp_done("ReloadCustomArtwork"); }