mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
make gamedir change a two phase operation so things can be done both before and after the cache is flushed. (still having problems with cached sounds, though)
This commit is contained in:
parent
54139a1742
commit
02c41feabc
12 changed files with 45 additions and 50 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -210,7 +210,7 @@ SND_PrecacheSound (const char *name)
|
|||
}
|
||||
|
||||
static void
|
||||
s_gamedir (void)
|
||||
s_gamedir (int phase)
|
||||
{
|
||||
snd_num_sfx = 0;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -82,12 +82,6 @@ Draw_PicFromWad (const char *name)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
Draw_ClearCache (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
VISIBLE qpic_t *
|
||||
Draw_CachePic (const char *path, qboolean alpha)
|
||||
{
|
||||
|
|
|
@ -82,12 +82,6 @@ Draw_PicFromWad (const char *name)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
Draw_ClearCache (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
VISIBLE qpic_t *
|
||||
Draw_CachePic (const char *path, qboolean alpha)
|
||||
{
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue