From cd25b4be4f4667456f68aa2f3f80b09cf9903f6c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 10:04:49 +0100 Subject: [PATCH 1/6] - use a TArray to store the particles and remove all 16 bit global variables. This means one less exit function to deal with - and these days 16 bit variables are a pointless attempt at saving space. --- src/p_effect.cpp | 45 +++++++++----------------- src/p_effect.h | 2 +- src/polyrenderer/scene/poly_scene.cpp | 2 +- src/swrenderer/scene/r_opaque_pass.cpp | 2 +- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index aeb5b0ec88..da43890c5d 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -59,10 +59,9 @@ FRandom pr_railtrail("RailTrail"); #define FADEFROMTTL(a) (1.f/(a)) // [RH] particle globals -uint16_t NumParticles; -uint16_t ActiveParticles; -uint16_t InactiveParticles; -particle_t *Particles; +uint32_t ActiveParticles; +uint32_t InactiveParticles; +TArray Particles; TArray ParticlesInSubsec; static int grey1, grey2, grey3, grey4, red, green, blue, yellow, black, @@ -105,13 +104,13 @@ static const struct ColorList { inline particle_t *NewParticle (void) { - particle_t *result = NULL; + particle_t *result = nullptr; if (InactiveParticles != NO_PARTICLE) { - result = Particles + InactiveParticles; + result = &Particles[InactiveParticles]; InactiveParticles = result->tnext; result->tnext = ActiveParticles; - ActiveParticles = uint16_t(result - Particles); + ActiveParticles = uint32_t(result - Particles.Data()); } return result; } @@ -120,7 +119,6 @@ inline particle_t *NewParticle (void) // [RH] Particle functions // void P_InitParticles (); -void P_DeinitParticles (); // [BC] Allow the maximum number of particles to be specified by a cvar (so people // with lots of nice hardware can have lots of particles!). @@ -135,7 +133,6 @@ CUSTOM_CVAR( Int, r_maxparticles, 4000, CVAR_ARCHIVE ) if ( gamestate != GS_STARTUP ) { - P_DeinitParticles( ); P_InitParticles( ); } } @@ -152,33 +149,21 @@ void P_InitParticles () num = r_maxparticles; // This should be good, but eh... - NumParticles = (uint16_t)clamp(num, 100, 65535); + int NumParticles = clamp(num, 100, 65535); - P_DeinitParticles(); - Particles = new particle_t[NumParticles]; + Particles.Resize(NumParticles); P_ClearParticles (); - atterm (P_DeinitParticles); -} - -void P_DeinitParticles() -{ - if (Particles != NULL) - { - delete[] Particles; - Particles = NULL; - } } void P_ClearParticles () { - int i; - - memset (Particles, 0, NumParticles * sizeof(particle_t)); + int i = 0; + memset (Particles.Data(), 0, Particles.Size() * sizeof(particle_t)); ActiveParticles = NO_PARTICLE; InactiveParticles = 0; - for (i = 0; i < NumParticles-1; i++) - Particles[i].tnext = i + 1; - Particles[i].tnext = NO_PARTICLE; + for (auto &p : Particles) + p.tnext = ++i; + Particles.Last().tnext = NO_PARTICLE; } // Group particles by subsectors. Because particles are always @@ -255,7 +240,7 @@ void P_ThinkParticles () prev = NULL; while (i != NO_PARTICLE) { - particle = Particles + i; + particle = &Particles[i]; i = particle->tnext; if (!particle->notimefreeze && ((bglobal.freeze) || (level.flags2 & LEVEL2_FROZEN))) { @@ -274,7 +259,7 @@ void P_ThinkParticles () else ActiveParticles = i; particle->tnext = InactiveParticles; - InactiveParticles = (int)(particle - Particles); + InactiveParticles = (int)(particle - Particles.Data()); continue; } diff --git a/src/p_effect.h b/src/p_effect.h index 4620bfa5a9..00689118ac 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -62,7 +62,7 @@ struct particle_t uint16_t snext; }; -extern particle_t *Particles; +extern TArray Particles; extern TArray ParticlesInSubsec; const uint16_t NO_PARTICLE = 0xffff; diff --git a/src/polyrenderer/scene/poly_scene.cpp b/src/polyrenderer/scene/poly_scene.cpp index 2f5e367023..f92c73762e 100644 --- a/src/polyrenderer/scene/poly_scene.cpp +++ b/src/polyrenderer/scene/poly_scene.cpp @@ -189,7 +189,7 @@ void RenderPolyScene::RenderSubsector(PolyRenderThread *thread, subsector_t *sub int subsectorIndex = sub->Index(); for (int i = ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Particles[i].snext) { - particle_t *particle = Particles + i; + particle_t *particle = &Particles[i]; thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject(particle, sub, subsectorDepth, CurrentViewpoint->StencilValue)); } } diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 1b03361ef1..cff29cbb43 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -616,7 +616,7 @@ namespace swrenderer int shade = LightVisibility::LightLevelToShade((floorlightlevel + ceilinglightlevel) / 2 + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy); for (int i = ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Particles[i].snext) { - RenderParticle::Project(Thread, Particles + i, sub->sector, shade, FakeSide, foggy); + RenderParticle::Project(Thread, &Particles[i], sub->sector, shade, FakeSide, foggy); } } From 48d87e3dcf961d2643d7ed618c7689786355c4d3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 11:55:21 +0100 Subject: [PATCH 2/6] - use TArrays for most buffers being used in the font class. --- src/v_font.cpp | 89 +++++++++++++++++--------------------------------- src/v_font.h | 9 ++--- 2 files changed, 35 insertions(+), 63 deletions(-) diff --git a/src/v_font.cpp b/src/v_font.cpp index 560a47f571..4cccf32a47 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -310,16 +310,14 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, int i; FTextureID lump; char buffer[12]; - TArray charLumps; + TArray charLumps(count, true); int maxyoffs; bool doomtemplate = gameinfo.gametype & GAME_DoomChex ? strncmp (nametemplate, "STCFN", 5) == 0 : false; bool stcfn121 = false; noTranslate = notranslate; Lump = fdlump; - Chars = new CharData[count]; - charLumps.Resize(count); - PatchRemap = new uint8_t[256]; + Chars.Resize(count); FirstChar = first; LastChar = first + count - 1; FontHeight = 0; @@ -422,19 +420,6 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, FFont::~FFont () { - if (Chars) - { - int count = LastChar - FirstChar + 1; - - delete[] Chars; - Chars = NULL; - } - if (PatchRemap) - { - delete[] PatchRemap; - PatchRemap = NULL; - } - FFont **prev = &FirstFont; FFont *font = *prev; @@ -537,7 +522,7 @@ static int compare (const void *arg1, const void *arg2) // //========================================================================== -int FFont::SimpleTranslation (uint8_t *colorsused, uint8_t *translation, uint8_t *reverse, double **luminosity) +int FFont::SimpleTranslation (uint8_t *colorsused, uint8_t *translation, uint8_t *reverse, TArray &Luminosity) { double min, max, diver; int i, j; @@ -555,26 +540,26 @@ int FFont::SimpleTranslation (uint8_t *colorsused, uint8_t *translation, uint8_t qsort (reverse+1, j-1, 1, compare); - *luminosity = new double[j]; - (*luminosity)[0] = 0.0; // [BL] Prevent uninitalized memory + Luminosity.Resize(j); + Luminosity[0] = 0.0; // [BL] Prevent uninitalized memory max = 0.0; min = 100000000.0; for (i = 1; i < j; i++) { translation[reverse[i]] = i; - (*luminosity)[i] = RPART(GPalette.BaseColors[reverse[i]]) * 0.299 + + Luminosity[i] = RPART(GPalette.BaseColors[reverse[i]]) * 0.299 + GPART(GPalette.BaseColors[reverse[i]]) * 0.587 + BPART(GPalette.BaseColors[reverse[i]]) * 0.114; - if ((*luminosity)[i] > max) - max = (*luminosity)[i]; - if ((*luminosity)[i] < min) - min = (*luminosity)[i]; + if (Luminosity[i] > max) + max = Luminosity[i]; + if (Luminosity[i] < min) + min = Luminosity[i]; } diver = 1.0 / (max - min); for (i = 1; i < j; i++) { - (*luminosity)[i] = ((*luminosity)[i] - min) * diver; + Luminosity[i] = (Luminosity[i] - min) * diver; } return j; @@ -858,7 +843,7 @@ void FFont::LoadTranslations() { unsigned int count = LastChar - FirstChar + 1; uint8_t usedcolors[256], identity[256]; - double *luminosity; + TArray Luminosity; memset (usedcolors, 0, 256); for (unsigned int i = 0; i < count; i++) @@ -876,7 +861,7 @@ void FFont::LoadTranslations() // Fixme: This needs to build a translation based on the source palette, not some intermediate 'ordered' table. - ActiveColors = SimpleTranslation (usedcolors, PatchRemap, identity, &luminosity); + ActiveColors = SimpleTranslation (usedcolors, PatchRemap, identity, Luminosity); for (unsigned int i = 0; i < count; i++) { @@ -884,9 +869,7 @@ void FFont::LoadTranslations() static_cast(Chars[i].Pic->GetImage())->SetSourceRemap(PatchRemap); } - BuildTranslations (luminosity, identity, &TranslationParms[0][0], ActiveColors, NULL); - - delete[] luminosity; + BuildTranslations (Luminosity.Data(), identity, &TranslationParms[0][0], ActiveColors, NULL); } //========================================================================== @@ -898,8 +881,6 @@ void FFont::LoadTranslations() FFont::FFont (int lump) { Lump = lump; - Chars = NULL; - PatchRemap = NULL; FontName = NAME_None; Cursor = '_'; noTranslate = false; @@ -964,8 +945,8 @@ void FSingleLumpFont::CreateFontFromPic (FTextureID picnum) GlobalKerning = 0; FirstChar = LastChar = 'A'; - Chars = new CharData[1]; - Chars->Pic = pic; + Chars.Resize(1); + Chars[0].Pic = pic; // Only one color range. Don't bother with the others. ActiveColors = 0; @@ -1030,7 +1011,7 @@ void FSingleLumpFont::LoadFON1 (int lump, const uint8_t *data) { int w, h; - Chars = new CharData[256]; + Chars.Resize(256); w = data[4] + data[5]*256; h = data[6] + data[7]*256; @@ -1042,10 +1023,9 @@ void FSingleLumpFont::LoadFON1 (int lump, const uint8_t *data) LastChar = 255; GlobalKerning = 0; translateUntranslated = true; - PatchRemap = new uint8_t[256]; for(unsigned int i = 0;i < 256;++i) - Chars[i].Pic = NULL; + Chars[i].Pic = nullptr; LoadTranslations(); } @@ -1062,7 +1042,6 @@ void FSingleLumpFont::LoadFON1 (int lump, const uint8_t *data) void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data) { int count, i, totalwidth; - int *widths2; uint16_t *widths; const uint8_t *palette; const uint8_t *data_p; @@ -1072,12 +1051,11 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data) FirstChar = data[6]; LastChar = data[7]; ActiveColors = data[10]+1; - PatchRemap = NULL; RescalePalette = data[9] == 0; count = LastChar - FirstChar + 1; - Chars = new CharData[count]; - widths2 = new int[count]; + Chars.Resize(count); + TArray widths2(count, true); if (data[11] & 1) { // Font specifies a kerning value. GlobalKerning = LittleShort(*(int16_t *)&data[12]); @@ -1162,7 +1140,6 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data) } LoadTranslations(); - delete[] widths2; } //========================================================================== @@ -1221,7 +1198,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) I_FatalError("BMF font defines no characters"); } count = LastChar - FirstChar + 1; - Chars = new CharData[count]; + Chars.Resize(count); for (i = 0; i < count; ++i) { Chars[i].Pic = NULL; @@ -1247,7 +1224,6 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) qsort(sort_palette + 1, ActiveColors - 1, sizeof(PalEntry), BMFCompare); // Create the PatchRemap table from the sorted "alpha" values. - PatchRemap = new uint8_t[ActiveColors]; PatchRemap[0] = 0; for (i = 1; i < ActiveColors; ++i) { @@ -1515,10 +1491,11 @@ int FSinglePicFont::GetCharWidth (int code) const // //========================================================================== -FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate) : FFont(lump) +FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate) + : FFont(lump) { int i; - FTexture **charlumps; + TArray charlumps(count, true); int maxyoffs; FTexture *pic; @@ -1526,9 +1503,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l noTranslate = donttranslate; FontName = name; - Chars = new CharData[count]; - charlumps = new FTexture*[count]; - PatchRemap = new uint8_t[256]; + Chars.Resize(count); FirstChar = first; LastChar = first + count - 1; FontHeight = 0; @@ -1541,7 +1516,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l for (i = 0; i < count; i++) { pic = charlumps[i] = lumplist[i]; - if (pic != NULL) + if (pic != nullptr) { int height = pic->GetDisplayHeight(); int yoffs = pic->GetDisplayTopOffset(); @@ -1557,7 +1532,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l } } - if (charlumps[i] != NULL) + if (charlumps[i] != nullptr) { if (!noTranslate) { @@ -1594,8 +1569,6 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l { LoadTranslations(); } - - delete[] charlumps; } //========================================================================== @@ -1608,7 +1581,7 @@ void FSpecialFont::LoadTranslations() { int count = LastChar - FirstChar + 1; uint8_t usedcolors[256], identity[256]; - double *luminosity; + TArray Luminosity; int TotalColors; int i, j; @@ -1631,7 +1604,7 @@ void FSpecialFont::LoadTranslations() if (notranslate[i]) usedcolors[i] = false; - TotalColors = ActiveColors = SimpleTranslation (usedcolors, PatchRemap, identity, &luminosity); + TotalColors = ActiveColors = SimpleTranslation (usedcolors, PatchRemap, identity, Luminosity); // Map all untranslated colors into the table of used colors for (i = 0; i < 256; i++) @@ -1650,7 +1623,7 @@ void FSpecialFont::LoadTranslations() static_cast(Chars[i].Pic->GetImage())->SetSourceRemap(PatchRemap); } - BuildTranslations (luminosity, identity, &TranslationParms[0][0], TotalColors, NULL); + BuildTranslations (Luminosity.Data(), identity, &TranslationParms[0][0], TotalColors, NULL); // add the untranslated colors to the Ranges tables if (ActiveColors < TotalColors) @@ -1667,8 +1640,6 @@ void FSpecialFont::LoadTranslations() } } ActiveColors = TotalColors; - - delete[] luminosity; } //========================================================================== diff --git a/src/v_font.h b/src/v_font.h index 907c3e1f8a..4bc20884ee 100644 --- a/src/v_font.h +++ b/src/v_font.h @@ -82,7 +82,7 @@ public: FFont (const char *fontname, const char *nametemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false); virtual ~FFont (); - virtual FTexture *GetChar (int code, int *const width) const; + FTexture *GetChar (int code, int *const width) const; virtual int GetCharWidth (int code) const; FRemapTable *GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const; int GetLump() const { return Lump; } @@ -112,7 +112,7 @@ protected: void FixXMoves(); static int SimpleTranslation (uint8_t *colorsused, uint8_t *translation, - uint8_t *identity, double **luminosity); + uint8_t *identity, TArray &Luminosity); int FirstChar, LastChar; int SpaceWidth; @@ -125,10 +125,11 @@ protected: { FTexture *Pic; int XMove; - } *Chars; + }; + TArray Chars; int ActiveColors; TArray Ranges; - uint8_t *PatchRemap; + uint8_t PatchRemap[256]; int Lump; FName FontName = NAME_None; From 056b2c3a800cc9155379e578bb7608466d105bf3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 14:25:30 +0100 Subject: [PATCH 3/6] - handle CR_UNTRANSLATED so that it doesn't force CR_UNTRANSLATED to the palette. Since the entire font setup is very much incapable of handling this during rendering, short of a complete rewrite, it was necessary to put the relevant code into the places which process the characters for drawing so that it can disable the translation table (which needs to be passed as raw data to the draw functions) and keep track of both the translatable and the original variant of the character graphics. --- src/g_statusbar/sbarinfo.cpp | 3 +- src/g_statusbar/shared_sbar.cpp | 2 +- src/intermission/intermission.cpp | 2 +- src/v_font.cpp | 151 +++++++++++++++++------------- src/v_font.h | 5 +- src/v_text.cpp | 14 ++- 6 files changed, 100 insertions(+), 77 deletions(-) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index aade1b1f91..7b1184cec0 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -1379,7 +1379,8 @@ public: width = font->GetCharWidth((unsigned char) *str); else width = font->GetCharWidth((unsigned char) script->spacingCharacter); - FTexture* c = font->GetChar((unsigned char) *str, &width); + bool redirected = false; + FTexture* c = font->GetChar((unsigned char) *str, fontcolor, &width); if(c == NULL) //missing character. { str++; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 1ed349d3a4..12b66bf889 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -1513,7 +1513,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d } int width; - FTexture* c = font->GetChar((unsigned char)ch, &width); + FTexture* c = font->GetChar((unsigned char)ch, fontcolor, &width); if (c == NULL) //missing character. { continue; diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index e4cd6ac302..4b3826261d 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -337,7 +337,7 @@ void DIntermissionScreenText::Drawer () continue; } - pic = SmallFont->GetChar (c, &w); + pic = SmallFont->GetChar (c, mTextColor, &w); w += kerning; w *= CleanXfac; if (cx + w > SCREENWIDTH) diff --git a/src/v_font.cpp b/src/v_font.cpp index 4cccf32a47..e1e5998ba2 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -195,7 +195,7 @@ extern int PrintColors[]; // PUBLIC DATA DEFINITIONS ------------------------------------------------- -FFont *FFont::FirstFont = NULL; +FFont *FFont::FirstFont = nullptr; int NumTextColors; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -266,7 +266,7 @@ static int stripaccent(int code) FFont *V_GetFont(const char *name) { FFont *font = FFont::FindFont (name); - if (font == NULL) + if (font == nullptr) { int lump = -1; @@ -285,7 +285,7 @@ FFont *V_GetFont(const char *name) font = new FSingleLumpFont (name, lump); } } - if (font == NULL) + if (font == nullptr) { FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any); if (picnum.isValid()) @@ -327,13 +327,15 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, FirstFont = this; Cursor = '_'; ActiveColors = 0; + uint8_t pp = 0; + for (auto &p : PatchRemap) p = pp++; translateUntranslated = false; maxyoffs = 0; for (i = 0; i < count; i++) { - charLumps[i] = NULL; + charLumps[i] = nullptr; mysnprintf (buffer, countof(buffer), nametemplate, i + start); lump = TexMan.CheckForTexture(buffer, ETextureType::MiscPatch); @@ -356,7 +358,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, if (lump.isValid()) { FTexture *pic = TexMan.GetTexture(lump); - if (pic != NULL) + if (pic != nullptr) { // set the lump here only if it represents a valid texture if (i != 124-start || !stcfn121) @@ -379,17 +381,20 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, if (charLumps[i] != nullptr) { + Chars[i].OriginalPic = charLumps[i]; + if (!noTranslate) { - Chars[i].Pic = new FImageTexture(new FFontChar1 (charLumps[i]->GetImage())); - TexMan.AddTexture(Chars[i].Pic); + Chars[i].TranslatedPic = new FImageTexture(new FFontChar1 (charLumps[i]->GetImage()), ""); + TexMan.AddTexture(Chars[i].TranslatedPic); } - else Chars[i].Pic = charLumps[i]; - Chars[i].XMove = Chars[i].Pic->GetDisplayWidth(); + else Chars[i].TranslatedPic = charLumps[i]; + + Chars[i].XMove = Chars[i].OriginalPic->GetDisplayWidth(); } else { - Chars[i].Pic = NULL; + Chars[i].TranslatedPic = Chars[i].OriginalPic = nullptr; Chars[i].XMove = INT_MIN; } } @@ -398,7 +403,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, { SpaceWidth = spacewidth; } - else if ('N'-first >= 0 && 'N'-first < count && Chars['N' - first].Pic != NULL) + else if ('N'-first >= 0 && 'N'-first < count && Chars['N' - first].OriginalPic != nullptr) { SpaceWidth = (Chars['N' - first].XMove + 1) / 2; } @@ -423,13 +428,13 @@ FFont::~FFont () FFont **prev = &FirstFont; FFont *font = *prev; - while (font != NULL && font != this) + while (font != nullptr && font != this) { prev = &font->Next; font = *prev; } - if (font != NULL) + if (font != nullptr) { *prev = font->Next; } @@ -593,10 +598,10 @@ void FFont::BuildTranslations (const double *luminosity, const uint8_t *identity { if (i == CR_UNTRANSLATED) { - if (identity != NULL) + if (identity != nullptr) { memcpy (remap.Remap, identity, ActiveColors); - if (palette != NULL) + if (palette != nullptr) { memcpy (remap.Palette, palette, ActiveColors*sizeof(PalEntry)); } @@ -677,7 +682,7 @@ FRemapTable *FFont::GetColorTranslation (EColorRange range, PalEntry *color) con if (color != nullptr) *color = retcolor; } if (ActiveColors == 0) - return NULL; + return nullptr; else if (range >= NumTextColors) range = CR_UNTRANSLATED; //if (range == CR_UNTRANSLATED && !translateUntranslated) return nullptr; @@ -701,7 +706,7 @@ int FFont::GetCharCode(int code, bool needpic) const // regular chars turn negative when the 8th bit is set. code &= 255; } - if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].Pic != NULL)) + if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].OriginalPic != nullptr)) { return code; } @@ -709,7 +714,7 @@ int FFont::GetCharCode(int code, bool needpic) const if (myislower(code)) { code -= 32; - if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].Pic != NULL)) + if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].OriginalPic != nullptr)) { return code; } @@ -719,7 +724,7 @@ int FFont::GetCharCode(int code, bool needpic) const if (newcode != code) { code = newcode; - if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].Pic != NULL)) + if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].OriginalPic != nullptr)) { return code; } @@ -733,7 +738,7 @@ int FFont::GetCharCode(int code, bool needpic) const // //========================================================================== -FTexture *FFont::GetChar (int code, int *const width) const +FTexture *FFont::GetChar (int code, int translation, int *const width, bool *redirected) const { code = GetCharCode(code, false); int xmove = SpaceWidth; @@ -742,7 +747,7 @@ FTexture *FFont::GetChar (int code, int *const width) const { code -= FirstChar; xmove = Chars[code].XMove; - if (Chars[code].Pic == NULL) + if (Chars[code].OriginalPic == nullptr) { code = GetCharCode(code + FirstChar, true); if (code >= 0) @@ -752,11 +757,21 @@ FTexture *FFont::GetChar (int code, int *const width) const } } } - if (width != NULL) + if (width != nullptr) { *width = xmove; } - return (code < 0) ? NULL : Chars[code].Pic; + if (code < 0) return nullptr; + + + if (translation == CR_UNTRANSLATED) + { + if (redirected) + *redirected = Chars[code].OriginalPic != Chars[code].TranslatedPic; + return Chars[code].OriginalPic; + } + if (redirected) *redirected = false; + return Chars[code].TranslatedPic; } //========================================================================== @@ -780,8 +795,8 @@ int FFont::GetCharWidth (int code) const double GetBottomAlignOffset(FFont *font, int c) { int w; - FTexture *tex_zero = font->GetChar('0', &w); - FTexture *texc = font->GetChar(c, &w); + FTexture *tex_zero = font->GetChar('0', CR_UNDEFINED, &w); + FTexture *texc = font->GetChar(c, CR_UNDEFINED, &w); double offset = 0; if (texc) offset += texc->GetDisplayTopOffsetDouble(); if (tex_zero) offset += -tex_zero->GetDisplayTopOffsetDouble() + tex_zero->GetDisplayHeightDouble(); @@ -848,12 +863,12 @@ void FFont::LoadTranslations() memset (usedcolors, 0, 256); for (unsigned int i = 0; i < count; i++) { - if (Chars[i].Pic) + if (Chars[i].TranslatedPic) { - FFontChar1 *pic = static_cast(Chars[i].Pic->GetImage()); + FFontChar1 *pic = static_cast(Chars[i].TranslatedPic->GetImage()); if (pic) { - pic->SetSourceRemap(NULL); // Force the FFontChar1 to return the same pixels as the base texture + pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture RecordTextureColors(pic, usedcolors); } } @@ -865,11 +880,11 @@ void FFont::LoadTranslations() for (unsigned int i = 0; i < count; i++) { - if(Chars[i].Pic) - static_cast(Chars[i].Pic->GetImage())->SetSourceRemap(PatchRemap); + if(Chars[i].TranslatedPic) + static_cast(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); } - BuildTranslations (Luminosity.Data(), identity, &TranslationParms[0][0], ActiveColors, NULL); + BuildTranslations (Luminosity.Data(), identity, &TranslationParms[0][0], ActiveColors, nullptr); } //========================================================================== @@ -946,7 +961,7 @@ void FSingleLumpFont::CreateFontFromPic (FTextureID picnum) FirstChar = LastChar = 'A'; Chars.Resize(1); - Chars[0].Pic = pic; + Chars[0].TranslatedPic = Chars[0].OriginalPic = pic; // Only one color range. Don't bother with the others. ActiveColors = 0; @@ -992,11 +1007,11 @@ void FSingleLumpFont::LoadTranslations() for(unsigned int i = 0;i < count;++i) { - if(Chars[i].Pic) - static_cast(Chars[i].Pic->GetImage())->SetSourceRemap(PatchRemap); + if(Chars[i].TranslatedPic) + static_cast(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); } - BuildTranslations (luminosity, useidentity ? identity : NULL, ranges, ActiveColors, usepalette ? local_palette : NULL); + BuildTranslations (luminosity, useidentity ? identity : nullptr, ranges, ActiveColors, usepalette ? local_palette : nullptr); } //========================================================================== @@ -1025,7 +1040,7 @@ void FSingleLumpFont::LoadFON1 (int lump, const uint8_t *data) translateUntranslated = true; for(unsigned int i = 0;i < 256;++i) - Chars[i].Pic = nullptr; + Chars[i].TranslatedPic = Chars[i].OriginalPic = nullptr; LoadTranslations(); } @@ -1111,12 +1126,12 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data) Chars[i].XMove = widths2[i]; if (destSize <= 0) { - Chars[i].Pic = NULL; + Chars[i].TranslatedPic = Chars[i].OriginalPic = nullptr; } else { - Chars[i].Pic = new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)); - TexMan.AddTexture(Chars[i].Pic); + Chars[i].TranslatedPic = Chars[i].OriginalPic = new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)); + TexMan.AddTexture(Chars[i].OriginalPic); do { int8_t code = *data_p++; @@ -1201,7 +1216,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) Chars.Resize(count); for (i = 0; i < count; ++i) { - Chars[i].Pic = NULL; + Chars[i].TranslatedPic = Chars[i].OriginalPic = nullptr; Chars[i].XMove = INT_MIN; } @@ -1256,7 +1271,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) -(int8_t)chardata[chari+3], // x offset -(int8_t)chardata[chari+4] // y offset )); - Chars[chardata[chari] - FirstChar].Pic = tex; + Chars[chardata[chari] - FirstChar].TranslatedPic = Chars[chardata[chari] - FirstChar].OriginalPic = tex; TexMan.AddTexture(tex); } @@ -1320,12 +1335,13 @@ void FSingleLumpFont::CheckFON1Chars (double *luminosity) { int destSize = SpaceWidth * FontHeight; - if(!Chars[i].Pic) + if(!Chars[i].OriginalPic) { - Chars[i].Pic = new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)); + Chars[i].OriginalPic = new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)); Chars[i].XMove = SpaceWidth; - TexMan.AddTexture(Chars[i].Pic); + TexMan.AddTexture(Chars[i].OriginalPic); } + Chars[i].TranslatedPic = Chars[i].OriginalPic; // Advance to next char's data and count the used colors. do @@ -1454,7 +1470,7 @@ FSinglePicFont::FSinglePicFont(const char *picname) : // // FSinglePicFont :: GetChar // -// Returns the texture if code is 'a' or 'A', otherwise NULL. +// Returns the texture if code is 'a' or 'A', otherwise nullptr. // //========================================================================== @@ -1467,7 +1483,7 @@ FTexture *FSinglePicFont::GetChar (int code, int *const width) const } else { - return NULL; + return nullptr; } } @@ -1534,23 +1550,24 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l if (charlumps[i] != nullptr) { + Chars[i].OriginalPic = charlumps[i]; if (!noTranslate) { - Chars[i].Pic = new FImageTexture(new FFontChar1 (charlumps[i]->GetImage())); - TexMan.AddTexture(Chars[i].Pic); + Chars[i].TranslatedPic = new FImageTexture(new FFontChar1 (charlumps[i]->GetImage()), ""); + TexMan.AddTexture(Chars[i].TranslatedPic); } - else Chars[i].Pic = charlumps[i]; - Chars[i].XMove = Chars[i].Pic->GetDisplayWidth(); + else Chars[i].TranslatedPic = charlumps[i]; + Chars[i].XMove = Chars[i].OriginalPic->GetDisplayWidth(); } else { - Chars[i].Pic = NULL; + Chars[i].TranslatedPic = Chars[i].OriginalPic = nullptr; Chars[i].XMove = INT_MIN; } } // Special fonts normally don't have all characters so be careful here! - if ('N'-first >= 0 && 'N'-first < count && Chars['N' - first].Pic != NULL) + if ('N'-first >= 0 && 'N'-first < count && Chars['N' - first].OriginalPic != nullptr) { SpaceWidth = (Chars['N' - first].XMove + 1) / 2; } @@ -1588,12 +1605,12 @@ void FSpecialFont::LoadTranslations() memset (usedcolors, 0, 256); for (i = 0; i < count; i++) { - if (Chars[i].Pic) + if (Chars[i].TranslatedPic) { - FFontChar1 *pic = static_cast(Chars[i].Pic->GetImage()); + FFontChar1 *pic = static_cast(Chars[i].TranslatedPic->GetImage()); if (pic) { - pic->SetSourceRemap(NULL); // Force the FFontChar1 to return the same pixels as the base texture + pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture RecordTextureColors(pic, usedcolors); } } @@ -1619,11 +1636,11 @@ void FSpecialFont::LoadTranslations() for (i = 0; i < count; i++) { - if(Chars[i].Pic) - static_cast(Chars[i].Pic->GetImage())->SetSourceRemap(PatchRemap); + if(Chars[i].TranslatedPic) + static_cast(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); } - BuildTranslations (Luminosity.Data(), identity, &TranslationParms[0][0], TotalColors, NULL); + BuildTranslations (Luminosity.Data(), identity, &TranslationParms[0][0], TotalColors, nullptr); // add the untranslated colors to the Ranges tables if (ActiveColors < TotalColors) @@ -1809,7 +1826,7 @@ void V_InitCustomFonts() { for (i = 0; i < 256; i++) { - if (lumplist[i] != NULL) + if (lumplist[i] != nullptr) { first = i; break; @@ -1817,7 +1834,7 @@ void V_InitCustomFonts() } for (i = 255; i >= 0; i--) { - if (lumplist[i] != NULL) + if (lumplist[i] != nullptr) { count = i - first + 1; break; @@ -1921,19 +1938,19 @@ void V_InitFontColors () else if (sc.Compare ("Flat:")) { sc.MustGetString(); - logcolor = V_GetColor (NULL, sc); + logcolor = V_GetColor (nullptr, sc); } else { // Get first color - c = V_GetColor (NULL, sc); + c = V_GetColor (nullptr, sc); tparm.Start[0] = RPART(c); tparm.Start[1] = GPART(c); tparm.Start[2] = BPART(c); // Get second color sc.MustGetString(); - c = V_GetColor (NULL, sc); + c = V_GetColor (nullptr, sc); tparm.End[0] = RPART(c); tparm.End[1] = GPART(c); tparm.End[2] = BPART(c); @@ -2261,7 +2278,7 @@ void V_InitFonts() { IntermissionFont = FFont::FindFont("IntermissionFont_Doom"); } - if (IntermissionFont == NULL) + if (IntermissionFont == nullptr) { IntermissionFont = BigFont; } @@ -2270,11 +2287,11 @@ void V_InitFonts() void V_ClearFonts() { - while (FFont::FirstFont != NULL) + while (FFont::FirstFont != nullptr) { delete FFont::FirstFont; } - FFont::FirstFont = NULL; - SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = NULL; + FFont::FirstFont = nullptr; + SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr; } diff --git a/src/v_font.h b/src/v_font.h index 4bc20884ee..b15790844a 100644 --- a/src/v_font.h +++ b/src/v_font.h @@ -82,7 +82,7 @@ public: FFont (const char *fontname, const char *nametemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false); virtual ~FFont (); - FTexture *GetChar (int code, int *const width) const; + FTexture *GetChar (int code, int translation, int *const width, bool *redirected = nullptr) const; virtual int GetCharWidth (int code) const; FRemapTable *GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const; int GetLump() const { return Lump; } @@ -123,7 +123,8 @@ protected: bool translateUntranslated; struct CharData { - FTexture *Pic; + FTexture *TranslatedPic; // Texture for use with font translations. + FTexture *OriginalPic; // Texture for use with CR_UNTRANSLATED or font colorization. int XMove; }; TArray Chars; diff --git a/src/v_text.cpp b/src/v_text.cpp index e9a78bee46..ea977168fc 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -139,8 +139,9 @@ void DFrameBuffer::DrawChar (FFont *font, int normalcolor, double x, double y, i FTexture *pic; int dummy; + bool redirected; - if (NULL != (pic = font->GetChar (character, &dummy))) + if (NULL != (pic = font->GetChar (character, normalcolor, &dummy, &redirected))) { DrawParms parms; Va_List tags; @@ -152,7 +153,7 @@ void DFrameBuffer::DrawChar (FFont *font, int normalcolor, double x, double y, i return; } PalEntry color = 0xffffffff; - parms.remap = font->GetColorTranslation((EColorRange)normalcolor, &color); + parms.remap = redirected? nullptr : font->GetColorTranslation((EColorRange)normalcolor, &color); parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); DrawTextureParms(pic, parms); } @@ -169,7 +170,7 @@ void DFrameBuffer::DrawChar(FFont *font, int normalcolor, double x, double y, in FTexture *pic; int dummy; - if (NULL != (pic = font->GetChar(character, &dummy))) + if (NULL != (pic = font->GetChar(character, normalcolor, &dummy))) { DrawParms parms; uint32_t tag = ListGetInt(args); @@ -238,6 +239,7 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double cy = y; + auto currentcolor = normalcolor; while ((const char *)ch - string < parms.maxstrlen) { c = GetCharFromString(ch); @@ -251,6 +253,7 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double { range = font->GetColorTranslation(newcolor, &color); parms.color = PalEntry(colorparm.a, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255); + currentcolor = newcolor; } continue; } @@ -262,9 +265,10 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double continue; } - if (NULL != (pic = font->GetChar(c, &w))) + bool redirected = false; + if (NULL != (pic = font->GetChar(c, currentcolor, &w, &redirected))) { - parms.remap = range; + parms.remap = redirected? nullptr : range; SetTextureParms(&parms, pic, cx, cy); if (parms.cellx) { From d937c50726a196fd13553467e15f67a705098fcd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 14:59:49 +0100 Subject: [PATCH 4/6] - use a TArray in PPUniforms. This makes the vast majority of code in that class just go away --- src/gl/renderer/gl_renderbuffers.cpp | 4 +- .../postprocessing/hw_postprocess.h | 42 ++++--------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index d5c78f1160..67d083a31c 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -966,11 +966,11 @@ void FGLRenderBuffers::RenderEffect(const FString &name) auto &shader = GLShaders[step.ShaderName]; // Set uniforms - if (step.Uniforms.Size > 0) + if (step.Uniforms.Data.Size() > 0) { if (!shader->Uniforms) shader->Uniforms.reset(screen->CreateDataBuffer(POSTPROCESS_BINDINGPOINT, false)); - shader->Uniforms->SetData(step.Uniforms.Size, step.Uniforms.Data); + shader->Uniforms->SetData(step.Uniforms.Data.Size(), step.Uniforms.Data.Data()); shader->Uniforms->BindBase(); } diff --git a/src/hwrenderer/postprocessing/hw_postprocess.h b/src/hwrenderer/postprocessing/hw_postprocess.h index c94a89b81e..0b11ec1241 100644 --- a/src/hwrenderer/postprocessing/hw_postprocess.h +++ b/src/hwrenderer/postprocessing/hw_postprocess.h @@ -38,12 +38,7 @@ public: PPUniforms(const PPUniforms &src) { - if (src.Size > 0) - { - Data = new uint8_t[src.Size]; - Size = src.Size; - memcpy(Data, src.Data, Size); - } + Data = src.Data; } ~PPUniforms() @@ -53,49 +48,26 @@ public: PPUniforms &operator=(const PPUniforms &src) { - if (this != &src) - { - if (src.Size > 0) - { - Data = new uint8_t[src.Size]; - Size = src.Size; - memcpy(Data, src.Data, Size); - } - else - { - delete[] Data; - Data = nullptr; - Size = 0; - } - } - + Data = src.Data; return *this; } void Clear() { - delete[] Data; - Data = nullptr; - Size = 0; + Data.Clear(); } template void Set(const T &v) { - if (Size != (int)sizeof(T)) + if (Data.Size() != (int)sizeof(T)) { - delete[] Data; - Data = nullptr; - Size = 0; - - Data = new uint8_t[sizeof(T)]; - Size = sizeof(T); - memcpy(Data, &v, Size); + Data.Resize(sizeof(T)); + memcpy(Data.Data(), &v, Data.Size()); } } - uint8_t *Data = nullptr; - int Size = 0; + TArray Data; }; class PPStep From faa4bb45c92db405981cf3dbe0fac2d4f4b4943b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 15:36:33 +0100 Subject: [PATCH 5/6] - store UnchangedSpriteNames in Dehacked in a less hacky manner. --- src/d_dehacked.cpp | 64 ++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 2e11c5ff2e..2562d8e636 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -223,8 +223,7 @@ DEFINE_FIELD_X(DehInfo, DehInfo, BlueAC) TArray TouchedActors; -char *UnchangedSpriteNames; -int NumUnchangedSprites; +TArray UnchangedSpriteNames; bool changedStates; // Sprite<->Class map for DehackedPickup::DetermineType @@ -395,17 +394,10 @@ static bool HandleKey (const struct Key *keys, void *structure, const char *key, static int FindSprite (const char *sprname) { - int i; - uint32_t nameint = *((uint32_t *)sprname); - - for (i = 0; i < NumUnchangedSprites; ++i) - { - if (*((uint32_t *)&UnchangedSpriteNames[i*4]) == nameint) - { - return i; - } - } - return -1; + uint32_t nameint; + memcpy(&nameint, sprname, 4); + auto f = UnchangedSpriteNames.Find(nameint); + return f == UnchangedSpriteNames.Size() ? -1 : f; } static FState *FindState (int statenum) @@ -2665,31 +2657,16 @@ static void UnloadDehSupp () // that was altered by the first. So we need to keep the // StateMap around until all patches have been applied. DehUseCount = 0; - Actions.Clear(); - Actions.ShrinkToFit(); - OrgHeights.Clear(); - OrgHeights.ShrinkToFit(); - CodePConv.Clear(); - CodePConv.ShrinkToFit(); - OrgSprNames.Clear(); - OrgSprNames.ShrinkToFit(); - SoundMap.Clear(); - SoundMap.ShrinkToFit(); - InfoNames.Clear(); - InfoNames.ShrinkToFit(); - BitNames.Clear(); - BitNames.ShrinkToFit(); - StyleNames.Clear(); - StyleNames.ShrinkToFit(); - AmmoNames.Clear(); - AmmoNames.ShrinkToFit(); - - if (UnchangedSpriteNames != NULL) - { - delete[] UnchangedSpriteNames; - UnchangedSpriteNames = NULL; - NumUnchangedSprites = 0; - } + Actions.Reset(); + OrgHeights.Reset(); + CodePConv.Reset(); + OrgSprNames.Reset(); + SoundMap.Reset(); + InfoNames.Reset(); + BitNames.Reset(); + StyleNames.Reset(); + AmmoNames.Reset(); + UnchangedSpriteNames.Reset(); if (EnglishStrings != NULL) { delete EnglishStrings; @@ -2731,14 +2708,11 @@ static bool LoadDehSupp () EnglishStrings->LoadStrings (true); } - if (UnchangedSpriteNames == NULL) + + UnchangedSpriteNames.Resize(sprites.Size()); + for (unsigned i = 0; i < UnchangedSpriteNames.Size(); ++i) { - UnchangedSpriteNames = new char[sprites.Size()*4]; - NumUnchangedSprites = sprites.Size(); - for (i = 0; i < NumUnchangedSprites; ++i) - { - memcpy (UnchangedSpriteNames+i*4, &sprites[i].name, 4); - } + memcpy (&UnchangedSpriteNames[i], &sprites[i].name, 4); } FScanner sc; From 1aba33122b8c80874c17fc446742de2b7ceace66 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 15:36:43 +0100 Subject: [PATCH 6/6] - fixed: The light defaults were not fully deleted on an engine restart. --- src/d_main.cpp | 2 +- src/g_shared/a_dynlight.h | 2 +- src/r_data/gldefs.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index b4f4c5b35b..a7a0ef46a5 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2709,7 +2709,7 @@ void D_DoomMain (void) DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods FS_Close(); // destroy the global FraggleScript. DeinitMenus(); - LightDefaults.Clear(); // this can leak heap memory if it isn't cleared. + LightDefaults.DeleteAndClear(); // this can leak heap memory if it isn't cleared. // delete DoomStartupInfo data DoomStartupInfo.Name = (const char*)0; diff --git a/src/g_shared/a_dynlight.h b/src/g_shared/a_dynlight.h index 369b826e31..685c3a39c3 100644 --- a/src/g_shared/a_dynlight.h +++ b/src/g_shared/a_dynlight.h @@ -85,7 +85,7 @@ public: } protected: - FName m_Name; + FName m_Name = NAME_None; int m_Args[5] = { 0,0,0,0,0 }; double m_Param = 0; DVector3 m_Pos = { 0,0,0 }; diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index 513d510941..8552ad77d3 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -1758,7 +1758,7 @@ void ParseGLDefs() { const char *defsLump = NULL; - LightDefaults.Clear(); + LightDefaults.DeleteAndClear(); //gl_DestroyUserShaders(); function says 'todo' switch (gameinfo.gametype) {