From: Holger Schemel Date: Wed, 24 Nov 2004 00:57:28 +0000 (+0100) Subject: rnd-20041124-1-src X-Git-Tag: 3.1.1^2~47 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c42862bb754d7a8b1ff476887669650845f7570e;p=rocksndiamonds.git rnd-20041124-1-src --- diff --git a/src/cartoons.c b/src/cartoons.c index fd53e502..55c36b5b 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -74,7 +74,7 @@ void InitToons() for (i=0; i < num_toons; i++) { int graphic = IMG_TOON_1 + i; - struct FileInfo *image = getImageListEntry(graphic); + struct FileInfo *image = getImageListEntryFromImageID(graphic); toons[i].bitmap = graphic_info[graphic].bitmap; diff --git a/src/conftime.h b/src/conftime.h index cfb6f7ff..6b86fe8b 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-11-22 02:34]" +#define COMPILE_DATE_STRING "[2004-11-24 01:32]" diff --git a/src/files.c b/src/files.c index f1c17f8e..abcf15d2 100644 --- a/src/files.c +++ b/src/files.c @@ -2104,7 +2104,7 @@ void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) level->field[ply2->x_initial - 1][ply2->y_initial - 1] = EL_PLAYER_2; level->field[ply1->x_initial - 1][ply1->y_initial - 1] = EL_PLAYER_1; -#if 1 +#if 0 printf("::: native Emerald Mine file version: %d\n", level_em->file_version); #endif } diff --git a/src/game_em/game_em.h b/src/game_em/game_em.h index 725d808c..f2800523 100644 --- a/src/game_em/game_em.h +++ b/src/game_em/game_em.h @@ -28,7 +28,7 @@ extern void UpdateEngineValues(int, int); extern void DrawGameDoorValues_EM(int, int, int, int); extern int getGameFrameDelay_EM(int); extern void PlayLevelSound_EM(int, int, int, int); -extern void InitGraphicsInfoEM(void); +extern void InitGraphicInfo_EM(void); /* ========================================================================= */ diff --git a/src/game_em/tab_generate.c b/src/game_em/tab_generate.c index a72fed83..a35bbd5c 100644 --- a/src/game_em/tab_generate.c +++ b/src/game_em/tab_generate.c @@ -4493,7 +4493,7 @@ void create_obj_graphics_info_em() } } - InitGraphicsInfoEM(); + InitGraphicInfo_EM(); } void create_spr() diff --git a/src/init.c b/src/init.c index 67d58102..b02d0883 100644 --- a/src/init.c +++ b/src/init.c @@ -258,12 +258,19 @@ void InitElementSmallImages() for (i = 0; element_to_special_graphic[i].element > -1; i++) InitElementSmallImagesScaledUp(element_to_special_graphic[i].graphic); - /* initialize images from dynamic configuration */ + /* initialize images from dynamic configuration (may be elements or other) */ +#if 1 + for (i = 0; i < num_property_mappings; i++) + InitElementSmallImagesScaledUp(property_mapping[i].artwork_index); +#else + /* !!! THIS DOES NOT WORK -- "artwork_index" is graphic, not element !!! */ + /* !!! ALSO, non-element graphics might need scaling-up !!! */ for (i = 0; i < num_property_mappings; i++) if (property_mapping[i].artwork_index < MAX_NUM_ELEMENTS) InitElementSmallImagesScaledUp(property_mapping[i].artwork_index); +#endif -#if 1 +#if 0 /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */ for (i = IMG_EMC_OBJECT; i <= IMG_EMC_SPRITE; i++) InitElementSmallImagesScaledUp(i); @@ -468,8 +475,10 @@ void InitElementGraphicInfo() if ((action > -1 || direction > -1 || crumbled == TRUE) && base_graphic != -1) { - boolean base_redefined = getImageListEntry(base_graphic)->redefined; - boolean act_dir_redefined = getImageListEntry(graphic)->redefined; + boolean base_redefined = + getImageListEntryFromImageID(base_graphic)->redefined; + boolean act_dir_redefined = + getImageListEntryFromImageID(graphic)->redefined; /* if the base graphic ("emerald", for example) has been redefined, but not the action graphic ("emerald.falling", for example), do not @@ -851,8 +860,10 @@ void InitElementSpecialGraphicInfo() int special = element_to_special_graphic[i].special; int graphic = element_to_special_graphic[i].graphic; int base_graphic = el2baseimg(element); - boolean base_redefined = getImageListEntry(base_graphic)->redefined; - boolean special_redefined = getImageListEntry(graphic)->redefined; + boolean base_redefined = + getImageListEntryFromImageID(base_graphic)->redefined; + boolean special_redefined = + getImageListEntryFromImageID(graphic)->redefined; /* if the base graphic ("emerald", for example) has been redefined, but not the special graphic ("emerald.EDITOR", for example), do not @@ -899,9 +910,27 @@ static int get_element_from_token(char *token) return -1; } -static void set_graphic_parameters(int graphic, char **parameter_raw) +static int get_scaled_graphic_width(int graphic) { - Bitmap *src_bitmap = getBitmapFromImageID(graphic); + int original_width = getOriginalImageWidthFromImageID(graphic); + int scale_up_factor = graphic_info[graphic].scale_up_factor; + + return original_width * scale_up_factor; +} + +static int get_scaled_graphic_height(int graphic) +{ + int original_height = getOriginalImageHeightFromImageID(graphic); + int scale_up_factor = graphic_info[graphic].scale_up_factor; + + return original_height * scale_up_factor; +} + +static void set_graphic_parameters(int graphic, int graphic_copy_from) +{ + struct FileInfo *image = getImageListEntryFromImageID(graphic_copy_from); + char **parameter_raw = image->parameter; + Bitmap *src_bitmap = getBitmapFromImageID(graphic_copy_from); int parameter[NUM_GFX_ARGS]; int anim_frames_per_row = 1, anim_frames_per_col = 1; int anim_frames_per_line = 1; @@ -964,10 +993,9 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) if (src_bitmap) { - /* bitmap is not scaled at this stage, so calculate final size */ - int scale_up_factor = graphic_info[graphic].scale_up_factor; - int src_bitmap_width = src_bitmap->width * scale_up_factor; - int src_bitmap_height = src_bitmap->height * scale_up_factor; + /* get final bitmap size (with scaling, but without small images) */ + int src_bitmap_width = get_scaled_graphic_width(graphic); + int src_bitmap_height = get_scaled_graphic_height(graphic); anim_frames_per_row = src_bitmap_width / graphic_info[graphic].width; anim_frames_per_col = src_bitmap_height / graphic_info[graphic].height; @@ -1094,8 +1122,6 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) static void InitGraphicInfo() { int fallback_graphic = IMG_CHAR_EXCLAM; - struct FileInfo *fallback_image = getImageListEntry(fallback_graphic); - Bitmap *fallback_bitmap = getBitmapFromImageID(fallback_graphic); int num_images = getImageListSize(); int i; @@ -1133,11 +1159,10 @@ static void InitGraphicInfo() for (i = 0; i < num_images; i++) { - struct FileInfo *image = getImageListEntry(i); Bitmap *src_bitmap; int src_x, src_y; int first_frame, last_frame; - int scale_up_factor, src_bitmap_width, src_bitmap_height; + int src_bitmap_width, src_bitmap_height; #if 0 printf("::: image: '%s' [%d]\n", image->token, i); @@ -1149,17 +1174,16 @@ static void InitGraphicInfo() getTokenFromImageID(i)); #endif - set_graphic_parameters(i, image->parameter); + set_graphic_parameters(i, i); /* now check if no animation frames are outside of the loaded image */ if (graphic_info[i].bitmap == NULL) continue; /* skip check for optional images that are undefined */ - /* bitmap is not scaled at this stage, so calculate final size */ - scale_up_factor = graphic_info[i].scale_up_factor; - src_bitmap_width = graphic_info[i].bitmap->width * scale_up_factor; - src_bitmap_height = graphic_info[i].bitmap->height * scale_up_factor; + /* get final bitmap size (with scaling, but without small images) */ + src_bitmap_width = get_scaled_graphic_width(i); + src_bitmap_height = get_scaled_graphic_height(i); first_frame = 0; getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); @@ -1190,8 +1214,7 @@ static void InitGraphicInfo() Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic"); Error(ERR_RETURN_LINE, "-"); - set_graphic_parameters(i, fallback_image->default_parameter); - graphic_info[i].bitmap = fallback_bitmap; + set_graphic_parameters(i, fallback_graphic); } last_frame = graphic_info[i].anim_frames - 1; @@ -1219,8 +1242,7 @@ static void InitGraphicInfo() Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic"); Error(ERR_RETURN_LINE, "-"); - set_graphic_parameters(i, fallback_image->default_parameter); - graphic_info[i].bitmap = fallback_bitmap; + set_graphic_parameters(i, fallback_graphic); } #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) @@ -1698,6 +1720,8 @@ static void ReinitializeGraphics() InitElementSmallImages(); /* scale images to all needed sizes */ InitFontGraphicInfo(); /* initialize text drawing functions */ + InitGraphicInfo_EM(); /* graphic mapping for EM engine */ + SetMainBackgroundImage(IMG_BACKGROUND); SetDoorBackgroundImage(IMG_BACKGROUND_DOOR); diff --git a/src/libgame/image.c b/src/libgame/image.c index 72e9580c..1475fe1e 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -820,7 +820,12 @@ struct ImageInfo int num_references; Bitmap *bitmap; - boolean contains_small_images; + + int original_width; /* original image file width */ + int original_height; /* original image file height */ + + boolean contains_small_images; /* set after adding small images */ + boolean scaled_up; /* set after scaling up */ }; typedef struct ImageInfo ImageInfo; @@ -846,7 +851,11 @@ static void *Load_PCX(char *filename) img_info->source_filename = getStringCopy(filename); + img_info->original_width = img_info->bitmap->width; + img_info->original_height = img_info->bitmap->height; + img_info->contains_small_images = FALSE; + img_info->scaled_up = FALSE; return img_info; } @@ -873,7 +882,7 @@ int getImageListSize() image_info->num_dynamic_file_list_entries); } -struct FileInfo *getImageListEntry(int pos) +struct FileInfo *getImageListEntryFromImageID(int pos) { int num_list_entries = image_info->num_file_list_entries; int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries); @@ -895,33 +904,30 @@ static ImageInfo *getImageInfoEntryFromImageID(int pos) Bitmap *getBitmapFromImageID(int pos) { -#if 0 - int num_list_entries = image_info->num_file_list_entries; - int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries); - ImageInfo **img_info = - (ImageInfo **)(pos < num_list_entries ? image_info->artwork_list : - image_info->dynamic_artwork_list); - - return (img_info[list_pos] != NULL ? img_info[list_pos]->bitmap : NULL); -#else ImageInfo *img_info = getImageInfoEntryFromImageID(pos); return (img_info != NULL ? img_info->bitmap : NULL); -#endif } -char *getTokenFromImageID(int graphic) +int getOriginalImageWidthFromImageID(int pos) { -#if 0 - /* !!! this does not work for dynamic artwork (crash!) !!! */ - struct FileInfo *file_list = (struct FileInfo *)image_info->file_list; + ImageInfo *img_info = getImageInfoEntryFromImageID(pos); + + return (img_info != NULL ? img_info->original_width : 0); +} + +int getOriginalImageHeightFromImageID(int pos) +{ + ImageInfo *img_info = getImageInfoEntryFromImageID(pos); + + return (img_info != NULL ? img_info->original_height : 0); +} - return file_list[graphic].token; -#else - struct FileInfo *file_list = getImageListEntry(graphic); +char *getTokenFromImageID(int graphic) +{ + struct FileInfo *file_list = getImageListEntryFromImageID(graphic); return (file_list != NULL ? file_list->token : NULL); -#endif } int getImageIDFromToken(char *token) @@ -1047,6 +1053,7 @@ void CreateImageWithSmallImages(int pos, int zoom_factor) CreateBitmapWithSmallBitmaps(img_info->bitmap, zoom_factor); img_info->contains_small_images = TRUE; + img_info->scaled_up = TRUE; #if 0 if (zoom_factor) diff --git a/src/libgame/image.h b/src/libgame/image.h index 1b98bbf6..3a2ac202 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -77,8 +77,10 @@ int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *); #endif /* TARGET_X11 */ int getImageListSize(); -struct FileInfo *getImageListEntry(int); +struct FileInfo *getImageListEntryFromImageID(int); Bitmap *getBitmapFromImageID(int); +int getOriginalImageWidthFromImageID(int); +int getOriginalImageHeightFromImageID(int); char *getTokenFromImageID(int); int getImageIDFromToken(char *); char *getImageConfigFilename(); diff --git a/src/tools.c b/src/tools.c index 57294eeb..ba053b0d 100644 --- a/src/tools.c +++ b/src/tools.c @@ -5305,7 +5305,7 @@ unsigned int InitRND(long seed) return InitEngineRND(seed); } -void InitGraphicsInfoEM(void) +void InitGraphicInfo_EM(void) { int mapping_EM_to_RND_element[TILE_MAX]; int mapping_EM_to_RND_action[TILE_MAX]; @@ -5515,11 +5515,6 @@ void InitGraphicsInfoEM(void) int cx = ABS(dx) * TILEX / 8; int cy = ABS(dy) * TILEY / 8; -#if 0 - if (i == Yemerald_sB) - printf("::: %d: ...\n", j); -#endif - if (backside) /* tile where movement starts */ { if (dx < 0 || dy < 0) diff --git a/src/tools.h b/src/tools.h index f79e84f0..18c196f1 100644 --- a/src/tools.h +++ b/src/tools.h @@ -151,5 +151,6 @@ int el2edimg(int); int el2preimg(int); unsigned int InitRND(long); +void InitGraphicInfo_EM(void); #endif /* TOOLS_H */