X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=8393c629d76d5c7adbb5540dbb9cd0942fd16ddd;hb=e788c9b6a44d9f2dea7aa048b48a11b14761229e;hp=70604f2a9392854cd4bda2dc4fc30ad16bcb6105;hpb=93806fb4c23f4b6ef58d9562e908a1b89ece869d;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 70604f2a..8393c629 100644 --- a/src/init.c +++ b/src/init.c @@ -23,6 +23,8 @@ #include "files.h" #include "network.h" #include "netserv.h" +#include "cartoons.h" +#include "config.h" static char *image_filename[NUM_PICTURES] = { @@ -38,18 +40,28 @@ static char *image_filename[NUM_PICTURES] = "RocksFont3.pcx" }; +static void InitSetup(void); static void InitPlayerInfo(void); static void InitLevelInfo(void); +static void InitArtworkInfo(void); static void InitNetworkServer(void); +static void InitMixer(void); static void InitSound(void); static void InitGfx(void); -static void InitCustomGraphics(void); static void InitGfxBackground(void); static void InitGadgets(void); static void InitElementProperties(void); +static void Execute_Debug_Command(char *); void OpenAll(void) { + if (options.debug_command) + { + Execute_Debug_Command(options.debug_command); + + exit(0); + } + if (options.serveronly) { #if defined(PLATFORM_UNIX) @@ -61,15 +73,17 @@ void OpenAll(void) } InitProgramInfo(UNIX_USERDATA_DIRECTORY, - PROGRAM_TITLE_STRING, WINDOW_TITLE_STRING, + PROGRAM_TITLE_STRING, getWindowTitleString(), ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, MSDOS_POINTER_FILENAME, COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL); + InitSetup(); InitPlayerInfo(); + InitArtworkInfo(); /* needed before loading gfx, sound & music */ InitCounter(); - InitSound(); + InitMixer(); InitJoysticks(); InitRND(NEW_RANDOMIZE); @@ -84,15 +98,21 @@ void OpenAll(void) InitLevelInfo(); InitGadgets(); /* needs to know number of level series */ - - InitCustomGraphics(); + InitSound(); /* needs to know current level directory */ InitGfxBackground(); + InitToons(); + DrawMainMenu(); InitNetworkServer(); } +void InitSetup() +{ + LoadSetup(); /* global setup info */ +} + void InitPlayerInfo() { int i; @@ -104,8 +124,6 @@ void InitPlayerInfo() stored_player[i].connected = FALSE; local_player->connected = TRUE; - - LoadSetup(); /* global setup info */ } void InitLevelInfo() @@ -115,6 +133,11 @@ void InitLevelInfo() LoadLevelSetup_SeriesInfo(); /* last played level info */ } +void InitArtworkInfo() +{ + LoadArtworkInfo(); +} + void InitNetworkServer() { #if defined(PLATFORM_UNIX) @@ -138,38 +161,29 @@ void InitNetworkServer() #endif } -void InitSound() +static void InitMixer() { - int i; - OpenAudio(); + InitSoundList(sound_effects, NUM_SOUND_EFFECTS); - for(i=0; iname); + InitReloadMusic(artwork.mus_current->name); } -void InitTileClipmasks() +static void InitTileClipmasks() { #if defined(TARGET_X11) - GC copy_clipmask_gc; XGCValues clip_gc_values; unsigned long clip_gc_valuemask; -#endif #if defined(TARGET_X11_NATIVE) + GC copy_clipmask_gc; + static struct { int start; @@ -221,7 +235,8 @@ void InitTileClipmasks() { GFX2_SHIELD_ACTIVE, 3 }, { -1, 0 } }; -#endif +#endif /* TARGET_X11_NATIVE */ +#endif /* TARGET_X11 */ int i; @@ -235,13 +250,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 = @@ -255,11 +263,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++) { @@ -283,13 +299,44 @@ void InitTileClipmasks() src_x, src_y, TILEX, TILEY, 0, 0); } } + + 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 */ +} + void InitGfx() { - char *filename; int i; /* initialize some global variables */ @@ -308,21 +355,14 @@ void InitGfx() pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); - filename = getImageFilename(image_filename[PIX_SMALLFONT]); - if ((pix_default[PIX_SMALLFONT] = LoadImage(filename)) == NULL) - Error(ERR_EXIT, "LoadImage() failed: %s", GetError()); - pix_custom[PIX_SMALLFONT] = NULL; - pix[PIX_SMALLFONT] = pix_default[PIX_SMALLFONT]; + pix[PIX_SMALLFONT] = LoadCustomImage(image_filename[PIX_SMALLFONT]); InitFontInfo(NULL, NULL, pix[PIX_SMALLFONT]); DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW); DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED); -#if defined(PLATFORM_MSDOS) - DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE); - rest(200); -#endif - DrawInitText("Loading graphics:",120,FC_GREEN); + + DrawInitText("Loading graphics:", 120, FC_GREEN); for(i=0; i/graphics */ - filename = getPath2(getUserDataDir(), GRAPHICS_DIRECTORY); - if (access(dir, F_OK) == 0) + if (artwork.graphics_set_current != artwork.gfx_current->name) { - } - - + int i; + ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE); -(leveldir_current->user_defined ? - getUserLevelDir("") : - options.level_directory), - leveldir_current->fullpath, - basename); + for(i=0; iuser_defined ? - getUserLevelDir("") : - options.level_directory), - leveldir_current->fullpath, - basename); -#endif -} + artwork.graphics_set_current = artwork.gfx_current->name; + } -void InitGfxBackground() -{ - int x, y; + if (artwork.sounds_set_current != artwork.snd_current->name) + { + InitReloadSounds(artwork.snd_current->name); - drawto = backbuffer; - fieldbuffer = pix[PIX_DB_FIELD]; - SetDrawtoField(DRAW_BACKBUFFER); + artwork.sounds_set_current = artwork.snd_current->name; + } - BlitBitmap(pix[PIX_BACK], backbuffer, 0,0, WIN_XSIZE,WIN_YSIZE, 0,0); - ClearRectangle(backbuffer, REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); - ClearRectangle(pix[PIX_DB_DOOR], 0,0, 3*DXSIZE,DYSIZE+VYSIZE); + if (artwork.music_set_current != artwork.mus_current->name) + { + InitReloadMusic(artwork.mus_current->name); - for(x=0; xname; + } } void InitGadgets() @@ -1563,19 +1594,35 @@ void InitElementProperties() Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE); } +void Execute_Debug_Command(char *command) +{ + if (strcmp(command, "create soundinfo.conf") == 0) + { + int i; + + printf("# You can configure additional/alternative sound effects here\n"); + printf("# (The sounds below are default and therefore commented out.)\n"); + printf("\n"); + + for (i=0; i