X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=c41af9fb25ba1cdb4aeec37f96f9eea2226db704;hb=ed5a795f1fd2d48a1372d46c06d86d2faab7e3c4;hp=7a70610eda39e90583ff2840afe54990699eacd3;hpb=30f635b58c076871cee2630ce15ffd7019764b2e;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 7a70610e..c41af9fb 100644 --- a/src/init.c +++ b/src/init.c @@ -39,7 +39,7 @@ #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]; @@ -89,48 +89,72 @@ static int copy_properties[][5] = }; -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; @@ -140,6 +164,9 @@ void DrawInitAnim() int sync_frame = FrameCounter; int x, y; + if (game_status != GAME_MODE_LOADING) + return; + if (anim_initial.bitmap == NULL || window == NULL) return; @@ -289,6 +316,7 @@ static int getFontBitmapID(int font_nr) { 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; @@ -2343,36 +2371,36 @@ static void InitMusicInfo() 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() @@ -2577,6 +2605,8 @@ void ResolveGroupElement(int group_element) void InitElementPropertiesStatic() { + static boolean clipboard_elements_initialized = FALSE; + static int ep_diggable[] = { EL_SAND, @@ -4525,9 +4555,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++) @@ -4545,6 +4578,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) @@ -4593,6 +4628,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) || @@ -5517,7 +5556,7 @@ void InitLevelArtworkInfo() static void InitImages() { - print_init_timestamp("INIT InitImages"); + print_timestamp_init("InitImages"); setLevelArtworkDir(artwork.gfx_first); @@ -5533,31 +5572,31 @@ static void InitImages() 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; @@ -5566,17 +5605,17 @@ static void InitSound(char *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; @@ -5585,12 +5624,12 @@ static void InitMusic(char *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() @@ -5731,6 +5770,7 @@ static char *getNewArtworkIdentifier(int type) 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; @@ -5752,10 +5792,26 @@ void ReloadCustomArtwork(int force_reload) 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) { @@ -5768,31 +5824,47 @@ void ReloadCustomArtwork(int force_reload) #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(); @@ -5800,8 +5872,13 @@ void ReloadCustomArtwork(int force_reload) #else fading = fading_none; #endif +#endif + +#if 0 + redraw_mask = REDRAW_ALL; +#endif - print_init_timestamp("DONE ReloadCustomArtwork"); + print_timestamp_done("ReloadCustomArtwork"); } void KeyboardAutoRepeatOffUnlessAutoplay() @@ -5817,7 +5894,9 @@ void KeyboardAutoRepeatOffUnlessAutoplay() void OpenAll() { - print_init_timestamp("INIT OpenAll"); + print_timestamp_init("OpenAll"); + + game_status = GAME_MODE_LOADING; InitGlobal(); /* initialize some global variables */ @@ -5850,7 +5929,7 @@ void OpenAll() InitJoysticks(); - print_init_timestamp("TIME [pre-video]"); + print_timestamp_time("[pre-video]"); InitVideoDisplay(); InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); @@ -5860,26 +5939,26 @@ void OpenAll() 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(); @@ -5909,9 +5988,9 @@ void OpenAll() 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();