Exemple #1
0
/*
@@@@@@@@@@@@@@@@@@@@@
RE_EndRegistration

@@@@@@@@@@@@@@@@@@@@@
*/
void RE_EndRegistration(void)
{
  int i;
  model_t *mod;

  for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) {
    if (!mod->name[0])
      continue;
    if (mod->registration_sequence != registration_sequence) { // don't need this model
      Hunk_Free(mod->extradata);
      memset(mod, 0, sizeof(*mod));
    } else { // make sure it is paged in
      Com_PageInMemory(mod->extradata, mod->extradatasize);
    }
  }

  R_FreeUnusedImages();
}
/*
=====================
S_EndRegistration

=====================
*/
void S_EndRegistration (void)
{
	int		i;
	sfx_t	*sfx;
	int		size;

	// free any sounds not from this registration sequence
	for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
	{
		if (!sfx->name[0])
			continue;
		if (sfx->registration_sequence != s_registration_sequence)
		{	// don't need this sound
			if (sfx->cache)	// it is possible to have a leftover
				Z_Free (sfx->cache);	// from a server that didn't finish loading
			memset (sfx, 0, sizeof(*sfx));
		}
		else
		{	// make sure it is paged in
			if (sfx->cache)
			{
				size = sfx->cache->length*sfx->cache->width;
				Com_PageInMemory ((byte *)sfx->cache, size);
			}
		}

	}

	// load everything in
	for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
	{
		if (!sfx->name[0])
			continue;
		S_LoadSound (sfx);
	}

	s_registering = false;

	// Knightmare added
	// S_EndRegistration is only called while the refresh is prepped
	// during a sound resart, so we can use this to restart the music track
	if (cls.state == ca_active && cl.refresh_prepped && !CDAudio_Active())
		CL_PlayBackgroundTrack ();
}
Exemple #3
0
/*
================
R_FreeUnusedImages

Any image that was not touched on this registration sequence
will be freed.
================
*/
void R_FreeUnusedImages(void)
{
  int i;
  image_t *image;

  for (i = 0, image = r_images; i < numr_images; i++, image++) {
    if (image->registration_sequence == registration_sequence) {
      Com_PageInMemory((byte *) image->pixels[0], image->width * image->height);
      continue; // used this sequence
    }
    if (!image->registration_sequence)
      continue; // free texture
    if (image->type == it_pic)
      continue; // don't free pics
    // free it
    free(image->pixels[0]); // the other mip levels just follow
    memset(image, 0, sizeof(*image));
  }
}
Exemple #4
0
/*
=====================
S_EndRegistration

=====================
*/
void S_EndRegistration(void)
{
    int i;
    sfx_t * sfx;
    int size;

    // free any sounds not from this registration sequence
    for (i = 0, sfx = known_sfx; i < num_sfx; i++, sfx++)
    {
        if (!sfx->name[0])
            continue;
        if (sfx->registration_sequence != s_registration_sequence)
        {                           // don't need this sound
            if (sfx->cache)         // it is possible to have a leftover
                Z_Free(sfx->cache); // from a server that didn't finish loading
            memset(sfx, 0, sizeof(*sfx));
        }
        else
        { // make sure it is paged in
            if (sfx->cache)
            {
                size = sfx->cache->length * sfx->cache->width;
                Com_PageInMemory((byte *)sfx->cache, size);
            }
        }
    }

    // load everything in
    for (i = 0, sfx = known_sfx; i < num_sfx; i++, sfx++)
    {
        if (!sfx->name[0])
            continue;
        S_LoadSound(sfx);
    }

    s_registering = false;
}
Exemple #5
0
/*
=====================
S_EndRegistration

=====================
*/
void S_EndRegistration (void)
{
	int		i;
	sfx_t	*sfx, *entry, **back;
	int		size;
	unsigned int hash;

	// free any sounds not from this registration sequence
	for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
	{
		if (!sfx->name[0])
			continue;
		if (sfx->registration_sequence == s_registration_sequence) {
#ifdef USE_OPENAL
			if(sfx->cache && !alSound) { // make sure it is paged in
#else
			if(sfx->cache) { // make sure it is paged in
#endif
				size = sfx->cache->length * sfx->cache->width * sfx->cache->channels;
				Com_PageInMemory( (byte *)sfx->cache, size);
			}
			continue;
		}

		hash = Com_HashKey (sfx->name, SND_HASH_SIZE);
		// delete it from hash table
		for( back=&sfx_hash[hash], entry=sfx_hash[hash]; entry; back=&entry->hashNext, entry=entry->hashNext ) {
			if( entry == sfx ) {
				*back = entry->hashNext;
				break;
			}
		}

		if (sfx->cache)	{ // it is possible to have a leftover
#ifdef USE_OPENAL
			if(alSound)
				ALSnd_DeleteBuffer(sfx->cache);
#endif
			Z_Free (sfx->cache);	// from a server that didn't finish loading
		}
		if (sfx->truename)
			Z_Free (sfx->truename);

		memset (sfx, 0, sizeof(*sfx));
	}

	// load everything in
	for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
	{
		if (!sfx->name[0])
			continue;
		S_LoadSound (sfx);
	}

	s_registering = false;
}


//=============================================================================

/*
=================
S_PickChannel
=================
*/
static channel_t *S_PickChannel(int entnum, int entchannel)
{
    int			ch_idx;
    int			first_to_die = -1;
    int			life_left = 0x7fffffff;
	channel_t	*ch;

	if (entchannel < 0)
		Com_Error(ERR_DROP, "S_PickChannel: entchannel < 0");

// Check for replacement sound, or find the best one to replace
    for (ch_idx=0 ; ch_idx < MAX_CHANNELS ; ch_idx++)
    {
		if (entchannel != 0		// channel 0 never overrides
		&& channels[ch_idx].entnum == entnum
		&& channels[ch_idx].entchannel == entchannel)
		{	// always override sound from same entity
			first_to_die = ch_idx;
			break;
		}

		// don't let monster sounds override player sounds
		if (channels[ch_idx].entnum == cl.playernum+1 && entnum != cl.playernum+1 && channels[ch_idx].sfx)
			continue;

		if (channels[ch_idx].end - paintedtime < life_left)
		{
			life_left = channels[ch_idx].end - paintedtime;
			first_to_die = ch_idx;
		}
   }

	if (first_to_die == -1)
		return NULL;

	ch = &channels[first_to_die];
	memset (ch, 0, sizeof(*ch));

    return ch;
}