X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=5d1867a2a1af1f37e1174e091fbaa706ae7ba82e;hb=bca0a1d2e0c7d05f0dfb1d1c62c85715c63652ba;hp=512c2756d2bdb8478cc8d46a9ce99a7deaad5eca;hpb=28514fc1f1f57cd280c32fba47eed6893caa3641;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 512c2756..5d1867a2 100644 --- a/src/init.c +++ b/src/init.c @@ -5422,6 +5422,7 @@ void InitGfx() InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE); InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE); InitGfxScrollbufferInfo(FXSIZE, FYSIZE); + InitGfxCustomArtworkInfo(); bitmap_font_initial = LoadCustomImage(filename_font_initial); @@ -5656,6 +5657,78 @@ void InitNetworkServer() #endif } +static boolean 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; + + break; + } + } + END_HASH_ITERATION(setup_file_hash, itr) + + freeSetupFileHash(setup_file_hash); + } + + return redefined_ce_found; +} + +static void InitOverrideArtwork() +{ + boolean init_override_from_setup = TRUE; + + gfx.override_level_graphics = FALSE; + gfx.override_level_sounds = FALSE; + gfx.override_level_music = FALSE; + + if (setup.auto_override_artwork) + { + char *filename_base, *filename_local; + boolean redefined_ce_found = FALSE; + + /* first look for special artwork configured in level series config */ + filename_base = getCustomArtworkLevelConfigFilename(ARTWORK_TYPE_GRAPHICS); + + if (fileExists(filename_base)) + redefined_ce_found |= CheckArtworkConfigForCustomElements(filename_base); + + filename_local = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS); + + if (filename_local != NULL && !strEqual(filename_base, filename_local)) + redefined_ce_found |= CheckArtworkConfigForCustomElements(filename_local); + +#if 0 + printf("::: redefined_ce_found == %d\n", redefined_ce_found); +#endif + + if (!redefined_ce_found) + { + gfx.override_level_graphics = TRUE; + gfx.override_level_sounds = TRUE; + gfx.override_level_music = TRUE; + + init_override_from_setup = FALSE; + } + } + + if (init_override_from_setup) + { + gfx.override_level_graphics = setup.override_level_graphics; + gfx.override_level_sounds = setup.override_level_sounds; + gfx.override_level_music = setup.override_level_music; + } +} + static char *getNewArtworkIdentifier(int type) { static char *leveldir_current_identifier[3] = { NULL, NULL, NULL }; @@ -5663,7 +5736,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 @@ -5780,6 +5857,8 @@ void ReloadCustomArtwork(int force_reload) boolean force_reload_mus = (force_reload & (1 << ARTWORK_TYPE_MUSIC)); boolean reload_needed; + InitOverrideArtwork(); + force_reload_gfx |= AdjustGraphicsForEMC(); gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS);