From efd0d0abb853018aa3ccc3c727b39bd7f5ba679d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 19 Mar 2002 04:28:26 +0100 Subject: [PATCH] rocksndiamonds-2.0.1 --- CHANGES | 11 ++++++++- Makefile | 8 ++++++- src/Makefile | 4 ++++ src/libgame/misc.c | 40 ++++++++++++++++++++++---------- src/libgame/sdl.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ src/libgame/sdl.h | 1 + src/libgame/system.c | 20 ++++++++++++++++ src/libgame/system.h | 1 + 8 files changed, 125 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index ebd7c3a9..4cac89f6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -Release Version 2.0.1 [?? ??? 2002] +Release Version 2.0.1 [19 MAR 2002] ----------------------------------- - bug in explosion code fixed that broke level 24 of "Baby Ghost Mine" - several Supaplex emulation bugs fixed (thanks to Mihail Milushev): @@ -16,6 +16,15 @@ Release Version 2.0.1 [?? ??? 2002] - /dev/dsp support for NetBSD added (thanks to Krister Walfridsson) - file permissions when saving files and creating directories changed - some small sound bugs fixed + - added new contributed levels from the following players: + + Arno Luppold + + Barak Shacked + + Ben Braithwaite + + Dominik Seichter + + Emilio Hemken + + Glenn Alexander + + Helge Hafting + + Paul Sutton Release Version 2.0.0 [01 JAN 2001] ----------------------------------- diff --git a/Makefile b/Makefile index 4da272c5..3794cd87 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,13 @@ dist-win32: dist-clean: @$(MAKE_CMD) dist-clean -dist: dist-unix dist-msdos dist-win32 +dist-build-all: + $(MAKE) clean + @BUILD_DIST=TRUE $(MAKE) x11 ; $(MAKE) dist-clean + @BUILD_DIST=TRUE $(MAKE) cross-win32 ; $(MAKE) dist-clean + @BUILD_DIST=TRUE $(MAKE) cross-msdos ; $(MAKE) dist-clean + +dist-all: dist-build-all dist-unix dist-msdos dist-win32 depend dep: $(MAKE_CMD) depend diff --git a/src/Makefile b/src/Makefile index 4010bcfb..f4f503fc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -108,6 +108,10 @@ OPTIONS = $(DEBUG) -O3 -Wall # only for debugging purposes # OPTIONS = -O3 # OPTIONS = -DSYSV -Ae # may be needed for HP-UX +ifdef BUILD_DIST # distribution build +OPTIONS = -O3 -Wall +endif + CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG) LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm diff --git a/src/libgame/misc.c b/src/libgame/misc.c index b3edef75..7a55d94d 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1306,6 +1306,12 @@ inline void swap_number_pairs(int *x1, int *y1, int *x2, int *y2) #ifndef S_IXOTH #define S_IXOTH S_IXUSR #endif +#ifndef S_IRWXG +#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +#endif +#ifndef S_ISGID +#define S_ISGID 0 +#endif #endif /* PLATFORM_WIN32 */ /* file permissions for newly written files */ @@ -1343,29 +1349,39 @@ char *getSetupDir() return getUserDataDir(); } -void createDirectory(char *dir, char *text, int permission_class) +static mode_t posix_umask(mode_t mask) { #if defined(PLATFORM_UNIX) + return umask(mask); +#else + return 0; +#endif +} + +static int posix_mkdir(const char *pathname, mode_t mode) +{ +#if defined(PLATFORM_WIN32) + return mkdir(pathname); +#else + return mkdir(pathname, mode); +#endif +} + +void createDirectory(char *dir, char *text, int permission_class) +{ /* leave "other" permissions in umask untouched, but ensure group parts of USERDATA_DIR_MODE are not masked */ mode_t dir_mode = (permission_class == PERMS_PRIVATE ? DIR_PERMS_PRIVATE : DIR_PERMS_PUBLIC); - mode_t normal_umask = umask(0); + mode_t normal_umask = posix_umask(0); mode_t group_umask = ~(dir_mode & S_IRWXG); - umask(normal_umask & group_umask); -#endif + posix_umask(normal_umask & group_umask); if (access(dir, F_OK) != 0) -#if defined(PLATFORM_WIN32) - if (mkdir(dir) != 0) -#else - if (mkdir(dir, dir_mode) != 0) -#endif + if (posix_mkdir(dir, dir_mode) != 0) Error(ERR_WARN, "cannot create %s directory '%s'", text, dir); -#if defined(PLATFORM_UNIX) - umask(normal_umask); /* reset normal umask */ -#endif + posix_umask(normal_umask); /* reset normal umask */ } void InitUserDataDirectory() diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 2441ede3..a2d82fab 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -320,6 +320,60 @@ inline void SDLDrawLines(SDL_Surface *surface, struct XY *points, } #endif +inline Pixel SDLGetPixel(Bitmap *dst_bitmap, int x, int y) +{ + SDL_Surface *surface = dst_bitmap->surface; + +#ifdef FULLSCREEN_BUG + if (dst_bitmap == backbuffer || dst_bitmap == window) + { + x += video_xoffset; + y += video_yoffset; + } +#endif + + switch (surface->format->BytesPerPixel) + { + case 1: /* assuming 8-bpp */ + { + return *((Uint8 *)surface->pixels + y * surface->pitch + x); + } + break; + + case 2: /* probably 15-bpp or 16-bpp */ + { + return *((Uint16 *)surface->pixels + y * surface->pitch / 2 + x); + } + break; + + case 3: /* slow 24-bpp mode; usually not used */ + { + /* does this work? */ + Uint8 *pix = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; + Uint32 color = 0; + int shift; + + shift = surface->format->Rshift; + color |= *(pix + shift / 8) >> shift; + shift = surface->format->Gshift; + color |= *(pix + shift / 8) >> shift; + shift = surface->format->Bshift; + color |= *(pix + shift / 8) >> shift; + + return color; + } + break; + + case 4: /* probably 32-bpp */ + { + return *((Uint32 *)surface->pixels + y * surface->pitch / 4 + x); + } + break; + } + + return 0; +} + /* ========================================================================= */ /* The following functions have been taken from the SGE library */ diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 7db0dc2c..fcc566ed 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -321,6 +321,7 @@ inline void SDLCopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int); inline void SDLFillRectangle(Bitmap *, int, int, int, int, unsigned int); inline void SDLDrawSimpleLine(Bitmap *, int, int, int, int, unsigned int); inline void SDLDrawLine(Bitmap *, int, int, int, int, Uint32); +inline Pixel SDLGetPixel(Bitmap *, int, int); Bitmap *SDLLoadImage(char *); diff --git a/src/libgame/system.c b/src/libgame/system.c index bd9fc229..b4ac9ce4 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -438,6 +438,26 @@ inline void DrawLines(Bitmap *bitmap, struct XY *points, int num_points, #endif } +inline Pixel GetPixel(Bitmap *bitmap, int x, int y) +{ +#if defined(TARGET_SDL) + return SDLGetPixel(bitmap, x, y); +#elif defined(TARGET_ALLEGRO) + return AllegroGetPixel(bitmap->drawable, x, y); +#else + unsigned long pixel_value; + XImage *pixel_image; + + pixel_image = XGetImage(display, bitmap->drawable, x, y, 1, 1, + AllPlanes, ZPixmap); + pixel_value = XGetPixel(pixel_image, 0, 0); + + XDestroyImage(pixel_image); + + return pixel_value; +#endif +} + inline Pixel GetPixelFromRGB(Bitmap *bitmap, unsigned int color_r, unsigned int color_g, unsigned int color_b) { diff --git a/src/libgame/system.h b/src/libgame/system.h index 71dfc5cf..34a068a5 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -291,6 +291,7 @@ inline void SetClipOrigin(Bitmap *, GC, int, int); inline void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int); inline void DrawSimpleWhiteLine(Bitmap *, int, int, int, int); inline void DrawLines(Bitmap *, struct XY *, int, Pixel); +inline Pixel GetPixel(Bitmap *, int, int); inline Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int); inline Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int); -- 2.34.1