X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Finit.c;h=44b0a5cbb10da6c37d001c37d0818bad679d1abe;hp=bbf62e674f8dd9cb60416716ea11d4cf4628dd62;hb=67f3bfab902e53e0dc24a01eb6c0e4d274030a47;hpb=4cd59cef0737229da365e385a8762e681a5e471f diff --git a/src/init.c b/src/init.c index bbf62e67..44b0a5cb 100644 --- a/src/init.c +++ b/src/init.c @@ -650,15 +650,14 @@ static void InitGlobalAnimGraphicInfo(void) } #if 0 - printf("::: InitGlobalAnimGraphicInfo\n"); - for (i = 0; i < NUM_GLOBAL_ANIMS; i++) for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) if (global_anim_info[i].graphic[j][k] != IMG_UNDEFINED && graphic_info[global_anim_info[i].graphic[j][k]].bitmap != NULL) - printf("::: - anim %d, part %d, mode %d => %d\n", - i, j, k, global_anim_info[i].graphic[j][k]); + Debug("init:InitGlobalAnimGraphicInfo", + "anim %d, part %d, mode %d => %d", + i, j, k, global_anim_info[i].graphic[j][k]); #endif } @@ -700,14 +699,13 @@ static void InitGlobalAnimSoundInfo(void) } #if 0 - printf("::: InitGlobalAnimSoundInfo\n"); - for (i = 0; i < NUM_GLOBAL_ANIMS; i++) for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) if (global_anim_info[i].sound[j][k] != SND_UNDEFINED) - printf("::: - anim %d, part %d, mode %d => %d\n", - i, j, k, global_anim_info[i].sound[j][k]); + Debug("init:InitGlobalAnimSoundInfo", + "anim %d, part %d, mode %d => %d", + i, j, k, global_anim_info[i].sound[j][k]); #endif } @@ -749,14 +747,13 @@ static void InitGlobalAnimMusicInfo(void) } #if 0 - printf("::: InitGlobalAnimMusicInfo\n"); - for (i = 0; i < NUM_GLOBAL_ANIMS; i++) for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) if (global_anim_info[i].music[j][k] != MUS_UNDEFINED) - printf("::: - anim %d, part %d, mode %d => %d\n", - i, j, k, global_anim_info[i].music[j][k]); + Debug("init:InitGlobalAnimMusicInfo", + "anim %d, part %d, mode %d => %d", + i, j, k, global_anim_info[i].music[j][k]); #endif } @@ -1658,7 +1655,7 @@ static void set_cloned_graphic_parameters(int graphic) Warn("custom graphic rejected for this element/action"); if (graphic == fallback_graphic) - Error(ERR_EXIT, "no fallback graphic available"); + Fail("no fallback graphic available"); Warn("fallback done to 'char_exclam' for this graphic"); Warn("---"); @@ -1811,7 +1808,7 @@ static void InitGraphicInfo(void) Warn("custom graphic rejected for this element/action"); if (i == fallback_graphic) - Error(ERR_EXIT, "no fallback graphic available"); + Fail("no fallback graphic available"); Warn("fallback done to 'char_exclam' for this graphic"); Warn("---"); @@ -1842,7 +1839,7 @@ static void InitGraphicInfo(void) Warn("custom graphic rejected for this element/action"); if (i == fallback_graphic) - Error(ERR_EXIT, "no fallback graphic available"); + Fail("no fallback graphic available"); Warn("fallback done to 'char_exclam' for this graphic"); Warn("---"); @@ -1882,7 +1879,10 @@ static void InitGraphicCompatibilityInfo(void) // process all images which default to same image as "global.door" if (strEqual(fi->default_filename, fi_global_door->default_filename)) { - // printf("::: special treatment needed for token '%s'\n", fi->token); +#if 0 + Debug("init:InitGraphicCompatibilityInfo", + "special treatment needed for token '%s'", fi->token); +#endif graphic_info[i].bitmaps = graphic_info[IMG_GLOBAL_DOOR].bitmaps; graphic_info[i].bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap; @@ -4782,7 +4782,7 @@ static void InitGlobal(void) { // check if element_name_info entry defined for each element in "main.h" if (i < MAX_NUM_ELEMENTS && element_name_info[i].token_name == NULL) - Error(ERR_EXIT, "undefined 'element_name_info' entry for element %d", i); + Fail("undefined 'element_name_info' entry for element %d", i); element_info[i].token_name = element_name_info[i].token_name; element_info[i].class_name = element_name_info[i].class_name; @@ -4794,7 +4794,7 @@ static void InitGlobal(void) // check if global_anim_name_info defined for each entry in "main.h" if (i < NUM_GLOBAL_ANIM_TOKENS && global_anim_name_info[i].token_name == NULL) - Error(ERR_EXIT, "undefined 'global_anim_name_info' entry for anim %d", i); + Fail("undefined 'global_anim_name_info' entry for anim %d", i); global_anim_info[i].token_name = global_anim_name_info[i].token_name; } @@ -5011,7 +5011,7 @@ static void Execute_Command(char *command) char *filename = &command[11]; if (!fileExists(filename)) - Error(ERR_EXIT, "cannot open file '%s'", filename); + Fail("cannot open file '%s'", filename); LoadLevelFromFilename(&level, filename); DumpLevel(&level); @@ -5023,7 +5023,7 @@ static void Execute_Command(char *command) char *filename = &command[10]; if (!fileExists(filename)) - Error(ERR_EXIT, "cannot open file '%s'", filename); + Fail("cannot open file '%s'", filename); LoadTapeFromFilename(filename); DumpTape(&tape); @@ -5090,7 +5090,7 @@ static void Execute_Command(char *command) str_ptr++; if (*str_ptr == '\0') - Error(ERR_EXIT, "cannot find MODE in command '%s'", command); + Fail("cannot find MODE in command '%s'", command); global.patchtapes_mode = str_ptr; // store patch mode @@ -5135,7 +5135,7 @@ static void Execute_Command(char *command) if (strEqual(global.patchtapes_mode, "help")) global.patchtapes_leveldir = UNDEFINED_LEVELSET; else - Error(ERR_EXIT, "cannot find LEVELDIR in command '%s'", command); + Fail("cannot find LEVELDIR in command '%s'", command); } program.headless = TRUE; @@ -5161,8 +5161,8 @@ static void Execute_Command(char *command) global.create_images_dir = getStringCopy(&command[14]); if (access(global.create_images_dir, W_OK) != 0) - Error(ERR_EXIT, "image target directory '%s' not found or not writable", - global.create_images_dir); + Fail("image target directory '%s' not found or not writable", + global.create_images_dir); } else if (strPrefix(command, "create CE image ")) { @@ -5172,7 +5172,7 @@ static void Execute_Command(char *command) } else { - Error(ERR_EXIT_HELP, "unrecognized command '%s'", command); + FailWithHelp("unrecognized command '%s'", command); } // disable networking if any valid command was recognized @@ -5463,7 +5463,7 @@ static void InitGfx(void) } if (filename_font_initial == NULL) // should not happen - Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL); + Fail("cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL); InitGfxBuffers(); InitGfxCustomArtworkInfo(); @@ -5549,7 +5549,7 @@ static void InitGfx(void) } if (filename_anim_initial == NULL) // should not happen - Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_GLOBAL_BUSY); + Fail("cannot get filename for '%s'", CONFIG_TOKEN_GLOBAL_BUSY); anim_initial.bitmaps = checked_calloc(sizeof(Bitmap *) * NUM_IMG_BITMAP_POINTERS); @@ -5621,36 +5621,36 @@ static void InitImages(void) print_timestamp_init("InitImages"); #if 0 - printf("::: leveldir_current->identifier == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); - printf("::: leveldir_current->graphics_path == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); - printf("::: leveldir_current->graphics_set == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); - printf("::: getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'\n", - leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); + Debug("init:InitImages", "leveldir_current->identifier == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); + Debug("init:InitImages", "leveldir_current->graphics_path == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); + Debug("init:InitImages", "leveldir_current->graphics_set == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); + Debug("init:InitImages", "getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'", + leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); #endif setLevelArtworkDir(artwork.gfx_first); #if 0 - printf("::: leveldir_current->identifier == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); - printf("::: leveldir_current->graphics_path == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); - printf("::: leveldir_current->graphics_set == '%s'\n", + Debug("init:InitImages", "leveldir_current->identifier == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); + Debug("init:InitImages", "leveldir_current->graphics_path == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); + Debug("init:InitImages", "leveldir_current->graphics_set == '%s'", leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); - printf("::: getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'\n", - leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); + Debug("init:InitImages", "getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'", + leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); #endif #if 0 - printf("::: InitImages for '%s' ['%s', '%s'] ['%s', '%s']\n", - leveldir_current->identifier, - artwork.gfx_current_identifier, - artwork.gfx_current->identifier, - leveldir_current->graphics_set, - leveldir_current->graphics_path); + Debug("init:InitImages", "InitImages for '%s' ['%s', '%s'] ['%s', '%s']", + leveldir_current->identifier, + artwork.gfx_current_identifier, + artwork.gfx_current->identifier, + leveldir_current->graphics_set, + leveldir_current->graphics_path); #endif UPDATE_BUSY_STATE(); @@ -5809,22 +5809,27 @@ static boolean CheckArtworkTypeForRedefinedCustomElements(int type) setLevelArtworkDir(ARTWORK_FIRST_NODE(artwork, type)); #if 0 - printf("::: leveldir_current->identifier == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); - printf("::: leveldir_current->graphics_path == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); - printf("::: leveldir_current->graphics_set == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); - printf("::: getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'\n", - leveldir_current == NULL ? "[NULL]" : - LEVELDIR_ARTWORK_SET(leveldir_current, type)); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "leveldir_current->identifier == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "leveldir_current->graphics_path == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "leveldir_current->graphics_set == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'", + leveldir_current == NULL ? "[NULL]" : + LEVELDIR_ARTWORK_SET(leveldir_current, type)); #endif // first look for special artwork configured in level series config filename_base = getCustomArtworkLevelConfigFilename(type); #if 0 - printf("::: filename_base == '%s'\n", filename_base); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "filename_base == '%s'", filename_base); #endif if (fileExists(filename_base)) @@ -5833,14 +5838,16 @@ static boolean CheckArtworkTypeForRedefinedCustomElements(int type) filename_local = getCustomArtworkConfigFilename(type); #if 0 - printf("::: filename_local == '%s'\n", filename_local); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "filename_local == '%s'", filename_local); #endif 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); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "redefined_ce_found == %d", redefined_ce_found); #endif return redefined_ce_found; @@ -5865,7 +5872,8 @@ static void InitOverrideArtwork(void) CheckArtworkTypeForRedefinedCustomElements(ARTWORK_TYPE_MUSIC)); #if 0 - printf("::: redefined_ce_found == %d\n", redefined_ce_found); + Debug("init:InitOverrideArtwork", "redefined_ce_found == %d", + redefined_ce_found); #endif if (redefined_ce_found) @@ -5884,10 +5892,10 @@ static void InitOverrideArtwork(void) } #if 0 - printf("::: => %d, %d, %d\n", - gfx.override_level_graphics, - gfx.override_level_sounds, - gfx.override_level_music); + Debug("init:InitOverrideArtwork", "%d, %d, %d", + gfx.override_level_graphics, + gfx.override_level_sounds, + gfx.override_level_music); #endif } @@ -6003,11 +6011,12 @@ void ReloadCustomArtwork(int force_reload) if (gfx_new_identifier != NULL || force_reload_gfx) { #if 0 - printf("RELOADING GRAPHICS '%s' -> '%s' ['%s', '%s']\n", - artwork.gfx_current_identifier, - gfx_new_identifier, - artwork.gfx_current->identifier, - leveldir_current->graphics_set); + Debug("init:ReloadCustomArtwork", + "RELOADING GRAPHICS '%s' -> '%s' ['%s', '%s']", + artwork.gfx_current_identifier, + gfx_new_identifier, + artwork.gfx_current->identifier, + leveldir_current->graphics_set); #endif InitImages(); @@ -6293,8 +6302,8 @@ void CloseAllAndExit(int exit_value) // using SDL_WaitThread() // // Code used with SDL 1.2: - // if (network_server) // terminate network server - // SDL_KillThread(server_thread); + // if (network.server_thread) // terminate network server + // SDL_KillThread(network.server_thread); CloseVideoDisplay(); ClosePlatformDependentStuff();