diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index 44865797b..612eef005 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -124,7 +124,7 @@ static void Shape2D_Clear(DShape2D* self, int which) if (which & C_Verts) self->mVertices.Clear(); if (which & C_Coords) self->mCoords.Clear(); if (which & C_Indices) self->mIndices.Clear(); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear) @@ -138,7 +138,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear) static void Shape2D_PushVertex(DShape2D* self, double x, double y) { self->mVertices.Push(DVector2(x, y)); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex) @@ -153,7 +153,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex) static void Shape2D_PushCoord(DShape2D* self, double u, double v) { self->mCoords.Push(DVector2(u, v)); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushCoord, Shape2D_PushCoord) @@ -170,7 +170,7 @@ static void Shape2D_PushTriangle(DShape2D* self, int a, int b, int c) self->mIndices.Push(a); self->mIndices.Push(b); self->mIndices.Push(c); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushTriangle, Shape2D_PushTriangle) @@ -528,13 +528,15 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) offset = osave; } +static TArray> buffersToDestroy; + void DShape2D::OnDestroy() { if (lastParms) delete lastParms; lastParms = nullptr; mIndices.Reset(); mVertices.Reset(); mCoords.Reset(); - buffers.Reset(); + buffersToDestroy.Push(std::move(bufferInfo)); } //========================================================================== @@ -567,11 +569,11 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) shape->lastParms = new DrawParms(parms); } else if (shape->lastParms->vertexColorChange(parms)) { - shape->needsVertexUpload = true; - if (!shape->uploadedOnce) { - shape->bufIndex = -1; - shape->buffers.Clear(); - shape->lastCommand = -1; + shape->bufferInfo->needsVertexUpload = true; + if (!shape->bufferInfo->uploadedOnce) { + shape->bufferInfo->bufIndex = -1; + shape->bufferInfo->buffers.Clear(); + shape->bufferInfo->lastCommand = -1; } delete shape->lastParms; shape->lastParms = new DrawParms(parms); @@ -583,7 +585,7 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) auto osave = offset; if (parms.nooffset) offset = { 0,0 }; - if (shape->needsVertexUpload) + if (shape->bufferInfo->needsVertexUpload) { shape->minx = 16383; shape->miny = 16383; @@ -622,15 +624,15 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) dg.transform = shape->transform; dg.transform.Cells[0][2] += offset.X; dg.transform.Cells[1][2] += offset.Y; - dg.shape2D = shape; + dg.shape2DBufInfo = shape->bufferInfo; dg.shape2DIndexCount = shape->mIndices.Size(); - if (shape->needsVertexUpload) + if (shape->bufferInfo->needsVertexUpload) { - shape->bufIndex += 1; + shape->bufferInfo->bufIndex += 1; - shape->buffers.Reserve(1); + shape->bufferInfo->buffers.Reserve(1); - auto buf = &shape->buffers[shape->bufIndex]; + auto buf = &shape->bufferInfo->buffers[shape->bufferInfo->bufIndex]; auto verts = TArray(dg.mVertCount, true); for ( int i=0; iUploadData(&verts[0], dg.mVertCount, &shape->mIndices[0], shape->mIndices.Size()); - shape->needsVertexUpload = false; - shape->uploadedOnce = true; + shape->bufferInfo->needsVertexUpload = false; + shape->bufferInfo->uploadedOnce = true; } - dg.shape2DBufIndex = shape->bufIndex; - shape->lastCommand += 1; - dg.shape2DCommandCounter = shape->lastCommand; + dg.shape2DBufIndex = shape->bufferInfo->bufIndex; + shape->bufferInfo->lastCommand += 1; + dg.shape2DCommandCounter = shape->bufferInfo->lastCommand; AddCommand(&dg); offset = osave; } @@ -1082,6 +1084,17 @@ void F2DDrawer::Clear() screenFade = 1.f; } +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::OnFrameDone() +{ + buffersToDestroy.Clear(); +} + F2DVertexBuffer::F2DVertexBuffer() { mVertexBuffer = screen->CreateVertexBuffer(); diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index 8bb113905..ebcef6142 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -7,6 +7,7 @@ #include "textures.h" #include "renderstyle.h" #include "dobject.h" +#include "refcounted.h" struct DrawParms; struct FColormap; @@ -49,6 +50,7 @@ struct F2DPolygons }; class DShape2D; +struct DShape2DBufferInfo; class F2DDrawer { @@ -123,7 +125,7 @@ public: bool useTransform; DMatrix3x3 transform; - DShape2D* shape2D; + RefCountedPtr shape2DBufInfo; int shape2DBufIndex; int shape2DIndexCount; int shape2DCommandCounter; @@ -136,7 +138,7 @@ public: // If these fields match, two draw commands can be batched. bool isCompatible(const RenderCommand &other) const { - if (shape2D != nullptr || other.shape2D != nullptr) return false; + if (shape2DBufInfo != nullptr || other.shape2DBufInfo != nullptr) return false; return mTexture == other.mTexture && mType == other.mType && mTranslationId == other.mTranslationId && @@ -214,6 +216,7 @@ public: void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; } void End() { isIn2D = false; } bool HasBegun2D() { return isIn2D; } + void OnFrameDone(); void ClearClipRect() { clipleft = cliptop = 0; clipwidth = clipheight = -1; } void SetClipRect(int x, int y, int w, int h); @@ -240,12 +243,22 @@ public: bool mIsFirstPass = true; }; +struct DShape2DBufferInfo : NoVirtualRefCountedBase +{ + TArray buffers; + bool needsVertexUpload = true; + int bufIndex = -1; + int lastCommand = -1; + bool uploadedOnce = false; +}; + class DShape2D : public DObject { DECLARE_CLASS(DShape2D,DObject) public: DShape2D() + : bufferInfo(new DShape2DBufferInfo) { transform.Identity(); } @@ -261,12 +274,8 @@ public: DMatrix3x3 transform; - TArray buffers; - bool needsVertexUpload = true; - int bufIndex = -1; - int lastCommand = -1; + RefCountedPtr bufferInfo; - bool uploadedOnce = false; DrawParms* lastParms; void OnDestroy() override; diff --git a/src/common/console/c_commandbuffer.cpp b/src/common/console/c_commandbuffer.cpp index 0ca96ade3..bf459350f 100644 --- a/src/common/console/c_commandbuffer.cpp +++ b/src/common/console/c_commandbuffer.cpp @@ -291,7 +291,7 @@ void FCommandBuffer::AddString(FString clip) if (clip.IsNotEmpty()) { // Only paste the first line. - long brk = clip.IndexOfAny("\r\n\b"); + auto brk = clip.IndexOfAny("\r\n\b"); std::u32string build; if (brk >= 0) { diff --git a/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index bcb52ba7e..ce9f2cef7 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -533,7 +533,7 @@ FString BuildString (int argc, FString *argv) else if (strchr(argv[arg], '"')) { // If it contains one or more quotes, we need to escape them. buf << '"'; - long substr_start = 0, quotepos; + ptrdiff_t substr_start = 0, quotepos; while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0) { if (substr_start < quotepos) diff --git a/src/common/engine/stringtable.cpp b/src/common/engine/stringtable.cpp index a666a4d9c..b36e6e409 100644 --- a/src/common/engine/stringtable.cpp +++ b/src/common/engine/stringtable.cpp @@ -435,7 +435,7 @@ void FStringTable::InsertString(int lumpnum, int langid, FName label, const FStr { const char *strlangid = (const char *)&langid; TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } }; - long index; + ptrdiff_t index; while ((index = te.strings[0].IndexOf("@[")) >= 0) { auto endindex = te.strings[0].IndexOf(']', index); diff --git a/src/common/filesystem/file_zip.cpp b/src/common/filesystem/file_zip.cpp index 0096507bf..b3acb8d13 100644 --- a/src/common/filesystem/file_zip.cpp +++ b/src/common/filesystem/file_zip.cpp @@ -234,6 +234,8 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) } name.ToLower(); + if (name.IndexOf("filter/") == 0) + continue; // 'filter' is a reserved name of the file system. if (name.IndexOf("__macosx") == 0) continue; // skip Apple garbage. At this stage only the root folder matters. if (!foundprefix) diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 4c5a5b910..5a709726f 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -113,7 +113,20 @@ struct FileSystem::LumpRecord if (Namespace == ns_hidden) shortName.qword = 0; else { - long slash = longName.LastIndexOf('/'); + ptrdiff_t encodedResID = longName.LastIndexOf(".{"); + if (resourceId == -1 && encodedResID >= 0) + { + const char* p = longName.GetChars() + encodedResID; + char* q; + int id = (int)strtoull(p+2, &q, 10); // only decimal numbers allowed here. + if (q[0] == '}' && (q[1] == '.' || q[1] == 0)) + { + FString toDelete(p, q - p + 1); + longName.Substitute(toDelete, ""); + resourceId = id; + } + } + ptrdiff_t slash = longName.LastIndexOf('/'); FString base = (slash >= 0) ? longName.Mid(slash + 1) : longName; auto dot = base.LastIndexOf('.'); if (dot >= 0) base.Truncate(dot); @@ -1533,7 +1546,7 @@ bool FileSystem::CreatePathlessCopy(const char *name, int id, int /*flags*/) if (lump < 0) return false; // Does not exist. auto oldlump = FileInfo[lump]; - int slash = oldlump.longName.LastIndexOf('/'); + ptrdiff_t slash = oldlump.longName.LastIndexOf('/'); if (slash == -1) { diff --git a/src/common/filesystem/resourcefile.cpp b/src/common/filesystem/resourcefile.cpp index 5fc484b23..cc2a27345 100644 --- a/src/common/filesystem/resourcefile.cpp +++ b/src/common/filesystem/resourcefile.cpp @@ -348,8 +348,8 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize, LumpFilterI uint32_t max = NumLumps; max -= FilterLumpsByGameType(filter, lumps, lumpsize, max); - long len; - int lastpos = -1; + ptrdiff_t len; + ptrdiff_t lastpos = -1; FString file; FString LumpFilter = filter->dotFilter; while ((len = LumpFilter.IndexOf('.', lastpos+1)) > 0) diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index 3324a14e4..9663f4e1c 100644 --- a/src/common/fonts/font.cpp +++ b/src/common/fonts/font.cpp @@ -437,7 +437,7 @@ void FFont::ReadSheetFont(TArray &folderdata, int width, int height Chars[i].OriginalPic->CopySize(*lump, true); if (Chars[i].OriginalPic != *lump) TexMan.AddGameTexture(Chars[i].OriginalPic); } - Chars[i].XMove = width; + Chars[i].XMove = int(width / Scale.X); } if (map1252) diff --git a/src/common/fonts/singlelumpfont.cpp b/src/common/fonts/singlelumpfont.cpp index 5ba90b989..c4711d902 100644 --- a/src/common/fonts/singlelumpfont.cpp +++ b/src/common/fonts/singlelumpfont.cpp @@ -407,6 +407,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) count = LastChar - FirstChar + 1; Chars.Resize(count); // BMF palettes are only six bits per component. Fix that. + Palette[0] = 0; for (i = 0; i < ActiveColors; ++i) { int r = (data[17 + i * 3] << 2) | (data[17 + i * 3] >> 4); diff --git a/src/common/fonts/v_text.cpp b/src/common/fonts/v_text.cpp index 59d843496..bfd6eac92 100644 --- a/src/common/fonts/v_text.cpp +++ b/src/common/fonts/v_text.cpp @@ -88,7 +88,7 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str { if (*string == '[') { - const uint8_t *start = string; + const uint8_t* start = string; while (*string != ']' && *string != '\0') { string++; @@ -97,11 +97,6 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str { string++; } - lastcolor = FString((const char *)start, string - start); - } - else - { - lastcolor = *string++; } } continue; @@ -130,6 +125,33 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str } auto index = Lines.Reserve(1); + for (const uint8_t* pos = start; pos < space; pos++) + { + if (*pos == TEXTCOLOR_ESCAPE) + { + pos++; + if (*pos) + { + if (*pos == '[') + { + const uint8_t* cstart = pos; + while (*pos != ']' && *pos != '\0') + { + pos++; + } + if (*pos != '\0') + { + pos++; + } + lastcolor = FString((const char*)cstart, pos - start); + } + else + { + lastcolor = *pos++; + } + } + } + } breakit (&Lines[index], font, start, space, linecolor); if (c == '\n' && !preservecolor) { diff --git a/src/common/models/model.cpp b/src/common/models/model.cpp index 90dedc272..eea099045 100644 --- a/src/common/models/model.cpp +++ b/src/common/models/model.cpp @@ -90,8 +90,8 @@ static int FindGFXFile(FString & fn) if (lump != -1) return lump; int best = -1; - int dot = fn.LastIndexOf('.'); - int slash = fn.LastIndexOf('/'); + auto dot = fn.LastIndexOf('.'); + auto slash = fn.LastIndexOf('/'); if (dot > slash) fn.Truncate(dot); static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr }; diff --git a/src/common/models/models_obj.cpp b/src/common/models/models_obj.cpp index 1af4fab7e..05d10b5cf 100644 --- a/src/common/models/models_obj.cpp +++ b/src/common/models/models_obj.cpp @@ -44,8 +44,8 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length { // Ensure usemtl statements remain intact TArray mtlUsages; - TArray mtlUsageIdxs; - long bpos = 0, nlpos = 0, slashpos = 0; + TArray mtlUsageIdxs; + ptrdiff_t bpos = 0, nlpos = 0, slashpos = 0; while (1) { bpos = objBuf.IndexOf("\nusemtl", bpos); @@ -58,7 +58,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length } if (nlpos == -1) { - nlpos = (long)objBuf.Len(); + nlpos = objBuf.Len(); } FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos); mtlUsages.Push(lineStr); @@ -76,7 +76,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length nlpos = objBuf.IndexOf('\n', bpos); if (nlpos == -1) { - nlpos = (long)objBuf.Len(); + nlpos = objBuf.Len(); } memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos); } diff --git a/src/common/platform/posix/cocoa/i_main.mm b/src/common/platform/posix/cocoa/i_main.mm index a243bdbe5..ea7040ee5 100644 --- a/src/common/platform/posix/cocoa/i_main.mm +++ b/src/common/platform/posix/cocoa/i_main.mm @@ -131,7 +131,7 @@ static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version) if (const char *patchVersionString = strstr(minorVersionString, ".")) { patchVersionString++; - plistVersion.patchVersion = atoi(minorVersionString); + plistVersion.patchVersion = atoi(patchVersionString); } } } diff --git a/src/common/platform/posix/sdl/i_system.cpp b/src/common/platform/posix/sdl/i_system.cpp index 03b96b8c3..922c228a3 100644 --- a/src/common/platform/posix/sdl/i_system.cpp +++ b/src/common/platform/posix/sdl/i_system.cpp @@ -204,7 +204,7 @@ void I_PrintStr(const char *cp) { // gray if (v < 0.33) attrib = 0x8; else if (v < 0.90) attrib = 0x7; - else attrib = 0x15; + else attrib = 0xF; } printData.AppendFormat("\033[%um",((attrib & 0x8) ? 90 : 30) + (attrib & 0x7)); diff --git a/src/common/platform/win32/i_main.cpp b/src/common/platform/win32/i_main.cpp index 7207717ea..acdfd2eb5 100644 --- a/src/common/platform/win32/i_main.cpp +++ b/src/common/platform/win32/i_main.cpp @@ -545,6 +545,20 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) // //========================================================================== +bool restartrequest; + +void CheckForRestart() +{ + if (restartrequest) + { + HMODULE hModule = GetModuleHandleW(NULL); + WCHAR path[MAX_PATH]; + GetModuleFileNameW(hModule, path, MAX_PATH); + ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL); + } + restartrequest = false; +} + INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) @@ -559,11 +573,7 @@ INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara { if (LOWORD(wParam) == IDC_BUTTON1) // we pressed the restart button, so run GZDoom again { - HMODULE hModule = GetModuleHandleW(NULL); - WCHAR path[MAX_PATH]; - GetModuleFileNameW(hModule, path, MAX_PATH); - - ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL); + restartrequest = true; } PostQuitMessage (0); return TRUE; @@ -969,6 +979,8 @@ int DoMain (HINSTANCE hInstance) atexit (UnCOM); int ret = GameMain (); + CheckForRestart(); + DestroyCustomCursor(); if (ret == 1337) // special exit code for 'norun'. { diff --git a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp index fb3b8a535..97420e0c2 100644 --- a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp @@ -52,15 +52,15 @@ static bool IsGlslWhitespace(char c) } } -static FString NextGlslToken(const char *chars, long len, long &pos) +static FString NextGlslToken(const char *chars, ptrdiff_t len, ptrdiff_t &pos) { // Eat whitespace - long tokenStart = pos; + ptrdiff_t tokenStart = pos; while (tokenStart != len && IsGlslWhitespace(chars[tokenStart])) tokenStart++; // Find token end - long tokenEnd = tokenStart; + ptrdiff_t tokenEnd = tokenStart; while (tokenEnd != len && !IsGlslWhitespace(chars[tokenEnd]) && chars[tokenEnd] != ';') tokenEnd++; @@ -82,13 +82,13 @@ FString RemoveLegacyUserUniforms(FString code) // The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace. - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; + ptrdiff_t startIndex = 0; while (true) { - long matchIndex = code.IndexOf("uniform", startIndex); + ptrdiff_t matchIndex = code.IndexOf("uniform", startIndex); if (matchIndex == -1) break; @@ -98,7 +98,7 @@ FString RemoveLegacyUserUniforms(FString code) bool isKeywordEnd = matchIndex + 7 == len || IsGlslWhitespace(chars[matchIndex + 7]); if (isKeywordStart && isKeywordEnd) { - long pos = matchIndex + 7; + ptrdiff_t pos = matchIndex + 7; FString type = NextGlslToken(chars, len, pos); FString identifier = NextGlslToken(chars, len, pos); @@ -107,10 +107,10 @@ FString RemoveLegacyUserUniforms(FString code) if (isLegacyUniformName) { - long statementEndIndex = code.IndexOf(';', matchIndex + 7); + ptrdiff_t statementEndIndex = code.IndexOf(';', matchIndex + 7); if (statementEndIndex == -1) statementEndIndex = len; - for (long i = matchIndex; i <= statementEndIndex; i++) + for (ptrdiff_t i = matchIndex; i <= statementEndIndex; i++) { if (!IsGlslWhitespace(chars[i])) chars[i] = ' '; @@ -127,7 +127,7 @@ FString RemoveLegacyUserUniforms(FString code) // Modern GLSL only allows use of 'texture'. while (true) { - long matchIndex = code.IndexOf("texture2d", startIndex); + ptrdiff_t matchIndex = code.IndexOf("texture2d", startIndex); if (matchIndex == -1) break; @@ -148,14 +148,14 @@ FString RemoveLegacyUserUniforms(FString code) FString RemoveSamplerBindings(FString code, TArray> &samplerstobind) { - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; - long startpos, endpos; + ptrdiff_t startIndex = 0; + ptrdiff_t startpos, endpos; while (true) { - long matchIndex = code.IndexOf("layout(binding", startIndex); + ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex); if (matchIndex == -1) break; @@ -165,7 +165,7 @@ FString RemoveSamplerBindings(FString code, TArray> &sam bool isKeywordEnd = matchIndex + 14 == len || IsGlslWhitespace(chars[matchIndex + 14]) || chars[matchIndex + 14] == '='; if (isKeywordStart && isKeywordEnd) { - long pos = matchIndex + 14; + ptrdiff_t pos = matchIndex + 14; startpos = matchIndex; while (IsGlslWhitespace(chars[pos])) pos++; if (chars[pos] == '=') @@ -175,7 +175,7 @@ FString RemoveSamplerBindings(FString code, TArray> &sam auto val = strtol(&chars[pos], &p, 0); if (p != &chars[pos]) { - pos = long(p - chars); + pos = (p - chars); while (IsGlslWhitespace(chars[pos])) pos++; if (chars[pos] == ')') { @@ -216,17 +216,17 @@ FString RemoveSamplerBindings(FString code, TArray> &sam FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) { - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; + ptrdiff_t startIndex = 0; while (true) { - long matchIndex = code.IndexOf("layout(location", startIndex); + ptrdiff_t matchIndex = code.IndexOf("layout(location", startIndex); if (matchIndex == -1) break; - long endIndex = matchIndex; + ptrdiff_t endIndex = matchIndex; // Find end of layout declaration while (chars[endIndex] != ')' && chars[endIndex] != 0) @@ -255,7 +255,7 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) if (keywordFound && IsGlslWhitespace(chars[endIndex + i])) { // yes - replace declaration with spaces - for (long i = matchIndex; i < endIndex; i++) + for (auto i = matchIndex; i < endIndex; i++) chars[i] = ' '; } diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp index 7fc369c98..c5e5fb09b 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp @@ -98,7 +98,8 @@ bool IShadowMap::PerformUpdate() LightsProcessed = 0; LightsShadowmapped = 0; - if (gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && screen->mPipelineType == 0 && CollectLights != nullptr) + // CollectLights will be null if the calling code decides that shadowmaps are not needed. + if (CollectLights != nullptr) { UpdateCycles.Clock(); UploadAABBTree(); diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.h b/src/common/rendering/hwrenderer/data/hw_shadowmap.h index f82e368b2..e755c0f59 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.h +++ b/src/common/rendering/hwrenderer/data/hw_shadowmap.h @@ -57,6 +57,11 @@ public: mLights[index + 3] = r; } + bool Enabled() const + { + return mAABBTree != nullptr; + } + protected: // Upload the AABB-tree to the GPU void UploadAABBTree(); diff --git a/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp b/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp index 59f215e02..35b5eea06 100644 --- a/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp +++ b/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp @@ -33,10 +33,10 @@ #include "i_interface.h" // Set up 3D-specific console variables: -CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) +CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // switch left and right eye views -CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG) +CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) // intraocular distance in meters CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS diff --git a/src/common/rendering/hwrenderer/hw_draw2d.cpp b/src/common/rendering/hwrenderer/hw_draw2d.cpp index cf3399432..af10a7bf2 100644 --- a/src/common/rendering/hwrenderer/hw_draw2d.cpp +++ b/src/common/rendering/hwrenderer/hw_draw2d.cpp @@ -178,22 +178,22 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) state.EnableTexture(false); } - if (cmd.shape2D != nullptr) + if (cmd.shape2DBufInfo != nullptr) { - state.SetVertexBuffer(&cmd.shape2D->buffers[cmd.shape2DBufIndex]); + state.SetVertexBuffer(&cmd.shape2DBufInfo->buffers[cmd.shape2DBufIndex]); state.DrawIndexed(DT_Triangles, 0, cmd.shape2DIndexCount); state.SetVertexBuffer(&vb); - if (cmd.shape2DCommandCounter == cmd.shape2D->lastCommand) + if (cmd.shape2DCommandCounter == cmd.shape2DBufInfo->lastCommand) { - cmd.shape2D->lastCommand = -1; - if (cmd.shape2D->bufIndex > 0) + cmd.shape2DBufInfo->lastCommand = -1; + if (cmd.shape2DBufInfo->bufIndex > 0) { - cmd.shape2D->needsVertexUpload = true; - cmd.shape2D->buffers.Clear(); - cmd.shape2D->bufIndex = -1; + cmd.shape2DBufInfo->needsVertexUpload = true; + cmd.shape2DBufInfo->buffers.Clear(); + cmd.shape2DBufInfo->bufIndex = -1; } } - cmd.shape2D->uploadedOnce = false; + cmd.shape2DBufInfo->uploadedOnce = false; } else { diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 6a551f1c6..17e148335 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -9823,6 +9823,8 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx) { CHECKRESOLVED(); + SAFE_RESOLVE(Condition, ctx); + if (WhenTrue == nullptr && WhenFalse == nullptr) { // We don't do anything either way, so disappear delete this; @@ -9830,8 +9832,6 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx) return new FxNop(ScriptPosition); } - SAFE_RESOLVE(Condition, ctx); - if (Condition->ValueType != TypeBool) { Condition = new FxBoolCast(Condition, false); diff --git a/src/common/scripting/interface/stringformat.cpp b/src/common/scripting/interface/stringformat.cpp index 87bfbb415..4bfe34ff6 100644 --- a/src/common/scripting/interface/stringformat.cpp +++ b/src/common/scripting/interface/stringformat.cpp @@ -419,7 +419,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Filter, StringFilter) static int StringIndexOf(FString *self, const FString &substr, int startIndex) { - return self->IndexOf(substr, startIndex); + return (int)self->IndexOf(substr, startIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) @@ -427,12 +427,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(startIndex); - ACTION_RETURN_INT(self->IndexOf(substr, startIndex)); + ACTION_RETURN_INT(StringIndexOf(self, substr, startIndex)); } static int StringLastIndexOf(FString *self, const FString &substr, int endIndex) { - return self->LastIndexOfBroken(substr, endIndex); + return (int)self->LastIndexOfBroken(substr, endIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) @@ -440,12 +440,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(endIndex); - ACTION_RETURN_INT(self->LastIndexOfBroken(substr, endIndex)); + ACTION_RETURN_INT(StringLastIndexOf(self, substr, endIndex)); } static int StringRightIndexOf(FString *self, const FString &substr, int endIndex) { - return self->LastIndexOf(substr, endIndex); + return (int)self->LastIndexOf(substr, endIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) @@ -453,7 +453,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(endIndex); - ACTION_RETURN_INT(self->LastIndexOf(substr, endIndex)); + ACTION_RETURN_INT(StringRightIndexOf(self, substr, endIndex)); } static void StringToUpper(FString *self) diff --git a/src/common/utility/refcounted.h b/src/common/utility/refcounted.h index b0c87d934..fd3e82aad 100644 --- a/src/common/utility/refcounted.h +++ b/src/common/utility/refcounted.h @@ -1,20 +1,29 @@ #pragma once // Simple lightweight reference counting pointer alternative for std::shared_ptr which stores the reference counter in the handled object itself. - - // Base class for handled objects + +// Base classes for handled objects +class NoVirtualRefCountedBase +{ +public: + void IncRef() { refCount++; } + void DecRef() { if (--refCount <= 0) delete this; } +private: + int refCount = 0; +}; + class RefCountedBase { public: - void IncRef() { refCount++; } - void DecRef() { if (--refCount <= 0) delete this; } + void IncRef() { refCount++; } + void DecRef() { if (--refCount <= 0) delete this; } private: - int refCount = 0; + int refCount = 0; protected: - virtual ~RefCountedBase() = default; + virtual ~RefCountedBase() = default; }; - - // The actual pointer object + +// The actual pointer object template class RefCountedPtr { @@ -31,10 +40,20 @@ public: { if (ptr) ptr->IncRef(); } - + + RefCountedPtr(const RefCountedPtr& r) : ptr(r.ptr) + { + if (ptr) ptr->IncRef(); + } + + RefCountedPtr(RefCountedPtr&& r) : ptr(r.ptr) + { + r.ptr = nullptr; + } + RefCountedPtr & operator=(const RefCountedPtr& r) { - if (ptr != r.ptr) + if (this != &r) { if (ptr) ptr->DecRef(); ptr = r.ptr; @@ -54,11 +73,14 @@ public: return *this; } - RefCountedPtr & operator=(const RefCountedPtr&& r) + RefCountedPtr & operator=(RefCountedPtr&& r) { - if (ptr) ptr->DecRef(); - ptr = r.ptr; - r.ptr = nullptr; + if (this != &r) + { + if (ptr) ptr->DecRef(); + ptr = r.ptr; + r.ptr = nullptr; + } return *this; } diff --git a/src/common/utility/s_playlist.cpp b/src/common/utility/s_playlist.cpp index 49e6f2d81..d284a3e90 100644 --- a/src/common/utility/s_playlist.cpp +++ b/src/common/utility/s_playlist.cpp @@ -95,7 +95,7 @@ bool FPlayList::ChangeList (const char *path) } // Check for relative paths. - long slashpos = song.IndexOf('/'); + auto slashpos = song.IndexOf('/'); if (slashpos == 0) { diff --git a/src/common/utility/zstring.cpp b/src/common/utility/zstring.cpp index 2cd308596..8d4d4d119 100644 --- a/src/common/utility/zstring.cpp +++ b/src/common/utility/zstring.cpp @@ -422,7 +422,7 @@ void FString::Remove(size_t index, size_t remlen) { if (index + remlen >= Len()) { - Truncate((long)index); + Truncate(index); } else { @@ -500,12 +500,12 @@ void FString::DeleteLastCharacter() } -long FString::IndexOf (const FString &substr, long startIndex) const +ptrdiff_t FString::IndexOf (const FString &substr, ptrdiff_t startIndex) const { return IndexOf (substr.Chars, startIndex); } -long FString::IndexOf (const char *substr, long startIndex) const +ptrdiff_t FString::IndexOf (const char *substr, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -516,10 +516,10 @@ long FString::IndexOf (const char *substr, long startIndex) const { return -1; } - return long(str - Chars); + return str - Chars; } -long FString::IndexOf (char subchar, long startIndex) const +ptrdiff_t FString::IndexOf (char subchar, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -530,15 +530,15 @@ long FString::IndexOf (char subchar, long startIndex) const { return -1; } - return long(str - Chars); + return str - Chars; } -long FString::IndexOfAny (const FString &charset, long startIndex) const +ptrdiff_t FString::IndexOfAny (const FString &charset, ptrdiff_t startIndex) const { return IndexOfAny (charset.Chars, startIndex); } -long FString::IndexOfAny (const char *charset, long startIndex) const +ptrdiff_t FString::IndexOfAny (const char *charset, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -549,19 +549,19 @@ long FString::IndexOfAny (const char *charset, long startIndex) const { return -1; } - return long(brk - Chars); + return brk - Chars; } -long FString::LastIndexOf (char subchar) const +ptrdiff_t FString::LastIndexOf (char subchar) const { - return LastIndexOf (subchar, long(Len())); + return LastIndexOf (subchar, Len()); } -long FString::LastIndexOf (char subchar, long endIndex) const +ptrdiff_t FString::LastIndexOf (char subchar, ptrdiff_t endIndex) const { if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } while (--endIndex >= 0) { @@ -573,16 +573,16 @@ long FString::LastIndexOf (char subchar, long endIndex) const return -1; } -long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const +ptrdiff_t FString::LastIndexOfBroken (const FString &_substr, ptrdiff_t endIndex) const { const char *substr = _substr.GetChars(); size_t substrlen = _substr.Len(); if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } substrlen--; - while (--endIndex >= long(substrlen)) + while (--endIndex >= ptrdiff_t(substrlen)) { if (strncmp (substr, Chars + endIndex - substrlen, substrlen + 1) == 0) { @@ -592,26 +592,26 @@ long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const return -1; } -long FString::LastIndexOfAny (const FString &charset) const +ptrdiff_t FString::LastIndexOfAny (const FString &charset) const { - return LastIndexOfAny (charset.Chars, long(Len())); + return LastIndexOfAny (charset.Chars, Len()); } -long FString::LastIndexOfAny (const char *charset) const +ptrdiff_t FString::LastIndexOfAny (const char *charset) const { return LastIndexOfAny (charset, long(Len())); } -long FString::LastIndexOfAny (const FString &charset, long endIndex) const +ptrdiff_t FString::LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const { return LastIndexOfAny (charset.Chars, endIndex); } -long FString::LastIndexOfAny (const char *charset, long endIndex) const +ptrdiff_t FString::LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const { if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } while (--endIndex >= 0) { @@ -623,31 +623,31 @@ long FString::LastIndexOfAny (const char *charset, long endIndex) const return -1; } -long FString::LastIndexOf (const FString &substr) const +ptrdiff_t FString::LastIndexOf (const FString &substr) const { - return LastIndexOf(substr.Chars, long(Len() - substr.Len()), substr.Len()); + return LastIndexOf(substr.Chars, Len() - substr.Len(), substr.Len()); } -long FString::LastIndexOf (const FString &substr, long endIndex) const +ptrdiff_t FString::LastIndexOf (const FString &substr, ptrdiff_t endIndex) const { return LastIndexOf(substr.Chars, endIndex, substr.Len()); } -long FString::LastIndexOf (const char *substr) const +ptrdiff_t FString::LastIndexOf (const char *substr) const { - return LastIndexOf(substr, long(Len() - strlen(substr)), strlen(substr)); + return LastIndexOf(substr, Len() - strlen(substr), strlen(substr)); } -long FString::LastIndexOf (const char *substr, long endIndex) const +ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex) const { return LastIndexOf(substr, endIndex, strlen(substr)); } -long FString::LastIndexOf (const char *substr, long endIndex, size_t substrlen) const +ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const { if ((size_t)endIndex + substrlen > Len()) { - endIndex = long(Len() - substrlen); + endIndex = Len() - substrlen; } while (endIndex >= 0) { @@ -1256,15 +1256,15 @@ void FString::Split(TArray& tokens, const char *delimiter, EmptyTokenTy { assert(nullptr != delimiter); - const long selfLen = static_cast(Len()); - const long delimLen = static_cast(strlen(delimiter)); - long lastPos = 0; + const auto selfLen = static_cast(Len()); + const auto delimLen = static_cast(strlen(delimiter)); + ptrdiff_t lastPos = 0; if (selfLen == 0) return; // Empty strings do not contain tokens, even with TOK_KEEPEMPTY. while (lastPos <= selfLen) { - long pos = IndexOf(delimiter, lastPos); + auto pos = IndexOf(delimiter, lastPos); if (-1 == pos) { diff --git a/src/common/utility/zstring.h b/src/common/utility/zstring.h index a30458c3c..4640d5c28 100644 --- a/src/common/utility/zstring.h +++ b/src/common/utility/zstring.h @@ -215,28 +215,28 @@ public: void AppendCharacter(int codepoint); void DeleteLastCharacter(); - long IndexOf (const FString &substr, long startIndex=0) const; - long IndexOf (const char *substr, long startIndex=0) const; - long IndexOf (char subchar, long startIndex=0) const; + ptrdiff_t IndexOf (const FString &substr, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOf (const char *substr, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOf (char subchar, ptrdiff_t startIndex=0) const; - long IndexOfAny (const FString &charset, long startIndex=0) const; - long IndexOfAny (const char *charset, long startIndex=0) const; + ptrdiff_t IndexOfAny (const FString &charset, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOfAny (const char *charset, ptrdiff_t startIndex=0) const; // This is only kept for backwards compatibility with old ZScript versions that used this function and depend on its bug. - long LastIndexOf (char subchar) const; - long LastIndexOfBroken (const FString &substr, long endIndex) const; - long LastIndexOf (char subchar, long endIndex) const; + ptrdiff_t LastIndexOf (char subchar) const; + ptrdiff_t LastIndexOfBroken (const FString &substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (char subchar, ptrdiff_t endIndex) const; - long LastIndexOfAny (const FString &charset) const; - long LastIndexOfAny (const char *charset) const; - long LastIndexOfAny (const FString &charset, long endIndex) const; - long LastIndexOfAny (const char *charset, long endIndex) const; + ptrdiff_t LastIndexOfAny (const FString &charset) const; + ptrdiff_t LastIndexOfAny (const char *charset) const; + ptrdiff_t LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const; - long LastIndexOf (const FString &substr) const; - long LastIndexOf (const FString &substr, long endIndex) const; - long LastIndexOf (const char *substr) const; - long LastIndexOf (const char *substr, long endIndex) const; - long LastIndexOf (const char *substr, long endIndex, size_t substrlen) const; + ptrdiff_t LastIndexOf (const FString &substr) const; + ptrdiff_t LastIndexOf (const FString &substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (const char *substr) const; + ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const; void ToUpper (); void ToLower (); diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index d147c8e7e..ca0f50f87 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -762,7 +762,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, FString path; if (info.Load[i][0] != ':') { - long lastslash = picks[pick].mFullPath.LastIndexOf('/'); + auto lastslash = picks[pick].mFullPath.LastIndexOf('/'); if (lastslash == -1) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 245922beb..1b77b57d8 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -903,6 +903,7 @@ static void End2DAndUpdate() twod->End(); CheckBench(); screen->Update(); + twod->OnFrameDone(); } //========================================================================== @@ -2121,8 +2122,8 @@ static void AddAutoloadFiles(const char *autoname) // Add common (global) wads D_AddConfigFiles(allwads, "Global.Autoload", "*.wad", GameConfig); - long len; - int lastpos = -1; + ptrdiff_t len; + ptrdiff_t lastpos = -1; while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) { diff --git a/src/g_game.cpp b/src/g_game.cpp index bfebb4f6b..fdbc18aa8 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1014,7 +1014,7 @@ bool G_Responder (event_t *ev) { if (ST_Responder (ev)) return true; // status window ate it - if (!viewactive && primaryLevel->automap->Responder (ev, false)) + if (!viewactive && primaryLevel->automap && primaryLevel->automap->Responder (ev, false)) return true; // automap ate it } else if (gamestate == GS_FINALE) diff --git a/src/g_level.cpp b/src/g_level.cpp index 0f85fc144..6468dd29d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -378,6 +378,10 @@ void G_NewInit () if (primaryLevel->FraggleScriptThinker) primaryLevel->FraggleScriptThinker->Destroy(); primaryLevel->FraggleScriptThinker = nullptr; + // Destroy thinkers that may remain after change level failure + // Usually, the list contains just a sentinel when such error occurred + primaryLevel->Thinkers.DestroyThinkersInList(STAT_TRAVELLING); + G_ClearSnapshots (); netgame = false; multiplayer = multiplayernext; diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 830cef232..17898f3ae 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -255,7 +255,7 @@ void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man) { FString section = workname + ".Autoload"; CreateSectionAtStart(section.GetChars()); - long dotpos = workname.LastIndexOf('.'); + auto dotpos = workname.LastIndexOf('.'); if (dotpos < 0) break; workname.Truncate(dotpos); } diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 40474c69e..6680911ac 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -635,7 +635,7 @@ void M_ScreenShot (const char *filename) if (!screenshot_quiet) { - int slash = -1; + ptrdiff_t slash = -1; if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\"); Printf ("Captured %s\n", autoname.GetChars()+slash+1); } diff --git a/src/maploader/glnodes.cpp b/src/maploader/glnodes.cpp index 216fb5784..843afeaa5 100644 --- a/src/maploader/glnodes.cpp +++ b/src/maploader/glnodes.cpp @@ -1001,13 +1001,13 @@ static FString CreateCacheName(MapData *map, bool create) { FString path = M_GetCachePath(create); FString lumpname = fileSystem.GetFileFullPath(map->lumpnum); - int separator = lumpname.IndexOf(':'); + auto separator = lumpname.IndexOf(':'); path << '/' << lumpname.Left(separator); if (create) CreatePath(path); lumpname.ReplaceChars('/', '%'); lumpname.ReplaceChars(':', '$'); - path << '/' << lumpname.Right(lumpname.Len() - separator - 1) << ".gzc"; + path << '/' << lumpname.Right((ptrdiff_t)lumpname.Len() - separator - 1) << ".gzc"; return path; } diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 1df0673a1..652530a64 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -64,6 +64,7 @@ #include "gameconfigfile.h" #include "d_player.h" #include "teaminfo.h" +#include "hwrenderer/scene/hw_drawinfo.h" EXTERN_CVAR(Int, cl_gfxlocalization) EXTERN_CVAR(Bool, m_quickexit) @@ -295,6 +296,7 @@ CCMD (menu_quit) { // F10 if (m_quickexit) { + CleanSWDrawer(); ST_Endoom(); } @@ -326,6 +328,7 @@ CCMD (menu_quit) I_WaitVBL(105); } } + CleanSWDrawer(); ST_Endoom(); }); @@ -568,8 +571,21 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs) if (y < topy) topy = y; } + int spacing = ld->mLinespacing; + for (unsigned i = 0; i < AllEpisodes.Size(); i++) + { + if (AllEpisodes[i].mPicName.IsNotEmpty()) + { + FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName); + if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName)) + continue; + } + if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18; + break; + } + // center the menu on the screen if the top space is larger than the bottom space - int totalheight = posy + AllEpisodes.Size() * ld->mLinespacing - topy; + int totalheight = posy + AllEpisodes.Size() * spacing - topy; if (totalheight < 190 || AllEpisodes.Size() == 1) { @@ -610,15 +626,15 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs) { FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName); if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName)) - it = CreateListMenuItemPatch(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i); + it = CreateListMenuItemPatch(posx, posy, spacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i); } if (it == nullptr) { - it = CreateListMenuItemText(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, + it = CreateListMenuItemText(posx, posy, spacing, AllEpisodes[i].mShortcut, AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i); } ld->mItems.Push(it); - posy += ld->mLinespacing; + posy += spacing; } if (AllEpisodes.Size() == 1) { @@ -1070,9 +1086,10 @@ void M_StartupSkillMenu(FNewGameStartup *gs) } } - if (done != restart) + int spacing = ld->mLinespacing; + //if (done != restart) { - done = restart; + //done = restart; ld->mSelectedItem = ld->mItems.Size() + defindex; int posy = y; @@ -1085,8 +1102,20 @@ void M_StartupSkillMenu(FNewGameStartup *gs) if (y < topy) topy = y; } + for (unsigned i = 0; i < MenuSkills.Size(); i++) + { + if (MenuSkills[i]->PicName.IsNotEmpty()) + { + FTextureID tex = GetMenuTexture(MenuSkills[i]->PicName); + if (MenuSkills[i]->MenuName.IsEmpty() || OkForLocalization(tex, MenuSkills[i]->MenuName)) + continue; + } + if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18; + break; + } + // center the menu on the screen if the top space is larger than the bottom space - int totalheight = posy + MenuSkills.Size() * ld->mLinespacing - topy; + int totalheight = posy + MenuSkills.Size() * spacing - topy; if (totalheight < 190 || MenuSkills.Size() == 1) { @@ -1154,16 +1183,16 @@ void M_StartupSkillMenu(FNewGameStartup *gs) { FTextureID tex = GetMenuTexture(skill.PicName); if (skill.MenuName.IsEmpty() || OkForLocalization(tex, skill.MenuName)) - li = CreateListMenuItemPatch(posx, y, ld->mLinespacing, skill.Shortcut, tex, action, SkillIndices[i]); + li = CreateListMenuItemPatch(posx, y, spacing, skill.Shortcut, tex, action, SkillIndices[i]); } if (li == nullptr) { - li = CreateListMenuItemText(posx, y, ld->mLinespacing, skill.Shortcut, + li = CreateListMenuItemText(posx, y, spacing, skill.Shortcut, pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, SkillIndices[i]); } ld->mItems.Push(li); GC::WriteBarrier(*desc, li); - y += ld->mLinespacing; + y += spacing; } if (AllEpisodes[gs->Episode].mNoSkill || MenuSkills.Size() == 1) { diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 7253eafbe..2889a06a5 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -175,22 +175,6 @@ void P_Ticker (void) { P_UpdateSpecials(Level); } - it = Level->GetThinkerIterator(); - - // Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame. - while ((ac = it.Next())) - { - if (ac->flags8 & MF8_RECREATELIGHTS) - { - ac->flags8 &= ~MF8_RECREATELIGHTS; - ac->SetDynamicLights(); - } - // This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop. - if ((ac->effects || ac->fountaincolor) && !Level->isFrozen()) - { - P_RunEffect(ac, ac->effects); - } - } // for par times Level->time++; diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 64099981f..75c75e789 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -42,6 +42,7 @@ #include "v_text.h" #include "g_levellocals.h" #include "a_dynlight.h" +#include "v_video.h" static int ThinkCount; @@ -106,6 +107,25 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) ThinkCycles.Clock(); + auto recreateLights = [=]() { + auto it = Level->GetThinkerIterator(); + + // Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame. + while (auto ac = it.Next()) + { + if (ac->flags8 & MF8_RECREATELIGHTS) + { + ac->flags8 &= ~MF8_RECREATELIGHTS; + ac->SetDynamicLights(); + } + // This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop. + if ((ac->effects || ac->fountaincolor) && !Level->isFrozen()) + { + P_RunEffect(ac, ac->effects); + } + } + }; + if (!profilethinkers) { // Tick every thinker left from last time @@ -124,11 +144,15 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - for (auto light = Level->lights; light;) + if (Level->HasDynamicLights) { - auto next = light->next; - light->Tick(); - light = next; + recreateLights(); + for (auto light = Level->lights; light;) + { + auto next = light->next; + light->Tick(); + light = next; + } } } else @@ -150,8 +174,9 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - if (Level->lights) + if (Level->lights && Level->HasDynamicLights) { + recreateLights(); // Also profile the internal dynamic lights, even though they are not implemented as thinkers. auto &prof = Profiles[NAME_InternalDynamicLight]; prof.timer.Clock(); diff --git a/src/playsim/mapthinkers/a_floor.cpp b/src/playsim/mapthinkers/a_floor.cpp index a94c98012..27dc1cf0e 100644 --- a/src/playsim/mapthinkers/a_floor.cpp +++ b/src/playsim/mapthinkers/a_floor.cpp @@ -648,7 +648,7 @@ bool FLevelLocals::EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, d floor->m_Instant = false; floor->m_Crush = (usespecials & DFloor::stairCrush) ? 10 : -1; //jff 2/27/98 fix uninitialized crush field - floor->m_Hexencrush = false; + floor->m_Hexencrush = true; floor->m_Speed = speed; height = sec->CenterFloor() + stairstep; diff --git a/src/playsim/p_maputl.cpp b/src/playsim/p_maputl.cpp index 68ab182e3..4f3af3c85 100644 --- a/src/playsim/p_maputl.cpp +++ b/src/playsim/p_maputl.cpp @@ -910,13 +910,13 @@ FBlockThingsIterator::FBlockThingsIterator(FLevelLocals *l, int _minx, int _miny Reset(); } -void FBlockThingsIterator::init(const FBoundingBox &box) +void FBlockThingsIterator::init(const FBoundingBox &box, bool clearhash) { maxy = Level->blockmap.GetBlockY(box.Top()); miny = Level->blockmap.GetBlockY(box.Bottom()); maxx = Level->blockmap.GetBlockX(box.Right()); minx = Level->blockmap.GetBlockX(box.Left()); - ClearHash(); + if (clearhash) ClearHash(); Reset(); } @@ -1139,7 +1139,7 @@ void FMultiBlockThingsIterator::startIteratorForGroup(int group) offset.X += checkpoint.X; offset.Y += checkpoint.Y; bbox.setBox(offset.X, offset.Y, checkpoint.Z); - blockIterator.init(bbox); + blockIterator.init(bbox, false); } //=========================================================================== @@ -1153,6 +1153,7 @@ void FMultiBlockThingsIterator::Reset() index = -1; portalflags = 0; startIteratorForGroup(basegroup); + blockIterator.ClearHash(); } //=========================================================================== @@ -1847,6 +1848,7 @@ AActor *P_RoughMonsterSearch(AActor *mo, int distance, bool onlyseekable, bool f { BlockCheckInfo info; info.onlyseekable = onlyseekable; + info.fov = fov; if ((info.frontonly = frontonly)) { info.frontline.x = mo->X(); diff --git a/src/playsim/p_maputl.h b/src/playsim/p_maputl.h index e293f317f..0c93ab445 100644 --- a/src/playsim/p_maputl.h +++ b/src/playsim/p_maputl.h @@ -319,7 +319,7 @@ public: Level = l; init(box); } - void init(const FBoundingBox &box); + void init(const FBoundingBox &box, bool clearhash = true); AActor *Next(bool centeronly = false); void Reset() { StartBlock(minx, miny); } }; diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index d970d5239..2d7c0eb2e 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -183,7 +183,7 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float ofsY) { AActor * playermo = players[consoleplayer].camera; - FSpriteModelFrame *smf = FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); // [BB] No model found for this sprite, so we can't render anything. if (smf == nullptr) @@ -216,7 +216,7 @@ void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float o renderer->BeginDrawHUDModel(playermo->RenderStyle, objectToWorldMatrix, orientation < 0); uint32_t trans = psp->GetTranslation() != 0 ? psp->GetTranslation() : 0; if ((psp->Flags & PSPF_PLAYERTRANSLATED)) trans = psp->Owner->mo->Translation; - RenderFrameModels(renderer, playermo->Level, smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), trans); + RenderFrameModels(renderer, playermo->Level, smf, psp->GetState(), psp->GetTics(), psp->Caller->GetClass(), trans); renderer->EndDrawHUDModel(playermo->RenderStyle); } @@ -777,15 +777,14 @@ FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, boo bool IsHUDModelForPlayerAvailable (player_t * player) { - if (player == nullptr || player->ReadyWeapon == nullptr) + if (player == nullptr || player->psprites == nullptr) return false; - DPSprite *psp = player->FindPSprite(PSP_WEAPON); - - if (psp == nullptr) - return false; - - FSpriteModelFrame *smf = FindModelFrame(player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false); - return ( smf != nullptr ); + // [MK] check that at least one psprite uses models + for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) + { + FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + if ( smf != nullptr ) return true; + } + return false; } - diff --git a/src/rendering/hwrenderer/hw_dynlightdata.cpp b/src/rendering/hwrenderer/hw_dynlightdata.cpp index f65b03172..044d34d3d 100644 --- a/src/rendering/hwrenderer/hw_dynlightdata.cpp +++ b/src/rendering/hwrenderer/hw_dynlightdata.cpp @@ -29,6 +29,7 @@ #include "a_dynlight.h" #include "hw_dynlightdata.h" #include"hw_cvars.h" +#include "v_video.h" #include "hwrenderer/scene/hw_drawstructs.h" // If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization. @@ -107,7 +108,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f } float shadowIndex; - if (gl_light_shadowmap) // note: with gl_light_shadowmap switched off, we cannot rely on properly set indices anymore. + if (screen->mShadowMap.Enabled()) // note: with shadowmaps switched off, we cannot rely on properly set indices anymore. { shadowIndex = light->mShadowmapIndex + 1.0f; } diff --git a/src/rendering/hwrenderer/hw_entrypoint.cpp b/src/rendering/hwrenderer/hw_entrypoint.cpp index 64945f990..38fc2b6e2 100644 --- a/src/rendering/hwrenderer/hw_entrypoint.cpp +++ b/src/rendering/hwrenderer/hw_entrypoint.cpp @@ -40,6 +40,7 @@ #include "flatvertices.h" #include "v_palette.h" #include "d_main.h" +#include "g_cvars.h" #include "hw_lightbuffer.h" #include "hw_cvars.h" @@ -107,7 +108,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou R_SetupFrame(mainvp, r_viewwindow, camera); - if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && gl_light_shadowmap && screen->mPipelineType == 0 && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER)) + if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && camera->Level->HasDynamicLights && gl_light_shadowmap && screen->mPipelineType == 0 && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER)) { screen->SetAABBTree(camera->Level->aabbTree); screen->mShadowMap.SetCollectLights([=] { diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index fd2f9cc2e..c763ab15f 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -614,7 +614,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area) for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) { if (!psp->GetState()) continue; - FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false) : nullptr; + FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); // This is an 'either-or' proposition. This maybe needs some work to allow overlays with weapon models but as originally implemented this just won't work. if (smf && !hudModelStep) continue; if (!smf && hudModelStep) continue; diff --git a/src/scripting/backend/codegen_doom.cpp b/src/scripting/backend/codegen_doom.cpp index 111147c2c..e10756354 100644 --- a/src/scripting/backend/codegen_doom.cpp +++ b/src/scripting/backend/codegen_doom.cpp @@ -808,12 +808,12 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi { FName scopename = NAME_None; FString statestring = _statestring; - int scopeindex = statestring.IndexOf("::"); + auto scopeindex = statestring.IndexOf("::"); if (scopeindex >= 0) { scopename = FName(statestring, scopeindex, false); - statestring = statestring.Right(statestring.Len() - scopeindex - 2); + statestring = statestring.Right((ptrdiff_t)statestring.Len() - scopeindex - 2); } names = MakeStateNameList(statestring); names.Insert(0, scopename); diff --git a/wadsrc/static/fonts/indexfont/0030.png b/wadsrc/static/fonts/indexfont/0030.png new file mode 100644 index 000000000..1e4547d5b Binary files /dev/null and b/wadsrc/static/fonts/indexfont/0030.png differ diff --git a/wadsrc/static/fonts/indexfont/font.inf b/wadsrc/static/fonts/indexfont/font.inf new file mode 100644 index 000000000..c7afafabc --- /dev/null +++ b/wadsrc/static/fonts/indexfont/font.inf @@ -0,0 +1,2 @@ +CellSize 4, 6 // This implies font sheets + diff --git a/wadsrc/static/indexfont b/wadsrc/static/indexfont deleted file mode 100644 index eb8188e27..000000000 Binary files a/wadsrc/static/indexfont and /dev/null differ diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 4bb946b44..de45efa28 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -209,6 +209,7 @@ ListMenu "EpisodeMenu" { Position 48, 63 StaticPatch 54, 38, "M_EPISOD", 0 , "$MNU_EPISODE" + linespacing 16 } IfGame(Strife) { @@ -234,6 +235,7 @@ ListMenu "SkillMenu" IfGame(Doom, Chex) { StaticPatch 96, 14, "M_NEWG", 0, "$MNU_NEWGAME" + linespacing 16 } IfGame(Strife) { diff --git a/wadsrc/static/zscript/actors/doom/doommisc.zs b/wadsrc/static/zscript/actors/doom/doommisc.zs index c6d8af717..a761f94e0 100644 --- a/wadsrc/static/zscript/actors/doom/doommisc.zs +++ b/wadsrc/static/zscript/actors/doom/doommisc.zs @@ -26,7 +26,7 @@ class ExplosiveBarrel : Actor BEXP A 5 BRIGHT; BEXP B 5 BRIGHT A_Scream; BEXP C 5 BRIGHT; - BEXP D 5 BRIGHT A_Explode; + BEXP D 10 BRIGHT A_Explode; BEXP E 10 BRIGHT; TNT1 A 1050 BRIGHT A_BarrelDestroy; TNT1 A 5 A_Respawn; diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 67b07b282..e63a5d773 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -456,6 +456,7 @@ class PlayerPawn : Actor virtual void CheckWeaponChange () { let player = self.player; + if (!player) return; if ((player.WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled. player.morphTics != 0) // Morphed classes cannot change weapons. { // ...so throw away any pending weapon requests. diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index 3c472a4a6..64f5921fe 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -412,7 +412,6 @@ struct Screen native native static Color PaletteColor(int index); native static int GetWidth(); native static int GetHeight(); - //native static Vector2 GetTextScreenSize(); native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1); native static void Dim(Color col, double amount, int x, int y, int w, int h); diff --git a/wadsrc/static/zscript/engine/ui/menu/listmenu.zs b/wadsrc/static/zscript/engine/ui/menu/listmenu.zs index c8a8a0f2e..dc12f4129 100644 --- a/wadsrc/static/zscript/engine/ui/menu/listmenu.zs +++ b/wadsrc/static/zscript/engine/ui/menu/listmenu.zs @@ -328,6 +328,36 @@ class ListMenu : Menu { mFocusControl = NULL; } + + //============================================================================= + // + // + // + //============================================================================= + + void ChangeLineSpacing(int newspace) + { + double top = -32767; + + for (int i = 0; i < mDesc.mItems.Size(); i++) + { + let selitem = ListMenuItemSelectable(mDesc.mItems[i]); + if (selitem) + { + let y = mDesc.mItems[i].GetY(); + if (top == -32767) + { + top = y; + } + else + { + let newy = top + (y - top) / mDesc.mLineSpacing * newspace; + mDesc.mItems[i].SetY(newy); + } + } + } + mDesc.mLineSpacing = newspace; + } } diff --git a/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs b/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs index 53a32e47f..2169e9fac 100644 --- a/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs +++ b/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs @@ -40,6 +40,7 @@ class MenuItemBase : Object native ui version("2.4") double GetY() { return mYpos; } double GetX() { return mXpos; } void SetX(double x) { mXpos = x; } + void SetY(double x) { mYpos = x; } virtual void OnMenuCreated() {} } diff --git a/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs b/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs index f1a64acc4..39cad7adb 100644 --- a/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs @@ -66,7 +66,7 @@ class DoomStatusBar : BaseStatusBar if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar) { - DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198)); + DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198), DI_DIMDEPLETED); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); @@ -169,7 +169,7 @@ class DoomStatusBar : BaseStatusBar } if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { - DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); + DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17), DI_DIMDEPLETED); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); } if (deathmatch) diff --git a/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs b/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs index 28eaf9db4..5c29e176f 100644 --- a/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs @@ -127,7 +127,7 @@ class HereticStatusBar : BaseStatusBar //inventory box if (CPlayer.mo.InvSel != null) { - DrawInventoryIcon(CPlayer.mo.InvSel, (194, 175), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (194, 175), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (209, 182), DI_TEXT_ALIGN_RIGHT); @@ -205,7 +205,7 @@ class HereticStatusBar : BaseStatusBar // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. DrawImage("ARTIBOX", (-46, -1), 0, HX_SHADOW); - DrawInventoryIcon(CPlayer.mo.InvSel, (-46, -15), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (-46, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-32, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); diff --git a/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs b/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs index 4b5d7189d..ce4d3dc89 100644 --- a/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs @@ -83,7 +83,7 @@ class HexenStatusBar : BaseStatusBar // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. DrawImage("ARTIBOX", (-66, -1), 0, HX_SHADOW); - DrawInventoryIcon(CPlayer.mo.InvSel, (-66, -15), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (-66, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-52, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); @@ -146,7 +146,7 @@ class HexenStatusBar : BaseStatusBar //inventory box if (CPlayer.mo.InvSel != null) { - DrawInventoryIcon(CPlayer.mo.InvSel, (159.5, 177), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (159.5, 177), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (174, 184), DI_TEXT_ALIGN_RIGHT); diff --git a/wadsrc/static/zscript/ui/statusbar/statusbar.zs b/wadsrc/static/zscript/ui/statusbar/statusbar.zs index b4d4f8a3d..75cbbe827 100644 --- a/wadsrc/static/zscript/ui/statusbar/statusbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/statusbar.zs @@ -981,7 +981,7 @@ class BaseStatusBar : StatusBarCore native } else { - DrawInventoryIcon(item, itempos + (boxsize.X * i, 0), flags | DI_ITEM_CENTER ); + DrawInventoryIcon(item, itempos + (boxsize.X * i, 0), flags | DI_ITEM_CENTER | DI_DIMDEPLETED ); } }