mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-23 19:01:06 +00:00
- change Cache_Get calls to Cache_TryGet (which I just added), so they
can tollerate failure. - minor error message tweak (an emptry string is not NULL!)
This commit is contained in:
parent
2c51098ac9
commit
6cab8cf4e0
5 changed files with 22 additions and 16 deletions
|
@ -146,6 +146,7 @@ void Cache_Report (void);
|
|||
void Cache_Add (cache_user_t *c, const char *filename, cache_loader_t loader);
|
||||
void Cache_Remove (cache_user_t *c);
|
||||
void *Cache_Get (cache_user_t *c);
|
||||
void *Cache_TryGet (cache_user_t *c);
|
||||
void Cache_Release (cache_user_t *c);
|
||||
|
||||
/* Modes, pick one */
|
||||
|
|
|
@ -360,10 +360,9 @@ SND_PrecacheSound (const char *name)
|
|||
sfx = SND_FindName (name);
|
||||
|
||||
// cache it in
|
||||
if (precache->int_val) {
|
||||
Cache_Get (&sfx->cache);
|
||||
Cache_Release (&sfx->cache);
|
||||
}
|
||||
if (precache->int_val)
|
||||
if (Cache_TryGet (&sfx->cache))
|
||||
Cache_Release (&sfx->cache);
|
||||
|
||||
return sfx;
|
||||
}
|
||||
|
@ -499,7 +498,7 @@ SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin,
|
|||
return; // not audible at all
|
||||
|
||||
// new channel
|
||||
sc = Cache_Get (&sfx->cache);
|
||||
sc = Cache_TryGet (&sfx->cache);
|
||||
if (!sc) {
|
||||
target_chan->sfx = NULL;
|
||||
return; // couldn't load the sound's data
|
||||
|
@ -617,7 +616,7 @@ SND_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
|
|||
ss = &channels[total_channels];
|
||||
total_channels++;
|
||||
|
||||
sc = Cache_Get (&sfx->cache);
|
||||
sc = Cache_TryGet (&sfx->cache);
|
||||
if (!sc)
|
||||
return;
|
||||
|
||||
|
@ -899,7 +898,7 @@ SND_SoundList (void)
|
|||
int size, total;
|
||||
int load;
|
||||
|
||||
if (Cmd_Argc() >= 2 && !strcmp (Cmd_Argv (1), "known"))
|
||||
if (Cmd_Argc() >= 2 && Cmd_Argv (1)[0])
|
||||
load = 1;
|
||||
else
|
||||
load = 0;
|
||||
|
@ -907,7 +906,7 @@ SND_SoundList (void)
|
|||
total = 0;
|
||||
for (sfx = known_sfx, i = 0; i < num_sfx; i++, sfx++) {
|
||||
if (load)
|
||||
sc = Cache_Get (&sfx->cache);
|
||||
sc = Cache_TryGet (&sfx->cache);
|
||||
else
|
||||
sc = Cache_Check (&sfx->cache);
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ SND_PaintChannels (int endtime)
|
|||
continue;
|
||||
if (!ch->leftvol && !ch->rightvol)
|
||||
continue;
|
||||
sc = Cache_Get (&ch->sfx->cache);
|
||||
sc = Cache_TryGet (&ch->sfx->cache);
|
||||
if (!sc)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ Mod_FindName (const char *name)
|
|||
model_t *mod;
|
||||
|
||||
if (!name[0])
|
||||
Sys_Error ("Mod_FindName: NULL name");
|
||||
Sys_Error ("Mod_FindName: empty name");
|
||||
|
||||
// search the currently loaded models
|
||||
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
|
||||
|
|
|
@ -999,7 +999,7 @@ Cache_Remove (cache_user_t *c)
|
|||
}
|
||||
|
||||
void *
|
||||
Cache_Get (cache_user_t *c)
|
||||
Cache_TryGet (cache_user_t *c)
|
||||
{
|
||||
void *mem;
|
||||
CACHE_WRITE_LOCK;
|
||||
|
@ -1009,16 +1009,22 @@ Cache_Get (cache_user_t *c)
|
|||
c->loader (c, Cache_RealAlloc);
|
||||
mem = Cache_RealCheck (c);
|
||||
}
|
||||
|
||||
if (!mem)
|
||||
Sys_Error ("Cache_Get: couldn't get cache!\n");
|
||||
|
||||
(((cache_system_t *)c->data) - 1)->readlock++;
|
||||
if (mem)
|
||||
(((cache_system_t *)c->data) - 1)->readlock++;
|
||||
|
||||
CACHE_WRITE_UNLOCK;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void *
|
||||
Cache_Get (cache_user_t *c)
|
||||
{
|
||||
void *mem = Cache_TryGet (c);
|
||||
if (!mem)
|
||||
Sys_Error ("Cache_Get: couldn't get cache!\n");
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
Cache_Release (cache_user_t *c)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue