diff --git a/src/Layers/xrRender/AnimationKeyCalculate.h b/src/Layers/xrRender/AnimationKeyCalculate.h index 04dfeb3ccb3..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], 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 (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 (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, 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 (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/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..64baf6ce78d 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,11 +191,11 @@ 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++) + 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 ebf01da9d4f..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 (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 (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/Layers/xrRender/r__dsgraph_build.cpp b/src/Layers/xrRender/r__dsgraph_build.cpp index bc226a5b609..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 (int idx = 0; idx < portals_count; ++idx) + for (u32 idx = 0; idx < portals_count; ++idx) { auto* portal = xr_new(); Portals[idx] = portal; } - for (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 (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 458c6f7d47a..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 (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 (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 (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/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..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 (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 06ee60bae33..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 (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 (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,7 +378,7 @@ void render_sun::flush() if (RImplementation.o.support_rt_arrays) { - for (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) { accumulate_cascade(cascade_ind); } diff --git a/src/xrAICore/Navigation/level_graph.h b/src/xrAICore/Navigation/level_graph.h index b9793c5aca0..7634b3aa6ee 100644 --- a/src/xrAICore/Navigation/level_graph.h +++ b/src/xrAICore/Navigation/level_graph.h @@ -196,7 +196,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..6b6bf13eeec 100644 --- a/src/xrAICore/Navigation/level_graph_inline.h +++ b/src/xrAICore/Navigation/level_graph_inline.h @@ -299,7 +299,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())); diff --git a/src/xrCDB/Frustum.cpp b/src/xrCDB/Frustum.cpp index 23bdbea8946..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 (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 (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 (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 (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 (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 (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 0d83674c681..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 (int ix = 0; ix < clpMX + 1; ix++) - for (int iy = 0; iy < clpMY + 1; iy++) - for (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/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)); 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)); diff --git a/src/xrGame/xrServer.cpp b/src/xrGame/xrServer.cpp index 38f9a71c88d..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 == GetCurrentProcessId()) + if (static_cast(CL->process_id) == GetCurrentProcessId()) { CL->flags.bLocal = 1; SV_Client = (xrClientData*)CL; 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; 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; }