From 4cc378525f493292a995869afcf0c45f1f38f951 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 22 Nov 2000 23:20:37 +0100 Subject: [PATCH] rnd-20001122-1-src --- CHANGES | 1 + src/image.c | 2 +- src/init.c | 161 ++++++++++++++++++++++++++++++-------------------- src/network.c | 12 ++-- src/sdl.c | 15 +++-- src/system.c | 10 ++-- 6 files changed, 121 insertions(+), 80 deletions(-) diff --git a/CHANGES b/CHANGES index c8ad050d..9cde8a3a 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,7 @@ Version 1.5.0 ------------- - SDL!!! - trying to open already busy audio device does not block the game + - fixed network playing bug (patch from web site) Release Version 1.4.0 [27 OCT 1999] ----------------------------------- diff --git a/src/image.c b/src/image.c index a3f92570..2b234d47 100644 --- a/src/image.c +++ b/src/image.c @@ -553,5 +553,5 @@ int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename, return PCX_Success; } -#endif /* !USE_SDL_LIBRARY */ #endif /* !MSDOS */ +#endif /* !USE_SDL_LIBRARY */ diff --git a/src/init.c b/src/init.c index 941881f3..66f4d178 100644 --- a/src/init.c +++ b/src/init.c @@ -53,6 +53,7 @@ static void InitSound(void); static void InitSoundServer(void); static void InitWindow(int, char **); static void InitGfx(void); +static void InitGfxBackground(void); static void LoadGfx(int, struct PictureFileInfo *); static void InitGadgets(void); static void InitElementProperties(void); @@ -100,6 +101,7 @@ void OpenAll(int argc, char *argv[]) InitLevelInfo(); InitGadgets(); /* needs to know number of level series */ + InitGfxBackground(); DrawMainMenu(); InitNetworkServer(); @@ -455,7 +457,7 @@ void InitWindow(int argc, char *argv[]) #ifdef USE_SDL_LIBRARY /* open SDL video output device (window or fullscreen mode) */ #if 0 - if ((window = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH, + if ((backbuffer = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH, SDL_HWSURFACE)) == NULL) Error(ERR_EXIT, "SDL_SetVideoMode() failed: %s", SDL_GetError()); @@ -591,7 +593,7 @@ void InitWindow(int argc, char *argv[]) void InitGfx() { - int i,j; + int i, j; #ifdef USE_SDL_LIBRARY SDL_Surface *sdl_image_tmp; @@ -698,39 +700,10 @@ void InitGfx() { -1, 0 } }; -#if DEBUG_TIMING - debug_print_timestamp(0, NULL); /* initialize timestamp function */ -#endif - -#ifdef DEBUG -#if 0 - printf("Test: Loading RocksFont2.pcx ...\n"); - LoadGfx(PIX_SMALLFONT,&test_pic1); - printf("Test: Done.\n"); - printf("Test: Loading mouse.pcx ...\n"); - LoadGfx(PIX_SMALLFONT,&test_pic2); - printf("Test: Done.\n"); -#endif -#endif - - LoadGfx(PIX_SMALLFONT, &pic[PIX_SMALLFONT]); - DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW); - DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED); -#ifdef MSDOS - DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE); - rest(200); -#endif /* MSDOS */ - DrawInitText("Loading graphics:",120,FC_GREEN); - - for(i=0; i> 8) & 0xff); buffer[9] = (unsigned char)((new_random_seed >> 0) & 0xff); - strcpy((char *)&buffer[10], leveldir_current->name); + strcpy((char *)&buffer[10], leveldir_current->filename); - SendBufferToServer(10 + strlen(leveldir_current->name) + 1); + SendBufferToServer(10 + strlen(leveldir_current->filename) + 1); } void SendToServer_PausePlaying() @@ -415,18 +415,18 @@ static void Handle_OP_START_PLAYING() int new_level_nr; int dummy; /* !!! HAS NO MEANING ANYMORE !!! */ unsigned long new_random_seed; - char *new_leveldir_name; + char *new_leveldir_filename; new_level_nr = (buffer[2] << 8) + buffer[3]; dummy = (buffer[4] << 8) + buffer[5]; new_random_seed = (buffer[6] << 24) | (buffer[7] << 16) | (buffer[8] << 8) | (buffer[9]); - new_leveldir_name = (char *)&buffer[10]; + new_leveldir_filename = (char *)&buffer[10]; - new_leveldir = getLevelDirInfoFromFilename(new_leveldir_name); + new_leveldir = getLevelDirInfoFromFilename(new_leveldir_filename); if (new_leveldir == NULL) { - Error(ERR_WARN, "no such level directory: '%s'", new_leveldir_name); + Error(ERR_WARN, "no such level directory: '%s'", new_leveldir_filename); new_leveldir = leveldir_first; Error(ERR_WARN, "using default level directory: '%s'", new_leveldir->name); diff --git a/src/sdl.c b/src/sdl.c index 941904e7..f3846da7 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -22,6 +22,7 @@ inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface, int width, int height, int dst_x, int dst_y) { + SDL_Surface *surface = (dst_surface == window ? backbuffer : dst_surface); SDL_Rect src_rect, dst_rect; src_rect.x = src_x; @@ -34,15 +35,17 @@ inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface, dst_rect.w = width; dst_rect.h = height; - SDL_BlitSurface(src_surface, &src_rect, dst_surface, &dst_rect); + if (src_surface != backbuffer || dst_surface != window) + SDL_BlitSurface(src_surface, &src_rect, surface, &dst_rect); if (dst_surface == window) - SDL_UpdateRect(dst_surface, dst_x, dst_y, width, height); + SDL_UpdateRect(backbuffer, dst_x, dst_y, width, height); } -inline void SDLFillRectangle(SDL_Surface *surface, int x, int y, +inline void SDLFillRectangle(SDL_Surface *dst_surface, int x, int y, int width, int height, unsigned int color) { + SDL_Surface *surface = (dst_surface == window ? backbuffer : dst_surface); SDL_Rect rect; unsigned int color_r = (color >> 16) && 0xff; unsigned int color_g = (color >> 8) && 0xff; @@ -54,8 +57,10 @@ inline void SDLFillRectangle(SDL_Surface *surface, int x, int y, rect.h = height; SDL_FillRect(surface, &rect, - SDL_MapRGB(surface->format, color_r, color_g, color_b)); - SDL_UpdateRect(surface, x, y, width, height); + SDL_MapRGB(surface->format, color_r, color_g, color_b)); + + if (dst_surface == window) + SDL_UpdateRect(backbuffer, x, y, width, height); } inline void SDLDrawSimpleLine(SDL_Surface *surface, int from_x, int from_y, diff --git a/src/system.c b/src/system.c index dd329f1c..0e1dd9d5 100644 --- a/src/system.c +++ b/src/system.c @@ -193,7 +193,7 @@ inline boolean SetVideoMode(void) if (setup.fullscreen && !fullscreen_enabled && fullscreen_available) { /* switch display to fullscreen mode, if available */ - DrawWindow window_old = window; + DrawWindow window_old = backbuffer; DrawWindow window_new; if ((window_new = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH, @@ -211,17 +211,17 @@ inline boolean SetVideoMode(void) { if (window_old) SDL_FreeSurface(window_old); - window = window_new; + backbuffer = window_new; fullscreen_enabled = TRUE; success = TRUE; } } - if ((!setup.fullscreen && fullscreen_enabled) || !window) + if ((!setup.fullscreen && fullscreen_enabled) || !backbuffer) { /* switch display to window mode */ - DrawWindow window_old = window; + DrawWindow window_old = backbuffer; DrawWindow window_new; if ((window_new = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH, @@ -237,7 +237,7 @@ inline boolean SetVideoMode(void) { if (window_old) SDL_FreeSurface(window_old); - window = window_new; + backbuffer = window_new; fullscreen_enabled = FALSE; success = TRUE; -- 2.34.1