From: Holger Schemel Date: Mon, 27 Jan 2003 03:34:37 +0000 (+0100) Subject: rnd-20030127-3-src X-Git-Tag: 3.0.0^2~155 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=56c6c0e7a97a0831480dd9fdac411923b046ba38;p=rocksndiamonds.git rnd-20030127-3-src --- diff --git a/src/conftime.h b/src/conftime.h index a0e88a3c..770195c4 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-01-27 02:43]" +#define COMPILE_DATE_STRING "[2003-01-27 04:33]" diff --git a/src/game.c b/src/game.c index ce26a3b8..f84bb354 100644 --- a/src/game.c +++ b/src/game.c @@ -4828,7 +4828,6 @@ void GameActions() if (game.magic_wall_active) { - boolean sieb = FALSE; int jx = local_player->jx, jy = local_player->jy; /* play the element sound at the position nearest to the player */ diff --git a/src/init.c b/src/init.c index 27088af6..2c04d701 100644 --- a/src/init.c +++ b/src/init.c @@ -57,29 +57,30 @@ static char *image_filename[NUM_PICTURES] = static Bitmap *bitmap_font_initial = NULL; -static void InitGlobal(void); -static void InitSetup(void); -static void InitPlayerInfo(void); -static void InitLevelInfo(void); -static void InitArtworkInfo(void); -static void InitLevelArtworkInfo(void); -static void InitNetworkServer(void); -static void InitArtworkConfig(void); -static void InitImages(void); -static void InitMixer(void); -static void InitSound(void); -static void InitMusic(void); -static void InitGfx(void); -static void InitGfxBackground(void); -static void InitGadgets(void); -static void InitElementProperties(void); -static void InitElementGraphicInfo(void); -static void InitElementSoundInfo(void); -static void InitGraphicInfo(void); +static void InitGlobal(); +static void InitSetup(); +static void InitPlayerInfo(); +static void InitLevelInfo(); +static void InitArtworkInfo(); +static void InitLevelArtworkInfo(); +static void InitNetworkServer(); +static void InitArtworkConfig(); +static void InitImages(); +static void InitMixer(); +static void InitSound(); +static void InitMusic(); +static void InitGfx(); +static void InitGfxBackground(); +static void InitGadgets(); +static void InitElementImages(); +static void InitElementGraphicInfo(); +static void InitElementSoundInfo(); +static void InitElementProperties(); +static void InitGraphicInfo(); static void InitSoundInfo(); static void Execute_Command(char *); -void OpenAll(void) +void OpenAll() { InitGlobal(); /* initialize some global variables */ @@ -263,6 +264,7 @@ static void ReinitializeGraphics() /* !!! TEST ONLY !!! */ + if (0) { Bitmap *tst_bitmap = graphic_info[IMG_SAND].bitmap; Bitmap *tmp_bitmap = ZoomBitmap(tst_bitmap, @@ -273,6 +275,20 @@ static void ReinitializeGraphics() FreeBitmap(tmp_bitmap); } + + if (1) + { + printf("CREATING SMALL IMAGES...\n"); + +#if 1 + InitElementImages(); +#else + CreateImageWithSmallImages(IMG_SAND); + CreateImageWithSmallImages(IMG_SAND); +#endif + + printf("DONE!\n"); + } } static void ReinitializeSounds() @@ -721,6 +737,21 @@ void InitGadgets() gadgets_initialized = TRUE; } +void InitElementImages() +{ + struct PropertyMapping *property_mapping = getImageListPropertyMapping(); + int num_property_mappings = getImageListPropertyMappingSize(); + int i; + + /* initialize images from static configuration */ + for (i=0; element_to_graphic[i].element > -1; i++) + CreateImageWithSmallImages(element_to_graphic[i].graphic); + + /* initialize images from dynamic configuration */ + for (i=0; i < num_property_mappings; i++) + CreateImageWithSmallImages(property_mapping[i].artwork_index); +} + void InitElementGraphicInfo() { struct PropertyMapping *property_mapping = getImageListPropertyMapping(); diff --git a/src/libgame/image.c b/src/libgame/image.c index 64dc3c41..8cdf8324 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -708,6 +708,7 @@ struct ImageInfo int num_references; Bitmap *bitmap; + boolean contains_small_images; }; typedef struct ImageInfo ImageInfo; @@ -733,6 +734,8 @@ static void *Load_PCX(char *filename) img_info->source_filename = getStringCopy(filename); + img_info->contains_small_images = FALSE; + return img_info; } @@ -767,8 +770,20 @@ struct FileInfo *getImageListEntry(int pos) &image_info->dynamic_file_list[list_pos]); } +static ImageInfo *getImageInfoEntryFromImageID(int pos) +{ + 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]; +} + 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 = @@ -776,6 +791,11 @@ Bitmap *getBitmapFromImageID(int pos) 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) @@ -865,23 +885,6 @@ void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries, image_info->free_artwork = FreeImage; } -void dumpImages() -{ - struct ListNode *node; - - if (image_info->content_list == NULL) - return; - - for (node = image_info->content_list; node != NULL; node = node->next) - { - ImageInfo *img_info = (ImageInfo *)node->content; - - printf("---> '%s' [%d]\n", - img_info->source_filename, - img_info->num_references); - } -} - void ReloadCustomImages() { #if 0 @@ -890,8 +893,20 @@ void ReloadCustomImages() LoadArtworkConfig(image_info); ReloadCustomArtworkList(image_info); +} + +void CreateImageWithSmallImages(int pos) +{ + ImageInfo *img_info = getImageInfoEntryFromImageID(pos); + + if (img_info == NULL || img_info->contains_small_images) + return; + + printf(" creating small image for '%s'\n", img_info->source_filename); + + CreateBitmapWithSmallBitmaps(img_info->bitmap); - dumpImages(); + img_info->contains_small_images = TRUE; } void FreeAllImages() diff --git a/src/libgame/image.h b/src/libgame/image.h index d372a468..46d06425 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -83,7 +83,10 @@ int getImageListPropertyMappingSize(); struct PropertyMapping *getImageListPropertyMapping(); void InitImageList(struct ConfigInfo *, int, struct ConfigInfo *, char **, char **, char **); + void ReloadCustomImages(); +void CreateImageWithSmallImages(int); + void FreeAllImages(); #endif /* IMAGE_H */ diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 46e41d78..5184b088 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -1107,12 +1107,21 @@ SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height) void SDLZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap) { + SDL_Surface *sdl_surface_tmp; int dst_width = dst_bitmap->width; int dst_height = dst_bitmap->height; + /* throw away old destination surface */ SDL_FreeSurface(dst_bitmap->surface); - dst_bitmap->surface = zoomSurface(src_bitmap->surface, dst_width,dst_height); + /* create zoomed temporary surface from source surface */ + sdl_surface_tmp = zoomSurface(src_bitmap->surface, dst_width, dst_height); + + /* create native format destination surface from zoomed temporary surface */ + dst_bitmap->surface = SDL_DisplayFormat(sdl_surface_tmp); + + /* free temporary surface */ + SDL_FreeSurface(sdl_surface_tmp); } diff --git a/src/libgame/system.c b/src/libgame/system.c index 1fbafd78..7ec7d7df 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -391,7 +391,7 @@ inline static void FreeBitmapPointers(Bitmap *bitmap) bitmap->surface_masked = NULL; #else /* The X11 version seems to have a memory leak here -- although - "XFreePixmap()" is called, the correspondig memory seems not + "XFreePixmap()" is called, the corresponding memory seems not to be freed (according to "ps"). The SDL version apparently does not have this problem. */ @@ -878,6 +878,49 @@ Bitmap *ZoomBitmap(Bitmap *src_bitmap, int zoom_width, int zoom_height) return dst_bitmap; } +void CreateBitmapWithSmallBitmaps(Bitmap *src_bitmap) +{ + Bitmap *tmp_bitmap, *tmp_bitmap_2, *tmp_bitmap_4, *tmp_bitmap_8; + int src_width, src_height; + int tmp_width, tmp_height; + + src_width = src_bitmap->width; + src_height = src_bitmap->height; + + tmp_width = src_width; + tmp_height = src_height + src_height / 2; + + tmp_bitmap = CreateBitmap(tmp_width, tmp_height, DEFAULT_DEPTH); + + tmp_bitmap_2 = ZoomBitmap(src_bitmap, src_width / 2, src_height / 2); + tmp_bitmap_4 = ZoomBitmap(src_bitmap, src_width / 4, src_height / 4); + tmp_bitmap_8 = ZoomBitmap(src_bitmap, src_width / 8, src_height / 8); + + BlitBitmap(src_bitmap, tmp_bitmap, 0, 0, src_width, src_height, 0, 0); + BlitBitmap(tmp_bitmap_2, tmp_bitmap, 0, 0, src_width / 2, src_height / 2, + 0, src_height); + BlitBitmap(tmp_bitmap_4, tmp_bitmap, 0, 0, src_width / 4, src_height / 4, + src_width / 2, src_height); + BlitBitmap(tmp_bitmap_8, tmp_bitmap, 0, 0, src_width / 8, src_height / 8, + 3 * src_width / 4, src_height); + + FreeBitmap(tmp_bitmap_2); + FreeBitmap(tmp_bitmap_4); + FreeBitmap(tmp_bitmap_8); + +#ifdef TARGET_SDL + src_bitmap->surface = tmp_bitmap->surface; + tmp_bitmap->surface = NULL; +#else + src_bitmap->drawable = tmp_bitmap->drawable; + tmp_bitmap->drawable = None; +#endif + + src_bitmap->height = tmp_bitmap->height; + + FreeBitmap(tmp_bitmap); +} + /* ========================================================================= */ /* audio functions */ diff --git a/src/libgame/system.h b/src/libgame/system.h index 086b5afa..655d00b1 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -652,6 +652,7 @@ Bitmap *LoadCustomImage(char *); void ReloadCustomImage(Bitmap *, char *); Bitmap *ZoomBitmap(Bitmap *, int, int); +void CreateBitmapWithSmallBitmaps(Bitmap *); inline void OpenAudio(void); inline void CloseAudio(void);