There is now a very first step in lwho/galaxy_generator (note: as this is WIP commits may be rebased, amended, squashed and force pushed). It currently only deals with the Sector layer of generation (i.e. there is nothing at all about StarSystem).
A GalaxyGenerator class is introduced, which gets attached a list of Sector generation stages. When a Sector is requested, the GalaxyGenerator creates an empty one and passes it in order to the SectorGenerator stages. Currently there are two stages: SectorCustomSystemsGenerator and SectorRandomSystemsGenerator. I'm planning to make AssignFactions a third stage somehow.
The user-visible behavior is supposed to be the same as before. So, if anything changed in the generated universe, that would be a bug.
The code is currently only very lightly tested: It compiles, and from a very first look at the sector map it looks fine.
I would be grateful about comments (especially about the general approach and design).
Universe generation and persistence of in-game modification
Re: Universe generation and persistence of in-game modificat
Just dumped all sectors from -100 to +100 in each dimension before and after my changes to text files. 1.7GB each (only containing Sector and Sector::System) :O
Fortunately, they had the same MD5 sum, I don't think a diff tool would have been so happy with so huge files ;)
Fortunately, they had the same MD5 sum, I don't think a diff tool would have been so happy with so huge files ;)
Re: Universe generation and persistence of in-game modificat
This project isn't dead, it progresses (you know, progress is a turtle ;)). I got side-tracked again and again, though the side-tracks were mostly related to this project.
The first step is to separate galaxy generation from Sector and StarSystem representation and put all related stuff in there. Once this is done I plan to have two galaxy generation tracks. One is the current (legacy) generator which is supposed to stay stable and save-game compatible. The other is supposed to be an experimental galaxy generator, which can change at any time (also in save-game incompatible ways).
The used galaxy generator (name and version) is to be put in the save-game and depending on that, further generator-related stuff can be loaded/saved (though I have no fields in mind, currently).
Certain galaxy-related stuff needs to be tight to a galaxy generator:
Factions and CustomSystems need to be re-initialized when the galaxy generator changes (e.g. loading a game with another galaxy generator). Currently those steps are relatively early in the Pioneer initialization, but on first look it seems that the stuff behind it doesn't really depend on it. So, I hope I can move those steps to the end, and just re-initialize only those two when needed.
This is the current initialization order in Pi::Init:
Comments, suggestions and such highly welcome.
The first step is to separate galaxy generation from Sector and StarSystem representation and put all related stuff in there. Once this is done I plan to have two galaxy generation tracks. One is the current (legacy) generator which is supposed to stay stable and save-game compatible. The other is supposed to be an experimental galaxy generator, which can change at any time (also in save-game incompatible ways).
The used galaxy generator (name and version) is to be put in the save-game and depending on that, further generator-related stuff can be loaded/saved (though I have no fields in mind, currently).
Certain galaxy-related stuff needs to be tight to a galaxy generator:
- Sector and StarSystem caches (which is relatively easy)
- Factions (this probably needs considerable cleanup of all the static stuff before, side-track I come)
- CustomSystems (I hope, this is easy again, but haven't looked closely, yet).
Factions and CustomSystems need to be re-initialized when the galaxy generator changes (e.g. loading a game with another galaxy generator). Currently those steps are relatively early in the Pioneer initialization, but on first look it seems that the stuff behind it doesn't really depend on it. So, I hope I can move those steps to the end, and just re-initialize only those two when needed.
This is the current initialization order in Pi::Init:
- FileSystem, GameConfig, ModManager, Resources
- SDL, Renderer, Joystick
- EnumStrings
- Multi-threading and job queues
- ShipType
- Lua
- Gui (now we are at progress bar 0.1)
- Galaxy::Init (0.2)
- FaceGenManager::Init (0.25)
- Faction::Init (0.3)
- CustomSystem::Init (0.4)
- Faction::SetHomeSectors (0.45)
- ModelCache, Shields::Init (0.5)
- 0,6 seems to be empty
- BaseSphere::Init (0.7)
- CityOnPlanet::Init (0.8)
- SpaceStation::Init (0.9)
- NavLights::Init, Sfx::Init (0.95)
- Sound/Music (1.0)
Code: Select all
Pi::galaxyGenerator = GalaxyGenerator::Create(config->String("GalaxyGenerator"));