X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Finit.c;h=ea7c8f9a744742b46fdf179a7d40ac3f5b719506;hp=8d2e4a1bd247fd32114f3ea4181318140dbb42ef;hb=17c100ba4bca1cf8475905b6eeb502e581489c5c;hpb=ff84e204dde10499c64dace35dc5c4a017b70765 diff --git a/src/init.c b/src/init.c index 8d2e4a1b..ea7c8f9a 100644 --- a/src/init.c +++ b/src/init.c @@ -84,6 +84,10 @@ static int copy_properties[][5] = }; +/* forward declaration for internal use */ +static int get_graphic_parameter_value(char *, char *, int); + + void DrawInitAnim() { struct GraphicInfo *graphic_info_last = graphic_info; @@ -409,7 +413,7 @@ void InitFontGraphicInfo() int special = property_mapping[i].ext3_index; int graphic = property_mapping[i].artwork_index; - if (font_nr < 0) + if (font_nr < 0 || font_nr >= NUM_FONTS) continue; if (IS_SPECIAL_GFX_ARG(special)) @@ -604,6 +608,19 @@ void InitGlobalAnimGraphicInfo() special = GFX_SPECIAL_ARG_DEFAULT; global_anim_info[anim_nr].graphic[part_nr][special] = graphic; + + /* fix default value for ".draw_masked" (for backward compatibility) */ + struct GraphicInfo *g = &graphic_info[graphic]; + struct FileInfo *image = getImageListEntryFromImageID(graphic); + char **parameter_raw = image->parameter; + int p = GFX_ARG_DRAW_MASKED; + int draw_masked = get_graphic_parameter_value(parameter_raw[p], + image_config_suffix[p].token, + image_config_suffix[p].type); + + /* if ".draw_masked" parameter is undefined, use default value "TRUE" */ + if (draw_masked == ARG_UNDEFINED_VALUE) + g->draw_masked = TRUE; } #if 0 @@ -1258,6 +1275,9 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->anim_delay_random = 0; g->post_delay_fixed = 0; g->post_delay_random = 0; + g->init_event = ANIM_EVENT_DEFAULT; + g->anim_event = ANIM_EVENT_DEFAULT; + g->draw_masked = FALSE; g->draw_order = 0; g->fade_mode = FADE_MODE_DEFAULT; g->fade_delay = -1; @@ -1474,6 +1494,12 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, if (parameter[GFX_ARG_POST_DELAY_RANDOM] != ARG_UNDEFINED_VALUE) g->post_delay_random = parameter[GFX_ARG_POST_DELAY_RANDOM]; + /* used for global animations */ + if (parameter[GFX_ARG_INIT_EVENT] != ARG_UNDEFINED_VALUE) + g->init_event = parameter[GFX_ARG_INIT_EVENT]; + if (parameter[GFX_ARG_ANIM_EVENT] != ARG_UNDEFINED_VALUE) + g->anim_event = parameter[GFX_ARG_ANIM_EVENT]; + /* used for toon animations and global animations */ g->step_offset = parameter[GFX_ARG_STEP_OFFSET]; g->step_xoffset = parameter[GFX_ARG_STEP_XOFFSET]; @@ -1488,8 +1514,14 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->draw_xoffset = parameter[GFX_ARG_DRAW_XOFFSET]; g->draw_yoffset = parameter[GFX_ARG_DRAW_YOFFSET]; - /* this is only used for drawing envelope graphics */ - g->draw_masked = parameter[GFX_ARG_DRAW_MASKED]; + /* use a different default value for global animations and toons */ + if ((graphic >= IMG_GFX_GLOBAL_ANIM_1 && graphic <= IMG_GFX_GLOBAL_ANIM_8) || + (graphic >= IMG_TOON_1 && graphic <= IMG_TOON_20)) + g->draw_masked = TRUE; + + /* this is used for drawing envelopes, global animations and toons */ + if (parameter[GFX_ARG_DRAW_MASKED] != ARG_UNDEFINED_VALUE) + g->draw_masked = parameter[GFX_ARG_DRAW_MASKED]; /* used for toon animations and global animations */ if (parameter[GFX_ARG_DRAW_ORDER] != ARG_UNDEFINED_VALUE) @@ -4690,6 +4722,16 @@ static void InitGlobal() element_info[i].editor_description= element_name_info[i].editor_description; } + for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS + 1; i++) + { + /* 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); + + global_anim_info[i].token_name = global_anim_name_info[i].token_name; + } + /* create hash from image config list */ image_config_hash = newSetupFileHash(); for (i = 0; image_config[i].token != NULL; i++) @@ -4981,6 +5023,8 @@ void Execute_Command(char *command) *str_ptr++ = '\0'; /* terminate leveldir string */ global.convert_level_nr = atoi(str_ptr); /* get level_nr value */ } + + program.headless = TRUE; } else if (strPrefix(command, "create images ")) { @@ -6030,10 +6074,10 @@ void OpenAll() Error(ERR_DEBUG, "::: SDL_AndroidGetExternalStoragePath() == '%s'", SDL_AndroidGetExternalStoragePath()); Error(ERR_DEBUG, "::: SDL_AndroidGetExternalStorageState() == '%s'", - (SDL_AndroidGetExternalStorageState() == - SDL_ANDROID_EXTERNAL_STORAGE_READ ? "read" : - SDL_AndroidGetExternalStorageState() == - SDL_ANDROID_EXTERNAL_STORAGE_WRITE ? "write" : "not available")); + (SDL_AndroidGetExternalStorageState() & + SDL_ANDROID_EXTERNAL_STORAGE_WRITE ? "writable" : + SDL_AndroidGetExternalStorageState() & + SDL_ANDROID_EXTERNAL_STORAGE_READ ? "readable" : "not available")); #endif #endif }