From 258c69287dbbf88592c181be4b99c9daeac5f374 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 07:17:51 -0500 Subject: [PATCH 01/17] deleting a null pointer has no effect --- Sources/Plasma/FeatureLib/pfDXPipeline/plDXDeviceRefs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDeviceRefs.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDeviceRefs.cpp index 9a2922bf01..d3e90d4f73 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDeviceRefs.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDeviceRefs.cpp @@ -189,8 +189,8 @@ plDXTextureRef& plDXTextureRef::Set( D3DFORMAT ft, uint32_t ml, uint32_t mw, uin fMaxHeight = mh; fNumPix = np; fDataSize = manSize; - if (fLevelSizes != nullptr) - delete [] fLevelSizes; + + delete [] fLevelSizes; if( lSz ) fLevelSizes = lSz; else From 3e4201e3b536b647c89968ba26d88d9ce5e88b0b Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 07:39:29 -0500 Subject: [PATCH 02/17] make these values constexpr --- .../FeatureLib/pfDXPipeline/plDXEnumerate.cpp | 10 ---------- .../Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h | 14 +++++++++++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.cpp index 13babbef9f..a7fc56f780 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.cpp @@ -50,16 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com typedef LPDIRECT3D9 (WINAPI * Direct3DCreateProc)( UINT sdkVersion ); -const uint8_t hsGDirect3DTnLEnumerate::kNumDisplayFormats = 6; -const D3DFORMAT hsGDirect3DTnLEnumerate::kDisplayFormats[] = -{ - D3DFMT_A1R5G5B5, - D3DFMT_A2B10G10R10, - D3DFMT_A8R8G8B8, - D3DFMT_R5G6B5, - D3DFMT_X1R5G5B5, - D3DFMT_X8R8G8B8, -}; bool hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devRec, const hsG3DDeviceMode* devMode) { diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h index 7f22a838fb..169461e637 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h @@ -151,9 +151,17 @@ class hsGDirect3DTnLEnumerate bool ICheckCubicRenderTargets( IDirect3D9 *pD3D, UINT iAdapter, D3DDEVTYPE deviceType, D3DEnum_ModeInfo *modeInfo ); HRESULT IConfirmDevice( D3DCAPS9* pCaps, DWORD dwBehavior, D3DFORMAT format ); - static const uint8_t kNumDisplayFormats; - static const D3DFORMAT kDisplayFormats[]; - + static constexpr D3DFORMAT kDisplayFormats[] = + { + D3DFMT_A1R5G5B5, + D3DFMT_A2B10G10R10, + D3DFMT_A8R8G8B8, + D3DFMT_R5G6B5, + D3DFMT_X1R5G5B5, + D3DFMT_X8R8G8B8, + }; + static constexpr uint8_t kNumDisplayFormats = std::end(kDisplayFormats) - std::begin(kDisplayFormats); + static_assert(kNumDisplayFormats == 6); public: hsGDirect3DTnLEnumerate(); virtual ~hsGDirect3DTnLEnumerate(); From e7858e38c6ba2f59dc1d29bf5b4e86d696e4c5bd Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 08:49:33 -0500 Subject: [PATCH 03/17] use getfiletype instead of _isatty on windows --- Sources/Tools/plFilePatcher/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Tools/plFilePatcher/main.cpp b/Sources/Tools/plFilePatcher/main.cpp index beeffceb98..9864455ec0 100644 --- a/Sources/Tools/plFilePatcher/main.cpp +++ b/Sources/Tools/plFilePatcher/main.cpp @@ -55,7 +55,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #if HS_BUILD_FOR_WIN32 # include "hsWindows.h" # include -# define isatty _isatty +# define ttycheck(fileinfo) (GetFileType(fileinfo) == FILE_TYPE_CHAR) void GetConsoleWidth(size_t& width) { @@ -67,7 +67,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com # include # include # include - +# define ttycheck(fileinfo) isatty(fileno(fileinfo)) void GetConsoleWidth(size_t& width) { struct winsize w; @@ -174,7 +174,7 @@ int main(int argc, char* argv[]) patcher.SetPatcherFlags(flags); - if (!cmdParser.GetBool(kArgQuiet) && isatty(fileno(stdout))) { + if (!cmdParser.GetBool(kArgQuiet) && ttycheck(stdout)) { patcher.SetDownloadBeginCallback(&FileDownloadBegin); patcher.SetProgressCallback(&FileDownloadProgress); } @@ -185,7 +185,7 @@ int main(int argc, char* argv[]) return 1; } - if (!cmdParser.GetBool(kArgQuiet) && isatty(fileno(stdout))) { + if (!cmdParser.GetBool(kArgQuiet) && ttycheck(stdout)) { ST::printf("\r{}\r", ST::string::fill(consoleWidth, ' ')); fflush(stdout); } From 0d1ce28186699288cda5497d65620b00345878c8 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 09:23:55 -0500 Subject: [PATCH 04/17] set the identity matrix to constexpr --- Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp | 2 +- Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp | 2 +- Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp index 7d795c863a..f47cf369eb 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp @@ -63,7 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define WEAK_ERROR_CHECK( cond ) cond #endif -static D3DMATRIX d3dIdentityMatrix{ +constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp index a9ed50f25f..a95eeaca9c 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp @@ -242,7 +242,7 @@ inline DWORD F2DW( FLOAT f ) #define WEAK_ERROR_CHECK( cond ) cond #endif -static D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, +constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp index 80a390aa9c..664309eaaf 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp @@ -66,7 +66,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com static const long PLD3D_FONTFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0); -static D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, +constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; From e53e7ecbc4a606de4869a199b802cf312aa149d7 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 09:45:36 -0500 Subject: [PATCH 05/17] use range based for loop instead --- Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp b/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp index 0604e448c5..50500fcb29 100644 --- a/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp +++ b/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp @@ -150,9 +150,9 @@ void plClient::InitDLLs() { hsStatusMessage("Init dlls client\n"); std::vector dlls = plFileSystem::ListDir("ModDLL", "*.dll"); - for (auto iter = dlls.begin(); iter != dlls.end(); ++iter) + for (auto& dll : dlls) { - HMODULE hMod = LoadLibraryW(iter->WideString().data()); + HMODULE hMod = LoadLibraryW(dll.WideString().data()); if (hMod) { pInitGlobalsFunc initGlobals = (pInitGlobalsFunc)GetProcAddress(hMod, "InitGlobals"); From 83e11f2204a9d0f759322e0dafd7e8af675c1c7d Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 17:44:33 -0500 Subject: [PATCH 06/17] use static constexpr --- Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp | 2 +- Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp | 2 +- Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp index f47cf369eb..ecb738c59c 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXDevice.cpp @@ -63,7 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define WEAK_ERROR_CHECK( cond ) cond #endif -constexpr D3DMATRIX d3dIdentityMatrix{ +static constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp index a95eeaca9c..3dadc0fcc7 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp @@ -242,7 +242,7 @@ inline DWORD F2DW( FLOAT f ) #define WEAK_ERROR_CHECK( cond ) cond #endif -constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, +static constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp index 664309eaaf..7f32b89027 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp @@ -66,7 +66,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com static const long PLD3D_FONTFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0); -constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, +static constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; From 4ea12713c4028739b7343dd855ba2c1edae4d8e8 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 18:25:23 -0500 Subject: [PATCH 07/17] use std::size instead of begin and end Co-authored-by: Michael Hansen --- Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h index 169461e637..40e2d7922c 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXEnumerate.h @@ -160,8 +160,7 @@ class hsGDirect3DTnLEnumerate D3DFMT_X1R5G5B5, D3DFMT_X8R8G8B8, }; - static constexpr uint8_t kNumDisplayFormats = std::end(kDisplayFormats) - std::begin(kDisplayFormats); - static_assert(kNumDisplayFormats == 6); + static constexpr uint8_t kNumDisplayFormats = std::size(kDisplayFormats); public: hsGDirect3DTnLEnumerate(); virtual ~hsGDirect3DTnLEnumerate(); From d5b0ce6c63b44fad5abd20ceea795f162f5c0ca9 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 18:26:17 -0500 Subject: [PATCH 08/17] add const to the for loop Co-authored-by: Michael Hansen --- Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp b/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp index 50500fcb29..13dfb10983 100644 --- a/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp +++ b/Sources/Plasma/Apps/plClient/win32/plClient_Win.cpp @@ -150,7 +150,7 @@ void plClient::InitDLLs() { hsStatusMessage("Init dlls client\n"); std::vector dlls = plFileSystem::ListDir("ModDLL", "*.dll"); - for (auto& dll : dlls) + for (const auto& dll : dlls) { HMODULE hMod = LoadLibraryW(dll.WideString().data()); if (hMod) From 9840aeae65496bd738cafcaeeceb79bf1a91d9ca Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 18:36:00 -0500 Subject: [PATCH 09/17] change kFVF to constexpr --- Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp | 5 +---- Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.h | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp index 7f32b89027..679e39a2d0 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp @@ -63,7 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //// Local Stuff ////////////////////////////////////////////////////////////// -static const long PLD3D_FONTFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE +static constexpr long PLD3D_FONTFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0); static constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, @@ -78,9 +78,6 @@ static constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, //const uint32_t kNumVertsInBuffer(32768); const uint32_t kNumVertsInBuffer(4608); -// See the declaration for plFontVertex in plTextFont.h for info -const DWORD plDXTextFont::kFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0); - IDirect3DVertexBuffer9* plDXTextFont::fBuffer = nullptr; uint32_t plDXTextFont::fBufferCursor = 0; diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.h b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.h index 53f326c73d..ae88da371b 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.h +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.h @@ -84,7 +84,8 @@ class plDXTextFont : public plTextFont void RestoreStates() override; void DestroyObjects() override; - static const DWORD kFVF; + // See the declaration for plFontVertex in plTextFont.h for info + static constexpr DWORD kFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0); }; From 19d1149b918372312d2ee32cb4781fb2774e27f0 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 18:36:43 -0500 Subject: [PATCH 10/17] use enhanced for loop --- Sources/Plasma/Apps/plPythonPack/main.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/Plasma/Apps/plPythonPack/main.cpp b/Sources/Plasma/Apps/plPythonPack/main.cpp index 125a0ec863..01aaadfa86 100644 --- a/Sources/Plasma/Apps/plPythonPack/main.cpp +++ b/Sources/Plasma/Apps/plPythonPack/main.cpp @@ -213,9 +213,9 @@ void FindFiles(std::vector &filenames, std::vector &path // Get the names of all the python files std::vector pys = plFileSystem::ListDir(path, "*.py"); - for (auto iter = pys.begin(); iter != pys.end(); ++iter) + for (const auto& py : pys) { - filenames.push_back(iter->GetFileName()); + filenames.push_back(py.GetFileName()); pathnames.push_back(path); } } @@ -223,8 +223,9 @@ void FindFiles(std::vector &filenames, std::vector &path void FindSubDirs(std::vector &dirnames, const plFileName &path) { std::vector subdirs = plFileSystem::ListSubdirs(path); - for (auto iter = subdirs.begin(); iter != subdirs.end(); ++iter) { - ST::string name = iter->GetFileName(); + for (const auto& subdir : subdirs) + { + ST::string name = subdir.GetFileName(); if (s_ignoreSubdirs.find(name) == s_ignoreSubdirs.end()) dirnames.push_back(name); } @@ -234,15 +235,15 @@ void FindPackages(std::vector& fileNames, std::vector& p { std::vector packages; FindSubDirs(packages, path); - for (int i = 0; i < packages.size(); i++) + for (const auto& package : packages) { ST::string packageName; if (!parent_package.empty()) packageName = parent_package + "."; - packageName += packages[i].AsString(); + packageName += package.AsString(); std::vector packageFileNames; std::vector packagePathNames; - plFileName packagePath = plFileName::Join(path, packages[i]); + plFileName packagePath = plFileName::Join(path, package); FindFiles(packageFileNames, packagePathNames, packagePath); // Check for the magic file to make sure this is really a package... From 79bd9171bb5feae2913751794dfbfb088b7d7cb1 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 23 Oct 2023 20:20:17 -0500 Subject: [PATCH 11/17] use enhanced for loop --- Sources/Plasma/CoreLib/hsMatrix33.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsMatrix33.cpp b/Sources/Plasma/CoreLib/hsMatrix33.cpp index c5f83f4f9a..1c06025976 100644 --- a/Sources/Plasma/CoreLib/hsMatrix33.cpp +++ b/Sources/Plasma/CoreLib/hsMatrix33.cpp @@ -91,16 +91,16 @@ hsMatrix33 operator*(const hsMatrix33& a, const hsMatrix33& b) void hsMatrix33::Read(hsStream* s) { - for (int i = 0; i < 3; i++) + for (auto& i : fMap) { - s->ReadLEFloat(3, fMap[i]); + s->ReadLEFloat(3, i); } } void hsMatrix33::Write(hsStream* s) { - for (int i = 0; i < 3; i++) + for (const auto& i : fMap) { - s->WriteLEFloat(3, fMap[i]); + s->WriteLEFloat(3, i); } } From 628841ab56549b7555df22e067715bbf902c7d1f Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Tue, 24 Oct 2023 18:31:42 -0500 Subject: [PATCH 12/17] set these variables to constexpr --- Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp b/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp index e9d3aadb35..625d86ff4f 100644 --- a/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp +++ b/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp @@ -45,17 +45,18 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include "plTriUtils.h" -static const float kAlmostZero = 1.e-5f; -static const float kPastZero = -kAlmostZero; -static const float kPastOne = 1.f + kAlmostZero; -static const float kAlmostOne = 1.f - kAlmostZero; -static const float kAlmostZeroSquared = kAlmostZero*kAlmostZero; +static constexpr float kAlmostZero = 1.e-5f; +static constexpr float kPastZero = -kAlmostZero; +static constexpr float kPastOne = 1.f + kAlmostZero; +static constexpr float kAlmostOne = 1.f - kAlmostZero; +static constexpr float kAlmostZeroSquared = kAlmostZero*kAlmostZero; static inline hsVector3 Cross(const hsScalarTriple& p0, const hsScalarTriple& p1) { - return hsVector3(p0.fY * p1.fZ - p0.fZ * p1.fY, - p0.fZ * p1.fX - p0.fX * p1.fZ, - p0.fX * p1.fY - p0.fY * p1.fX); + return {p0.fY * p1.fZ - p0.fZ * p1.fY, + p0.fZ * p1.fX - p0.fX * p1.fZ, + p0.fX * p1.fY - p0.fY * p1.fX + }; } From d9d3b8e5974f396880b8dda8868d609fee2822a2 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Fri, 3 Nov 2023 12:49:50 -0500 Subject: [PATCH 13/17] defer copy Co-authored-by: Adam Johnson --- Sources/Plasma/Apps/plPythonPack/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/Apps/plPythonPack/main.cpp b/Sources/Plasma/Apps/plPythonPack/main.cpp index 01aaadfa86..e07809f9cb 100644 --- a/Sources/Plasma/Apps/plPythonPack/main.cpp +++ b/Sources/Plasma/Apps/plPythonPack/main.cpp @@ -225,7 +225,7 @@ void FindSubDirs(std::vector &dirnames, const plFileName &path) std::vector subdirs = plFileSystem::ListSubdirs(path); for (const auto& subdir : subdirs) { - ST::string name = subdir.GetFileName(); + const ST::string& name = subdir.GetFileName(); if (s_ignoreSubdirs.find(name) == s_ignoreSubdirs.end()) dirnames.push_back(name); } From da62cf337ab075c378d858e4b8cfa4b3930878e3 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Fri, 3 Nov 2023 12:59:46 -0500 Subject: [PATCH 14/17] use emplace_back instead Co-authored-by: Adam Johnson --- Sources/Plasma/Apps/plPythonPack/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/Apps/plPythonPack/main.cpp b/Sources/Plasma/Apps/plPythonPack/main.cpp index e07809f9cb..6c643dde77 100644 --- a/Sources/Plasma/Apps/plPythonPack/main.cpp +++ b/Sources/Plasma/Apps/plPythonPack/main.cpp @@ -215,7 +215,7 @@ void FindFiles(std::vector &filenames, std::vector &path for (const auto& py : pys) { - filenames.push_back(py.GetFileName()); + filenames.emplace_back(py.GetFileName()); pathnames.push_back(path); } } From 9ef170e653d922c17cf0a188eb0fc56ffb103314 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Fri, 3 Nov 2023 18:03:59 +0000 Subject: [PATCH 15/17] fix indentation --- Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp b/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp index 625d86ff4f..10f2ac7946 100644 --- a/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp +++ b/Sources/Plasma/PubUtilLib/plMath/plTriUtils.cpp @@ -54,8 +54,8 @@ static constexpr float kAlmostZeroSquared = kAlmostZero*kAlmostZero; static inline hsVector3 Cross(const hsScalarTriple& p0, const hsScalarTriple& p1) { return {p0.fY * p1.fZ - p0.fZ * p1.fY, - p0.fZ * p1.fX - p0.fX * p1.fZ, - p0.fX * p1.fY - p0.fY * p1.fX + p0.fZ * p1.fX - p0.fX * p1.fZ, + p0.fX * p1.fY - p0.fY * p1.fX }; } From 080ae435a558abca9858e9aea2b8ed826097b244 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Mon, 30 Oct 2023 20:19:20 -0500 Subject: [PATCH 16/17] revert constexpr --- Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp index 679e39a2d0..6b5a9e64b1 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXTextFont.cpp @@ -66,7 +66,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com static constexpr long PLD3D_FONTFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0); -static constexpr D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, +static const D3DMATRIX d3dIdentityMatrix{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; From 1684bb1a2e5adde855d940486028473a7f7f7ff3 Mon Sep 17 00:00:00 2001 From: noah the goodra Date: Sat, 4 Nov 2023 22:15:46 -0500 Subject: [PATCH 17/17] handle mingw --- Sources/Tools/plFilePatcher/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Tools/plFilePatcher/main.cpp b/Sources/Tools/plFilePatcher/main.cpp index 9864455ec0..02b944bbab 100644 --- a/Sources/Tools/plFilePatcher/main.cpp +++ b/Sources/Tools/plFilePatcher/main.cpp @@ -55,7 +55,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #if HS_BUILD_FOR_WIN32 # include "hsWindows.h" # include + +#ifndef __MINGW32__ # define ttycheck(fileinfo) (GetFileType(fileinfo) == FILE_TYPE_CHAR) +#endif void GetConsoleWidth(size_t& width) {