- rewrote the operator>> methods of FileReader as normal functions for clarity.

This commit is contained in:
Christoph Oelckers 2018-03-11 18:20:49 +01:00
parent 833dbee167
commit 0be1ed252b
12 changed files with 150 additions and 133 deletions

View file

@ -324,14 +324,17 @@ public:
buf.Resize(length); buf.Resize(length);
memcpy(&buf[0], buffer, length); memcpy(&buf[0], buffer, length);
} }
Length = length; UpdateBuffer();
FilePos = 0;
bufptr = (const char *)&buf[0];
} }
TArray<uint8_t> &GetArray() { return buf; } TArray<uint8_t> &GetArray() { return buf; }
void UpdateLength() { Length = buf.Size(); } void UpdateBuffer()
{
bufptr = (const char*)&buf[0];
FilePos = 0;
Length = buf.Size();
}
}; };
@ -381,7 +384,7 @@ bool FileRdr::OpenMemoryArray(std::function<bool(TArray<uint8_t>&)> getter)
if (getter(reader->GetArray())) if (getter(reader->GetArray()))
{ {
Close(); Close();
reader->UpdateLength(); reader->UpdateBuffer();
mReader = reader; mReader = reader;
return true; return true;
} }

View file

@ -201,47 +201,63 @@ public:
return mReader->GetLength(); return mReader->GetLength();
} }
// Note: These need to go because they are fundamentally unsafe to use on a binary stream. uint8_t ReadUInt8()
FileRdr &operator>> (uint8_t &v)
{ {
mReader->Read(&v, 1); uint8_t v;
return *this; Read(&v, 1);
return v;
} }
FileRdr &operator>> (int8_t &v) int8_t ReadInt8()
{ {
mReader->Read(&v, 1); int8_t v;
return *this; Read(&v, 1);
return v;
} }
FileRdr &operator>> (uint16_t &v) uint16_t ReadUInt16()
{ {
mReader->Read(&v, 2); uint16_t v;
v = LittleShort(v); Read(&v, 2);
return *this; return LittleShort(v);
} }
FileRdr &operator>> (int16_t &v) int16_t ReadInt16()
{ {
mReader->Read(&v, 2); uint16_t v;
v = LittleShort(v); Read(&v, 2);
return *this; return LittleShort(v);
} }
FileRdr &operator>> (uint32_t &v) uint32_t ReadUInt32()
{ {
mReader->Read(&v, 4); uint32_t v;
v = LittleLong(v); Read(&v, 4);
return *this; return LittleLong(v);
} }
FileRdr &operator>> (int32_t &v) int32_t ReadInt32()
{ {
mReader->Read(&v, 4); uint32_t v;
v = LittleLong(v); Read(&v, 4);
return *this; return LittleLong(v);
} }
uint32_t ReadUInt32BE()
{
uint32_t v;
Read(&v, 4);
return BigLong(v);
}
int32_t ReadInt32BE()
{
uint32_t v;
Read(&v, 4);
return BigLong(v);
}
friend class FWadCollection; friend class FWadCollection;
}; };

View file

@ -842,9 +842,9 @@ void P_LoadVertexes (MapData * map)
// Copy and convert vertex coordinates, internal representation as fixed. // Copy and convert vertex coordinates, internal representation as fixed.
for (auto &v : level.vertexes) for (auto &v : level.vertexes)
{ {
int16_t x, y; int16_t x = fr.ReadInt16();
int16_t y = fr.ReadInt16();
fr >> x >> y;
v.set(double(x), double(y)); v.set(double(x), double(y));
} }
} }
@ -860,11 +860,10 @@ void P_LoadZSegs (FileRdr &data)
for (auto &seg : level.segs) for (auto &seg : level.segs)
{ {
line_t *ldef; line_t *ldef;
uint32_t v1, v2; uint32_t v1 = data.ReadUInt32();
uint16_t line; uint32_t v2 = data.ReadUInt32();
uint8_t side; uint16_t line = data.ReadUInt16();
uint8_t side = data.ReadUInt8();
data >> v1 >> v2 >> line >> side;
seg.v1 = &level.vertexes[v1]; seg.v1 = &level.vertexes[v1];
seg.v2 = &level.vertexes[v2]; seg.v2 = &level.vertexes[v2];
@ -899,22 +898,20 @@ void P_LoadGLZSegs (FileRdr &data, int type)
for (size_t j = 0; j < level.subsectors[i].numlines; ++j) for (size_t j = 0; j < level.subsectors[i].numlines; ++j)
{ {
seg_t *seg; seg_t *seg;
uint32_t v1, partner; uint32_t v1 = data.ReadUInt32();
uint32_t partner = data.ReadUInt32();
uint32_t line; uint32_t line;
uint16_t lineword;
uint8_t side;
data >> v1 >> partner;
if (type >= 2) if (type >= 2)
{ {
data >> line; line = data.ReadUInt32();
} }
else else
{ {
data >> lineword; line = data.ReadUInt16();
line = lineword == 0xFFFF ? 0xFFFFFFFF : lineword; if (line == 0xffff) line = 0xffffffff;
} }
data >> side; uint8_t side = data.ReadUInt8();
seg = level.subsectors[i].firstline + j; seg = level.subsectors[i].firstline + j;
seg->v1 = &level.vertexes[v1]; seg->v1 = &level.vertexes[v1];
@ -964,10 +961,10 @@ void P_LoadGLZSegs (FileRdr &data, int type)
void LoadZNodes(FileRdr &data, int glnodes) void LoadZNodes(FileRdr &data, int glnodes)
{ {
// Read extra vertices added during node building // Read extra vertices added during node building
uint32_t orgVerts, newVerts;
unsigned int i; unsigned int i;
data >> orgVerts >> newVerts; uint32_t orgVerts = data.ReadUInt32();
uint32_t newVerts = data.ReadUInt32();
if (orgVerts > level.vertexes.Size()) if (orgVerts > level.vertexes.Size())
{ // These nodes are based on a map with more vertex data than we have. { // These nodes are based on a map with more vertex data than we have.
// We can't use them. // We can't use them.
@ -980,8 +977,8 @@ void LoadZNodes(FileRdr &data, int glnodes)
} }
for (i = 0; i < newVerts; ++i) for (i = 0; i < newVerts; ++i)
{ {
int32_t x, y; fixed_t x = data.ReadInt32();
data >> x >> y; fixed_t y = data.ReadInt32();
level.vertexes[i + orgVerts].set(x, y); level.vertexes[i + orgVerts].set(x, y);
} }
if (oldvertexes != &level.vertexes[0]) if (oldvertexes != &level.vertexes[0])
@ -994,26 +991,21 @@ void LoadZNodes(FileRdr &data, int glnodes)
} }
// Read the subsectors // Read the subsectors
uint32_t numSubs, currSeg; uint32_t currSeg;
uint32_t numSubs = data.ReadUInt32();
data >> numSubs;
level.subsectors.Alloc(numSubs); level.subsectors.Alloc(numSubs);
memset (&level.subsectors[0], 0, level.subsectors.Size()*sizeof(subsector_t)); memset (&level.subsectors[0], 0, level.subsectors.Size()*sizeof(subsector_t));
for (i = currSeg = 0; i < numSubs; ++i) for (i = currSeg = 0; i < numSubs; ++i)
{ {
uint32_t numsegs; uint32_t numsegs = data.ReadUInt32();
data >> numsegs;
level.subsectors[i].firstline = (seg_t *)(size_t)currSeg; // Oh damn. I should have stored the seg count sooner. level.subsectors[i].firstline = (seg_t *)(size_t)currSeg; // Oh damn. I should have stored the seg count sooner.
level.subsectors[i].numlines = numsegs; level.subsectors[i].numlines = numsegs;
currSeg += numsegs; currSeg += numsegs;
} }
// Read the segs // Read the segs
uint32_t numSegs; uint32_t numSegs = data.ReadUInt32();
data >> numSegs;
// The number of segs stored should match the number of // The number of segs stored should match the number of
// segs used by subsectors. // segs used by subsectors.
@ -1040,9 +1032,8 @@ void LoadZNodes(FileRdr &data, int glnodes)
} }
// Read nodes // Read nodes
uint32_t numNodes; uint32_t numNodes = data.ReadUInt32();
data >> numNodes;
auto &nodes = level.nodes; auto &nodes = level.nodes;
nodes.Alloc(numNodes); nodes.Alloc(numNodes);
memset (&nodes[0], 0, sizeof(node_t)*numNodes); memset (&nodes[0], 0, sizeof(node_t)*numNodes);
@ -1051,31 +1042,28 @@ void LoadZNodes(FileRdr &data, int glnodes)
{ {
if (glnodes < 3) if (glnodes < 3)
{ {
int16_t x, y, dx, dy; nodes[i].x = data.ReadInt16() * FRACUNIT;
nodes[i].y = data.ReadInt16() * FRACUNIT;
data >> x >> y >> dx >> dy; nodes[i].dx = data.ReadInt16() * FRACUNIT;
nodes[i].x = x << FRACBITS; nodes[i].dy = data.ReadInt16() * FRACUNIT;
nodes[i].y = y << FRACBITS;
nodes[i].dx = dx << FRACBITS;
nodes[i].dy = dy << FRACBITS;
} }
else else
{ {
data >> nodes[i].x >> nodes[i].y >> nodes[i].dx >> nodes[i].dy; nodes[i].x = data.ReadInt32();
nodes[i].y = data.ReadInt32();
nodes[i].dx = data.ReadInt32();
nodes[i].dy = data.ReadInt32();
} }
for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j)
{ {
for (int k = 0; k < 4; ++k) for (int k = 0; k < 4; ++k)
{ {
int16_t coord; nodes[i].bbox[j][k] = data.ReadInt16();
data >> coord;
nodes[i].bbox[j][k] = coord;
} }
} }
for (int m = 0; m < 2; ++m) for (int m = 0; m < 2; ++m)
{ {
uint32_t child; uint32_t child = data.ReadUInt32();
data >> child;
if (child & 0x80000000) if (child & 0x80000000)
{ {
nodes[i].children[m] = (uint8_t *)&level.subsectors[child & 0x7FFFFFFF] + 1; nodes[i].children[m] = (uint8_t *)&level.subsectors[child & 0x7FFFFFFF] + 1;
@ -1399,7 +1387,8 @@ void P_LoadSubsectors (MapData * map)
{ {
subsectortype subd; subsectortype subd;
fr >> subd.numsegs >> subd.firstseg; subd.numsegs = sizeof(subd.numsegs) == 2 ? fr.ReadUInt16() : fr.ReadUInt32();
subd.firstseg = sizeof(subd.firstseg) == 2 ? fr.ReadUInt16() : fr.ReadUInt32();
if (subd.numsegs == 0) if (subd.numsegs == 0)
{ {

View file

@ -1520,8 +1520,7 @@ void SFFile::LoadSample(SFSample *sample)
// Load 16-bit sample data. // Load 16-bit sample data.
for (i = 0; i < sample->End - sample->Start; ++i) for (i = 0; i < sample->End - sample->Start; ++i)
{ {
int16_t samp; int16_t samp = fp.ReadInt16();
fp >> samp;
sample->InMemoryData[i] = samp / 32768.f; sample->InMemoryData[i] = samp / 32768.f;
} }
if (SampleDataLSBOffset != 0) if (SampleDataLSBOffset != 0)
@ -1529,8 +1528,7 @@ void SFFile::LoadSample(SFSample *sample)
fp.Seek(SampleDataLSBOffset + sample->Start, FileRdr::SeekSet); fp.Seek(SampleDataLSBOffset + sample->Start, FileRdr::SeekSet);
for (i = 0; i < sample->End - sample->Start; ++i) for (i = 0; i < sample->End - sample->Start; ++i)
{ {
uint8_t samp; uint8_t samp = fp.ReadUInt8();
fp >> samp;
sample->InMemoryData[i] = ((((int32_t(sample->InMemoryData[i] * 32768) << 8) | samp) << 8) >> 8) / 8388608.f; sample->InMemoryData[i] = ((((int32_t(sample->InMemoryData[i] * 32768) << 8) | samp) << 8) >> 8) / 8388608.f;
} }
} }

View file

@ -92,7 +92,10 @@ FTexture *IMGZTexture_TryCreate(FileRdr & file, int lumpnum)
file.Seek(0, FileRdr::SeekSet); file.Seek(0, FileRdr::SeekSet);
if (file.Read(&magic, 4) != 4) return NULL; if (file.Read(&magic, 4) != 4) return NULL;
if (magic != MAKE_ID('I','M','G','Z')) return NULL; if (magic != MAKE_ID('I','M','G','Z')) return NULL;
file >> w >> h >> l >> t; w = file.ReadUInt16();
h = file.ReadUInt16();
l = file.ReadInt16();
t = file.ReadInt16();
return new FIMGZTexture(lumpnum, w, h, l, t); return new FIMGZTexture(lumpnum, w, h, l, t);
} }

View file

@ -814,9 +814,8 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
} }
{ {
auto pnames = Wads.OpenLumpReader (patcheslump); auto pnames = Wads.OpenLumpReader(patcheslump);
numpatches = pnames.ReadUInt32();
pnames >> numpatches;
// Check whether the amount of names reported is correct. // Check whether the amount of names reported is correct.
if ((signed)numpatches < 0) if ((signed)numpatches < 0)

View file

@ -135,7 +135,10 @@ FTexture *PatchTexture_TryCreate(FileRdr & file, int lumpnum)
if (!CheckIfPatch(file)) return NULL; if (!CheckIfPatch(file)) return NULL;
file.Seek(0, FileRdr::SeekSet); file.Seek(0, FileRdr::SeekSet);
file >> header.width >> header.height >> header.leftoffset >> header.topoffset; header.width = file.ReadUInt16();
header.height = file.ReadUInt16();
header.leftoffset = file.ReadInt16();
header.topoffset = file.ReadInt16();
return new FPatchTexture(lumpnum, &header); return new FPatchTexture(lumpnum, &header);
} }

View file

@ -493,15 +493,15 @@ void FPCXTexture::MakeTexture()
} }
else if (bitcount == 8) else if (bitcount == 8)
{ {
uint8_t c;
lump.Seek(-769, FileRdr::SeekEnd); lump.Seek(-769, FileRdr::SeekEnd);
lump >> c; uint8_t c = lump.ReadUInt8();
//if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette //if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette
//else //else
for(int i=0;i<256;i++) for(int i=0;i<256;i++)
{ {
uint8_t r,g,b; uint8_t r = lump.ReadUInt8();
lump >> r >> g >> b; uint8_t g = lump.ReadUInt8();
uint8_t b = lump.ReadUInt8();
PaletteMap[i] = ColorMatcher.Pick(r,g,b); PaletteMap[i] = ColorMatcher.Pick(r,g,b);
} }
lump.Seek(sizeof(header), FileRdr::SeekSet); lump.Seek(sizeof(header), FileRdr::SeekSet);
@ -582,9 +582,8 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
} }
else if (bitcount == 8) else if (bitcount == 8)
{ {
uint8_t c;
lump.Seek(-769, FileRdr::SeekEnd); lump.Seek(-769, FileRdr::SeekEnd);
lump >> c; uint8_t c = lump.ReadUInt8();
c=0x0c; // Apparently there's many non-compliant PCXs out there... c=0x0c; // Apparently there's many non-compliant PCXs out there...
if (c !=0x0c) if (c !=0x0c)
{ {
@ -592,8 +591,9 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
} }
else for(int i=0;i<256;i++) else for(int i=0;i<256;i++)
{ {
uint8_t r,g,b; uint8_t r = lump.ReadUInt8();
lump >> r >> g >> b; uint8_t g = lump.ReadUInt8();
uint8_t b = lump.ReadUInt8();
pe[i] = PalEntry(255, r,g,b); pe[i] = PalEntry(255, r,g,b);
} }
lump.Seek(sizeof(header), FileRdr::SeekSet); lump.Seek(sizeof(header), FileRdr::SeekSet);

View file

@ -99,8 +99,6 @@ FTexture *PNGTexture_TryCreate(FileRdr & data, int lumpnum)
uint8_t b[4]; uint8_t b[4];
} first4bytes; } first4bytes;
uint32_t width, height;
uint8_t bitdepth, colortype, compression, filter, interlace;
// This is most likely a PNG, but make sure. (Note that if the // This is most likely a PNG, but make sure. (Note that if the
// first 4 bytes match, but later bytes don't, we assume it's // first 4 bytes match, but later bytes don't, we assume it's
@ -118,9 +116,13 @@ FTexture *PNGTexture_TryCreate(FileRdr & data, int lumpnum)
// The PNG looks valid so far. Check the IHDR to make sure it's a // The PNG looks valid so far. Check the IHDR to make sure it's a
// type of PNG we support. // type of PNG we support.
data.Read(&width, 4); int width = data.ReadInt32BE();
data.Read(&height, 4); int height = data.ReadInt32BE();
data >> bitdepth >> colortype >> compression >> filter >> interlace; uint8_t bitdepth = data.ReadUInt8();
uint8_t colortype = data.ReadUInt8();
uint8_t compression = data.ReadUInt8();
uint8_t filter = data.ReadUInt8();
uint8_t interlace = data.ReadUInt8();
if (compression != 0 || filter != 0 || interlace > 1) if (compression != 0 || filter != 0 || interlace > 1)
{ {
@ -147,8 +149,7 @@ FTexture *PNGTexture_TryCreate(FileRdr & data, int lumpnum)
} }
} }
return new FPNGTexture (data, lumpnum, FString(), BigLong((int)width), BigLong((int)height), return new FPNGTexture (data, lumpnum, FString(), width, height, bitdepth, colortype, interlace);
bitdepth, colortype, interlace);
} }
//========================================================================== //==========================================================================
@ -159,8 +160,6 @@ FTexture *PNGTexture_TryCreate(FileRdr & data, int lumpnum)
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename) FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
{ {
uint32_t width, height;
uint8_t bitdepth, colortype, compression, filter, interlace;
if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0) if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0)
{ {
@ -168,9 +167,14 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
} }
// Check the IHDR to make sure it's a type of PNG we support. // Check the IHDR to make sure it's a type of PNG we support.
png->File.Read(&width, 4); auto &data = png->File;
png->File.Read(&height, 4); int width = data.ReadInt32BE();
png->File >> bitdepth >> colortype >> compression >> filter >> interlace; int height = data.ReadInt32BE();
uint8_t bitdepth = data.ReadUInt8();
uint8_t colortype = data.ReadUInt8();
uint8_t compression = data.ReadUInt8();
uint8_t filter = data.ReadUInt8();
uint8_t interlace = data.ReadUInt8();
if (compression != 0 || filter != 0 || interlace > 1) if (compression != 0 || filter != 0 || interlace > 1)
{ {
@ -185,8 +189,7 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
return NULL; return NULL;
} }
return new FPNGTexture (png->File, -1, filename, BigLong((int)width), BigLong((int)height), return new FPNGTexture (png->File, -1, filename, width, height, bitdepth, colortype, interlace);
bitdepth, colortype, interlace);
} }
//========================================================================== //==========================================================================
@ -651,7 +654,9 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
case MAKE_ID('P','L','T','E'): case MAKE_ID('P','L','T','E'):
for(int i = 0; i < PaletteSize; i++) for(int i = 0; i < PaletteSize; i++)
{ {
(*lump) >> pe[i].r >> pe[i].g >> pe[i].b; pe[i].r = lump->ReadUInt8();
pe[i].g = lump->ReadUInt8();
pe[i].b = lump->ReadUInt8();
} }
break; break;
@ -660,7 +665,7 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
{ {
for(uint32_t i = 0; i < len; i++) for(uint32_t i = 0; i < len; i++)
{ {
(*lump) >> pe[i].a; pe[i].a = lump->ReadUInt8();
if (pe[i].a != 0 && pe[i].a != 255) if (pe[i].a != 0 && pe[i].a != 255)
transpal = true; transpal = true;
} }

View file

@ -768,7 +768,7 @@ void FTextureManager::AddPatches (int lumpnum)
uint32_t numpatches, i; uint32_t numpatches, i;
char name[9]; char name[9];
file >> numpatches; numpatches = file.ReadUInt32();
name[8] = '\0'; name[8] = '\0';
for (i = 0; i < numpatches; ++i) for (i = 0; i < numpatches; ++i)
@ -1186,9 +1186,8 @@ int FTextureManager::CountLumpTextures (int lumpnum)
if (lumpnum >= 0) if (lumpnum >= 0)
{ {
auto file = Wads.OpenLumpReader (lumpnum); auto file = Wads.OpenLumpReader (lumpnum);
uint32_t numtex; uint32_t numtex = file.ReadUInt32();;
file >> numtex;
return int(numtex) >= 0 ? numtex : 0; return int(numtex) >= 0 ? numtex : 0;
} }
return 0; return 0;

View file

@ -252,13 +252,12 @@ const uint8_t *FTGATexture::GetPixels ()
void FTGATexture::ReadCompressed(FileRdr &lump, uint8_t * buffer, int bytesperpixel) void FTGATexture::ReadCompressed(FileRdr &lump, uint8_t * buffer, int bytesperpixel)
{ {
uint8_t b;
uint8_t data[4]; uint8_t data[4];
int Size = Width * Height; int Size = Width * Height;
while (Size > 0) while (Size > 0)
{ {
lump >> b; uint8_t b = lump.ReadUInt8();
if (b & 128) if (b & 128)
{ {
b&=~128; b&=~128;
@ -314,7 +313,7 @@ void FTGATexture::MakeTexture ()
{ {
case 15: case 15:
case 16: case 16:
lump >> w; w = lump.ReadUInt16();
r = (w & 0x001F) << 3; r = (w & 0x001F) << 3;
g = (w & 0x03E0) >> 2; g = (w & 0x03E0) >> 2;
b = (w & 0x7C00) >> 7; b = (w & 0x7C00) >> 7;
@ -322,12 +321,17 @@ void FTGATexture::MakeTexture ()
break; break;
case 24: case 24:
lump >> b >> g >> r; b = lump.ReadUInt8();
g = lump.ReadUInt8();
r = lump.ReadUInt8();
a=255; a=255;
break; break;
case 32: case 32:
lump >> b >> g >> r >> a; b = lump.ReadUInt8();
g = lump.ReadUInt8();
r = lump.ReadUInt8();
a = lump.ReadUInt8();
if ((hdr.img_desc&15)!=8) a=255; if ((hdr.img_desc&15)!=8) a=255;
break; break;
@ -515,24 +519,29 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
{ {
case 15: case 15:
case 16: case 16:
lump >> w; w = lump.ReadUInt16();
r = (w & 0x001F) << 3; r = (w & 0x001F) << 3;
g = (w & 0x03E0) >> 2; g = (w & 0x03E0) >> 2;
b = (w & 0x7C00) >> 7; b = (w & 0x7C00) >> 7;
a = 255; a = 255;
break; break;
case 24: case 24:
lump >> b >> g >> r; b = lump.ReadUInt8();
a=255; g = lump.ReadUInt8();
r = lump.ReadUInt8();
a = 255;
break; break;
case 32: case 32:
lump >> b >> g >> r >> a; b = lump.ReadUInt8();
if ((hdr.img_desc&15)!=8) a=255; g = lump.ReadUInt8();
else if (a!=0 && a!=255) transval = true; r = lump.ReadUInt8();
a = lump.ReadUInt8();
if ((hdr.img_desc & 15) != 8) a = 255;
else if (a != 0 && a != 255) transval = true;
break; break;
default: // should never happen default: // should never happen
r=g=b=a=0; r=g=b=a=0;
break; break;

View file

@ -1899,9 +1899,7 @@ void FFontChar2::MakeTexture ()
{ {
if (runlen != 0) if (runlen != 0)
{ {
uint8_t color; uint8_t color = lump.ReadUInt8();
lump >> color;
color = MIN (color, max); color = MIN (color, max);
if (SourceRemap != NULL) if (SourceRemap != NULL)
{ {
@ -1921,18 +1919,14 @@ void FFontChar2::MakeTexture ()
} }
else else
{ {
int8_t code; int8_t code = lump.ReadInt8();
lump >> code;
if (code >= 0) if (code >= 0)
{ {
runlen = code + 1; runlen = code + 1;
} }
else if (code != -128) else if (code != -128)
{ {
uint8_t color; uint8_t color = lump.ReadUInt8();
lump >> color;
setlen = (-code) + 1; setlen = (-code) + 1;
setval = MIN (color, max); setval = MIN (color, max);
if (SourceRemap != NULL) if (SourceRemap != NULL)
@ -1951,8 +1945,7 @@ void FFontChar2::MakeTexture ()
{ {
for (int x = Width; x != 0; --x) for (int x = Width; x != 0; --x)
{ {
uint8_t color; uint8_t color = lump.ReadUInt8();
lump >> color;
if (color > max) if (color > max)
{ {
color = max; color = max;