当前位置: 首页>>代码示例>>C++>>正文


C++ CFile::ReadInt方法代码示例

本文整理汇总了C++中CFile::ReadInt方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::ReadInt方法的具体用法?C++ CFile::ReadInt怎么用?C++ CFile::ReadInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::ReadInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadColor

void ReadColor (CFile& cf, tFaceColor *pc, int bFloatData, int bRegisterColor)
{
pc->index = cf.ReadByte ();
if (bFloatData) {
	tRgbColord	c;
	cf.Read (&c, sizeof (c), 1);
	pc->color.red = (float) c.red;
	pc->color.green = (float) c.green;
	pc->color.blue = (float) c.blue;
	}
else {
	int c = cf.ReadInt ();
	pc->color.red = (float) c / (float) 0x7fffffff;
	c = cf.ReadInt ();
	pc->color.green = (float) c / (float) 0x7fffffff;
	c = cf.ReadInt ();
	pc->color.blue = (float) c / (float) 0x7fffffff;
	}
if (bRegisterColor &&
	 (((pc->color.red > 0) && (pc->color.red < 1)) ||
	 ((pc->color.green > 0) && (pc->color.green < 1)) ||
	 ((pc->color.blue > 0) && (pc->color.blue < 1))))
	gameStates.render.bColored = 1;
pc->color.alpha = 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:25,代码来源:gamemine.cpp

示例2: SetupMVL

int CMovieLib::SetupMVL (CFile& cf)
{
	int			nFiles, offset;
	int			i, len;

	//read movie file header

nFiles = cf.ReadInt ();        //get number of files
if (nFiles > 255) {
	gameStates.app.bLittleEndian = 0;
	nFiles = SWAPINT (nFiles);
	}
if (!m_movies.Create (nFiles))
	return 0;
m_nMovies = nFiles;
offset = 4 + 4 + nFiles * (13 + 4);	//id + nFiles + nFiles * (filename + size)
for (i = 0; i < nFiles; i++) {
	if (cf.Read (m_movies [i].m_name, 13, 1) != 1)
		break;		//end of file (probably)
	len = cf.ReadInt ();
	m_movies [i].m_len = len;
	m_movies [i].m_offset = offset;
	offset += m_movies [i].m_len;
	}
cf.Close ();
m_flags = 0;
return nFiles;
}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:28,代码来源:movie.cpp

示例3: ReadHamFile

int ReadHamFile (bool bDefault)
{
	CFile		cf;
#if 1
	char		szD1PigFileName [FILENAME_LEN];
#endif
	int		nHAMId;
	int		nSoundOffset = 0;
	char		szFile [FILENAME_LEN];
	char*		pszFile, * pszFolder;

if (bDefault) {
	pszFile = DefaultHamFile ();
	pszFolder = gameFolders.szDataDir;
	}
else {
	if (!*gameFolders.szModName)
		return 0;
	sprintf (szFile, "%s.ham", gameFolders.szModName);
	pszFile = szFile;
	pszFolder = gameFolders.szModDir [1];
	}
	
if (!cf.Open (pszFile, pszFolder, "rb", 0)) {
	bMustWriteHamFile = 1;
	return 0;
	}
//make sure ham is valid nType file & is up-to-date
nHAMId = cf.ReadInt ();
gameData.pig.tex.nHamFileVersion = cf.ReadInt ();
if (nHAMId != HAMFILE_ID)
	Error ("Cannot open ham file %s\n", DefaultHamFile ());
if (gameData.pig.tex.nHamFileVersion < 3) // hamfile contains sound info
	nSoundOffset = cf.ReadInt ();
	BMReadAll (cf);
/*---*/PrintLog ("      Loading bitmap index translation table\n");
	gameData.pig.tex.bitmapXlat.Read (cf, MAX_BITMAP_FILES);
if (gameData.pig.tex.nHamFileVersion < 3) {
	cf.Seek (nSoundOffset, SEEK_SET);
	int nSoundNum = cf.ReadInt ();
	int nSoundStart = cf.Tell ();
/*---*/PrintLog ("      Loading %d sounds\n", nSoundNum);
	SetupSounds (cf, nSoundNum, nSoundStart);
	}
cf.Close ();
/*---*/PrintLog ("      Looking for Descent 1 data files\n");
strcpy (szD1PigFileName, "descent.pig");
if (cfPiggy [1].File ())
	cfPiggy [1].Seek (0, SEEK_SET);
else
	cfPiggy [1].Open (szD1PigFileName, gameFolders.szDataDir, "rb", 0);
if (cfPiggy [1].File ()) {
	gameStates.app.bHaveD1Data = 1;
/*---*/PrintLog ("      Loading Descent 1 data\n");
	BMReadGameDataD1 (cfPiggy [1]);
	}
return 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:58,代码来源:piggy.cpp

示例4: PiggyInitPigFile

//------------------------------------------------------------------------------
//initialize a pigfile, reading headers
//returns the size of all the bitmap data
void PiggyInitPigFile (char *filename)
{
	CFile					*cfP = cfPiggy + gameStates.app.bD1Data;
	char					szName [16];
	char					szNameRead [16];
	char					szPigName [FILENAME_LEN];
	int					nHeaderSize, nBitmapNum, nDataSize, nDataStart, i;
	grsBitmap			bmTemp;
	tPIGBitmapHeader	bmh;

PiggyCloseFile ();             //close old pig if still open
strcpy (szPigName, filename);
//rename pigfile for shareware
if (!stricmp (DEFAULT_PIGFILE, DEFAULT_PIGFILE_SHAREWARE) && 
	 !CFile::Exist (szPigName, gameFolders.szDataDir, 0))
	strcpy (szPigName, DEFAULT_PIGFILE_SHAREWARE);
strlwr (szPigName);
if (!cfP->Open (szPigName, gameFolders.szDataDir, "rb", 0)) {
#ifdef EDITOR
	return;         //if editor, ok to not have pig, because we'll build one
#else
	if (!CopyPigFileFromCD (*cfP, szPigName))
		return;
#endif
	}
int pig_id = cfP->ReadInt ();
int pigVersion = cfP->ReadInt ();
if (pig_id != PIGFILE_ID || pigVersion != PIGFILE_VERSION) {
	cfP->Close ();              //out of date pig
	return;
	}
strncpy (szCurrentPigFile [0], szPigName, sizeof (szCurrentPigFile [0]));
nBitmapNum = cfP->ReadInt ();
nHeaderSize = nBitmapNum * sizeof (tPIGBitmapHeader);
nDataStart = nHeaderSize + cfP->Tell ();
nDataSize = cfP->Length () - nDataStart;
gameData.pig.tex.nBitmaps [0] = 1;
for (i = 0; i < nBitmapNum; i++) {
	PIGBitmapHeaderRead (&bmh, *cfP);
	memcpy (szNameRead, bmh.name, 8);
	szNameRead [8] = 0;
	if (bmh.dflags & DBM_FLAG_ABM)        
		sprintf (szName, "%s#%d", szNameRead, bmh.dflags & DBM_NUM_FRAMES);
	else
		strcpy (szName, szNameRead);
	memset (&bmTemp, 0, sizeof (grsBitmap));
	bmTemp.bmProps.w = bmTemp.bmProps.rowSize = bmh.width + ((short) (bmh.wh_extra & 0x0f) << 8);
	bmTemp.bmProps.h = bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4);
	bmTemp.bmProps.flags |= BM_FLAG_PAGED_OUT;
	bmTemp.bmAvgColor = bmh.bmAvgColor;
	gameData.pig.tex.bitmapFlags [0][i+1] = bmh.flags & BM_FLAGS_TO_COPY;
	bitmapOffsets [0][i+1] = bmh.offset + nDataStart;
	Assert ((i+1) == gameData.pig.tex.nBitmaps [0]);
	PiggyRegisterBitmap (&bmTemp, szName, 1);
	}
bPigFileInitialized = 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:60,代码来源:piggy.cpp

示例5: ReadReactor

void ReadReactor (tReactorProps& reactor, CFile& cf)
{
	int i;

reactor.nModel = cf.ReadInt ();
reactor.nGuns = cf.ReadInt ();
for (i = 0; i < MAX_CONTROLCEN_GUNS; i++)
	cf.ReadVector (reactor.gunPoints [i]);
for (i = 0; i < MAX_CONTROLCEN_GUNS; i++)
	cf.ReadVector (reactor.gunDirs [i]);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:11,代码来源:reactor.cpp

示例6: PiggyInitPigFile

//------------------------------------------------------------------------------
//initialize a pigfile, reading headers
//returns the size of all the bitmap data
void PiggyInitPigFile (char *filename)
{
	CFile					*cfP = cfPiggy + gameStates.app.bD1Data;
	char					szName [16];
	char					szNameRead [16];
	char					szPigName [FILENAME_LEN];
	int					nHeaderSize, nBitmapNum, nDataSize, nDataStart, i;
	CBitmap				bm;
	tPIGBitmapHeader	bmh;

PiggyCloseFile ();             //close old pig if still open
strcpy (szPigName, filename);
//rename pigfile for shareware
if (!stricmp (DefaultPigFile (), DefaultPigFile (1)) && 
	 !CFile::Exist (szPigName, gameFolders.szDataDir, 0))
	strcpy (szPigName, DefaultPigFile (1));
strlwr (szPigName);
if (!cfP->Open (szPigName, gameFolders.szDataDir, "rb", 0)) {
	if (!CopyPigFileFromCD (*cfP, szPigName))
		return;
	}
int pig_id = cfP->ReadInt ();
int pigVersion = cfP->ReadInt ();
if (pig_id != PIGFILE_ID || pigVersion != PIGFILE_VERSION) {
	cfP->Close ();              //out of date pig
	return;
	}
strncpy (szCurrentPigFile [0], szPigName, sizeof (szCurrentPigFile [0]));
nBitmapNum = cfP->ReadInt ();
nHeaderSize = nBitmapNum * sizeof (tPIGBitmapHeader);
nDataStart = nHeaderSize + cfP->Tell ();
nDataSize = cfP->Length () - nDataStart;
gameData.pig.tex.nBitmaps [0] = 1;
for (i = 0; i < nBitmapNum; i++) {
	PIGBitmapHeaderRead (&bmh, *cfP);
	memcpy (szNameRead, bmh.name, 8);
	szNameRead [8] = 0;
	if (bmh.dflags & DBM_FLAG_ABM)        
		sprintf (szName, "%s#%d", szNameRead, bmh.dflags & DBM_NUM_FRAMES);
	else
		strcpy (szName, szNameRead);
	memset (&bm, 0, sizeof (CBitmap));
	bm.SetWidth (bmh.width + ((short) (bmh.wh_extra & 0x0f) << 8));
	bm.SetHeight (bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4));
	bm.SetBPP (1);
	bm.SetFlags (BM_FLAG_PAGED_OUT);
	bm.SetAvgColorIndex (bmh.avgColor);
	gameData.pig.tex.bitmapFlags [0][i+1] = bmh.flags & BM_FLAGS_TO_COPY;
	bitmapOffsets [0][i+1] = bmh.offset + nDataStart;
	Assert ((i+1) == gameData.pig.tex.nBitmaps [0]);
	PiggyRegisterBitmap (&bm, szName, 1);
	}
bPigFileInitialized = 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:57,代码来源:piggy.cpp

示例7: PlayerShipRead

void PlayerShipRead (tPlayerShip *ps, CFile& cf)
{
	int i;

ps->nModel = cf.ReadInt ();
ps->nExplVClip = cf.ReadInt ();
ps->mass = cf.ReadFix ();
ps->drag = cf.ReadFix ();
ps->maxThrust = cf.ReadFix ();
ps->reverseThrust = cf.ReadFix ();
ps->brakes = cf.ReadFix ();
ps->wiggle = cf.ReadFix ();
ps->maxRotThrust = cf.ReadFix ();
for (i = 0; i < N_PLAYER_GUNS; i++)
	cf.ReadVector (ps->gunPoints[i]);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:16,代码来源:player.cpp

示例8: LoadD1PigHeader

void LoadD1PigHeader (CFile& cf, int *pSoundNum, int *pBmHdrOffs, int *pBmDataOffs, int *pBitmapNum, int bReadTMapNums)
{

#	define D1_PIG_LOAD_FAILED "Failed loading " D1_PIGFILE

	int	nPigDataStart,
			nHeaderSize,
			nBmHdrOffs, 
			nBmDataOffs,
			nSoundNum, 
			nBitmapNum;

switch (cf.Length ()) {
	case D1_SHARE_BIG_PIGSIZE:
	case D1_SHARE_10_PIGSIZE:
	case D1_SHARE_PIGSIZE:
	case D1_10_BIG_PIGSIZE:
	case D1_10_PIGSIZE:
		nPigDataStart = 0;
		Warning ("%s %s. %s", TXT_LOAD_FAILED, D1_PIGFILE, TXT_D1_SUPPORT);
		return;
	default:
		Warning ("%s %s", TXT_UNKNOWN_SIZE, D1_PIGFILE);
		Int3 ();
		// fall through
	case D1_PIGSIZE:
	case D1_OEM_PIGSIZE:
	case D1_MAC_PIGSIZE:
	case D1_MAC_SHARE_PIGSIZE:
		nPigDataStart = cf.ReadInt ();
		if (bReadTMapNums)
			BMReadD1TMapNums (cf); 
		break;
	}
cf.Seek (nPigDataStart, SEEK_SET);
nBitmapNum = cf.ReadInt ();
nSoundNum = cf.ReadInt ();
nHeaderSize = nBitmapNum * PIGBITMAPHEADER_D1_SIZE + nSoundNum * sizeof (tPIGSoundHeader);
nBmHdrOffs = nPigDataStart + 2 * sizeof (int);
nBmDataOffs = nBmHdrOffs + nHeaderSize;
if (pSoundNum)
	*pSoundNum = nSoundNum;
*pBmHdrOffs = nBmHdrOffs;
*pBmDataOffs = nBmDataOffs;
*pBitmapNum = nBitmapNum;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:46,代码来源:piggy.cpp

示例9: ReadHamFile

int ReadHamFile (void)
{
	CFile cf;
#if 1
	char szD1PigFileName [FILENAME_LEN];
#endif
	int nHAMId;
	int nSoundOffset = 0;

if (!cf.Open ((char *) DEFAULT_HAMFILE, gameFolders.szDataDir, "rb", 0)) {
	bMustWriteHamFile = 1;
	return 0;
	}
//make sure ham is valid nType file & is up-to-date
nHAMId = cf.ReadInt ();
gameData.pig.tex.nHamFileVersion = cf.ReadInt ();
if (nHAMId != HAMFILE_ID)
	Error ("Cannot open ham file %s\n", DEFAULT_HAMFILE);
if (gameData.pig.tex.nHamFileVersion < 3) // hamfile contains sound info
	nSoundOffset = cf.ReadInt ();
#ifndef EDITOR
	BMReadAll (cf);
/*---*/PrintLog ("      Loading bitmap index translation table\n");
	cf.Read (gameData.pig.tex.bitmapXlat, sizeof (ushort)*MAX_BITMAP_FILES, 1);
#endif
if (gameData.pig.tex.nHamFileVersion < 3) {
	cf.Seek (nSoundOffset, SEEK_SET);
	int nSoundNum = cf.ReadInt ();
	int nSoundStart = cf.Tell ();
/*---*/PrintLog ("      Loading %d sounds\n", nSoundNum);
	LoadSounds (cf, nSoundNum, nSoundStart);
	}
cf.Close ();
/*---*/PrintLog ("      Looking for Descent 1 data files\n");
	strcpy (szD1PigFileName, "descent.pig");
	if (!cfPiggy [1].File ())
		cfPiggy [1].Open (szD1PigFileName, gameFolders.szDataDir, "rb", 0);
	if (cfPiggy [1].File ()) {
		gameStates.app.bHaveD1Data = 1;
/*---*/PrintLog ("      Loading Descent 1 data\n");
		BMReadGameDataD1 (cfPiggy [1]);
		}
return 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:44,代码来源:piggy.cpp

示例10: PIGBitmapHeaderD1Read

/*
 * reads a descent 1 tPIGBitmapHeader structure from a CFile
 */
void PIGBitmapHeaderD1Read (tPIGBitmapHeader *dbh, CFile& cf)
{
cf.Read (dbh->name, 8, 1);
dbh->dflags = cf.ReadByte ();
dbh->width = cf.ReadByte ();
dbh->height = cf.ReadByte ();
dbh->wh_extra = 0;
dbh->flags = cf.ReadByte ();
dbh->bmAvgColor = cf.ReadByte ();
dbh->offset = cf.ReadInt ();
}
开发者ID:paud,项目名称:d2x-xl,代码行数:14,代码来源:piggy.cpp

示例11: ReadVariableLights

static int ReadVariableLights (CFile& cf)
{
	int	nLights = cf.ReadInt ();

if (!nLights)
	return 0;
if (!gameData.render.lights.flicker.Create (nLights))
	return -1;
for (int i = 0; i < nLights; i++)
	gameData.render.lights.flicker [i].Read (cf);
return nLights;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:12,代码来源:gamesave.cpp

示例12:

CBitmap *PiggyLoadBitmap (const char *pszFile)
{
	CFile					cf;
	CBitmap				*bmP;
	tBitmapFileHeader	bfh;
	tBitmapInfoHeader	bih;

if (!cf.Open (pszFile, gameFolders.szDataDir, "rb", 0))
	return NULL;

bfh.bfType = cf.ReadShort ();
bfh.bfSize = (uint) cf.ReadInt ();
bfh.bfReserved1 = cf.ReadShort ();
bfh.bfReserved2 = cf.ReadShort ();
bfh.bfOffBits = (uint) cf.ReadInt ();

bih.biSize = (uint) cf.ReadInt ();
bih.biWidth = (uint) cf.ReadInt ();
bih.biHeight = (uint) cf.ReadInt ();
bih.biPlanes = cf.ReadShort ();
bih.biBitCount = cf.ReadShort ();
bih.biCompression = (uint) cf.ReadInt ();
bih.biSizeImage = (uint) cf.ReadInt ();
bih.biXPelsPerMeter = (uint) cf.ReadInt ();
bih.biYPelsPerMeter = (uint) cf.ReadInt ();
bih.biClrUsed = (uint) cf.ReadInt ();
bih.biClrImportant = (uint) cf.ReadInt ();

if (!(bmP = CBitmap::Create (0, bih.biWidth, bih.biHeight, 1))) {
	cf.Close ();
	return NULL;
	}
cf.Seek (bfh.bfOffBits, SEEK_SET);
if (bmP->Read (cf, bih.biWidth * bih.biHeight) != bih.biWidth * bih.biHeight) {
	delete bmP;
	return NULL;
	}
cf.Close ();
return bmP;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:40,代码来源:piggy.cpp

示例13:

grsBitmap *PiggyLoadBitmap (const char *pszFile)
{
	CFile					cf;
	grsBitmap			*bmp;
	tBitmapFileHeader	bfh;
	tBitmapInfoHeader	bih;

if (!cf.Open (pszFile, gameFolders.szDataDir, "rb", 0))
	return NULL;

bfh.bfType = cf.ReadShort ();
bfh.bfSize = (unsigned int) cf.ReadInt ();
bfh.bfReserved1 = cf.ReadShort ();
bfh.bfReserved2 = cf.ReadShort ();
bfh.bfOffBits = (unsigned int) cf.ReadInt ();

bih.biSize = (unsigned int) cf.ReadInt ();
bih.biWidth = (unsigned int) cf.ReadInt ();
bih.biHeight = (unsigned int) cf.ReadInt ();
bih.biPlanes = cf.ReadShort ();
bih.biBitCount = cf.ReadShort ();
bih.biCompression = (unsigned int) cf.ReadInt ();
bih.biSizeImage = (unsigned int) cf.ReadInt ();
bih.biXPelsPerMeter = (unsigned int) cf.ReadInt ();
bih.biYPelsPerMeter = (unsigned int) cf.ReadInt ();
bih.biClrUsed = (unsigned int) cf.ReadInt ();
bih.biClrImportant = (unsigned int) cf.ReadInt ();

if (!(bmp = GrCreateBitmap (bih.biWidth, bih.biHeight, 1))) {
	cf.Close ();
	return NULL;
	}
cf.Seek (bfh.bfOffBits, SEEK_SET);
if (cf.Read (bmp->bmTexBuf, bih.biWidth * bih.biHeight, 1) != 1) {
	GrFreeBitmap (bmp);
	return NULL;
	}
cf.Close ();
return bmp;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:40,代码来源:piggy.cpp

示例14: ReadTMapInfoND1

int ReadTMapInfoND1 (tTexMapInfo *ti, int n, CFile& cf)
{
	int i;

for (i = 0;i < n;i++) {
	cf.Seek (13, SEEK_CUR);// skip filename
	ti [i].flags = cf.ReadByte ();
	ti [i].lighting = cf.ReadFix ();
	ti [i].damage = cf.ReadFix ();
	ti [i].nEffectClip = cf.ReadInt ();
	}
return i;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:13,代码来源:loadgamedata.cpp

示例15: PiggyBitmapReadD1

void PiggyBitmapReadD1 (
	CFile					&cf,
	CBitmap				*bmP, /* read into this bmP */
	int					nBmDataOffs, /* specific to file */
   tPIGBitmapHeader	*bmh, /* header info for bmP */
   ubyte					**pNextBmP, /* where to write it (if 0, use reinterpret_cast<ubyte*> (D2_ALLOC) */
   ubyte					*colorMap) /* how to translate bmP's colors */
{
	int zSize, bSwap0255;

memset (bmP, 0, sizeof (CBitmap));
bmP->SetWidth (bmh->width + ((short) (bmh->wh_extra&0x0f)<<8));
bmP->SetHeight (bmh->height + ((short) (bmh->wh_extra&0xf0)<<4));
bmP->SetBPP (1);
bmP->SetAvgColorIndex (bmh->avgColor);
bmP->AddFlags (bmh->flags & BM_FLAGS_TO_COPY);

cf.Seek (nBmDataOffs + bmh->offset, SEEK_SET);
if (bmh->flags & BM_FLAG_RLE) {
	zSize = cf.ReadInt ();
	cf.Seek (-4, SEEK_CUR);
	}
else
	zSize = bmP->Width () * bmP->Width ();

if (pNextBmP) {
	bmP->SetBuffer (*pNextBmP);
	*pNextBmP += zSize;
	}
else {
	if (bmP->CreateBuffer ())
		UseBitmapCache (bmP, (int) bmP->FrameSize ());
	else
		return;
	}
bmP->Read (cf, zSize);
bSwap0255 = 0;
switch (cf.Length ()) {
	case D1_MAC_PIGSIZE:
	case D1_MAC_SHARE_PIGSIZE:
		if (bmh->flags & BM_FLAG_RLE)
			bSwap0255 = 1;
		else
			bmP->Swap_0_255 ();
		}
if (bmh->flags & BM_FLAG_RLE)
	bmP->RLEExpand (NULL, bSwap0255);
bmP->Remap (paletteManager.D1 (), TRANSPARENCY_COLOR, -1);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:49,代码来源:piggy.cpp


注:本文中的CFile::ReadInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。