本文整理汇总了C++中FMemLump类的典型用法代码示例。如果您正苦于以下问题:C++ FMemLump类的具体用法?C++ FMemLump怎么用?C++ FMemLump使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FMemLump类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
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();
}
}
}
}
示例2: 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;
}
}
示例3: OpenLumpNum
void FScanner :: OpenLumpNum (int lump)
{
Close ();
{
FMemLump mem = Wads.ReadLump(lump);
ScriptBuffer = mem.GetString();
}
ScriptName = Wads.GetLumpFullPath(lump);
LumpNum = lump;
PrepareScript ();
}
示例4: 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;
}
}
示例5: FindModel
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;
}
示例6: 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();
}
示例7: Unload
// 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;
}
}
示例8: 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];
}
}
}
示例9: 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);
}
}
}
示例10: 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;
}
示例11: 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;
}
示例12: 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.
}
}
}
示例13: 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);
}
示例14: 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;
}
}
}
示例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);
}