亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? w_wad.c

?? 游戲類程序源代碼---WinDoom 3D源程序.zip
?? C
字號:
// Emacs style mode select   -*- C++ -*- 
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// $Log:$
//
// DESCRIPTION:
//	Handles WAD file header, directory, lump I/O.
//
//-----------------------------------------------------------------------------


static const char
rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";


#ifdef NORMALUNIX
#include <ctype.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <alloca.h>
#define O_BINARY		0
#else
   #include <stdio.h>
   #include <stdlib.h>
   #include <io.h>
   #include <malloc.h>
   #include <string.h>
   #include <sys/types.h>
   #include <sys/stat.h>
   #include <fcntl.h>
#endif

#include "doomtype.h"
#include "m_swap.h"
#include "i_system.h"
#include "z_zone.h"

#ifdef __GNUG__
#pragma implementation "w_wad.h"
#endif
#include "w_wad.h"


char MsgText[256];
void WriteDebug(char *);



//
// GLOBALS
//

// Location of each lump on disk.
lumpinfo_t*		lumpinfo;		
int			numlumps;

void**			lumpcache;


//#define strcmpi	strcasecmp // This is a redefinition of a standard 'C' function -- not necessary...

//void strupr (char* s)
//{
//    while (*s) { *s = toupper(*s); s++; }
//}

/* This is a redefinition of a standard 'C' function -- not necessary...
int filelength (int handle) 
{ 
    struct stat	fileinfo;
    
    if (fstat (handle,&fileinfo) == -1)
	I_Error ("Error fstating");

    return fileinfo.st_size;
}
*/

void
ExtractFileBase
( char*		path,
  char*		dest )
{
    char*	src;
    int		length;

    src = path + strlen(path) - 1;
    
    // back up until a \ or the start
    while (src != path
	   && *(src-1) != '\\'
	   && *(src-1) != '/')
    {
	src--;
    }
    
    // copy up to eight characters
    memset (dest,0,8);
    length = 0;
    
    while (*src && *src != '.')
    {
	if (++length == 9)
	    I_Error ("Filename base of %s >8 chars",path);

	*dest++ = toupper((int)*src++);
    }
}





//
// LUMP BASED ROUTINES.
//

//
// W_AddFile
// All files are optional, but at least one file must be
//  found (PWAD, if all required lumps are present).
// Files with a .wad extension are wadlink files
//  with multiple lumps.
// Other files are single lumps with the base filename
//  for the lump name.
//
// If filename starts with a tilde, the file is handled
//  specially to allow map reloads.
// But: the reload feature is a fragile hack...

int			reloadlump;
char*			reloadname;


void W_AddFile (char *filename)
{
    wadinfo_t		header;
    lumpinfo_t*		lump_p;
    unsigned		i;
    int			handle;
    int			length;
    int			startlump;
    filelump_t*		fileinfo;
    filelump_t		singleinfo;
    int			storehandle;
    
    // open the file and add to directory

    // handle reload indicator.
    if (filename[0] == '~')
    {
	filename++;
	reloadname = filename;
	reloadlump = numlumps;
    }
		
    if ( (handle = open (filename,O_RDONLY | O_BINARY)) == -1)
    {
	printf (" couldn't open %s\n",filename);
	return;
    }

    sprintf (MsgText," adding %s\n",filename);
    WriteDebug(MsgText);
    startlump = numlumps;
	
    if (strcmpi (filename+strlen(filename)-3 , "wad" ) )
    {
	// single lump file
	fileinfo = &singleinfo;
	singleinfo.filepos = 0;
	singleinfo.size = LONG(filelength(handle));
	ExtractFileBase (filename, singleinfo.name);
	numlumps++;
    }
    else 
    {
	// WAD file
	read (handle, &header, sizeof(header));
	if (strncmp(header.identification,"IWAD",4))
	{
	    // Homebrew levels?
	    if (strncmp(header.identification,"PWAD",4))
	    {
		I_Error ("Wad file %s doesn't have IWAD "
			 "or PWAD id\n", filename);
	    }
	    
	    // ???modifiedgame = true;		
	}
	header.numlumps = LONG(header.numlumps);
	header.infotableofs = LONG(header.infotableofs);
	length = header.numlumps*sizeof(filelump_t);
	fileinfo = alloca (length);
	lseek (handle, header.infotableofs, SEEK_SET);
	read (handle, fileinfo, length);
	numlumps += header.numlumps;
    }

    
    // Fill in lumpinfo
    lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));

    if (!lumpinfo)
	I_Error ("Couldn't realloc lumpinfo");

    lump_p = &lumpinfo[startlump];
	
    storehandle = reloadname ? -1 : handle;
	
    for (i=startlump ; (int)i<numlumps ; i++,lump_p++, fileinfo++)
    {
	lump_p->handle = storehandle;
	lump_p->position = LONG(fileinfo->filepos);
	lump_p->size = LONG(fileinfo->size);
	strncpy (lump_p->name, fileinfo->name, 8);
    }
	
    if (reloadname)
	close (handle);
}




//
// W_Reload
// Flushes any of the reloadable lumps in memory
//  and reloads the directory.
//
void W_Reload (void)
{
    wadinfo_t		header;
    int			lumpcount;
    lumpinfo_t*		lump_p;
    unsigned		i;
    int			handle;
    int			length;
    filelump_t*		fileinfo;
	
    if (!reloadname)
	return;
		
    if ( (handle = open (reloadname,O_RDONLY | O_BINARY)) == -1)
	I_Error ("W_Reload: couldn't open %s",reloadname);

    read (handle, &header, sizeof(header));
    lumpcount = LONG(header.numlumps);
    header.infotableofs = LONG(header.infotableofs);
    length = lumpcount*sizeof(filelump_t);
    fileinfo = alloca (length);
    lseek (handle, header.infotableofs, SEEK_SET);
    read (handle, fileinfo, length);
    
    // Fill in lumpinfo
    lump_p = &lumpinfo[reloadlump];
	
    for (i=reloadlump ;
	 (int)i<reloadlump+lumpcount ;
	 i++,lump_p++, fileinfo++)
    {
	if (lumpcache[i])
	    Z_Free (lumpcache[i]);

	lump_p->position = LONG(fileinfo->filepos);
	lump_p->size = LONG(fileinfo->size);
    }
	
    close (handle);
}



//
// W_InitMultipleFiles
// Pass a null terminated list of files to use.
// All files are optional, but at least one file
//  must be found.
// Files with a .wad extension are idlink files
//  with multiple lumps.
// Other files are single lumps with the base filename
//  for the lump name.
// Lump names can appear multiple times.
// The name searcher looks backwards, so a later file
//  does override all earlier ones.
//
void W_InitMultipleFiles (char** filenames)
{	
    int		size;
    
    // open all the files, load headers, and count lumps
    numlumps = 0;

    // will be realloced as lumps are added
    lumpinfo = malloc(1);	

    for ( ; *filenames ; filenames++)
	W_AddFile (*filenames);

    if (!numlumps)
	I_Error ("W_InitFiles: no files found");
    
    // set up caching
    size = numlumps * sizeof(*lumpcache);
    lumpcache = malloc (size);
    
    if (!lumpcache)
	I_Error ("Couldn't allocate lumpcache");

    memset (lumpcache,0, size);
}




//
// W_InitFile
// Just initialize from a single file.
//
void W_InitFile (char* filename)
{
    char*	names[2];

    names[0] = filename;
    names[1] = NULL;
    W_InitMultipleFiles (names);
}



//
// W_NumLumps
//
int W_NumLumps (void)
{
    return numlumps;
}



//
// W_CheckNumForName
// Returns -1 if name not found.
//

int W_CheckNumForName (char* name)
{
    union {
	char	s[9];
	int	x[2];
	
    } name8;
    
    int		v1;
    int		v2;
    lumpinfo_t*	lump_p;

    // make the name into two integers for easy compares
    strncpy (name8.s,name,8);

    // in case the name was a full 8 chars
    name8.s[8] = 0;

    // case insensitive
    strupr (name8.s);		

    v1 = name8.x[0];
    v2 = name8.x[1];


    // scan backwards so patch lump files take precedence
    lump_p = lumpinfo + numlumps;

    while (lump_p-- != lumpinfo)
    {
	if ( *(int *)lump_p->name == v1
	     && *(int *)&lump_p->name[4] == v2)
	{
	    return lump_p - lumpinfo;
	}
    }

    // TFB. Not found.
    return -1;
}




//
// W_GetNumForName
// Calls W_CheckNumForName, but bombs out if not found.
//
int W_GetNumForName (char* name)
{
    int	i;

    i = W_CheckNumForName (name);
    
    if (i == -1)
      I_Error ("W_GetNumForName: %s not found!", name);
      
    return i;
}


//
// W_LumpLength
// Returns the buffer size needed to load the given lump.
//
int W_LumpLength (int lump)
{
    if (lump >= numlumps)
	I_Error ("W_LumpLength: %i >= numlumps",lump);

    return lumpinfo[lump].size;
}



//
// W_ReadLump
// Loads the lump into the given buffer,
//  which must be >= W_LumpLength().
//
void
W_ReadLump
( int		lump,
  void*		dest )
{
    int		c;
    lumpinfo_t*	l;
    int		handle;
	
    if (lump >= numlumps)
	I_Error ("W_ReadLump: %i >= numlumps",lump);

    l = lumpinfo+lump;
	
    // ??? I_BeginRead ();
	
    if (l->handle == -1)
    {
	// reloadable file, so use open / read / close
	if ( (handle = open (reloadname,O_RDONLY | O_BINARY)) == -1)
	    I_Error ("W_ReadLump: couldn't open %s",reloadname);
    }
    else
	handle = l->handle;
		
    lseek (handle, l->position, SEEK_SET);
    c = read (handle, dest, l->size);

    if (c < l->size)
	I_Error ("W_ReadLump: only read %i of %i on lump %i",
		 c,l->size,lump);	

    if (l->handle == -1)
	close (handle);
		
    // ??? I_EndRead ();
}




//
// W_CacheLumpNum
//
void*
W_CacheLumpNum
( int		lump,
  int		tag )
{
    byte*	ptr;

    if ((unsigned)lump >= (unsigned)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];
}



//
// W_CacheLumpName
//
void*
W_CacheLumpName
( char*		name,
  int		tag )
{
 int LumpNum;

 LumpNum = W_GetNumForName(name);
 if (LumpNum >= 0)
    return W_CacheLumpNum(LumpNum, tag);
 else
    return NULL;
}


//
// W_Profile
//
int		info[2500][10];
int		profilecount;

void W_Profile (void)
{
    int		i;
    memblock_t*	block;
    void*	ptr;
    char	ch;
    FILE*	f;
    int		j;
    char	name[9];
	
	
    for (i=0 ; i<numlumps ; i++)
    {	
	ptr = lumpcache[i];
	if (!ptr)
	{
	    ch = ' ';
	    continue;
	}
	else
	{
	    block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
	    if (block->tag < PU_PURGELEVEL)
		ch = 'S';
	    else
		ch = 'P';
	}
	info[i][profilecount] = ch;
    }
    profilecount++;
	
    f = fopen ("waddump.txt","w");
    name[8] = 0;

    for (i=0 ; i<numlumps ; i++)
    {
	memcpy (name,lumpinfo[i].name,8);

	for (j=0 ; j<8 ; j++)
	    if (!name[j])
		break;

	for ( ; j<8 ; j++)
	    name[j] = ' ';

	fprintf (f,"%s ",name);

	for (j=0 ; j<profilecount ; j++)
	    fprintf (f,"    %c",info[i][j]);

	fprintf (f,"\n");
    }
    fclose (f);
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
风间由美一区二区av101| 91香蕉国产在线观看软件| 国产拍揄自揄精品视频麻豆| 91蜜桃免费观看视频| 精品一区精品二区高清| 日韩理论片一区二区| 精品国产污污免费网站入口 | 国产精品高清亚洲| 91精品国产综合久久精品麻豆| 成人精品一区二区三区四区| 日韩精品电影在线观看| 亚洲人吸女人奶水| 26uuu欧美| 制服丝袜成人动漫| 欧美在线观看视频在线| av电影在线观看不卡| 国产一区二区三区四区五区美女 | 欧美无砖专区一中文字| 风间由美一区二区av101| 蜜臀精品一区二区三区在线观看| 亚洲日本va午夜在线电影| 国产亚洲精品超碰| 26uuu国产在线精品一区二区| 欧美日韩在线播放三区四区| 91美女片黄在线观看| 国产成人久久精品77777最新版本| 蜜臀久久久久久久| 日韩主播视频在线| 亚洲午夜一二三区视频| 一区二区三区四区视频精品免费| 国产一区三区三区| 老司机一区二区| 天天色综合成人网| 亚洲免费色视频| 国产精品久久久久久亚洲伦 | www.在线欧美| 国产91精品久久久久久久网曝门| 激情小说亚洲一区| 狠狠色丁香婷婷综合久久片| 久久91精品久久久久久秒播| 蜜臀va亚洲va欧美va天堂| 日韩国产一区二| 青青草国产精品97视觉盛宴| 香蕉加勒比综合久久| 日日夜夜精品视频免费| 日韩影院免费视频| 日本大胆欧美人术艺术动态 | 国产成人精品一区二区三区网站观看| 黄色小说综合网站| 丁香啪啪综合成人亚洲小说| 成人免费视频网站在线观看| 91猫先生在线| 欧美在线影院一区二区| 欧美日本在线播放| 日韩一区二区免费高清| 精品久久久久久久久久久久包黑料 | 九一九一国产精品| 国产乱码精品一区二区三区av | 国产一区二区三区四区五区美女| 国产成人免费在线视频| 懂色av一区二区三区免费观看| 国产不卡视频在线观看| 色婷婷综合五月| 欧美另类一区二区三区| 日韩欧美一二区| 国产女主播视频一区二区| 亚洲色图视频网| 香蕉av福利精品导航| 久久99精品久久久| 成人在线综合网| 欧美综合一区二区三区| 欧美一区二区啪啪| 久久精品亚洲一区二区三区浴池| 国产精品护士白丝一区av| 亚洲国产精品久久久久婷婷884| 麻豆成人av在线| 成人高清免费观看| 欧美日韩国产高清一区二区| 久久综合九色综合欧美就去吻| 亚洲人午夜精品天堂一二香蕉| 丝袜国产日韩另类美女| 国产成人自拍在线| 色94色欧美sute亚洲线路一ni | 老司机精品视频一区二区三区| 粉嫩aⅴ一区二区三区四区| 91国产免费观看| 久久综合久久综合亚洲| 亚洲精品免费在线播放| 久久激情综合网| 色综合天天在线| 久久色在线观看| 亚洲国产精品麻豆| 成人免费视频caoporn| 日韩一区二区三区av| 亚洲美腿欧美偷拍| 国产呦精品一区二区三区网站| 欧美主播一区二区三区| 国产精品午夜久久| 麻豆国产精品777777在线| 在线观看av一区| 亚洲国产精品黑人久久久| 日本午夜一区二区| 在线欧美小视频| 一区精品在线播放| 国产精品一区二区在线观看网站| 欧美电影一区二区| 亚洲男人都懂的| 成人禁用看黄a在线| 欧美电视剧在线观看完整版| 一区二区成人在线| 91在线视频免费91| 日本一区二区视频在线| 精品一区二区三区视频| 91精品国产综合久久小美女| 一级女性全黄久久生活片免费| 国产69精品久久久久毛片| 日韩女优毛片在线| 日日夜夜精品视频天天综合网| 色婷婷av一区二区| 国产精品久久久久久久第一福利| 国产乱妇无码大片在线观看| 欧美成人免费网站| 视频一区二区三区入口| 欧美日韩国产乱码电影| 亚洲成人在线网站| 在线视频国内一区二区| 亚洲精品五月天| 91在线码无精品| 成人免费在线播放视频| 99麻豆久久久国产精品免费| 国产欧美一区视频| 国产精品69毛片高清亚洲| 日韩一区二区三区视频在线| 奇米四色…亚洲| 欧美一区二区久久| 男女激情视频一区| 欧美va亚洲va| 国产在线一区观看| 国产午夜精品久久久久久久| 国产一区二区按摩在线观看| 2021久久国产精品不只是精品| 美女任你摸久久| 成人免费va视频| 精品国产制服丝袜高跟| 麻豆精品久久久| 久久久久国产精品麻豆| 国产精品亚洲专一区二区三区| 精品成人a区在线观看| 国产精品夜夜嗨| 国产精品三级av| 日本电影欧美片| 亚洲国产一区二区视频| 91精品婷婷国产综合久久性色| 美女在线观看视频一区二区| 久久久久久久久久久99999| 国产一区美女在线| 国产精品国产三级国产三级人妇 | 欧美日韩综合色| 蜜乳av一区二区| 国产日产精品一区| 99精品1区2区| 天堂一区二区在线| www成人在线观看| 成人18视频在线播放| 亚洲综合色婷婷| 欧美一区二区三区视频| 国产黄色精品视频| 亚洲美女视频在线| 日韩欧美三级在线| jlzzjlzz亚洲女人18| 亚洲国产另类av| 国产亚洲制服色| 在线免费观看一区| 精品一区二区在线视频| 亚洲视频一区在线观看| 日韩视频不卡中文| 99综合电影在线视频| 五月激情综合婷婷| 国产午夜精品久久久久久免费视 | 日韩av电影免费观看高清完整版| 久久色.com| 欧美日韩一区二区三区在线看| 麻豆成人久久精品二区三区小说| 国产精品久久久久久久浪潮网站| 欧美影院精品一区| 国产一区福利在线| 亚洲成人av在线电影| 久久久激情视频| 欧美日韩国产一区二区三区地区| 国产一区啦啦啦在线观看| 亚洲影院理伦片| 国产精品丝袜久久久久久app| 欧美性猛片aaaaaaa做受| 国产精品一二三四五| 午夜av区久久| 亚洲日本欧美天堂| 国产午夜亚洲精品羞羞网站| 9191精品国产综合久久久久久| 北条麻妃国产九九精品视频| 美女尤物国产一区|