示例#1
0
//
// R_LoadVoxelResource
//
// Loads a .vox-format voxel model into an rvoxelmodel_t structure.
//
rvoxelmodel_t *R_LoadVoxelResource(int lumpnum)
{
   rvoxelmodel_t *model = NULL;
   byte *buffer = NULL, *rover = NULL;
   int lumplen  = W_LumpLength(lumpnum);
   int xsize, ysize, zsize, voxsize;
   int i;

   // minimum size test
   if(lumplen < 12)
      return NULL;

   // cache the lump
   rover = buffer = (byte *)(wGlobalDir.cacheLumpNum(lumpnum, PU_STATIC));

   // get sizes
   xsize = SwapLong(*(int32_t *)rover);
   rover += 4;
   ysize = SwapLong(*(int32_t *)rover);
   rover += 4;
   zsize = SwapLong(*(int32_t *)rover);
   rover += 4;

   voxsize = xsize*ysize*zsize;

   // true size test
   if(lumplen < 12 + voxsize + 768)
   {
      Z_ChangeTag(buffer, PU_CACHE);
      return NULL;
   }

   // create the model and its voxel buffer
   model         = (rvoxelmodel_t *)(Z_Calloc(1,       sizeof(rvoxelmodel_t), PU_RENDERER, NULL));
   model->voxels =          (byte *)(Z_Calloc(voxsize, sizeof(byte),          PU_RENDERER, NULL));

   model->xsize = xsize;
   model->ysize = ysize;
   model->zsize = zsize;

   // get voxel data
   memcpy(model->voxels, rover, voxsize);
   rover += voxsize;

   // get original palette data
   memcpy(model->palette, rover, 768);

   // transform palette data into 0-255 range
   // TODO: verify color component order
   for(i = 0; i < 768; i++)
      model->palette[i] <<= 2;

   // TODO: run V_FindBestColor to create translated palette?

   // done with lump
   Z_ChangeTag(buffer, PU_CACHE);

   return model;
}
示例#2
0
static void HI_Stop(void)
{
   if(hi_interpic)
      Z_ChangeTag(hi_interpic, PU_CACHE);

   Z_ChangeTag(hi_in_x, PU_CACHE);
   Z_ChangeTag(hi_in_yah, PU_CACHE);
}
示例#3
0
static void getsfx (struct sfxinfo_struct *sfx)
{
    Uint32 samplerate;
	Uint32 length ,expanded_length;
	Uint8 *data;
	Uint32 new_size = 0;
	Mix_Chunk *chunk;

    data = (Uint8 *)W_CacheLumpNum(sfx->lumpnum, PU_STATIC);
    // [Russell] - ICKY QUICKY HACKY SPACKY *I HATE THIS SOUND MANAGEMENT SYSTEM!*
    // get the lump size, shouldn't this be filled in elsewhere?
    sfx->length = W_LumpLength(sfx->lumpnum);

    // [Russell] is it not a doom sound lump?
    if (((data[1] << 8) | data[0]) != 3)
    {
        chunk = (Mix_Chunk *)Z_Malloc(sizeof(Mix_Chunk), PU_STATIC, NULL);
        chunk->allocated = 1;
        chunk->abuf = perform_sdlmix_conv(data, sfx->length, &new_size);
        chunk->alen = new_size;
        chunk->volume = MIX_MAX_VOLUME;

        sfx->data = chunk;

        Z_ChangeTag(data, PU_CACHE);

        return;
    }

	samplerate = (data[3] << 8) | data[2];
    length = (data[5] << 8) | data[4];

    // [Russell] - Ignore doom's sound format length info
    // if the lump is longer than the value, fixes exec.wad's ssg
    length = (sfx->length - 8 > length) ? sfx->length - 8 : length;

    expanded_length = (uint32_t) ((((uint64_t) length) * mixer_freq) / samplerate);

    // Double up twice: 8 -> 16 bit and mono -> stereo

    expanded_length *= 4;
	
	chunk = (Mix_Chunk *)Z_Malloc(sizeof(Mix_Chunk), PU_STATIC, NULL);
    chunk->allocated = 1;
    chunk->alen = expanded_length;
    chunk->abuf 
        = (Uint8 *)Z_Malloc(expanded_length, PU_STATIC, &chunk->abuf);
    chunk->volume = MIX_MAX_VOLUME;

    ExpandSoundData((unsigned char *)data + 8, 
                    samplerate, 
                    length, 
                    chunk);
                    
    sfx->data = chunk;
    
    Z_ChangeTag(data, PU_CACHE);
}
示例#4
0
void ST_unloadGraphics(void)
{

  int i;

  // unload the numbers, tall and short
  for (i=0;i<10;i++)
  {
    Z_ChangeTag(tallnum[i], PU_CACHE);
    Z_ChangeTag(shortnum[i], PU_CACHE);
  }
  // unload tall percent
  Z_ChangeTag(tallpercent, PU_CACHE); 

  // unload arms background
  Z_ChangeTag(armsbg, PU_CACHE); 

  // unload the key cards
  for (i=0;i<NUMCARDS;i++)
    Z_ChangeTag(keys[i], PU_CACHE);

  Z_ChangeTag(sbar, PU_CACHE);
  if (netgame)
  {
    Z_ChangeTag(faceback, PU_CACHE);
  }

  for (i=0;i<ST_NUMFACES;i++)
    Z_ChangeTag(faces[i], PU_CACHE);

  // Note: nobody ain't seen no unloading
  //   of stminus yet. Dude.


}
示例#5
0
static void UnloadPics(void)
{
	int i;

	if(HubCount || gametype == DEATHMATCH)
	{
		Z_ChangeTag(patchINTERPIC, PU_CACHE);
		for(i=0; i<10; i++)
		{
			Z_ChangeTag(FontBNumbers[i], PU_CACHE);
		}
		Z_ChangeTag(FontBNegative, PU_CACHE);
		Z_ChangeTag(FontBSlash, PU_CACHE);
		Z_ChangeTag(FontBPercent, PU_CACHE);
	}
}
示例#6
0
文件: w_wad.c 项目: mdgunn/doomretro
//
// W_CacheLumpNum
//
// Load a lump into memory and return a pointer to a buffer containing
// the lump data.
//
// 'tag' is the type of zone memory buffer to allocate for the lump
// (usually PU_STATIC or PU_CACHE). If the lump is loaded as
// PU_STATIC, it should be released back using W_ReleaseLumpNum
// when no longer needed (do not use Z_ChangeTag).
//
void *W_CacheLumpNum(lumpindex_t lumpnum, int tag)
{
    byte        *result;
    lumpinfo_t  *lump;

    if (lumpnum >= numlumps)
        I_Error("W_CacheLumpNum: %i >= numlumps", lumpnum);

    lump = lumpinfo[lumpnum];

    // Get the pointer to return. If the lump is in a memory-mapped
    // file, we can just return a pointer to within the memory-mapped
    // region. If the lump is in an ordinary file, we may already
    // have it cached; otherwise, load it into memory.
    if (lump->wad_file->mapped)
    {
        // Memory mapped file, return from the mmapped region.
        result = lump->wad_file->mapped + lump->position;
    }
    else if (lump->cache)
    {
        // Already cached, so just switch the zone tag.
        result = (byte *)lump->cache;
        Z_ChangeTag(lump->cache, tag);
    }
    else
    {
        // Not yet loaded, so load it now
        lump->cache = Z_Malloc(W_LumpLength(lumpnum), tag, &lump->cache);
        W_ReadLump(lumpnum, lump->cache);
        result = (byte *)lump->cache;
    }

    return result;
}
示例#7
0
文件: am_map.c 项目: fragglet/mbf
//
// AM_unloadPics()
//
// Makes the mark patches purgable
//
// Passed nothing, returns nothing
//
void AM_unloadPics(void)
{
  int i;

  for (i=0;i<10;i++)
    Z_ChangeTag(marknums[i], PU_CACHE);
}
示例#8
0
/*
 * W_LockLumpNum
 *
 * This copies the lump into a malloced memory region and returns its address
 * instead of returning a pointer into the memory mapped area
 *
 */
const void* W_LockLumpNum(int lump)
{
  size_t len = W_LumpLength(lump);
  const void *data = W_CacheLumpNum(lump);

  if (!cachelump[lump].cache) {
    // read the lump in
    Z_Malloc(len, PU_CACHE, &cachelump[lump].cache);
    memcpy(cachelump[lump].cache, data, len);
  }

  /* cph - if wasn't locked but now is, tell z_zone to hold it */
  if (cachelump[lump].locks <= 0) {
    Z_ChangeTag(cachelump[lump].cache,PU_STATIC);
#ifdef TIMEDIAG
    cachelump[lump].locktic = gametic;
#endif
    // reset lock counter
    cachelump[lump].locks = 1;
  } else {
    // increment lock counter
    cachelump[lump].locks += 1;
  }

#ifdef SIMPLECHECKS
  if (!((cachelump[lump].locks+1) & 0xf))
    lprintf(LO_DEBUG, "W_CacheLumpNum: High lock on %8s (%d)\n",
      lumpinfo[lump].name, cachelump[lump].locks);
#endif

  return cachelump[lump].cache;
}
示例#9
0
//---------------------------------------------------------------------------
const rpatch_t *R_CacheTextureCompositePatchNum(int id) {
  const int locks = 1;

  if (!texture_composites)
    I_Error("R_CacheTextureCompositePatchNum: Composite patches not initialized");

#ifdef RANGECHECK
  if (id >= numtextures)
    I_Error("createTextureCompositePatch: %i >= numtextures", id);
#endif

  if (!texture_composites[id].data)
    createTextureCompositePatch(id);

  /* cph - if wasn't locked but now is, tell z_zone to hold it */
  if (!texture_composites[id].locks && locks) {
    Z_ChangeTag(texture_composites[id].data,PU_STATIC);
#ifdef TIMEDIAG
    texture_composites[id].locktic = gametic;
#endif
  }
  texture_composites[id].locks += locks;

#ifdef SIMPLECHECKS
  if (!((texture_composites[id].locks+1) & 0xf))
    lprintf(LO_DEBUG, "R_CacheTextureCompositePatchNum: High lock on %8s (%d)\n", 
	    textures[id]->name, texture_composites[id].locks);
#endif

  return &texture_composites[id];

}
示例#10
0
文件: p_switch.c 项目: dorienh/smmu
//
// P_InitSwitchList()
//
// Only called at game initialization in order to list the set of switches
// and buttons known to the engine. This enables their texture to change
// when activated, and in the case of buttons, change back after a timeout.
//
// This routine modified to read its data from a predefined lump or
// PWAD lump called SWITCHES rather than a static table in this module to
// allow wad designers to insert or modify switches.
//
// Lump format is an array of byte packed switchlist_t structures, terminated
// by a structure with episode == -0. The lump can be generated from a
// text source file using SWANTBLS.EXE, distributed with the BOOM utils.
// The standard list of switches and animations is contained in the example
// source text file DEFSWANI.DAT also in the BOOM util distribution.
//
// Rewritten by Lee Killough to remove limit 2/8/98
//
void P_InitSwitchList(void)
{
  int i, index = 0;
  int episode = (gamemode == registered || gamemode==retail) ?
                 2 : gamemode == commercial ? 3 : 1;
  switchlist_t *alphSwitchList;         //jff 3/23/98 pointer to switch table

  //jff 3/23/98 read the switch table from a predefined lump             
  alphSwitchList = (switchlist_t *)W_CacheLumpName("SWITCHES",PU_STATIC);

  for (i=0;;i++)
  {
    if (index+1 >= max_numswitches)
      switchlist = realloc(switchlist, sizeof *switchlist *
          (max_numswitches = max_numswitches ? max_numswitches*2 : 8));
    if (SHORT(alphSwitchList[i].episode) <= episode) //jff 5/11/98 endianess
    {
      if (!SHORT(alphSwitchList[i].episode))
        break;
      switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1);
      switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2);
    }
  }

  numswitches = index/2;
  switchlist[index] = -1;
  Z_ChangeTag(alphSwitchList,PU_CACHE); //jff 3/23/98 allow table to be freed
}
示例#11
0
//
// W_CacheLumpNum
//
void*
W_CacheLumpNum
( int		lump,
  int		tag )
{
    byte*	ptr;

    if ((unsigned)lump >= numlumps)
	I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
		
    if (!lumpcache[lump])
    {
	// read the lump in
	
	//printf ("cache miss on lump %i\n",lump);
	ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]);
	W_ReadLump (lump, lumpcache[lump]);
    }
    else
    {
	//printf ("cache hit on lump %i\n",lump);
	Z_ChangeTag (lumpcache[lump],tag);
    }
	
    return lumpcache[lump];
}
示例#12
0
//---------------------------------------------------------------------------
const rpatch_t *R_CachePatchNum(int id) {
  const int locks = 1;

  if (!patches)
    I_Error("R_CachePatchNum: Patches not initialized");

#ifdef RANGECHECK
  if (id >= numlumps)
    I_Error("createPatch: %i >= numlumps", id);
#endif

  if (!patches[id].data)
    createPatch(id);

  /* cph - if wasn't locked but now is, tell z_zone to hold it */
  if (!patches[id].locks && locks) {
    Z_ChangeTag(patches[id].data,PU_STATIC);
#ifdef TIMEDIAG
    patches[id].locktic = gametic;
#endif
  }
  patches[id].locks += locks;

#ifdef SIMPLECHECKS
  if (!((patches[id].locks+1) & 0xf))
    lprintf(LO_DEBUG, "R_CachePatchNum: High lock on %8s (%d)\n", 
	    lumpinfo[id].name, patches[id].locks);
#endif

  return &patches[id];
}
示例#13
0
//
// Free the slider graphics.
//
void FE_FreeSlider(void)
{
    int i;

    for(i = 0; i < FE_SLIDER_NUMGFX; i++)
        Z_ChangeTag(feslidergfx[i], PU_CACHE);
}
示例#14
0
const void *W_CacheLumpNum(int lump)
{
  const int locks = 1;
#ifdef RANGECHECK
  if ((unsigned)lump >= (unsigned)numlumps)
    I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
#endif

  if (!cachelump[lump].cache)      // read the lump in
    W_ReadLump(lump, Z_Malloc(W_LumpLength(lump), PU_CACHE, &cachelump[lump].cache));

  /* cph - if wasn't locked but now is, tell z_zone to hold it */
  if (!cachelump[lump].locks && locks) {
    Z_ChangeTag(cachelump[lump].cache,PU_STATIC);
#ifdef TIMEDIAG
    cachelump[lump].locktic = gametic;
#endif
  }
  cachelump[lump].locks += locks;

#ifdef SIMPLECHECKS
  if (!((cachelump[lump].locks+1) & 0xf))
    lprintf(LO_DEBUG, "W_CacheLumpNum: High lock on %8s (%d)\n",
	    lumpinfo[lump].name, cachelump[lump].locks);
#endif

  return cachelump[lump].cache;
}
示例#15
0
void   *W_CacheLumpNum(int lump, int tag)
{
	byte   *ptr;

	if((unsigned) lump >= (unsigned) numlumps)
	{
		Con_Error("W_CacheLumpNum: %i >= numlumps", lump);
	}
	// Return the name instead of data?
	if(tag == PU_GETNAME)
	{
		strncpy(retname, lumpinfo[lump].name, 8);
		retname[8] = 0;
		return retname;
	}
	if(!lumpcache[lump])
	{							// Need to read the lump in
		ptr = Z_Malloc(W_LumpLength(lump), tag, &lumpcache[lump]);
		W_ReadLump(lump, lumpcache[lump]);
	}
	else
	{
		Z_ChangeTag(lumpcache[lump], tag);
	}
	return lumpcache[lump];
}
示例#16
0
文件: w_wad.c 项目: mdgunn/doomretro
//
// Release a lump back to the cache, so that it can be reused later
// without having to read from disk again, or alternatively, discarded
// if we run out of memory.
//
// Back in Vanilla DOOM, this was just done using Z_ChangeTag
// directly, but now that we have WAD mmap, things are a bit more
// complicated...
//
void W_ReleaseLumpNum(lumpindex_t lumpnum)
{
    lumpinfo_t  *lump;

    if (lumpnum >= numlumps)
        I_Error("W_ReleaseLumpNum: %i >= numlumps", lumpnum);

    lump = lumpinfo[lumpnum];

    if (!lump->wad_file->mapped)
        Z_ChangeTag(lump->cache, PU_CACHE);
}
示例#17
0
void W_RemoveLumpsWithHandle(DFILE * handle)
{
	int     i, k, first, len;

	for(i = 0, first = -1; i < numlumps; i++)
	{
		if(first < 0 && lumpinfo[i].handle == handle)
		{
			// Start a region.
			first = i;
			continue;
		}
		// Does a region end?
		if(first >= 0)
			if(lumpinfo[i].handle != handle || i == numlumps - 1 ||
			   MarkerForGroup(lumpinfo[i].name, true) ||
			   MarkerForGroup(lumpinfo[i].name, false))
			{
				if(lumpinfo[i].handle == handle && i == numlumps - 1)
					i++;		// Also free the last one.
				// The length of the region.
				len = i - first;
				// Free the memory allocated for the region.
				for(k = first; k < i; k++)
				{
					//  Con_Message("removing lump: %s (%d)\n", lumpinfo[k].name, lumpinfo[k].handle);
					if(lumpcache[k])
					{

						// If the block has a user, it must be explicitly freed.
						/*if((unsigned int)Z_GetUser(lumpcache[k]) > 0x100)
						   Z_Free(lumpcache[k]);
						   else if(Z_GetTag(lumpcache[k]) < PU_LEVEL)
						   Z_ChangeTag(lumpcache[k], PU_LEVEL); */
						//Z_ChangeTag(lumpcache[k], PU_CACHE);
						//Z_ChangeUser(lumpcache[k], NULL);
						if(Z_GetTag(lumpcache[k]) < PU_LEVEL)
							Z_ChangeTag(lumpcache[k], PU_LEVEL);
						// Mark the memory pointer in use, but unowned.
						Z_ChangeUser(lumpcache[k], (void *) 0x2);
					}
				}
				// Move the data in the lump storage.
				W_MoveLumps(i, numlumps - i, -len);
				numlumps -= len;
				i -= len;
				// Make it possible to begin a new region.
				first = -1;
			}
	}
}
示例#18
0
/*
===================
=
= R_GenerateComposite
=
===================
*/

void R_GenerateComposite (int texnum)
{
	byte		*block;
	texture_t	*texture;
	texpatch_t	*patch;	
	patch_t		*realpatch;
	int			x, x1, x2;
	int			i;
	column_t	*patchcol;
	short		*collump;
	unsigned short *colofs;
	
	texture = textures[texnum];
	block = Z_Malloc (texturecompositesize[texnum], PU_STATIC, 
		&texturecomposite[texnum]);	
	collump = texturecolumnlump[texnum];
	colofs = texturecolumnofs[texnum];
		
//
// composite the columns together
//
	patch = texture->patches;
		
	for (i=0 , patch = texture->patches; i<texture->patchcount ; i++, patch++)
	{
		realpatch = W_CacheLumpNum (patch->patch, PU_CACHE);
		x1 = patch->originx;
		x2 = x1 + SHORT(realpatch->width);

		if (x1<0)
			x = 0;
		else
			x = x1;
		if (x2 > texture->width)
			x2 = texture->width;

		for ( ; x<x2 ; x++)
		{
			if (collump[x] >= 0)
				continue;		// column does not have multiple patches
			patchcol = (column_t *)((byte *)realpatch + 
				LONG(realpatch->columnofs[x-x1]));
			R_DrawColumnInCache (patchcol, block + colofs[x], patch->originy,
			texture->height);
		}
						
	}

// now that the texture has been built, it is purgable
	Z_ChangeTag (block, PU_CACHE);
示例#19
0
static Mix_Chunk *GetSFXChunk(int sound_id)
{
    if (sound_chunks[sound_id].abuf == NULL)
    {
        if (!CacheSFX_SDL(sound_id))
            return NULL;
    }
    else
    {
        // don't free the sound while it is playing!
        Z_ChangeTag(sound_chunks[sound_id].abuf, PU_STATIC);
    }

    return &sound_chunks[sound_id];
}
示例#20
0
void W_UnlockLumpNum(int lump)
{
  const int unlocks = 1;
#ifdef SIMPLECHECKS
  if ((signed short)cachelump[lump].locks < unlocks)
    lprintf(LO_DEBUG, "W_UnlockLumpNum: Excess unlocks on %8s (%d-%d)\n",
	    lumpinfo[lump].name, cachelump[lump].locks, unlocks);
#endif
  cachelump[lump].locks -= unlocks;
  /* cph - Note: must only tell z_zone to make purgeable if currently locked,
   * else it might already have been purged
   */
  if (unlocks && !cachelump[lump].locks)
    Z_ChangeTag(cachelump[lump].cache, PU_CACHE);
}
示例#21
0
//
// E_DisposePatches
//
// Dumps all dumpable patches when overwriting a font.
//
static void E_DisposePatches(vfont_t *font)
{
   if(!font->fontgfx)
      return;

   for(unsigned int i = 0; i < font->size; i++)
   {
      if(font->fontgfx[i] && !E_IsPatchUsed(font, font->fontgfx[i]))
         Z_ChangeTag(font->fontgfx[i], PU_CACHE); // make purgable
   }

   // get rid of the patch array
   efree(font->fontgfx);
   font->fontgfx = nullptr;
}
示例#22
0
void R_UnlockTextureCompositePatchNum(int id)
{
  const int unlocks = 1;
#ifdef SIMPLECHECKS
  if ((signed short)texture_composites[id].locks < unlocks)
    lprintf(LO_DEBUG, "R_UnlockTextureCompositePatchNum: Excess unlocks on %8s (%d-%d)\n", 
	    textures[id]->name, texture_composites[id].locks, unlocks);
#endif
  texture_composites[id].locks -= unlocks;
  /* cph - Note: must only tell z_zone to make purgeable if currently locked, 
   * else it might already have been purged
   */
  if (unlocks && !texture_composites[id].locks)
    Z_ChangeTag(texture_composites[id].data, PU_CACHE);
}
示例#23
0
rpatch_t *R_CacheTextureCompositePatchNum(int id)
{
    if (!texture_composites)
        I_Error("R_CacheTextureCompositePatchNum: Composite patches not initialized");

    if (!texture_composites[id].data)
        createTextureCompositePatch(id);

    // cph - if wasn't locked but now is, tell z_zone to hold it
    if (!texture_composites[id].locks)
        Z_ChangeTag(texture_composites[id].data, PU_STATIC);
    texture_composites[id].locks++;

    return &texture_composites[id];
}
示例#24
0
void W_UnlockLumpNum(int lump) {
  if (cachelump[lump].locks == -1)
    return; // this lump is memory mapped

#ifdef SIMPLECHECKS
  if (cachelump[lump].locks == 0)
    lprintf(LO_DEBUG, "W_UnlockLumpNum: Excess unlocks on %8s\n",
      lumpinfo[lump].name);
#endif
  cachelump[lump].locks -= 1;
  /* cph - Note: must only tell z_zone to make purgeable if currently locked,
   * else it might already have been purged
   */
  if (cachelump[lump].locks == 0)
    Z_ChangeTag(cachelump[lump].cache, PU_CACHE);
}
示例#25
0
// When a sound stops, check if it is still playing. If it is not,
// we can mark the sound data as CACHE to be freed back for other
// means.
static void ReleaseSoundOnChannel(int channel)
{
    int         i;
    int         id = channels_playing[channel];

    if (!id)
        return;

    channels_playing[channel] = sfx_None;

    for (i = 0; i < NUM_CHANNELS; ++i)
        // Playing on this channel? if so, don't release.
        if (channels_playing[i] == id)
            return;

    // Not used on any channel, and can be safely released
    Z_ChangeTag(sound_chunks[id].abuf, PU_CACHE);
}
示例#26
0
//
// W_CachePatch
//
// [SL] Reads and caches a patch from disk. This takes care of converting the
// patch from the standard Doom format of posts with 1-byte lengths and offsets
// to a new format for posts that uses 2-byte lengths and offsets.
//
patch_t* W_CachePatch(unsigned lumpnum, int tag)
{
	if (lumpnum >= numlumps)
		I_Error ("W_CachePatch: %u >= numlumps", lumpnum);

	if (!lumpcache[lumpnum])
	{
		// temporary storage of the raw patch in the old format
		byte *rawlumpdata = new byte[W_LumpLength(lumpnum)];

		W_ReadLump(lumpnum, rawlumpdata);
		patch_t *rawpatch = (patch_t*)(rawlumpdata);

		size_t newlumplen = R_CalculateNewPatchSize(rawpatch, W_LumpLength(lumpnum));

		if (newlumplen > 0)
		{
			// valid patch
			byte *ptr = (byte *)Z_Malloc(newlumplen + 1, tag, &lumpcache[lumpnum]);
			patch_t *newpatch = (patch_t*)lumpcache[lumpnum];

			R_ConvertPatch(newpatch, rawpatch);
			ptr[newlumplen] = 0;
		}
		else
		{
			// invalid patch - just create a header with width = 0, height = 0
			Z_Malloc(sizeof(patch_t) + 1, tag, &lumpcache[lumpnum]);
			memset(lumpcache[lumpnum], 0, sizeof(patch_t) + 1);
		}

		delete [] rawlumpdata;
	}
	else
	{
		Z_ChangeTag(lumpcache[lumpnum], tag);
	}

	// denis - todo - would be good to check whether the patch violates W_LumpLength here
	// denis - todo - would be good to check for width/height == 0 here, and maybe replace those with a valid patch

	return (patch_t*)lumpcache[lumpnum];
}
示例#27
0
void IN_UnloadPics(void)
{
	int i;

	if(patchINTERPIC)
	{
		Z_ChangeTag(patchINTERPIC, PU_CACHE);
	}
	Z_ChangeTag(patchBEENTHERE, PU_CACHE);
	Z_ChangeTag(patchGOINGTHERE, PU_CACHE);
	for(i=0; i<10; i++)
	{
		Z_ChangeTag(FontBNumbers[i], PU_CACHE);
	}
	Z_ChangeTag(FontBNegative, PU_CACHE);
	Z_ChangeTag(FontBSlash, PU_CACHE);
	Z_ChangeTag(FontBPercent, PU_CACHE);
}
示例#28
0
文件: w_wad.c 项目: derek57/research
void W_ReleaseLumpNum(lumpindex_t lumpnum)
{
    lumpinfo_t *lump;

    if ((unsigned)lumpnum >= numlumps)
    {
	I_Error ("W_ReleaseLumpNum: %i >= numlumps", lumpnum);
    }

    lump = lumpinfo[lumpnum];

    if (lump->wad_file->mapped != NULL)
    {
        // Memory-mapped file, so nothing needs to be done here.
    }
    else
    {
        Z_ChangeTag(lump->cache, PU_CACHE);
    }
}
示例#29
0
//
// ZoneObject::changeTag
//
// If the object was allocated on the zone heap, the allocation tag will be
// changed.
//
void ZoneObject::changeTag(int tag)
{
   if(zonealloc) // If not a zone object, this is a no-op
   {
      int curtag = getZoneTag();

      // not actually changing?
      if(tag == curtag)
         return;

      // remove from current tag list, if in one
      removeFromTagList();

      // put it in the new list
      addToTagList(tag);

      // change the actual allocation tag
      Z_ChangeTag(zonealloc, tag);
   }
}
示例#30
0
static bool CachePCSLump(sfxinfo_t *sfx)
{
   int lumpnum;
   int lumplen;
   int headerlen;
   
   // Free the current sound lump back to the cache   
   if(current_sound_lump != NULL)
   {
      Z_ChangeTag(current_sound_lump, PU_CACHE);
      current_sound_lump = NULL;
   }
   
   // Load from WAD
   
   // haleyjd: check for validity
   if((lumpnum = I_PCSGetSfxLumpNum(sfx)) == -1)
      return false;

   current_sound_lump = (Uint8 *)(wGlobalDir.cacheLumpNum(lumpnum, PU_STATIC));
   lumplen            = W_LumpLength(lumpnum);
   
   // Read header   

   if(current_sound_lump[0] != 0x00 || current_sound_lump[1] != 0x00)
      return false;
   
   headerlen = (current_sound_lump[3] << 8) | current_sound_lump[2];
   
   if(headerlen > lumplen - 4)
      return false;
   
   // Header checks out ok   
   current_sound_remaining = headerlen;
   current_sound_pos       = current_sound_lump + 4;
   current_sound_lump_num  = lumpnum;
   
   return true;
}