#define CONFIG_TOKEN_GLOBAL_BUSY "global.busy"
#define DEBUG_PRINT_INIT_TIMESTAMPS TRUE
-#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 3
+#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 1
static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS];
};
-static void print_init_timestamp(char *message)
+static void print_timestamp_ext(char *message, char *mode)
{
#if DEBUG
#if DEBUG_PRINT_INIT_TIMESTAMPS
+ static char *debug_message = NULL;
static char *last_message = NULL;
static int counter_nr = 0;
int max_depth = DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH;
- if (strPrefix(message, "INIT"))
+ checked_free(debug_message);
+ debug_message = getStringCat3(mode, " ", message);
+
+ if (strEqual(mode, "INIT"))
{
+ debug_print_timestamp(counter_nr, NULL);
+
if (counter_nr + 1 < max_depth)
- {
- debug_print_timestamp(counter_nr, NULL);
- debug_print_timestamp(counter_nr, message);
- }
+ debug_print_timestamp(counter_nr, debug_message);
counter_nr++;
debug_print_timestamp(counter_nr, NULL);
}
- else if (strPrefix(message, "DONE"))
+ else if (strEqual(mode, "DONE"))
{
counter_nr--;
if (counter_nr + 1 < max_depth ||
(counter_nr == 0 && max_depth == 1))
{
- last_message = &message[4];
+ last_message = message;
- debug_print_timestamp(counter_nr, message);
+ if (counter_nr == 0 && max_depth == 1)
+ {
+ checked_free(debug_message);
+ debug_message = getStringCat3("TIME", " ", message);
+ }
+
+ debug_print_timestamp(counter_nr, debug_message);
}
}
- else if (!strPrefix(message, "TIME") ||
- !strSuffix(message, last_message))
+ else if (!strEqual(mode, "TIME") ||
+ !strEqual(message, last_message))
{
if (counter_nr < max_depth)
- debug_print_timestamp(counter_nr, message);
+ debug_print_timestamp(counter_nr, debug_message);
}
#endif
#endif
}
+static void print_timestamp_init(char *message)
+{
+ print_timestamp_ext(message, "INIT");
+}
+
+static void print_timestamp_time(char *message)
+{
+ print_timestamp_ext(message, "TIME");
+}
+
+static void print_timestamp_done(char *message)
+{
+ print_timestamp_ext(message, "DONE");
+}
+
void DrawInitAnim()
{
struct GraphicInfo *graphic_info_last = graphic_info;
int sync_frame = FrameCounter;
int x, y;
+ if (game_status != GAME_MODE_LOADING)
+ return;
+
if (anim_initial.bitmap == NULL || window == NULL)
return;
{
int special = -1;
+ /* (special case: do not use special font for GAME_MODE_LOADING) */
if (game_status >= GAME_MODE_TITLE_INITIAL &&
game_status <= GAME_MODE_PSEUDO_PREVIEW)
special = game_status;
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();
static void ReinitializeGraphics()
{
- print_init_timestamp("INIT ReinitializeGraphics");
+ print_timestamp_init("ReinitializeGraphics");
InitGraphicInfo(); /* graphic properties mapping */
- print_init_timestamp("TIME InitGraphicInfo");
+ print_timestamp_time("InitGraphicInfo");
InitElementGraphicInfo(); /* element game graphic mapping */
- print_init_timestamp("TIME InitElementGraphicInfo");
+ print_timestamp_time("InitElementGraphicInfo");
InitElementSpecialGraphicInfo(); /* element special graphic mapping */
- print_init_timestamp("TIME InitElementSpecialGraphicInfo");
+ print_timestamp_time("InitElementSpecialGraphicInfo");
InitElementSmallImages(); /* scale elements to all needed sizes */
- print_init_timestamp("TIME InitElementSmallImages");
+ print_timestamp_time("InitElementSmallImages");
InitScaledImages(); /* scale all other images, if needed */
- print_init_timestamp("TIME InitScaledImages");
+ print_timestamp_time("InitScaledImages");
InitFontGraphicInfo(); /* initialize text drawing functions */
- print_init_timestamp("TIME InitFontGraphicInfo");
+ print_timestamp_time("InitFontGraphicInfo");
InitGraphicInfo_EM(); /* graphic mapping for EM engine */
- print_init_timestamp("TIME InitGraphicInfo_EM");
+ print_timestamp_time("InitGraphicInfo_EM");
SetMainBackgroundImage(IMG_BACKGROUND);
- print_init_timestamp("TIME SetMainBackgroundImage");
+ print_timestamp_time("SetMainBackgroundImage");
SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
- print_init_timestamp("TIME SetDoorBackgroundImage");
+ print_timestamp_time("SetDoorBackgroundImage");
InitGadgets();
- print_init_timestamp("TIME InitGadgets");
+ print_timestamp_time("InitGadgets");
InitToons();
- print_init_timestamp("TIME InitToons");
+ print_timestamp_time("InitToons");
- print_init_timestamp("DONE ReinitializeGraphics");
+ print_timestamp_done("ReinitializeGraphics");
}
static void ReinitializeSounds()
void InitElementPropertiesStatic()
{
+ static boolean clipboard_elements_initialized = FALSE;
+
static int ep_diggable[] =
{
EL_SAND,
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++)
/* 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)
/* 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) ||
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,
InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
+ InitGfxCustomArtworkInfo();
bitmap_font_initial = LoadCustomImage(filename_font_initial);
static void InitImages()
{
- print_init_timestamp("INIT InitImages");
+ print_timestamp_init("InitImages");
setLevelArtworkDir(artwork.gfx_first);
UPDATE_BUSY_STATE();
ReloadCustomImages();
- print_init_timestamp("TIME ReloadCustomImages");
+ print_timestamp_time("ReloadCustomImages");
UPDATE_BUSY_STATE();
LoadCustomElementDescriptions();
- print_init_timestamp("TIME LoadCustomElementDescriptions");
+ print_timestamp_time("LoadCustomElementDescriptions");
UPDATE_BUSY_STATE();
LoadMenuDesignSettings();
- print_init_timestamp("TIME LoadMenuDesignSettings");
+ print_timestamp_time("LoadMenuDesignSettings");
UPDATE_BUSY_STATE();
ReinitializeGraphics();
- print_init_timestamp("TIME ReinitializeGraphics");
+ print_timestamp_time("ReinitializeGraphics");
UPDATE_BUSY_STATE();
- print_init_timestamp("DONE InitImages");
+ print_timestamp_done("InitImages");
}
static void InitSound(char *identifier)
{
- print_init_timestamp("INIT InitSound");
+ print_timestamp_init("InitSound");
if (identifier == NULL)
identifier = artwork.snd_current->identifier;
setLevelArtworkDir(artwork.snd_first);
InitReloadCustomSounds(identifier);
- print_init_timestamp("TIME InitReloadCustomSounds");
+ print_timestamp_time("InitReloadCustomSounds");
ReinitializeSounds();
- print_init_timestamp("TIME ReinitializeSounds");
+ print_timestamp_time("ReinitializeSounds");
- print_init_timestamp("DONE InitSound");
+ print_timestamp_done("InitSound");
}
static void InitMusic(char *identifier)
{
- print_init_timestamp("INIT InitMusic");
+ print_timestamp_init("InitMusic");
if (identifier == NULL)
identifier = artwork.mus_current->identifier;
setLevelArtworkDir(artwork.mus_first);
InitReloadCustomMusic(identifier);
- print_init_timestamp("TIME InitReloadCustomMusic");
+ print_timestamp_time("InitReloadCustomMusic");
ReinitializeMusic();
- print_init_timestamp("TIME ReinitializeMusic");
+ print_timestamp_time("ReinitializeMusic");
- print_init_timestamp("DONE InitMusic");
+ print_timestamp_done("InitMusic");
}
void InitNetworkServer()
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
void ReloadCustomArtwork(int force_reload)
{
+ int last_game_status = game_status; /* save current game status */
char *gfx_new_identifier;
char *snd_new_identifier;
char *mus_new_identifier;
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);
if (!reload_needed)
return;
- print_init_timestamp("INIT ReloadCustomArtwork");
+ print_timestamp_init("ReloadCustomArtwork");
+
+ game_status = GAME_MODE_LOADING;
+ FadeOut(REDRAW_ALL);
+
+#if 1
+ ClearRectangle(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
+#else
ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
- print_init_timestamp("TIME ClearRectangle");
+#endif
+ print_timestamp_time("ClearRectangle");
+
+#if 0
+ printf("::: fading in ... %d\n", fading.fade_mode);
+#endif
+ FadeIn(REDRAW_ALL);
+#if 0
+ printf("::: done\n");
+#endif
if (gfx_new_identifier != NULL || force_reload_gfx)
{
#endif
InitImages();
- print_init_timestamp("TIME InitImages");
+ print_timestamp_time("InitImages");
}
if (snd_new_identifier != NULL || force_reload_snd)
{
InitSound(snd_new_identifier);
- print_init_timestamp("TIME InitSound");
+ print_timestamp_time("InitSound");
}
if (mus_new_identifier != NULL || force_reload_mus)
{
InitMusic(mus_new_identifier);
- print_init_timestamp("TIME InitMusic");
+ print_timestamp_time("InitMusic");
}
+ 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
+ FadeOut(REDRAW_ALL);
+#if 0
+ printf("::: FadeOut @ ReloadCustomArtwork done\n");
+#endif
+
RedrawBackground();
/* force redraw of (open or closed) door graphics */
SetDoorState(DOOR_OPEN_ALL);
CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
+#if 1
#if 1
#if 1
FadeSetEnterScreen();
- // FadeSkipNextFadeOut();
+ FadeSkipNextFadeOut();
// FadeSetDisabled();
#else
FadeSkipNext();
#else
fading = fading_none;
#endif
+#endif
+
+#if 0
+ redraw_mask = REDRAW_ALL;
+#endif
- print_init_timestamp("DONE ReloadCustomArtwork");
+ print_timestamp_done("ReloadCustomArtwork");
}
void KeyboardAutoRepeatOffUnlessAutoplay()
void OpenAll()
{
- print_init_timestamp("INIT OpenAll");
+ print_timestamp_init("OpenAll");
+
+ game_status = GAME_MODE_LOADING;
InitGlobal(); /* initialize some global variables */
InitJoysticks();
- print_init_timestamp("TIME [pre-video]");
+ print_timestamp_time("[pre-video]");
InitVideoDisplay();
InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
InitElementPropertiesStatic();
InitElementPropertiesEngine(GAME_VERSION_ACTUAL);
- print_init_timestamp("TIME [post-video]");
+ print_timestamp_time("[post-video]");
InitGfx();
- print_init_timestamp("TIME InitGfx");
+ print_timestamp_time("InitGfx");
InitLevelInfo();
- print_init_timestamp("TIME InitLevelInfo");
+ print_timestamp_time("InitLevelInfo");
InitLevelArtworkInfo();
- print_init_timestamp("TIME InitLevelArtworkInfo");
+ print_timestamp_time("InitLevelArtworkInfo");
InitImages(); /* needs to know current level directory */
- print_init_timestamp("TIME InitImages");
+ print_timestamp_time("InitImages");
InitSound(NULL); /* needs to know current level directory */
- print_init_timestamp("TIME InitSound");
+ print_timestamp_time("InitSound");
InitMusic(NULL); /* needs to know current level directory */
- print_init_timestamp("TIME InitMusic");
+ print_timestamp_time("InitMusic");
InitGfxBackground();
fading = fading_none;
#endif
- print_init_timestamp("TIME [post-artwork]");
+ print_timestamp_time("[post-artwork]");
- print_init_timestamp("DONE OpenAll");
+ print_timestamp_done("OpenAll");
DrawMainMenu();