本文整理汇总了C++中FResourceFile::SetFirstLump方法的典型用法代码示例。如果您正苦于以下问题:C++ FResourceFile::SetFirstLump方法的具体用法?C++ FResourceFile::SetFirstLump怎么用?C++ FResourceFile::SetFirstLump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FResourceFile
的用法示例。
在下文中一共展示了FResourceFile::SetFirstLump方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddFile
void FWadCollection::AddFile (const char *filename, FileReader *wadinfo)
{
int startlump;
bool isdir = false;
if (wadinfo == NULL)
{
// Does this exist? If so, is it a directory?
if (!DirEntryExists(filename, &isdir))
{
Printf(TEXTCOLOR_RED "%s: File or Directory not found\n", filename);
PrintLastError();
return;
}
if (!isdir)
{
try
{
wadinfo = new FileReader(filename);
}
catch (CRecoverableError &err)
{ // Didn't find file
Printf (TEXTCOLOR_RED "%s\n", err.GetMessage());
PrintLastError ();
return;
}
}
}
if (!batchrun) Printf (" adding %s", filename);
startlump = NumLumps;
FResourceFile *resfile;
if (!isdir)
resfile = FResourceFile::OpenResourceFile(filename, wadinfo);
else
resfile = FResourceFile::OpenDirectory(filename);
if (resfile != NULL)
{
uint32_t lumpstart = LumpInfo.Size();
resfile->SetFirstLump(lumpstart);
for (uint32_t i=0; i < resfile->LumpCount(); i++)
{
FResourceLump *lump = resfile->GetLump(i);
FWadCollection::LumpRecord *lump_p = &LumpInfo[LumpInfo.Reserve(1)];
lump_p->lump = lump;
lump_p->wadnum = Files.Size();
}
if (static_cast<int>(Files.Size()) == GetIwadNum() && gameinfo.gametype == GAME_Strife && gameinfo.flags & GI_SHAREWARE)
{
resfile->FindStrifeTeaserVoices();
}
Files.Push(resfile);
for (uint32_t i=0; i < resfile->LumpCount(); i++)
{
FResourceLump *lump = resfile->GetLump(i);
if (lump->Flags & LUMPF_EMBEDDED)
{
FString path;
path.Format("%s:%s", filename, lump->FullName.GetChars());
FileReader *embedded = lump->NewReader();
AddFile(path, embedded);
}
}
if (hashfile)
{
uint8_t cksum[16];
char cksumout[33];
memset(cksumout, 0, sizeof(cksumout));
FileReader *reader = wadinfo;
if (reader != NULL)
{
MD5Context md5;
reader->Seek(0, SEEK_SET);
md5.Update(reader, reader->GetLength());
md5.Final(cksum);
for (size_t j = 0; j < sizeof(cksum); ++j)
{
sprintf(cksumout + (j * 2), "%02X", cksum[j]);
}
fprintf(hashfile, "file: %s, hash: %s, size: %ld\n", filename, cksumout, reader->GetLength());
}
else
fprintf(hashfile, "file: %s, Directory structure\n", filename);
for (uint32_t i = 0; i < resfile->LumpCount(); i++)
{
//.........这里部分代码省略.........
示例2: AddFile
void FWadCollection::AddFile (const char *filename, FileReader *wadinfo)
{
int startlump;
bool isdir = false;
if (wadinfo == NULL)
{
// Does this exist? If so, is it a directory?
struct stat info;
if (stat(filename, &info) != 0)
{
Printf(TEXTCOLOR_RED "Could not stat %s\n", filename);
PrintLastError();
return;
}
isdir = (info.st_mode & S_IFDIR) != 0;
if (!isdir)
{
try
{
wadinfo = new FileReader(filename);
}
catch (CRecoverableError &err)
{ // Didn't find file
Printf (TEXTCOLOR_RED "%s\n", err.GetMessage());
PrintLastError ();
return;
}
}
}
Printf (" adding %s", filename);
startlump = NumLumps;
FResourceFile *resfile;
if (!isdir)
resfile = FResourceFile::OpenResourceFile(filename, wadinfo);
else
resfile = FResourceFile::OpenDirectory(filename);
if (resfile != NULL)
{
DWORD lumpstart = LumpInfo.Size();
resfile->SetFirstLump(lumpstart);
for (DWORD i=0; i < resfile->LumpCount(); i++)
{
FResourceLump *lump = resfile->GetLump(i);
FWadCollection::LumpRecord *lump_p = &LumpInfo[LumpInfo.Reserve(1)];
lump_p->lump = lump;
lump_p->wadnum = Files.Size();
}
if (Files.Size() == IWAD_FILENUM && gameinfo.gametype == GAME_Strife && gameinfo.flags & GI_SHAREWARE)
{
resfile->FindStrifeTeaserVoices();
}
Files.Push(resfile);
for (DWORD i=0; i < resfile->LumpCount(); i++)
{
FResourceLump *lump = resfile->GetLump(i);
if (lump->Flags & LUMPF_EMBEDDED)
{
char path[256];
mysnprintf(path, countof(path), "%s:", filename);
char *wadstr = path + strlen(path);
FileReader *embedded = lump->NewReader();
strcpy(wadstr, lump->FullName);
AddFile(path, embedded);
}
}
return;
}
}