X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=9af442484ca33df0fbcc39d9dda7ea3c3627a2df;hb=681721dddc91bcdaef50002d1e861cc8d484e938;hp=b95b99c290fa5c81e620e2dee5e2da680b7174e6;hpb=4bca9bc5f299a9b287134b06e41b147f506792b4;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index b95b99c2..9af44248 100644 --- a/src/init.c +++ b/src/init.c @@ -1,22 +1,20 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* (c) 1995-98 Artsoft Entertainment * -* Holger Schemel * -* Oststrasse 11a * -* 33604 Bielefeld * -* phone: ++49 +521 290471 * -* email: aeglos@valinor.owl.de * +* (c) 1995-2001 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* init.c * +* init.c * ***********************************************************/ -#include +#include "libgame/libgame.h" #include "init.h" #include "events.h" -#include "misc.h" -#include "sound.h" #include "screens.h" #include "editor.h" #include "game.h" @@ -24,62 +22,46 @@ #include "tools.h" #include "files.h" #include "joystick.h" -#include "image.h" -#include "pcx.h" #include "network.h" #include "netserv.h" -struct PictureFileInfo -{ - char *picture_filename; - boolean picture_with_mask; -}; - -#ifndef TARGET_SDL -static int sound_process_id = 0; -#endif - static void InitPlayerInfo(void); static void InitLevelInfo(void); static void InitNetworkServer(void); static void InitSound(void); -static void InitSoundServer(void); static void InitGfx(void); static void InitGfxBackground(void); -static void LoadGfx(int, struct PictureFileInfo *); static void InitGadgets(void); static void InitElementProperties(void); -void OpenAll(int argc, char *argv[]) +void OpenAll(void) { -#if !defined(PLATFORM_UNIX) - initErrorFile(); -#endif - if (options.serveronly) { #if defined(PLATFORM_UNIX) NetworkServer(options.server_port, options.serveronly); #else - Error(ERR_WARN, "networking not supported in Windows version"); + Error(ERR_WARN, "networking only supported in Unix version"); #endif - - /* never reached */ - exit(0); + exit(0); /* never reached */ } + InitProgramInfo(UNIX_USERDATA_DIRECTORY, + PROGRAM_TITLE_STRING, WINDOW_TITLE_STRING, + ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, + MSDOS_POINTER_FILENAME); + InitPlayerInfo(); InitCounter(); InitSound(); - InitSoundServer(); InitJoysticks(); InitRND(NEW_RANDOMIZE); - signal(SIGINT, CloseAllAndExit); - signal(SIGTERM, CloseAllAndExit); + InitVideoDisplay(); + InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, + setup.fullscreen); - InitBufferedDisplay(&backbuffer, &window); InitEventFilter(FilterMouseMotionEvents); InitGfx(); @@ -146,86 +128,23 @@ void InitSound() { int i; - if (sound_status == SOUND_OFF) - return; - -#if defined(TARGET_SDL) - if (InitAudio()) - { - sound_status = SOUND_AVAILABLE; - sound_loops_allowed = TRUE; - } - else - { - sound_status = SOUND_OFF; - } -#else /* !TARGET_SDL */ - -#if defined(PLATFORM_UNIX) - if ((sound_status = CheckAudio(sound_device_name)) == SOUND_OFF) - return; - -#ifdef VOXWARE - sound_loops_allowed = TRUE; -#endif - -#else /* !PLATFORM_UNIX */ - sound_loops_allowed = TRUE; - -#endif /* !PLATFORM_UNIX */ -#endif /* !TARGET_SDL */ + OpenAudio(); for(i=0; i=0; i++) { - for(j=0; jformat, 0x00, 0x00, 0x00)); - if ((tile_masked[tile] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) - Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); - - SDL_FreeSurface(sdl_image_tmp); - - BlitBitmap(src_bitmap, tile_masked[tile], src_x,src_y, TILEX,TILEY, 0,0); + DrawInitText(image_filename[i], 150, FC_YELLOW); + pix[i] = LoadImage(image_filename[i]); } } -#else /* !TARGET_SDL */ + InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]); + + /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */ + for(i=0; iclip_mask, + clip_gc_valuemask, &clip_gc_values); clip_gc_values.graphics_exposures = False; clip_gc_valuemask = GCGraphicsExposures; tile_clip_gc = - XCreateGC(display, window, clip_gc_valuemask, &clip_gc_values); + XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values); for(i=0; iclip_mask) { clip_gc_values.graphics_exposures = False; - clip_gc_values.clip_mask = clipmask[i]; + clip_gc_values.clip_mask = pix[i]->clip_mask; clip_gc_valuemask = GCGraphicsExposures | GCClipMask; - clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values); + pix[i]->stored_clip_gc = XCreateGC(display, window->drawable, + clip_gc_valuemask,&clip_gc_values); } } - /* initialize pixmap array to Pixmap 'None' */ - for(i=0; i=0; i++) { + int j; + for(j=0; jclip_mask; - tile_clipmask[tile] = XCreatePixmap(display, window, TILEX,TILEY, 1); + tile_clipmask[tile] = XCreatePixmap(display, window->drawable, + TILEX, TILEY, 1); - XCopyArea(display,src_pixmap,tile_clipmask[tile],copy_clipmask_gc, - src_x,src_y, TILEX,TILEY, 0,0); + XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc, + src_x, src_y, TILEX, TILEY, 0, 0); } } - -#endif /* !TARGET_SDL */ +#endif /* TARGET_X11_NATIVE */ +#endif /* TARGET_X11 */ } void InitGfxBackground() { int x, y; - drawto = backbuffer = pix[PIX_DB_BACK]; + drawto = backbuffer; fieldbuffer = pix[PIX_DB_FIELD]; SetDrawtoField(DRAW_BACKBUFFER); @@ -563,87 +472,6 @@ void InitGfxBackground() redraw_mask = REDRAW_ALL; } -void LoadGfx(int pos, struct PictureFileInfo *pic) -{ - char basefilename[256]; - char filename[256]; - -#if defined(TARGET_SDL) - SDL_Surface *sdl_image_tmp; -#else - int pcx_err; -#endif - char *picture_ext = ".pcx"; - - /* Grafik laden */ - if (pic->picture_filename) - { - sprintf(basefilename, "%s%s", pic->picture_filename, picture_ext); - DrawInitText(basefilename, 150, FC_YELLOW); - sprintf(filename, "%s/%s/%s", - options.ro_base_directory, GRAPHICS_DIRECTORY, basefilename); - -#if defined(PLATFORM_MSDOS) - rest(100); -#endif - -#if defined(TARGET_SDL) - /* load image to temporary surface */ - if ((sdl_image_tmp = IMG_Load(filename)) == NULL) - Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError()); - - /* create native non-transparent surface for current image */ - if ((pix[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) - Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); - - /* create native transparent surface for current image */ - SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY, - SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00)); - if ((pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) - Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); - - /* free temporary surface */ - SDL_FreeSurface(sdl_image_tmp); - -#else /* !TARGET_SDL */ - - pcx_err = Read_PCX_to_Pixmap(display, window, gc, filename, - &pix[pos], &clipmask[pos]); - switch(pcx_err) - { - case PCX_Success: - break; - case PCX_OpenFailed: - Error(ERR_EXIT, "cannot open PCX file '%s'", filename); - case PCX_ReadFailed: - Error(ERR_EXIT, "cannot read PCX file '%s'", filename); - case PCX_FileInvalid: - Error(ERR_EXIT, "invalid PCX file '%s'", filename); - case PCX_NoMemory: - Error(ERR_EXIT, "not enough memory for PCX file '%s'", filename); - case PCX_ColorFailed: - Error(ERR_EXIT, "cannot get colors for PCX file '%s'", filename); - default: - break; - } - - if (!pix[pos]) - Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename); - - /* setting pix_masked[] to pix[] allows BlitBitmapMasked() to always - use pix_masked[], although they are the same when not using SDL */ - pix_masked[pos] = pix[pos]; - -#endif /* !TARGET_SDL */ - } - -#if defined(TARGET_X11) - /* check if clip mask was correctly created */ - if (pic->picture_with_mask && !clipmask[pos]) - Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename); -#endif -} - void InitGadgets() { CreateLevelEditorGadgets(); @@ -1805,49 +1633,15 @@ void CloseAllAndExit(int exit_value) { int i; -#if defined(TARGET_SDL) StopSounds(); FreeSounds(NUM_SOUNDS); -#else - if (sound_process_id) - { - StopSounds(); - kill(sound_process_id, SIGTERM); - FreeSounds(NUM_SOUNDS); - } -#endif + CloseAudio(); for(i=0; i