From: Holger Schemel Date: Sun, 7 Apr 2002 18:15:59 +0000 (+0200) Subject: rnd-20020407-3-src X-Git-Tag: 2.1.0^2~61 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=909a0a4d74f274b5c05c16cf595b235aa092fc9a;p=rocksndiamonds.git rnd-20020407-3-src --- diff --git a/src/init.c b/src/init.c index bc29424e..e5a1738b 100644 --- a/src/init.c +++ b/src/init.c @@ -180,7 +180,6 @@ void InitTileClipmasks() GC copy_clipmask_gc; XGCValues clip_gc_values; unsigned long clip_gc_valuemask; -#endif #if defined(TARGET_X11_NATIVE) static struct @@ -234,7 +233,8 @@ void InitTileClipmasks() { GFX2_SHIELD_ACTIVE, 3 }, { -1, 0 } }; -#endif +#endif /* TARGET_X11_NATIVE */ +#endif /* TARGET_X11 */ int i; @@ -248,13 +248,6 @@ void InitTileClipmasks() To prevent this, create small (tile-sized) mask Pixmaps which will then be set much faster with XSetClipOrigin() and speed things up a lot. */ - /* create graphic context structures needed for clipping */ - clip_gc_values.graphics_exposures = False; - clip_gc_valuemask = GCGraphicsExposures; - copy_clipmask_gc = - XCreateGC(display, pix[PIX_BACK]->clip_mask, - clip_gc_valuemask, &clip_gc_values); - clip_gc_values.graphics_exposures = False; clip_gc_valuemask = GCGraphicsExposures; tile_clip_gc = @@ -268,11 +261,19 @@ void InitTileClipmasks() clip_gc_values.clip_mask = pix[i]->clip_mask; clip_gc_valuemask = GCGraphicsExposures | GCClipMask; pix[i]->stored_clip_gc = XCreateGC(display, window->drawable, - clip_gc_valuemask,&clip_gc_values); + clip_gc_valuemask, &clip_gc_values); } } #if defined(TARGET_X11_NATIVE) + + /* create graphic context structures needed for clipping */ + clip_gc_values.graphics_exposures = False; + clip_gc_valuemask = GCGraphicsExposures; + copy_clipmask_gc = + XCreateGC(display, pix[PIX_BACK]->clip_mask, + clip_gc_valuemask, &clip_gc_values); + /* create only those clipping Pixmaps we really need */ for(i=0; tile_needs_clipping[i].start>=0; i++) { @@ -296,10 +297,39 @@ void InitTileClipmasks() src_x, src_y, TILEX, TILEY, 0, 0); } } -#endif /* TARGET_X11_NATIVE */ XFreeGC(display, copy_clipmask_gc); +#endif /* TARGET_X11_NATIVE */ +#endif /* TARGET_X11 */ +} + +void FreeTileClipmasks() +{ +#if defined(TARGET_X11) + int i; + + for(i=0; istored_clip_gc) + { + XFreeGC(display, pix[i]->stored_clip_gc); + pix[i]->stored_clip_gc = None; + } + } #endif /* TARGET_X11 */ } @@ -346,6 +376,7 @@ void InitGfx() } InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]); + InitTileClipmasks(); } @@ -372,46 +403,19 @@ void ReloadCustomArtwork() { if (artwork.graphics_set_current != artwork.gfx_current->name) { - Bitmap *pix_new[NUM_PICTURES]; int i; ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE); - for(i=0; isurface); if (bitmap->surface_masked) SDL_FreeSurface(bitmap->surface_masked); + bitmap->surface = NULL; + bitmap->surface_masked = NULL; #else + /* The X11 version seems to have a memory leak here -- although + "XFreePixmap()" is called, the correspondig memory seems not + to be freed (according to "ps"). The SDL version apparently + does not have this problem. */ + if (bitmap->drawable) XFreePixmap(display, bitmap->drawable); if (bitmap->clip_mask) @@ -299,13 +306,18 @@ inline static void FreeBitmapPointers(Bitmap *bitmap) if (bitmap->stored_clip_gc) XFreeGC(display, bitmap->stored_clip_gc); /* the other GCs are only pointers to GCs used elsewhere */ + bitmap->drawable = None; + bitmap->clip_mask = None; + bitmap->stored_clip_gc = None; #endif if (bitmap->source_filename) free(bitmap->source_filename); + bitmap->source_filename = NULL; } -inline void TransferBitmapPointers(Bitmap *src_bitmap, Bitmap *dst_bitmap) +inline static void TransferBitmapPointers(Bitmap *src_bitmap, + Bitmap *dst_bitmap) { if (src_bitmap == NULL || dst_bitmap == NULL) return; @@ -666,57 +678,42 @@ Bitmap *LoadCustomImage(char *basename) return new_bitmap; } -Bitmap *ReloadCustomImage(Bitmap **bitmap, char *basename) +void ReloadCustomImage(Bitmap *bitmap, char *basename) { char *filename = getCustomImageFilename(basename); - Bitmap *old_bitmap = *bitmap; Bitmap *new_bitmap; if (filename == NULL) /* (should never happen) */ { Error(ERR_WARN, "ReloadCustomImage(): cannot find file '%s'", basename); - return NULL; + return; } - if (strcmp(filename, old_bitmap->source_filename) == 0) + if (strcmp(filename, bitmap->source_filename) == 0) { /* The old and new image are the same (have the same filename and path). This usually means that this image does not exist in this graphic set and a fallback to the existing image is done. */ - return NULL; + return; } if ((new_bitmap = LoadImage(filename)) == NULL) { Error(ERR_WARN, "LoadImage() failed: %s", GetError()); - return NULL; + return; } - if (old_bitmap->width != new_bitmap->width || - old_bitmap->height != new_bitmap->height) + if (bitmap->width != new_bitmap->width || + bitmap->height != new_bitmap->height) { Error(ERR_WARN, "ReloadCustomImage: new image has wrong dimensions"); FreeBitmap(new_bitmap); - return NULL; + return; } -#if 0 - /* copy filename for new image */ - free(old_bitmap->source_filename); - old_bitmap->source_filename = getStringCopy(filename); - - /* copy bitmap data for new image */ - BlitBitmap(new_bitmap, old_bitmap, 0,0, - old_bitmap->width, old_bitmap->height, 0,0); - - FreeBitmap(new_bitmap); -#else - /* - *bitmap = new_bitmap; - */ - return new_bitmap; -#endif + TransferBitmapPointers(new_bitmap, bitmap); + free(new_bitmap); } diff --git a/src/libgame/system.h b/src/libgame/system.h index 19fdf645..f372306f 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -443,7 +443,6 @@ inline void CloseVideoDisplay(void); inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean); inline Bitmap *CreateBitmapStruct(void); inline Bitmap *CreateBitmap(int, int, int); -inline void TransferBitmapPointers(Bitmap *, Bitmap *); inline void FreeBitmap(Bitmap *); inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int); inline void ClearRectangle(Bitmap *, int, int, int, int); @@ -466,7 +465,7 @@ inline boolean ChangeVideoModeIfNeeded(boolean); Bitmap *LoadImage(char *); Bitmap *LoadCustomImage(char *); -Bitmap *ReloadCustomImage(Bitmap **, char *); +void ReloadCustomImage(Bitmap *, char *); inline void OpenAudio(void); inline void CloseAudio(void); diff --git a/src/screens.c b/src/screens.c index ece8b097..4537893f 100644 --- a/src/screens.c +++ b/src/screens.c @@ -135,7 +135,7 @@ void DrawMainMenu() UnmapAllGadgets(); FadeSounds(); KeyboardAutoRepeatOn(); - ActivateJoystickIfAvailable(); + ActivateJoystick(); SetDrawDeactivationMask(REDRAW_NONE); /* needed if last screen was the playing screen, invoked from level editor */ @@ -1796,9 +1796,11 @@ void DrawSetupScreen_Input() DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN); DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN); +#if 0 DeactivateJoystickForCalibration(); DrawTextFCentered(SYSIZE - 20, FC_BLUE, "Joysticks deactivated on this screen"); +#endif HandleSetupScreen_Input(0,0, 0,0, MB_MENU_INITIALIZE); FadeToFront(); @@ -2347,6 +2349,8 @@ void CalibrateJoystick(int player_nr) void DrawSetupScreen() { + DeactivateJoystick(); + if (setup_mode == SETUP_MODE_INPUT) DrawSetupScreen_Input(); else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS) diff --git a/src/timestamp.h b/src/timestamp.h index 4a85f3d7..1078b58d 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-04-07 18:38]" +#define COMPILE_DATE_STRING "[2002-04-07 20:15]"