本文整理汇总了C++中CFile::EoF方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::EoF方法的具体用法?C++ CFile::EoF怎么用?C++ CFile::EoF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::EoF方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
int CModel::Read (char *filename, short nModel, int bFlipV, int bCustom)
{
if (m_nModel >= 0)
return 0;
CFile cf;
char fileId [4];
int i, nLength, nFrames, nSubModels, bTimed = 0;
bLogOOF = (fErr != NULL) && FindArg ("-printoof");
nIndent = 0;
OOF_PrintLog ("\nreading %s/%s\n", gameFolders.szModelDir [bCustom], filename);
if (!(*filename && cf.Open (filename, gameFolders.szModelDir [bCustom], "rb", 0))) {
OOF_PrintLog (" file not found");
return 0;
}
if (!cf.Read (fileId, sizeof (fileId), 1)) {
OOF_PrintLog (" invalid file id\n");
cf.Close ();
return 0;
}
if (strncmp (fileId, "PSPO", 4)) {
OOF_PrintLog (" invalid file id\n");
cf.Close ();
return 0;
}
Init ();
m_nModel = nModel;
m_bCustom = bCustom;
m_nVersion = OOF_ReadInt (cf, "nVersion");
if (m_nVersion >= 2100)
m_nFlags |= OOF_PMF_LIGHTMAP_RES;
if (m_nVersion >= 22) {
bTimed = 1;
m_nFlags |= OOF_PMF_TIMED;
m_frameInfo.m_nFirstFrame = 0;
m_frameInfo.m_nLastFrame = 0;
}
nSubModels = 0;
while (!cf.EoF ()) {
char chunkID [4];
if (!cf.Read (chunkID, sizeof (chunkID), 1)) {
cf.Close ();
return 0;
}
OOF_PrintLog (" chunkID = '%c%c%c%c'\n", chunkID [0], chunkID [1], chunkID [2], chunkID [3]);
nLength = OOF_ReadInt (cf, "nLength");
switch (ListType (chunkID)) {
case 0:
if (!ReadTextures (cf)) {
Destroy ();
return 0;
}
break;
case 1:
if (!ReadInfo (cf)) {
Destroy ();
return 0;
}
break;
case 2:
if (!m_subModels [nSubModels].Read (cf, this, bFlipV)) {
Destroy ();
return 0;
}
nSubModels++;
break;
case 3:
if (!m_gunPoints.Read (cf, m_nVersion >= 1908, MAX_GUNS)) {
Destroy ();
return 0;
}
break;
case 4:
if (!m_specialPoints.Read (cf)) {
Destroy ();
return 0;
}
break;
case 5:
if (!m_attachPoints.Read (cf)) {
Destroy ();
return 0;
}
break;
case 6:
nFrames = m_frameInfo.m_nFrames;
if (!bTimed)
m_frameInfo.m_nFrames = OOF_ReadInt (cf, "nFrames");
//.........这里部分代码省略.........
示例2: ReadConfigFile
int ReadConfigFile (void)
{
CFile cf;
char line [80], *token, *value, *ptr;
ubyte gamma;
tJoyAxisCal cal [7];
int i;
strcpy (gameConfig.szLastPlayer, "");
memset (cal, 0, sizeof (cal));
JoySetCalVals (cal, sizeofa (cal));
gameConfig.nDigiVolume = 8;
gameConfig.nMidiVolume = 8;
gameConfig.nRedbookVolume = 8;
gameConfig.nControlType = 0;
gameConfig.bReverseChannels = 0;
//set these here in case no cfg file
bHiresMoviesSave = gameOpts->movies.bHires;
bRedbookEnabledSave = redbook.Enabled ();
if (!cf.Open ("descent.cfg", gameFolders.szConfigDir, "rt", 0))
return 1;
while (!cf.EoF ()) {
memset (line, 0, 80);
cf.GetS (line, 80);
ptr = line;
while (::isspace (*ptr))
ptr++;
if (*ptr != '\0') {
token = strtok (ptr, "=");
value = strtok (NULL, "=");
if (!(value && token)) {
PrintLog ("configuration file (descent.cfg) looks messed up.\n");
continue;
}
if (value [strlen (value) - 1] == '\n')
value [strlen (value) - 1] = 0;
if (!strcmp (token, pszDigiVolume))
gameConfig.nDigiVolume = (ubyte) strtol (value, NULL, 10);
else if (!strcmp (token, pszMidiVolume))
gameConfig.nMidiVolume = (ubyte) strtol (value, NULL, 10);
else if (!strcmp (token, pszRedbookEnabled))
redbook.Enable (bRedbookEnabledSave = strtol (value, NULL, 10));
else if (!strcmp (token, pszRedbookVolume))
gameConfig.nRedbookVolume = (ubyte) strtol (value, NULL, 10);
else if (!strcmp (token, pszStereoRev))
gameConfig.bReverseChannels = (ubyte) strtol (value, NULL, 10);
else if (!strcmp (token, pszGammaLevel)) {
gamma = (ubyte) strtol (value, NULL, 10);
paletteManager.SetGamma (gamma);
}
else if (!strcmp (token, pszDetailLevel)) {
gameStates.app.nDetailLevel = strtol (value, NULL, 10);
if (gameStates.app.nDetailLevel == NUM_DETAIL_LEVELS-1) {
int count,dummy,oc,od,wd,wrd,da,sc;
count = sscanf (value, "%d,%d,%d,%d,%d,%d,%d\n", &dummy, &oc, &od, &wd, &wrd, &da, &sc);
if (count == 7) {
gameStates.render.detail.nObjectComplexity = oc;
gameStates.render.detail.nObjectDetail = od;
gameStates.render.detail.nWallDetail = wd;
gameStates.render.detail.nWallRenderDepth = wrd;
gameStates.render.detail.nDebrisAmount = da;
gameStates.sound.nSoundChannels = sc;
InitCustomDetails ();
}
}
}
else if (!strcmp (token, pszJoystickMin))
sscanf (value, "%d,%d,%d,%d", &cal [0].nMin, &cal [1].nMin, &cal [2].nMin, &cal [3].nMin);
else if (!strcmp (token, pszJoystickMax))
sscanf (value, "%d,%d,%d,%d", &cal [0].nMax, &cal [1].nMax, &cal [2].nMax, &cal [3].nMax);
else if (!strcmp (token, pszJoystickCen))
sscanf (value, "%d,%d,%d,%d", &cal [0].nCenter, &cal [1].nCenter, &cal [2].nCenter, &cal [3].nCenter);
else if (!strcmp (token, pszLastPlayer)) {
char * p;
strncpy (gameConfig.szLastPlayer, value, CALLSIGN_LEN);
p = strchr (gameConfig.szLastPlayer, '\n');
if (p) *p = 0;
}
else if (!strcmp (token, pszLastMission)) {
int j = MsnHasGameVer (value) ? 4 : 0;
strncpy (gameConfig.szLastMission, value + j, MISSION_NAME_LEN);
char *p = strchr (gameConfig.szLastMission, '\n');
if (p)
*p = 0;
}
else if (!strcmp (token, pszVrType))
gameConfig.vrType = strtol (value, NULL, 10);
else if (!strcmp (token, pszVrResolution))
gameConfig.vrResolution = strtol (value, NULL, 10);
else if (!strcmp (token, pszVrTracking))
gameConfig.vrTracking = strtol (value, NULL, 10);
else if (!strcmp (token, pszD2XVersion))
gameConfig.nVersion = strtoul (value, NULL, 10);
else if (!strcmp (token, pszHiresMovies) && gameStates.app.bNostalgia)
bHiresMoviesSave = gameOpts->movies.bHires = strtol (value, NULL, 10);
}
}
cf.Close ();
//.........这里部分代码省略.........