Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable min/max macros from windows.h #356

Merged
merged 4 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 3 additions & 2 deletions OVP/D3D7Client/CSphereMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "Camera.h"
#include "Texture.h"
#include "D3D7Config.h"

#include <algorithm>
using std::min;
using namespace oapi;

// =======================================================================
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion OVP/D3D7Client/CelSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "Scene.h"
#include "Camera.h"
#include "Texture.h"
#include <algorithm>
using std::min;

#define NSEG 64 // number of segments in celestial grid lines

Expand Down Expand Up @@ -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);
}

// ==============================================================
Expand Down
2 changes: 2 additions & 0 deletions OVP/D3D7Client/CloudMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "CloudMgr.h"
#include "VPlanet.h"
#include "Texture.h"
#include <algorithm>
using std::min;

using namespace oapi;

Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D7Client/D3D7Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

#include "D3D7Config.h"
#include "orbitersdk.h"
#include <algorithm>
using std::min;
using std::max;

static const char *cfgfile = "D3D7Client.cfg";

Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D7Client/D3D7Extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "D3D7Extra.h"
#include "D3D7Config.h"
#include "resource.h"
#include <algorithm>

using std::min;

char *D3D7ClientCfg::Name ()
{
Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D7Client/HazeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "HazeMgr.h"
#include "VPlanet.h"
#include "Texture.h"
#include <algorithm>
using std::min;
using std::max;

using namespace oapi;

Expand Down
10 changes: 7 additions & 3 deletions OVP/D3D7Client/Particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include "Camera.h"
#include "Texture.h"
#include <stdio.h>
#include <algorithm>

using std::min;
using std::max;

static bool needsetup = true;
static VERTEX_XYZ_TEX evtx[MAXPARTICLE*4]; // vertex list for emissive trail (no normals)
Expand Down Expand Up @@ -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)));
}
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions OVP/D3D7Client/RingMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define D3D_OVERLOADS
#include "RingMgr.h"
#include "Texture.h"
#include <algorithm>
using std::min;

using namespace oapi;

Expand Down
2 changes: 2 additions & 0 deletions OVP/D3D7Client/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "VVessel.h"
#include "VBase.h"
#include "Particle.h"
#include <algorithm>
using std::min;

using namespace oapi;

Expand Down
2 changes: 2 additions & 0 deletions OVP/D3D7Client/SurfMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include "SurfMgr.h"
#include "VPlanet.h"
#include "Texture.h"
#include <algorithm>

using std::min;
using namespace oapi;

int nrender[15]; // temporary
Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D7Client/TileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
#include "VPlanet.h"
#include "Texture.h"
#include "D3D7Config.h"
#include <algorithm>

using std::min;
using std::max;
using namespace oapi;

// Max supported patch resolution level
Expand Down
8 changes: 6 additions & 2 deletions OVP/D3D7Client/VBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include "VBase.h"
#include "TileMgr.h"
#include "D3D7Client.h"
#include <algorithm>

using std::min;
using std::max;

vBase::vBase (OBJHANDLE _hObj, const Scene *scene): vObject (_hObj, scene)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion OVP/D3D7Client/VObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "D3D7Util.h"
#include <algorithm>

using std::min;
using std::max;
using namespace oapi;

// Initialisation of static members
Expand Down Expand Up @@ -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));

Expand Down
13 changes: 8 additions & 5 deletions OVP/D3D7Client/VPlanet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
#include "CloudMgr.h"
#include "HazeMgr.h"
#include "RingMgr.h"
#include <algorithm>

using std::min;
using std::max;
using namespace oapi;

// ==============================================================
Expand All @@ -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);
Expand Down Expand Up @@ -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<CloudTile> (this, maxlvl, 32);
}
} else {
Expand Down Expand Up @@ -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)));
}
}

Expand Down Expand Up @@ -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;
}
7 changes: 5 additions & 2 deletions OVP/D3D7Client/VVessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#include "VVessel.h"
#include "MeshMgr.h"
#include "Texture.h"
#include <algorithm>

using std::min;
using std::max;
using namespace oapi;

// ==============================================================
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions OVP/D3D7Client/cloudmgr2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "cloudmgr2.h"
#include "Texture.h"
#include "Camera.h"
#include <algorithm>

using std::min;
using std::max;

// =======================================================================
// =======================================================================
Expand Down
4 changes: 4 additions & 0 deletions OVP/D3D7Client/surfmgr2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "tilelabel.h"
#include "Texture.h"
#include "Camera.h"
#include <algorithm>

using std::min;
using std::max;

// =======================================================================

Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D7Client/tilelabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#include "camera.h"
#include <limits>
#include <sstream>
#include <algorithm>

using std::min;
using std::max;
extern Orbiter *g_pOrbiter;
extern Camera *g_camera;

Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D7Client/tilemgr2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include "Texture.h"
#include "Camera.h"
#include "D3D7Config.h"
#include <algorithm>

using std::max;

// =======================================================================
// Externals
Expand Down
3 changes: 2 additions & 1 deletion OVP/D3D7Client/tilemgr2_imp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "Camera.h"
#include "tilemgr2.h"
#include <algorithm>

// -----------------------------------------------------------------------

Expand Down Expand Up @@ -129,7 +130,7 @@ void TileManager2Base::ProcessNode (QuadTreeNode<TileType> *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);
}

Expand Down
2 changes: 2 additions & 0 deletions OVP/D3D9Client/AABBUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <xnamath.h>
#pragma warning(pop)

using std::min;

// =================================================================================================================================
//
bool SolveLUSystem(int n, double *A, double *b, double *x, double *det)
Expand Down
2 changes: 1 addition & 1 deletion OVP/D3D9Client/CSphereMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion OVP/D3D9Client/CelSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "D3D9Pad.h"
#include "AABBUtil.h"

using std::min;

#define NSEG 64 // number of segments in celestial grid lines

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion OVP/D3D9Client/D3D9Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading