diff --git a/CMakeLists.txt b/CMakeLists.txt index c63516aef..22552aabb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ set(Qt5_x64_DIR ) if(MSVC) - add_compile_options(/we4311) + add_compile_options(/we4311 /DNOMINMAX) add_link_options("/NODEFAULTLIB:\"LIBCMTD\"") endif() diff --git a/OVP/D3D7Client/CSphereMgr.cpp b/OVP/D3D7Client/CSphereMgr.cpp index abb8d4770..ec66e6887 100644 --- a/OVP/D3D7Client/CSphereMgr.cpp +++ b/OVP/D3D7Client/CSphereMgr.cpp @@ -18,7 +18,8 @@ #include "Camera.h" #include "Texture.h" #include "D3D7Config.h" - +#include +using std::min; using namespace oapi; // ======================================================================= @@ -81,7 +82,7 @@ CSphereManager::CSphereManager (const D3D7Client *gclient, const Scene *scene) intensity = (float)tmp; maxlvl = 8; // g_pOrbiter->Cfg()->CSphereMaxLevel; - maxbaselvl = min (8, maxlvl); + maxbaselvl = min ((DWORD)8, maxlvl); int maxidx = patchidx[maxbaselvl]; bPreloadTile = (cfg->PlanetPreloadMode != 0); nhitex = nhispec = 0; diff --git a/OVP/D3D7Client/CelSphere.cpp b/OVP/D3D7Client/CelSphere.cpp index 719e0e90e..77758b9c9 100644 --- a/OVP/D3D7Client/CelSphere.cpp +++ b/OVP/D3D7Client/CelSphere.cpp @@ -19,6 +19,8 @@ #include "Scene.h" #include "Camera.h" #include "Texture.h" +#include +using std::min; #define NSEG 64 // number of segments in celestial grid lines @@ -507,7 +509,7 @@ void D3D7CelestialSphere::RenderStars (LPDIRECT3DDEVICE7 dev) int ns = m_starCutoffIdx[bgidx]; for (i = j = 0; i < ns; i += D3DMAXNUMVERTICES, j++) - dev->DrawPrimitiveVB (D3DPT_POINTLIST, m_sVtx[j], 0, min (ns-i, D3DMAXNUMVERTICES), 0); + dev->DrawPrimitiveVB (D3DPT_POINTLIST, m_sVtx[j], 0, min (ns-i, (DWORD)D3DMAXNUMVERTICES), 0); } // ============================================================== diff --git a/OVP/D3D7Client/CloudMgr.cpp b/OVP/D3D7Client/CloudMgr.cpp index 7863a4201..f26e2ff7a 100644 --- a/OVP/D3D7Client/CloudMgr.cpp +++ b/OVP/D3D7Client/CloudMgr.cpp @@ -17,6 +17,8 @@ #include "CloudMgr.h" #include "VPlanet.h" #include "Texture.h" +#include +using std::min; using namespace oapi; diff --git a/OVP/D3D7Client/D3D7Config.cpp b/OVP/D3D7Client/D3D7Config.cpp index 421118a6e..b2ab168fb 100644 --- a/OVP/D3D7Client/D3D7Config.cpp +++ b/OVP/D3D7Client/D3D7Config.cpp @@ -13,6 +13,9 @@ #include "D3D7Config.h" #include "orbitersdk.h" +#include +using std::min; +using std::max; static const char *cfgfile = "D3D7Client.cfg"; diff --git a/OVP/D3D7Client/D3D7Extra.cpp b/OVP/D3D7Client/D3D7Extra.cpp index 60b3aecbc..b14e304ce 100644 --- a/OVP/D3D7Client/D3D7Extra.cpp +++ b/OVP/D3D7Client/D3D7Extra.cpp @@ -17,6 +17,9 @@ #include "D3D7Extra.h" #include "D3D7Config.h" #include "resource.h" +#include + +using std::min; char *D3D7ClientCfg::Name () { diff --git a/OVP/D3D7Client/HazeMgr.cpp b/OVP/D3D7Client/HazeMgr.cpp index e525db7d4..b4397292e 100644 --- a/OVP/D3D7Client/HazeMgr.cpp +++ b/OVP/D3D7Client/HazeMgr.cpp @@ -17,6 +17,9 @@ #include "HazeMgr.h" #include "VPlanet.h" #include "Texture.h" +#include +using std::min; +using std::max; using namespace oapi; diff --git a/OVP/D3D7Client/Particle.cpp b/OVP/D3D7Client/Particle.cpp index 2391cadd8..dd03333f0 100644 --- a/OVP/D3D7Client/Particle.cpp +++ b/OVP/D3D7Client/Particle.cpp @@ -17,6 +17,10 @@ #include "Camera.h" #include "Texture.h" #include +#include + +using std::min; +using std::max; static bool needsetup = true; static VERTEX_XYZ_TEX evtx[MAXPARTICLE*4]; // vertex list for emissive trail (no normals) @@ -165,7 +169,7 @@ double D3D7ParticleStream::Level2Alpha (double level) const case PARTICLESTREAMSPEC::LVL_SQRT: return sqrt (level); case PARTICLESTREAMSPEC::LVL_PLIN: - return max (0, min (1, (level-lmin)/(lmax-lmin))); + return max (0.0, min (1.0, (level-lmin)/(lmax-lmin))); case PARTICLESTREAMSPEC::LVL_PSQRT: return (level <= lmin ? 0 : level >= lmax ? 1 : sqrt ((level-lmin)/(lmax-lmin))); } @@ -178,9 +182,9 @@ double D3D7ParticleStream::Atm2Alpha (double prm) const case PARTICLESTREAMSPEC::ATM_FLAT: return amin; case PARTICLESTREAMSPEC::ATM_PLIN: - return max (0, min (1, (prm-amin)*afac)); + return max (0.0, min (1.0, (prm-amin)*afac)); case PARTICLESTREAMSPEC::ATM_PLOG: - return max (0, min (1, log(prm/amin)*afac)); + return max (0.0, min (1.0, log(prm/amin)*afac)); } return 0; // should not happen } diff --git a/OVP/D3D7Client/RingMgr.cpp b/OVP/D3D7Client/RingMgr.cpp index e2487a3e4..5ea0363b9 100644 --- a/OVP/D3D7Client/RingMgr.cpp +++ b/OVP/D3D7Client/RingMgr.cpp @@ -14,6 +14,8 @@ #define D3D_OVERLOADS #include "RingMgr.h" #include "Texture.h" +#include +using std::min; using namespace oapi; diff --git a/OVP/D3D7Client/Scene.cpp b/OVP/D3D7Client/Scene.cpp index 0608a068c..bf84755a2 100644 --- a/OVP/D3D7Client/Scene.cpp +++ b/OVP/D3D7Client/Scene.cpp @@ -24,6 +24,8 @@ #include "VVessel.h" #include "VBase.h" #include "Particle.h" +#include +using std::min; using namespace oapi; diff --git a/OVP/D3D7Client/SurfMgr.cpp b/OVP/D3D7Client/SurfMgr.cpp index e6a19e736..08e2a796a 100644 --- a/OVP/D3D7Client/SurfMgr.cpp +++ b/OVP/D3D7Client/SurfMgr.cpp @@ -17,7 +17,9 @@ #include "SurfMgr.h" #include "VPlanet.h" #include "Texture.h" +#include +using std::min; using namespace oapi; int nrender[15]; // temporary diff --git a/OVP/D3D7Client/TileMgr.cpp b/OVP/D3D7Client/TileMgr.cpp index b0bf169b3..24449d4a2 100644 --- a/OVP/D3D7Client/TileMgr.cpp +++ b/OVP/D3D7Client/TileMgr.cpp @@ -18,7 +18,10 @@ #include "VPlanet.h" #include "Texture.h" #include "D3D7Config.h" +#include +using std::min; +using std::max; using namespace oapi; // Max supported patch resolution level diff --git a/OVP/D3D7Client/VBase.cpp b/OVP/D3D7Client/VBase.cpp index 454af3d2f..089fc51ab 100644 --- a/OVP/D3D7Client/VBase.cpp +++ b/OVP/D3D7Client/VBase.cpp @@ -19,6 +19,10 @@ #include "VBase.h" #include "TileMgr.h" #include "D3D7Client.h" +#include + +using std::min; +using std::max; vBase::vBase (OBJHANDLE _hObj, const Scene *scene): vObject (_hObj, scene) { @@ -342,7 +346,7 @@ void vBase::RenderGroundShadow (LPDIRECT3DDEVICE7 dev) DWORD tfactor; bool resetalpha = false; if (gc->UseStencilBuffer()) { - double scale = min (1, (csun-0.07)/0.015); + double scale = min (1.0, (csun-0.07)/0.015); if (scale < 1) { dev->GetRenderState (D3DRENDERSTATE_TEXTUREFACTOR, &tfactor); float modalpha = (float)(scale*RGBA_GETALPHA(tfactor)/256.0); @@ -429,7 +433,7 @@ bool vBase::ModLighting (LPD3DLIGHT7 light, double &nextcheck) double amb0 = min (0.7, log (atm->rho0+1.0)*0.4); amb = amb0 * min (1.0, (sunelev+14.0*RAD)/(20.0*RAD)); if (!lightmod) lightmod = (amb > 0.05); - amb = max (0, amb-0.05); + amb = max (0.0, amb-0.05); // reduce direct light component to avoid overexposure lcol *= 1.0-amb*0.5; } diff --git a/OVP/D3D7Client/VObject.cpp b/OVP/D3D7Client/VObject.cpp index 1dd5b55c3..71301b6de 100644 --- a/OVP/D3D7Client/VObject.cpp +++ b/OVP/D3D7Client/VObject.cpp @@ -32,6 +32,8 @@ #include "D3D7Util.h" #include +using std::min; +using std::max; using namespace oapi; // Initialisation of static members @@ -296,7 +298,7 @@ bool vObject::DrawVector(LPDIRECT3DDEVICE7 dev, const VECTOR3& end, const VECTOR float w = (float)rad; float h = (float)length(end); if (h < EPS) return false; - float hb = max(h - 4.0f * w, 0); + float hb = max(h - 4.0f * w, 0.0f); memcpy(Vtx, Vtx0, nVtx * sizeof(D3DVERTEX)); diff --git a/OVP/D3D7Client/VPlanet.cpp b/OVP/D3D7Client/VPlanet.cpp index 6a8c88c9b..13df847e9 100644 --- a/OVP/D3D7Client/VPlanet.cpp +++ b/OVP/D3D7Client/VPlanet.cpp @@ -29,7 +29,10 @@ #include "CloudMgr.h" #include "HazeMgr.h" #include "RingMgr.h" +#include +using std::min; +using std::max; using namespace oapi; // ============================================================== @@ -49,7 +52,7 @@ vPlanet::vPlanet (OBJHANDLE _hObj, const Scene *scene): vObject (_hObj, scene) max_centre_dist = 0.9*scene->GetCamera()->GetFarlimit(); maxdist = max (max_centre_dist, max_surf_dist + rad); max_patchres = *(DWORD*)oapiGetObjectParam (_hObj, OBJPRM_PLANET_SURFACEMAXLEVEL); - max_patchres = min (max_patchres, *(DWORD*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL)); + max_patchres = min (max_patchres, (int)*(DWORD*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL)); int tilever = *(int*)oapiGetObjectParam (_hObj, OBJPRM_PLANET_TILEENGINE); if (tilever < 2) { surfmgr = new SurfaceManager (gc, this); @@ -109,7 +112,7 @@ vPlanet::vPlanet (OBJHANDLE _hObj, const Scene *scene): vObject (_hObj, scene) } } else { // v2 cloud engine int maxlvl = *(int*)oapiGetObjectParam (_hObj, OBJPRM_PLANET_CLOUDMAXLEVEL); - maxlvl = min (maxlvl, *(DWORD*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL)); + maxlvl = min (maxlvl, (int)*(DWORD*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL)); cloudmgr2 = new TileManager2 (this, maxlvl, 32); } } else { @@ -244,7 +247,7 @@ bool vPlanet::Update () // set microtexture intensity double alt = cdist-rad; double lvl = (clouddata->microalt1-alt)/(clouddata->microalt1-clouddata->microalt0); - clouddata->cloudmgr->SetMicrolevel (max (0, min (1, lvl))); + clouddata->cloudmgr->SetMicrolevel (max (0.0, min (1.0, lvl))); } } @@ -744,12 +747,12 @@ bool vPlanet::ModLighting (DWORD &ambient) double rscale = (size-cdist)/prm.atm_href + 1.0; // effect altitude scale (1 on ground, 0 at reference alt) double amb = prm.atm_amb0 * min (1.0, (sunelev+14.0*RAD)/(20.0*RAD)); // effect magnitude (dependent on sun elevation) if (amb < 0.05) return false; - amb = max (0, amb-0.05); + amb = max (0.0, amb-0.05); DWORD addamb = (DWORD)(amb*rscale*256.0); DWORD newamb = *(DWORD*)gc->GetConfigParam (CFGPRM_AMBIENTLEVEL) + addamb; ambient = 0; for (int i = 0; i < 4; i++) - ambient |= min (255, newamb) << (i<<3); + ambient |= min ((DWORD)255, newamb) << (i<<3); return true; } diff --git a/OVP/D3D7Client/VVessel.cpp b/OVP/D3D7Client/VVessel.cpp index 4fdfd079c..a39428973 100644 --- a/OVP/D3D7Client/VVessel.cpp +++ b/OVP/D3D7Client/VVessel.cpp @@ -14,7 +14,10 @@ #include "VVessel.h" #include "MeshMgr.h" #include "Texture.h" +#include +using std::min; +using std::max; using namespace oapi; // ============================================================== @@ -585,7 +588,7 @@ void vVessel::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, OBJHANDLE hPlanet) DWORD tfactor; bool resetalpha = false; if (gc->UseStencilBuffer()) { - double scale = min (1, (csun-0.07)/0.015); + double scale = min (1.0, (csun-0.07)/0.015); if (scale < 1) { dev->GetRenderState (D3DRENDERSTATE_TEXTUREFACTOR, &tfactor); float modalpha = (float)(scale*RGBA_GETALPHA(tfactor)/256.0); @@ -744,7 +747,7 @@ bool vVessel::ModLighting (LPD3DLIGHT7 light) amb = amb0 / (alt*0.5e-4 + 1.0); amb *= min (1.0, (sunelev+14.0*RAD)/(20.0*RAD)); if (!lightmod) lightmod = (amb > 0.05); - amb = max (0, amb-0.05); + amb = max (0.0, amb-0.05); // reduce direct light component to avoid overexposure lcol *= 1.0-amb*0.5; } diff --git a/OVP/D3D7Client/cloudmgr2.cpp b/OVP/D3D7Client/cloudmgr2.cpp index ec7d8ae62..5d210ecf1 100644 --- a/OVP/D3D7Client/cloudmgr2.cpp +++ b/OVP/D3D7Client/cloudmgr2.cpp @@ -15,6 +15,10 @@ #include "cloudmgr2.h" #include "Texture.h" #include "Camera.h" +#include + +using std::min; +using std::max; // ======================================================================= // ======================================================================= diff --git a/OVP/D3D7Client/surfmgr2.cpp b/OVP/D3D7Client/surfmgr2.cpp index e9e9ceddb..4a29b7956 100644 --- a/OVP/D3D7Client/surfmgr2.cpp +++ b/OVP/D3D7Client/surfmgr2.cpp @@ -18,6 +18,10 @@ #include "tilelabel.h" #include "Texture.h" #include "Camera.h" +#include + +using std::min; +using std::max; // ======================================================================= diff --git a/OVP/D3D7Client/tilelabel.cpp b/OVP/D3D7Client/tilelabel.cpp index 4f6ee128b..9048ad204 100644 --- a/OVP/D3D7Client/tilelabel.cpp +++ b/OVP/D3D7Client/tilelabel.cpp @@ -5,7 +5,10 @@ #include "camera.h" #include #include +#include +using std::min; +using std::max; extern Orbiter *g_pOrbiter; extern Camera *g_camera; diff --git a/OVP/D3D7Client/tilemgr2.cpp b/OVP/D3D7Client/tilemgr2.cpp index 0fbd9ef54..20e2764f6 100644 --- a/OVP/D3D7Client/tilemgr2.cpp +++ b/OVP/D3D7Client/tilemgr2.cpp @@ -16,6 +16,9 @@ #include "Texture.h" #include "Camera.h" #include "D3D7Config.h" +#include + +using std::max; // ======================================================================= // Externals diff --git a/OVP/D3D7Client/tilemgr2_imp.hpp b/OVP/D3D7Client/tilemgr2_imp.hpp index 62770f7d6..7f20d1213 100644 --- a/OVP/D3D7Client/tilemgr2_imp.hpp +++ b/OVP/D3D7Client/tilemgr2_imp.hpp @@ -17,6 +17,7 @@ #include "Camera.h" #include "tilemgr2.h" +#include // ----------------------------------------------------------------------- @@ -129,7 +130,7 @@ void TileManager2Base::ProcessNode (QuadTreeNode *node) tdist = sqrt(a*a + h*h); } double apr = tdist * camera->GetTanAp() * resolutionScale; - int tgtres = (apr < 1e-6 ? prm.maxlvl : max (0, min (prm.maxlvl, (int)(bias - log(apr)*res_scale)))); + int tgtres = (apr < 1e-6 ? prm.maxlvl : std::max (0, std::min (prm.maxlvl, (int)(bias - log(apr)*res_scale)))); bstepdown = (lvl < tgtres); } diff --git a/OVP/D3D9Client/AABBUtil.cpp b/OVP/D3D9Client/AABBUtil.cpp index 218a369fb..e7531ad71 100644 --- a/OVP/D3D9Client/AABBUtil.cpp +++ b/OVP/D3D9Client/AABBUtil.cpp @@ -26,6 +26,8 @@ #include #pragma warning(pop) +using std::min; + // ================================================================================================================================= // bool SolveLUSystem(int n, double *A, double *b, double *x, double *det) diff --git a/OVP/D3D9Client/CSphereMgr.cpp b/OVP/D3D9Client/CSphereMgr.cpp index 62a6d12c8..6f8769e8a 100644 --- a/OVP/D3D9Client/CSphereMgr.cpp +++ b/OVP/D3D9Client/CSphereMgr.cpp @@ -94,7 +94,7 @@ CSphereManager::CSphereManager(D3D9Client *gc, const Scene *scene) : gc(gc), tex intensity = (float)tmp; maxlvl = 8; // g_pOrbiter->Cfg()->CSphereMaxLevel; - maxbaselvl = min (8, maxlvl); + maxbaselvl = min ((DWORD)8, maxlvl); int maxidx = patchidx[maxbaselvl]; bPreloadTile = (Config->PlanetPreloadMode != 0); nhitex = nhispec = 0; diff --git a/OVP/D3D9Client/CelSphere.cpp b/OVP/D3D9Client/CelSphere.cpp index 560172916..805feb1c0 100644 --- a/OVP/D3D9Client/CelSphere.cpp +++ b/OVP/D3D9Client/CelSphere.cpp @@ -22,6 +22,7 @@ #include "D3D9Pad.h" #include "AABBUtil.h" +using std::min; #define NSEG 64 // number of segments in celestial grid lines @@ -130,7 +131,7 @@ void D3D9CelestialSphere::InitStars () DWORD nbuf = (m_nsVtx + maxNumVertices - 1) / maxNumVertices; // number of buffers required m_sVtx.resize(nbuf); for (auto it = m_sVtx.begin(); it != m_sVtx.end(); it++) { - nv = min(maxNumVertices, m_nsVtx - idx); + nv = min((DWORD)maxNumVertices, m_nsVtx - idx); m_pDevice->CreateVertexBuffer(UINT(nv * sizeof(VERTEX_XYZC)), D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &*it, NULL); VERTEX_XYZC* vbuf; (*it)->Lock(0, 0, (LPVOID*)&vbuf, 0); diff --git a/OVP/D3D9Client/D3D9Client.h b/OVP/D3D9Client/D3D9Client.h index 1c1b22b2e..22701215e 100644 --- a/OVP/D3D9Client/D3D9Client.h +++ b/OVP/D3D9Client/D3D9Client.h @@ -36,7 +36,7 @@ #define PP_DEFAULT 0x1 #define PP_LENSFLARE 0x2 -#define MAX_SCENE_LIGHTS 24 +#define MAX_SCENE_LIGHTS (DWORD)24 #define MAX_MESH_LIGHTS 8 // Must match the setting in D3D9Client.fx #ifdef _NVAPI_H diff --git a/OVP/D3D9Client/D3D9Config.cpp b/OVP/D3D9Client/D3D9Config.cpp index 46330dc25..bbdb1f92f 100644 --- a/OVP/D3D9Client/D3D9Config.cpp +++ b/OVP/D3D9Client/D3D9Config.cpp @@ -9,7 +9,10 @@ #include "D3D9Config.h" #include "Orbitersdk.h" -static const char *cfgfile = "D3D9Client.cfg"; +using std::min; +using std::max; + +static const char* cfgfile = "D3D9Client.cfg"; class D3D9Config *Config; // configuration manager diff --git a/OVP/D3D9Client/DebugControls.cpp b/OVP/D3D9Client/DebugControls.cpp index a93c67e63..b487ddd38 100644 --- a/OVP/D3D9Client/DebugControls.cpp +++ b/OVP/D3D9Client/DebugControls.cpp @@ -22,6 +22,8 @@ enum scale { LIN, SQRT, SQR }; using namespace oapi; +using std::min; +using std::max; extern HINSTANCE g_hInst; extern D3D9Client *g_client; @@ -1387,8 +1389,8 @@ void SetColorValue(const char *lbl) // float reduce(float v, float q) { - if (v>0) return max(0, v-q); - else return min(0, v+q); + if (v>0) return max(0.0f, v-q); + else return min(0.0f, v+q); } struct PCParam { diff --git a/OVP/D3D9Client/Particle.cpp b/OVP/D3D9Client/Particle.cpp index a4dd99483..6bc93d18a 100644 --- a/OVP/D3D9Client/Particle.cpp +++ b/OVP/D3D9Client/Particle.cpp @@ -167,7 +167,7 @@ double D3D9ParticleStream::Level2Alpha(double level) const case PARTICLESTREAMSPEC::LVL_FLAT: return lmin; case PARTICLESTREAMSPEC::LVL_LIN: return level; case PARTICLESTREAMSPEC::LVL_SQRT: return sqrt (level); - case PARTICLESTREAMSPEC::LVL_PLIN: return max (0, min (1, (level-lmin)/(lmax-lmin))); + case PARTICLESTREAMSPEC::LVL_PLIN: return max (0.0, min (1.0, (level-lmin)/(lmax-lmin))); case PARTICLESTREAMSPEC::LVL_PSQRT: return (level <= lmin ? 0 : level >= lmax ? 1 : sqrt ((level-lmin)/(lmax-lmin))); } return 0; // should not happen @@ -177,8 +177,8 @@ double D3D9ParticleStream::Atm2Alpha(double prm) const { switch (amap) { case PARTICLESTREAMSPEC::ATM_FLAT: return amin; - case PARTICLESTREAMSPEC::ATM_PLIN: return max (0, min (1, (prm-amin)*afac)); - case PARTICLESTREAMSPEC::ATM_PLOG: return max (0, min (1, log(prm/amin)*afac)); + case PARTICLESTREAMSPEC::ATM_PLIN: return max (0.0, min (1.0, (prm-amin)*afac)); + case PARTICLESTREAMSPEC::ATM_PLOG: return max (0.0, min (1.0, log(prm/amin)*afac)); } return 0; // should not happen } diff --git a/OVP/D3D9Client/RingMgr.cpp b/OVP/D3D9Client/RingMgr.cpp index 230b04f99..6aeec6cd6 100644 --- a/OVP/D3D9Client/RingMgr.cpp +++ b/OVP/D3D9Client/RingMgr.cpp @@ -73,7 +73,7 @@ DWORD RingManager::LoadTextures () const D3DCAPS9 *caps = gc->GetHardwareCaps(); - int size = max(min(caps->MaxTextureWidth, 8192), 2048); + int size = max(min((int)caps->MaxTextureWidth, 8192), 2048); sprintf_s(temp, ARRAYSIZE(temp), "%s_ring_%d.dds", fname, size); if (gc->TexturePath(temp, path) && diff --git a/OVP/D3D9Client/Scene.cpp b/OVP/D3D9Client/Scene.cpp index b8edb212f..54657ea07 100644 --- a/OVP/D3D9Client/Scene.cpp +++ b/OVP/D3D9Client/Scene.cpp @@ -2648,7 +2648,7 @@ bool Scene::RenderBlurredMap(LPDIRECT3DDEVICE9 pDev, LPDIRECT3DCUBETEXTURE9 pSrc D3DSURFACE_DESC desc; pEnvDS->GetDesc(&desc); - DWORD width = min(512, desc.Width); + DWORD width = min((UINT)512, desc.Width); if (!pBlrTemp[0]) { diff --git a/OVP/D3D9Client/Surfmgr2.cpp b/OVP/D3D9Client/Surfmgr2.cpp index 5419fc66e..5056100ac 100644 --- a/OVP/D3D9Client/Surfmgr2.cpp +++ b/OVP/D3D9Client/Surfmgr2.cpp @@ -626,8 +626,8 @@ void SurfTile::ComputeElevationData(const float *elev) const for (j = 0; j <= res; j++) { for (i = 0; i <= res; i++) { ehdr.emean += elev[i]; - ehdr.emax = max(ehdr.emax, elev[i]); - ehdr.emin = min(ehdr.emin, elev[i]); + ehdr.emax = max(ehdr.emax, (double)elev[i]); + ehdr.emin = min(ehdr.emin, (double)elev[i]); } elev += TILE_ELEVSTRIDE; } diff --git a/OVP/D3D9Client/Tilemgr2_imp.hpp b/OVP/D3D9Client/Tilemgr2_imp.hpp index 4853d025c..4ed3e2b97 100644 --- a/OVP/D3D9Client/Tilemgr2_imp.hpp +++ b/OVP/D3D9Client/Tilemgr2_imp.hpp @@ -161,7 +161,7 @@ void TileManager2Base::ProcessNode (QuadTreeNode *node) tdist = (x > 0.0) ? sqrt(x) : 0.0; } - bias -= 2.0 * sqrt(max(0,adist) / prm.viewap); + bias -= 2.0 * sqrt(max(0.0,adist) / prm.viewap); int maxlvl = prm.maxlvl; double apr = tdist * scene->GetTanAp() * resolutionScale; diff --git a/OVP/D3D9Client/VPlanet.cpp b/OVP/D3D9Client/VPlanet.cpp index 693a0ee62..330ee7516 100644 --- a/OVP/D3D9Client/VPlanet.cpp +++ b/OVP/D3D9Client/VPlanet.cpp @@ -789,7 +789,7 @@ bool vPlanet::Update (bool bMainScene) // set microtexture intensity double alt = cdist-size; double lvl = (clouddata->microalt1-alt)/(clouddata->microalt1-clouddata->microalt0); - clouddata->cloudmgr->SetMicrolevel (max (0, min (1, lvl))); + clouddata->cloudmgr->SetMicrolevel (max (0.0, min (1.0, lvl))); } } @@ -852,7 +852,7 @@ void vPlanet::CheckResolution() static const double scal2 = 1.0/log(2.0); const double shift = (surfmgr2 ? 6.0 : 5.0); // reduce level for tile mgr v2, because of increased patch size - new_patchres = min (max ((DWORD)(scal2*log(ntx)-shift),1), max_patchres); + new_patchres = min (max ((DWORD)(scal2*log(ntx)-shift),(DWORD)1), max_patchres); } if (new_patchres != patchres) { if (hashaze) { @@ -1241,13 +1241,13 @@ bool vPlanet::ModLighting (DWORD &ambient) double rscale = (size-cdist)/prm.atm_href + 1.0; // effect altitude scale (1 on ground, 0 at reference alt) double amb = prm.atm_amb0 * min (1.0, (sunelev+14.0*RAD)/(20.0*RAD)); // effect magnitude (dependent on sun elevation) if (amb < 0.05) return false; - amb = max (0, amb-0.05); + amb = max (0.0, amb-0.05); DWORD addamb = (DWORD)(amb*rscale*256.0); DWORD newamb = *(DWORD*)gc->GetConfigParam (CFGPRM_AMBIENTLEVEL) + addamb; ambient = 0; for (int i = 0; i < 4; i++) - ambient |= min (255, newamb) << (i<<3); + ambient |= min ((DWORD)255, newamb) << (i<<3); return true; } diff --git a/OVP/D3D9Client/VPlanetAtmo.cpp b/OVP/D3D9Client/VPlanetAtmo.cpp index daa37e727..711b0b084 100644 --- a/OVP/D3D9Client/VPlanetAtmo.cpp +++ b/OVP/D3D9Client/VPlanetAtmo.cpp @@ -583,7 +583,7 @@ void vPlanet::UpdateScatter() float ph = atmo->mphase * 200.0f; float g = ph / sqrt(1.0f + ph * ph); - float hrz = sqrt(max(0, cr * cr - pr * pr)); + float hrz = sqrt(max(0.0, cr * cr - pr * pr)); float qw = float(pr / cr); LPDIRECT3DSURFACE9 pTgt, pTgt2; @@ -673,7 +673,7 @@ void vPlanet::UpdateScatter() if (cp.CamAlt < prm.cloudalt) { float SMi = cp.CloudAlt; - float SMa = min(100e3, cp.HrzDst); // Semi-major axis + float SMa = min(100e3f, cp.HrzDst); // Semi-major axis cp.ecc = sqrt((SMa * SMa - SMi * SMi) / (SMa * SMa)); // eccentricity cp.smi = SMi; } @@ -1287,7 +1287,7 @@ void vPlanet::TestComputations(Sketchpad* pSkp) if (bSrc) { // Camera in Shadow s0 = max(sp.sx, sp.ae); - float lf = max(0, sp.ca) / max(1.0f, abs(sp.hd)); // Lerp Factor + float lf = max(0.0f, sp.ca) / max(1.0f, abs(sp.hd)); // Lerp Factor float mp = lerp((sp.ax + s0) * 0.5f, sp.hd, saturate(lf)); e0 = mp; @@ -1295,9 +1295,9 @@ void vPlanet::TestComputations(Sketchpad* pSkp) e1 = sp.ax; } else { // Camera is Lit - s0 = max(0, sp.ae); + s0 = max(0.0f, sp.ae); - float lf = max(0, sp.ca) / max(1.0f, abs(sp.hd)); // Lerp Factor + float lf = max(0.0f, sp.ca) / max(1.0f, abs(sp.hd)); // Lerp Factor float mp = lerp((sp.ax + s0) * 0.5f, sp.hd, saturate(lf)); bool bA = (sp.se > sp.ax || sp.se < 0); diff --git a/OVP/D3D9Client/VVessel.cpp b/OVP/D3D9Client/VVessel.cpp index 25361aa44..86dd4c4d4 100644 --- a/OVP/D3D9Client/VVessel.cpp +++ b/OVP/D3D9Client/VVessel.cpp @@ -1703,7 +1703,7 @@ void vVessel::RenderReentry(LPDIRECT3DDEVICE9 dev) float lim = 100000000.0; float www = float(p*v*v*v); - float ints = max(0,(www-lim)) / (5.0f*lim); + float ints = max(0.0f,(www-lim)) / (5.0f*lim); if (ints>1.0f) ints = 1.0f; if (ints<0.01f) return; diff --git a/OVP/D3D9Client/VectorHelpers.h b/OVP/D3D9Client/VectorHelpers.h index a6a73f785..843084014 100644 --- a/OVP/D3D9Client/VectorHelpers.h +++ b/OVP/D3D9Client/VectorHelpers.h @@ -145,12 +145,12 @@ inline VECTOR3 rcp(const VECTOR3 &v) inline VECTOR3 vmax(const VECTOR3 &v, const VECTOR3 &w) { - return _V(max(v.x, w.x), max(v.y, w.y), max(v.z, w.z)); + return _V(std::max(v.x, w.x), std::max(v.y, w.y), std::max(v.z, w.z)); } inline VECTOR3 vmin(const VECTOR3 &v, const VECTOR3 &w) { - return _V(min(v.x, w.x), min(v.y, w.y), min(v.z, w.z)); + return _V(std::min(v.x, w.x), std::min(v.y, w.y), std::min(v.z, w.z)); } @@ -233,12 +233,12 @@ inline VECTOR4 rcp(const VECTOR4 &v) inline VECTOR4 vmax(const VECTOR4 &v, const VECTOR4 &w) { - return _V(max(v.x, w.x), max(v.y, w.y), max(v.z, w.z), max(v.w, w.w)); + return _V(std::max(v.x, w.x), std::max(v.y, w.y), std::max(v.z, w.z), std::max(v.w, w.w)); } inline VECTOR4 vmin(const VECTOR4 &v, const VECTOR4 &w) { - return _V(min(v.x, w.x), min(v.y, w.y), min(v.z, w.z), min(v.w, w.w)); + return _V(std::min(v.x, w.x), std::min(v.y, w.y), std::min(v.z, w.z), std::min(v.w, w.w)); } @@ -290,12 +290,12 @@ inline D3DXVECTOR3 rcp(const D3DXVECTOR3 &v) inline D3DXVECTOR3 vmax(const D3DXVECTOR3 &v, const D3DXVECTOR3 &w) { - return D3DXVECTOR3(max(v.x, w.x), max(v.y, w.y), max(v.z, w.z)); + return D3DXVECTOR3(std::max(v.x, w.x), std::max(v.y, w.y), std::max(v.z, w.z)); } inline D3DXVECTOR3 vmin(const D3DXVECTOR3 &v, const D3DXVECTOR3 &w) { - return D3DXVECTOR3(min(v.x, w.x), min(v.y, w.y), min(v.z, w.z)); + return D3DXVECTOR3(std::min(v.x, w.x), std::min(v.y, w.y), std::min(v.z, w.z)); } inline D3DXVECTOR3 lerp(const D3DXVECTOR3 &v, const D3DXVECTOR3 &w, float x) diff --git a/OVP/D3D9Client/samples/DX9ExtMFD/MFDWindow.cpp b/OVP/D3D9Client/samples/DX9ExtMFD/MFDWindow.cpp index 66c530a75..77e2b4e48 100644 --- a/OVP/D3D9Client/samples/DX9ExtMFD/MFDWindow.cpp +++ b/OVP/D3D9Client/samples/DX9ExtMFD/MFDWindow.cpp @@ -7,6 +7,9 @@ #include "resource.h" #include // temporary +using std::min; +using std::max; + #define IDSTICK 999 // ============================================================== diff --git a/OVP/D3D9Client/samples/GenericCamera/MFD.cpp b/OVP/D3D9Client/samples/GenericCamera/MFD.cpp index e82da5702..f90b46446 100644 --- a/OVP/D3D9Client/samples/GenericCamera/MFD.cpp +++ b/OVP/D3D9Client/samples/GenericCamera/MFD.cpp @@ -13,6 +13,7 @@ #include "Shell.h" #include "DrawAPI.h" +using std::min; #define ENABLE_OVERLAY false diff --git a/OVP/D3D9Client/samples/TerrainToolBox/ToolBox.cpp b/OVP/D3D9Client/samples/TerrainToolBox/ToolBox.cpp index 6a848c273..a4acf364f 100644 --- a/OVP/D3D9Client/samples/TerrainToolBox/ToolBox.cpp +++ b/OVP/D3D9Client/samples/TerrainToolBox/ToolBox.cpp @@ -632,9 +632,9 @@ void ToolKit::clbkRender() selw = abs(alng - blng) + 1; selh = abs(alat - blat) + 1; - int max = sp.MaxTexSize / 512; - if (selw > max) selw = max; - if (selh > max) selh = max; + int maxts = sp.MaxTexSize / 512; + if (selw > maxts) selw = maxts; + if (selh > maxts) selh = maxts; double width = pFirst->Width(); double height = pFirst->Height(); diff --git a/Orbitersdk/include/DrawAPI.h b/Orbitersdk/include/DrawAPI.h index e8f73a9ff..bbda13013 100644 --- a/Orbitersdk/include/DrawAPI.h +++ b/Orbitersdk/include/DrawAPI.h @@ -226,12 +226,12 @@ namespace oapi { #endif float MaxRGB() const { - return max(max(r, g), b); + return std::max( r, std::max(g, b)); } float MinRGB() const { - return min(min(r, g), b); + return std::min( r, std::min(g, b)); } float sql() const @@ -359,10 +359,10 @@ namespace oapi { { DWORD dword_abgr() const { - DWORD dr = DWORD(max(0, r) * 255.0f + 0.5f); - DWORD dg = DWORD(max(0, g) * 255.0f + 0.5f); - DWORD db = DWORD(max(0, b) * 255.0f + 0.5f); - DWORD da = DWORD(max(0, a) * 255.0f + 0.5f); + DWORD dr = DWORD(std::max(0.0f, r) * 255.0f + 0.5f); + DWORD dg = DWORD(std::max(0.0f, g) * 255.0f + 0.5f); + DWORD db = DWORD(std::max(0.0f, b) * 255.0f + 0.5f); + DWORD da = DWORD(std::max(0.0f, a) * 255.0f + 0.5f); if (dr > 0xFF) dr = 0xFF; if (dg > 0xFF) dg = 0xFF; if (db > 0xFF) db = 0xFF; @@ -372,10 +372,10 @@ namespace oapi { DWORD dword_argb() const { - DWORD dr = DWORD(max(0, r) * 255.0f + 0.5f); - DWORD dg = DWORD(max(0, g) * 255.0f + 0.5f); - DWORD db = DWORD(max(0, b) * 255.0f + 0.5f); - DWORD da = DWORD(max(0, a) * 255.0f + 0.5f); + DWORD dr = DWORD(std::max(0.0f, r) * 255.0f + 0.5f); + DWORD dg = DWORD(std::max(0.0f, g) * 255.0f + 0.5f); + DWORD db = DWORD(std::max(0.0f, b) * 255.0f + 0.5f); + DWORD da = DWORD(std::max(0.0f, a) * 255.0f + 0.5f); if (dr > 0xFF) dr = 0xFF; if (dg > 0xFF) dg = 0xFF; if (db > 0xFF) db = 0xFF; @@ -391,7 +391,7 @@ namespace oapi { float MaxRGB() const { - return max(max(r, g), b); + return std::max( r, std::max(g, b)); } FVECTOR4() @@ -765,7 +765,11 @@ namespace oapi { inline float saturate(float x) { - return min(1, max(0, x)); + //sadly std::clamp produces garbage assembly on both gcc and MSVC + //this version makes MSVC produce good code + x = (x < 0.0f) ? 0.0f : x; + x = (x > 1.0f) ? 1.0f : x; + return x; } inline FVECTOR3 saturate(const FVECTOR3& v) diff --git a/Orbitersdk/include/VesselAPI.h b/Orbitersdk/include/VesselAPI.h index 6f45df146..ddb74bf05 100644 --- a/Orbitersdk/include/VesselAPI.h +++ b/Orbitersdk/include/VesselAPI.h @@ -6377,9 +6377,9 @@ class AnimState { bool Move (double dp) { if (!Moving()) return false; if (Closing()) { - if ((pos = max (0.0, pos-dp)) == 0.0) action = CLOSED; + if ((pos = std::max (0.0, pos-dp)) == 0.0) action = CLOSED; } else { - if ((pos = min (1.0, pos+dp)) == 1.0) action = OPEN; + if ((pos = std::min (1.0, pos+dp)) == 1.0) action = OPEN; } return true; } diff --git a/Sound/XRSound/src/SoundPreSteps.cpp b/Sound/XRSound/src/SoundPreSteps.cpp index 56dac55c9..4d5973b99 100644 --- a/Sound/XRSound/src/SoundPreSteps.cpp +++ b/Sound/XRSound/src/SoundPreSteps.cpp @@ -545,7 +545,7 @@ void AFCtrlModeDefaultSoundPreStep::clbkPreStep(const double simt, const double // - bit 0: elevator enabled/disabled // - bit 1: rudder enabled / disabled // - bit 2: ailerons enabled / disabled - const int afCtrlMode = min(pVessel->GetADCtrlMode(), 2); // 0 = OFF, 1 = PITCH (elevators), 2 = ON (more than just pitch) + const int afCtrlMode = min(pVessel->GetADCtrlMode(), (DWORD)2); // 0 = OFF, 1 = PITCH (elevators), 2 = ON (more than just pitch) if (m_previousAFCtrlMode < 0) { diff --git a/Sound/XRSound/src/VesselXRSoundEngine.cpp b/Sound/XRSound/src/VesselXRSoundEngine.cpp index 9dbdbbc91..cba955644 100644 --- a/Sound/XRSound/src/VesselXRSoundEngine.cpp +++ b/Sound/XRSound/src/VesselXRSoundEngine.cpp @@ -515,7 +515,7 @@ double VesselXRSoundEngine::GetGearAdjustedAltitude() } } - return max(altitude, 0); + return max(altitude, 0.0); } // Returns animation (door) state of this vessel's landing gear (0..1), or -1 if none is defined or data is unavailable diff --git a/Src/DlgCtrl/DlgCtrl.cpp b/Src/DlgCtrl/DlgCtrl.cpp index e92a178a9..a5dcf0a96 100644 --- a/Src/DlgCtrl/DlgCtrl.cpp +++ b/Src/DlgCtrl/DlgCtrl.cpp @@ -4,7 +4,10 @@ #include "DlgCtrl.h" #include "DlgCtrlLocal.h" #include +#include +using std::min; +using std::max; GDIRES g_GDI; @@ -170,7 +173,7 @@ LRESULT FAR PASCAL MsgProc_Gauge (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP } else { int rmin = GetWindowLongPtr (hWnd, WINOFS_RMIN); int rmax = GetWindowLongPtr (hWnd, WINOFS_RMAX); - g_timer = SetTimer (hWnd, 1, min(1000,max(1,3000/(rmax-rmin))), NULL); + g_timer = SetTimer (hWnd, 1, min(1000, max(1,3000/(rmax-rmin))), NULL); PostMessage (hWnd, WM_TIMER, 1, 0); } } return 0; diff --git a/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp b/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp index 5be81a08b..d8b7a1efb 100644 --- a/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp +++ b/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp @@ -9,6 +9,9 @@ #include "DrawAPI.h" #include +using std::min; +using std::max; + /*** Module oapi: General Orbiter API interface functions @module oapi diff --git a/Src/Orbiter/CSphereMgr.cpp b/Src/Orbiter/CSphereMgr.cpp index 1c7eefa48..499e168ae 100644 --- a/Src/Orbiter/CSphereMgr.cpp +++ b/Src/Orbiter/CSphereMgr.cpp @@ -16,6 +16,8 @@ #include "Camera.h" #include "Log.h" #include "OGraphics.h" +#include +using std::min; // ======================================================================= // Externals @@ -64,7 +66,7 @@ CSphereManager::CSphereManager () intensity = (float)g_pOrbiter->Cfg()->CfgVisualPrm.CSphereBgIntens; maxlvl = 8; // g_pOrbiter->Cfg()->CSphereMaxLevel; - maxbaselvl = min (8, maxlvl); + maxbaselvl = min ((DWORD)8, maxlvl); int maxidx = patchidx[maxbaselvl]; bPreloadTile = (g_pOrbiter->Cfg()->CfgPRenderPrm.PreloadMode > 0); nhitex = nhispec = 0; @@ -264,7 +266,7 @@ void CSphereManager::Render(LPDIRECT3DDEVICE7 dev, int level, double bglvl) if (bgscale < 1e-3 || (intens < 1e-3 && !m_bStarImg)) return; // sanity check - level = min(level, maxlvl); + level = min(level, (int)maxlvl); RenderParam.dev = dev; RenderParam.tgtlvl = level; diff --git a/Src/Orbiter/Camera.cpp b/Src/Orbiter/Camera.cpp index 327bc84e6..197a1b8f9 100644 --- a/Src/Orbiter/Camera.cpp +++ b/Src/Orbiter/Camera.cpp @@ -737,7 +737,7 @@ double Camera::GroundElevation (const Planet *ref, double lng, double lat, doubl double elev = 0.0; ElevationManager *emgr = ref->ElevMgr(); if (emgr) { - int reslvl = (int)(32.0-log(max(go.alt,100))*LOG2); + int reslvl = (int)(32.0-log(max(go.alt,100.0))*LOG2); elev = emgr->Elevation (lat, lng, reslvl, &etile); } return elev; @@ -832,7 +832,7 @@ void Camera::GroundObserverShift (double dx, double dz, double dh) Vector dsz (grot.m13, grot.m23, grot.m33); // dz: go forward/backward w.r.t. camera view direction Vector dsx (grot.m11, grot.m21, grot.m31); // dx: go sideways w.r.t. camera view direction dirref->GlobalToEquatorial (gpos + dsz*dz + dsx*dx, go.lng, go.lat, r); - double new_alt = max (1, go.alt+dh); + double new_alt = max (1.0, go.alt+dh); go.alt0 += new_alt-go.alt; go.alt = new_alt; double clng = cos(go.lng), slng = sin(go.lng); diff --git a/Src/Orbiter/CelSphere.cpp b/Src/Orbiter/CelSphere.cpp index 1ce7d513b..fe5e3f891 100644 --- a/Src/Orbiter/CelSphere.cpp +++ b/Src/Orbiter/CelSphere.cpp @@ -10,6 +10,9 @@ #include "D3dmath.h" #include "OrbiterAPI.h" #include "Log.h" +#include +using std::min; +using std::max; #define NSEG 64 @@ -39,7 +42,7 @@ OGCelestialSphere::OGCelestialSphere(OrbiterGraphics* gc, Scene* scene) m_viewW = gc->GetViewW(); m_viewH = gc->GetViewH(); m_mjdPrecessionChecked = -1e10; - DWORD fontScale = max(m_viewH / 60, 14); + DWORD fontScale = max(m_viewH / 60, (DWORD)14); m_cLabelFont = gc->clbkCreateFont(fontScale, true, "Arial", FONT_ITALIC); char cpath[256]; @@ -553,7 +556,7 @@ void OGCelestialSphere::RenderStars(LPDIRECT3DDEVICE7 dev) int ns = m_starCutoffIdx[bgidx]; for (i = j = 0; i < ns; i += D3DMAXNUMVERTICES, j++) - dev->DrawPrimitiveVB(D3DPT_POINTLIST, m_sVtx[j], 0, min(ns - i, D3DMAXNUMVERTICES), 0); + dev->DrawPrimitiveVB(D3DPT_POINTLIST, m_sVtx[j], 0, min(ns - i, (DWORD)D3DMAXNUMVERTICES), 0); } diff --git a/Src/Orbiter/CelSphereAPI.cpp b/Src/Orbiter/CelSphereAPI.cpp index 9b41a2f4c..c5b42c45e 100644 --- a/Src/Orbiter/CelSphereAPI.cpp +++ b/Src/Orbiter/CelSphereAPI.cpp @@ -10,6 +10,9 @@ #include "Mesh.h" #include "Log.h" +using std::min; +using std::max; + extern Orbiter* g_pOrbiter; extern PlanetarySystem* g_psys; @@ -19,8 +22,8 @@ oapi::CelestialSphere::CelestialSphere(oapi::GraphicsClient* gc) : m_gc(gc) { gc->clbkGetViewportSize(&m_viewW, &m_viewH); - m_cLabelFont = gc->clbkCreateFont(max(m_viewH / 50, 14), true, "Arial", FONT_ITALIC); - m_markerFont = gc->clbkCreateFont(max(m_viewH / 75, 12), true, "Arial"); + m_cLabelFont = gc->clbkCreateFont(max((int)m_viewH / 50, 14), true, "Arial", FONT_ITALIC); + m_markerFont = gc->clbkCreateFont(max((int)m_viewH / 75, 12), true, "Arial"); for (int i = 0; i < 7; i++) m_markerPen[i] = gc->clbkCreatePen(1, 0, MarkerColor(i)); m_textBlendAdditive = false; diff --git a/Src/Orbiter/Config.cpp b/Src/Orbiter/Config.cpp index 1f9b1a35e..a9218226d 100644 --- a/Src/Orbiter/Config.cpp +++ b/Src/Orbiter/Config.cpp @@ -554,7 +554,7 @@ bool Config::Load(const char *fname) if (GetReal (ifs, "PlanetResolutionBias", d)) CfgPRenderPrm.ResolutionBias = max (-2.0, min (2.0, d)); if (GetInt (ifs, "TileLoadFlags", i)) - CfgPRenderPrm.TileLoadFlags = max (min((DWORD)i, 3), 1); + CfgPRenderPrm.TileLoadFlags = max (min(i, 3), 1); // map dialog parameters if (GetInt (ifs, "MapDlgFlag", i)) @@ -642,7 +642,7 @@ bool Config::Load(const char *fname) if (GetInt (ifs, "PlanetMaxPatchLevel", i)) CfgVisualPrm.PlanetMaxLevel = max (1, min (SURF_MAX_PATCHLEVEL2, i)); if (GetReal (ifs, "PlanetPatchRes", d)) - CfgVisualPrm.PlanetPatchRes = max (0.1, min (10, d)); + CfgVisualPrm.PlanetPatchRes = max (0.1, min (10.0, d)); if (GetReal (ifs, "NightlightBrightness", d)) CfgVisualPrm.LightBrightness = max (0.0, min (1.0, d)); if (GetInt (ifs, "ElevationMode", i) && i >= 0 && i <= 1) diff --git a/Src/Orbiter/Config.h b/Src/Orbiter/Config.h index 1f67c209c..bc1a2f22c 100644 --- a/Src/Orbiter/Config.h +++ b/Src/Orbiter/Config.h @@ -425,7 +425,7 @@ class Config { void DelActiveModule (const std::string& name); inline void SetAmbientLevel (DWORD lvl) - { AmbientColour = (CfgVisualPrm.AmbientLevel = min (lvl, 0xff)) * 0x01010101; } + { AmbientColour = (CfgVisualPrm.AmbientLevel = std::min (lvl, (DWORD)0xff)) * 0x01010101; } const void *GetParam (DWORD paramtype) const; // return a specific parameter setting (paramtype defined in GraphicsAPI.h) diff --git a/Src/Orbiter/CustomControls.cpp b/Src/Orbiter/CustomControls.cpp index aab57b4de..098aec8a9 100644 --- a/Src/Orbiter/CustomControls.cpp +++ b/Src/Orbiter/CustomControls.cpp @@ -5,6 +5,9 @@ #include "CustomControls.h" #include "Util.h" +using std::min; +using std::max; + // =========================================================================== CustomCtrl::CustomCtrl () @@ -104,7 +107,7 @@ void SplitterCtrl::SetHwnd (HWND hCtrl, HWND hPane1, HWND hPane2) GetClientRect (hCtrl, &r); totalW = r.right; GetClientRect (hPane1, &r); - paneW[0] = min (r.right, totalW-splitterW-4); + paneW[0] = min ((int)r.right, totalW-splitterW-4); paneW[1] = totalW-splitterW-paneW[0]; widthRatio = (double)paneW[0]/(double)(totalW-splitterW); Refresh(); diff --git a/Src/Orbiter/Defpanel.cpp b/Src/Orbiter/Defpanel.cpp index 6d85728da..e677ae256 100644 --- a/Src/Orbiter/Defpanel.cpp +++ b/Src/Orbiter/Defpanel.cpp @@ -6,6 +6,9 @@ #include "Util.h" #include "Vessel.h" +using std::min; +using std::max; + extern Orbiter *g_pOrbiter; extern Vessel *g_focusobj; extern char DBG_MSG[256]; @@ -508,18 +511,18 @@ void DefaultPanel::Render () vofs += 4; if (upd_fuel) { cb = FmtNum (ts ? fuel*ts->maxmass : 0.0); - NumOut (cb, engstat_str[0], min(strlen(cb),5), grp->Vtx+vofs); + NumOut (cb, engstat_str[0], min(strlen(cb),(size_t)5), grp->Vtx+vofs); } // Update main engine readout vofs += 4*5; th = (engmain >= 0.0 ? engmain*g_focusobj->GetThrusterGroupMaxth(THGROUP_MAIN) : -engmain*g_focusobj->GetThrusterGroupMaxth(THGROUP_RETRO)); cb = FmtNum (th); - NumOut (cb, engstat_str[1], min(strlen(cb),5), grp->Vtx+vofs); + NumOut (cb, engstat_str[1], min(strlen(cb),(size_t)5), grp->Vtx+vofs); // Update hover engine readout vofs += 4*5; cb = FmtNum (enghovr*g_focusobj->GetThrusterGroupMaxth(THGROUP_HOVER)); - NumOut (cb, engstat_str[2], min(strlen(cb),5), grp->Vtx+vofs); + NumOut (cb, engstat_str[2], min(strlen(cb),(size_t)5), grp->Vtx+vofs); // Update trim indicator and readout vofs += 4*5; if (g_focusobj->bElevTrim) { @@ -529,7 +532,7 @@ void DefaultPanel::Render () grp->Vtx[vofs+j].y = dy + (95.0f + 5.0f*(j/2) - (float)trim*14.5f)*scale; char cbuf[16]; sprintf (cbuf, "%3.1f", fabs(trim)); - NumOut (cbuf, engstat_str[3], min(strlen(cbuf),3), grp->Vtx+vofs+4); + NumOut (cbuf, engstat_str[3], min(strlen(cbuf),(size_t)3), grp->Vtx+vofs+4); float ofs = (fabs(trim) < 0.01 ? 0.0f : trim < 0 ? 15.0f : 31.0f); for (j = 0; j < 4; j++) grp->Vtx[vofs+16+j].tu = (314.0f+ofs+14.0f*(j%2))/texw; diff --git a/Src/Orbiter/DlgCamera.cpp b/Src/Orbiter/DlgCamera.cpp index b6bf34197..8a92d0b53 100644 --- a/Src/Orbiter/DlgCamera.cpp +++ b/Src/Orbiter/DlgCamera.cpp @@ -17,6 +17,9 @@ #include "Uxtheme.h" #include "DlgCtrl.h" +using std::min; +using std::max; + extern Orbiter *g_pOrbiter; extern PlanetarySystem *g_psys; extern Camera *g_camera; diff --git a/Src/Orbiter/DlgMap.cpp b/Src/Orbiter/DlgMap.cpp index b2c365b8f..e8b946e3e 100644 --- a/Src/Orbiter/DlgMap.cpp +++ b/Src/Orbiter/DlgMap.cpp @@ -18,6 +18,9 @@ #include "Pane.h" #include "Util.h" +using std::min; +using std::max; + extern Orbiter *g_pOrbiter; extern TimeData td; extern Vessel *g_focusobj; diff --git a/Src/Orbiter/ExtraRender.cpp b/Src/Orbiter/ExtraRender.cpp index 47b2db865..6c71d0605 100644 --- a/Src/Orbiter/ExtraRender.cpp +++ b/Src/Orbiter/ExtraRender.cpp @@ -11,6 +11,8 @@ #include "ExtraRender.h" #include "Help.h" #include "resource.h" +#include +using std::min; //============================================================================= diff --git a/Src/Orbiter/GraphicsAPI.cpp b/Src/Orbiter/GraphicsAPI.cpp index 6ebaff809..8fd818197 100644 --- a/Src/Orbiter/GraphicsAPI.cpp +++ b/Src/Orbiter/GraphicsAPI.cpp @@ -19,6 +19,8 @@ #include #include +using std::min; + extern Orbiter *g_pOrbiter; extern PlanetarySystem *g_psys; extern Pane *g_pane; diff --git a/Src/Orbiter/Launchpad.cpp b/Src/Orbiter/Launchpad.cpp index 7b740b237..b5bbbcd93 100644 --- a/Src/Orbiter/Launchpad.cpp +++ b/Src/Orbiter/Launchpad.cpp @@ -106,8 +106,8 @@ bool orbiter::LaunchpadDialog::Create (bool startvideotab) RECT dr, lr = pCfg->rLaunchpad; int x = lr.left, y = lr.top, w = lr.right-lr.left, h = lr.bottom-lr.top; GetWindowRect (GetDesktopWindow(), &dr); - x = min (max (x, dr.left), dr.right-w); - y = min (max (y, dr.top), dr.bottom-h); + x = min (max ((LONG)x, dr.left), dr.right-w); + y = min (max ((LONG)y, dr.top), dr.bottom-h); SetWindowPos (hDlg, 0, x, y, w, h, 0); } SetWindowText (GetDlgItem (hDlg, IDC_BLACKBOX), SIG4 " \n" SIG2 " \n" SIG1AA " \n" SIG1AB " "); @@ -249,7 +249,7 @@ BOOL orbiter::LaunchpadDialog::Resize (HWND hWnd, DWORD w, DWORD h, DWORD mode) 0, 0, w, shadowh, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); w4 = r_exit0.right - r_data0.left + dw; - h4 = max (10, r_data0.bottom - r_data0.top + dh); + h4 = max ((LONG)10, r_data0.bottom - r_data0.top + dh); SetWindowPos (GetDlgItem (hWnd, IDLAUNCH), NULL, xb1, r_launch0.top+dh, wb1, bh, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER|SWP_NOCOPYBITS); @@ -260,7 +260,7 @@ BOOL orbiter::LaunchpadDialog::Resize (HWND hWnd, DWORD w, DWORD h, DWORD mode) xb3, r_exit0.top+dh, wb3, bh, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER|SWP_NOCOPYBITS); SetWindowPos (hWait, NULL, - (w-(r_wait0.right-r_wait0.left))/2, max (r_wait0.top, r_wait0.top+(h-r_wait0.bottom)/2), 0, 0, + (w-(r_wait0.right-r_wait0.left))/2, max (r_wait0.top, r_wait0.top+((LONG)h-r_wait0.bottom)/2), 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOOWNERZORDER|SWP_NOZORDER); SetWindowPos (GetDlgItem (hWnd, IDC_VERSION), NULL, r_version0.left, r_version0.top+dh, 0, 0, diff --git a/Src/Orbiter/LpadTab.cpp b/Src/Orbiter/LpadTab.cpp index fa8988274..7da06ff0e 100644 --- a/Src/Orbiter/LpadTab.cpp +++ b/Src/Orbiter/LpadTab.cpp @@ -14,6 +14,8 @@ #include "Help.h" #include "resource.h" +using std::max; + //----------------------------------------------------------------------------- // LaunchpadTab base class @@ -75,8 +77,8 @@ void orbiter::LaunchpadTab::TabAreaResized(int w, int h) else { RECT r; GetClientRect(hTab, &r); - int x0 = max(0, (w - r.right) / 2); - int y0 = max(0, (h - r.bottom) / 2); + int x0 = max((LONG)0, (w - r.right) / 2); + int y0 = max((LONG)0, (h - r.bottom) / 2); SetWindowPos(hTab, NULL, x0, y0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER); } diff --git a/Src/Orbiter/MenuInfoBar.cpp b/Src/Orbiter/MenuInfoBar.cpp index 2a6f17914..34f298d3b 100644 --- a/Src/Orbiter/MenuInfoBar.cpp +++ b/Src/Orbiter/MenuInfoBar.cpp @@ -11,6 +11,9 @@ #include "Log.h" #include "GraphicsAPI.h" +using std::min; +using std::max; + // ======================================================================= // Externs diff --git a/Src/Orbiter/Mfd.cpp b/Src/Orbiter/Mfd.cpp index 86bd3ced9..107b69bf6 100644 --- a/Src/Orbiter/Mfd.cpp +++ b/Src/Orbiter/Mfd.cpp @@ -103,7 +103,7 @@ Instrument *Instrument::Create (ifstream &ifs, Pane *_pane, Instrument *instr = 0; char header[64], cbuf[256], *pc; strcpy (header, "BEGIN_MFD "); - strcat (header, mfdstr[min(MAXMFD-1,_id)]); + strcat (header, mfdstr[min((ptrdiff_t)(MAXMFD-1),(ptrdiff_t)_id)]); if (!FindLine (ifs, header)) return 0; for (;instr == 0;) { diff --git a/Src/Orbiter/MfdAlign.cpp b/Src/Orbiter/MfdAlign.cpp index c74698b5b..d99a2a3d5 100644 --- a/Src/Orbiter/MfdAlign.cpp +++ b/Src/Orbiter/MfdAlign.cpp @@ -153,7 +153,7 @@ void Instrument_OPlaneAlign::UpdateDraw (oapi::Sketchpad *skp) DisplayTitle (skp, "Align plane"); const char *modestr[3] = { "Orbit ", "Ballist", "Surface" }; if (elref) { - skp->Text (cw*17, 1, elref->Name(), min (16, strlen(elref->Name()))); + skp->Text (cw*17, 1, elref->Name(), min ((size_t)16, strlen(elref->Name()))); strcpy (cbuf, tgt ? tgt->Name() : customel ? "[Custom]" : "[None]"); skp->Text (cw*17, 1+ch, cbuf, strlen (cbuf)); skp->Text(cw * 5, 1 + ch, modestr[mode], 7); diff --git a/Src/Orbiter/MfdHsi.cpp b/Src/Orbiter/MfdHsi.cpp index 75d11859b..793df16ec 100644 --- a/Src/Orbiter/MfdHsi.cpp +++ b/Src/Orbiter/MfdHsi.cpp @@ -178,12 +178,12 @@ void Instrument_HSI::UpdateDraw (oapi::Sketchpad *skp) if (bglideslope) { const double glslope = 4.0; double dslope = slope*DEG-glslope; - dy1 = (int)(max(-2, min(2, dslope))*0.3*R0); + dy1 = (int)(max(-2.0, min(2.0, dslope))*0.3*R0); skp->Rectangle (-R0/2, dy1-U4, R0/2, dy1+U4); } // draw obs arrows - dy1 = (int)(max(-10, min (10, DEG*crsdev))*0.06*R0)+U4; + dy1 = (int)(max(-10.0, min (10.0, DEG*crsdev))*0.06*R0)+U4; dy2 = dy1-2*U4; parrow[11].y = parrow[12].y = dy2; parrow[13].y = parrow[14].y = dy1; diff --git a/Src/Orbiter/MfdMap.cpp b/Src/Orbiter/MfdMap.cpp index 698e793ac..cacba0d80 100644 --- a/Src/Orbiter/MfdMap.cpp +++ b/Src/Orbiter/MfdMap.cpp @@ -178,7 +178,7 @@ bool Instrument_Map::KeyBuffered (DWORD key) bool Instrument_Map::KeyImmediate (char *kstate) { double t = td.SysT0; - double dt = max(t-scroll_t0, 0); + double dt = max(t-scroll_t0, 0.0); double mag = min(dt*0.5, 8.0); double step = (t-scroll_tp) * mag / zoom; @@ -496,7 +496,7 @@ void Instrument_Map::UpdateDraw_Dispprm (oapi::Sketchpad *skp) } CustomMkrSet &set = map->GetCustomMarkerSet(); - for (i = max(0,dispprm_top-ndefault); i < min(set.nset,nlist-ndefault+dispprm_top); i++) { + for (i = max(0,dispprm_top-ndefault); i < min((int)set.nset,nlist-ndefault+dispprm_top); i++) { std::string& name = set.set[i].list->name; bool active = set.set[i].active; skp->Text (x0, y, name.c_str(), name.size()); diff --git a/Src/Orbiter/OptionsPages.cpp b/Src/Orbiter/OptionsPages.cpp index ac1ce3ebf..484735b17 100644 --- a/Src/Orbiter/OptionsPages.cpp +++ b/Src/Orbiter/OptionsPages.cpp @@ -16,6 +16,9 @@ #include "resource.h" #include "Uxtheme.h" +using std::min; +using std::max; + extern Orbiter* g_pOrbiter; extern PlanetarySystem* g_psys; extern Camera* g_camera; @@ -498,7 +501,7 @@ void OptionsPage_Visual::UpdateConfig(HWND hPage) 0 : SendDlgItemMessage(hPage, IDC_OPT_VIS_ELEVMODE, CB_GETCURSEL, 0, 0) + 1); GetWindowText(GetDlgItem(hPage, IDC_OPT_VIS_MAXLEVEL), cbuf, 127); if (!sscanf(cbuf, "%lu", &i)) i = SURF_MAX_PATCHLEVEL2; - Cfg()->CfgVisualPrm.PlanetMaxLevel = max(1, min(SURF_MAX_PATCHLEVEL2, i)); + Cfg()->CfgVisualPrm.PlanetMaxLevel = max((DWORD)1, min((DWORD)SURF_MAX_PATCHLEVEL2, i)); Cfg()->CfgVisualPrm.bVesselShadows = (SendDlgItemMessage(hPage, IDC_OPT_VIS_VSHADOW, BM_GETCHECK, 0, 0) == BST_CHECKED); Cfg()->CfgVisualPrm.bReentryFlames = (SendDlgItemMessage(hPage, IDC_OPT_VIS_REENTRY, BM_GETCHECK, 0, 0) == BST_CHECKED); Cfg()->CfgVisualPrm.bShadows = (SendDlgItemMessage(hPage, IDC_OPT_VIS_SHADOW, BM_GETCHECK, 0, 0) == BST_CHECKED); diff --git a/Src/Orbiter/Pane.cpp b/Src/Orbiter/Pane.cpp index 4811168ed..af3ee19e1 100644 --- a/Src/Orbiter/Pane.cpp +++ b/Src/Orbiter/Pane.cpp @@ -512,7 +512,7 @@ void Pane::IncHUDIntens () void Pane::DecHUDIntens () { - SetHUDColour (-1, max (0, hudIntens - td.SysDT*0.3)); + SetHUDColour (-1, max (0.0, hudIntens - td.SysDT*0.3)); } void Pane::RenderCustomHUD (MESHHANDLE hMesh, SURFHANDLE *hTex) diff --git a/Src/Orbiter/Panel.cpp b/Src/Orbiter/Panel.cpp index 01cf06c2f..1a5a07bae 100644 --- a/Src/Orbiter/Panel.cpp +++ b/Src/Orbiter/Panel.cpp @@ -92,12 +92,12 @@ void Panel::Move (LONG dx, LONG dy) if (X0 > 0) X0 = 0; if (tgtW+X0 < pane->W) X0 = pane->W-tgtW; tgtRect.left = 0; - tgtRect.right = min (tgtRect.left+tgtW, pane->W); + tgtRect.right = min (tgtRect.left+tgtW, (LONG)pane->W); srcRect.left = -X0; srcRect.right = srcRect.left + (tgtRect.right-tgtRect.left); if (scaled) { - srcRect.left = max((int)(srcRect.left *iscale), 0); - srcRect.right = min((int)(srcRect.right * iscale), srcW); + srcRect.left = max((LONG)(srcRect.left *iscale), (LONG)0); + srcRect.right = min((LONG)(srcRect.right * iscale), srcW); } } if (dy) { @@ -113,12 +113,12 @@ void Panel::Move (LONG dx, LONG dy) else visible = true; tgtRect.top = (Y0 >= 0 ? Y0 : 0); - tgtRect.bottom = min (Y0+tgtH, pane->H); + tgtRect.bottom = min (Y0+tgtH, (LONG)pane->H); srcRect.top = tgtRect.top-Y0; srcRect.bottom = min (tgtH, srcRect.top + (tgtRect.bottom-tgtRect.top)); if (scaled) { - srcRect.top = max((int)(srcRect.top *iscale), 0); - srcRect.bottom = min((int)(srcRect.bottom* iscale), srcH); + srcRect.top = max((LONG)(srcRect.top *iscale), (LONG)0); + srcRect.bottom = min((LONG)(srcRect.bottom* iscale), srcH); } } MFDMoved(); @@ -193,8 +193,8 @@ void Panel::DefineBackground (HBITMAP hBmp, DWORD flag, DWORD _ck) tgtRect.left = (X0 >= 0 ? X0 : 0); tgtRect.top = (Y0 >= 0 ? Y0 : 0); - tgtRect.right = min (tgtRect.left+tgtW, pane->W); - tgtRect.bottom = min (tgtRect.top+tgtH, pane->H); + tgtRect.right = min (tgtRect.left+tgtW, (LONG)pane->W); + tgtRect.bottom = min (tgtRect.top+tgtH, (LONG)pane->H); srcRect.left = tgtRect.left-X0; srcRect.top = tgtRect.top-Y0; @@ -202,10 +202,10 @@ void Panel::DefineBackground (HBITMAP hBmp, DWORD flag, DWORD _ck) srcRect.bottom = srcRect.top + (tgtRect.bottom-tgtRect.top); if (scaled) { - srcRect.left = max((int)(srcRect.left *iscale), 0); - srcRect.top = max((int)(srcRect.top *iscale), 0); - srcRect.right = min((int)(srcRect.right * iscale), srcW); - srcRect.bottom = min((int)(srcRect.bottom* iscale), srcH); + srcRect.left = max((LONG)(srcRect.left *iscale), (LONG)0); + srcRect.top = max((LONG)(srcRect.top *iscale), (LONG)0); + srcRect.right = min((LONG)(srcRect.right * iscale), srcW); + srcRect.bottom = min((LONG)(srcRect.bottom* iscale), srcH); } // define color key for blitting diff --git a/Src/Orbiter/Panel2D.cpp b/Src/Orbiter/Panel2D.cpp index e39000c84..6def184ff 100644 --- a/Src/Orbiter/Panel2D.cpp +++ b/Src/Orbiter/Panel2D.cpp @@ -133,11 +133,11 @@ void Panel2D::SetActiveScale (double scale, bool force) x0 = 0.5 * ((double)viewW - tgtW); else { x0 = refx - sr*(refx-x0); - x0 = max (min(0,x0), viewW-tgtW); + x0 = max (min(0.0,x0), viewW-tgtW); } y0 = refy - sr*(refy-y0); if (shiftflag & PANEL_ATTACH_BOTTOM) y0 = max (y0, viewH-tgtH); - else if (shiftflag & PANEL_ATTACH_TOP) y0 = min (y0, 0); + else if (shiftflag & PANEL_ATTACH_TOP) y0 = min (y0, 0.0); if (panelscale == 1.0) { // pixel alignment x0 = floor(x0+0.5); @@ -202,7 +202,7 @@ void Panel2D::Move (double dx, double dy) if (dx && tgtW > viewW) { // horizontal panning only if panel wider than viewport x0 += dx; - x0 = max (min (x0, 0), viewW-tgtW); + x0 = max (min (x0, 0.0), viewW-tgtW); moved = true; } if (dy) { diff --git a/Src/Orbiter/Particle.cpp b/Src/Orbiter/Particle.cpp index 5a9029083..a79aa34c8 100644 --- a/Src/Orbiter/Particle.cpp +++ b/Src/Orbiter/Particle.cpp @@ -15,6 +15,9 @@ #include "Astro.h" #include "Util.h" #include +#include +using std::min; +using std::max; extern Orbiter *g_pOrbiter; extern Camera *g_camera; @@ -150,7 +153,7 @@ double D3D7ParticleStream::Level2Alpha (double level) const case PARTICLESTREAMSPEC::LVL_SQRT: return sqrt (level); case PARTICLESTREAMSPEC::LVL_PLIN: - return max (0, min (1, (level-lmin)/(lmax-lmin))); + return max (0.0, min (.01, (level-lmin)/(lmax-lmin))); case PARTICLESTREAMSPEC::LVL_PSQRT: return (level <= lmin ? 0 : level >= lmax ? 1 : sqrt ((level-lmin)/(lmax-lmin))); } @@ -163,9 +166,9 @@ double D3D7ParticleStream::Atm2Alpha (double prm) const case PARTICLESTREAMSPEC::ATM_FLAT: return amin; case PARTICLESTREAMSPEC::ATM_PLIN: - return max (0, min (1, (prm-amin)*afac)); + return max (0.0, min (1.0, (prm-amin)*afac)); case PARTICLESTREAMSPEC::ATM_PLOG: - return max (0, min (1, log(prm/amin)*afac)); + return max (0.0, min (1.0, log(prm/amin)*afac)); } return 0; // should not happen } diff --git a/Src/Orbiter/Planet.cpp b/Src/Orbiter/Planet.cpp index 5417aad95..e55a0326e 100644 --- a/Src/Orbiter/Planet.cpp +++ b/Src/Orbiter/Planet.cpp @@ -271,7 +271,7 @@ Planet::Planet (char *fname) if (!GetItemReal (ifs, "AtmGamma", atm.gamma) && !atm.gamma) atm.gamma = 1.4; // default to air if (!GetItemReal (ifs, "AtmHazeExtent", hazerange)) hazerange = 0.1; - hazerange = max (0, min (0.9, hazerange)); + hazerange = max (0.0, min (0.9, hazerange)); if (!GetItemReal (ifs, "AtmHazeShift", hazeshift)) hazeshift = 0.0; if (!GetItemReal (ifs, "AtmHazeDensity", hazedens)) hazedens = 1.0; Vector col0; @@ -317,14 +317,14 @@ Planet::Planet (char *fname) max_patch_level = (DWORD)i; else max_patch_level = 8; - max_patch_level = min (max_patch_level, SURF_MAX_PATCHLEVEL2); + max_patch_level = min (max_patch_level, (DWORD)SURF_MAX_PATCHLEVEL2); max_patch_level = min (max_patch_level, g_pOrbiter->Cfg()->CfgVisualPrm.PlanetMaxLevel); bHasCloudlayer = g_pOrbiter->Cfg()->CfgVisualPrm.bClouds && GetItemInt (ifs, "MinCloudResolution", min_cloud_level) && min_cloud_level >= 1; if (bHasCloudlayer) { if (!GetItemInt (ifs, "MaxCloudResolution", max_cloud_level)) - max_cloud_level = min (8, max_patch_level); + max_cloud_level = min (8, (int)max_patch_level); if (!GetItemBool (ifs, "BrightenClouds", bBrightClouds)) bBrightClouds = false; if (GetItemString (ifs, "CloudMicrotextureAlt", cbuf) && diff --git a/Src/Orbiter/PlaybackEd.cpp b/Src/Orbiter/PlaybackEd.cpp index 7ff3c1f00..6290d6a95 100644 --- a/Src/Orbiter/PlaybackEd.cpp +++ b/Src/Orbiter/PlaybackEd.cpp @@ -247,7 +247,7 @@ void TaccEvent::SetTacc (double _tacc) void TaccEvent::SetDelay (double _delay) { - delay = max (0, _delay); + delay = max (0.0, _delay); } void TaccEvent::TagStr (char *str) diff --git a/Src/Orbiter/Scene.cpp b/Src/Orbiter/Scene.cpp index f8dc39353..ed950fd26 100644 --- a/Src/Orbiter/Scene.cpp +++ b/Src/Orbiter/Scene.cpp @@ -22,6 +22,8 @@ #include "Log.h" #include "D3dmath.h" #include "resource.h" +#include +using std::min; #define NSEG 64 diff --git a/Src/Orbiter/Select.cpp b/Src/Orbiter/Select.cpp index ef5786b60..6aec1990e 100644 --- a/Src/Orbiter/Select.cpp +++ b/Src/Orbiter/Select.cpp @@ -11,6 +11,8 @@ #include "Util.h" #include "Log.h" +using std::max; + extern Orbiter *g_pOrbiter; extern char DBG_MSG[256]; COLORREF titlecol = RGB(255,255,255); @@ -147,7 +149,7 @@ void Select::Activate () colh = itemh; submenu = false; } else { - col[ncol].w = max (col[ncol].w, textW); + col[ncol].w = max (col[ncol].w, (int)textW); colh += itemh; } col[ncol].nitem++; @@ -489,7 +491,7 @@ void SelectionList::AllocSurface () colh = itemh; submenu = false; } else { - col[ncol].w = max (col[ncol].w, textw); + col[ncol].w = max ((DWORD)col[ncol].w, textw); colh += itemh; } col[ncol].nitem++; diff --git a/Src/Orbiter/Spherepatch.cpp b/Src/Orbiter/Spherepatch.cpp index 899404046..fd62efa41 100644 --- a/Src/Orbiter/Spherepatch.cpp +++ b/Src/Orbiter/Spherepatch.cpp @@ -17,6 +17,9 @@ #include "Log.h" #include "Util.h" #include "OGraphics.h" +#include +using std::min; +using std::max; // ======================================================================= // Externals diff --git a/Src/Orbiter/TabExtra.cpp b/Src/Orbiter/TabExtra.cpp index f5e4cc723..ae7ef4676 100644 --- a/Src/Orbiter/TabExtra.cpp +++ b/Src/Orbiter/TabExtra.cpp @@ -20,6 +20,8 @@ #include "resource.h" #include "resource2.h" +using std::max; + extern Orbiter *g_pOrbiter; //----------------------------------------------------------------------------- diff --git a/Src/Orbiter/TabModule.cpp b/Src/Orbiter/TabModule.cpp index ce3b12eb8..a3336ad5b 100644 --- a/Src/Orbiter/TabModule.cpp +++ b/Src/Orbiter/TabModule.cpp @@ -13,6 +13,8 @@ #include "TabModule.h" #include "resource.h" +using std::max; + extern char DBG_MSG[256]; static int counter = -1; diff --git a/Src/Orbiter/TileMgr.cpp b/Src/Orbiter/TileMgr.cpp index c7c2ec7e3..4e49d7e5e 100644 --- a/Src/Orbiter/TileMgr.cpp +++ b/Src/Orbiter/TileMgr.cpp @@ -16,6 +16,9 @@ #include "Camera.h" #include "Log.h" #include "OGraphics.h" +#include +using std::min; +using std::max; // ======================================================================= // Externals @@ -67,8 +70,8 @@ TileManager::TileManager (const Planet *_cbody) { cbody = _cbody; maxlvl = min (g_pOrbiter->Cfg()->CfgVisualPrm.PlanetMaxLevel, cbody->max_patch_level); - maxlvl = min (maxlvl, SURF_MAX_PATCHLEVEL); - maxbaselvl = min (8, maxlvl); + maxlvl = min (maxlvl, (DWORD)SURF_MAX_PATCHLEVEL); + maxbaselvl = min ((DWORD)8, maxlvl); int maxidx = patchidx[maxbaselvl]; pcdir.Set (1,0,0); bRipple = (g_pOrbiter->Cfg()->CfgVisualPrm.bSpecularRipple && cbody->bWaterMicrotex); @@ -484,7 +487,7 @@ void TileManager::Stop () void TileManager::Render (LPDIRECT3DDEVICE7 dev, D3DMATRIX &wmat, double scale, VPlanet *vbody, int level, bool addambient, bool addfog) { - level = min (level, maxlvl); + level = min (level, (int)maxlvl); memset(nrender,0,15*sizeof(int)); // temporary RenderParam.dev = dev; diff --git a/Src/Orbiter/TimeData.cpp b/Src/Orbiter/TimeData.cpp index 6a1033a35..2111666c5 100644 --- a/Src/Orbiter/TimeData.cpp +++ b/Src/Orbiter/TimeData.cpp @@ -1,6 +1,9 @@ #include "TimeData.h" #include "Astro.h" +using std::min; +using std::max; + //============================================================================= // Implementation of class TimeData //============================================================================= diff --git a/Src/Orbiter/VBase.cpp b/Src/Orbiter/VBase.cpp index 8b3229829..8dceeb251 100644 --- a/Src/Orbiter/VBase.cpp +++ b/Src/Orbiter/VBase.cpp @@ -15,8 +15,10 @@ #include "Spherepatch.h" #include "Astro.h" #include - +#include #include +using std::min; +using std::max; extern Orbiter *g_pOrbiter; extern PlanetarySystem *g_psys; @@ -300,7 +302,7 @@ void VBase::Update (bool moving, bool force) double az = atan2 (shdir.z, shdir.x); for (DWORD i = 0; i < base->nobj; i++) base->obj[i]->UpdateShadow (shdir, az); - shadowstrength = (float)min (1, (csun-0.07)/0.015); + shadowstrength = (float)min (1.0, (csun-0.07)/0.015); } bool night = csun < lightson; if (lights != night) { @@ -697,7 +699,7 @@ void VBase::RenderGroundShadow (LPDIRECT3DDEVICE7 dev) DWORD tfactor; bool resetalpha = false; if (gc->GetStencilDepth() > 0) { - double scale = min (1, (csun-0.07)/0.015); + double scale = min (1.0, (csun-0.07)/0.015); if (scale < 1) { dev->GetRenderState (D3DRENDERSTATE_TEXTUREFACTOR, &tfactor); float modalpha = (float)(scale*RGBA_GETALPHA(tfactor)/256.0); @@ -780,7 +782,7 @@ bool VBase::ModLighting (LPD3DLIGHT7 light) double amb0 = min (0.7, log (atm->rho0+1.0)*0.4); amb = amb0 * min (1.0, (sunelev+14.0*RAD)/(20.0*RAD)); if (!lightmod) lightmod = (amb > 0.05); - amb = max (0, amb-0.05); + amb = max (0.0, amb-0.05); // reduce direct light component to avoid overexposure lcol *= 1.0-amb*0.5; } diff --git a/Src/Orbiter/VPlanet.cpp b/Src/Orbiter/VPlanet.cpp index 60dca405e..4fae80542 100644 --- a/Src/Orbiter/VPlanet.cpp +++ b/Src/Orbiter/VPlanet.cpp @@ -26,6 +26,9 @@ #include #include #include +#include +using std::min; +using std::max; extern Orbiter *g_pOrbiter; extern PlanetarySystem *g_psys; @@ -53,7 +56,7 @@ VPlanet::VPlanet (const Planet *_planet): VObject (_planet) dist_scale = 1.0; tCheckRes = -1.0; tCheckRingSh = -1.0; - max_patchres = min (SURF_MAX_PATCHLEVEL2, planet->max_patch_level); + max_patchres = min (SURF_MAX_PATCHLEVEL2, (int)planet->max_patch_level); prm.bAtm = planet->HasAtmosphere(); if (prm.bAtm) { prm.atm_href = log(planet->atm.rho0)*2e4 + 2e4; @@ -180,7 +183,7 @@ void VPlanet::Update (bool moving, bool force) double alt = cdist-planet->size; double lvl = (planet->cloud_micro_alt1-alt)/(planet->cloud_micro_alt1-planet->cloud_micro_alt0); cloudmanager->SetMicroStructure (lvl > 0.0 ? MICROSTRUCT_CLOUD : 0); - cloudmanager->SetMicroLevel (max (0, min (1, lvl))); + cloudmanager->SetMicroLevel (max (0.0, min (1.0, lvl))); } } } @@ -798,12 +801,12 @@ bool VPlanet::ModLighting (DWORD &ambient) double amb0 = min (0.7, log (planet->atm.rho0+1.0)*0.35); // effect magnitude scale (planet-atmosphere dependent) double amb = amb0 * min (1.0, (sunelev+14.0*RAD)/(20.0*RAD)); // effect magnitude (dependent on sun elevation) if (amb < 0.05) return false; - amb = max (0, amb-0.05); + amb = max (0.0, amb-0.05); DWORD addamb = (DWORD)(amb*rscale*256); DWORD baseamb = g_pOrbiter->Cfg()->AmbientColour; ambient = 0; for (int i = 0; i < 4; i++) - ambient |= min (255, ((baseamb >> (i*8)) & 0xff) + addamb) << (i*8); + ambient |= min ((DWORD)255, ((baseamb >> (i*8)) & 0xff) + addamb) << (i*8); return true; } \ No newline at end of file diff --git a/Src/Orbiter/VectorMap.cpp b/Src/Orbiter/VectorMap.cpp index d292fbeb5..257345325 100644 --- a/Src/Orbiter/VectorMap.cpp +++ b/Src/Orbiter/VectorMap.cpp @@ -1117,7 +1117,7 @@ void VectorMap::DrawMarker (double lng, double lat, const char *name, int which) LineTo (hDCmem, x, y+11); SelectObject (hDCmem, ppen); SetTextColor (hDCmem, Instrument::draw[which][0].col); - TextOut (hDCmem, x+3, which==2 ? y:y-labelsize-3, name, min(64,strlen(name))); + TextOut (hDCmem, x+3, which==2 ? y:y-labelsize-3, name, min((size_t)64,strlen(name))); } // ======================================================================= diff --git a/Src/Orbiter/Vessel.cpp b/Src/Orbiter/Vessel.cpp index eb555033f..d87bbd0c9 100644 --- a/Src/Orbiter/Vessel.cpp +++ b/Src/Orbiter/Vessel.cpp @@ -3498,7 +3498,7 @@ void Vessel::InitOrbiting (const Vector &relr, const Vector &relv, const Vector double lng, lat, alt0; cbody->LocalToEquatorial (tmul(cbody->GRot(), cpos), lng, lat, rad); alt0 = rad-cbody->Size(); - int reslvl = (int)(32.0-log(max(alt0,100))*LOG2); + int reslvl = (int)(32.0-log(max(alt0,100.0))*LOG2); elev = emgr->Elevation (lat, lng, reslvl, &etile); } else { rad = cpos.length(); @@ -4220,7 +4220,7 @@ bool Vessel::AddSurfaceForces (Vector *F, Vector *M, const StateVectors *s, doub ElevationManager* emgr = (cbody->Type() == OBJTP_PLANET ? ((Planet*)cbody)->ElevMgr() : 0); int reslvl = 1; - if (emgr) reslvl = (int)(32.0-log(max(alt,100))*LOG2); + if (emgr) reslvl = (int)(32.0-log(max(alt,100.0))*LOG2); Vector shift = tmul(ps.R, s->pos - ps.pos); for (i = 0; i < ntouchdown_vtx; i++) { diff --git a/Src/Orbiter/Vessel.h b/Src/Orbiter/Vessel.h index 1ae3419d9..83ebfc09f 100644 --- a/Src/Orbiter/Vessel.h +++ b/Src/Orbiter/Vessel.h @@ -428,7 +428,7 @@ class Vessel: public VesselBase { double dlevel = level - ts->level_permanent; ts->level_permanent = level; if (ts->tank && ts->tank->mass) - ts->level = max(0.0, min(1.0, ts->level+dlevel)); + ts->level = std::max(0.0, std::min(1.0, ts->level+dlevel)); } } // set the permanent level for a thruster (0-1) @@ -438,7 +438,7 @@ class Vessel: public VesselBase { if (!bFRplayback) { ts->level_permanent += dlevel; if (ts->tank && ts->tank->mass) - ts->level = max(0.0, min(1.0, ts->level+dlevel)); + ts->level = std::max(0.0, std::min(1.0, ts->level+dlevel)); } } @@ -447,7 +447,7 @@ class Vessel: public VesselBase { double dlevel = level - ts->level_permanent; ts->level_permanent = level; if (ts->tank && ts->tank->mass) - ts->level = max(0.0, min(1.0, ts->level+dlevel)); + ts->level = std::max(0.0, std::min(1.0, ts->level+dlevel)); } // set permanent thruster level during playback @@ -783,11 +783,11 @@ class Vessel: public VesselBase { { return (def_tank ? def_tank : ntank ? tank[0] : 0); } inline void SetPropellantMaxMass (TankSpec *ts, double m) - { ts->mass = ts->pmass = min (ts->maxmass = m, ts->mass); UpdateMass(); } + { ts->mass = ts->pmass = std::min (ts->maxmass = m, ts->mass); UpdateMass(); } // Reset the maximum capacity [kg] of a propellant resource inline void SetPropellantMass (TankSpec *ts, double m) - { ts->mass = ts->pmass = min (m, ts->maxmass); ResetMass(); } + { ts->mass = ts->pmass = std::min (m, ts->maxmass); ResetMass(); } // Set fuel mass [kg] of a propellant resource inline double GetPropellantLevel (const TankSpec *ts) const @@ -1321,7 +1321,7 @@ class Vessel: public VesselBase { inline double ThrusterAtmScale (const ThrustSpec *ts, double p) const { if (!ts->pfac) return 1.0; - return max (0.0, 1.0 - p*ts->pfac); // old linear model + return std::max (0.0, 1.0 - p*ts->pfac); // old linear model //return exp (p*ts->pfac); // new exponential model } // Returns a thrust scaling factor for thruster th in ambient pressure p @@ -1440,7 +1440,7 @@ class Vessel: public VesselBase { inline void FlushThrusterLevel (ThrustSpec *ts) { if (ts->tank && ts->tank->mass) - ts->level = max (0.0, min (1.0, ts->level_permanent + ts->level_override)); + ts->level = std::max (0.0, std::min (1.0, ts->level_permanent + ts->level_override)); } // set thruster level as sum of permanent and override setting diff --git a/Src/Orbiter/Vesselbase.cpp b/Src/Orbiter/Vesselbase.cpp index 11e40ec8d..135fa49f7 100644 --- a/Src/Orbiter/Vesselbase.cpp +++ b/Src/Orbiter/Vesselbase.cpp @@ -5,6 +5,8 @@ #include "Vesselbase.h" #include "Psys.h" +using std::max; + extern PlanetarySystem *g_psys; extern TimeData td; extern char DBG_MSG[256]; @@ -35,7 +37,7 @@ void SurfParam::Set (const StateVectors &s, const StateVectors &s_ref, const Cel if (ref->Type() == OBJTP_PLANET) { ElevationManager *emgr = ((Planet*)ref)->ElevMgr(); if (emgr) { - int reslvl = (int)(32.0-log(max(alt0,100))*LOG2); + int reslvl = (int)(32.0-log(max(alt0,100.0))*LOG2); elev = emgr->Elevation (lat, lng, reslvl, etilecache, &surfnml, &elev_lvl); alt -= elev; } @@ -113,7 +115,7 @@ double SurfParam::ComputeAltitude(const StateVectors &s, const StateVectors &s_r if (etilecache && _alt < alt_max && _ref->Type() == OBJTP_PLANET) { ElevationManager *emgr = ((Planet*)_ref)->ElevMgr(); if (emgr) { - int reslvl = (int)(32.0-log(max(_alt,100))*LOG2); + int reslvl = (int)(32.0-log(max(_alt,100.0))*LOG2); double elev = emgr->Elevation (_lat, _lng, reslvl, etilecache); _alt -= elev; } diff --git a/Src/Orbiter/Vesselstatus.cpp b/Src/Orbiter/Vesselstatus.cpp index 053f07eb0..af23496a5 100644 --- a/Src/Orbiter/Vesselstatus.cpp +++ b/Src/Orbiter/Vesselstatus.cpp @@ -22,6 +22,8 @@ #include #include +using std::min; + extern Orbiter *g_pOrbiter; extern TimeData td; extern PlanetarySystem *g_psys; diff --git a/Src/Orbiter/Vobject.cpp b/Src/Orbiter/Vobject.cpp index 73d024496..4950d108d 100644 --- a/Src/Orbiter/Vobject.cpp +++ b/Src/Orbiter/Vobject.cpp @@ -18,6 +18,8 @@ #include "Astro.h" #include #include +using std::min; +using std::max; using namespace oapi; @@ -428,7 +430,7 @@ bool VObject::DrawVector (LPDIRECT3DDEVICE7 dev, const Vector &end, const Vector float w = (float)rad; float h = (float)end.length(); if (h < EPS) return false; - float hb = max (h-4.0f*w, 0); + float hb = max (h-4.0f*w, 0.0f); memcpy (Vtx, Vtx0, nVtx*sizeof(D3DVERTEX)); diff --git a/Src/Orbiter/Vvessel.cpp b/Src/Orbiter/Vvessel.cpp index d90819890..e1c5cbf62 100644 --- a/Src/Orbiter/Vvessel.cpp +++ b/Src/Orbiter/Vvessel.cpp @@ -19,6 +19,9 @@ #include "Log.h" #include "Astro.h" #include "Util.h" +#include +using std::min; +using std::max; #define EXHAUST_SCALEALPHA //#define EXHAUST_SCALESIZE @@ -668,7 +671,7 @@ void VVessel::RenderExhaust (LPDIRECT3DDEVICE7 dev, LPDIRECTDRAWSURFACE7 default if (vessel->sp.is_in_atm && g_pOrbiter->Cfg()->CfgVisualPrm.bReentryFlames && vessel->reentry.do_render) { const double afac = 1.0/log(1e11/2e8); double friction = 0.5 * pow(vessel->sp.atmrho,0.6) * pow (vessel->sp.airspd, 3); - double opac = max (0, min (1, log(friction/2e8)*afac)); + double opac = max (0.0, min (1.0, log(friction/2e8)*afac)); if (opac > 0.005) { if (need_setup) { // initialise render state @@ -752,7 +755,7 @@ void VVessel::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, const Planet *planet) if (g_pOrbiter->UseStencil()) { static D3DMATERIAL7 shmat_grey = {{0,0,0,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},0}; - shmat_grey.diffuse.a = (float)(depth * min (1, (csun-0.07)/0.015)); + shmat_grey.diffuse.a = (float)(depth * min (1.0, (csun-0.07)/0.015)); dev->SetMaterial (&shmat_grey); } for (UINT i = 0; i < nmesh; i++) { @@ -979,7 +982,7 @@ bool VVessel::ModLighting (LPD3DLIGHT7 light) amb = amb0 / (alt*0.5e-4 + 1.0); amb *= min (1.0, (sunelev+14.0*RAD)/(20.0*RAD)); if (!lightmod) lightmod = (amb > 0.05); - amb = max (0, amb-0.05); + amb = max (0.0, amb-0.05); // reduce direct light component to avoid overexposure lcol *= 1.0-amb*0.5; } diff --git a/Src/Orbiter/cloudmgr2.cpp b/Src/Orbiter/cloudmgr2.cpp index 789e9ef19..d054b7ec5 100644 --- a/Src/Orbiter/cloudmgr2.cpp +++ b/Src/Orbiter/cloudmgr2.cpp @@ -9,6 +9,9 @@ #include "OGraphics.h" #include "Texture.h" #include "Log.h" +#include +using std::min; +using std::max; // Subsystem for loading, managing and displaying planetary cloud layers diff --git a/Src/Orbiter/elevmgr.cpp b/Src/Orbiter/elevmgr.cpp index f19b8b9fb..ac0bcb2b5 100644 --- a/Src/Orbiter/elevmgr.cpp +++ b/Src/Orbiter/elevmgr.cpp @@ -6,6 +6,9 @@ #include "Planet.h" #include "Orbiter.h" +using std::min; +using std::max; + static int elev_grid = 256; static int elev_stride = elev_grid+3; static int MAXLVL_LIMIT = 11; @@ -39,7 +42,7 @@ ElevationManager::ElevationManager (const CelestialBody *_cbody) maxlvl = MAXLVL_LIMIT; elev_res = 1.0; if (cbody->Type() == OBJTP_PLANET) { - maxlvl = min (maxlvl, ((Planet*)cbody)->MaxPatchLevel()-7); + maxlvl = min ((DWORD)maxlvl, ((Planet*)cbody)->MaxPatchLevel()-7); // -7: -4 for level offset of quadtree root, -3 for great-grandfather elevation access mode elev_res = ((Planet*)cbody)->ElevationResolution(); } diff --git a/Src/Orbiter/surfmgr2.cpp b/Src/Orbiter/surfmgr2.cpp index 0207bef3c..c1a49e8ea 100644 --- a/Src/Orbiter/surfmgr2.cpp +++ b/Src/Orbiter/surfmgr2.cpp @@ -12,6 +12,9 @@ #include "OGraphics.h" #include "Util.h" #include "Log.h" +#include +using std::min; +using std::max; // ----------------------------------------------------------------------- diff --git a/Src/Orbiter/tilelabel.cpp b/Src/Orbiter/tilelabel.cpp index 01f547de0..2ae9ebeea 100644 --- a/Src/Orbiter/tilelabel.cpp +++ b/Src/Orbiter/tilelabel.cpp @@ -7,6 +7,9 @@ #include "D3dmath.h" #include #include +#include +using std::min; +using std::max; extern Orbiter *g_pOrbiter; extern Camera *g_camera; diff --git a/Src/Orbiter/tilemgr2.cpp b/Src/Orbiter/tilemgr2.cpp index 0b935a717..4ca3c312d 100644 --- a/Src/Orbiter/tilemgr2.cpp +++ b/Src/Orbiter/tilemgr2.cpp @@ -10,6 +10,8 @@ #include "Log.h" #include "OGraphics.h" #include +#include +using std::max; static TEXCRDRANGE2 fullrange = {0,1,0,1}; diff --git a/Src/Orbiter/tilemgr2_imp.hpp b/Src/Orbiter/tilemgr2_imp.hpp index 324df2858..849e923f8 100644 --- a/Src/Orbiter/tilemgr2_imp.hpp +++ b/Src/Orbiter/tilemgr2_imp.hpp @@ -126,7 +126,7 @@ void TileManager2Base::ProcessNode (QuadTreeNode *node) double apr = tdist * g_camera->TanAperture() / g_pOrbiter->ViewH() * 1400.0; double amax = (prm.cdist > 1.0 ? acos(1.0/prm.cdist) : 0.0); if (adist > 0.5*amax) bias -= 2.0*(adist/amax-0.5); // reduce resolution for oblique tiles at the horizon - int tgtres = (apr < 1e-6 ? prm.maxlvl : max (0, min (prm.maxlvl, (int)(bias - log(apr)*res_scale)))); + int tgtres = (apr < 1e-6 ? prm.maxlvl : std::max (0, std::min (prm.maxlvl, (int)(bias - log(apr)*res_scale)))); bstepdown = (lvl < tgtres); } diff --git a/Src/Plugin/ExtMFD/MFDWindow.cpp b/Src/Plugin/ExtMFD/MFDWindow.cpp index 376a4a341..df3d95666 100644 --- a/Src/Plugin/ExtMFD/MFDWindow.cpp +++ b/Src/Plugin/ExtMFD/MFDWindow.cpp @@ -17,6 +17,9 @@ #include "resource.h" #include // temporary +using std::min; +using std::max; + // ============================================================== // prototype definitions diff --git a/Src/Plugin/LuaConsole/LuaConsole.cpp b/Src/Plugin/LuaConsole/LuaConsole.cpp index 872c96a79..7807aa6ed 100644 --- a/Src/Plugin/LuaConsole/LuaConsole.cpp +++ b/Src/Plugin/LuaConsole/LuaConsole.cpp @@ -9,6 +9,8 @@ #include #include +using std::min; +using std::max; using namespace oapi; // ============================================================== @@ -450,7 +452,7 @@ bool LuaConsole::ScanHistory (int step) ninp = caret = 0; } else { strncpy (inp, line[ln].buf, 1024); - ninp = caret = min (strlen (line[ln].buf), 1024); + ninp = caret = min (strlen (line[ln].buf), (size_t)1024); } } else if (step > 0) { inp[0] = '\0'; diff --git a/Src/Plugin/LuaMFD/LuaMFD.cpp b/Src/Plugin/LuaMFD/LuaMFD.cpp index 3ba42018d..7d02de87b 100644 --- a/Src/Plugin/LuaMFD/LuaMFD.cpp +++ b/Src/Plugin/LuaMFD/LuaMFD.cpp @@ -6,6 +6,8 @@ #include "orbitersdk.h" #include "LuaMFD.h" +using std::min; + // ============================================================== // Global variables @@ -178,7 +180,7 @@ void ScriptMFD::Update (HDC hDC) col = ls->col; SetTextColor (hDC, col); } - TextOut (hDC, xofs, yofs, ls->buf, min(strlen(ls->buf),nchar)); + TextOut (hDC, xofs, yofs, ls->buf, min(strlen(ls->buf),(size_t)nchar)); yofs += fh; } SelectObject (hDC, oFont); diff --git a/Src/Plugin/Meshdebug/Meshdebug.cpp b/Src/Plugin/Meshdebug/Meshdebug.cpp index acfaba637..cee7241c1 100644 --- a/Src/Plugin/Meshdebug/Meshdebug.cpp +++ b/Src/Plugin/Meshdebug/Meshdebug.cpp @@ -19,6 +19,9 @@ #include "resource.h" #include +using std::min; +using std::max; + // ============================================================== // Global variables // ============================================================== diff --git a/Src/Plugin/ScnEditor/Editor.cpp b/Src/Plugin/ScnEditor/Editor.cpp index db0e7aa90..74a7f6bd3 100644 --- a/Src/Plugin/ScnEditor/Editor.cpp +++ b/Src/Plugin/ScnEditor/Editor.cpp @@ -19,6 +19,9 @@ #include #include +using std::min; +using std::max; + extern ScnEditor *g_editor; extern HBITMAP g_hPause; @@ -871,7 +874,7 @@ void EditorTab_New::DrawVesselBmp () GetClientRect (hImgWnd, &r); GetObject(hVesselBmp, sizeof(bm), &bm); dx = bm.bmWidth, dy = bm.bmHeight; - h = min (imghmax, (r.right*dy)/dx); + h = min (imghmax, (int)(r.right*dy)/dx); SetWindowPos (hImgWnd, NULL, 0, 0, r.right, h, SWP_NOMOVE|SWP_NOZORDER); StretchBlt (hDC, 0, 0, r.right, h, hBmpDC, 0, 0, dx, dy, SRCCOPY); DeleteDC (hBmpDC); @@ -2185,7 +2188,7 @@ INT_PTR EditorTab_Landed::TabProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l GetWindowText (GetDlgItem (hDlg, IDC_EDIT2), cbuf, 256); sscanf (cbuf, "%lf", &val); val -= nmud->iDelta * (id == IDC_SPIN2 ? 0.00001 : 0.001); - val = min (90, max (-90, val)); + val = min (90.0, max (-90.0, val)); sprintf (cbuf, "%lf", val); SetWindowText (GetDlgItem (hDlg, IDC_EDIT2), cbuf); Apply (); @@ -2372,7 +2375,7 @@ INT_PTR EditorTab_Orientation::TabProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPA GetWindowText (GetDlgItem (hDlg, IDC_EDIT2), cbuf, 256); sscanf (cbuf, "%lf", &val); val -= nmud->iDelta * (id == IDC_SPIN2 ? 0.001 : 0.1); - val = min (90, max (-90, val)); + val = min (90.0, max (-90.0, val)); sprintf (cbuf, "%lf", val); SetWindowText (GetDlgItem (hDlg, IDC_EDIT2), cbuf); Apply (); @@ -2660,7 +2663,7 @@ INT_PTR EditorTab_Propellant::TabProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPAR i = sscanf (cbuf, "%d", &n); if (!i || !n || n > ntank) n = 1; n += (nmud->iDelta < 0 ? 1 : -1); - n = max (1, min (ntank, n)); + n = max ((DWORD)1, min (ntank, n)); sprintf (cbuf, "%d", n); SetWindowText (GetDlgItem (hDlg, IDC_EDIT1), cbuf); Refresh (); @@ -2736,7 +2739,7 @@ void EditorTab_Propellant::Apply () if (lastedit == IDC_EDIT2) { GetWindowText (GetDlgItem (hTab, IDC_EDIT2), cbuf, 256); sscanf (cbuf, "%lf", &level); - level = max (0, min (1, level)); + level = max (0.0, min (1.0, level)); } else { VESSEL *vessel = oapiGetVesselInterface (ed->hVessel); GetWindowText (GetDlgItem (hTab, IDC_EDIT1), cbuf, 256); @@ -2746,7 +2749,7 @@ void EditorTab_Propellant::Apply () double m, m0 = vessel->GetPropellantMaxMass (hP); GetWindowText (GetDlgItem (hTab, IDC_EDIT3), cbuf, 256); sscanf (cbuf, "%lf", &m); - level = max (0, min (1, m/m0)); + level = max (0.0, min (1.0, m/m0)); } SetLevel (level); } @@ -2982,7 +2985,7 @@ void EditorTab_Docking::Refresh () GetWindowText (GetDlgItem (hTab, IDC_EDIT1), cbuf, 256); if (!sscanf (cbuf, "%d", &n)) n = 0; if (n < 1 || n > ndock) { - n = max (1, min (ndock, n)); + n = max ((DWORD)1, min (ndock, n)); sprintf (cbuf, "%d", n); SetWindowText (GetDlgItem (hTab, IDC_EDIT1), cbuf); } @@ -3020,7 +3023,7 @@ void EditorTab_Docking::SetTargetDock (DWORD dock) if (hTarget) { VESSEL *v = oapiGetVesselInterface (hTarget); DWORD ndock = v->DockCount(); - if (ndock) n = max (1, min (ndock, dock)); + if (ndock) n = max ((DWORD)1, min (ndock, dock)); } if (n) sprintf (cbuf, "%d", n); else cbuf[0] = '\0'; diff --git a/Src/Plugin/TrackIR/TrackIR.cpp b/Src/Plugin/TrackIR/TrackIR.cpp index 22d3e60be..eace3b6c8 100644 --- a/Src/Plugin/TrackIR/TrackIR.cpp +++ b/Src/Plugin/TrackIR/TrackIR.cpp @@ -8,6 +8,9 @@ #include "NPClient.h" #include "NPClientWraps.h" +using std::min; +using std::max; + // ============================================================== // Global parameters diff --git a/Src/Plugin/TrackIR/TrackIRconfig.cpp b/Src/Plugin/TrackIR/TrackIRconfig.cpp index ad5c1c749..06ffa208a 100644 --- a/Src/Plugin/TrackIR/TrackIRconfig.cpp +++ b/Src/Plugin/TrackIR/TrackIRconfig.cpp @@ -5,6 +5,9 @@ #include #include +using std::min; +using std::max; + extern GPARAMS gParams; TrackIRconfig *TrackIRconfig::tirc = 0; @@ -116,9 +119,9 @@ void TrackIRconfig::Apply (HWND hDlg) trackir->trkmode.rotationdata = (SendDlgItemMessage (hTab[2], IDC_RADIO1, BM_GETCHECK, 0, 0) == BST_CHECKED ? ExternalCameraControl::TrackMode::BYROTATION : ExternalCameraControl::TrackMode::BYPOSITION); GetWindowText (GetDlgItem (hTab[2], IDC_EDIT1), cbuf, 256); - if (sscanf (cbuf, "%lf", &t)) trackir->trkmode.deadzone = max (0, min (100, t))*0.01; + if (sscanf (cbuf, "%lf", &t)) trackir->trkmode.deadzone = max (0.0, min (100.0, t))*0.01; GetWindowText (GetDlgItem (hTab[2], IDC_EDIT2), cbuf, 256); - if (sscanf (cbuf, "%lf", &t)) trackir->trkmode.speed = max(1, min (100, t))*0.05; + if (sscanf (cbuf, "%lf", &t)) trackir->trkmode.speed = max(1.0, min (100.0, t))*0.05; } INT_PTR CALLBACK TrackIRconfig::DlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) diff --git a/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp b/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp index c579c31e1..876436301 100644 --- a/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp +++ b/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp @@ -16,6 +16,9 @@ #include "resource.h" #include "Common\Dialog\Graph.h" +using std::min; +using std::max; + extern GDIParams g_Param; // ============================================================== @@ -902,7 +905,7 @@ void AscentApMfd::InitDecAzimuth () { set_mode = MODE_AZIMUTH_DEC; ref_t = oapiGetSysTime(); - ref_val = max(ap->GetLaunchAzimuth()-RAD*0.1, 0); + ref_val = max(ap->GetLaunchAzimuth()-RAD*0.1, 0.0); ap->SetLaunchAzimuth(ref_val); InvalidateDisplay(); } @@ -929,7 +932,7 @@ void AscentApMfd::DecAzimuth() da -= min(dt-3.0,3.0)*RAD*2.0; if (dt > 6.0) da -= (dt-6.0)*RAD*20.0; - double az = max(ref_val + da, 0); + double az = max(ref_val + da, 0.0); ap->SetLaunchAzimuth (az); InvalidateDisplay(); } @@ -956,7 +959,7 @@ void AscentApMfd::InitDecAltitude () { set_mode = MODE_AZIMUTH_DEC; ref_t = oapiGetSysTime(); - ref_val = max(ap->GetOrbitAltitude()-100, 0); + ref_val = max(ap->GetOrbitAltitude()-100, 0.0); ap->SetOrbitAltitude(ref_val); InvalidateDisplay(); } @@ -983,7 +986,7 @@ void AscentApMfd::DecAltitude() da -= min(dt-3.0,3.0)*1e3*2.0; if (dt > 6.0) da -= (dt-6.0)*1e3*20.0; - double alt = max(ref_val + da, 0); + double alt = max(ref_val + da, 0.0); ap->SetOrbitAltitude (alt); InvalidateDisplay(); } diff --git a/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp b/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp index cbc0b5dd3..46a94a8cb 100644 --- a/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp +++ b/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp @@ -25,6 +25,9 @@ #include #include +using std::min; +using std::max; + #ifdef _DEBUG // D. Beachy: for BoundsChecker debugging extern int GrowStack(); @@ -1001,7 +1004,7 @@ void Atlantis::AutoGimbal (const VECTOR3 &tgt_rate) maxdg = dt*0.3; // max gimbal speed [rad/s] dgimbal = a_pitch*(avel.x-tgt_rate.x) + b_pitch*aacc.x; dgimbal = max(-maxdg, min(maxdg, dgimbal)); - gimbal_pos.x = min (0, max (pitch_gimbal_max, gimbal_pos.x+dgimbal)); + gimbal_pos.x = min (0.0, max (pitch_gimbal_max, gimbal_pos.x+dgimbal)); // Yaw gimbal settings dgimbal = a_yaw*(avel.y-tgt_rate.y) + b_yaw*aacc.y; @@ -1376,7 +1379,7 @@ void Atlantis::clbkLoadStateEx (FILEHANDLE scn, void *vs) if (status == 0) { VESSELSTATUS2 *vs2 = (VESSELSTATUS2*)vs; if (vs2->status & 1) { // idle flag - launchelev = max (0, vs2->vrot.x - 18.962); + launchelev = max (0.0, vs2->vrot.x - 18.962); if (vs2->arot.x > 4.0) { // rotation matrix not defined - need to construct manually double slng = sin (vs2->surf_lng), clng = cos (vs2->surf_lng); double slat = sin (vs2->surf_lat), clat = cos (vs2->surf_lat); @@ -1388,7 +1391,7 @@ void Atlantis::clbkLoadStateEx (FILEHANDLE scn, void *vs) } else { double rad = length(vs2->rpos); double alt = rad - oapiGetSize(vs2->rbody); - launchelev = max (0, alt - 18.962); + launchelev = max (0.0, alt - 18.962); } } diff --git a/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp b/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp index 28e3b558b..e22b69bcd 100644 --- a/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp +++ b/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp @@ -7,6 +7,9 @@ #include "DlgCtrl.h" #include +using std::min; +using std::max; + extern GDIParams g_Param; extern HELPCONTEXT g_hc; extern const char *ActionString[5]; diff --git a/Src/Vessel/DeltaGlider/AAPSubsys.cpp b/Src/Vessel/DeltaGlider/AAPSubsys.cpp index ba6e20d1f..2663ea1bb 100644 --- a/Src/Vessel/DeltaGlider/AAPSubsys.cpp +++ b/Src/Vessel/DeltaGlider/AAPSubsys.cpp @@ -23,6 +23,9 @@ #include "InstrHsi.h" #include "meshres_p0.h" +using std::min; +using std::max; + static const float texw = (float)PANEL2D_TEXW; // texture width static const float texh = (float)PANEL2D_TEXH; // texture height static const int xofs = 742; @@ -194,8 +197,8 @@ bool AAP::ProcessMouse2D (int event, int mx, int my) mag = (dt < 1 ? 2 : dt < 2 ? 1 : 0); if (t-tp > 0.5-mag*0.2) { tp = t; - step = max(1,min(1e4,pow(10,floor(log10 (max(tgt[active_block],1)))-mag))); - tgt[active_block] = max(0,floor(tgt[active_block]/step)*step + scanmode*step); + step = max(1.0, min(1e4,pow(10,floor(log10 (max(tgt[active_block],1.0)))-mag))); + tgt[active_block] = max(0.0,floor(tgt[active_block]/step)*step + scanmode*step); if (active[active_block]) SetValue (active_block, tgt[active_block]); return true; } diff --git a/Src/Vessel/DeltaGlider/AerodynSubsys.cpp b/Src/Vessel/DeltaGlider/AerodynSubsys.cpp index e90e72c6e..114396f8d 100644 --- a/Src/Vessel/DeltaGlider/AerodynSubsys.cpp +++ b/Src/Vessel/DeltaGlider/AerodynSubsys.cpp @@ -18,6 +18,9 @@ #include "meshres_vc.h" #include "dg_vc_anim.h" +using std::min; +using std::max; + // ============================================================== // Aerodynamic control subsystem // ============================================================== @@ -101,7 +104,7 @@ bool AerodynSelector::IncMode () bool AerodynSelector::DecMode () { - DWORD mode = min (DG()->GetADCtrlMode(),2); + DWORD mode = min (DG()->GetADCtrlMode(),(DWORD)2); if (mode) { DG()->SetADCtrlMode (mode-1); return true; @@ -172,7 +175,7 @@ bool AerodynSelectorDial::Redraw2D (SURFHANDLE surf) static const float tx_dy = 43.0f; // texture block height static float tu[4] = {tx_x0/texw,(tx_x0+tx_dx)/texw,tx_x0/texw,(tx_x0+tx_dx)/texw}; - float dtu = (float)(min(vessel->GetADCtrlMode(),2)*40.0)/texw; + float dtu = (float)(min(vessel->GetADCtrlMode(),(DWORD)2)*40.0)/texw; for (int i = 0; i < 4; i++) grp->Vtx[vtxofs+i].tu = tu[i]+dtu; return false; diff --git a/Src/Vessel/DeltaGlider/DeltaGlider.cpp b/Src/Vessel/DeltaGlider/DeltaGlider.cpp index 6368ba8ee..8d5e710f8 100644 --- a/Src/Vessel/DeltaGlider/DeltaGlider.cpp +++ b/Src/Vessel/DeltaGlider/DeltaGlider.cpp @@ -37,6 +37,9 @@ #include #include +using std::min; +using std::max; + // ============================================================== // Global parameters // ============================================================== @@ -314,7 +317,7 @@ void DeltaGlider::PaintMarkings (SURFHANDLE tex) skp->SetTextAlign (oapi::Sketchpad::CENTER); char cbuf[32]; strncpy (cbuf, GetName(), 10); - int len = min(strlen(GetName()), 10); + int len = min(strlen(GetName()), (size_t)10); skp->Text (193, 10, cbuf, len); skp->Text (193, 74, cbuf, len); oapiReleaseFont(font1); diff --git a/Src/Vessel/DeltaGlider/FuelMfd.cpp b/Src/Vessel/DeltaGlider/FuelMfd.cpp index b8b8ec58f..5011275c6 100644 --- a/Src/Vessel/DeltaGlider/FuelMfd.cpp +++ b/Src/Vessel/DeltaGlider/FuelMfd.cpp @@ -16,6 +16,8 @@ #include "meshres_p0.h" #include "meshres_vc.h" +using std::max; + // ============================================================== // constants for texture coordinates diff --git a/Src/Vessel/DeltaGlider/HoverSubsys.cpp b/Src/Vessel/DeltaGlider/HoverSubsys.cpp index 2385d6e1b..77cb577f0 100644 --- a/Src/Vessel/DeltaGlider/HoverSubsys.cpp +++ b/Src/Vessel/DeltaGlider/HoverSubsys.cpp @@ -15,6 +15,9 @@ #include "meshres_vc.h" #include "dg_vc_anim.h" +using std::min; +using std::max; + // constants for texture coordinates static const float texw = (float)PANEL2D_TEXW; // texture width diff --git a/Src/Vessel/DeltaGlider/InstrAoa.cpp b/Src/Vessel/DeltaGlider/InstrAoa.cpp index dea1b5ed4..e6e897a73 100644 --- a/Src/Vessel/DeltaGlider/InstrAoa.cpp +++ b/Src/Vessel/DeltaGlider/InstrAoa.cpp @@ -16,6 +16,8 @@ #include "meshres_vc.h" #include "dg_vc_anim.h" +using std::min; + // ============================================================== InstrAOA::InstrAOA (VESSEL3 *v): PanelElement (v) diff --git a/Src/Vessel/DeltaGlider/InstrHsi.cpp b/Src/Vessel/DeltaGlider/InstrHsi.cpp index 1c5003e36..f66ea94cb 100644 --- a/Src/Vessel/DeltaGlider/InstrHsi.cpp +++ b/Src/Vessel/DeltaGlider/InstrHsi.cpp @@ -16,6 +16,8 @@ #include "meshres_p0.h" #include "dg_vc_anim.h" +using std::min; + // ============================================================== InstrHSI::InstrHSI (VESSEL3 *v): PanelElement (v) diff --git a/Src/Vessel/DeltaGlider/LightSubsys.cpp b/Src/Vessel/DeltaGlider/LightSubsys.cpp index 63f16f802..24b098c02 100644 --- a/Src/Vessel/DeltaGlider/LightSubsys.cpp +++ b/Src/Vessel/DeltaGlider/LightSubsys.cpp @@ -17,6 +17,9 @@ #include "meshres_vc.h" #include "dg_vc_anim.h" +using std::min; +using std::max; + // ============================================================== // Light control subsystem // ============================================================== diff --git a/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp b/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp index 4b5113cd1..d84467106 100644 --- a/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp +++ b/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp @@ -16,6 +16,9 @@ #include "meshres_vc.h" #include "dg_vc_anim.h" +using std::min; +using std::max; + // constants for texture coordinates static const float texw = (float)PANEL2D_TEXW; // texture width static const float texh = (float)PANEL2D_TEXH; // texture height diff --git a/Src/Vessel/DeltaGlider/MomentInd.cpp b/Src/Vessel/DeltaGlider/MomentInd.cpp index c97ad8fd8..22e714226 100644 --- a/Src/Vessel/DeltaGlider/MomentInd.cpp +++ b/Src/Vessel/DeltaGlider/MomentInd.cpp @@ -15,6 +15,8 @@ #include "meshres_p0.h" #include "meshres_vc.h" +using std::min; + // ============================================================== //SURFHANDLE AngRateIndicator::srf[3] = {0,0,0}; diff --git a/Src/Vessel/DeltaGlider/PressureSubsys.cpp b/Src/Vessel/DeltaGlider/PressureSubsys.cpp index 54dd81c7a..15fd95934 100644 --- a/Src/Vessel/DeltaGlider/PressureSubsys.cpp +++ b/Src/Vessel/DeltaGlider/PressureSubsys.cpp @@ -17,6 +17,9 @@ #include "meshres_vc.h" #include "dg_vc_anim.h" +using std::min; +using std::max; + // ============================================================== double PressureSubsystem::v_cabin = 24.0; diff --git a/Src/Vessel/DeltaGlider/ScramSubsys.cpp b/Src/Vessel/DeltaGlider/ScramSubsys.cpp index 6526dcb06..56de95e58 100644 --- a/Src/Vessel/DeltaGlider/ScramSubsys.cpp +++ b/Src/Vessel/DeltaGlider/ScramSubsys.cpp @@ -13,6 +13,9 @@ #include "meshres_p0.h" #include "meshres_vc.h" +using std::min; +using std::max; + // -------------------------------------------------------------- // constructor diff --git a/Src/Vessel/DeltaGlider/ThermalSubsys.cpp b/Src/Vessel/DeltaGlider/ThermalSubsys.cpp index 73c2524fb..b081dc160 100644 --- a/Src/Vessel/DeltaGlider/ThermalSubsys.cpp +++ b/Src/Vessel/DeltaGlider/ThermalSubsys.cpp @@ -19,6 +19,9 @@ #include "meshres_vc.h" #include "dg_vc_anim.h" +using std::min; +using std::max; + static const double sigma = 5.670e-8; // Boltzmann constant // heat capacity coefficients [J kg^-1 K^-1] diff --git a/Src/Vessel/Dragonfly/Dragonfly.cpp b/Src/Vessel/Dragonfly/Dragonfly.cpp index f53efe4ba..3f599c8c4 100644 --- a/Src/Vessel/Dragonfly/Dragonfly.cpp +++ b/Src/Vessel/Dragonfly/Dragonfly.cpp @@ -16,6 +16,10 @@ #include #include "internal.h" //#include "glstuff.cpp" + +using std::min; +using std::max; + HINSTANCE hDLL; double Lsim; diff --git a/Src/Vessel/Dragonfly/instruments.cpp b/Src/Vessel/Dragonfly/instruments.cpp index 9f5134e3f..413fbf296 100644 --- a/Src/Vessel/Dragonfly/instruments.cpp +++ b/Src/Vessel/Dragonfly/instruments.cpp @@ -11,6 +11,8 @@ #include "orbitersdk.h" #include "dragonfly.h" +using std::min; + instrument::instrument(int x, int y,Panel* i_parent) diff --git a/Src/Vessel/HST/HST.cpp b/Src/Vessel/HST/HST.cpp index cae8d2300..1604a68a1 100644 --- a/Src/Vessel/HST/HST.cpp +++ b/Src/Vessel/HST/HST.cpp @@ -16,6 +16,9 @@ #include "HST.h" #include +using std::min; +using std::max; + // ============================================================== // HST class implementation // ============================================================== diff --git a/Src/Vessel/Quadcopter/PropulsionSubsys.cpp b/Src/Vessel/Quadcopter/PropulsionSubsys.cpp index 4415c8169..c414d905f 100644 --- a/Src/Vessel/Quadcopter/PropulsionSubsys.cpp +++ b/Src/Vessel/Quadcopter/PropulsionSubsys.cpp @@ -3,6 +3,9 @@ #include "PropulsionSubsys.h" +using std::min; +using std::max; + // ============================================================== // Single-rotor implementation // ============================================================== @@ -255,7 +258,7 @@ void PropulsionSubsystem::HoldVspd(double vh_tgt) double dlvl_max = dt; if (fabs(dlvl) > dlvl_max) dlvl = (dlvl > 0.0 ? dlvl_max : -dlvl_max); - m_throttle = max(0, min(1.0, m_throttle + dlvl)); + m_throttle = max(0.0, min(1.0, m_throttle + dlvl)); } void PropulsionSubsystem::HoldAlt(double alt_tgt) diff --git a/Src/Vessel/ShuttleA/InstrVs.cpp b/Src/Vessel/ShuttleA/InstrVs.cpp index 0fe910034..66716b939 100644 --- a/Src/Vessel/ShuttleA/InstrVs.cpp +++ b/Src/Vessel/ShuttleA/InstrVs.cpp @@ -13,6 +13,8 @@ #include "InstrVs.h" #include "ShuttleA.h" +using std::min; + const int label_srcx = 103; const int wheel_srcx = 111; const float vtape_xcnt = 694.0f, vtape_ycnt = 76.0f; @@ -547,7 +549,7 @@ bool InstrVAcc::Redraw2D (SURFHANDLE surf) if (t > pt) { const double yscale = 6.2455; double vacc = (vspd-pvspd)/(t-pt); - yofs = -(float)((vacc >= 0.0 ? sqrt(min(40,vacc)) : -sqrt(min(40,-vacc))) * yscale); + yofs = -(float)((vacc >= 0.0 ? sqrt(min(40.0,vacc)) : -sqrt(min(40.0,-vacc))) * yscale); static const float y0[3] = {vtape_ycnt, vtape_ycnt-6, vtape_ycnt+6}; for (i = 0; i < 3; i++) grp->Vtx[vtxofs+i].y = y0[i] + yofs; diff --git a/Src/Vessel/ShuttleA/ShuttleA.cpp b/Src/Vessel/ShuttleA/ShuttleA.cpp index ad4d895da..931102398 100644 --- a/Src/Vessel/ShuttleA/ShuttleA.cpp +++ b/Src/Vessel/ShuttleA/ShuttleA.cpp @@ -35,6 +35,9 @@ #include #include +using std::min; +using std::max; + #define LOADBMP(id) (LoadBitmap (g_Param.hDLL, MAKEINTRESOURCE (id))) // ============================================================== @@ -2442,7 +2445,7 @@ void ShuttleA::PaintMarkings (SURFHANDLE tex) skp->SetTextAlign (oapi::Sketchpad::CENTER); char cbuf[32]; strncpy (cbuf, GetName(), 10); - int len = min(strlen(GetName()), 10); + int len = min(strlen(GetName()), (size_t)10); skp->Text (66, 37, cbuf, len); skp->Text (209, 25, cbuf, len); oapiReleaseFont(font1); diff --git a/Src/Vessel/ShuttleA/adiball.cpp b/Src/Vessel/ShuttleA/adiball.cpp index e63e514f7..ca69398b3 100644 --- a/Src/Vessel/ShuttleA/adiball.cpp +++ b/Src/Vessel/ShuttleA/adiball.cpp @@ -13,6 +13,9 @@ #include "adiball.h" #include "attref.h" +using std::min; +using std::max; + // Generic ADI texture parameters static const float texw = 512.0f; // ADI texture width static const float texh = 512.0f; // ADI texture height @@ -302,7 +305,7 @@ bool ADIBall::Redraw2D (SURFHANDLE surf) double tgtx, tgty; static const float yexofs[4] = {bb_cntx-needle_w2,bb_cntx+needle_w2,bb_cntx-needle_w2,bb_cntx+needle_w2}; static const float peyofs[4] = {bb_cnty+needle_w2,bb_cnty-needle_w2,bb_cnty+needle_w2,bb_cnty-needle_w2}; - const float erange = 42.0f; + const double erange = 42.0; int tgtflag; VECTOR3 euler_tgt; if (!aref->GetTgtEulerAngles (euler_tgt)) { diff --git a/Src/Vessel/ShuttleA/auxpodctrl.cpp b/Src/Vessel/ShuttleA/auxpodctrl.cpp index 8acf5bcc4..fe16f162f 100644 --- a/Src/Vessel/ShuttleA/auxpodctrl.cpp +++ b/Src/Vessel/ShuttleA/auxpodctrl.cpp @@ -12,6 +12,9 @@ #include "ShuttleA.h" #include "auxpodctrl.h" +using std::min; +using std::max; + #define STRICT 1 static const float texw = (float)PANEL2D_TEXW; @@ -273,7 +276,7 @@ bool AuxPodCtrl::ProcessMouse2D (int event, int mx, int my) double dangle = dt*POD_ROTREQUEST_SPEED; double pod_angle_ref = (ctrl & 1 ? pod_angle_cmd[0] : pod_angle_cmd[1]); if (mode == 1) pod_angle_ref = min (pod_angle_ref+dangle, PI); - else pod_angle_ref = max (pod_angle_ref-dangle, 0); + else pod_angle_ref = max (pod_angle_ref-dangle, 0.0); for (i = 0; i < 2; i++) if ((ctrl >> i) & 1) pod_angle_cmd[i] = pod_angle_ref; diff --git a/Src/Vessel/Solarsail/SailLua.cpp b/Src/Vessel/Solarsail/SailLua.cpp index 36a8af030..476e013d3 100644 --- a/Src/Vessel/Solarsail/SailLua.cpp +++ b/Src/Vessel/Solarsail/SailLua.cpp @@ -9,6 +9,9 @@ extern "C" { #include "Lua/lauxlib.h" } +using std::min; +using std::max; + // ========================================================================== // API function prototypes diff --git a/Utils/Pltex/Pltex.cpp b/Utils/Pltex/Pltex.cpp index 4b96179bd..13445f5e3 100644 --- a/Utils/Pltex/Pltex.cpp +++ b/Utils/Pltex/Pltex.cpp @@ -983,7 +983,7 @@ void CreateLocalArea () maxlvl++; scl *= 0.5; } - maxlvl = min (MAXLEVEL, maxlvl); // max. currently supported level + maxlvl = min ((int)MAXLEVEL, maxlvl); // max. currently supported level if (maxlvl < 9) FatalError ("Bitmap resolution insufficient for level 9"); if (maxlvl > 9) { cout << endl << "The bitmaps support resolutions up to level " << maxlvl << ".\n"; @@ -2189,11 +2189,11 @@ void ErodeLights (RGB *limg, Alpha *aimg, LONG imgw, LONG imgh) static RGB zero = {0,0,0}; LONG i, j, ii, jj, imin, imax, jmin, jmax; for (i = 0; i < imgh; i++) { - imin = max (0, i-1); + imin = max ((LONG)0, i-1); imax = min (imgh-1, i+1); for (j = 0; j < imgw; j++) { if (aimg[i*imgw+j] >= 128) { // water pixel - jmin = max (0, j-1); + jmin = max ((LONG)0, j-1); jmax = min (imgw-1, j+1); for (ii = imin; ii <= imax; ii++) for (jj = jmin; jj <= jmax; jj++) @@ -2314,7 +2314,7 @@ WORD CatMaskDDS (FILE *texf, RGB *img, Alpha *aimg, LONG imgw, LONG imgh) FILE *bmpf; BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; - int i, res, ddssize, fh; + int res, ddssize, fh; bool bopaque = false, btransparent = false; bool brgb = false, balpha = false; int nlight, nopaque, ntransparent; @@ -2325,7 +2325,7 @@ WORD CatMaskDDS (FILE *texf, RGB *img, Alpha *aimg, LONG imgw, LONG imgh) if (img) { // city-light texture provided // count light pixels - for (i = nlight = 0; i < imgw*imgh; i++) { + for (LONG i = nlight = 0; i < imgw*imgh; i++) { if ((int)img[i].r + (int)img[i].g + (int)img[i].b > 32*3) nlight++; //else @@ -2347,7 +2347,7 @@ WORD CatMaskDDS (FILE *texf, RGB *img, Alpha *aimg, LONG imgw, LONG imgh) if (aimg) { // land-water mask provided // make alpha binary black/white, and count opaque/transparent pixels - for (i = nopaque = ntransparent = 0; i < imgw*imgh; i++) { + for (LONG i = nopaque = ntransparent = 0; i < imgw*imgh; i++) { aimg[i] = 255 - aimg[i]; // invert if (aimg[i] < 128) aimg[i] = 0, ntransparent++; else aimg[i] = 255, nopaque++; @@ -2356,14 +2356,14 @@ WORD CatMaskDDS (FILE *texf, RGB *img, Alpha *aimg, LONG imgw, LONG imgh) btransparent = true; flag |= 2; // water present } else if (ntransparent) { // suppress transparent pixels - for (i = 0; i < imgw*imgh; i++) aimg[i] = 255; + for (LONG i = 0; i < imgw*imgh; i++) aimg[i] = 255; g_nsuppressed++; } if (nopaque > imgw*imgh * g_tol) { // # opaque pixels above threshold? flag |= 1; // land present bopaque = true; } else if (nopaque) { // suppress opaque pixels - for (i = 0; i < imgw*imgh; i++) aimg[i] = 0; + for (LONG i = 0; i < imgw*imgh; i++) aimg[i] = 0; g_nsuppressed++; } balpha = btransparent && bopaque; @@ -2377,12 +2377,12 @@ WORD CatMaskDDS (FILE *texf, RGB *img, Alpha *aimg, LONG imgw, LONG imgh) // remove lights from any water pixels including a 1-pixel border along // coastlines to avoid edge artefacts if (brgb && balpha) { - int imin, imax, ii, jmin, jmax, j, jj; - for (i = 0; i < imgh; i++) { - imin = max (0, i-1); + LONG imin, imax, ii, jmin, jmax, j, jj; + for (LONG i = 0; i < imgh; i++) { + imin = max ((LONG)0, i-1); imax = min (imgh-1, i+1); for (j = 0; j < imgw; j++) { - jmin = max (0, j-1); + jmin = max ((LONG)0, j-1); jmax = min (imgw-1, j+1); if (aimg[i*imgw+j] == 0) // water pixel for (ii = imin; ii <= imax; ii++) @@ -2406,7 +2406,7 @@ WORD CatMaskDDS (FILE *texf, RGB *img, Alpha *aimg, LONG imgw, LONG imgh) if (!bmpf) FatalError ("Could not open temporary alpha file."); fwrite (&bmfh, sizeof(BITMAPFILEHEADER), 1, bmpf); fwrite (&bmih, sizeof(BITMAPINFOHEADER), 1, bmpf); - for (i = 0; i < imgw*imgh; i++) { + for (LONG i = 0; i < imgw*imgh; i++) { RGB rgb; rgb.r = rgb.g = rgb.b = aimg[i]; fwrite (&rgb, 3, 1, bmpf); @@ -2800,7 +2800,7 @@ DWORD CopyDDS (FILE *ftgt, FILE *fsrc, DWORD idx, bool idx_is_ofs) mipsize[j] = s; mipbuf[j] = new BYTE[s]; s >>= 2; - s = max (s, 8); // Minimum texture size. This appears to be + s = max (s, (DWORD)8); // Minimum texture size. This appears to be // correct for DXT1, but may differ for other formats! } } @@ -2808,7 +2808,7 @@ DWORD CopyDDS (FILE *ftgt, FILE *fsrc, DWORD idx, bool idx_is_ofs) if (ddsd.dwFlags & DDSD_MIPMAPCOUNT) { for (j = 1, s = size; j < ddsd.dwMipMapCount; j++) { s >>= 2; - s = max (s, 8); + s = max (s, (DWORD)8); fread (mipbuf[j], s, 1, fsrc); } } @@ -2820,7 +2820,7 @@ DWORD CopyDDS (FILE *ftgt, FILE *fsrc, DWORD idx, bool idx_is_ofs) if (ddsd.dwFlags & DDSD_MIPMAPCOUNT) { for (j = 1, s = size; j < ddsd.dwMipMapCount; j++) { s >>= 2; - s = max (s, 8); + s = max (s, (DWORD)8); fwrite (mipbuf[j], s, 1, ftgt); tsize += s; } }