diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9a66b702f..15765d5ed 100755 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3884,8 +3884,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) // wake up the status bar ST_Start(); - // wake up the heads up text - HU_Start(); if (camera.chase && !splitscreenplayer) P_ResetCamera(newplayer, &camera); diff --git a/src/d_main.c b/src/d_main.c index 92416507f..eab4d03a6 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1761,6 +1761,8 @@ void D_SRB2Main(void) // Reload all files. void D_ReloadFiles(void) { + game_reloading = true; + // Set the initial state G_InitialState(); @@ -1777,7 +1779,6 @@ void D_ReloadFiles(void) Patch_FreeTag(PU_PATCH_LOWPRIORITY); Patch_FreeTag(PU_PATCH_ROTATED); Patch_FreeTag(PU_SPRITE); - Patch_FreeTag(PU_HUDGFX); // Load SOC and Lua. for (INT32 i = 0; i < numwadfiles; i++) @@ -1795,23 +1796,18 @@ void D_ReloadFiles(void) P_InitPicAnims(); // Flush and reload HUD graphics - ST_UnloadGraphics(); HU_LoadGraphics(); ST_LoadGraphics(); ST_ReloadSkinFaceGraphics(); + + game_reloading = false; } void D_RestartGame(boolean remove_all_addons) { - // Remove all addons + W_ClearCachedData(); W_UnloadAddons(remove_all_addons); - - // Reload all files - game_reloading = true; - D_ReloadFiles(); - - game_reloading = false; } const char *D_Home(void) diff --git a/src/g_game.c b/src/g_game.c index a440f8b5a..e2eaca3c9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4349,15 +4349,13 @@ void G_InitialState(void) // Delete all skins. R_DelSkins(); - // Stop all sound effects. - S_StopSounds(); - S_ClearSfx(); - - for (INT32 i = 0; i < NUMSFX; i++) + // Clear all added sound effects. + for (INT32 i = sfx_freeslot0; i <= sfx_lastskinsoundslot; i++) { if (S_sfx[i].lumpnum != LUMPERROR) { - S_RemoveSoundFx(i); + S_sfx[i].lumpnum = LUMPERROR; + S_sfx[i].priority = 0; I_FreeSfx(&S_sfx[i]); } } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 091e2b2fb..3cbdf9bdc 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -75,11 +75,9 @@ patch_t *ttlnum[10]; // act numbers (0-9) patch_t *ntb_font[NT_FONTSIZE]; patch_t *nto_font[NT_FONTSIZE]; -static player_t *plr; boolean chat_on; // entering a chat message? static char w_chat[HU_MAXMSGLEN + 1]; static size_t c_input = 0; // let's try to make the chat input less shitty. -static boolean headsupactive = false; boolean hu_showscores; // draw rankings static char hu_tick; @@ -341,24 +339,6 @@ void HU_Init(void) luahuddrawlist_scores = LUA_HUD_CreateDrawList(); } -static inline void HU_Stop(void) -{ - headsupactive = false; -} - -// -// Reset Heads up when consoleplayer spawns -// -void HU_Start(void) -{ - if (headsupactive) - HU_Stop(); - - plr = &players[consoleplayer]; - - headsupactive = true; -} - //====================================================================== // EXECUTION //====================================================================== diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 8647e4500..1953a66a9 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -104,9 +104,6 @@ void HU_Init(void); void HU_LoadGraphics(void); -// reset heads up when consoleplayer respawns. -void HU_Start(void); - boolean HU_Responder(event_t *ev); void HU_Ticker(void); void HU_Drawer(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index 4ca59285f..70fd9fb36 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11676,8 +11676,6 @@ void P_AfterPlayerSpawn(INT32 playernum) { // wake up the status bar ST_Start(); - // wake up the heads up text - HU_Start(); } p->drawangle = mobj->angle; diff --git a/src/p_setup.c b/src/p_setup.c index fe4238823..31a7d6169 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7846,7 +7846,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // As oddly named as this is, this handles music only. // We should be fine starting it here. // Don't do this during titlemap, because the menu code handles music by itself. - S_Start(); + S_PlayMapMusic(false); } levelfadecol = (ranspecialwipe) ? 0 : 31; diff --git a/src/s_sound.c b/src/s_sound.c index 024efb1aa..bed852d4c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2431,7 +2431,7 @@ boolean S_FadeOutStopMusic(UINT32 ms) // Kills playing sounds at start of level, // determines music if any, changes music. // -void S_StartEx(boolean reset) +void S_PlayMapMusic(boolean reset) { if (mapmusflags & MUSIC_RELOADRESET) { diff --git a/src/s_sound.h b/src/s_sound.h index 288859c8d..60dc93897 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -125,8 +125,7 @@ void S_InitSfxChannels(INT32 sfxVolume); // void S_StopSounds(void); void S_ClearSfx(void); -void S_StartEx(boolean reset); -#define S_Start() S_StartEx(false) +void S_PlayMapMusic(boolean reset); // // Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum. diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 0a39c7f28..d32e41962 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -151,7 +151,7 @@ static void Midiplayer_Onchange(void) Mix_Timidity_addToPathList(cv_miditimiditypath.string); if (restart) - S_StartEx(true); + S_PlayMapMusic(true); } static void MidiSoundfontPath_Onchange(void) @@ -189,7 +189,7 @@ static void MidiSoundfontPath_Onchange(void) if (!Mix_SetSoundFonts(cv_midisoundfontpath.string)) CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError()); else - S_StartEx(true); + S_PlayMapMusic(true); } } } diff --git a/src/sounds.c b/src/sounds.c index 19b69dd28..b9ba90edd 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -915,7 +915,7 @@ void S_RemoveSoundFx(sfxenum_t id) && S_sfx[id].priority != 0) { S_sfx[id].lumpnum = LUMPERROR; - I_FreeSfx(&S_sfx[id]); S_sfx[id].priority = 0; + I_FreeSfx(&S_sfx[id]); } } diff --git a/src/st_stuff.c b/src/st_stuff.c index 29937716a..b0cce4cf6 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -403,16 +403,6 @@ void ST_UnLoadFaceGraphics(INT32 skinnum) W_UnlockCachedPatch(superprefix[skinnum]); } -static inline void ST_InitData(void) -{ - // 'link' the statusbar display to a player, which could be - // another player than consoleplayer, for example, when you - // change the view in a multiplayer demo with F12. - stplyr = &players[displayplayer]; - - st_palette = -1; -} - static inline void ST_Stop(void) { if (st_stopped) @@ -428,7 +418,12 @@ void ST_Start(void) if (!st_stopped) ST_Stop(); - ST_InitData(); + // 'link' the statusbar display to a player, which could be + // another player than consoleplayer, for example, when you + // change the view in a multiplayer demo with F12. + stplyr = &players[displayplayer]; + + st_palette = -1; st_stopped = false; } diff --git a/src/w_wad.c b/src/w_wad.c index 50fbc2fa4..0a563f708 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -64,6 +64,8 @@ #include "i_time.h" #include "i_system.h" #include "i_video.h" // rendermode +#include "st_stuff.h" +#include "hu_stuff.h" #include "md5.h" #include "lua_script.h" #ifdef SCANTHINGS @@ -1237,11 +1239,25 @@ void W_LoadFileScripts(UINT16 wadfilenum, boolean mainfile) } } -/** Unloads a file. - */ void W_UnloadWadFile(UINT16 num) { - G_SaveGameData(clientGamedata); + boolean is_important = wadfiles[num]->important; + + if (is_important) + G_SaveGameData(clientGamedata); + + // Clear all added sound effects for this file + for (INT32 i = sfx_freeslot0; i <= sfx_lastskinsoundslot; i++) + { + if (S_sfx[i].lumpnum != LUMPERROR && WADFILENUM(S_sfx[i].lumpnum) == num) + { + S_sfx[i].lumpnum = LUMPERROR; + S_sfx[i].priority = 0; + I_FreeSfx(&S_sfx[i]); + } + } + + W_ClearCachedData(); W_UnloadFile(wadfiles[num]); @@ -1251,18 +1267,34 @@ void W_UnloadWadFile(UINT16 num) for (UINT16 i = num; i < numwadfiles; i++) wadfiles[i] = wadfiles[i + 1]; - game_reloading = true; + if (!is_important) + { + HU_LoadGraphics(); + ST_LoadGraphics(); + ST_ReloadSkinFaceGraphics(); + S_PlayMapMusic(true); + return; + } D_ReloadFiles(); G_LoadGameData(clientGamedata); M_CopyGameData(serverGamedata, clientGamedata); - game_reloading = false; - G_AfterFileDeletion(); } +void W_ClearCachedData(void) +{ + // Stop all sounds, stop current music + S_StopSounds(); + S_ClearSfx(); + S_StopMusic(); + + // Unload HUD graphics + ST_UnloadGraphics(); +} + void W_UnloadAddons(boolean remove_all_addons) { for (UINT16 i = mainwads + 1; i < numwadfiles;) diff --git a/src/w_wad.h b/src/w_wad.h index 93795074a..fd8d46f30 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -182,6 +182,9 @@ void W_UnloadWadFile(UINT16 num); // Unloads all addons. void W_UnloadAddons(boolean remove_all_addons); +// Call before W_UnloadAddons or W_UnloadWadFile +void W_ClearCachedData(void); + const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum);