diff --git a/include/QF/draw.h b/include/QF/draw.h index 6354ee80c..7d90d32e3 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -163,10 +163,6 @@ void Draw_FadeScreen (void); \ingroup video_renderer_draw */ //@{ -/** Clear out the cached qpic textures. -*/ -void Draw_ClearCache (void); - /** Load a qpic from the filesystem. \param path path of the file within the quake filesystem \param alpha transparency level of the pic. diff --git a/include/QF/quakefs.h b/include/QF/quakefs.h index 6604f053c..20e5631dc 100644 --- a/include/QF/quakefs.h +++ b/include/QF/quakefs.h @@ -71,7 +71,10 @@ typedef struct gamedir_s { } dir; } gamedir_t; -typedef void gamedir_callback_t (void); +/** Function type of callback called on gamedir change. + \param phase 0 = before Cache_Flush(), 1 = after Cache_Flush() +*/ +typedef void gamedir_callback_t (int phase); extern searchpath_t *qfs_searchpaths; extern gamedir_t *qfs_gamedir; diff --git a/libs/audio/cd/cd_file.c b/libs/audio/cd/cd_file.c index d5986d687..b73a3751c 100644 --- a/libs/audio/cd/cd_file.c +++ b/libs/audio/cd/cd_file.c @@ -407,9 +407,10 @@ Mus_VolChange (cvar_t *bgmvolume) } static void -Mus_gamedir (void) +Mus_gamedir (int phase) { - Mus_OggChange (mus_ogglist); + if (phase); + Mus_OggChange (mus_ogglist); } static void diff --git a/libs/audio/renderer/snd_channels.c b/libs/audio/renderer/snd_channels.c index 2ea46241c..454b3e73f 100644 --- a/libs/audio/renderer/snd_channels.c +++ b/libs/audio/renderer/snd_channels.c @@ -249,10 +249,12 @@ s_playvol_f (void) } static void -s_channels_gamedir (void) +s_channels_gamedir (int phase) { - ambient_sfx[AMBIENT_WATER] = SND_PrecacheSound ("ambience/water1.wav"); - ambient_sfx[AMBIENT_SKY] = SND_PrecacheSound ("ambience/wind2.wav"); + if (phase) { + ambient_sfx[AMBIENT_WATER] = SND_PrecacheSound ("ambience/water1.wav"); + ambient_sfx[AMBIENT_SKY] = SND_PrecacheSound ("ambience/wind2.wav"); + } } void @@ -361,39 +363,35 @@ s_updateAmbientSounds (void) // stop all ambient channels. for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) { - if (ambient_channels[ambient_channel]) - SND_ChannelStop (ambient_channels[ambient_channel]); - ambient_channels[ambient_channel] = 0; + if (ambient_channels[ambient_channel]) { + chan->master_vol = 0; + chan->leftvol = chan->rightvol = chan->master_vol; + } } return; } for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) { - chan = ambient_channels[ambient_channel]; - if (chan && chan->done) { - SND_ChannelStop (chan); - chan = ambient_channels[ambient_channel] = 0; - } sfx = ambient_sfx[ambient_channel]; - if (!sfx) { - if (chan) - SND_ChannelStop (chan); - chan = ambient_channels[ambient_channel] = 0; + if (!sfx) continue; - } - if (!chan) + chan = ambient_channels[ambient_channel]; + if (!chan) { chan = ambient_channels[ambient_channel] = SND_AllocChannel (); - if (!chan) - continue; + if (!chan) + continue; + } if (!chan->sfx) { sfx = sfx->open (sfx); + if (!sfx) + continue; sfx->retain (sfx); } else { sfx = chan->sfx; - sfx->retain (sfx); //FIXME why is this necessary? + //sfx->retain (sfx); //FIXME why is this necessary? } // sfx will be written to chan->sfx later to ensure mixer doesn't use // channel prematurely. diff --git a/libs/audio/renderer/snd_sfx.c b/libs/audio/renderer/snd_sfx.c index 1710af585..5666687d3 100644 --- a/libs/audio/renderer/snd_sfx.c +++ b/libs/audio/renderer/snd_sfx.c @@ -210,7 +210,7 @@ SND_PrecacheSound (const char *name) } static void -s_gamedir (void) +s_gamedir (int phase) { snd_num_sfx = 0; } diff --git a/libs/net/nc/net_udp.c b/libs/net/nc/net_udp.c index f18961952..69e96c16b 100644 --- a/libs/net/nc/net_udp.c +++ b/libs/net/nc/net_udp.c @@ -284,7 +284,8 @@ NET_GetPacket (void) #endif // _WIN32 if (err == EWOULDBLOCK) return false; - Con_Printf ("NET_GetPacket: %d: %s\n", err, strerror (err)); + Con_Printf ("NET_GetPacket: %d: %d: %s\n", net_socket, err, + strerror (err)); return false; } @@ -335,7 +336,8 @@ NET_SendPacket (int length, void *data, netadr_t to) if (err == EWOULDBLOCK) return; - Con_Printf ("NET_SendPacket: %s\n", strerror (errno)); + Con_Printf ("NET_SendPacket: %d: %d: %s\n", net_socket, err, + strerror (errno)); } } diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index a6eaa759a..90eb3e0d1 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -1187,11 +1187,12 @@ QFS_Gamedir (const char *dir) // Make sure everyone else knows we've changed gamedirs for (i = 0; i < num_gamedir_callbacks; i++) { - gamedir_callbacks[i] (); + gamedir_callbacks[i] (0); } - - // Flush cache last, so other things get a chance to deal with it Cache_Flush (); + for (i = 0; i < num_gamedir_callbacks; i++) { + gamedir_callbacks[i] (1); + } } /* diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index aaeb0b36b..9efec2675 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -186,12 +186,14 @@ Draw_PicFromWad (const char *name) return p; } -void -Draw_ClearCache (void) +static void +Draw_ClearCache (int phase) { cachepic_t *pic; int i; + if (phase) + return; for (pic = cachepics, i = 0; i < numcachepics; pic++, i++) pic->dirty = true; } diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index 8139f143f..5c42cdcc2 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -82,12 +82,6 @@ Draw_PicFromWad (const char *name) } -void -Draw_ClearCache (void) -{ -} - - VISIBLE qpic_t * Draw_CachePic (const char *path, qboolean alpha) { diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index ba9e8144f..fdda1c45d 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -82,12 +82,6 @@ Draw_PicFromWad (const char *name) } -void -Draw_ClearCache (void) -{ -} - - VISIBLE qpic_t * Draw_CachePic (const char *path, qboolean alpha) { diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 8034a2025..5e896723f 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1693,10 +1693,12 @@ CL_Init_Memory (void) } static void -CL_Autoexec (void) +CL_Autoexec (int phase) { int cmd_warncmd_val = cmd_warncmd->int_val; + if (!phase) + return; Cbuf_AddText (cl_cbuf, "cmd_warncmd 0\n"); Cbuf_AddText (cl_cbuf, "exec config.cfg\n"); Cbuf_AddText (cl_cbuf, "exec frontend.cfg\n"); diff --git a/qw/source/cl_tent.c b/qw/source/cl_tent.c index 1991cb718..c75510016 100644 --- a/qw/source/cl_tent.c +++ b/qw/source/cl_tent.c @@ -93,8 +93,10 @@ model_t *cl_mod_bolt3; model_t *cl_spr_explod; static void -CL_TEnts_Precache (void) +CL_TEnts_Precache (int phase) { + if (!phase) + return; cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav"); cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav"); cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav"); @@ -116,7 +118,7 @@ void CL_TEnts_Init (void) { QFS_GamedirCallback (CL_TEnts_Precache); - CL_TEnts_Precache (); + CL_TEnts_Precache (1); } void