X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=41bdc3604a698e15300013591b71861fd74cabd9;hb=c9433eab5c4317ed4f89164b386a7d33562e29be;hp=ef6586f701c4f6465f59766db271a4c1a7fb0555;hpb=d0e7ff980c3d4d73ac39c2670177e6030b966760;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index ef6586f7..41bdc360 100644 --- a/src/init.c +++ b/src/init.c @@ -1,7 +1,7 @@ /*********************************************************** * Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* (c) 1995-2001 Artsoft Entertainment * +* (c) 1995-2002 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -44,16 +44,25 @@ static void InitSetup(void); static void InitPlayerInfo(void); static void InitLevelInfo(void); static void InitArtworkInfo(void); +static void InitLevelArtworkInfo(void); static void InitNetworkServer(void); -static void InitSoundServer(void); +static void InitMixer(void); static void InitSound(void); static void InitGfx(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) @@ -75,7 +84,7 @@ void OpenAll(void) InitArtworkInfo(); /* needed before loading gfx, sound & music */ InitCounter(); - InitSoundServer(); + InitMixer(); InitJoysticks(); InitRND(NEW_RANDOMIZE); @@ -89,6 +98,7 @@ void OpenAll(void) InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ InitLevelInfo(); + InitLevelArtworkInfo(); InitGadgets(); /* needs to know number of level series */ InitSound(); /* needs to know current level directory */ @@ -130,6 +140,11 @@ void InitArtworkInfo() LoadArtworkInfo(); } +void InitLevelArtworkInfo() +{ + LoadLevelArtworkInfo(); +} + void InitNetworkServer() { #if defined(PLATFORM_UNIX) @@ -153,44 +168,22 @@ void InitNetworkServer() #endif } -static void ReloadCustomSounds() -{ - int i; - -#if 1 - printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current); -#endif - - FreeAllSounds(); - - InitSoundList(NUM_SOUNDS); - for(i=0; iname); InitReloadMusic(artwork.mus_current->name); + + /* initialize sound effect lookup table for element actions */ + InitGameSound(); } static void InitTileClipmasks() @@ -344,7 +337,7 @@ void FreeTileClipmasks() for(i=0; istored_clip_gc) + if (pix[i] != NULL && pix[i]->stored_clip_gc) { XFreeGC(display, pix[i]->stored_clip_gc); pix[i]->stored_clip_gc = None; @@ -379,11 +372,8 @@ void InitGfx() 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; iname) + static char *leveldir_current_filename = NULL; + static boolean last_override_level_graphics = FALSE; + static boolean last_override_level_sounds = FALSE; + static boolean last_override_level_music = FALSE; + + if (leveldir_current_filename != leveldir_current->filename) + { + char *filename_old = leveldir_current_filename; + char *filename_new = leveldir_current->filename; + + /* force reload of custom artwork after new level series was selected, + but reload only that part of the artwork that really has changed */ + if (getTreeInfoFromFilename(artwork.gfx_first, filename_old) != + getTreeInfoFromFilename(artwork.gfx_first, filename_new)) + artwork.graphics_set_current_name = NULL; + if (getTreeInfoFromFilename(artwork.snd_first, filename_old) != + getTreeInfoFromFilename(artwork.snd_first, filename_new)) + artwork.sounds_set_current_name = NULL; + if (getTreeInfoFromFilename(artwork.mus_first, filename_new) != + getTreeInfoFromFilename(artwork.mus_first, filename_new)) + artwork.music_set_current_name = NULL; + + leveldir_current_filename = leveldir_current->filename; + } + + if (artwork.graphics_set_current_name != artwork.gfx_current->name || + last_override_level_graphics != setup.override_level_graphics) { int i; @@ -437,23 +453,30 @@ void ReloadCustomArtwork() InitTileClipmasks(); InitGfxBackground(); - SetDoorState(DOOR_OPEN_1 | DOOR_CLOSE_2); + /* force redraw of (open or closed) door graphics */ + SetDoorState(DOOR_OPEN_ALL); + CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); - artwork.graphics_set_current = artwork.gfx_current->name; + artwork.graphics_set_current_name = artwork.gfx_current->name; + last_override_level_graphics = setup.override_level_graphics; } - if (artwork.sounds_set_current != artwork.snd_current->name) + if (artwork.sounds_set_current_name != artwork.snd_current->name || + last_override_level_sounds != setup.override_level_sounds) { InitReloadSounds(artwork.snd_current->name); - artwork.sounds_set_current = artwork.snd_current->name; + artwork.sounds_set_current_name = artwork.snd_current->name; + last_override_level_sounds = setup.override_level_sounds; } - if (artwork.music_set_current != artwork.mus_current->name) + if (artwork.music_set_current_name != artwork.mus_current->name || + last_override_level_music != setup.override_level_music) { InitReloadMusic(artwork.mus_current->name); - artwork.music_set_current = artwork.mus_current->name; + artwork.music_set_current_name = artwork.mus_current->name; + last_override_level_music = setup.override_level_music; } } @@ -521,9 +544,13 @@ void InitElementProperties() EL_EM_GATE_3X, EL_EM_GATE_4X, EL_SWITCHGATE_OPEN, + EL_SWITCHGATE_OPENING, EL_SWITCHGATE_CLOSED, + EL_SWITCHGATE_CLOSING, EL_TIMEGATE_OPEN, + EL_TIMEGATE_OPENING, EL_TIMEGATE_CLOSED, + EL_TIMEGATE_CLOSING, EL_TUBE_CROSS, EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL, @@ -562,11 +589,15 @@ void InitElementProperties() EL_QUICKSAND_EMPTYING, EL_MAGIC_WALL_OFF, EL_MAGIC_WALL_EMPTY, + EL_MAGIC_WALL_EMPTYING, + EL_MAGIC_WALL_FILLING, EL_MAGIC_WALL_FULL, EL_MAGIC_WALL_DEAD, EL_MAGIC_WALL_BD_OFF, EL_MAGIC_WALL_BD_EMPTY, + EL_MAGIC_WALL_BD_EMPTYING, EL_MAGIC_WALL_BD_FULL, + EL_MAGIC_WALL_BD_FILLING, EL_MAGIC_WALL_BD_DEAD, EL_LIFE, EL_LIFE_ASYNC, @@ -592,6 +623,7 @@ void InitElementProperties() EL_SP_HARD_BASE5, EL_SP_HARD_BASE6, EL_SP_TERMINAL, + EL_SP_TERMINAL_ACTIVE, EL_SP_EXIT, EL_INVISIBLE_STEEL, EL_BELT1_SWITCH_LEFT, @@ -640,6 +672,30 @@ void InitElementProperties() EL_CRYSTAL, EL_WALL_PEARL, EL_WALL_CRYSTAL, + EL_PFORTE1, + EL_PFORTE2, + EL_PFORTE3, + EL_PFORTE4, + EL_PFORTE1X, + EL_PFORTE2X, + EL_PFORTE3X, + EL_PFORTE4X, + EL_EM_GATE_1, + EL_EM_GATE_2, + EL_EM_GATE_3, + EL_EM_GATE_4, + EL_EM_GATE_1X, + EL_EM_GATE_2X, + EL_EM_GATE_3X, + EL_EM_GATE_4X, + EL_SWITCHGATE_OPEN, + EL_SWITCHGATE_OPENING, + EL_SWITCHGATE_CLOSED, + EL_SWITCHGATE_CLOSING, + EL_TIMEGATE_OPEN, + EL_TIMEGATE_OPENING, + EL_TIMEGATE_CLOSED, + EL_TIMEGATE_CLOSING, EL_TUBE_CROSS, EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL, @@ -663,26 +719,6 @@ void InitElementProperties() EL_BADEWANNE3, EL_BADEWANNE4, EL_BADEWANNE5, - EL_PFORTE1, - EL_PFORTE2, - EL_PFORTE3, - EL_PFORTE4, - EL_PFORTE1X, - EL_PFORTE2X, - EL_PFORTE3X, - EL_PFORTE4X, - EL_EM_GATE_1, - EL_EM_GATE_2, - EL_EM_GATE_3, - EL_EM_GATE_4, - EL_EM_GATE_1X, - EL_EM_GATE_2X, - EL_EM_GATE_3X, - EL_EM_GATE_4X, - EL_SWITCHGATE_OPEN, - EL_SWITCHGATE_CLOSED, - EL_TIMEGATE_OPEN, - EL_TIMEGATE_CLOSED, EL_SP_HARD_GRAY, EL_SP_HARD_GREEN, EL_SP_HARD_BLUE, @@ -727,6 +763,30 @@ void InitElementProperties() EL_EMC_STEEL_WALL_3, EL_EMC_STEEL_WALL_4, EL_CRYSTAL, + EL_PFORTE1, + EL_PFORTE2, + EL_PFORTE3, + EL_PFORTE4, + EL_PFORTE1X, + EL_PFORTE2X, + EL_PFORTE3X, + EL_PFORTE4X, + EL_EM_GATE_1, + EL_EM_GATE_2, + EL_EM_GATE_3, + EL_EM_GATE_4, + EL_EM_GATE_1X, + EL_EM_GATE_2X, + EL_EM_GATE_3X, + EL_EM_GATE_4X, + EL_SWITCHGATE_OPEN, + EL_SWITCHGATE_OPENING, + EL_SWITCHGATE_CLOSED, + EL_SWITCHGATE_CLOSING, + EL_TIMEGATE_OPEN, + EL_TIMEGATE_OPENING, + EL_TIMEGATE_CLOSED, + EL_TIMEGATE_CLOSING, EL_TUBE_CROSS, EL_TUBE_VERTICAL, EL_TUBE_HORIZONTAL, @@ -840,6 +900,7 @@ void InitElementProperties() EL_SP_HARD_BASE5, EL_SP_HARD_BASE6, EL_SP_TERMINAL, + EL_SP_TERMINAL_ACTIVE, EL_SP_EXIT, EL_INVISIBLE_STEEL, EL_STEEL_SLANTED, @@ -1615,6 +1676,39 @@ void InitElementProperties() Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE); } +void Execute_Debug_Command(char *command) +{ + if (strcmp(command, "create graphicsinfo.conf") == 0) + { + printf("# (Currently only the \"name\" directive is recognized.)\n"); + printf("\n"); + printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics")); + printf("\n"); + } + else if (strcmp(command, "create soundsinfo.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"); + printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds")); + printf("\n"); + + for (i=0; i