diff --git a/source/common/2d/v_2ddrawer.cpp b/source/common/2d/v_2ddrawer.cpp index 2d1387f02..44865797b 100644 --- a/source/common/2d/v_2ddrawer.cpp +++ b/source/common/2d/v_2ddrawer.cpp @@ -528,8 +528,13 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) offset = osave; } -DShape2D::~DShape2D() { - delete lastParms; +void DShape2D::OnDestroy() { + if (lastParms) delete lastParms; + lastParms = nullptr; + mIndices.Reset(); + mVertices.Reset(); + mCoords.Reset(); + buffers.Reset(); } //========================================================================== diff --git a/source/common/2d/v_2ddrawer.h b/source/common/2d/v_2ddrawer.h index feac2e4d7..8bb113905 100644 --- a/source/common/2d/v_2ddrawer.h +++ b/source/common/2d/v_2ddrawer.h @@ -269,7 +269,7 @@ public: bool uploadedOnce = false; DrawParms* lastParms; - ~DShape2D(); + void OnDestroy() override; }; diff --git a/source/common/engine/namedef.h b/source/common/engine/namedef.h index af285ce7e..489507061 100644 --- a/source/common/engine/namedef.h +++ b/source/common/engine/namedef.h @@ -495,6 +495,7 @@ xx(Blockeverything) xx(Zoneboundary) xx(Jumpover) xx(Blockfloaters) +xx(Blocklandmonsters) xx(Clipmidtex) xx(Wrapmidtex) xx(Midtex3d) @@ -1109,3 +1110,5 @@ xy(menu_advance, "menu/advance") xx(zoomsize) xx(ScreenJobRunner) xx(RazeStatusBar) +xx(RipSound) +xx(Archvile) diff --git a/source/common/engine/serializer_internal.h b/source/common/engine/serializer_internal.h index 161d2ebdf..e05d5785c 100644 --- a/source/common/engine/serializer_internal.h +++ b/source/common/engine/serializer_internal.h @@ -238,7 +238,7 @@ FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T ** vv = value - base; if (vv < 0 || vv >= count) { - Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count); + Printf("Trying to serialize out-of-bounds array value with key '%s', index = %" PRId64 ", size = %" PRId64 "\n", key, vv, count); vv = -1; } } @@ -247,7 +247,7 @@ FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T ** value = nullptr; else if (vv < 0 || vv >= count) { - Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count); + Printf("Trying to serialize out-of-bounds array value with key '%s', index = %" PRId64 ", size = %" PRId64 "\n", key, vv, count); value = nullptr; } else diff --git a/source/common/fonts/v_font.cpp b/source/common/fonts/v_font.cpp index dd10b540e..6b002b754 100644 --- a/source/common/fonts/v_font.cpp +++ b/source/common/fonts/v_font.cpp @@ -958,28 +958,3 @@ char* CleanseString(char* str) return str; } - -#include "c_dispatch.h" -FGameTexture* GetBaseForChar(FGameTexture* t); -CCMD(dumpfonts) -{ - for (auto c : { "tilesmallfont", "tilebigfont", "smallfont2", "digifont", "indexfont" }) - { - auto f = V_GetFont(c); - if (f) - { - Printf("%s\n{\n", c); - for (int i = 33; i < 127; i++) - { - auto ch = f->GetChar(i, CR_UNDEFINED, nullptr); - if (ch) - { - ch = GetBaseForChar(ch); - if (i == 34) Printf("\t\"\\\""); else Printf("\t%c", i); - Printf(" %s\n", ch->GetName().GetChars()); - } - } - Printf("}\n\n"); - } - } -} \ No newline at end of file diff --git a/source/common/models/models_obj.cpp b/source/common/models/models_obj.cpp index 1fa6d3181..1af4fab7e 100644 --- a/source/common/models/models_obj.cpp +++ b/source/common/models/models_obj.cpp @@ -240,13 +240,12 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length */ template void FOBJModel::ParseVector(TArray &array) { - float coord[L]; - for (size_t axis = 0; axis < L; axis++) + T vec; + for (unsigned axis = 0; axis < L; axis++) { sc.MustGetFloat(); - coord[axis] = (float)sc.Float; + vec[axis] = (float)sc.Float; } - T vec(coord); array.Push(vec); } diff --git a/source/common/platform/posix/cocoa/i_main.mm b/source/common/platform/posix/cocoa/i_main.mm index 7159d31ea..a243bdbe5 100644 --- a/source/common/platform/posix/cocoa/i_main.mm +++ b/source/common/platform/posix/cocoa/i_main.mm @@ -35,6 +35,7 @@ #include "s_soundinternal.h" #include +#include #include "c_console.h" #include "c_cvars.h" @@ -89,20 +90,83 @@ struct NSOperatingSystemVersion #endif // before 10.10 +static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 110000 + // The version returned by macOS depends on the SDK which the software has been built against. + // When built against the 10.15 SDK or earlier, Big Sur returns 10.16 for compatibility with previous numbering. + // When built against the 11.0 SDK, it returns 11.0 for forward compatibility. + // https://eclecticlight.co/2020/08/13/macos-version-numbering-isnt-so-simple/ + + // It's impossible to load real SystemVersion.plist when linking with old SDK, i.e. when building for Intel CPU + // Any attempt to read this file is redirected to SystemVersionCompat.plist silently + // Workaround with the external process is needed in order to report correct macOS version + + const char *const plistPath = "/System/Library/CoreServices/SystemVersion.plist"; + struct stat dummy; + + if (stat(plistPath, &dummy) != 0) + return false; + + char commandLine[1024] = {}; + snprintf(commandLine, sizeof commandLine, "defaults read %s ProductVersion", plistPath); + + FILE *const versionFile = popen(commandLine, "r"); + + if (versionFile == nullptr) + return false; + + NSOperatingSystemVersion plistVersion = {}; + char versionString[256] = {}; + + if (fgets(versionString, sizeof versionString, versionFile)) + { + plistVersion.majorVersion = atoi(versionString); + + if (const char *minorVersionString = strstr(versionString, ".")) + { + minorVersionString++; + plistVersion.minorVersion = atoi(minorVersionString); + + if (const char *patchVersionString = strstr(minorVersionString, ".")) + { + patchVersionString++; + plistVersion.patchVersion = atoi(minorVersionString); + } + } + } + + fclose(versionFile); + + if (plistVersion.majorVersion != 0) + { + version = plistVersion; + return true; + } +#endif // MAC_OS_X_VERSION_MAX_ALLOWED < 110000 + + return false; +} + void I_DetectOS() { NSOperatingSystemVersion version = {}; - NSProcessInfo* const processInfo = [NSProcessInfo processInfo]; - if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) + if (!ReadSystemVersionFromPlist(version)) { - version = [processInfo operatingSystemVersion]; + NSProcessInfo *const processInfo = [NSProcessInfo processInfo]; + + if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) + { + version = [processInfo operatingSystemVersion]; + } } const char* name = "Unknown version"; - if (10 == version.majorVersion) + switch (version.majorVersion) { + case 10: switch (version.minorVersion) { case 9: name = "OS X Mavericks"; break; @@ -114,13 +178,13 @@ void I_DetectOS() case 15: name = "macOS Catalina"; break; case 16: name = "macOS Big Sur"; break; } - } - else if (11 == version.majorVersion) - { - switch (version.minorVersion) - { - case 0: name = "macOS Big Sur"; break; - } + break; + case 11: + name = "macOS Big Sur"; + break; + case 12: + name = "macOS Monterey"; + break; } char release[16] = "unknown"; diff --git a/source/common/platform/win32/i_system.cpp b/source/common/platform/win32/i_system.cpp index 6a6119bf2..72930a560 100644 --- a/source/common/platform/win32/i_system.cpp +++ b/source/common/platform/win32/i_system.cpp @@ -199,7 +199,7 @@ void I_DetectOS(void) } else if (info.dwMajorVersion == 10) { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "10 (or higher)" : "Server 2016 (or higher)"; + osname = (info.wProductType == VER_NT_WORKSTATION) ? (info.dwBuildNumber >= 22000 ? "11 (or higher)" : "10") : "Server 2016 (or higher)"; sys_ostype = 3; // modern OS } break; diff --git a/source/common/rendering/vulkan/system/vk_device.cpp b/source/common/rendering/vulkan/system/vk_device.cpp index 2e7ca9aad..ae2b9900f 100644 --- a/source/common/rendering/vulkan/system/vk_device.cpp +++ b/source/common/rendering/vulkan/system/vk_device.cpp @@ -27,6 +27,7 @@ #undef min #endif +#include #include #include #include @@ -361,7 +362,7 @@ VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT mess if (callbackData->pObjects[i].pObjectName) { FString hexname; - hexname.Format("0x%llx", callbackData->pObjects[i].objectHandle); + hexname.Format("0x%" PRIx64, callbackData->pObjects[i].objectHandle); msg.Substitute(hexname.GetChars(), callbackData->pObjects[i].pObjectName); } } diff --git a/source/common/rendering/vulkan/system/vk_framebuffer.cpp b/source/common/rendering/vulkan/system/vk_framebuffer.cpp index 9b83b6e26..5bce01224 100644 --- a/source/common/rendering/vulkan/system/vk_framebuffer.cpp +++ b/source/common/rendering/vulkan/system/vk_framebuffer.cpp @@ -22,6 +22,8 @@ #include "volk/volk.h" +#include + #include "v_video.h" #include "m_png.h" #include "templates.h" @@ -698,7 +700,7 @@ void VulkanFrameBuffer::PrintStartupLog() const auto &limits = props.limits; Printf("Max. texture size: %d\n", limits.maxImageDimension2D); Printf("Max. uniform buffer range: %d\n", limits.maxUniformBufferRange); - Printf("Min. uniform buffer offset alignment: %llu\n", limits.minUniformBufferOffsetAlignment); + Printf("Min. uniform buffer offset alignment: %" PRIu64 "\n", limits.minUniformBufferOffsetAlignment); } void VulkanFrameBuffer::CreateFanToTrisIndexBuffer() diff --git a/source/common/scripting/backend/codegen.cpp b/source/common/scripting/backend/codegen.cpp index 9eb887827..6a551f1c6 100644 --- a/source/common/scripting/backend/codegen.cpp +++ b/source/common/scripting/backend/codegen.cpp @@ -1449,7 +1449,7 @@ FxFontCast::FxFontCast(FxExpression *x) : FxExpression(EFX_FontCast, x->ScriptPosition) { basex = x; - ValueType = TypeSound; + ValueType = TypeFont; } //========================================================================== diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp index cb86e5cd2..6b1806b28 100644 --- a/source/common/scripting/interface/vmnatives.cpp +++ b/source/common/scripting/interface/vmnatives.cpp @@ -978,10 +978,16 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, UnbindACommand) // This is only accessible to the special menu item to run CCMDs. DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand) { - if (CurrentMenu == nullptr) return 0; PARAM_PROLOGUE; PARAM_STRING(cmd); PARAM_BOOL(unsafe); + + // Only menus are allowed to execute CCMDs. + if (DMenu::InMenu == 0) + { + I_FatalError("Attempt to execute CCMD '%s' outside of menu code", cmd.GetChars()); + } + UnsafeExecutionScope scope(unsafe); C_DoCommand(cmd); return 0; diff --git a/source/common/utility/vectors.h b/source/common/utility/vectors.h index e8c39fc28..2118a22fa 100644 --- a/source/common/utility/vectors.h +++ b/source/common/utility/vectors.h @@ -82,6 +82,11 @@ struct TVector2 { } + TVector2(vec_t *o) + : X(o[0]), Y(o[1]) + { + } + void Zero() { Y = X = 0;