Skip to content

Commit

Permalink
(to squash) Move integers to members of class
Browse files Browse the repository at this point in the history
  • Loading branch information
impaktor committed Dec 3, 2024
1 parent 880b79e commit 3c1c948
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/galaxy/SectorGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,12 @@ bool SectorCustomSystemsGenerator::Apply(Random &rng, RefCountedPtr<Galaxy> gala

if (cs->want_rand_explored) {

int GalaxyExploredMax = (SectorCustomSystemsGenerator::galaxyConfig->Int("GalaxyExploredMax"));
int GalaxyExploredMin = (SectorCustomSystemsGenerator::galaxyConfig->Int("GalaxyExploredMin"));
int GalaxyExploredMix = (SectorCustomSystemsGenerator::galaxyConfig->Int("GalaxyExploredMix"));
/*
* 0 - ~500ly from sol: explored
* ~500ly - ~700ly (65-90 sectors): gradual
* ~700ly+: unexplored
*/
if (((dist <= Square(GalaxyExploredMax)) && (dist <= Square(GalaxyExploredMin) || rng.Int32(dist) <= Square(GalaxyExploredMix))) || galaxy->GetFactions()->IsHomeSystem(SystemPath(sx, sy, sz, sysIdx)))
if (((dist <= Square(m_GalaxyExploredMax)) && (dist <= Square(m_GalaxyExploredMin) || rng.Int32(dist) <= Square(m_GalaxyExploredMix))) || galaxy->GetFactions()->IsHomeSystem(SystemPath(sx, sy, sz, sysIdx)))
s.m_explored = StarSystem::eEXPLORED_AT_START;
else
s.m_explored = StarSystem::eUNEXPLORED;
Expand Down Expand Up @@ -173,16 +170,12 @@ bool SectorRandomSystemsGenerator::Apply(Random &rng, RefCountedPtr<Galaxy> gala
s.m_pos.y = rng.Double(Sector::SIZE);
s.m_pos.z = rng.Double(Sector::SIZE);

int GalaxyExploredMax = (SectorRandomSystemsGenerator::galaxyConfig->Int("GalaxyExploredMax"));
int GalaxyExploredMin = (SectorRandomSystemsGenerator::galaxyConfig->Int("GalaxyExploredMin"));
int GalaxyExploredMix = (SectorRandomSystemsGenerator::galaxyConfig->Int("GalaxyExploredMix"));

/*
* 0 - ~500ly from sol: explored
* ~500ly - ~700ly (65-90 sectors): gradual
* ~700ly+: unexplored
*/
if (((dist <= Square(GalaxyExploredMax)) && (dist <= Square(GalaxyExploredMin) || rng.Int32(dist) <= Square(GalaxyExploredMix))) || galaxy->GetFactions()->IsHomeSystem(SystemPath(sx, sy, sz, customCount + i)))
if (((dist <= Square(m_GalaxyExploredMax)) && (dist <= Square(m_GalaxyExploredMin) || rng.Int32(dist) <= Square(m_GalaxyExploredMix))) || galaxy->GetFactions()->IsHomeSystem(SystemPath(sx, sy, sz, customCount + i)))
s.m_explored = StarSystem::eEXPLORED_AT_START;
else
s.m_explored = StarSystem::eUNEXPLORED;
Expand Down
16 changes: 16 additions & 0 deletions src/galaxy/SectorGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ class SectorCustomSystemsGenerator : public SectorGeneratorStage {
SectorCustomSystemsGenerator(int customOnlyRadius) :
m_customOnlyRadius(customOnlyRadius) {
SectorCustomSystemsGenerator::galaxyConfig = new GalaxyConfig();

m_GalaxyExploredMax = galaxyConfig->Int("GalaxyExploredMax");
m_GalaxyExploredMin = galaxyConfig->Int("GalaxyExploredMin");
m_GalaxyExploredMix = galaxyConfig->Int("GalaxyExploredMix");
}
virtual bool Apply(Random &rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig *config);

private:
int m_GalaxyExploredMax;
int m_GalaxyExploredMin;
int m_GalaxyExploredMix;

int m_customOnlyRadius;
static GalaxyConfig *galaxyConfig;
};
Expand All @@ -28,10 +36,18 @@ class SectorRandomSystemsGenerator : public SectorGeneratorStage {
public:
SectorRandomSystemsGenerator(){
SectorRandomSystemsGenerator::galaxyConfig = new GalaxyConfig();

m_GalaxyExploredMax = galaxyConfig->Int("GalaxyExploredMax");
m_GalaxyExploredMin = galaxyConfig->Int("GalaxyExploredMin");
m_GalaxyExploredMix = galaxyConfig->Int("GalaxyExploredMix");
}
virtual bool Apply(Random &rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig *config);

private:
int m_GalaxyExploredMax;
int m_GalaxyExploredMin;
int m_GalaxyExploredMix;

const std::string GenName(RefCountedPtr<Galaxy> galaxy, const Sector &sec, Sector::System &sys, int si, Random &rand);
static GalaxyConfig *galaxyConfig;
};
Expand Down

0 comments on commit 3c1c948

Please sign in to comment.