Skip to content

Commit

Permalink
WIP warning redux
Browse files Browse the repository at this point in the history
  • Loading branch information
joonicks committed Sep 7, 2021
1 parent db12012 commit b2ab3ce
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 23 deletions.
9 changes: 6 additions & 3 deletions src/SpaceStationType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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*/
Expand Down
3 changes: 2 additions & 1 deletion src/SystemView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
15 changes: 11 additions & 4 deletions src/collider/GeomTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -57,7 +60,8 @@ GeomTree::GeomTree(const int numVerts, const int numTris, const std::vector<vect
std::vector<Uint32> xrefs;
nv::Weld<vector3f> 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);

Expand Down Expand Up @@ -109,12 +113,14 @@ GeomTree::GeomTree(const int numVerts, const int numTris, const std::vector<vect
}

//int t = SDL_GetTicks();
m_triTree.reset(new BVHTree(activeTris.size(), &activeTris[0], aabbs));
#pragma message("FIX: warning of data loss (x64)")
m_triTree.reset(new BVHTree(0xFFFFFFFF & activeTris.size(), &activeTris[0], aabbs));
delete[] aabbs;
}
//Output("Tri tree of %d tris build in %dms\n", activeTris.size(), SDL_GetTicks() - t);

m_numEdges = edges.size();
#pragma message("FIX: warning of data loss (x64)")
m_numEdges = 0xFFFFFFFF & edges.size();
m_edges.resize(m_numEdges);
// to build Edge bvh tree with.
m_aabbs.resize(m_numEdges);
Expand Down Expand Up @@ -212,7 +218,8 @@ GeomTree::GeomTree(Serializer::Reader &rd)
aabbs[i].Update(v2);
aabbs[i].Update(v3);
}
m_triTree.reset(new BVHTree(activeTris.size(), &activeTris[0], aabbs));
#pragma message("FIX: warning of data loss (x64)")
m_triTree.reset(new BVHTree(0xFFFFFFFF & activeTris.size(), &activeTris[0], aabbs));
delete[] aabbs;

//
Expand Down
3 changes: 2 additions & 1 deletion src/collider/Weld.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ namespace nv {
// xrefs maps old elements to new elements
Uint32 operator()(std::vector<T> &p, std::vector<Uint32> &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
Expand Down
4 changes: 4 additions & 0 deletions src/galaxy/SystemPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 6 additions & 3 deletions src/graphics/opengl/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 4 additions & 2 deletions src/graphics/opengl/RendererGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,15 +541,17 @@ 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);

uint32_t numShaderPrograms = 0;
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;
Expand Down
3 changes: 2 additions & 1 deletion src/graphics/opengl/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
12 changes: 8 additions & 4 deletions src/scenegraph/Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace Serializer {

void writeObject(const std::string &obj)
{
writeObject<Uint32>(obj.size());
#pragma message("FIX: warning of data loss (x64)")
writeObject<Uint32>(0xFFFFFFFF & obj.size());
m_str.append(obj.c_str(), obj.size());
}

Expand All @@ -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);
}
Expand All @@ -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());
}
Expand Down Expand Up @@ -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.");
Expand Down
6 changes: 4 additions & 2 deletions src/text/TextSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/win32/TextUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit b2ab3ce

Please sign in to comment.