ODR protection for solar system states.
This commit is contained in:
@@ -13,60 +13,62 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
struct Coord
|
||||
namespace
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
struct Coord
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
std::strong_ordering operator <=> ( const Coord & ) const= default;
|
||||
};
|
||||
std::strong_ordering operator <=> ( const Coord & ) const= default;
|
||||
};
|
||||
|
||||
struct WorldState
|
||||
{
|
||||
DWORD ScanRetrieveMask[NUM_SCAN_TYPES];
|
||||
};
|
||||
struct WorldState
|
||||
{
|
||||
DWORD ScanRetrieveMask[NUM_SCAN_TYPES];
|
||||
};
|
||||
|
||||
struct WorldDescriptor
|
||||
{
|
||||
int planetNumber;
|
||||
int moonNumber; // -1 is world itself.
|
||||
struct WorldDescriptor
|
||||
{
|
||||
int planetNumber;
|
||||
int moonNumber; // -1 is world itself.
|
||||
|
||||
std::strong_ordering operator <=> ( const WorldDescriptor & ) const= default;
|
||||
};
|
||||
std::strong_ordering operator <=> ( const WorldDescriptor & ) const= default;
|
||||
};
|
||||
|
||||
using SolarSystemTable= std::map< WorldDescriptor, WorldState >;
|
||||
using GalaxyTable= std::map< Coord, SolarSystemTable >;
|
||||
using SolarSystemTable= std::map< WorldDescriptor, WorldState >;
|
||||
using GalaxyTable= std::map< Coord, SolarSystemTable >;
|
||||
|
||||
static auto &
|
||||
galaxy()
|
||||
{
|
||||
static GalaxyTable table;
|
||||
return table;
|
||||
}
|
||||
auto &
|
||||
galaxy()
|
||||
{
|
||||
static GalaxyTable table;
|
||||
return table;
|
||||
}
|
||||
|
||||
static auto
|
||||
getCurrentCoord()
|
||||
{
|
||||
const auto &star= *CurStarDescPtr;
|
||||
const Coord pos{ .x{ star.star_pt.x }, .y{ star.star_pt.y } };
|
||||
return pos;
|
||||
}
|
||||
auto
|
||||
getCurrentCoord()
|
||||
{
|
||||
const auto &star= *CurStarDescPtr;
|
||||
const Coord pos{ .x{ star.star_pt.x }, .y{ star.star_pt.y } };
|
||||
return pos;
|
||||
}
|
||||
|
||||
static auto &
|
||||
getCurrentWorldMasks()
|
||||
{
|
||||
const Coord pos= getCurrentCoord();
|
||||
auto &
|
||||
getCurrentWorldMasks()
|
||||
{
|
||||
const Coord pos= getCurrentCoord();
|
||||
|
||||
const int planet_index = (pSolarSysState->pBaseDesc->pPrevDesc
|
||||
- pSolarSysState->PlanetDesc);
|
||||
const int moon_index= (pSolarSysState->pOrbitalDesc->pPrevDesc
|
||||
== pSolarSysState->SunDesc)
|
||||
? -1
|
||||
: (pSolarSysState->pOrbitalDesc
|
||||
- pSolarSysState->MoonDesc);
|
||||
const int planet_index = (pSolarSysState->pBaseDesc->pPrevDesc
|
||||
- pSolarSysState->PlanetDesc);
|
||||
const int moon_index= (pSolarSysState->pOrbitalDesc->pPrevDesc
|
||||
== pSolarSysState->SunDesc)
|
||||
? -1
|
||||
: (pSolarSysState->pOrbitalDesc
|
||||
- pSolarSysState->MoonDesc);
|
||||
|
||||
return galaxy()[ pos ][ { planet_index, moon_index } ].ScanRetrieveMask;
|
||||
return galaxy()[ pos ][ { planet_index, moon_index } ].ScanRetrieveMask;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
||||
Reference in New Issue
Block a user