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

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

?? files.c

?? 著名游戲quake2原代碼最新版本(vc6.0可以編譯的)
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

#include "qcommon.h"

// define this to dissalow any data but the demo pak file
//#define	NO_ADDONS

// if a packfile directory differs from this, it is assumed to be hacked
// Full version
#define	PAK0_CHECKSUM	0x40e614e0
// Demo
//#define	PAK0_CHECKSUM	0xb2c6d7ea
// OEM
//#define	PAK0_CHECKSUM	0x78e135c

/*
=============================================================================

QUAKE FILESYSTEM

=============================================================================
*/


//
// in memory
//

typedef struct
{
	char	name[MAX_QPATH];
	int		filepos, filelen;
} packfile_t;

typedef struct pack_s
{
	char	filename[MAX_OSPATH];
	FILE	*handle;
	int		numfiles;
	packfile_t	*files;
} pack_t;

char	fs_gamedir[MAX_OSPATH];
cvar_t	*fs_basedir;
cvar_t	*fs_cddir;
cvar_t	*fs_gamedirvar;

typedef struct filelink_s
{
	struct filelink_s	*next;
	char	*from;
	int		fromlength;
	char	*to;
} filelink_t;

filelink_t	*fs_links;

typedef struct searchpath_s
{
	char	filename[MAX_OSPATH];
	pack_t	*pack;		// only one of filename / pack will be used
	struct searchpath_s *next;
} searchpath_t;

searchpath_t	*fs_searchpaths;
searchpath_t	*fs_base_searchpaths;	// without gamedirs


/*

All of Quake's data access is through a hierchal file system, but the contents of the file system can be transparently merged from several sources.

The "base directory" is the path to the directory holding the quake.exe and all game directories.  The sys_* files pass this to host_init in quakeparms_t->basedir.  This can be overridden with the "-basedir" command line parm to allow code debugging in a different directory.  The base directory is
only used during filesystem initialization.

The "game directory" is the first tree on the search path and directory that all generated files (savegames, screenshots, demos, config files) will be saved to.  This can be overridden with the "-game" command line parameter.  The game directory can never be changed while quake is executing.  This is a precacution against having a malicious server instruct clients to write files over areas they shouldn't.

*/


/*
================
FS_filelength
================
*/
int FS_filelength (FILE *f)
{
	int		pos;
	int		end;

	pos = ftell (f);
	fseek (f, 0, SEEK_END);
	end = ftell (f);
	fseek (f, pos, SEEK_SET);

	return end;
}


/*
============
FS_CreatePath

Creates any directories needed to store the given filename
============
*/
void	FS_CreatePath (char *path)
{
	char	*ofs;
	
	for (ofs = path+1 ; *ofs ; ofs++)
	{
		if (*ofs == '/')
		{	// create the directory
			*ofs = 0;
			Sys_Mkdir (path);
			*ofs = '/';
		}
	}
}


/*
==============
FS_FCloseFile

For some reason, other dll's can't just cal fclose()
on files returned by FS_FOpenFile...
==============
*/
void FS_FCloseFile (FILE *f)
{
	fclose (f);
}


// RAFAEL
/*
	Developer_searchpath
*/
int	Developer_searchpath (int who)
{
	
	int		ch;
	// PMM - warning removal
//	char	*start;
	searchpath_t	*search;
	
	if (who == 1) // xatrix
		ch = 'x';
	else if (who == 2)
		ch = 'r';

	for (search = fs_searchpaths ; search ; search = search->next)
	{
		if (strstr (search->filename, "xatrix"))
			return 1;

		if (strstr (search->filename, "rogue"))
			return 2;
/*
		start = strchr (search->filename, ch);

		if (start == NULL)
			continue;

		if (strcmp (start ,"xatrix") == 0)
			return (1);
*/
	}
	return (0);

}


/*
===========
FS_FOpenFile

Finds the file in the search path.
returns filesize and an open FILE *
Used for streaming data out of either a pak file or
a seperate file.
===========
*/
int file_from_pak = 0;
#ifndef NO_ADDONS
int FS_FOpenFile (char *filename, FILE **file)
{
	searchpath_t	*search;
	char			netpath[MAX_OSPATH];
	pack_t			*pak;
	int				i;
	filelink_t		*link;

	file_from_pak = 0;

	// check for links first
	for (link = fs_links ; link ; link=link->next)
	{
		if (!strncmp (filename, link->from, link->fromlength))
		{
			Com_sprintf (netpath, sizeof(netpath), "%s%s",link->to, filename+link->fromlength);
			*file = fopen (netpath, "rb");
			if (*file)
			{		
				Com_DPrintf ("link file: %s\n",netpath);
				return FS_filelength (*file);
			}
			return -1;
		}
	}

//
// search through the path, one element at a time
//
	for (search = fs_searchpaths ; search ; search = search->next)
	{
	// is the element a pak file?
		if (search->pack)
		{
		// look through all the pak file elements
			pak = search->pack;
			for (i=0 ; i<pak->numfiles ; i++)
				if (!Q_strcasecmp (pak->files[i].name, filename))
				{	// found it!
					file_from_pak = 1;
					Com_DPrintf ("PackFile: %s : %s\n",pak->filename, filename);
				// open a new file on the pakfile
					*file = fopen (pak->filename, "rb");
					if (!*file)
						Com_Error (ERR_FATAL, "Couldn't reopen %s", pak->filename);	
					fseek (*file, pak->files[i].filepos, SEEK_SET);
					return pak->files[i].filelen;
				}
		}
		else
		{		
	// check a file in the directory tree
			
			Com_sprintf (netpath, sizeof(netpath), "%s/%s",search->filename, filename);
			
			*file = fopen (netpath, "rb");
			if (!*file)
				continue;
			
			Com_DPrintf ("FindFile: %s\n",netpath);

			return FS_filelength (*file);
		}
		
	}
	
	Com_DPrintf ("FindFile: can't find %s\n", filename);
	
	*file = NULL;
	return -1;
}

#else

// this is just for demos to prevent add on hacking

int FS_FOpenFile (char *filename, FILE **file)
{
	searchpath_t	*search;
	char			netpath[MAX_OSPATH];
	pack_t			*pak;
	int				i;

	file_from_pak = 0;

	// get config from directory, everything else from pak
	if (!strcmp(filename, "config.cfg") || !strncmp(filename, "players/", 8))
	{
		Com_sprintf (netpath, sizeof(netpath), "%s/%s",FS_Gamedir(), filename);
		
		*file = fopen (netpath, "rb");
		if (!*file)
			return -1;
		
		Com_DPrintf ("FindFile: %s\n",netpath);

		return FS_filelength (*file);
	}

	for (search = fs_searchpaths ; search ; search = search->next)
		if (search->pack)
			break;
	if (!search)
	{
		*file = NULL;
		return -1;
	}

	pak = search->pack;
	for (i=0 ; i<pak->numfiles ; i++)
		if (!Q_strcasecmp (pak->files[i].name, filename))
		{	// found it!
			file_from_pak = 1;
			Com_DPrintf ("PackFile: %s : %s\n",pak->filename, filename);
		// open a new file on the pakfile
			*file = fopen (pak->filename, "rb");
			if (!*file)
				Com_Error (ERR_FATAL, "Couldn't reopen %s", pak->filename);	
			fseek (*file, pak->files[i].filepos, SEEK_SET);
			return pak->files[i].filelen;
		}
	
	Com_DPrintf ("FindFile: can't find %s\n", filename);
	
	*file = NULL;
	return -1;
}

#endif


/*
=================
FS_ReadFile

Properly handles partial reads
=================
*/
void CDAudio_Stop(void);
#define	MAX_READ	0x10000		// read in blocks of 64k
void FS_Read (void *buffer, int len, FILE *f)
{
	int		block, remaining;
	int		read;
	byte	*buf;
	int		tries;

	buf = (byte *)buffer;

	// read in chunks for progress bar
	remaining = len;
	tries = 0;
	while (remaining)
	{
		block = remaining;
		if (block > MAX_READ)
			block = MAX_READ;
		read = fread (buf, 1, block, f);
		if (read == 0)
		{
			// we might have been trying to read from a CD
			if (!tries)
			{
				tries = 1;
				CDAudio_Stop();
			}
			else
				Com_Error (ERR_FATAL, "FS_Read: 0 bytes read");
		}

		if (read == -1)
			Com_Error (ERR_FATAL, "FS_Read: -1 bytes read");

		// do some progress bar thing here...

		remaining -= read;
		buf += read;
	}
}

/*
============
FS_LoadFile

Filename are reletive to the quake search path
a null buffer will just return the file length without loading
============
*/
int FS_LoadFile (char *path, void **buffer)
{
	FILE	*h;
	byte	*buf;
	int		len;

	buf = NULL;	// quiet compiler warning

// look for it in the filesystem or pack files
	len = FS_FOpenFile (path, &h);
	if (!h)
	{
		if (buffer)
			*buffer = NULL;
		return -1;
	}
	
	if (!buffer)
	{
		fclose (h);
		return len;
	}

	buf = Z_Malloc(len);
	*buffer = buf;

	FS_Read (buf, len, h);

	fclose (h);

	return len;
}


/*
=============
FS_FreeFile
=============
*/
void FS_FreeFile (void *buffer)
{
	Z_Free (buffer);
}

/*
=================
FS_LoadPackFile

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av中文字幕一区| 裸体在线国模精品偷拍| 久久欧美中文字幕| 日韩精品综合一本久道在线视频| 欧美性受极品xxxx喷水| 91亚洲精品乱码久久久久久蜜桃| 99久久精品国产一区| 色狠狠色狠狠综合| 一本色道久久综合亚洲aⅴ蜜桃 | 色婷婷国产精品| 成人黄动漫网站免费app| 丁香亚洲综合激情啪啪综合| 国产 欧美在线| 色老综合老女人久久久| 欧美日韩二区三区| 欧美大白屁股肥臀xxxxxx| 日韩美女视频在线| 国产午夜精品一区二区| 成人欧美一区二区三区1314| 亚洲精品国产高清久久伦理二区| 性感美女久久精品| 国内不卡的二区三区中文字幕| 福利一区二区在线观看| 日韩色视频在线观看| 久久久不卡网国产精品二区| 亚洲天堂av老司机| 日本欧美加勒比视频| 粉嫩高潮美女一区二区三区| 欧美性感一区二区三区| 久久色成人在线| 亚洲综合视频在线观看| 国产综合色在线视频区| 色综合天天综合网国产成人综合天 | 欧美三区在线视频| 久久日一线二线三线suv| 亚洲欧洲综合另类在线| 麻豆国产精品一区二区三区| 色综合网色综合| 精品播放一区二区| 亚洲午夜在线视频| 成人免费观看男女羞羞视频| 在线播放中文字幕一区| 中文字幕一区二区5566日韩| 日韩激情av在线| 日韩一二三区视频| 自拍视频在线观看一区二区| 久久99精品久久久久久动态图 | 成人综合在线网站| 911精品国产一区二区在线| 亚洲欧洲日韩在线| 国产一区二区在线观看免费| 欧美综合一区二区三区| 国产精品国产自产拍高清av| 麻豆精品久久精品色综合| 色视频欧美一区二区三区| 精品对白一区国产伦| 日韩成人一区二区| 欧美三级韩国三级日本三斤 | 欧美日韩午夜在线| 亚洲男人都懂的| av在线不卡电影| 久久精品视频免费| 精品一区二区精品| 日韩美女视频一区二区在线观看| 亚洲国产色一区| 色婷婷狠狠综合| 亚洲欧洲av在线| 成人看片黄a免费看在线| 国产日韩欧美a| 国产精品一卡二卡在线观看| 欧美电视剧在线观看完整版| 日韩高清在线观看| 制服丝袜av成人在线看| 成人性生交大片免费看在线播放 | 亚洲第一在线综合网站| 欧美色精品天天在线观看视频| 亚洲女女做受ⅹxx高潮| 一本色道亚洲精品aⅴ| 亚洲图片另类小说| 色8久久人人97超碰香蕉987| 一区二区在线观看不卡| 91色视频在线| 亚洲成av人片www| 91精品国产综合久久国产大片| 日本不卡高清视频| 日韩精品一区二区三区视频播放 | 9191国产精品| 免费美女久久99| 欧美成人a在线| 国产v日产∨综合v精品视频| 国产精品久久久久aaaa樱花| 一本色道久久综合亚洲aⅴ蜜桃 | 69久久99精品久久久久婷婷| 蜜桃久久久久久| 欧美激情综合在线| 91视频免费播放| 日本欧美韩国一区三区| 国产午夜精品理论片a级大结局| 高清国产一区二区| 亚洲成在人线免费| ww亚洲ww在线观看国产| 972aa.com艺术欧美| 日本视频免费一区| 国产精品全国免费观看高清| 欧美无砖砖区免费| 国产一区在线看| 亚洲综合免费观看高清在线观看| 日韩欧美中文一区| 91网址在线看| 韩国精品在线观看| 一区二区三区av电影 | 国产成人午夜精品5599| 一区二区三区色| 欧美电影免费提供在线观看| 91啪亚洲精品| 精品一区二区三区免费观看| 国产精品成人一区二区艾草| 欧美午夜影院一区| 福利电影一区二区三区| 日韩高清不卡在线| 亚洲欧美乱综合| 亚洲国产经典视频| 精品国产一区a| 欧美精品乱码久久久久久按摩| 欧美亚洲一区二区三区四区| 国产美女视频91| 五月天国产精品| 亚洲免费av高清| 国产欧美日韩另类视频免费观看 | 国产高清精品网站| 日日夜夜精品视频天天综合网| 国产精品水嫩水嫩| 精品国产三级a在线观看| 欧美美女视频在线观看| 色猫猫国产区一区二在线视频| 国产91在线观看| 国产精品小仙女| 精品一区免费av| 轻轻草成人在线| 日韩电影免费在线看| 亚洲成人精品在线观看| 亚洲另类在线一区| 国产精品护士白丝一区av| 国产婷婷色一区二区三区四区 | 亚洲欧美在线高清| 18成人在线观看| 1区2区3区欧美| 亚洲视频在线一区二区| 国产精品久久久久久久久快鸭| 亚洲高清视频在线| 亚洲在线一区二区三区| 一区二区三区四区国产精品| 一区二区视频在线| 亚洲乱码精品一二三四区日韩在线 | 奇米色一区二区| 久久疯狂做爰流白浆xx| 国产一区欧美一区| 丁香六月久久综合狠狠色| 成人毛片视频在线观看| 成人免费视频免费观看| 99精品在线观看视频| 91国产成人在线| 日韩亚洲欧美综合| wwww国产精品欧美| 国产精品剧情在线亚洲| 亚洲精品伦理在线| 亚洲成人av电影在线| 久久99国产精品免费| 国产美女精品在线| fc2成人免费人成在线观看播放| 成人av在线网| 欧美日韩午夜影院| 精品国产制服丝袜高跟| 中文无字幕一区二区三区| 亚洲摸摸操操av| 肉肉av福利一精品导航| 精品午夜久久福利影院| 成人网男人的天堂| 欧美老女人在线| 国产亚洲精品7777| 亚洲黄色性网站| 日本不卡一二三| 99久久er热在这里只有精品15| 欧美午夜在线一二页| 26uuu久久综合| 亚洲一卡二卡三卡四卡无卡久久 | 国产精品亲子伦对白| 一区二区三区四区五区视频在线观看 | 亚洲国产综合在线| 国产精品中文字幕一区二区三区| 99久久久免费精品国产一区二区| 欧美无乱码久久久免费午夜一区| 日韩精品一区二区三区蜜臀| 亚洲色图制服丝袜| 国内外成人在线| 欧美日韩国产123区| 国产精品久久久久久久久久免费看| 日产欧产美韩系列久久99| 成人午夜私人影院| 日韩欧美专区在线|