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