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


C++ FResourceFile::GetLump方法代码示例

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


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

示例1: ScanIWAD

int FIWadManager::ScanIWAD (const char *iwad)
{
	FResourceFile *iwadfile = FResourceFile::OpenResourceFile(iwad, NULL, true);

	if (iwadfile != NULL)
	{
		ClearChecks();
		for(DWORD ii = 0; ii < iwadfile->LumpCount(); ii++)
		{
			FResourceLump *lump = iwadfile->GetLump(ii);

			CheckLumpName(lump->Name);
			if (lump->FullName != NULL)
			{
				if (strnicmp(lump->FullName, "maps/", 5) == 0)
				{
					FString mapname(lump->FullName+5, strcspn(lump->FullName+5, "."));
					CheckLumpName(mapname);
				}
				else if (0 == strlen(lump->Name) && strlen(lump->FullName) > 8)
				{
					CheckLumpName(lump->FullName);
				}
			}
		}
		delete iwadfile;
	}
	return GetIWadInfo();
}
开发者ID:alexey-lysiuk,项目名称:gzdoom-osx,代码行数:29,代码来源:d_iwad.cpp

示例2: ParseIWadInfos

void FIWadManager::ParseIWadInfos(const char *fn)
{
	FResourceFile *resfile = FResourceFile::OpenResourceFile(fn, NULL, true);
	if (resfile != NULL)
	{
		DWORD cnt = resfile->LumpCount();
		for(int i=cnt-1; i>=0; i--)
		{
			FResourceLump *lmp = resfile->GetLump(i);

			if (lmp->Namespace == ns_global && !stricmp(lmp->Name, "IWADINFO"))
			{
				// Found one!
				ParseIWadInfo(resfile->Filename, (const char*)lmp->CacheLump(), lmp->LumpSize);
				break;
			}
		}
		delete resfile;
	}
	if (mIWadNames.Size() == 0 || mIWads.Size() == 0)
	{
		I_FatalError("No IWAD definitions found");
	}
}
开发者ID:alexey-lysiuk,项目名称:gzdoom-osx,代码行数:24,代码来源:d_iwad.cpp

示例3: 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++)
			{
//.........这里部分代码省略.........
开发者ID:emileb,项目名称:gzdoom,代码行数:101,代码来源:w_wad.cpp

示例4: ScanIWAD

static EIWADType ScanIWAD (const char *iwad)
{
	static const char checklumps[][8] =
	{
		"AD2LIB",
		"E1M1",
		"E4M2",
		"MAP01",
		"MAP40",
		"MAP60",
		"TITLE",
		"REDTNT2",
		"CAMO1",
		{ 'E','X','T','E','N','D','E','D'},
		"ENDSTRF",
		"MAP33",
		"INVCURS",
		{ 'F','R','E','E','D','O','O','M' },
		{ 'B','L','A','S','P','H','E','M' },
		"W94_1",
		{ 'P','O','S','S','H','0','M','0' },
		"CYCLA1",
		"FLMBA1",
		"MAPINFO",
		"0HAWK01",
		"0CARA3",
		"0NOSE1",
		{ 'G','A','M','E','I','N','F','O' },
		"E2M1","E2M2","E2M3","E2M4","E2M5","E2M6","E2M7","E2M8","E2M9",
		"E3M1","E3M2","E3M3","E3M4","E3M5","E3M6","E3M7","E3M8","E3M9",
		"DPHOOF","BFGGA0","HEADA1","CYBRA1",
		{ 'S','P','I','D','A','1','D','1' },

	};
#define NUM_CHECKLUMPS (countof(checklumps))
	enum
	{
		Check_ad2lib,
		Check_e1m1,
		Check_e4m1,
		Check_map01,
		Check_map40,
		Check_map60,
		Check_title,
		Check_redtnt2,
		Check_cam01,
		Check_Extended,
		Check_endstrf,
		Check_map33,
		Check_invcurs,
		Check_FreeDoom,
		Check_Blasphem,
		Check_W94_1,
		Check_POSSH0M0,
		Check_Cycla1,
		Check_Flmba1,
		Check_Mapinfo,
		Check_Hawk,
		Check_Car,
		Check_Nose,
		Check_Gameinfo,
		Check_e2m1
	};
	bool lumpsfound[NUM_CHECKLUMPS];
	size_t i;

	memset (lumpsfound, 0, sizeof(lumpsfound));
	FResourceFile *iwadfile = FResourceFile::OpenResourceFile(iwad, NULL, true);

	if (iwadfile != NULL)
	{
		for(DWORD ii = 0; ii < iwadfile->LumpCount(); ii++)
		{
			FResourceLump *lump = iwadfile->GetLump(ii);
			size_t j;

			for (j = 0; j < NUM_CHECKLUMPS; j++)
			{
				if (!lumpsfound[j])
				{
					if (strnicmp (lump->Name, checklumps[j], 8) == 0)
					{
						lumpsfound[j] = true;
						break;
					}
					// Check for maps inside zips, too.
					else if (lump->FullName != NULL)
					{
						if (checklumps[j][0] == 'E' && checklumps[j][2] == 'M' && checklumps[j][4] == '\0')
						{
							if (strnicmp(lump->FullName, "maps/", 5) == 0 &&
								strnicmp(lump->FullName + 5, checklumps[j], 4) == 0 &&
								stricmp(lump->FullName + 9, ".wad") == 0)
							{
								lumpsfound[j] = true;
								break;
							}
						}
						else if (checklumps[j][0] == 'M' && checklumps[j][1] == 'A' && checklumps[j][2] == 'P' &&
								 checklumps[j][5] == '\0')
//.........这里部分代码省略.........
开发者ID:WChrisK,项目名称:Zandronum,代码行数:101,代码来源:d_iwad.cpp

示例5: 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;
	}
}
开发者ID:Krazygamr,项目名称:D-Touch,代码行数:81,代码来源:w_wad.cpp


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