diff --git a/CMakePresets.json b/CMakePresets.json index 79aa6238..21ca4f9a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -28,7 +28,7 @@ "hidden": true, "cacheVariables": { "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL", - "VC_CXX_FLAGS": "/Zc:strictStrings;-wd4244;-wd4018;-wd4291;-wd4101;-wd4267", + "VC_CXX_FLAGS": "/Zc:strictStrings;-wd4244;-wd4018;-wd4291;-wd4101;-wd4267;-wd4200", "CMAKE_CXX_FLAGS_RELEASE": "/Zi /O2 /Ob2 /DNDEBUG", "CMAKE_EXE_LINKER_FLAGS_RELEASE": "/debug:full /INCREMENTAL:NO", "CMAKE_MODULE_LINKER_FLAGS_RELEASE": "/debug:full /INCREMENTAL:NO", diff --git a/common/field.cpp b/common/field.cpp index fc387fb1..49bf11c2 100644 --- a/common/field.cpp +++ b/common/field.cpp @@ -33,9 +33,6 @@ #include "field.h" #include "endianness.h" -// ST - 12/18/2018 10:14AM -#pragma warning(disable : 4996) - FieldClass::FieldClass(const char* id, char data) { strncpy(ID, id, sizeof(ID)); diff --git a/common/file.cpp b/common/file.cpp index 55779b98..5a639b85 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -12,8 +12,11 @@ static void Resolve_File_Single(char* fname) return; } - if (ffblk->FindFirst(fname) && strlen(fname) == strlen(ffblk->GetName())) { - strncpy(fname, ffblk->GetName(), strlen(fname) + 1); + size_t name_len = strlen(fname); + size_t full_len = strlen(ffblk->GetFullName()); + + if (ffblk->FindFirst(fname) && name_len == full_len) { + strncpy(fname, ffblk->GetFullName(), name_len + 1); } delete ffblk; diff --git a/common/file.h b/common/file.h index 83b447ff..3e05794c 100644 --- a/common/file.h +++ b/common/file.h @@ -231,6 +231,10 @@ class Find_File_Data { } virtual const char* GetName() const = 0; + virtual const char* GetFullName() const + { + return nullptr; + }; virtual unsigned int GetTime() const = 0; virtual bool FindFirst(const char* fname) = 0; diff --git a/common/file_posix.cpp b/common/file_posix.cpp index 233ba0f9..bcc4d64e 100644 --- a/common/file_posix.cpp +++ b/common/file_posix.cpp @@ -18,6 +18,10 @@ class Find_File_Data_Posix : public Find_File_Data virtual ~Find_File_Data_Posix(); virtual const char* GetName() const; + virtual const char* GetFullName() const + { + return DirEntry != nullptr ? FullName : nullptr; + } virtual unsigned int GetTime() const; virtual bool FindFirst(const char* fname); @@ -50,7 +54,7 @@ const char* Find_File_Data_Posix::GetName() const if (DirEntry == nullptr) { return nullptr; } - return FullName; + return DirEntry->d_name; } unsigned int Find_File_Data_Posix::GetTime() const diff --git a/common/graphicsviewport.cpp b/common/graphicsviewport.cpp index bcdc7b8b..1dda825f 100644 --- a/common/graphicsviewport.cpp +++ b/common/graphicsviewport.cpp @@ -779,8 +779,6 @@ unsigned int GraphicViewPortClass::Print(char const* str, int x, int y, int fcol return (return_code); } -#pragma warning(disable : 4996) - /*************************************************************************** * GVPC::PRINT -- Stub function to print an integer * * * diff --git a/common/ini.cpp b/common/ini.cpp index a11a0501..98f3ac17 100644 --- a/common/ini.cpp +++ b/common/ini.cpp @@ -80,9 +80,6 @@ #include "cstraw.h" #endif -// Disable the "temporary object used to initialize a non-constant reference" warning. -//#pragma warning 665 9 - /*********************************************************************************************** * INIClass::~INIClass -- Destructor for INI handler. * * * diff --git a/common/int.h b/common/int.h index 53258cc9..6e7fc8fc 100644 --- a/common/int.h +++ b/common/int.h @@ -476,8 +476,6 @@ template T Gcd(const T& a, const T& n) return g[(i - 1) % 3]; } -//#pragma warning 604 9 -//#pragma warning 595 9 template T Generate_Prime(Straw& rng, int pbits) { T minQ = (T(1UL) << (unsigned short)(pbits - (unsigned short)2)); diff --git a/common/mp.cpp b/common/mp.cpp index e064cb23..d65f19bf 100644 --- a/common/mp.cpp +++ b/common/mp.cpp @@ -333,7 +333,6 @@ unsigned XMP_Encode(unsigned char* to, unsigned tobytes, digit const* from, int * HISTORY: * * 07/01/1996 JLB : Created. * *=============================================================================================*/ -//#pragma warning 364 9 unsigned XMP_Encode(unsigned char* to, digit const* from, int precision) { int i; diff --git a/common/packet.cpp b/common/packet.cpp index da29423f..2f6907a5 100644 --- a/common/packet.cpp +++ b/common/packet.cpp @@ -402,7 +402,6 @@ bool PacketClass::Get_Field(const char* id, int& data) * HISTORY: * * 04/23/1996 PWG : Created. * *========================================================================*/ -#pragma warning(disable : 4996) bool PacketClass::Get_Field(const char* id, char* data) { FieldClass* field = Find_Field(id); diff --git a/common/shape.h b/common/shape.h index a8224160..197623d6 100644 --- a/common/shape.h +++ b/common/shape.h @@ -129,7 +129,6 @@ typedef struct /* ------------------------------- Shape block --------------------------------- */ -#pragma warning(disable : 4200) #pragma pack(push, 2) typedef struct { diff --git a/common/soscodec.cpp b/common/soscodec.cpp index 47d3e87c..f40b938e 100644 --- a/common/soscodec.cpp +++ b/common/soscodec.cpp @@ -196,6 +196,7 @@ unsigned sosCODECDecompressData(_SOS_COMPRESS_INFO* stream, unsigned bytes) } #endif assert(0 && "Unreachable"); + return 0; } // diff --git a/redalert/dllinterface.cpp b/redalert/dllinterface.cpp index 1ec7194d..e78a9fa7 100644 --- a/redalert/dllinterface.cpp +++ b/redalert/dllinterface.cpp @@ -24,9 +24,6 @@ ** */ -// Exception handling isn't enabled -#pragma warning(disable : 4530) // warning C4530: C++ exception handler used, but unwind semantics are not enabled. - #include #include #include @@ -72,9 +69,6 @@ typedef __int64 int64; ** ** */ -// For compatibility with Watcom in audio enums -#pragma warning(disable : 4091) - // From RedAlert\Audio.cpp typedef enum { diff --git a/redalert/ipxmgr.cpp b/redalert/ipxmgr.cpp index 0a884594..6eee2110 100644 --- a/redalert/ipxmgr.cpp +++ b/redalert/ipxmgr.cpp @@ -85,9 +85,6 @@ #endif // WINSOCK_IPX -// Turn off "expression is not meaningful". -//#pragma warning 628 9 - //#include "WolDebug.h" /*************************************************************************** diff --git a/tiberiandawn/conquer.cpp b/tiberiandawn/conquer.cpp index 0220640c..a8aebd8e 100644 --- a/tiberiandawn/conquer.cpp +++ b/tiberiandawn/conquer.cpp @@ -3613,7 +3613,6 @@ static bool Change_Local_Dir(int cd) * 07/11/1995 JLB : Created. * * 05/22/1996 ST : Handles multiple CD drives / CD changers * *=============================================================================================*/ -#pragma warning(disable : 4101) bool Force_CD_Available(int cd) { diff --git a/tiberiandawn/defines.h b/tiberiandawn/defines.h index 82ff91d8..79269148 100644 --- a/tiberiandawn/defines.h +++ b/tiberiandawn/defines.h @@ -173,13 +173,6 @@ #define FOREIGN_VERSION_NUMBER 6 -// -// typedef enums with -1 will show this warning, even when the type of the enum is signed. It's a compiler bug, -// apparently ST - 1/8/2019 9:23AM -// -#pragma warning(push) -#pragma warning(disable : 4341) - /********************************************************************** ** These enumerations are used to implement RTTI. */ @@ -3042,6 +3035,4 @@ typedef enum StrategyType : unsigned char #endif // USE_RA_AI -#pragma warning(pop) - #endif \ No newline at end of file diff --git a/tiberiandawn/dllinterface.cpp b/tiberiandawn/dllinterface.cpp index 7ccce4b2..28d1c418 100644 --- a/tiberiandawn/dllinterface.cpp +++ b/tiberiandawn/dllinterface.cpp @@ -65,9 +65,6 @@ typedef __int64 int64; ** ** */ -// For compatibility with Watcom in audio enums -#pragma warning(disable : 4091) - // From TiberianDawn\Audio.cpp typedef enum { diff --git a/tiberiandawn/iomap.cpp b/tiberiandawn/iomap.cpp index 2dcee7ef..f4f1ef33 100644 --- a/tiberiandawn/iomap.cpp +++ b/tiberiandawn/iomap.cpp @@ -65,8 +65,6 @@ #include "function.h" -#pragma warning(disable : 4302) // Truncation from pointer to TARGET - /*********************************************************************************************** * CellClass::Should_Save -- Should the cell be written to disk? * * * diff --git a/tiberiandawn/ioobj.cpp b/tiberiandawn/ioobj.cpp index e4f1f917..2c34db7a 100644 --- a/tiberiandawn/ioobj.cpp +++ b/tiberiandawn/ioobj.cpp @@ -130,8 +130,6 @@ #include "function.h" -#pragma warning(disable : 4302) // Truncation from pointer to TARGET - /*********************************************************************************************** * TeamTypeClass::Load -- Loads from a save game file. * * * diff --git a/tiberiandawn/ipxmgr.cpp b/tiberiandawn/ipxmgr.cpp index 4a3e3273..f3002a9c 100644 --- a/tiberiandawn/ipxmgr.cpp +++ b/tiberiandawn/ipxmgr.cpp @@ -89,9 +89,6 @@ /* For `Players` vector */ #include "externs.h" -// Turn off "expression is not meaningful". -//#pragma warning 628 9 - //#include "WolDebug.h" /*************************************************************************** diff --git a/tools/miniposix/dirent/dirent.c b/tools/miniposix/dirent/dirent.c index 4e356d6d..d101424f 100644 --- a/tools/miniposix/dirent/dirent.c +++ b/tools/miniposix/dirent/dirent.c @@ -214,7 +214,7 @@ DIR *opendir(const char *name) __seterrno(ENOENT); return NULL; } - size = wcslen(full) + 1; + size = (int)wcslen(full) + 1; memcpy(wname, L"\\\\?\\", sizeof(wchar_t) * 5); if (size > NTFS_MAX_PATH) { free(wname);