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


C++ FMemLump::GetMem方法代码示例

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


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

示例1: SetupBlakeStrings

/* Blake Stone strings are stored in text chunks. They're referenced by an
 * index. Strings are stored separated by ^XX at the end of a line.
 */
void Language::SetupBlakeStrings(const char* lumpname, const char* prefix)
{
    int lumpnum = Wads.CheckNumForName(lumpname);
    if(lumpnum == -1)
        return;

    FMemLump wadLump = Wads.ReadLump(lumpnum);

    unsigned int num = 1; // Start at prefix_1
    unsigned int pos = 0;
    unsigned int start = 0;
    const char* data = reinterpret_cast<const char*>(wadLump.GetMem());
    static const WORD endToken = ('X'<<8)|'X'; // Since both chars are the same this should be endian safe
    while(pos+2 < wadLump.GetSize())
    {
        if(data[pos] == '^' && *(WORD*)(data+pos+1) == endToken)
        {
            FString name;
            FString str(data+start, pos-start);
            name.Format("%s%d", prefix, num++);

            strings[name] = str;

            pos += 3;
            while((data[pos] == '\n' || data[pos] == '\r') && pos < wadLump.GetSize())
                ++pos;
            start = pos;
        }
        else
            ++pos;
    }
}
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:35,代码来源:language.cpp

示例2: InitPalettedVersions

void FTextureManager::InitPalettedVersions()
{
	int lump, lastlump = 0;

	PalettedVersions.Clear();
	while ((lump = Wads.FindLump("PALVERS", &lastlump)) != -1)
	{
		FMemLump data = Wads.ReadLump(lump);
		Scanner sc((const char*)data.GetMem(), data.GetSize());

		while (sc.GetNextToken())
		{
			FTextureID pic1 = CheckForTexture(sc->str, FTexture::TEX_Any);
			if (!pic1.isValid())
			{
				sc.ScriptMessage(Scanner::WARNING, "Unknown texture %s to replace", sc->str.GetChars());
			}
			sc.GetNextToken();
			FTextureID pic2 = CheckForTexture(sc->str, FTexture::TEX_Any);
			if (!pic2.isValid())
			{
				sc.ScriptMessage(Scanner::WARNING, "Unknown texture %s to use as replacement", sc->str.GetChars());
			}
			if (pic1.isValid() && pic2.isValid())
			{
				PalettedVersions[pic1.GetIndex()] = pic2.GetIndex();
			}
		}
	}
}
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:30,代码来源:texturemanager.cpp

示例3: R_CreateSkinTranslation

static void R_CreateSkinTranslation (const char *palname)
{
	FMemLump lump = Wads.ReadLump (palname);
	const BYTE *otherPal = (BYTE *)lump.GetMem();
 
	for (int i = 0; i < 256; ++i)
	{
		OtherGameSkinRemap[i] = ColorMatcher.Pick (otherPal[0], otherPal[1], otherPal[2]);
		OtherGameSkinPalette[i] = PalEntry(otherPal[0], otherPal[1], otherPal[2]);
		otherPal += 3;
	}
}
开发者ID:floverdevel,项目名称:zdoom,代码行数:12,代码来源:sprites.cpp

示例4: if

static FModel * FindModel(const char * path, const char * modelfile)
{
	FModel * model;
	FString fullname;

	fullname.Format("%s%s", path, modelfile);
	int lump = Wads.CheckNumForFullName(fullname);

	if (lump<0)
	{
		Printf("FindModel: '%s' not found\n", fullname.GetChars());
		return NULL;
	}

	for(int i = 0; i< (int)Models.Size(); i++)
	{
		if (!stricmp(fullname, Models[i]->filename)) return Models[i];
	}

	int len = Wads.LumpLength(lump);
	FMemLump lumpd = Wads.ReadLump(lump);
	char * buffer = (char*)lumpd.GetMem();

	if (!memcmp(buffer, "DMDM", 4))
	{
		model = new FDMDModel;
	}
	else if (!memcmp(buffer, "IDP2", 4))
	{
		model = new FMD2Model;
	}
	else if (!memcmp(buffer, "IDP3", 4))
	{
		model = new FMD3Model;
	}
	else
	{
		Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars());
		delete buffer;
		return NULL;
	}

	if (!model->Load(path, buffer, len))
	{
		delete model;
		delete buffer;
		return NULL;
	}
	model->filename = copystring(fullname);
	Models.Push(model);
	return model;
}
开发者ID:WChrisK,项目名称:Zandronum,代码行数:52,代码来源:gl_models.cpp

示例5: HelpScreens

/*
=================
=
= HelpScreens
=
=================
*/
void HelpScreens (void)
{
    int lumpNum = Wads.CheckNumForName("HELPART", ns_global);
    if(lumpNum != -1)
    {
        FMemLump lump = Wads.ReadLump(lumpNum);

        backgroundFlat = TexMan(gameinfo.FinaleFlat);
        ShowArticle((char*)lump.GetMem());
    }

    VW_FadeOut();
}
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:20,代码来源:wl_text.cpp

示例6: HackHack

// Fix for certain special patches on single-patch textures.
void FPatchTexture::HackHack (int newheight)
{
	BYTE *out;
	int x;

	Unload ();
	if (Spans != NULL)
	{
		FreeSpans (Spans);
	}

	{
		FMemLump lump = Wads.ReadLump (SourceLump);
		const patch_t *patch = (const patch_t *)lump.GetMem();

		Width = LittleShort(patch->width);
		Height = newheight;
		LeftOffset = 0;
		TopOffset = 0;

		Pixels = new BYTE[Width * Height];

		// Draw the image to the buffer
		for (x = 0, out = Pixels; x < Width; ++x)
		{
			const BYTE *in = (const BYTE *)patch + LittleLong(patch->columnofs[x]) + 3;

			for (int y = newheight; y > 0; --y)
			{
				*out = *in != 255 ? *in : Near255;
				out++, in++;
			}
			out += newheight;
		}
	}

	// Create the spans
	Spans = (Span **)M_Malloc (sizeof(Span *)*Width + sizeof(Span)*Width*2);

	Span *span = (Span *)&Spans[Width];

	for (x = 0; x < Width; ++x)
	{
		Spans[x] = span;
		span[0].Length = newheight;
		span[0].TopOffset = 0;
		span[1].Length = 0;
		span[1].TopOffset = 0;
		span += 2;
	}
}
开发者ID:ddraigcymraeg,项目名称:scoredoomst,代码行数:52,代码来源:patchtexture.cpp

示例7: MakeTexture

void FAutomapTexture::MakeTexture ()
{
	int x, y;
	FMemLump data = Wads.ReadLump (SourceLump);
	const BYTE *indata = (const BYTE *)data.GetMem();

	Pixels = new BYTE[Width * Height];

	for (x = 0; x < Width; ++x)
	{
		for (y = 0; y < Height; ++y)
		{
			Pixels[x*Height+y] = indata[x+320*y];
		}
	}
}
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:16,代码来源:automaptexture.cpp

示例8: LittleLong

void FMD3Model::LoadGeometry()
{
	FMemLump lumpdata = Wads.ReadLump(mLumpNum);
	const char *buffer = (const char *)lumpdata.GetMem();
	md3_header_t * hdr = (md3_header_t *)buffer;
	md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces));

	for(int i=0;i<numSurfaces;i++)
	{
		MD3Surface * s = &surfaces[i];
		md3_surface_t * ss = surf;

		surf = (md3_surface_t *)(((char*)surf) + LittleLong(surf->Ofs_End));

		// copy triangle indices
		md3_triangle_t * tris = (md3_triangle_t*)(((char*)ss)+LittleLong(ss->Ofs_Triangles));
		s->tris = new MD3Triangle[s->numTriangles];

		for(int i=0;i<s->numTriangles;i++) for (int j=0;j<3;j++)
		{
			s->tris[i].VertIndex[j]=LittleLong(tris[i].vt_index[j]);
		}

		// Load texture coordinates
		md3_texcoord_t * tc = (md3_texcoord_t*)(((char*)ss)+LittleLong(ss->Ofs_Texcoord));
		s->texcoords = new MD3TexCoord[s->numVertices];

		for(int i=0;i<s->numVertices;i++)
		{
			s->texcoords[i].s = tc[i].s;
			s->texcoords[i].t = tc[i].t;
		}

		// Load vertices and texture coordinates
		md3_vertex_t * vt = (md3_vertex_t*)(((char*)ss)+LittleLong(ss->Ofs_XYZNormal));
		s->vertices = new MD3Vertex[s->numVertices * numFrames];

		for(int i=0;i<s->numVertices * numFrames;i++)
		{
			s->vertices[i].x = LittleShort(vt[i].x)/64.f;
			s->vertices[i].y = LittleShort(vt[i].y)/64.f;
			s->vertices[i].z = LittleShort(vt[i].z)/64.f;
			UnpackVector( LittleShort(vt[i].n), s->vertices[i].nx, s->vertices[i].ny, s->vertices[i].nz);
		}
	}
}
开发者ID:Xeomuz,项目名称:Doom-Port-Source-Code,代码行数:46,代码来源:gl_models_md3.cpp

示例9: SD_PrepareSound

byte* SD_PrepareSound(int which)
{
    int size = Wads.LumpLength(which);
    if(size == 0)
        return NULL;

    FMemLump soundLump = Wads.ReadLump(which);

    byte* out = reinterpret_cast<byte*> (Mix_LoadWAV_RW(SDL_RWFromMem(soundLump.GetMem(), size), 1));
    if(!out)
        return NULL;

    // TEMPORARY WORK AROUND FOR MEMORY ERROR
    byte* nout = new byte[sizeof(Mix_Chunk)];
    memcpy(nout, out, sizeof(Mix_Chunk));
    return nout;
}
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:17,代码来源:id_sd.cpp

示例10: Pixels

TArray<uint8_t> FAutomapTexture::CreatePalettedPixels(int conversion)
{
	int x, y;
	FMemLump data = Wads.ReadLump (SourceLump);
	const uint8_t *indata = (const uint8_t *)data.GetMem();

	TArray<uint8_t> Pixels(Width * Height, true);

	const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance);
	for (x = 0; x < Width; ++x)
	{
		for (y = 0; y < Height; ++y)
		{
			auto p = indata[x + 320 * y];
			Pixels[x*Height + y] = remap[p];
		}
	}
	return Pixels;
}
开发者ID:coelckers,项目名称:gzdoom,代码行数:19,代码来源:automaptexture.cpp

示例11: HackHack

void FPatchTexture::HackHack (int newheight)
{
	// Check if this patch is likely to be a problem.
	// It must be 256 pixels tall, and all its columns must have exactly
	// one post, where each post has a supposed length of 0.
	FMemLump lump = Wads.ReadLump (SourceLump);
	const patch_t *realpatch = (patch_t *)lump.GetMem();
	const DWORD *cofs = realpatch->columnofs;
	int x, x2 = LittleShort(realpatch->width);

	if (LittleShort(realpatch->height) == 256)
	{
		for (x = 0; x < x2; ++x)
		{
			const column_t *col = (column_t*)((BYTE*)realpatch+LittleLong(cofs[x]));
			if (col->topdelta != 0 || col->length != 0)
			{
				break;	// It's not bad!
			}
			col = (column_t *)((BYTE *)col + 256 + 4);
			if (col->topdelta != 0xFF)
			{
				break;	// More than one post in a column!
			}
		}
		if (x == x2)
		{ 
			// If all the columns were checked, it needs fixing.
			Unload ();
			if (Spans != NULL)
			{
				FreeSpans (Spans);
			}

			Height = newheight;
			LeftOffset = 0;
			TopOffset = 0;

			hackflag = true;
			bMasked = false;	// Hacked textures don't have transparent parts.
		}
	}
}
开发者ID:BadSanta1980,项目名称:gzdoom,代码行数:43,代码来源:patchtexture.cpp

示例12: InitSwitchList

void FTextureManager::InitSwitchList ()
{
	const BITFIELD texflags = TEXMAN_Overridable | TEXMAN_TryAny;
	int lump = Wads.CheckNumForName ("SWITCHES");

	if (lump != -1)
	{
		FMemLump lumpdata = Wads.ReadLump (lump);
		const char *alphSwitchList = (const char *)lumpdata.GetMem();
		const char *list_p;
		FSwitchDef *def1, *def2;

		for (list_p = alphSwitchList; list_p[18] || list_p[19]; list_p += 20)
		{
			// [RH] Check for switches that aren't really switches
			if (stricmp (list_p, list_p+9) == 0)
			{
				Printf ("Switch %s in SWITCHES has the same 'on' state\n", list_p);
				continue;
			}
			// [RH] Skip this switch if its textures can't be found.
			if (CheckForTexture (list_p /* .name1 */, FTexture::TEX_Wall, texflags).Exists() &&
				CheckForTexture (list_p + 9 /* .name2 */, FTexture::TEX_Wall, texflags).Exists())
			{
				def1 = (FSwitchDef *)M_Malloc (sizeof(FSwitchDef));
				def2 = (FSwitchDef *)M_Malloc (sizeof(FSwitchDef));
				def1->PreTexture = def2->frames[0].Texture = CheckForTexture (list_p /* .name1 */, FTexture::TEX_Wall, texflags);
				def2->PreTexture = def1->frames[0].Texture = CheckForTexture (list_p + 9, FTexture::TEX_Wall, texflags);
				def1->Sound = def2->Sound = 0;
				def1->NumFrames = def2->NumFrames = 1;
				def1->frames[0].TimeMin = def2->frames[0].TimeMin = 0;
				def1->frames[0].TimeRnd = def2->frames[0].TimeRnd = 0;
				AddSwitchPair(def1, def2);
			}
		}
	}

	mSwitchDefs.ShrinkToFit ();
	qsort (&mSwitchDefs[0], mSwitchDefs.Size(), sizeof(FSwitchDef *), SortSwitchDefs);
}
开发者ID:AkumaKing,项目名称:Xeu,代码行数:40,代码来源:anim_switches.cpp

示例13: MakeTexture

void FIMGZTexture::MakeTexture ()
{
	FMemLump lump = Wads.ReadLump (SourceLump);
	const ImageHeader *imgz = (const ImageHeader *)lump.GetMem();
	const BYTE *data = (const BYTE *)&imgz[1];

	if (Width != 0xFFFF)
	{
		Width = LittleShort(imgz->Width);
		Height = LittleShort(imgz->Height);
		LeftOffset = LittleShort(imgz->LeftOffset);
		TopOffset = LittleShort(imgz->TopOffset);
	}

	BYTE *dest_p;
	int dest_adv = Height;
	int dest_rew = Width * Height - 1;

	CalcBitSize ();
	Pixels = new BYTE[Width*Height];
	dest_p = Pixels;

	// Convert the source image from row-major to column-major format
	if (!imgz->Compression)
	{
		for (int y = Height; y != 0; --y)
		{
			for (int x = Width; x != 0; --x)
			{
				*dest_p = *data;
				dest_p += dest_adv;
				data++;
			}
			dest_p -= dest_rew;
		}
	}
	else
	{
		// IMGZ compression is the same RLE used by IFF ILBM files
		int runlen = 0, setlen = 0;
		BYTE setval = 0;  // Shut up, GCC

		for (int y = Height; y != 0; --y)
		{
			for (int x = Width; x != 0; )
			{
				if (runlen != 0)
				{
					BYTE color = *data;
					*dest_p = color;
					dest_p += dest_adv;
					data++;
					x--;
					runlen--;
				}
				else if (setlen != 0)
				{
					*dest_p = setval;
					dest_p += dest_adv;
					x--;
					setlen--;
				}
				else
				{
					SBYTE code = *data++;
					if (code >= 0)
					{
						runlen = code + 1;
					}
					else if (code != -128)
					{
						setlen = (-code) + 1;
						setval = *data++;
					}
				}
			}
			dest_p -= dest_rew;
		}
	}
}
开发者ID:Xane123,项目名称:world-of-kirbycraft,代码行数:80,代码来源:imgztexture.cpp

示例14: LoadTextureDefs

void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
{
	int remapLump, lastLump;
	char src[9];
	//bool is32bit;
	//int width, height;
	//int type, mode;
	TArray<FTextureID> tlist;

	lastLump = 0;
	src[8] = '\0';

	while ((remapLump = Wads.FindLump(lumpname, &lastLump)) != -1)
	{
		if (Wads.GetLumpFile(remapLump) == wadnum)
		{
			FMemLump lmp = Wads.ReadLump(remapLump);
			Scanner sc((const char*)lmp.GetMem(), lmp.GetSize());
			sc.SetScriptIdentifier(Wads.GetLumpFullName(remapLump));
			while (sc.CheckToken(TK_Identifier))
			{
				/*if (sc.Compare("remap")) // remap an existing texture
				{
					sc.MustGetString();

					// allow selection by type
					if (sc.Compare("wall")) type=FTexture::TEX_Wall, mode=FTextureManager::TEXMAN_Overridable;
					else if (sc.Compare("flat")) type=FTexture::TEX_Flat, mode=FTextureManager::TEXMAN_Overridable;
					else if (sc.Compare("sprite")) type=FTexture::TEX_Sprite, mode=0;
					else type = FTexture::TEX_Any, mode = 0;

					if (type != FTexture::TEX_Any) sc.MustGetString();

					sc.String[8]=0;

					tlist.Clear();
					int amount = ListTextures(sc.String, tlist);
					FName texname = sc.String;

					sc.MustGetString();
					int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches);
					if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics);

					if (tlist.Size() == 0)
					{
						Printf("Attempting to remap non-existent texture %s to %s\n",
							texname.GetChars(), sc.String);
					}
					else if (lumpnum == -1)
					{
						Printf("Attempting to remap texture %s to non-existent lump %s\n",
							texname.GetChars(), sc.String);
					}
					else
					{
						for(unsigned int i = 0; i < tlist.Size(); i++)
						{
							FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture;
							int sl;

							// only replace matching types. For sprites also replace any MiscPatches
							// based on the same lump. These can be created for icons.
							if (oldtex->UseType == type || type == FTexture::TEX_Any ||
								(mode == TEXMAN_Overridable && oldtex->UseType == FTexture::TEX_Override) ||
								(type == FTexture::TEX_Sprite && oldtex->UseType == FTexture::TEX_MiscPatch &&
								(sl=oldtex->GetSourceLump()) >= 0 && Wads.GetLumpNamespace(sl) == ns_sprites)
								)
							{
								FTexture * newtex = FTexture::CreateTexture (lumpnum, FTexture::TEX_Any);
								if (newtex != NULL)
								{
									// Replace the entire texture and adjust the scaling and offset factors.
									newtex->bWorldPanning = true;
									newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
									newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
									newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
									ReplaceTexture(tlist[i], newtex, true);
								}
							}
						}
					}
				}
				else if (sc.Compare("define")) // define a new "fake" texture
				{
					sc.GetString();
					
					FString base = ExtractFileBase(sc.String, false);
					if (!base.IsEmpty())
					{
						strncpy(src, base, 8);

						int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches);
						if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics);

						sc.GetString();
						is32bit = !!sc.Compare("force32bit");
						if (!is32bit) sc.UnGet();

						sc.GetNumber();
						width = sc.Number;
//.........这里部分代码省略.........
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:101,代码来源:texturemanager.cpp

示例15: FindModel

static unsigned FindModel(const char * path, const char * modelfile)
{
	FModel * model = nullptr;
	FString fullname;

	fullname.Format("%s%s", path, modelfile);
	int lump = Wads.CheckNumForFullName(fullname);

	if (lump<0)
	{
		Printf("FindModel: '%s' not found\n", fullname.GetChars());
		return -1;
	}

	for(unsigned i = 0; i< Models.Size(); i++)
	{
		if (!Models[i]->mFileName.CompareNoCase(fullname)) return i;
	}

	int len = Wads.LumpLength(lump);
	FMemLump lumpd = Wads.ReadLump(lump);
	char * buffer = (char*)lumpd.GetMem();

	if (!memcmp(buffer, "DMDM", 4))
	{
		model = new FDMDModel;
	}
	else if (!memcmp(buffer, "IDP2", 4))
	{
		model = new FMD2Model;
	}
	else if (!memcmp(buffer, "IDP3", 4))
	{
		model = new FMD3Model;
	}

	if (model != nullptr)
	{
		if (!model->Load(path, lump, buffer, len))
		{
			delete model;
			return -1;
		}
	}
	else
	{
		// try loading as a voxel
		FVoxel *voxel = R_LoadKVX(lump);
		if (voxel != nullptr)
		{
			model = new FVoxelModel(voxel, true);
		}
		else
		{
			Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars());
			return -1;
		}
	}
	// The vertex buffer cannot be initialized here because this gets called before OpenGL is initialized
	model->mFileName = fullname;
	return Models.Push(model);
}
开发者ID:nashmuhandes,项目名称:GZDoom-GPL,代码行数:62,代码来源:gl_models.cpp


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