From b2ab3ceaa954425b1e4039826859f5596b835f0b Mon Sep 17 00:00:00 2001 From: joonicks Date: Wed, 8 Sep 2021 00:41:31 +0200 Subject: [PATCH] WIP warning redux --- src/SpaceStationType.cpp | 9 ++++++--- src/SystemView.cpp | 3 ++- src/collider/GeomTree.cpp | 15 +++++++++++---- src/collider/Weld.h | 3 ++- src/galaxy/SystemPath.cpp | 4 ++++ src/graphics/opengl/Program.cpp | 9 ++++++--- src/graphics/opengl/RendererGL.cpp | 6 ++++-- src/graphics/opengl/Shader.h | 3 ++- src/scenegraph/Serializer.h | 12 ++++++++---- src/text/TextSupport.h | 6 ++++-- src/win32/TextUtils.cpp | 6 ++++-- 11 files changed, 53 insertions(+), 23 deletions(-) diff --git a/src/SpaceStationType.cpp b/src/SpaceStationType.cpp index a3630734606..c3e80726a9a 100644 --- a/src/SpaceStationType.cpp +++ b/src/SpaceStationType.cpp @@ -232,7 +232,8 @@ void SpaceStationType::OnSetupComplete() } } - numDockingPorts = m_portPaths.size(); +#pragma message("FIX: warning of data loss (x64)") + numDockingPorts = 0xFFFFFFFF & m_portPaths.size(); // sanity assert(!m_portPaths.empty()); @@ -421,10 +422,12 @@ void SpaceStationType::Init() const SpaceStationType *SpaceStationType::RandomStationType(Random &random, const bool bIsGround) { if (bIsGround) { - return &surfaceTypes[random.Int32(SpaceStationType::surfaceTypes.size())]; +#pragma message("FIX: warning of data loss (x64)") + return &surfaceTypes[random.Int32(0xFFFFFFFF & SpaceStationType::surfaceTypes.size())]; } - return &orbitalTypes[random.Int32(SpaceStationType::orbitalTypes.size())]; +#pragma message("FIX: warning of data loss (x64)") + return &orbitalTypes[random.Int32(0xFFFFFFFF & SpaceStationType::orbitalTypes.size())]; } /*static*/ diff --git a/src/SystemView.cpp b/src/SystemView.cpp index dc0b457bcb1..e2e13ea0950 100644 --- a/src/SystemView.cpp +++ b/src/SystemView.cpp @@ -486,7 +486,8 @@ void SystemView::Update() AnimationCurves::Approach(m_rot_y, m_rot_y_to, ft); // to capture mouse when button was pressed and release when released - if (Pi::input->MouseButtonState(SDL_BUTTON_MIDDLE) != m_rotateWithMouseButton) { +#pragma message("FIX: warning comparing int with bool") + if (bool(Pi::input->MouseButtonState(SDL_BUTTON_MIDDLE)) != m_rotateWithMouseButton) { m_rotateWithMouseButton = !m_rotateWithMouseButton; Pi::input->SetCapturingMouse(m_rotateWithMouseButton); } diff --git a/src/collider/GeomTree.cpp b/src/collider/GeomTree.cpp index e2d1ebf3e06..b49311198dd 100644 --- a/src/collider/GeomTree.cpp +++ b/src/collider/GeomTree.cpp @@ -7,7 +7,10 @@ #include "Weld.h" #include "scenegraph/Serializer.h" +#pragma message("FIX: warning unknown pragma") +#ifdef __GNUC__ #pragma GCC optimize("O3") +#endif /* __GNUC__ */ GeomTree::~GeomTree() { @@ -57,7 +60,8 @@ GeomTree::GeomTree(const int numVerts, const int numTris, const std::vector xrefs; nv::Weld weld; weld(m_vertices, xrefs); - m_numVertices = m_vertices.size(); +#pragma message("FIX: warning of data loss (x64)") + m_numVertices = 0xFFFFFFFF & m_vertices.size(); //Output("--- %d vertices welded\n", count - newCount); @@ -109,12 +113,14 @@ GeomTree::GeomTree(const int numVerts, const int numTris, const std::vector &p, std::vector &xrefs) { - const Uint32 N = p.size(); // # of input vertices. +#pragma message("FIX: warning of data loss (x64)") + const Uint32 N = 0xFFFFFFFF & p.size(); // # of input vertices. Uint32 outputCount = 0; // # of output vertices Uint32 hashSize = nextPowerOfTwo(N); // size of the hash table Uint32 *hashTable = new Uint32[hashSize + N]; // hash table + linked list diff --git a/src/galaxy/SystemPath.cpp b/src/galaxy/SystemPath.cpp index 75f9b1dfa46..4d38e2415e5 100644 --- a/src/galaxy/SystemPath.cpp +++ b/src/galaxy/SystemPath.cpp @@ -27,9 +27,13 @@ static int ParseInt(const std::string &str) int i = 0; try { i = std::stoi(str); +#pragma message("FIX: warning of unused variable") +#pragma warning(push) +#pragma warning(disable: 4101) } catch (const std::invalid_argument &e) { throw SystemPath::ParseFailure(); } +#pragma warning(pop) return i; } diff --git a/src/graphics/opengl/Program.cpp b/src/graphics/opengl/Program.cpp index 6524c723e41..3c472c76073 100644 --- a/src/graphics/opengl/Program.cpp +++ b/src/graphics/opengl/Program.cpp @@ -184,19 +184,22 @@ namespace Graphics { void AppendSource(const char *str) { blocks.push_back(str); - block_sizes.push_back(std::strlen(str)); +#pragma message("FIX: warning of data loss (x64)") + block_sizes.push_back(0xFFFFFFFF & std::strlen(str)); } void AppendSource(StringRange str) { blocks.push_back(str.begin); - block_sizes.push_back(str.Size()); +#pragma message("FIX: warning of data loss (x64)") + block_sizes.push_back(0xFFFFFFFF & str.Size()); } void Compile(GLuint shader_id) { assert(blocks.size() == block_sizes.size()); - glShaderSource(shader_id, blocks.size(), &blocks[0], &block_sizes[0]); +#pragma message("FIX: warning of data loss (x64)") + glShaderSource(shader_id, 0xFFFFFFFF & blocks.size(), &blocks[0], &block_sizes[0]); glCompileShader(shader_id); } diff --git a/src/graphics/opengl/RendererGL.cpp b/src/graphics/opengl/RendererGL.cpp index af91a76fcd0..7f6644b029b 100644 --- a/src/graphics/opengl/RendererGL.cpp +++ b/src/graphics/opengl/RendererGL.cpp @@ -541,7 +541,8 @@ namespace Graphics { buffer.vtxBuffer->Reset(); } - stat.SetStatCount(Stats::STAT_DYNAMIC_DRAW_BUFFER_INUSE, s_DynamicDrawBufferMap.size()); +#pragma message("FIX: warning of data loss (x64)") + stat.SetStatCount(Stats::STAT_DYNAMIC_DRAW_BUFFER_INUSE, 0xFFFFFFFF & s_DynamicDrawBufferMap.size()); stat.SetStatCount(Stats::STAT_DRAW_UNIFORM_BUFFER_INUSE, uint32_t(m_drawUniformBuffers.size())); stat.SetStatCount(Stats::STAT_DRAW_UNIFORM_BUFFER_ALLOCS, numAllocs); @@ -549,7 +550,8 @@ namespace Graphics { for (auto &pair : m_shaders) numShaderPrograms += pair.second->GetNumVariants(); - stat.SetStatCount(Stats::STAT_NUM_RENDER_STATES, m_renderStateCache->m_stateDescCache.size()); +#pragma message("FIX: warning of data loss (x64)") + stat.SetStatCount(Stats::STAT_NUM_RENDER_STATES, 0xFFFFFFFF & m_renderStateCache->m_stateDescCache.size()); stat.SetStatCount(Stats::STAT_NUM_SHADER_PROGRAMS, numShaderPrograms); return true; diff --git a/src/graphics/opengl/Shader.h b/src/graphics/opengl/Shader.h index 2fbcedc3fde..c1bc781868e 100644 --- a/src/graphics/opengl/Shader.h +++ b/src/graphics/opengl/Shader.h @@ -75,7 +75,8 @@ namespace Graphics { void Reload(); Program *GetProgramForDesc(const MaterialDescriptor &desc); - uint32_t GetNumVariants() const { return m_variants.size(); } +#pragma message("FIX: warning of data loss (x64)") + uint32_t GetNumVariants() const { return 0xFFFFFFFF & m_variants.size(); } TextureBindingData GetTextureBindingInfo(size_t name) const; size_t GetNumTextureBindings() const { return m_textureBindingInfo.size(); } diff --git a/src/scenegraph/Serializer.h b/src/scenegraph/Serializer.h index a0624c47298..be827c73560 100644 --- a/src/scenegraph/Serializer.h +++ b/src/scenegraph/Serializer.h @@ -45,7 +45,8 @@ namespace Serializer { void writeObject(const std::string &obj) { - writeObject(obj.size()); +#pragma message("FIX: warning of data loss (x64)") + writeObject(0xFFFFFFFF & obj.size()); m_str.append(obj.c_str(), obj.size()); } @@ -56,7 +57,8 @@ namespace Serializer { return; } - Uint32 len = strlen(s); +#pragma message("FIX: warning of data loss (x64)") + uint32_t len = uint32_t(strlen(s)); *this << len; m_str.append(s, len); } @@ -80,7 +82,8 @@ namespace Serializer { void Blob(ByteRange range) { assert(range.Size() < SDL_MAX_UINT32); - Int32(range.Size()); +#pragma message("FIX: warning of data loss (x64)") + Int32(0xFFFFFFFF & range.Size()); if (range.Size()) { m_str.append(range.begin, range.Size()); } @@ -179,7 +182,8 @@ namespace Serializer { ByteRange Blob() { - auto len = Int32(); +#pragma message("FIX: signed/unsigned mismatch") + int32_t len = Int32(); if (len == 0) return ByteRange(); if (len > (m_data.end - m_at)) throw std::out_of_range("Serializer::Reader encountered truncated stream."); diff --git a/src/text/TextSupport.h b/src/text/TextSupport.h index 1c568797dbf..e75d1434a04 100644 --- a/src/text/TextSupport.h +++ b/src/text/TextSupport.h @@ -39,7 +39,8 @@ namespace Text { do { ++str; } while ((*str & 0xC0) == 0x80); - return (str - start); +#pragma message("FIX: warning of data loss (x64)") + return int(str - start); } else return 1; } @@ -57,7 +58,8 @@ namespace Text { while ((str > begin) && ((*str & 0xC0) == 0x80)) { --str; } - return (start - str); +#pragma message("FIX: warning of data loss (x64)") + return int(start - str); } else return 1; } diff --git a/src/win32/TextUtils.cpp b/src/win32/TextUtils.cpp index 8e2d53ce6d5..21dc5c384fd 100644 --- a/src/win32/TextUtils.cpp +++ b/src/win32/TextUtils.cpp @@ -12,7 +12,8 @@ std::wstring transcode_utf8_to_utf16(const char *s, size_t nbytes) { std::wstring buf(nbytes, L'x'); - int reqchars = MultiByteToWideChar(CP_UTF8, 0, s, nbytes, &buf[0], buf.size()); +#pragma message("FIX: warning of data loss (x64)") + int reqchars = MultiByteToWideChar(CP_UTF8, 0, s, 0xFFFFFFFF & nbytes, &buf[0], 0xFFFFFFFF & buf.size()); if (!reqchars) { fprintf(stderr, "failed to transcode UTF-8 to UTF-16\n"); abort(); @@ -29,7 +30,8 @@ std::wstring transcode_utf8_to_utf16(const std::string &s) std::string transcode_utf16_to_utf8(const wchar_t *s, size_t nchars) { std::string buf(nchars * 2, 'x'); - int reqbytes = WideCharToMultiByte(CP_UTF8, 0, s, nchars, &buf[0], buf.size(), 0, 0); +#pragma message("FIX: warning of data loss (x64)") + int reqbytes = WideCharToMultiByte(CP_UTF8, 0, s, 0xFFFFFFFF & nchars, &buf[0], 0xFFFFFFFF & buf.size(), 0, 0); if (!reqbytes) { fprintf(stderr, "failed to transcode UTF-16 to UTF-8\n"); abort();