Skip to content

Commit

Permalink
Ensure randomly-generated starports have population
Browse files Browse the repository at this point in the history
- PopulateStage1() was not being called for starports added at the end of the generation process, leading to orbital and surface starports without any population.
- This manifested as an almost total lack of paintshops across the galaxy :)
  • Loading branch information
sturnclaw committed Jan 9, 2025
1 parent ce3d102 commit 248b652
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/galaxy/StarSystemGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,8 @@ void PopulateStarSystemGenerator::PopulateAddStations(SystemBody *sbody, StarSys
// with respect to well-spaced orbital shells (e.g. a "station belt" around a high-population planet)
// as well as generating station placement for e.g. research, industrial, or communications stations

fixed totalPop = system->GetTotalPop();

if (sbody->GetPopulationAsFixed() < fixed(1, 1000)) return;
fixed orbMaxS = fixed(1, 4) * fixed(CalcHillRadius(sbody));
fixed orbMinS = fixed().FromDouble((sbody->CalcAtmosphereParams().atmosRadius + +500000.0 / EARTH_RADIUS)) * AU_EARTH_RADIUS;
Expand Down Expand Up @@ -1747,6 +1749,7 @@ void PopulateStarSystemGenerator::PopulateAddStations(SystemBody *sbody, StarSys
sp->m_orbMax = sp->GetSemiMajorAxisAsFixed();

sp->m_name = gen_unique_station_name(sp, system, namerand);
PopulateStage1(sp, system, totalPop);
}
}
}
Expand All @@ -1771,6 +1774,7 @@ void PopulateStarSystemGenerator::PopulateAddStations(SystemBody *sbody, StarSys
PositionSettlementOnPlanet(sp, previousOrbits);
sbody->m_children.insert(sbody->m_children.begin(), sp);
system->AddSpaceStation(sp);
PopulateStage1(sp, system, totalPop);
}

// guarantee that there is always a star port on a populated world
Expand All @@ -1786,7 +1790,10 @@ void PopulateStarSystemGenerator::PopulateAddStations(SystemBody *sbody, StarSys
PositionSettlementOnPlanet(sp, previousOrbits);
sbody->m_children.insert(sbody->m_children.begin(), sp);
system->AddSpaceStation(sp);
PopulateStage1(sp, system, totalPop);
}

system->SetTotalPop(totalPop);
}

void PopulateStarSystemGenerator::SetSysPolit(RefCountedPtr<Galaxy> galaxy, RefCountedPtr<StarSystem::GeneratorAPI> system, const fixed &human_infestedness)
Expand Down

0 comments on commit 248b652

Please sign in to comment.