mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-29 07:32:02 +00:00
Don't reload all files if removing an unimportant one
This commit is contained in:
parent
12599c6272
commit
2876a02466
14 changed files with 62 additions and 66 deletions
|
@ -3884,8 +3884,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
|
||||||
|
|
||||||
// wake up the status bar
|
// wake up the status bar
|
||||||
ST_Start();
|
ST_Start();
|
||||||
// wake up the heads up text
|
|
||||||
HU_Start();
|
|
||||||
|
|
||||||
if (camera.chase && !splitscreenplayer)
|
if (camera.chase && !splitscreenplayer)
|
||||||
P_ResetCamera(newplayer, &camera);
|
P_ResetCamera(newplayer, &camera);
|
||||||
|
|
14
src/d_main.c
14
src/d_main.c
|
@ -1761,6 +1761,8 @@ void D_SRB2Main(void)
|
||||||
// Reload all files.
|
// Reload all files.
|
||||||
void D_ReloadFiles(void)
|
void D_ReloadFiles(void)
|
||||||
{
|
{
|
||||||
|
game_reloading = true;
|
||||||
|
|
||||||
// Set the initial state
|
// Set the initial state
|
||||||
G_InitialState();
|
G_InitialState();
|
||||||
|
|
||||||
|
@ -1777,7 +1779,6 @@ void D_ReloadFiles(void)
|
||||||
Patch_FreeTag(PU_PATCH_LOWPRIORITY);
|
Patch_FreeTag(PU_PATCH_LOWPRIORITY);
|
||||||
Patch_FreeTag(PU_PATCH_ROTATED);
|
Patch_FreeTag(PU_PATCH_ROTATED);
|
||||||
Patch_FreeTag(PU_SPRITE);
|
Patch_FreeTag(PU_SPRITE);
|
||||||
Patch_FreeTag(PU_HUDGFX);
|
|
||||||
|
|
||||||
// Load SOC and Lua.
|
// Load SOC and Lua.
|
||||||
for (INT32 i = 0; i < numwadfiles; i++)
|
for (INT32 i = 0; i < numwadfiles; i++)
|
||||||
|
@ -1795,23 +1796,18 @@ void D_ReloadFiles(void)
|
||||||
P_InitPicAnims();
|
P_InitPicAnims();
|
||||||
|
|
||||||
// Flush and reload HUD graphics
|
// Flush and reload HUD graphics
|
||||||
ST_UnloadGraphics();
|
|
||||||
HU_LoadGraphics();
|
HU_LoadGraphics();
|
||||||
ST_LoadGraphics();
|
ST_LoadGraphics();
|
||||||
ST_ReloadSkinFaceGraphics();
|
ST_ReloadSkinFaceGraphics();
|
||||||
|
|
||||||
|
game_reloading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D_RestartGame(boolean remove_all_addons)
|
void D_RestartGame(boolean remove_all_addons)
|
||||||
{
|
{
|
||||||
// Remove all addons
|
W_ClearCachedData();
|
||||||
W_UnloadAddons(remove_all_addons);
|
W_UnloadAddons(remove_all_addons);
|
||||||
|
|
||||||
// Reload all files
|
|
||||||
game_reloading = true;
|
|
||||||
|
|
||||||
D_ReloadFiles();
|
D_ReloadFiles();
|
||||||
|
|
||||||
game_reloading = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *D_Home(void)
|
const char *D_Home(void)
|
||||||
|
|
10
src/g_game.c
10
src/g_game.c
|
@ -4349,15 +4349,13 @@ void G_InitialState(void)
|
||||||
// Delete all skins.
|
// Delete all skins.
|
||||||
R_DelSkins();
|
R_DelSkins();
|
||||||
|
|
||||||
// Stop all sound effects.
|
// Clear all added sound effects.
|
||||||
S_StopSounds();
|
for (INT32 i = sfx_freeslot0; i <= sfx_lastskinsoundslot; i++)
|
||||||
S_ClearSfx();
|
|
||||||
|
|
||||||
for (INT32 i = 0; i < NUMSFX; i++)
|
|
||||||
{
|
{
|
||||||
if (S_sfx[i].lumpnum != LUMPERROR)
|
if (S_sfx[i].lumpnum != LUMPERROR)
|
||||||
{
|
{
|
||||||
S_RemoveSoundFx(i);
|
S_sfx[i].lumpnum = LUMPERROR;
|
||||||
|
S_sfx[i].priority = 0;
|
||||||
I_FreeSfx(&S_sfx[i]);
|
I_FreeSfx(&S_sfx[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,11 +75,9 @@ patch_t *ttlnum[10]; // act numbers (0-9)
|
||||||
patch_t *ntb_font[NT_FONTSIZE];
|
patch_t *ntb_font[NT_FONTSIZE];
|
||||||
patch_t *nto_font[NT_FONTSIZE];
|
patch_t *nto_font[NT_FONTSIZE];
|
||||||
|
|
||||||
static player_t *plr;
|
|
||||||
boolean chat_on; // entering a chat message?
|
boolean chat_on; // entering a chat message?
|
||||||
static char w_chat[HU_MAXMSGLEN + 1];
|
static char w_chat[HU_MAXMSGLEN + 1];
|
||||||
static size_t c_input = 0; // let's try to make the chat input less shitty.
|
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
|
boolean hu_showscores; // draw rankings
|
||||||
static char hu_tick;
|
static char hu_tick;
|
||||||
|
|
||||||
|
@ -341,24 +339,6 @@ void HU_Init(void)
|
||||||
luahuddrawlist_scores = LUA_HUD_CreateDrawList();
|
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
|
// EXECUTION
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
|
@ -104,9 +104,6 @@ void HU_Init(void);
|
||||||
|
|
||||||
void HU_LoadGraphics(void);
|
void HU_LoadGraphics(void);
|
||||||
|
|
||||||
// reset heads up when consoleplayer respawns.
|
|
||||||
void HU_Start(void);
|
|
||||||
|
|
||||||
boolean HU_Responder(event_t *ev);
|
boolean HU_Responder(event_t *ev);
|
||||||
void HU_Ticker(void);
|
void HU_Ticker(void);
|
||||||
void HU_Drawer(void);
|
void HU_Drawer(void);
|
||||||
|
|
|
@ -11676,8 +11676,6 @@ void P_AfterPlayerSpawn(INT32 playernum)
|
||||||
{
|
{
|
||||||
// wake up the status bar
|
// wake up the status bar
|
||||||
ST_Start();
|
ST_Start();
|
||||||
// wake up the heads up text
|
|
||||||
HU_Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p->drawangle = mobj->angle;
|
p->drawangle = mobj->angle;
|
||||||
|
|
|
@ -7846,7 +7846,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
||||||
// As oddly named as this is, this handles music only.
|
// As oddly named as this is, this handles music only.
|
||||||
// We should be fine starting it here.
|
// We should be fine starting it here.
|
||||||
// Don't do this during titlemap, because the menu code handles music by itself.
|
// Don't do this during titlemap, because the menu code handles music by itself.
|
||||||
S_Start();
|
S_PlayMapMusic(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
levelfadecol = (ranspecialwipe) ? 0 : 31;
|
levelfadecol = (ranspecialwipe) ? 0 : 31;
|
||||||
|
|
|
@ -2431,7 +2431,7 @@ boolean S_FadeOutStopMusic(UINT32 ms)
|
||||||
// Kills playing sounds at start of level,
|
// Kills playing sounds at start of level,
|
||||||
// determines music if any, changes music.
|
// determines music if any, changes music.
|
||||||
//
|
//
|
||||||
void S_StartEx(boolean reset)
|
void S_PlayMapMusic(boolean reset)
|
||||||
{
|
{
|
||||||
if (mapmusflags & MUSIC_RELOADRESET)
|
if (mapmusflags & MUSIC_RELOADRESET)
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,8 +125,7 @@ void S_InitSfxChannels(INT32 sfxVolume);
|
||||||
//
|
//
|
||||||
void S_StopSounds(void);
|
void S_StopSounds(void);
|
||||||
void S_ClearSfx(void);
|
void S_ClearSfx(void);
|
||||||
void S_StartEx(boolean reset);
|
void S_PlayMapMusic(boolean reset);
|
||||||
#define S_Start() S_StartEx(false)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum.
|
// Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum.
|
||||||
|
|
|
@ -151,7 +151,7 @@ static void Midiplayer_Onchange(void)
|
||||||
Mix_Timidity_addToPathList(cv_miditimiditypath.string);
|
Mix_Timidity_addToPathList(cv_miditimiditypath.string);
|
||||||
|
|
||||||
if (restart)
|
if (restart)
|
||||||
S_StartEx(true);
|
S_PlayMapMusic(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MidiSoundfontPath_Onchange(void)
|
static void MidiSoundfontPath_Onchange(void)
|
||||||
|
@ -189,7 +189,7 @@ static void MidiSoundfontPath_Onchange(void)
|
||||||
if (!Mix_SetSoundFonts(cv_midisoundfontpath.string))
|
if (!Mix_SetSoundFonts(cv_midisoundfontpath.string))
|
||||||
CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError());
|
CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError());
|
||||||
else
|
else
|
||||||
S_StartEx(true);
|
S_PlayMapMusic(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -915,7 +915,7 @@ void S_RemoveSoundFx(sfxenum_t id)
|
||||||
&& S_sfx[id].priority != 0)
|
&& S_sfx[id].priority != 0)
|
||||||
{
|
{
|
||||||
S_sfx[id].lumpnum = LUMPERROR;
|
S_sfx[id].lumpnum = LUMPERROR;
|
||||||
I_FreeSfx(&S_sfx[id]);
|
|
||||||
S_sfx[id].priority = 0;
|
S_sfx[id].priority = 0;
|
||||||
|
I_FreeSfx(&S_sfx[id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,16 +403,6 @@ void ST_UnLoadFaceGraphics(INT32 skinnum)
|
||||||
W_UnlockCachedPatch(superprefix[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)
|
static inline void ST_Stop(void)
|
||||||
{
|
{
|
||||||
if (st_stopped)
|
if (st_stopped)
|
||||||
|
@ -428,7 +418,12 @@ void ST_Start(void)
|
||||||
if (!st_stopped)
|
if (!st_stopped)
|
||||||
ST_Stop();
|
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;
|
st_stopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
42
src/w_wad.c
42
src/w_wad.c
|
@ -64,6 +64,8 @@
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "i_video.h" // rendermode
|
#include "i_video.h" // rendermode
|
||||||
|
#include "st_stuff.h"
|
||||||
|
#include "hu_stuff.h"
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
#include "lua_script.h"
|
#include "lua_script.h"
|
||||||
#ifdef SCANTHINGS
|
#ifdef SCANTHINGS
|
||||||
|
@ -1237,12 +1239,26 @@ void W_LoadFileScripts(UINT16 wadfilenum, boolean mainfile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Unloads a file.
|
|
||||||
*/
|
|
||||||
void W_UnloadWadFile(UINT16 num)
|
void W_UnloadWadFile(UINT16 num)
|
||||||
{
|
{
|
||||||
|
boolean is_important = wadfiles[num]->important;
|
||||||
|
|
||||||
|
if (is_important)
|
||||||
G_SaveGameData(clientGamedata);
|
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]);
|
W_UnloadFile(wadfiles[num]);
|
||||||
|
|
||||||
wadfiles[num] = NULL;
|
wadfiles[num] = NULL;
|
||||||
|
@ -1251,18 +1267,34 @@ void W_UnloadWadFile(UINT16 num)
|
||||||
for (UINT16 i = num; i < numwadfiles; i++)
|
for (UINT16 i = num; i < numwadfiles; i++)
|
||||||
wadfiles[i] = wadfiles[i + 1];
|
wadfiles[i] = wadfiles[i + 1];
|
||||||
|
|
||||||
game_reloading = true;
|
if (!is_important)
|
||||||
|
{
|
||||||
|
HU_LoadGraphics();
|
||||||
|
ST_LoadGraphics();
|
||||||
|
ST_ReloadSkinFaceGraphics();
|
||||||
|
S_PlayMapMusic(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
D_ReloadFiles();
|
D_ReloadFiles();
|
||||||
|
|
||||||
G_LoadGameData(clientGamedata);
|
G_LoadGameData(clientGamedata);
|
||||||
M_CopyGameData(serverGamedata, clientGamedata);
|
M_CopyGameData(serverGamedata, clientGamedata);
|
||||||
|
|
||||||
game_reloading = false;
|
|
||||||
|
|
||||||
G_AfterFileDeletion();
|
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)
|
void W_UnloadAddons(boolean remove_all_addons)
|
||||||
{
|
{
|
||||||
for (UINT16 i = mainwads + 1; i < numwadfiles;)
|
for (UINT16 i = mainwads + 1; i < numwadfiles;)
|
||||||
|
|
|
@ -182,6 +182,9 @@ void W_UnloadWadFile(UINT16 num);
|
||||||
// Unloads all addons.
|
// Unloads all addons.
|
||||||
void W_UnloadAddons(boolean remove_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_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
|
||||||
const char *W_CheckNameForNum(lumpnum_t lumpnum);
|
const char *W_CheckNameForNum(lumpnum_t lumpnum);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue