diff --git a/source/common/engine/i_interface.cpp b/source/common/engine/i_interface.cpp index 217f9212f..13d35a3a9 100644 --- a/source/common/engine/i_interface.cpp +++ b/source/common/engine/i_interface.cpp @@ -1,6 +1,8 @@ #include "i_interface.h" #include "st_start.h" +static_assert(sizeof(void*) == 8, "32 builds are not supported"); + // Some global engine variables taken out of the backend code. FStartupScreen* StartWindow; SystemCallbacks sysCallbacks; diff --git a/source/common/engine/namedef.h b/source/common/engine/namedef.h index 7f9024538..af8e2bca0 100644 --- a/source/common/engine/namedef.h +++ b/source/common/engine/namedef.h @@ -75,8 +75,17 @@ xx(ACS_NamedExecuteWithResult) xx(__decorate_internal_int__) xx(__decorate_internal_bool__) xx(__decorate_internal_float__) + +// Per-actor sound channels (for deprecated PlaySoundEx function) Do not separate this block!!! +xx(Auto) xx(Weapon) +xx(Voice) xx(Item) +xx(Body) +xx(SoundSlot5) +xx(SoundSlot6) +xx(SoundSlot7) + xx(LevelLocals) xx(Level) diff --git a/source/common/engine/stats.h b/source/common/engine/stats.h index d6e976ea5..0794455d2 100644 --- a/source/common/engine/stats.h +++ b/source/common/engine/stats.h @@ -35,6 +35,9 @@ #define __STATS_H__ #include "zstring.h" +#if defined __i386__ +#include "x86.h" +#endif #if !defined _WIN32 && !defined __APPLE__ diff --git a/source/common/platform/posix/cocoa/i_main.mm b/source/common/platform/posix/cocoa/i_main.mm index 382fabb23..21b4b3bef 100644 --- a/source/common/platform/posix/cocoa/i_main.mm +++ b/source/common/platform/posix/cocoa/i_main.mm @@ -164,6 +164,9 @@ void I_DetectOS() case 12: name = "macOS Monterey"; break; + case 13: + name = "macOS Ventura"; + break; } char release[16] = "unknown"; diff --git a/source/common/platform/win32/i_mainwindow.cpp b/source/common/platform/win32/i_mainwindow.cpp index d3e27b21c..3395ec430 100644 --- a/source/common/platform/win32/i_mainwindow.cpp +++ b/source/common/platform/win32/i_mainwindow.cpp @@ -10,6 +10,7 @@ #include "utf8.h" #include "v_font.h" #include "i_net.h" +#include "engineerrors.h" #include #include #include @@ -264,7 +265,7 @@ static INT_PTR CALLBACK NetStartPaneProc(HWND hDlg, UINT msg, WPARAM wParam, LPA { if (msg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL) { - PostQuitMessage(0); + PostMessage(hDlg, WM_COMMAND, 1337, 1337); return TRUE; } return FALSE; @@ -357,6 +358,11 @@ bool MainWindow::RunMessageLoop(bool (*timer_callback)(void*), void* userdata) } else { + // This must be outside the window function so that the exception does not cross DLL boundaries. + if (msg.message == WM_COMMAND && msg.wParam == 1337 && msg.lParam == 1337) + { + throw CExitEvent(0); + } if (msg.message == WM_TIMER && msg.hwnd == Window && msg.wParam == 1337) { if (timer_callback(userdata)) diff --git a/source/common/rendering/vulkan/system/vk_device.cpp b/source/common/rendering/vulkan/system/vk_device.cpp index 5aa229cb1..a092d9bc6 100644 --- a/source/common/rendering/vulkan/system/vk_device.cpp +++ b/source/common/rendering/vulkan/system/vk_device.cpp @@ -47,7 +47,7 @@ bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names); bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface); -FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames); +FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames, int maxFrames = -1); // Physical device info static std::vector AvailableDevices; @@ -409,7 +409,7 @@ VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT mess if (vk_debug_callstack && showcallstack) { - FString callstack = JitCaptureStackTrace(0, true); + FString callstack = JitCaptureStackTrace(0, true, 5); if (!callstack.IsEmpty()) Printf("%s\n", callstack.GetChars()); } diff --git a/source/common/scripting/backend/codegen.cpp b/source/common/scripting/backend/codegen.cpp index 9232a6589..175b6206e 100644 --- a/source/common/scripting/backend/codegen.cpp +++ b/source/common/scripting/backend/codegen.cpp @@ -1850,7 +1850,7 @@ FxExpression *FxMinusSign::Resolve(FCompileContext& ctx) ExpEmit FxMinusSign::Emit(VMFunctionBuilder *build) { - assert(ValueType == Operand->ValueType); + //assert(ValueType == Operand->ValueType); ExpEmit from = Operand->Emit(build); ExpEmit to; assert(from.Konst == 0); @@ -2777,7 +2777,7 @@ FxExpression *FxAddSub::Resolve(FCompileContext& ctx) else if (left->IsVector() && right->IsVector()) { // a vector2 can be added to or subtracted from a vector 3 but it needs to be the right operand. - if (left->ValueType == right->ValueType || (left->IsVector3() && right->IsVector2())) + if (((left->IsVector3() || left->IsVector2()) && right->IsVector2()) || (left->IsVector3() && right->IsVector3())) { ValueType = left->ValueType; } @@ -3522,7 +3522,8 @@ FxExpression *FxCompareEq::Resolve(FCompileContext& ctx) return nullptr; } - if (left->ValueType != right->ValueType) // identical types are always comparable, if they can be placed in a register, so we can save most checks if this is the case. + // identical types are always comparable, if they can be placed in a register, so we can save most checks if this is the case. + if (left->ValueType != right->ValueType && !(left->IsVector2() && right->IsVector2()) && !(left->IsVector3() && right->IsVector3())) { FxExpression *x; if (left->IsNumeric() && right->ValueType == TypeString && (x = StringConstToChar(right))) diff --git a/source/common/scripting/jit/jit.h b/source/common/scripting/jit/jit.h index faaf65112..c4aa1fb27 100644 --- a/source/common/scripting/jit/jit.h +++ b/source/common/scripting/jit/jit.h @@ -5,4 +5,4 @@ JitFuncPtr JitCompile(VMScriptFunction *func); void JitDumpLog(FILE *file, VMScriptFunction *func); -FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames); +FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames, int maxFrames = -1); diff --git a/source/common/scripting/jit/jit_runtime.cpp b/source/common/scripting/jit/jit_runtime.cpp index 647647442..89672b940 100644 --- a/source/common/scripting/jit/jit_runtime.cpp +++ b/source/common/scripting/jit/jit_runtime.cpp @@ -5,6 +5,7 @@ #ifdef WIN32 #include +#include #else #include #include @@ -813,8 +814,16 @@ static int CaptureStackTrace(int max_frames, void **out_frames) class NativeSymbolResolver { public: - NativeSymbolResolver() { SymInitialize(GetCurrentProcess(), nullptr, TRUE); } - ~NativeSymbolResolver() { SymCleanup(GetCurrentProcess()); } + NativeSymbolResolver() + { + SymInitialize(GetCurrentProcess(), nullptr, TRUE); + GetModuleInformation(GetCurrentProcess(), GetModuleHandle(0), &moduleInfo, sizeof(MODULEINFO)); + } + + ~NativeSymbolResolver() + { + SymCleanup(GetCurrentProcess()); + } FString GetName(void *frame) { @@ -830,6 +839,9 @@ public: BOOL result = SymGetSymFromAddr64(GetCurrentProcess(), (DWORD64)frame, &displacement, symbol64); if (result) { + if ((DWORD64)frame < (DWORD64)moduleInfo.lpBaseOfDll || (DWORD64)frame >= ((DWORD64)moduleInfo.lpBaseOfDll + moduleInfo.SizeOfImage)) + return s; // Ignore anything not from the exe itself + IMAGEHLP_LINE64 line64; DWORD displacement1 = 0; memset(&line64, 0, sizeof(IMAGEHLP_LINE64)); @@ -847,6 +859,8 @@ public: return s; } + + MODULEINFO moduleInfo = {}; }; #else class NativeSymbolResolver @@ -952,7 +966,7 @@ FString JitGetStackFrameName(NativeSymbolResolver *nativeSymbols, void *pc) return nativeSymbols ? nativeSymbols->GetName(pc) : FString(); } -FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames) +FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames, int maxFrames) { void *frames[32]; int numframes = CaptureStackTrace(32, frames); @@ -961,10 +975,18 @@ FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames) if (includeNativeFrames) nativeSymbols.reset(new NativeSymbolResolver()); + int total = 0; FString s; for (int i = framesToSkip + 1; i < numframes; i++) { - s += JitGetStackFrameName(nativeSymbols.get(), frames[i]); + FString name = JitGetStackFrameName(nativeSymbols.get(), frames[i]); + if (!name.IsEmpty()) + { + s += name; + total++; + if (maxFrames != -1 && maxFrames == total) + break; + } } return s; } diff --git a/source/common/scripting/vm/vmframe.cpp b/source/common/scripting/vm/vmframe.cpp index 6cb03be43..476b945c2 100644 --- a/source/common/scripting/vm/vmframe.cpp +++ b/source/common/scripting/vm/vmframe.cpp @@ -56,7 +56,7 @@ CUSTOM_CVAR(Bool, vm_jit, true, CVAR_NOINITCALL) } #else CVAR(Bool, vm_jit, false, CVAR_NOINITCALL|CVAR_NOSET) -FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames) { return FString(); } +FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames, int maxFrames) { return FString(); } void JitRelease() {} #endif