Pioneer
CustomSystem.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _CUSTOMSYSTEM_H
5 #define _CUSTOMSYSTEM_H
6 
7 #include "Color.h"
8 #include "Polit.h"
9 #include "galaxy/SystemBody.h"
10 
11 #include "fixed.h"
12 #include "vector3.h"
13 
14 class Faction;
15 class Galaxy;
16 
18 public:
21 
22  std::string name;
24  fixed radius; // in earth radii for planets, sol radii for stars (equatorial radius)
25  fixed aspectRatio; // the ratio between equatorial radius and polar radius for bodies flattened due to equatorial bulge (1.0 to infinity)
26  fixed mass; // earth masses or sol masses
27  int averageTemp; // kelvin
28  fixed semiMajorAxis; // in AUs
31  fixed orbitalPhaseAtStart; // mean anomaly at start 0 to 2 pi
33  // for orbiting things, latitude = inclination
34  float latitude, longitude; // radians
35  fixed rotationPeriod; // in days
37  fixed axialTilt; // in radians
38  std::string heightMapFilename;
40  std::vector<CustomSystemBody *> children;
41 
42  /* composition */
43  fixed metallicity; // (crust) 0.0 = light (Al, SiO2, etc), 1.0 = heavy (Fe, heavy metals)
44  fixed volatileGas; // 1.0 = earth atmosphere density
45  fixed volatileLiquid; // 1.0 = 100% ocean cover (earth = 70%)
46  fixed volatileIces; // 1.0 = 100% ice cover (earth = 3%)
47  fixed volcanicity; // 0 = none, 1.0 = fucking volcanic
48  fixed atmosOxidizing; // 0.0 = reducing (H2, NH3, etc), 1.0 = oxidising (CO2, O2, etc)
49  fixed life; // 0.0 = dead, 1.0 = teeming
50 
51  /* rings */
52  enum RingStatus {
57  };
62 
63  Uint32 seed;
65  std::string spaceStationType;
66 
67  void SanityChecks();
68 
69 };
70 
71 class CustomSystem {
72 public:
73  static const int CUSTOM_ONLY_RADIUS = 4;
74  CustomSystem();
75  ~CustomSystem();
76 
77  std::string name;
78  std::vector<std::string> other_names;
81  unsigned numStars;
84  Uint32 seed;
86  bool explored;
87  const Faction *faction;
90  fixed lawlessness; // 0.0 = lawful, 1.0 = totally lawless
91  std::string shortDesc;
92  std::string longDesc;
93 
94  void SanityChecks();
95 
96  bool IsRandom() const { return !sBody; }
97 };
98 
100 public:
101  CustomSystemsDatabase(Galaxy *galaxy, const std::string &customSysDir) :
102  m_galaxy(galaxy),
103  m_customSysDirectory(customSysDir) {}
105 
106  void Load();
107 
108  typedef std::vector<const CustomSystem *> SystemList;
109  // XXX this is not as const-safe as it should be
110  const SystemList &GetCustomSystemsForSector(int sectorX, int sectorY, int sectorZ) const;
111  void AddCustomSystem(const SystemPath &path, CustomSystem *csys);
112  Galaxy *GetGalaxy() const { return m_galaxy; }
113 
114 private:
115  typedef std::map<SystemPath, SystemList> SectorMap;
116 
117  Galaxy *const m_galaxy;
118  const std::string m_customSysDirectory;
119  SectorMap m_sectorMap;
120  static const SystemList s_emptySystemList; // see: Null Object pattern
121 };
122 
123 #endif /* _CUSTOMSYSTEM_H */
Definition: CustomSystem.h:17
fixed atmosOxidizing
Definition: CustomSystem.h:48
fixed volcanicity
Definition: CustomSystem.h:47
Color ringColor
Definition: CustomSystem.h:61
std::string heightMapFilename
Definition: CustomSystem.h:38
SystemBody::BodyType type
Definition: CustomSystem.h:23
int heightMapFractal
Definition: CustomSystem.h:39
fixed ringInnerRadius
Definition: CustomSystem.h:59
std::string name
Definition: CustomSystem.h:22
fixed semiMajorAxis
Definition: CustomSystem.h:28
fixed mass
Definition: CustomSystem.h:26
fixed orbitalOffset
Definition: CustomSystem.h:30
RingStatus
Definition: CustomSystem.h:52
@ WANT_RANDOM_RINGS
Definition: CustomSystem.h:53
@ WANT_RINGS
Definition: CustomSystem.h:54
@ WANT_CUSTOM_RINGS
Definition: CustomSystem.h:56
@ WANT_NO_RINGS
Definition: CustomSystem.h:55
CustomSystemBody()
Definition: CustomSystem.cpp:718
fixed life
Definition: CustomSystem.h:49
fixed aspectRatio
Definition: CustomSystem.h:25
fixed volatileLiquid
Definition: CustomSystem.h:45
int averageTemp
Definition: CustomSystem.h:27
fixed rotationalPhaseAtStart
Definition: CustomSystem.h:36
fixed axialTilt
Definition: CustomSystem.h:37
std::string spaceStationType
Definition: CustomSystem.h:65
fixed radius
Definition: CustomSystem.h:24
fixed orbitalPhaseAtStart
Definition: CustomSystem.h:31
fixed rotationPeriod
Definition: CustomSystem.h:35
RingStatus ringStatus
Definition: CustomSystem.h:58
std::vector< CustomSystemBody * > children
Definition: CustomSystem.h:40
~CustomSystemBody()
Definition: CustomSystem.cpp:731
float latitude
Definition: CustomSystem.h:34
fixed volatileGas
Definition: CustomSystem.h:44
fixed metallicity
Definition: CustomSystem.h:43
float longitude
Definition: CustomSystem.h:34
bool want_rand_offset
Definition: CustomSystem.h:32
fixed ringOuterRadius
Definition: CustomSystem.h:60
void SanityChecks()
Definition: CustomSystem.cpp:778
Uint32 seed
Definition: CustomSystem.h:63
fixed volatileIces
Definition: CustomSystem.h:46
fixed eccentricity
Definition: CustomSystem.h:29
bool want_rand_seed
Definition: CustomSystem.h:64
Definition: CustomSystem.h:71
CustomSystemBody * sBody
Definition: CustomSystem.h:79
std::vector< std::string > other_names
Definition: CustomSystem.h:78
std::string name
Definition: CustomSystem.h:77
bool IsRandom() const
Definition: CustomSystem.h:96
static const int CUSTOM_ONLY_RADIUS
Definition: CustomSystem.h:73
int sectorZ
Definition: CustomSystem.h:82
bool want_rand_explored
Definition: CustomSystem.h:85
bool want_rand_lawlessness
Definition: CustomSystem.h:89
Uint32 seed
Definition: CustomSystem.h:84
std::string shortDesc
Definition: CustomSystem.h:91
int sectorY
Definition: CustomSystem.h:82
const Faction * faction
Definition: CustomSystem.h:87
CustomSystem()
Definition: CustomSystem.cpp:692
Polit::GovType govType
Definition: CustomSystem.h:88
fixed lawlessness
Definition: CustomSystem.h:90
unsigned numStars
Definition: CustomSystem.h:81
int sectorX
Definition: CustomSystem.h:82
bool explored
Definition: CustomSystem.h:86
SystemBody::BodyType primaryType[4]
Definition: CustomSystem.h:80
~CustomSystem()
Definition: CustomSystem.cpp:705
void SanityChecks()
Definition: CustomSystem.cpp:710
vector3f pos
Definition: CustomSystem.h:83
std::string longDesc
Definition: CustomSystem.h:92
Definition: CustomSystem.h:99
~CustomSystemsDatabase()
Definition: CustomSystem.cpp:669
void AddCustomSystem(const SystemPath &path, CustomSystem *csys)
Definition: CustomSystem.cpp:687
Galaxy * GetGalaxy() const
Definition: CustomSystem.h:112
const SystemList & GetCustomSystemsForSector(int sectorX, int sectorY, int sectorZ) const
Definition: CustomSystem.cpp:680
void Load()
Definition: CustomSystem.cpp:630
CustomSystemsDatabase(Galaxy *galaxy, const std::string &customSysDir)
Definition: CustomSystem.h:101
std::vector< const CustomSystem * > SystemList
Definition: CustomSystem.h:108
Definition: Factions.h:21
Definition: Galaxy.h:18
BodyType
Definition: SystemBody.h:23
Definition: SystemPath.h:13
GovType
Definition: Polit.h:25
Definition: Color.h:66