diff --git a/libraries/ZWidget/src/core/nanosvg/nanosvg.h b/libraries/ZWidget/src/core/nanosvg/nanosvg.h index 60a323820c..36830f05c6 100644 --- a/libraries/ZWidget/src/core/nanosvg/nanosvg.h +++ b/libraries/ZWidget/src/core/nanosvg/nanosvg.h @@ -192,6 +192,11 @@ void nsvgDelete(NSVGimage* image); #include #include +#ifdef _MSC_VER +#pragma warning(push); +#pragma warning(disable:4244) +#endif + #define NSVG_PI (3.14159265358979323846264338327f) #define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs. @@ -3093,6 +3098,10 @@ void nsvgDelete(NSVGimage* image) free(image); } +#ifdef _MSC_VER +#pragma warning(pop); +#endif + #endif // NANOSVG_IMPLEMENTATION #endif // NANOSVG_H diff --git a/libraries/ZWidget/src/core/schrift/schrift.cpp b/libraries/ZWidget/src/core/schrift/schrift.cpp index 0febb86c00..3b25941352 100644 --- a/libraries/ZWidget/src/core/schrift/schrift.cpp +++ b/libraries/ZWidget/src/core/schrift/schrift.cpp @@ -1548,7 +1548,7 @@ render_outline(Outline *outl, double transform[6], SFT_Image image) numPixels = (unsigned int) image.width * (unsigned int) image.height; - STACK_ALLOC(cells, Cell, 128 * 128, numPixels); + STACK_ALLOC(cells, Cell, 32 * 32, numPixels); if (!cells) { return -1; } diff --git a/libraries/ZWidget/src/widgets/imagebox/imagebox.cpp b/libraries/ZWidget/src/widgets/imagebox/imagebox.cpp index d81a39ab13..45d35a160f 100644 --- a/libraries/ZWidget/src/widgets/imagebox/imagebox.cpp +++ b/libraries/ZWidget/src/widgets/imagebox/imagebox.cpp @@ -24,7 +24,6 @@ void ImageBox::SetImage(std::shared_ptr newImage) void ImageBox::OnPaint(Canvas* canvas) { - canvas->fillRect(Rect::xywh(0.0, 0.0, GetWidth(), GetHeight()), Colorf::fromRgba8(0, 0, 0)); if (image) { canvas->drawImage(image, Point((GetWidth() - (double)image->GetWidth()) * 0.5, (GetHeight() - (double)image->GetHeight()) * 0.5)); diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index 3567f2bff1..c2be564dc9 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -192,7 +192,7 @@ public: TArray mVertices; TArray mData; int Width, Height; - bool isIn2D; + bool isIn2D = false; bool locked = false; // prevents clearing of the data so it can be reused multiple times (useful for screen fades) float screenFade = 1.f; DVector2 offset; @@ -317,7 +317,7 @@ public: RefCountedPtr bufferInfo; - DrawParms* lastParms; + DrawParms* lastParms = nullptr; void OnDestroy() override; }; diff --git a/src/common/audio/music/i_soundfont.cpp b/src/common/audio/music/i_soundfont.cpp index 0f3c0020b9..9737374fc4 100644 --- a/src/common/audio/music/i_soundfont.cpp +++ b/src/common/audio/music/i_soundfont.cpp @@ -465,19 +465,16 @@ const FSoundFontInfo *FSoundFontManager::FindSoundFont(const char *name, int all // //========================================================================== -FSoundFontReader *FSoundFontManager::OpenSoundFont(const char *name, int allowed) +FSoundFontReader *FSoundFontManager::OpenSoundFont(const char *const name, int allowed) { - + if (name == nullptr) return nullptr; // First check if the given name is inside the loaded resources. // To avoid clashes this will only be done if the name has the '.cfg' extension. // Sound fonts cannot be loaded this way. - if (name != nullptr) + const char *p = name + strlen(name) - 4; + if (p > name && !stricmp(p, ".cfg") && fileSystem.CheckNumForFullName(name) >= 0) { - const char *p = name + strlen(name) - 4; - if (p > name && !stricmp(p, ".cfg") && fileSystem.CheckNumForFullName(name) >= 0) - { - return new FLumpPatchSetReader(name); - } + return new FLumpPatchSetReader(name); } // Next check if the file is a .sf file diff --git a/src/common/audio/music/music.cpp b/src/common/audio/music/music.cpp index 769d5c07c2..13837e93e7 100644 --- a/src/common/audio/music/music.cpp +++ b/src/common/audio/music/music.cpp @@ -432,14 +432,14 @@ static FString ReplayGainHash(ZMusicCustomReader* reader, int flength, int playe { std::string playparam = _playparam; - uint8_t buffer[50000]; // for performance reasons only hash the start of the file. If we wanted to do this to large waveform songs it'd cause noticable lag. + TArray buffer(50000, true); // for performance reasons only hash the start of the file. If we wanted to do this to large waveform songs it'd cause noticable lag. uint8_t digest[16]; char digestout[33]; - auto length = reader->read(reader, buffer, 50000); + auto length = reader->read(reader, buffer.data(), 50000); reader->seek(reader, 0, SEEK_SET); MD5Context md5; md5.Init(); - md5.Update(buffer, (int)length); + md5.Update(buffer.data(), (int)length); md5.Final(digest); for (size_t j = 0; j < sizeof(digest); ++j) @@ -448,7 +448,7 @@ static FString ReplayGainHash(ZMusicCustomReader* reader, int flength, int playe } digestout[32] = 0; - auto type = ZMusic_IdentifyMIDIType((uint32_t*)buffer, 32); + auto type = ZMusic_IdentifyMIDIType((uint32_t*)buffer.data(), 32); if (type == MIDI_NOTMIDI) return FStringf("%d:%s", flength, digestout); // get the default for MIDI synth diff --git a/src/common/console/c_enginecmds.cpp b/src/common/console/c_enginecmds.cpp index 4911b9f444..38e64ab46a 100644 --- a/src/common/console/c_enginecmds.cpp +++ b/src/common/console/c_enginecmds.cpp @@ -244,7 +244,7 @@ CCMD (wdir) { if (wadnum == -1 || fileSystem.GetFileContainer(i) == wadnum) { - Printf ("%10d %s\n", fileSystem.FileLength(i), fileSystem.GetFileFullName(i)); + Printf ("%10ld %s\n", fileSystem.FileLength(i), fileSystem.GetFileFullName(i)); } } } diff --git a/src/common/engine/stringtable.cpp b/src/common/engine/stringtable.cpp index 6bfbe12804..5fd020ed04 100644 --- a/src/common/engine/stringtable.cpp +++ b/src/common/engine/stringtable.cpp @@ -321,7 +321,7 @@ void FStringTable::LoadLanguage (int lumpnum, const char* buffer, size_t size) } else { - sc.ScriptError ("The language code must be 2 or 3 characters long.\n'%s' is %lu characters long.", + sc.ScriptError ("The language code must be 2 or 3 characters long.\n'%s' is %zu characters long.", sc.String, len); } } diff --git a/src/common/filesystem/include/fs_filesystem.h b/src/common/filesystem/include/fs_filesystem.h index bfd134758f..858b748374 100644 --- a/src/common/filesystem/include/fs_filesystem.h +++ b/src/common/filesystem/include/fs_filesystem.h @@ -154,20 +154,20 @@ protected: std::vector FileInfo; std::vector Hashes; // one allocation for all hash lists. - uint32_t *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure - uint32_t *NextLumpIndex; + uint32_t *FirstLumpIndex = nullptr; // [RH] Hashing stuff moved out of lumpinfo structure + uint32_t *NextLumpIndex = nullptr; - uint32_t *FirstLumpIndex_FullName; // The same information for fully qualified paths from .zips - uint32_t *NextLumpIndex_FullName; + uint32_t *FirstLumpIndex_FullName = nullptr; // The same information for fully qualified paths from .zips + uint32_t *NextLumpIndex_FullName = nullptr; - uint32_t *FirstLumpIndex_NoExt; // The same information for fully qualified paths from .zips - uint32_t *NextLumpIndex_NoExt; + uint32_t *FirstLumpIndex_NoExt = nullptr; // The same information for fully qualified paths from .zips + uint32_t *NextLumpIndex_NoExt = nullptr; - uint32_t* FirstLumpIndex_ResId; // The same information for fully qualified paths from .zips - uint32_t* NextLumpIndex_ResId; + uint32_t* FirstLumpIndex_ResId = nullptr; // The same information for fully qualified paths from .zips + uint32_t* NextLumpIndex_ResId = nullptr; uint32_t NumEntries = 0; // Not necessarily the same as FileInfo.Size() - uint32_t NumWads; + uint32_t NumWads = 0; int IwadIndex = -1; int MaxIwadIndex = -1; diff --git a/src/common/filesystem/include/resourcefile.h b/src/common/filesystem/include/resourcefile.h index 7940e90e16..a23914444e 100644 --- a/src/common/filesystem/include/resourcefile.h +++ b/src/common/filesystem/include/resourcefile.h @@ -177,7 +177,7 @@ public: int GetEntryNamespace(uint32_t entry) { - return (entry < NumLumps) ? Entries[entry].Namespace : ns_hidden; + return (entry < NumLumps) ? Entries[entry].Namespace : (int)ns_hidden; } int GetEntryResourceID(uint32_t entry) diff --git a/src/common/filesystem/source/ancientzip.cpp b/src/common/filesystem/source/ancientzip.cpp index 34356306ee..9f5ebdfefe 100644 --- a/src/common/filesystem/source/ancientzip.cpp +++ b/src/common/filesystem/source/ancientzip.cpp @@ -45,6 +45,7 @@ #include #include +#include #include "ancientzip.h" namespace FileSys { @@ -342,10 +343,19 @@ int FZipExploder::Explode(unsigned char *out, unsigned int outsize, int ShrinkLoop(unsigned char *out, unsigned int outsize, FileReader &_In, unsigned int InLeft) { + // don't allocate this on the stack, it's a bit on the large side. + struct work + { + unsigned char ReadBuf[256]; + unsigned short Parent[HSIZE]; + unsigned char Value[HSIZE], Stack[HSIZE]; + }; + auto s = std::make_unique(); + unsigned char* ReadBuf = s->ReadBuf; + unsigned short* Parent = s->Parent; + unsigned char* Value = s->Value, * Stack = s->Stack; + FileReader *In = &_In; - unsigned char ReadBuf[256]; - unsigned short Parent[HSIZE]; - unsigned char Value[HSIZE], Stack[HSIZE]; unsigned char *newstr; int len; int KwKwK, codesize = 9; /* start at 9 bits/code */ diff --git a/src/common/filesystem/source/filesystem.cpp b/src/common/filesystem/source/filesystem.cpp index b931920e98..f011c4c57d 100644 --- a/src/common/filesystem/source/filesystem.cpp +++ b/src/common/filesystem/source/filesystem.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "resourcefile.h" #include "fs_filesystem.h" @@ -415,7 +416,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf snprintf(cksumout + (j * 2), 3, "%02X", cksum[j]); } - fprintf(hashfile, "file: %s, hash: %s, size: %d\n", filename, cksumout, (int)filereader.GetLength()); + fprintf(hashfile, "file: %s, hash: %s, size: %td\n", filename, cksumout, filereader.GetLength()); } else @@ -434,7 +435,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf snprintf(cksumout + (j * 2), 3, "%02X", cksum[j]); } - fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %llu\n", filename, resfile->getName(i), cksumout, (uint64_t)resfile->Length(i)); + fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %zu\n", filename, resfile->getName(i), cksumout, (uint64_t)resfile->Length(i)); } } } @@ -1272,7 +1273,7 @@ void FileSystem::ReadFile (int lump, void *dest) if (numread != size) { - throw FileSystemException("W_ReadFile: only read %ld of %ld on '%s'\n", + throw FileSystemException("W_ReadFile: only read %td of %td on '%s'\n", numread, size, FileInfo[lump].LongName); } } diff --git a/src/common/filesystem/source/fs_stringpool.h b/src/common/filesystem/source/fs_stringpool.h index 199a3483b6..f327d14a3e 100644 --- a/src/common/filesystem/source/fs_stringpool.h +++ b/src/common/filesystem/source/fs_stringpool.h @@ -8,7 +8,7 @@ class StringPool friend class FileSystem; friend class FResourceFile; private: - StringPool(bool _shared, size_t blocksize = 10*1024) : TopBlock(nullptr), FreeBlocks(nullptr), BlockSize(blocksize), shared(_shared) {} + StringPool(bool _shared, size_t blocksize = 10*1024) : TopBlock(nullptr), BlockSize(blocksize), shared(_shared) {} public: ~StringPool(); const char* Strdup(const char*); @@ -20,7 +20,6 @@ protected: Block *AddBlock(size_t size); Block *TopBlock; - Block *FreeBlocks; size_t BlockSize; public: bool shared; diff --git a/src/common/platform/win32/i_crash.cpp b/src/common/platform/win32/i_crash.cpp index ab65b2ea59..dd58692817 100644 --- a/src/common/platform/win32/i_crash.cpp +++ b/src/common/platform/win32/i_crash.cpp @@ -381,12 +381,14 @@ static HANDLE WriteMyMiniDump (void) { MiniDumpThreadData dumpdata = { file, pMiniDumpWriteDump, &exceptor }; DWORD id; - HANDLE thread = CreateThread (NULL, 0, WriteMiniDumpInAnotherThread, - &dumpdata, 0, &id); - WaitForSingleObject (thread, INFINITE); - if (GetExitCodeThread (thread, &id)) + HANDLE thread = CreateThread (NULL, 0, WriteMiniDumpInAnotherThread, &dumpdata, 0, &id); + if (thread != nullptr) { - good = id; + WaitForSingleObject(thread, INFINITE); + if (GetExitCodeThread(thread, &id)) + { + good = id; + } } } } diff --git a/src/common/platform/win32/i_dijoy.cpp b/src/common/platform/win32/i_dijoy.cpp index a81fa1a269..492cbda148 100644 --- a/src/common/platform/win32/i_dijoy.cpp +++ b/src/common/platform/win32/i_dijoy.cpp @@ -421,7 +421,8 @@ void FDInputJoystick::ProcessInput() return; } - state = (uint8_t *)alloca(DataFormat.dwDataSize); + TArray statearr(DataFormat.dwDataSize, true); + state = statearr.data(); hr = Device->GetDeviceState(DataFormat.dwDataSize, state); if (FAILED(hr)) return; diff --git a/src/common/platform/win32/i_input.cpp b/src/common/platform/win32/i_input.cpp index 4ce8766aa5..054c995903 100644 --- a/src/common/platform/win32/i_input.cpp +++ b/src/common/platform/win32/i_input.cpp @@ -334,7 +334,8 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (!GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)) && size != 0) { - uint8_t *buffer = (uint8_t *)alloca(size); + TArray array(size, true); + uint8_t *buffer = array.data(); if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, buffer, &size, sizeof(RAWINPUTHEADER)) == size) { int code = GET_RAWINPUT_CODE_WPARAM(wParam); @@ -691,12 +692,15 @@ void I_PutInClipboard (const char *str) auto wstr = WideString(str); HGLOBAL cliphandle = GlobalAlloc (GMEM_DDESHARE, wstr.length() * 2 + 2); - if (cliphandle != NULL) + if (cliphandle != nullptr) { wchar_t *ptr = (wchar_t *)GlobalLock (cliphandle); - wcscpy (ptr, wstr.c_str()); - GlobalUnlock (cliphandle); - SetClipboardData (CF_UNICODETEXT, cliphandle); + if (ptr) + { + wcscpy(ptr, wstr.c_str()); + GlobalUnlock(cliphandle); + SetClipboardData(CF_UNICODETEXT, cliphandle); + } } CloseClipboard (); } diff --git a/src/common/platform/win32/i_main.cpp b/src/common/platform/win32/i_main.cpp index d1f82e59ae..6977055b7f 100644 --- a/src/common/platform/win32/i_main.cpp +++ b/src/common/platform/win32/i_main.cpp @@ -284,12 +284,12 @@ int DoMain (HINSTANCE hInstance) HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE); ShowWindow(mainwindow.GetHandle(), SW_HIDE); - WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL); + if (StdOut != nullptr) WriteFile(StdOut, "Press any key to exit...", 24, &bytes, nullptr); FlushConsoleInputBuffer(stdinput); SetConsoleMode(stdinput, 0); ReadConsole(stdinput, &bytes, 1, &bytes, NULL); } - else if (StdOut == NULL) + else if (StdOut == nullptr) { mainwindow.ShowErrorPane(nullptr); } diff --git a/src/common/platform/win32/win32glvideo.cpp b/src/common/platform/win32/win32glvideo.cpp index c972940a5a..bceb1908e7 100644 --- a/src/common/platform/win32/win32glvideo.cpp +++ b/src/common/platform/win32/win32glvideo.cpp @@ -326,8 +326,7 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) if (!myWglChoosePixelFormatARB(m_hDC, attributes.data(), attribsFloat, 1, &pixelFormat, &numFormats)) { - Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); - goto oldmethod; + I_FatalError("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); } if (vid_hdr && numFormats == 0) // This card/driver doesn't support the rgb16f pixel format. Fall back to 8bpc @@ -343,8 +342,7 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) if (!myWglChoosePixelFormatARB(m_hDC, attributes.data(), attribsFloat, 1, &pixelFormat, &numFormats)) { - Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); - goto oldmethod; + I_FatalError("R_OPENGL: Couldn't choose pixel format."); } } else if (vid_hdr) @@ -360,41 +358,12 @@ bool Win32GLVideo::SetupPixelFormat(int multisample) vr_enable_quadbuffered = false; goto again; } - Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n"); - goto oldmethod; + I_FatalError("R_OPENGL: No valid pixel formats found."); } } else { - oldmethod: - // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, // color depth - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 32, // z depth - 8, // stencil buffer - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - pixelFormat = ChoosePixelFormat(m_hDC, &pfd); - DescribePixelFormat(m_hDC, pixelFormat, sizeof(pfd), &pfd); - - if (pfd.dwFlags & PFD_GENERIC_FORMAT) - { - I_Error("R_OPENGL: OpenGL driver not accelerated!"); - return false; - } + I_FatalError("R_OPENGL: Unable to create an OpenGL render context. Insufficient driver support for context creation\n"); } if (!::SetPixelFormat(m_hDC, pixelFormat, NULL)) @@ -452,8 +421,7 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample) m_hRC = zd_wglCreateContext(m_hDC); if (m_hRC == NULL) { - I_Error("R_OPENGL: Unable to create an OpenGL render context.\n"); - return false; + I_FatalError("R_OPENGL: Unable to create an OpenGL render context.\n"); } } @@ -464,7 +432,7 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample) } } // We get here if the driver doesn't support the modern context creation API which always means an old driver. - I_Error("R_OPENGL: Unable to create an OpenGL render context. Insufficient driver support for context creation\n"); + I_FatalError("R_OPENGL: Unable to create an OpenGL render context. Insufficient driver support for context creation\n"); return false; } diff --git a/src/common/rendering/gl_load/gl_load.c b/src/common/rendering/gl_load/gl_load.c index e29207f4ab..14aba7a702 100644 --- a/src/common/rendering/gl_load/gl_load.c +++ b/src/common/rendering/gl_load/gl_load.c @@ -77,10 +77,19 @@ static void CheckOpenGL(void) if (opengl32dll == 0) { opengl32dll = LoadLibrary(L"OpenGL32.DLL"); - createcontext = (HGLRC(WINAPI*)(HDC)) GetProcAddress(opengl32dll, "wglCreateContext"); - deletecontext = (BOOL(WINAPI*)(HGLRC)) GetProcAddress(opengl32dll, "wglDeleteContext"); - makecurrent = (BOOL(WINAPI*)(HDC, HGLRC)) GetProcAddress(opengl32dll, "wglMakeCurrent"); - getprocaddress = (PROC(WINAPI*)(LPCSTR)) GetProcAddress(opengl32dll, "wglGetProcAddress"); + if (opengl32dll != 0) + { + createcontext = (HGLRC(WINAPI*)(HDC)) GetProcAddress(opengl32dll, "wglCreateContext"); + deletecontext = (BOOL(WINAPI*)(HGLRC)) GetProcAddress(opengl32dll, "wglDeleteContext"); + makecurrent = (BOOL(WINAPI*)(HDC, HGLRC)) GetProcAddress(opengl32dll, "wglMakeCurrent"); + getprocaddress = (PROC(WINAPI*)(LPCSTR)) GetProcAddress(opengl32dll, "wglGetProcAddress"); + } + else + { + // Should this ever happen we have no choice but to hard abort, there is no good way to recover. + MessageBoxA(0, "OpenGL32.dll not found", "Fatal error", MB_OK | MB_ICONERROR | MB_TASKMODAL); + exit(3); + } } } diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 84f7e76b4b..66f99e8b4a 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -11674,7 +11674,7 @@ FxExpression *FxThreeArgForEachLoop::Resolve(FCompileContext &ctx) if(HasGameSpecificThreeArgForEachLoopTypeNames()) { - ScriptPosition.Message(MSG_ERROR, "foreach( a, b, c : it ) - 'it' must be % but is a %s", GetGameSpecificThreeArgForEachLoopTypeNames(), BlockIteratorExpr->ValueType->DescriptiveName()); + ScriptPosition.Message(MSG_ERROR, "foreach( a, b, c : it ) - 'it' must be %s but is a %s", GetGameSpecificThreeArgForEachLoopTypeNames(), BlockIteratorExpr->ValueType->DescriptiveName()); delete this; return nullptr; } @@ -11727,7 +11727,7 @@ FxExpression *FxTypedForEachLoop::Resolve(FCompileContext &ctx) if(HasGameSpecificTypedForEachLoopTypeNames()) { - ScriptPosition.Message(MSG_ERROR, "foreach(Type var : it ) - 'it' must be % but is a %s",GetGameSpecificTypedForEachLoopTypeNames(), Expr->ValueType->DescriptiveName()); + ScriptPosition.Message(MSG_ERROR, "foreach(Type var : it ) - 'it' must be %s but is a %s",GetGameSpecificTypedForEachLoopTypeNames(), Expr->ValueType->DescriptiveName()); delete this; return nullptr; } diff --git a/src/common/scripting/core/symbols.h b/src/common/scripting/core/symbols.h index 15d547f7dd..b75d3a2ea2 100644 --- a/src/common/scripting/core/symbols.h +++ b/src/common/scripting/core/symbols.h @@ -54,7 +54,7 @@ class PSymbolType : public PSymbol { DECLARE_CLASS(PSymbolType, PSymbol); public: - PType *Type; + PType *Type = nullptr; PSymbolType(FName name, class PType *ty) : PSymbol(name), Type(ty) {} PSymbolType() : PSymbol(NAME_None) {} @@ -66,7 +66,7 @@ class PSymbolTreeNode : public PSymbol { DECLARE_CLASS(PSymbolTreeNode, PSymbol); public: - struct ZCC_TreeNode *Node; + struct ZCC_TreeNode *Node = nullptr; PSymbolTreeNode(FName name, struct ZCC_TreeNode *node) : PSymbol(name), Node(node) {} PSymbolTreeNode() : PSymbol(NAME_None) {} @@ -147,11 +147,11 @@ public: void *Pad; }; - PSymbolConstNumeric(FName name, PType *type=NULL) : PSymbolConst(name, type) {} + PSymbolConstNumeric(FName name, PType *type=nullptr) : PSymbolConst(name, type), Float(0) {} PSymbolConstNumeric(FName name, PType *type, int val) : PSymbolConst(name, type), Value(val) {} PSymbolConstNumeric(FName name, PType *type, unsigned int val) : PSymbolConst(name, type), Value((int)val) {} PSymbolConstNumeric(FName name, PType *type, double val) : PSymbolConst(name, type), Float(val) {} - PSymbolConstNumeric() {} + PSymbolConstNumeric() : Float(0) {} }; // A constant string value -------------------------------------------------- diff --git a/src/common/scripting/core/types.cpp b/src/common/scripting/core/types.cpp index 1e9302bd4d..0873125f83 100644 --- a/src/common/scripting/core/types.cpp +++ b/src/common/scripting/core/types.cpp @@ -116,7 +116,7 @@ void DumpTypeTable() } Printf("\n"); } - Printf("Used buckets: %d/%lu (%.2f%%) for %d entries\n", used, countof(TypeTable.TypeHash), double(used)/countof(TypeTable.TypeHash)*100, all); + Printf("Used buckets: %d/%zu (%.2f%%) for %d entries\n", used, countof(TypeTable.TypeHash), double(used)/countof(TypeTable.TypeHash)*100, all); Printf("Min bucket size: %d\n", min); Printf("Max bucket size: %d\n", max); Printf("Avg bucket size: %.2f\n", double(all) / used); diff --git a/src/common/textures/hires/hqresize.cpp b/src/common/textures/hires/hqresize.cpp index 9a6c42aa25..fc3f13a162 100644 --- a/src/common/textures/hires/hqresize.cpp +++ b/src/common/textures/hires/hqresize.cpp @@ -39,6 +39,7 @@ #ifdef HAVE_MMX #include "hqnx_asm/hqnx_asm.h" #endif +#include #include "xbr/xbrz.h" #include "xbr/xbrz_old.h" #include "parallel_for.h" @@ -304,7 +305,8 @@ static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char* initdone = true; } - HQnX_asm::CImage cImageIn; + auto pImageIn = std::make_unique(); + auto& cImageIn = *pImageIn; cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32); cImageIn.Convert32To17(); diff --git a/src/common/textures/m_png.cpp b/src/common/textures/m_png.cpp index 43e548e6cf..331b35e200 100644 --- a/src/common/textures/m_png.cpp +++ b/src/common/textures/m_png.cpp @@ -510,7 +510,8 @@ bool M_ReadIDAT (FileReader &file, uint8_t *buffer, int width, int height, int p { i += bytesPerRowOut * 2; } - inputLine = (Byte *)alloca (i); + TArray inputArray(i, true); + inputLine = inputArray.data(); adam7buff[0] = inputLine + 4 + bytesPerRowOut; adam7buff[1] = adam7buff[0] + bytesPerRowOut; adam7buff[2] = adam7buff[1] + bytesPerRowOut; @@ -925,7 +926,8 @@ bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height temprow[i] = &temprow_storage[temprow_size * i]; } - Byte buffer[PNG_WRITE_SIZE]; + TArray array(PNG_WRITE_SIZE, true); + auto buffer = array.data(); z_stream stream; int err; int y; diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index 6aa6c84a5c..3e4578cfb4 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -181,7 +181,7 @@ struct FTextureBuffer } FTextureBuffer(const FTextureBuffer &other) = delete; - FTextureBuffer(FTextureBuffer &&other) + FTextureBuffer(FTextureBuffer &&other) noexcept { mBuffer = other.mBuffer; mWidth = other.mWidth; @@ -190,7 +190,7 @@ struct FTextureBuffer other.mBuffer = nullptr; } - FTextureBuffer& operator=(FTextureBuffer &&other) + FTextureBuffer& operator=(FTextureBuffer &&other) noexcept { mBuffer = other.mBuffer; mWidth = other.mWidth; diff --git a/src/common/thirdparty/gain_analysis.cpp b/src/common/thirdparty/gain_analysis.cpp index 2f92e2128c..a31538f40a 100644 --- a/src/common/thirdparty/gain_analysis.cpp +++ b/src/common/thirdparty/gain_analysis.cpp @@ -282,7 +282,7 @@ GainAnalyzer::ResetSampleFrequency(int samplefreq) { int GainAnalyzer::InitGainAnalysis(int samplefreq) { - *this = {}; + memset(this, 0, sizeof(*this)); if (ResetSampleFrequency(samplefreq) != INIT_GAIN_ANALYSIS_OK) { return INIT_GAIN_ANALYSIS_ERROR; } diff --git a/src/common/utility/tarray.h b/src/common/utility/tarray.h index 95f4842edd..a420b078a8 100644 --- a/src/common/utility/tarray.h +++ b/src/common/utility/tarray.h @@ -234,7 +234,7 @@ public: { DoCopy (other); } - TArray (TArray &&other) + TArray (TArray &&other) noexcept { Array = other.Array; other.Array = NULL; Most = other.Most; other.Most = 0; @@ -256,7 +256,7 @@ public: } return *this; } - TArray &operator= (TArray &&other) + TArray &operator= (TArray &&other) noexcept { if (Array) { @@ -1777,14 +1777,14 @@ public: return *this; } - BitArray(BitArray && arr) + BitArray(BitArray && arr) noexcept : bytes(std::move(arr.bytes)) { size = arr.size; arr.size = 0; } - BitArray &operator=(BitArray && arr) + BitArray &operator=(BitArray && arr) noexcept { bytes = std::move(arr.bytes); size = arr.size; diff --git a/src/common/utility/zstring.h b/src/common/utility/zstring.h index dfbe47706d..5913d1e197 100644 --- a/src/common/utility/zstring.h +++ b/src/common/utility/zstring.h @@ -125,7 +125,7 @@ public: // Copy constructors FString (const FString &other) { AttachToOther (other); } - FString (FString &&other) : Chars(other.Chars) { other.ResetToNull(); } + FString (FString &&other) noexcept : Chars(other.Chars) { other.ResetToNull(); } FString (const char *copyStr); FString (const char *copyStr, size_t copyLen); FString (char oneChar); diff --git a/src/common/widgets/widgetresourcedata.cpp b/src/common/widgets/widgetresourcedata.cpp index 84822fc868..fd416e1d11 100644 --- a/src/common/widgets/widgetresourcedata.cpp +++ b/src/common/widgets/widgetresourcedata.cpp @@ -12,6 +12,11 @@ void InitWidgetResources(const char* filename) I_FatalError("Unable to open %s", filename); } +void CloseWidgetResources() +{ + if (WidgetResources) delete WidgetResources; +} + static std::vector LoadFile(const std::string& name) { auto lump = WidgetResources->FindEntry(name.c_str());