Skip to content

Commit

Permalink
Merge pull request #357 from dimitry-ishenko-orbiter/cleanup
Browse files Browse the repository at this point in the history
Code clean-up for C++20 conformance
  • Loading branch information
Xyon authored Jul 8, 2023
2 parents 1c06c81 + 632f1c4 commit 0530f27
Show file tree
Hide file tree
Showing 194 changed files with 1,379 additions and 1,390 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ cmake_minimum_required(VERSION 3.19)
# Set the project name
project (Orbiter VERSION 21.7.24)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Some functions to simplify debugging CMake scripts
include(CMakePrintHelpers)

Expand Down
28 changes: 14 additions & 14 deletions OVP/D3D7Client/D3D7Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "D3D7Config.h"
#include "orbitersdk.h"

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

// ==============================================================
// default values
Expand Down Expand Up @@ -56,17 +56,17 @@ bool D3D7Config::ReadParams ()

FILEHANDLE hFile = oapiOpenFile (cfgfile, FILE_IN, ROOT);
if (!hFile) return false;
if (oapiReadItem_int (hFile, "PlanetPreloadMode", i))
if (oapiReadItem_int (hFile, (char*)"PlanetPreloadMode", i))
PlanetPreloadMode = max (0, min (1, i));
if (oapiReadItem_int (hFile, "PlanetTexLoadFreq", i))
if (oapiReadItem_int (hFile, (char*)"PlanetTexLoadFreq", i))
PlanetLoadFrequency = max (1, min (1000, i));
if (oapiReadItem_int (hFile, "PlanetMipmapMode", i))
if (oapiReadItem_int (hFile, (char*)"PlanetMipmapMode", i))
PlanetMipmapMode = max (0, min (2, i));
if (oapiReadItem_int (hFile, "PlanetAnisoMode", i))
if (oapiReadItem_int (hFile, (char*)"PlanetAnisoMode", i))
PlanetAnisoMode = max (1, min (16, i));
if (oapiReadItem_int (hFile, "PlanetTileLoadFlags", i))
if (oapiReadItem_int (hFile, (char*)"PlanetTileLoadFlags", i))
PlanetTileLoadFlags = max(1, min (3, i));
if (oapiReadItem_float (hFile, "PlanetMipmapBias", d))
if (oapiReadItem_float (hFile, (char*)"PlanetMipmapBias", d))
PlanetMipmapBias = max (-1.0, min (1.0, d));
oapiCloseFile (hFile, FILE_IN);
return true;
Expand All @@ -75,11 +75,11 @@ bool D3D7Config::ReadParams ()
void D3D7Config::WriteParams ()
{
FILEHANDLE hFile = oapiOpenFile (cfgfile, FILE_OUT, ROOT);
oapiWriteItem_int (hFile, "PlanetPreloadMode", PlanetPreloadMode);
oapiWriteItem_int (hFile, "PlanetTexLoadFreq", PlanetLoadFrequency);
oapiWriteItem_int (hFile, "PlanetAnisoMode", PlanetAnisoMode);
oapiWriteItem_int (hFile, "PlanetMipmapMode", PlanetMipmapMode);
oapiWriteItem_int (hFile, "PlanetTileLoadFlags", PlanetTileLoadFlags);
oapiWriteItem_float (hFile, "PlanetMipmapBias", PlanetMipmapBias);
oapiWriteItem_int (hFile, (char*)"PlanetPreloadMode", PlanetPreloadMode);
oapiWriteItem_int (hFile, (char*)"PlanetTexLoadFreq", PlanetLoadFrequency);
oapiWriteItem_int (hFile, (char*)"PlanetAnisoMode", PlanetAnisoMode);
oapiWriteItem_int (hFile, (char*)"PlanetMipmapMode", PlanetMipmapMode);
oapiWriteItem_int (hFile, (char*)"PlanetTileLoadFlags", PlanetTileLoadFlags);
oapiWriteItem_float (hFile, (char*)"PlanetMipmapBias", PlanetMipmapBias);
oapiCloseFile (hFile, FILE_OUT);
}
}
12 changes: 4 additions & 8 deletions OVP/D3D7Client/D3D7Extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

char *D3D7ClientCfg::Name ()
{
static char *name = "D3D7 Graphics Configuration";
return name;
return (char*)"D3D7 Graphics Configuration";
}

char *D3D7ClientCfg::Description ()
{
static char *desc = "Configure the D3D7 graphics client plugin.\r\n\r\nThis allows to fine-tune rendering options and visual quality.";
return desc;
return (char*)"Configure the D3D7 graphics client plugin.\r\n\r\nThis allows to fine-tune rendering options and visual quality.";
}


Expand All @@ -39,14 +37,12 @@ D3D7PlanetRenderCfg::D3D7PlanetRenderCfg (oapi::D3D7Client *_gc)

char *D3D7PlanetRenderCfg::Name ()
{
static char *name = "Planet Rendering Options";
return name;
return (char*)"Planet Rendering Options";
}

char *D3D7PlanetRenderCfg::Description ()
{
static char *desc = "Configure the rendering options for planets and other celestial objects.";
return desc;
return (char*)"Configure the rendering options for planets and other celestial objects.";
}

bool D3D7PlanetRenderCfg::clbkOpen (HWND hLaunchpad)
Expand Down
4 changes: 2 additions & 2 deletions OVP/D3D7Client/RingMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RingManager {

protected:
D3D7Mesh *CreateRing (double irad, double orad, int nsect);
DWORD RingManager::LoadTextures ();
DWORD LoadTextures ();

private:
static const oapi::D3D7Client *gc;
Expand All @@ -54,4 +54,4 @@ class RingManager {
double irad, orad;
};

#endif // !__RINGMGR_H
#endif // !__RINGMGR_H
6 changes: 3 additions & 3 deletions OVP/D3D7Client/TileMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ typedef struct {
class D3D7Config;
class vPlanet;

void ApplyPatchTextureCoordinates (VBMESH &mesh, LPDIRECT3DVERTEXBUFFER7 vtx, const TEXCRDRANGE &range);

class TileManager {
friend class TileBuffer;
friend class CSphereManager;
Expand Down Expand Up @@ -192,8 +194,6 @@ class TileManager {
double objsize; // planet radius
bool bfog; // distance fog flag
} RenderParam;

friend void ApplyPatchTextureCoordinates (VBMESH &mesh, LPDIRECT3DVERTEXBUFFER7 vtx, const TEXCRDRANGE &range);
};


Expand Down Expand Up @@ -243,4 +243,4 @@ class TileBuffer {
} loadqueue[MAXQUEUE];
};

#endif // !__TILEMGR_H
#endif // !__TILEMGR_H
2 changes: 1 addition & 1 deletion OVP/D3D7Client/VObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void vObject::GlobalInit (const D3D7Client *gclient)
gc = gclient;

for (int i = 0; i < 3; i++) {
static char *fname[3] = {"Ball.dds","Ball2.dds","Ball3.dds"};
static const char *fname[3] = {"Ball.dds","Ball2.dds","Ball3.dds"};
gc->GetTexMgr()->LoadTexture (fname[i], blobtex+i, 0);
}
}
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 @@ -15,6 +15,7 @@
#ifndef __TILEMGR2_IMP_HPP
#define __TILEMGR2_IMP_HPP

#include "Camera.h"
#include "tilemgr2.h"

// -----------------------------------------------------------------------
Expand Down Expand Up @@ -292,4 +293,4 @@ void TileManager2<TileType>::CheckCoverage (const QuadTreeNode<TileType> *node,
}
}

#endif // !__TILEMGR2_IMP_HPP
#endif // !__TILEMGR2_IMP_HPP
4 changes: 2 additions & 2 deletions OVP/D3D7Client/ztreemgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class TreeFileHeader {

public:
TreeFileHeader();
size_t TreeFileHeader::fwrite(FILE *f);
bool TreeFileHeader::fread(FILE *f);
size_t fwrite(FILE *f);
bool fread(FILE *f);

private:
BYTE magic[4]; // file ID and version
Expand Down
42 changes: 21 additions & 21 deletions OVP/D3D9Client/AtmoControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void Create()
vObj = NULL;
hDlg = NULL;

dwCmd = oapiRegisterCustomCmd("D3D9 Atmospheric Controls", "This dialog allows to control various atmospheric parameters and effects", OpenDlgClbk, NULL);
dwCmd = oapiRegisterCustomCmd((char*)"D3D9 Atmospheric Controls", (char*)"This dialog allows to control various atmospheric parameters and effects", OpenDlgClbk, NULL);

memset(Slider,0,sizeof(Slider));

Expand Down Expand Up @@ -238,30 +238,30 @@ void OpenDlgClbk(void *context)
ConfigSlider(IDC_ATM_AUX4, 0.0, 8.0); // Mie Phase-B
ConfigSlider(IDC_ATM_AUX5, 0.0, 5.0, 8); // Clouds intensity
// -------------------------------------------------------
CreateToolTip(IDC_ATM_TW_DST, hDlg, "Light travel distance behind terminator");
CreateToolTip(IDC_ATM_GREEN, hDlg, "Green wave lenght. (Green balance)");
CreateToolTip(IDC_ATM_TW_BRI, hDlg, "Terrain brightness during twilight");
CreateToolTip(IDC_ATM_RPOW, hDlg, "Main control for atmospheric rayleigh color composition (4.0 for the Earth)");
CreateToolTip(IDC_ATM_MPOW, hDlg, "Main control for atmospheric mie color composition");
CreateToolTip(IDC_ATM_HEIGHT, hDlg, "Atmosphere Ray scale height (7km - 9km for the Earth)");
CreateToolTip(IDC_ATM_M_HEIGHT, hDlg, "Atmosphere Mie scale height (0.6km - 2km for the Earth)");
CreateToolTip(IDC_ATM_TW_DST, hDlg, (char*)"Light travel distance behind terminator");
CreateToolTip(IDC_ATM_GREEN, hDlg, (char*)"Green wave lenght. (Green balance)");
CreateToolTip(IDC_ATM_TW_BRI, hDlg, (char*)"Terrain brightness during twilight");
CreateToolTip(IDC_ATM_RPOW, hDlg, (char*)"Main control for atmospheric rayleigh color composition (4.0 for the Earth)");
CreateToolTip(IDC_ATM_MPOW, hDlg, (char*)"Main control for atmospheric mie color composition");
CreateToolTip(IDC_ATM_HEIGHT, hDlg, (char*)"Atmosphere Ray scale height (7km - 9km for the Earth)");
CreateToolTip(IDC_ATM_M_HEIGHT, hDlg, (char*)"Atmosphere Mie scale height (0.6km - 2km for the Earth)");
// -------------------------------------------------------
CreateToolTip(IDC_ATM_TRB, hDlg, "Terrain/Ocean brightness control (default 1.0)");
CreateToolTip(IDC_ATM_TRGAMMA, hDlg, "Terrain/Ocean gamma control value (default 1.0)");
CreateToolTip(IDC_ATM_TRLIGHTSHAD, hDlg, "Terrain light and shadow boost");
CreateToolTip(IDC_ATM_TRB, hDlg, (char*)"Terrain/Ocean brightness control (default 1.0)");
CreateToolTip(IDC_ATM_TRGAMMA, hDlg, (char*)"Terrain/Ocean gamma control value (default 1.0)");
CreateToolTip(IDC_ATM_TRLIGHTSHAD, hDlg, (char*)"Terrain light and shadow boost");
// -------------------------------------------------------
CreateToolTip(IDC_ATM_RAY, hDlg, "Overall control for rayleigh scattering (i.e. Haze stickness, atmosphere transparency, optical depth");
CreateToolTip(IDC_ATM_IN, hDlg, "Rayleigh in-scatter out-scatter ratio (1.0 nominal)");
CreateToolTip(IDC_ATM_RPHASE, hDlg, "Ambient light level for buildings");
CreateToolTip(IDC_ATM_RAY, hDlg, (char*)"Overall control for rayleigh scattering (i.e. Haze stickness, atmosphere transparency, optical depth");
CreateToolTip(IDC_ATM_IN, hDlg, (char*)"Rayleigh in-scatter out-scatter ratio (1.0 nominal)");
CreateToolTip(IDC_ATM_RPHASE, hDlg, (char*)"Ambient light level for buildings");
// -------------------------------------------------------
CreateToolTip(IDC_ATM_MIE, hDlg, "Overall scale factor for mie scattering. (Mie-particle density)");
CreateToolTip(IDC_ATM_MPHASE, hDlg, "Directional strength of Henyey-Greenstein phase function");
CreateToolTip(IDC_ATM_MIEIN, hDlg, "Mie in-scatter out-scatter ratio (1.0 nominal)");
CreateToolTip(IDC_ATM_MIE, hDlg, (char*)"Overall scale factor for mie scattering. (Mie-particle density)");
CreateToolTip(IDC_ATM_MPHASE, hDlg, (char*)"Directional strength of Henyey-Greenstein phase function");
CreateToolTip(IDC_ATM_MIEIN, hDlg, (char*)"Mie in-scatter out-scatter ratio (1.0 nominal)");
// -------------------------------------------------------
CreateToolTip(IDC_ATM_AUX2, hDlg, "Altitude for cloud lighting calculations");
CreateToolTip(IDC_ATM_AUX3, hDlg, "'HDR' Exposure factor");
CreateToolTip(IDC_ATM_AUX4, hDlg, "Omnidirectional mie scattering scale factor");
CreateToolTip(IDC_ATM_AUX5, hDlg, "[Dual purpose] Clouds intensity [on surface]. Multiscatter light level [on orbit]");
CreateToolTip(IDC_ATM_AUX2, hDlg, (char*)"Altitude for cloud lighting calculations");
CreateToolTip(IDC_ATM_AUX3, hDlg, (char*)"'HDR' Exposure factor");
CreateToolTip(IDC_ATM_AUX4, hDlg, (char*)"Omnidirectional mie scattering scale factor");
CreateToolTip(IDC_ATM_AUX5, hDlg, (char*)"[Dual purpose] Clouds intensity [on surface]. Multiscatter light level [on orbit]");

SendDlgItemMessageA(hDlg, IDC_ATM_MODE, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageA(hDlg, IDC_ATM_MODE, CB_ADDSTRING, 0, (LPARAM)"Auto");
Expand Down
4 changes: 2 additions & 2 deletions OVP/D3D9Client/CloudMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ void CloudManager::RenderTile (int lvl, int hemisp, int ilat, int nlat, int ilng
VBMESH &mesh = PATCH_TPL[lvl][ilat]; // patch template

if (range.tumin == 0 && range.tumax == 1) {
HR(FX->SetVector(eTexOff, &D3DXVECTOR4(1.0f, 0.0f, 1.0f, 0.0f)));
HR(FX->SetVector(eTexOff, ptr(D3DXVECTOR4(1.0f, 0.0f, 1.0f, 0.0f))));
}
else {
float tuscale = range.tumax-range.tumin, tuofs = range.tumin;
float tvscale = range.tvmax-range.tvmin, tvofs = range.tvmin;
HR(FX->SetVector(eTexOff, &D3DXVECTOR4(tuscale,tuofs,tvscale,tvofs)));
HR(FX->SetVector(eTexOff, ptr(D3DXVECTOR4(tuscale,tuofs,tvscale,tvofs))));
}
HR(FX->SetMatrix(eW, &mWorld));
HR(FX->SetTexture(eTex0, tex)); // Diffuse Texture
Expand Down
22 changes: 11 additions & 11 deletions OVP/D3D9Client/D3D9Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,26 +708,26 @@ void D3D9Client::SketchPadTest()
pSkp->QuickPen(0xA0000000, 3.0f);
pSkp->PushWorldTransform();

pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos0);
pSkp->SetWorldScaleTransform2D(ptr(FVECTOR2(100.0f, 100.0f)), &pos0);
pSkp->DrawPoly(hColors);
pSkp->DrawPoly(hOutline);

pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos1);
pSkp->SetWorldScaleTransform2D(ptr(FVECTOR2(100.0f, 100.0f)), &pos1);
pSkp->DrawPoly(hOutline2);

pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos2);
pSkp->SetWorldScaleTransform2D(ptr(FVECTOR2(100.0f, 100.0f)), &pos2);
pSkp->DrawPoly(hStrip);

pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos3);
pSkp->SetWorldScaleTransform2D(ptr(FVECTOR2(100.0f, 100.0f)), &pos3);
pSkp->DrawPoly(hStrip2);

pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos4);
pSkp->SetWorldScaleTransform2D(ptr(FVECTOR2(100.0f, 100.0f)), &pos4);
pSkp->QuickPen(0xFF000000, 25.0f);
pSkp->DrawPoly(hOutline);

hSrc = clbkLoadSurface("generic/noisep.dds", OAPISURFACE_TEXTURE);

pSkp->SetWorldScaleTransform2D(&FVECTOR2(1.0f, 1.0f), &pos5);
pSkp->SetWorldScaleTransform2D(ptr(FVECTOR2(1.0f, 1.0f)), &pos5);

FVECTOR2 pt[4];
pt[0] = FVECTOR2(-100.0f, -100.0f);
Expand Down Expand Up @@ -823,7 +823,7 @@ void D3D9Client::clbkCloseSession(bool fastclose)
void D3D9Client::clbkDestroyRenderWindow (bool fastclose)
{
_TRACE;
oapiWriteLog("D3D9: [Destroy Render Window Called]");
oapiWriteLog((char*)"D3D9: [Destroy Render Window Called]");
LogAlw("============= clbkDestroyRenderWindow ===========");

#ifdef _NVAPI_H
Expand Down Expand Up @@ -986,7 +986,7 @@ void D3D9Client::PushSketchpad(SURFHANDLE surf, D3D9Pad *pSkp) const

void D3D9Client::PushRenderTarget(LPDIRECT3DSURFACE9 pColor, LPDIRECT3DSURFACE9 pDepthStencil, int code) const
{
static char *labels[] = { "NULL", "MAIN", "ENV", "CUSTOMCAM", "SHADOWMAP", "PICK", "SKETCHPAD", "OVERLAY" };
static const char *labels[] = { "NULL", "MAIN", "ENV", "CUSTOMCAM", "SHADOWMAP", "PICK", "SKETCHPAD", "OVERLAY" };

RenderTgtData data;
data.pColor = pColor;
Expand Down Expand Up @@ -1025,7 +1025,7 @@ void D3D9Client::AlterRenderTarget(LPDIRECT3DSURFACE9 pColor, LPDIRECT3DSURFACE9

void D3D9Client::PopRenderTargets() const
{
static char *labels[] = { "NULL", "MAIN", "ENV", "CUSTOMCAM", "SHADOWMAP", "PICK", "SKETCHPAD", "OVERLAY" };
static const char *labels[] = { "NULL", "MAIN", "ENV", "CUSTOMCAM", "SHADOWMAP", "PICK", "SKETCHPAD", "OVERLAY" };

assert(RenderStack.empty() == false);

Expand Down Expand Up @@ -2324,7 +2324,7 @@ bool D3D9Client::clbkScaleBlt (SURFHANDLE tgt, DWORD tgtx, DWORD tgty, DWORD tgt
SURFHANDLE src, DWORD srcx, DWORD srcy, DWORD srcw, DWORD srch, DWORD flag) const
{

if (src==NULL) { oapiWriteLog("ERROR: oapiBlt() Source surface is NULL"); return false; }
if (src==NULL) { oapiWriteLog((char*)"ERROR: oapiBlt() Source surface is NULL"); return false; }

if (tgt==NULL) tgt = pFramework->GetBackBufferHandle();

Expand Down Expand Up @@ -2893,7 +2893,7 @@ void D3D9Client::SplashScreen()
SetTextColor(hDC, 0xE0A0A0);
SetBkMode(hDC,TRANSPARENT);

char *months[]={"???","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","???"};
const char *months[]={"???","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","???"};

DWORD d = oapiGetOrbiterVersion();
DWORD y = d/10000; d-=y*10000;
Expand Down
Loading

0 comments on commit 0530f27

Please sign in to comment.