ODR protection for solar system states.

This commit is contained in:
2024-05-03 03:22:23 -04:00
parent d99e5cf176
commit 902048134c
+24 -22
View File
@@ -13,49 +13,50 @@
#include <vector>
#include <map>
struct Coord
namespace
{
struct Coord
{
int x;
int y;
std::strong_ordering operator <=> ( const Coord & ) const= default;
};
};
struct WorldState
{
struct WorldState
{
DWORD ScanRetrieveMask[NUM_SCAN_TYPES];
};
};
struct WorldDescriptor
{
struct WorldDescriptor
{
int planetNumber;
int moonNumber; // -1 is world itself.
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()
{
auto &
galaxy()
{
static GalaxyTable table;
return table;
}
}
static auto
getCurrentCoord()
{
auto
getCurrentCoord()
{
const auto &star= *CurStarDescPtr;
const Coord pos{ .x{ star.star_pt.x }, .y{ star.star_pt.y } };
return pos;
}
}
static auto &
getCurrentWorldMasks()
{
auto &
getCurrentWorldMasks()
{
const Coord pos= getCurrentCoord();
const int planet_index = (pSolarSysState->pBaseDesc->pPrevDesc
@@ -67,6 +68,7 @@ getCurrentWorldMasks()
- pSolarSysState->MoonDesc);
return galaxy()[ pos ][ { planet_index, moon_index } ].ScanRetrieveMask;
}
}
extern "C"