From b8d691d564a33274eab1707412b5dcba087827f4 Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Tue, 17 Dec 2024 11:50:05 -0300 Subject: [PATCH 1/9] var game_type converted to i32 in all instances this resolve a compilation warning about comparison of expressions wih different signedness. --- src/xrSound/Sound.h | 8 ++++---- src/xrSound/SoundRender_Core.cpp | 2 +- src/xrSound/SoundRender_Core.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/xrSound/Sound.h b/src/xrSound/Sound.h index 42d3d32a40c..f4280801d32 100644 --- a/src/xrSound/Sound.h +++ b/src/xrSound/Sound.h @@ -207,7 +207,7 @@ class XRSOUND_API XR_NOVTABLE ISoundManager friend struct CSound; friend struct resptrcode_sound; - virtual CSound* create(pcstr fName, esound_type sound_type, int game_type) = 0; + virtual CSound* create(pcstr fName, esound_type sound_type, u32 game_type) = 0; virtual void destroy(CSound& S) = 0; virtual void attach_tail(CSound& S, pcstr fName) = 0; @@ -318,7 +318,7 @@ struct resptrcode_sound : public resptr_base [[nodiscard]] ICF CSound_UserDataPtr _g_userdata() const { VERIFY(p_); return p_ ? p_->g_userdata : nullptr; } - ICF bool create(pcstr name, esound_type sound_type, int game_type) + ICF bool create(pcstr name, esound_type sound_type, u32 game_type) { VerSndUnlocked(); _set(GEnv.Sound->create(name, sound_type, game_type)); @@ -338,7 +338,7 @@ struct resptrcode_sound : public resptr_base GEnv.Sound->attach_tail(*p_, name); } - void clone(const ref_sound& from, esound_type sound_type, int game_type) + void clone(const ref_sound& from, esound_type sound_type, u32 game_type) { if (!from._get()) return; @@ -422,7 +422,7 @@ class XRSOUND_API CSound_stats_ext CSound_params params; float volume; esound_type type; - int game_type; + u32 game_type; IGameObject* game_object; struct diff --git a/src/xrSound/SoundRender_Core.cpp b/src/xrSound/SoundRender_Core.cpp index 15b14343c23..6c96c0084bb 100644 --- a/src/xrSound/SoundRender_Core.cpp +++ b/src/xrSound/SoundRender_Core.cpp @@ -98,7 +98,7 @@ void CSoundRender_Core::_restart() env_apply(); } -CSound* CSoundRender_Core::create(pcstr fName, esound_type sound_type, int game_type) +CSound* CSoundRender_Core::create(pcstr fName, esound_type sound_type, u32 game_type) { if (!bPresent) return nullptr; diff --git a/src/xrSound/SoundRender_Core.h b/src/xrSound/SoundRender_Core.h index 149d864ee43..d4e2af0ff12 100644 --- a/src/xrSound/SoundRender_Core.h +++ b/src/xrSound/SoundRender_Core.h @@ -95,7 +95,7 @@ class CSoundRender_Core : public ISoundManager void _restart() override; // Sound interface - CSound* create(pcstr fName, esound_type sound_type, int game_type) override; + CSound* create(pcstr fName, esound_type sound_type, u32 game_type) override; void attach_tail(CSound& S, pcstr fName) override; void destroy(CSound& S) override; From e9d23a1a610dc40c4afd8d6ed4b6e1e56172bd9f Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Tue, 17 Dec 2024 12:51:33 -0300 Subject: [PATCH 2/9] explicit conversion to u32 of GetCurrentProcessId()/getpid() in Server_Client_Check function this avoid a compilation warning about comparison of integer expressions of different signedness. --- src/xrGame/xrServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xrGame/xrServer.cpp b/src/xrGame/xrServer.cpp index 38f9a71c88d..ab180810a53 100644 --- a/src/xrGame/xrServer.cpp +++ b/src/xrGame/xrServer.cpp @@ -866,7 +866,7 @@ void xrServer::Server_Client_Check(IClient* CL) return; }; - if (CL->process_id == GetCurrentProcessId()) + if (CL->process_id == static_cast(GetCurrentProcessId())) { CL->flags.bLocal = 1; SV_Client = (xrClientData*)CL; From 1e19d9c5ed112e92066b3d30a9b0d321b71fa3fd Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Tue, 17 Dec 2024 15:25:37 -0300 Subject: [PATCH 3/9] local variable "c" converted to size_t this avoid compilation warnings about comparison expressions of different signedness. --- src/xrCore/FixedVector.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xrCore/FixedVector.h b/src/xrCore/FixedVector.h index d1da4527e58..c3d0b51538f 100644 --- a/src/xrCore/FixedVector.h +++ b/src/xrCore/FixedVector.h @@ -20,7 +20,7 @@ class svector public: svector() : count(0) {} - svector(iterator p, int c) { assign(p, c); } + svector(iterator p, size_t c) { assign(p, c); } IC iterator begin() { return array; } IC iterator end() { return array + count; } IC const_iterator begin() const { return array; } @@ -30,13 +30,13 @@ class svector IC u32 size() const { return count; } IC void clear() { count = 0; } - IC void resize(int c) + IC void resize(size_t c) { VERIFY(c <= dim); count = c; } - IC void reserve(int c) {} + IC void reserve(size_t c) {} IC void push_back(value_type e) { @@ -98,7 +98,7 @@ class svector count++; array[id] = V; } - IC void assign(const_iterator p, int c) + IC void assign(const_iterator p, size_t c) { VERIFY(c > 0 && c <= dim); CopyMemory(array, p, c * sizeof(value_type)); From 23ec54538ab19a75513c38a0814c0e996a720fbe Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Thu, 19 Dec 2024 11:48:22 -0300 Subject: [PATCH 4/9] var "m_style_id" explictly converted to int - resolves a compilation warning about comparison expressions of different signedness. - setupstyle() uses getcurrentstylename() to retrieve name. - correction in the message log. --- src/xrUICore/ui_styles.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/xrUICore/ui_styles.cpp b/src/xrUICore/ui_styles.cpp index 2cf6b92e4a7..94d1ca4b342 100644 --- a/src/xrUICore/ui_styles.cpp +++ b/src/xrUICore/ui_styles.cpp @@ -74,12 +74,7 @@ void UIStyleManager::SetupStyle(u32 styleID) if (DefaultStyleIsSet()) return; - pcstr selectedStyle = nullptr; - for (const auto& token : m_token) - { - if (token.id == static_cast(m_style_id)) - selectedStyle = token.name; - } + pcstr selectedStyle = GetCurrentStyleName(); string_path selectedStylePath; strconcat(selectedStylePath, UI_PATH_DEFAULT, DELIMITER "styles" DELIMITER, selectedStyle); @@ -125,9 +120,9 @@ pcstr UIStyleManager::GetCurrentStyleName() const { for (const auto& token : m_token) { - if (token.id == m_style_id) + if (token.id == static_cast(m_style_id)) return token.name; } - VERIFY(!"Could retrieve current style name!"); + VERIFY(!"Could not retrieve current style name!"); return nullptr; } From 72a2fd818dedd2ed82875d7edcba7fc35393fd9e Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Thu, 19 Dec 2024 16:28:52 -0300 Subject: [PATCH 5/9] calculate_packed_xz() refactored in level_graph_inline.h - resolved a comp warning about comparison of different signedness - new function created: calculate_packed_xz(), used by const CPosition& CLevelGraph::vertex_position() and bool CLevelGraph::inside() - aditional minor resolves --- src/xrAICore/Navigation/level_graph.h | 3 +- src/xrAICore/Navigation/level_graph_inline.h | 31 +++++++++----------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/xrAICore/Navigation/level_graph.h b/src/xrAICore/Navigation/level_graph.h index b9793c5aca0..77a77ebb77a 100644 --- a/src/xrAICore/Navigation/level_graph.h +++ b/src/xrAICore/Navigation/level_graph.h @@ -125,6 +125,7 @@ class XRAICORE_API CLevelGraph ICF u32 vertex(const CLevelVertex& vertex_r) const; IC const Fvector vertex_position(const CLevelGraph::CPosition& source_position) const; IC const Fvector& vertex_position(Fvector& dest_position, const CLevelGraph::CPosition& source_position) const; + IC int calculate_packed_xz(const float x, const float z) const; IC const CLevelGraph::CPosition& vertex_position( CLevelGraph::CPosition& dest_position, const Fvector& source_position) const; IC const CLevelGraph::CPosition vertex_position(const Fvector& position) const; @@ -196,7 +197,7 @@ class XRAICORE_API CLevelGraph template IC float vertex_low_cover_angle(u32 vertex_id, float inc_angle, _predicate compare_predicate) const; IC void set_invalid_vertex(u32& vertex_id, CLevelVertex** vertex = NULL) const; - IC const u32 vertex_id(const CLevelGraph::CLevelVertex* vertex) const; + IC u32 vertex_id(const CLevelGraph::CLevelVertex* vertex) const; u32 vertex_id(const Fvector& position) const; private: diff --git a/src/xrAICore/Navigation/level_graph_inline.h b/src/xrAICore/Navigation/level_graph_inline.h index 2a79520eb3f..1124bf5545d 100644 --- a/src/xrAICore/Navigation/level_graph_inline.h +++ b/src/xrAICore/Navigation/level_graph_inline.h @@ -80,19 +80,23 @@ ICF const Fvector& CLevelGraph::vertex_position( return (dest_position = vertex_position(source_position)); } -// XXX: This method is WAY to large to inline. -IC const CLevelGraph::CPosition& CLevelGraph::vertex_position(CPosition& dest_position, const Fvector& source_position) const +IC int CLevelGraph::calculate_packed_xz(const float x, const float z) const { const auto [box_x, box_y, box_z] = header().box().vMin; const auto cell_size = header().cell_size(); + const int packed_xz = iFloor((x - box_x) / cell_size + .5f) * m_row_length + + iFloor((z - box_z) / cell_size + .5f); - VERIFY(iFloor((source_position.z - box_z) / cell_size + .5f) < (int)m_row_length); + VERIFY(packed_xz < static_cast(NodePosition::MAX_XZ)); + return packed_xz; +} - const int packed_xz = iFloor((source_position.x - box_x) / cell_size + .5f) - * m_row_length + iFloor((source_position.z - box_z) / cell_size + .5f); - VERIFY(packed_xz < NodePosition::MAX_XZ); +// XXX: This method is WAY too large to inline. +IC const CLevelGraph::CPosition& CLevelGraph::vertex_position(CPosition& dest_position, const Fvector& source_position) const +{ + const int packed_xz = calculate_packed_xz(source_position.x, source_position.z); - int packed_y = iFloor(65535.f * (source_position.y - box_y) / header().factor_y() + EPS_S); + int packed_y = iFloor(65535.f * (source_position.y - header().box().vMin.y) / header().factor_y() + EPS_S); clamp(packed_y, 0, 65535); dest_position.xz(u32(packed_xz)); @@ -195,15 +199,8 @@ IC bool CLevelGraph::inside(const u32 vertex_id, const Fvector& position, const IC bool CLevelGraph::inside(const u32 vertex_id, const Fvector2& position) const { - [[maybe_unused]] - const auto [box_x, box_y, box_z] = header().box().vMin; - const auto cell_size = header().cell_size(); - - const int packed_xz = iFloor((position.x - box_x) / cell_size + .5f) * m_row_length + - iFloor((position.y - box_z) / cell_size + .5f); - VERIFY(packed_xz < NodePosition::MAX_XZ); - const bool b = vertex(vertex_id)->position().xz() == u32(packed_xz); - return b; + const int packed_xz = calculate_packed_xz(position.x, position.y); + return vertex(vertex_id)->position().xz() == u32(packed_xz); } IC float CLevelGraph::vertex_plane_y(const CLevelGraph::CLevelVertex& vertex, const float X, const float Z) const @@ -299,7 +296,7 @@ IC void CLevelGraph::set_invalid_vertex(u32& vertex_id, CLevelVertex** vertex) c *vertex = NULL; } -IC const u32 CLevelGraph::vertex_id(const CLevelGraph::CLevelVertex* vertex) const +IC u32 CLevelGraph::vertex_id(const CLevelGraph::CLevelVertex* vertex) const { VERIFY(valid_vertex_id(u32(vertex - m_nodes->begin()))); return (u32(vertex - m_nodes->begin())); From f4f26f3f976ccf1bde289fbe3a6b66e8d85fb6c3 Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Thu, 19 Dec 2024 21:08:08 -0300 Subject: [PATCH 6/9] resolves several warning compilations when comparing differents signedness - resolves a warning compilation in ConvertTextureFormat(), modified to a for loop range, this avoid integers comparisions. - resolves warnings when int comparing with unsigned macro R__NUM_SUN_CASCADES, in render_phase_sun.cpp. - resolves warnings when int comparing with unsigned macro R__NUM_PARALLEL_CONTEXTS, in r2_loader.cpp - var "b_count" converted to unsigned to resolve warnings within for loops, in AnimationKeyCalculate.h - resolves warnings when for loops compare signed vs unsigned, in r__sector.cpp --- src/Layers/xrRender/AnimationKeyCalculate.h | 10 +++++----- src/Layers/xrRender/r__sector.cpp | 6 +++--- src/Layers/xrRenderGL/glTextureUtils.cpp | 11 +++++------ src/Layers/xrRender_R2/r2_loader.cpp | 2 +- src/Layers/xrRender_R2/render_phase_sun.cpp | 8 ++++---- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/Layers/xrRender/AnimationKeyCalculate.h b/src/Layers/xrRender/AnimationKeyCalculate.h index 04dfeb3ccb3..9bcf27dc648 100644 --- a/src/Layers/xrRender/AnimationKeyCalculate.h +++ b/src/Layers/xrRender/AnimationKeyCalculate.h @@ -178,7 +178,7 @@ IC void Dequantize(CKey& K, const CBlend& BD, const CMotion& M) } } -IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], int b_count) +IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], unsigned int b_count) { VERIFY(MAX_BLENDED >= b_count); switch (b_count) @@ -237,14 +237,14 @@ IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLE //int count = Blend.size(); float total = 0; ConsistantKey S[MAX_BLENDED]; - for (int i = 0; i < b_count; i++) + for (unsigned int i = 0; i < b_count; i++) S[i].set(R + i, BA[i]->blendAmount); std::sort(S, S + b_count); CKey tmp; total = S[0].w; tmp = *S[0].K; - for (int cnt = 1; cnt < b_count; cnt++) + for (unsigned int cnt = 1; cnt < b_count; cnt++) { total += S[cnt].w; float d; @@ -400,14 +400,14 @@ IC void process_single_channel( VERIFY(_valid(Result.T)); VERIFY(_valid(Result.Q)); } -IC void MixChannels(CKey& Result, const CKey* R, const animation::channel_def* BA, int b_count) +IC void MixChannels(CKey& Result, const CKey* R, const animation::channel_def* BA, unsigned int b_count) { VERIFY(b_count > 0); Result = R[0]; // MixinAdd(Result,R,BA,b_count); float lerp_factor_sum = 0.f; - for (int i = 1; i < b_count; i++) + for (unsigned int i = 1; i < b_count; i++) switch (BA[i].rule.extern_) { case animation::add: key_mad(Result, CKey(Result), R[i], BA[i].factor); break; diff --git a/src/Layers/xrRender/r__sector.cpp b/src/Layers/xrRender/r__sector.cpp index 458c6f7d47a..28ef818618e 100644 --- a/src/Layers/xrRender/r__sector.cpp +++ b/src/Layers/xrRender/r__sector.cpp @@ -97,7 +97,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector& // calc sphere Fbox BB; BB.invalidate(); - for (int v = 0; v < vcnt; v++) + for (unsigned int v = 0; v < vcnt; v++) BB.modify(V[v]); BB.getsphere(S.P, S.R); @@ -111,7 +111,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector& N.set(0, 0, 0); u32 _cnt = 0; - for (int i = 2; i < vcnt; i++) + for (unsigned int i = 2; i < vcnt; i++) { T.mknormal_non_normalized(poly[0], poly[i - 1], poly[i]); float m = T.magnitude(); @@ -136,7 +136,7 @@ void CSector::setup(const level_sector_data_t& data, const xr_vector & // Assign portal polygons const auto num_portals = data.portals_id.size(); m_portals.resize(num_portals); - for (int idx = 0; idx < num_portals; ++idx) + for (unsigned int idx = 0; idx < num_portals; ++idx) { const auto ID = data.portals_id[idx]; m_portals[idx] = portals[ID]; diff --git a/src/Layers/xrRenderGL/glTextureUtils.cpp b/src/Layers/xrRenderGL/glTextureUtils.cpp index 4536987e314..ef5acd3d28a 100644 --- a/src/Layers/xrRenderGL/glTextureUtils.cpp +++ b/src/Layers/xrRenderGL/glTextureUtils.cpp @@ -99,12 +99,11 @@ TextureFormatPairs TextureFormatList[] = GLenum ConvertTextureFormat(D3DFORMAT dx9FMT) { - constexpr size_t arrayLength = sizeof(TextureFormatList) / sizeof(TextureFormatList[0]); - for (int i = 0; i < arrayLength; ++i) - { - if (TextureFormatList[i].m_dx9FMT == dx9FMT) - return TextureFormatList[i].m_glFMT; - } + for (const auto& textureFormat : TextureFormatList) + { + if (textureFormat.m_dx9FMT == dx9FMT) + return textureFormat.m_glFMT; + } VERIFY(!"ConvertTextureFormat didn't find appropriate gl texture format!"); return GL_NONE; diff --git a/src/Layers/xrRender_R2/r2_loader.cpp b/src/Layers/xrRender_R2/r2_loader.cpp index c703c7e96ce..c7ccc4442da 100644 --- a/src/Layers/xrRender_R2/r2_loader.cpp +++ b/src/Layers/xrRender_R2/r2_loader.cpp @@ -423,7 +423,7 @@ void CRender::LoadSectors(IReader* fs) rmPortals = nullptr; } - for (int id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id) + for (unsigned int id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id) { auto& dsgraph = contexts_pool[id]; dsgraph.reset(); diff --git a/src/Layers/xrRender_R2/render_phase_sun.cpp b/src/Layers/xrRender_R2/render_phase_sun.cpp index 06ee60bae33..730f4097d0a 100644 --- a/src/Layers/xrRender_R2/render_phase_sun.cpp +++ b/src/Layers/xrRender_R2/render_phase_sun.cpp @@ -49,7 +49,7 @@ void render_sun::init() return; // pre-allocate contexts - for (int i = 0; i < R__NUM_SUN_CASCADES; ++i) + for (unsigned int i = 0; i < R__NUM_SUN_CASCADES; ++i) { contexts_ids[i] = RImplementation.alloc_context(); VERIFY(contexts_ids[i] != R_dsgraph_structure::INVALID_CONTEXT_ID); @@ -114,7 +114,7 @@ void render_sun::calculate() Fvector3 cull_COP[R__NUM_SUN_CASCADES]; Fmatrix cull_xform[R__NUM_SUN_CASCADES]; - for (int cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind) + for (unsigned int cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind) { cull_planes.clear(); @@ -378,9 +378,9 @@ void render_sun::flush() if (RImplementation.o.support_rt_arrays) { - for (int cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind) + for (unsigned int i = 0; i < R__NUM_SUN_CASCADES; ++i) { - accumulate_cascade(cascade_ind); + accumulate_cascade(i); } } From c8066e995098a9992c36e110f9ccb86e69411326 Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Fri, 20 Dec 2024 21:26:20 -0300 Subject: [PATCH 7/9] Resolves several compile warnings when comparing different int signedness (2) - advances #713 and eliminates all warnings concerning this operation: - in R_dsgraph_structure::load() / r__dsgraph_build.cpp - var 'vcnt' converted to u32 in R_Backend_DBG.cpp - several for loops in light.cpp - several for loops in in DetailManager_CACHE.cpp - var 'filled_blocks' converted from int to i32, in SoundRender_Emitter.cpp - in CSoundRender_Core::create() / SoundRender_Core.cpp, explicit convertion of var 'sg_SourceType' to int - for loop in CollectorPacked::CollectorPacked() / xrCDB_Collector.cpp - several for loops in Frustum.cpp --- src/Layers/xrRender/DetailManager_CACHE.cpp | 4 ++-- src/Layers/xrRender/R_Backend.h | 2 +- src/Layers/xrRender/R_Backend_DBG.cpp | 4 ++-- src/Layers/xrRender/light.cpp | 4 ++-- src/Layers/xrRender/r__dsgraph_build.cpp | 6 +++--- src/xrCDB/Frustum.cpp | 12 ++++++------ src/xrCDB/xrCDB_Collector.cpp | 6 +++--- src/xrSound/SoundRender_Core.cpp | 2 +- src/xrSound/SoundRender_Emitter.h | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Layers/xrRender/DetailManager_CACHE.cpp b/src/Layers/xrRender/DetailManager_CACHE.cpp index d3fab4b11fe..aaa6b2ced83 100644 --- a/src/Layers/xrRender/DetailManager_CACHE.cpp +++ b/src/Layers/xrRender/DetailManager_CACHE.cpp @@ -37,9 +37,9 @@ void CDetailManager::cache_Initialize() CDetailManager::Slot* CDetailManager::cache_Query(int r_x, int r_z) { int gx = w2cg_X(r_x + cache_cx); - VERIFY(gx >= 0 && gx < dm_cache_line); + VERIFY(gx >= 0 && gx < static_cast(dm_cache_line)); int gz = w2cg_Z(r_z + cache_cz); - VERIFY(gz >= 0 && gz < dm_cache_line); + VERIFY(gz >= 0 && gz < static_cast(dm_cache_line)); return cache[gz][gx]; } diff --git a/src/Layers/xrRender/R_Backend.h b/src/Layers/xrRender/R_Backend.h index b75f7a808ec..1eca7c5e8eb 100644 --- a/src/Layers/xrRender/R_Backend.h +++ b/src/Layers/xrRender/R_Backend.h @@ -539,7 +539,7 @@ class ECORE_API CBackend void dbg_SetRS(D3DRENDERSTATETYPE p1, u32 p2); void dbg_SetSS(u32 sampler, D3DSAMPLERSTATETYPE type, u32 value); #ifdef DEBUG - void dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int vcnt, u16* pIdx, int pcnt); + void dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, u32 vcnt, u16* pIdx, int pcnt); void dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int pcnt); void dbg_DrawAABB(Fvector& T, float sx, float sy, float sz, u32 C) diff --git a/src/Layers/xrRender/R_Backend_DBG.cpp b/src/Layers/xrRender/R_Backend_DBG.cpp index c97d61c97df..34c04817262 100644 --- a/src/Layers/xrRender/R_Backend_DBG.cpp +++ b/src/Layers/xrRender/R_Backend_DBG.cpp @@ -29,7 +29,7 @@ void CBackend::dbg_DIP(D3DPRIMITIVETYPE pt, ref_geom geom, u32 baseV, u32 startV #ifdef DEBUG -void CBackend::dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int vcnt, u16* pIdx, int pcnt) +void CBackend::dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, u32 vcnt, u16* pIdx, int pcnt) { u32 vBase; { @@ -191,7 +191,7 @@ void CBackend::dbg_DrawEllipse(Fmatrix& T, u32 C) 102, 113, 104, 103, 113, 105, 104, 113, 106, 105, 113, 107, 106, 113, 108, 107, 113, 109, 108, 113, 110, 109, 113, 111, 110, 113, 112, 111, 113, 97, 112}; - const int vcnt = sizeof(gVertices) / (sizeof(float) * 3); + const u32 vcnt = sizeof(gVertices) / (sizeof(float) * 3); FVF::L verts[vcnt]; for (int i = 0; i < vcnt; i++) { diff --git a/src/Layers/xrRender/light.cpp b/src/Layers/xrRender/light.cpp index ebf01da9d4f..4d17884aab2 100644 --- a/src/Layers/xrRender/light.cpp +++ b/src/Layers/xrRender/light.cpp @@ -36,7 +36,7 @@ light::light() : SpatialBase(g_pGamePersistent->SpatialSpace) vis.query_order = 0; vis.visible = true; vis.pending = false; - for (int id = 0; id < R__NUM_CONTEXTS; ++id) + for (unsigned int id = 0; id < R__NUM_CONTEXTS; ++id) svis[id].id = id; #endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL) } @@ -212,7 +212,7 @@ void light::spatial_move() #if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER == R_GL) if (flags.bActive) gi_generate(); - for (int id = 0; id < R__NUM_CONTEXTS; ++id) + for (unsigned int id = 0; id < R__NUM_CONTEXTS; ++id) svis[id].invalidate(); #endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER == R_GL) } diff --git a/src/Layers/xrRender/r__dsgraph_build.cpp b/src/Layers/xrRender/r__dsgraph_build.cpp index bc226a5b609..2a11b45b409 100644 --- a/src/Layers/xrRender/r__dsgraph_build.cpp +++ b/src/Layers/xrRender/r__dsgraph_build.cpp @@ -675,13 +675,13 @@ void R_dsgraph_structure::load(const xr_vector& se Sectors.resize(sectors_count); Portals.resize(portals_count); - for (int idx = 0; idx < portals_count; ++idx) + for (unsigned int idx = 0; idx < portals_count; ++idx) { auto* portal = xr_new(); Portals[idx] = portal; } - for (int idx = 0; idx < sectors_count; ++idx) + for (unsigned int idx = 0; idx < sectors_count; ++idx) { auto* sector = xr_new(); @@ -690,7 +690,7 @@ void R_dsgraph_structure::load(const xr_vector& se Sectors[idx] = sector; } - for (int idx = 0; idx < portals_count; ++idx) + for (unsigned int idx = 0; idx < portals_count; ++idx) { auto* portal = static_cast(Portals[idx]); diff --git a/src/xrCDB/Frustum.cpp b/src/xrCDB/Frustum.cpp index 23bdbea8946..b7d780e5a3b 100644 --- a/src/xrCDB/Frustum.cpp +++ b/src/xrCDB/Frustum.cpp @@ -82,7 +82,7 @@ u32 frustum_aabb_remap[8][6] = EFC_Visible CFrustum::testSphere(Fvector& c, float r, u32& test_mask) const { u32 bit = 1; - for (int i = 0; i < p_count; i++, bit <<= 1) + for (unsigned int i = 0; i < p_count; i++, bit <<= 1) { if (test_mask & bit) { @@ -162,7 +162,7 @@ EFC_Visible CFrustum::testAABB(const float* mM, u32& test_mask) const // go for trivial rejection or acceptance using "faster overlap test" u32 bit = 1; - for (int i = 0; i < p_count; i++, bit <<= 1) + for (unsigned int i = 0; i < p_count; i++, bit <<= 1) { if (test_mask & bit) { @@ -182,7 +182,7 @@ EFC_Visible CFrustum::testAABB(const float* mM, u32& test_mask) const EFC_Visible CFrustum::testSAABB(Fvector& c, float r, const float* mM, u32& test_mask) const { u32 bit = 1; - for (int i = 0; i < p_count; i++, bit <<= 1) + for (unsigned int i = 0; i < p_count; i++, bit <<= 1) { if (test_mask & bit) { @@ -213,7 +213,7 @@ EFC_Visible CFrustum::testSAABB(Fvector& c, float r, const float* mM, u32& test_ bool CFrustum::testPolyInside_dirty(Fvector* p, size_t count) const { Fvector* e = p + count; - for (int i = 0; i < p_count; i++) + for (unsigned int i = 0; i < p_count; i++) { const fplane& P = planes[i]; for (Fvector* I = p; I != e; I++) @@ -384,7 +384,7 @@ sPoly* CFrustum::ClipPoly(sPoly& S, sPoly& D) const { sPoly* src = &D; sPoly* dest = &S; - for (int i = 0; i < p_count; i++) + for (unsigned int i = 0; i < p_count; i++) { // cache plane and swap lists const fplane& P = planes[i]; @@ -530,7 +530,7 @@ void CFrustum::CreateFromMatrix(Fmatrix& M, u32 mask) p_count++; } - for (int i = 0; i < p_count; i++) + for (unsigned int i = 0; i < p_count; i++) { float denom = 1.0f / planes[i].n.magnitude(); // Get magnitude of Vector planes[i].n.x *= denom; diff --git a/src/xrCDB/xrCDB_Collector.cpp b/src/xrCDB/xrCDB_Collector.cpp index 0d83674c681..fbeba853d8f 100644 --- a/src/xrCDB/xrCDB_Collector.cpp +++ b/src/xrCDB/xrCDB_Collector.cpp @@ -305,9 +305,9 @@ CollectorPacked::CollectorPacked(const Fbox& bb, int apx_vertices, int apx_faces flags.reserve(apx_faces); int _size = (clpMX + 1) * (clpMY + 1) * (clpMZ + 1); int _average = (apx_vertices / _size) / 2; - for (int ix = 0; ix < clpMX + 1; ix++) - for (int iy = 0; iy < clpMY + 1; iy++) - for (int iz = 0; iz < clpMZ + 1; iz++) + for (unsigned int ix = 0; ix < clpMX + 1; ix++) + for (unsigned int iy = 0; iy < clpMY + 1; iy++) + for (unsigned int iz = 0; iz < clpMZ + 1; iz++) VM[ix][iy][iz].reserve(_average); } diff --git a/src/xrSound/SoundRender_Core.cpp b/src/xrSound/SoundRender_Core.cpp index 6c96c0084bb..a3eee88b376 100644 --- a/src/xrSound/SoundRender_Core.cpp +++ b/src/xrSound/SoundRender_Core.cpp @@ -115,7 +115,7 @@ CSound* CSoundRender_Core::create(pcstr fName, esound_type sound_type, u32 game_ auto* snd = xr_new(handle); snd->g_type = game_type; - if (game_type == sg_SourceType) + if (game_type == static_cast(sg_SourceType)) snd->g_type = snd->handle->game_type(); snd->s_type = sound_type; diff --git a/src/xrSound/SoundRender_Emitter.h b/src/xrSound/SoundRender_Emitter.h index dde498c0bf3..0c3938f3e04 100644 --- a/src/xrSound/SoundRender_Emitter.h +++ b/src/xrSound/SoundRender_Emitter.h @@ -85,7 +85,7 @@ class CSoundRender_Emitter final : public CSound_emitter std::atomic prefill_task{}; size_t current_block{}; - int filled_blocks{}; + u32 filled_blocks{}; void fill_block(void* ptr, u32 size); void fill_data(void* dest, u32 offset, u32 size) const; From 1679150514397240afc6d864725f576f252789aa Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Mon, 30 Dec 2024 18:17:43 -0300 Subject: [PATCH 8/9] Requested changes: "unsigned int" to "u32" Also, added fixes for Images.cpp --- src/Layers/xrRender/AnimationKeyCalculate.h | 10 +++++----- src/Layers/xrRender/R_Backend_DBG.cpp | 4 ++-- src/Layers/xrRender/light.cpp | 4 ++-- src/xrCore/Media/Image.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Layers/xrRender/AnimationKeyCalculate.h b/src/Layers/xrRender/AnimationKeyCalculate.h index 9bcf27dc648..0de76fed911 100644 --- a/src/Layers/xrRender/AnimationKeyCalculate.h +++ b/src/Layers/xrRender/AnimationKeyCalculate.h @@ -178,7 +178,7 @@ IC void Dequantize(CKey& K, const CBlend& BD, const CMotion& M) } } -IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], unsigned int b_count) +IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLENDED], u32 b_count) { VERIFY(MAX_BLENDED >= b_count); switch (b_count) @@ -237,14 +237,14 @@ IC void MixInterlerp(CKey& Result, const CKey* R, const CBlend* const BA[MAX_BLE //int count = Blend.size(); float total = 0; ConsistantKey S[MAX_BLENDED]; - for (unsigned int i = 0; i < b_count; i++) + for (u32 i = 0; i < b_count; i++) S[i].set(R + i, BA[i]->blendAmount); std::sort(S, S + b_count); CKey tmp; total = S[0].w; tmp = *S[0].K; - for (unsigned int cnt = 1; cnt < b_count; cnt++) + for (u32 cnt = 1; cnt < b_count; cnt++) { total += S[cnt].w; float d; @@ -400,14 +400,14 @@ IC void process_single_channel( VERIFY(_valid(Result.T)); VERIFY(_valid(Result.Q)); } -IC void MixChannels(CKey& Result, const CKey* R, const animation::channel_def* BA, unsigned int b_count) +IC void MixChannels(CKey& Result, const CKey* R, const animation::channel_def* BA, u32 b_count) { VERIFY(b_count > 0); Result = R[0]; // MixinAdd(Result,R,BA,b_count); float lerp_factor_sum = 0.f; - for (unsigned int i = 1; i < b_count; i++) + for (u32 i = 1; i < b_count; i++) switch (BA[i].rule.extern_) { case animation::add: key_mad(Result, CKey(Result), R[i], BA[i].factor); break; diff --git a/src/Layers/xrRender/R_Backend_DBG.cpp b/src/Layers/xrRender/R_Backend_DBG.cpp index 34c04817262..64baf6ce78d 100644 --- a/src/Layers/xrRender/R_Backend_DBG.cpp +++ b/src/Layers/xrRender/R_Backend_DBG.cpp @@ -193,9 +193,9 @@ void CBackend::dbg_DrawEllipse(Fmatrix& T, u32 C) const u32 vcnt = sizeof(gVertices) / (sizeof(float) * 3); FVF::L verts[vcnt]; - for (int i = 0; i < vcnt; i++) + for (u32 i = 0; i < vcnt; i++) { - int k = i * 3; + u32 k = i * 3; verts[i].set(gVertices[k], gVertices[k + 1], gVertices[k + 2], C); } diff --git a/src/Layers/xrRender/light.cpp b/src/Layers/xrRender/light.cpp index 4d17884aab2..b47a927f070 100644 --- a/src/Layers/xrRender/light.cpp +++ b/src/Layers/xrRender/light.cpp @@ -36,7 +36,7 @@ light::light() : SpatialBase(g_pGamePersistent->SpatialSpace) vis.query_order = 0; vis.visible = true; vis.pending = false; - for (unsigned int id = 0; id < R__NUM_CONTEXTS; ++id) + for (u32 id = 0; id < R__NUM_CONTEXTS; ++id) svis[id].id = id; #endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL) } @@ -212,7 +212,7 @@ void light::spatial_move() #if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER == R_GL) if (flags.bActive) gi_generate(); - for (unsigned int id = 0; id < R__NUM_CONTEXTS; ++id) + for (u32 id = 0; id < R__NUM_CONTEXTS; ++id) svis[id].invalidate(); #endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER == R_GL) } diff --git a/src/xrCore/Media/Image.cpp b/src/xrCore/Media/Image.cpp index b64b4b4220b..ba1aa75d140 100644 --- a/src/xrCore/Media/Image.cpp +++ b/src/xrCore/Media/Image.cpp @@ -53,10 +53,10 @@ void Image::SaveTGA(TWriter& writerFunc, ImageDataFormat format, bool align) writerFunc(&hdr, sizeof(hdr)); int paddingBuf = 0; int paddingSize = align ? 4 - (width * 3 & 3) : 0; - for (int j = 0; j < height; j++) + for (u32 j = 0; j < height; j++) { u8* p = (u8*)data + scanLength * j; - for (int i = 0; i < width; i++) + for (u32 i = 0; i < width; i++) { u8 buffer[3] = {p[0], p[1], p[2]}; writerFunc(buffer, sizeof(buffer)); @@ -76,10 +76,10 @@ void Image::SaveTGA(TWriter& writerFunc, ImageDataFormat format, bool align) writerFunc(data, width * height * channelCount); else { - for (int j = 0; j < height; j++) + for (u32 j = 0; j < height; j++) { u8* p = (u8*)data + scanLength * j; - for (int i = 0; i < width; i++) + for (u32 i = 0; i < width; i++) { u8 buffer[4] = {p[0], p[1], p[2], 0xff}; writerFunc(buffer, sizeof(buffer)); From 91e7e6f8669961e313fb46d82d1c6b1295ba12c6 Mon Sep 17 00:00:00 2001 From: Eduardo Alsina Date: Tue, 31 Dec 2024 10:56:44 -0300 Subject: [PATCH 9/9] revision changes: - all `unsigned int` changed to `u32` - on SoundRender_Emitter.h - var `filled_blocks` reverted to `int` as requested. - reverted changes to `level_graph_inline.h` - proposal for `Server_Client_Check()` on `xrServer.cpp` --- src/Layers/xrRender/r__dsgraph_build.cpp | 6 ++-- src/Layers/xrRender/r__sector.cpp | 6 ++-- src/Layers/xrRender_R2/r2_loader.cpp | 2 +- src/Layers/xrRender_R2/render_phase_sun.cpp | 8 +++--- src/xrAICore/Navigation/level_graph.h | 1 - src/xrAICore/Navigation/level_graph_inline.h | 29 +++++++++++--------- src/xrCDB/Frustum.cpp | 12 ++++---- src/xrCDB/xrCDB_Collector.cpp | 6 ++-- src/xrGame/xrServer.cpp | 2 +- src/xrSound/SoundRender_Core.cpp | 2 +- src/xrSound/SoundRender_Emitter.h | 2 +- 11 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/Layers/xrRender/r__dsgraph_build.cpp b/src/Layers/xrRender/r__dsgraph_build.cpp index 2a11b45b409..4e0dc12e337 100644 --- a/src/Layers/xrRender/r__dsgraph_build.cpp +++ b/src/Layers/xrRender/r__dsgraph_build.cpp @@ -675,13 +675,13 @@ void R_dsgraph_structure::load(const xr_vector& se Sectors.resize(sectors_count); Portals.resize(portals_count); - for (unsigned int idx = 0; idx < portals_count; ++idx) + for (u32 idx = 0; idx < portals_count; ++idx) { auto* portal = xr_new(); Portals[idx] = portal; } - for (unsigned int idx = 0; idx < sectors_count; ++idx) + for (u32 idx = 0; idx < sectors_count; ++idx) { auto* sector = xr_new(); @@ -690,7 +690,7 @@ void R_dsgraph_structure::load(const xr_vector& se Sectors[idx] = sector; } - for (unsigned int idx = 0; idx < portals_count; ++idx) + for (u32 idx = 0; idx < portals_count; ++idx) { auto* portal = static_cast(Portals[idx]); diff --git a/src/Layers/xrRender/r__sector.cpp b/src/Layers/xrRender/r__sector.cpp index 28ef818618e..637733a9b55 100644 --- a/src/Layers/xrRender/r__sector.cpp +++ b/src/Layers/xrRender/r__sector.cpp @@ -97,7 +97,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector& // calc sphere Fbox BB; BB.invalidate(); - for (unsigned int v = 0; v < vcnt; v++) + for (u32 v = 0; v < vcnt; v++) BB.modify(V[v]); BB.getsphere(S.P, S.R); @@ -111,7 +111,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector& N.set(0, 0, 0); u32 _cnt = 0; - for (unsigned int i = 2; i < vcnt; i++) + for (u32 i = 2; i < vcnt; i++) { T.mknormal_non_normalized(poly[0], poly[i - 1], poly[i]); float m = T.magnitude(); @@ -136,7 +136,7 @@ void CSector::setup(const level_sector_data_t& data, const xr_vector & // Assign portal polygons const auto num_portals = data.portals_id.size(); m_portals.resize(num_portals); - for (unsigned int idx = 0; idx < num_portals; ++idx) + for (u32 idx = 0; idx < num_portals; ++idx) { const auto ID = data.portals_id[idx]; m_portals[idx] = portals[ID]; diff --git a/src/Layers/xrRender_R2/r2_loader.cpp b/src/Layers/xrRender_R2/r2_loader.cpp index c7ccc4442da..167b00682bf 100644 --- a/src/Layers/xrRender_R2/r2_loader.cpp +++ b/src/Layers/xrRender_R2/r2_loader.cpp @@ -423,7 +423,7 @@ void CRender::LoadSectors(IReader* fs) rmPortals = nullptr; } - for (unsigned int id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id) + for (u32 id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id) { auto& dsgraph = contexts_pool[id]; dsgraph.reset(); diff --git a/src/Layers/xrRender_R2/render_phase_sun.cpp b/src/Layers/xrRender_R2/render_phase_sun.cpp index 730f4097d0a..036d1f8726b 100644 --- a/src/Layers/xrRender_R2/render_phase_sun.cpp +++ b/src/Layers/xrRender_R2/render_phase_sun.cpp @@ -49,7 +49,7 @@ void render_sun::init() return; // pre-allocate contexts - for (unsigned int i = 0; i < R__NUM_SUN_CASCADES; ++i) + for (u32 i = 0; i < R__NUM_SUN_CASCADES; ++i) { contexts_ids[i] = RImplementation.alloc_context(); VERIFY(contexts_ids[i] != R_dsgraph_structure::INVALID_CONTEXT_ID); @@ -114,7 +114,7 @@ void render_sun::calculate() Fvector3 cull_COP[R__NUM_SUN_CASCADES]; Fmatrix cull_xform[R__NUM_SUN_CASCADES]; - for (unsigned int cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind) + for (u32 cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind) { cull_planes.clear(); @@ -378,9 +378,9 @@ void render_sun::flush() if (RImplementation.o.support_rt_arrays) { - for (unsigned int i = 0; i < R__NUM_SUN_CASCADES; ++i) + for (u32 cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind) { - accumulate_cascade(i); + accumulate_cascade(cascade_ind); } } diff --git a/src/xrAICore/Navigation/level_graph.h b/src/xrAICore/Navigation/level_graph.h index 77a77ebb77a..7634b3aa6ee 100644 --- a/src/xrAICore/Navigation/level_graph.h +++ b/src/xrAICore/Navigation/level_graph.h @@ -125,7 +125,6 @@ class XRAICORE_API CLevelGraph ICF u32 vertex(const CLevelVertex& vertex_r) const; IC const Fvector vertex_position(const CLevelGraph::CPosition& source_position) const; IC const Fvector& vertex_position(Fvector& dest_position, const CLevelGraph::CPosition& source_position) const; - IC int calculate_packed_xz(const float x, const float z) const; IC const CLevelGraph::CPosition& vertex_position( CLevelGraph::CPosition& dest_position, const Fvector& source_position) const; IC const CLevelGraph::CPosition vertex_position(const Fvector& position) const; diff --git a/src/xrAICore/Navigation/level_graph_inline.h b/src/xrAICore/Navigation/level_graph_inline.h index 1124bf5545d..6b6bf13eeec 100644 --- a/src/xrAICore/Navigation/level_graph_inline.h +++ b/src/xrAICore/Navigation/level_graph_inline.h @@ -80,23 +80,19 @@ ICF const Fvector& CLevelGraph::vertex_position( return (dest_position = vertex_position(source_position)); } -IC int CLevelGraph::calculate_packed_xz(const float x, const float z) const +// XXX: This method is WAY to large to inline. +IC const CLevelGraph::CPosition& CLevelGraph::vertex_position(CPosition& dest_position, const Fvector& source_position) const { const auto [box_x, box_y, box_z] = header().box().vMin; const auto cell_size = header().cell_size(); - const int packed_xz = iFloor((x - box_x) / cell_size + .5f) * m_row_length + - iFloor((z - box_z) / cell_size + .5f); - VERIFY(packed_xz < static_cast(NodePosition::MAX_XZ)); - return packed_xz; -} + VERIFY(iFloor((source_position.z - box_z) / cell_size + .5f) < (int)m_row_length); -// XXX: This method is WAY too large to inline. -IC const CLevelGraph::CPosition& CLevelGraph::vertex_position(CPosition& dest_position, const Fvector& source_position) const -{ - const int packed_xz = calculate_packed_xz(source_position.x, source_position.z); + const int packed_xz = iFloor((source_position.x - box_x) / cell_size + .5f) + * m_row_length + iFloor((source_position.z - box_z) / cell_size + .5f); + VERIFY(packed_xz < NodePosition::MAX_XZ); - int packed_y = iFloor(65535.f * (source_position.y - header().box().vMin.y) / header().factor_y() + EPS_S); + int packed_y = iFloor(65535.f * (source_position.y - box_y) / header().factor_y() + EPS_S); clamp(packed_y, 0, 65535); dest_position.xz(u32(packed_xz)); @@ -199,8 +195,15 @@ IC bool CLevelGraph::inside(const u32 vertex_id, const Fvector& position, const IC bool CLevelGraph::inside(const u32 vertex_id, const Fvector2& position) const { - const int packed_xz = calculate_packed_xz(position.x, position.y); - return vertex(vertex_id)->position().xz() == u32(packed_xz); + [[maybe_unused]] + const auto [box_x, box_y, box_z] = header().box().vMin; + const auto cell_size = header().cell_size(); + + const int packed_xz = iFloor((position.x - box_x) / cell_size + .5f) * m_row_length + + iFloor((position.y - box_z) / cell_size + .5f); + VERIFY(packed_xz < NodePosition::MAX_XZ); + const bool b = vertex(vertex_id)->position().xz() == u32(packed_xz); + return b; } IC float CLevelGraph::vertex_plane_y(const CLevelGraph::CLevelVertex& vertex, const float X, const float Z) const diff --git a/src/xrCDB/Frustum.cpp b/src/xrCDB/Frustum.cpp index b7d780e5a3b..a49924897ca 100644 --- a/src/xrCDB/Frustum.cpp +++ b/src/xrCDB/Frustum.cpp @@ -82,7 +82,7 @@ u32 frustum_aabb_remap[8][6] = EFC_Visible CFrustum::testSphere(Fvector& c, float r, u32& test_mask) const { u32 bit = 1; - for (unsigned int i = 0; i < p_count; i++, bit <<= 1) + for (u32 i = 0; i < p_count; i++, bit <<= 1) { if (test_mask & bit) { @@ -162,7 +162,7 @@ EFC_Visible CFrustum::testAABB(const float* mM, u32& test_mask) const // go for trivial rejection or acceptance using "faster overlap test" u32 bit = 1; - for (unsigned int i = 0; i < p_count; i++, bit <<= 1) + for (u32 i = 0; i < p_count; i++, bit <<= 1) { if (test_mask & bit) { @@ -182,7 +182,7 @@ EFC_Visible CFrustum::testAABB(const float* mM, u32& test_mask) const EFC_Visible CFrustum::testSAABB(Fvector& c, float r, const float* mM, u32& test_mask) const { u32 bit = 1; - for (unsigned int i = 0; i < p_count; i++, bit <<= 1) + for (u32 i = 0; i < p_count; i++, bit <<= 1) { if (test_mask & bit) { @@ -213,7 +213,7 @@ EFC_Visible CFrustum::testSAABB(Fvector& c, float r, const float* mM, u32& test_ bool CFrustum::testPolyInside_dirty(Fvector* p, size_t count) const { Fvector* e = p + count; - for (unsigned int i = 0; i < p_count; i++) + for (u32 i = 0; i < p_count; i++) { const fplane& P = planes[i]; for (Fvector* I = p; I != e; I++) @@ -384,7 +384,7 @@ sPoly* CFrustum::ClipPoly(sPoly& S, sPoly& D) const { sPoly* src = &D; sPoly* dest = &S; - for (unsigned int i = 0; i < p_count; i++) + for (u32 i = 0; i < p_count; i++) { // cache plane and swap lists const fplane& P = planes[i]; @@ -530,7 +530,7 @@ void CFrustum::CreateFromMatrix(Fmatrix& M, u32 mask) p_count++; } - for (unsigned int i = 0; i < p_count; i++) + for (u32 i = 0; i < p_count; i++) { float denom = 1.0f / planes[i].n.magnitude(); // Get magnitude of Vector planes[i].n.x *= denom; diff --git a/src/xrCDB/xrCDB_Collector.cpp b/src/xrCDB/xrCDB_Collector.cpp index fbeba853d8f..cf4c72dc13b 100644 --- a/src/xrCDB/xrCDB_Collector.cpp +++ b/src/xrCDB/xrCDB_Collector.cpp @@ -305,9 +305,9 @@ CollectorPacked::CollectorPacked(const Fbox& bb, int apx_vertices, int apx_faces flags.reserve(apx_faces); int _size = (clpMX + 1) * (clpMY + 1) * (clpMZ + 1); int _average = (apx_vertices / _size) / 2; - for (unsigned int ix = 0; ix < clpMX + 1; ix++) - for (unsigned int iy = 0; iy < clpMY + 1; iy++) - for (unsigned int iz = 0; iz < clpMZ + 1; iz++) + for (u32 ix = 0; ix < clpMX + 1; ix++) + for (u32 iy = 0; iy < clpMY + 1; iy++) + for (u32 iz = 0; iz < clpMZ + 1; iz++) VM[ix][iy][iz].reserve(_average); } diff --git a/src/xrGame/xrServer.cpp b/src/xrGame/xrServer.cpp index ab180810a53..b915b1d9408 100644 --- a/src/xrGame/xrServer.cpp +++ b/src/xrGame/xrServer.cpp @@ -866,7 +866,7 @@ void xrServer::Server_Client_Check(IClient* CL) return; }; - if (CL->process_id == static_cast(GetCurrentProcessId())) + if (static_cast(CL->process_id) == GetCurrentProcessId()) { CL->flags.bLocal = 1; SV_Client = (xrClientData*)CL; diff --git a/src/xrSound/SoundRender_Core.cpp b/src/xrSound/SoundRender_Core.cpp index a3eee88b376..6c96c0084bb 100644 --- a/src/xrSound/SoundRender_Core.cpp +++ b/src/xrSound/SoundRender_Core.cpp @@ -115,7 +115,7 @@ CSound* CSoundRender_Core::create(pcstr fName, esound_type sound_type, u32 game_ auto* snd = xr_new(handle); snd->g_type = game_type; - if (game_type == static_cast(sg_SourceType)) + if (game_type == sg_SourceType) snd->g_type = snd->handle->game_type(); snd->s_type = sound_type; diff --git a/src/xrSound/SoundRender_Emitter.h b/src/xrSound/SoundRender_Emitter.h index 0c3938f3e04..dde498c0bf3 100644 --- a/src/xrSound/SoundRender_Emitter.h +++ b/src/xrSound/SoundRender_Emitter.h @@ -85,7 +85,7 @@ class CSoundRender_Emitter final : public CSound_emitter std::atomic prefill_task{}; size_t current_block{}; - u32 filled_blocks{}; + int filled_blocks{}; void fill_block(void* ptr, u32 size); void fill_data(void* dest, u32 offset, u32 size) const;