Skip to content

Commit

Permalink
- Removed 'register' keyword. fixed link warnings, replaced prt() fun…
Browse files Browse the repository at this point in the history
…ction with '&' macro, set default to C++17
  • Loading branch information
jarmonik committed Jul 24, 2023
1 parent 09baae4 commit c4c7be5
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ 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_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

#Add /permissive if using C++20 or higher
#add_compile_options(/permissive)

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

Expand Down
6 changes: 3 additions & 3 deletions OVP/D3D9Client/D3D9Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,9 +1156,9 @@ LPDIRECT3DVERTEXSHADER9 CompileVertexShader(LPDIRECT3DDEVICE9 pDev, const char *
const char *RemovePath(const char *in)
{
int len = lstrlen(in);
const char *ptr = in;
for (int i=0;i<len;i++) if (in[i]=='\\' || in[i]=='/') ptr = &in[i+1];
return ptr;
const char *cptr = in;
for (int i=0;i<len;i++) if (in[i]=='\\' || in[i]=='/') cptr = &in[i+1];
return cptr;
}

// ============================================================================
Expand Down
9 changes: 7 additions & 2 deletions OVP/D3D9Client/D3D9Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ const char *_PTR(const void *p);

// helper function to get address of a temporary
// NB: use with caution
template<typename T>
T* ptr(T&& x) { return &x; }


// Required only with c++20 without /permissive flag
// template<typename T>
// T* ptr(T&& x) { return &x; }

#define ptr & // use for faster code

// ------------------------------------------------------------------------------------
// Vertex Declaration equal to NTVERTEX
Expand Down
4 changes: 2 additions & 2 deletions OVP/D3D9Client/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ MeshShader::PSBools MeshShader::ps_bools = {};

int compare_lights(const void * a, const void * b)
{
register float fa = static_cast<const _LightList*>(a)->illuminace;
register float fb = static_cast<const _LightList*>(b)->illuminace;
float fa = static_cast<const _LightList*>(a)->illuminace;
float fb = static_cast<const _LightList*>(b)->illuminace;
if (fa < fb * 0.9995f) return 1;
if (fa > fb * 1.0005f) return -1;
return 0;
Expand Down
4 changes: 2 additions & 2 deletions OVP/D3D9Client/TileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ bool TileManager::LoadTileData ()

int compare_idx (const void *el1, const void *el2)
{
register const IDXLIST *idx1 = static_cast<const IDXLIST*>(el1);
register const IDXLIST *idx2 = static_cast<const IDXLIST*>(el2);
const IDXLIST *idx1 = static_cast<const IDXLIST*>(el1);
const IDXLIST *idx2 = static_cast<const IDXLIST*>(el2);
return (idx1->ofs < idx2->ofs ? -1 : idx1->ofs > idx2->ofs ? 1 : 0);
}

Expand Down
6 changes: 3 additions & 3 deletions OVP/D3D9Client/samples/DrawOrbits/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const char *ValueToText(double real, int digits)
const char *k2 = { "M" };
const char *k3 = { "G" };
const char *k5 = { "m" };
const char *k6 = { "µ" };
const char *k6 = { "µ" };
const char *k7 = { "T" };

n = (int)floor(log10(v)) + 1;
Expand Down Expand Up @@ -89,7 +89,7 @@ const char *AngleToText(double deg, int digits)
if (f >= 360.0) f = 0.0;
if (deg<0) f = -f;

sprintf_s(ValueToText_Str, 30, "%1.*f°", digits, f);
sprintf_s(ValueToText_Str, 30, "%1.*f°", digits, f);

return ValueToText_Str;
}
Expand Down Expand Up @@ -364,7 +364,7 @@ double mna2eca(double mna, double ecc)
{

// iterative calculation of eccentric anomaly from mean anomaly
register double eca, m, x;
double eca, m, x;
int i;

if (ecc<1.0) {
Expand Down
2 changes: 2 additions & 0 deletions Src/Orbiter/CelSphere.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Martin Schweiger
// Licensed under the MIT License

#define OAPI_IMPLEMENTATION

#include "CelSphere.h"
#include "Scene.h"
#include "Camera.h"
Expand Down

0 comments on commit c4c7be5

Please sign in to comment.