Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Anubis-class Cruiser (12/20/24)

Author Topic: Changing hyperspace terrain generation  (Read 2241 times)

Bad_Idea

  • Ensign
  • *
  • Posts: 17
    • View Profile
Changing hyperspace terrain generation
« on: February 03, 2019, 10:43:43 AM »

Hey!

I've been trying some my hand at some tentative modding, namely increasing the sector size.

I've already increased the sector size and upped the max amount of systems allowed in the generator, however, i've reached somewhat of an impasse. This being the hyperspace terrain.

As many probably already knew (including me) it only generates in the original game area, and not in the expanded one. This ends up looking like this:
Spoiler
[close]

Me and a couple of people on the unofficial discord have been trying our best to find out where this generation is taking place so we can change the generated size of the hyperspace terrain, however, there's only so much that can be learned by randomly staring at API files and we haven't found anything out.

So in short i'd like to ask how, if possible at all, one would go about changing this?

Cheers!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24956
    • View Profile
Re: Changing hyperspace terrain generation
« Reply #1 on: February 03, 2019, 11:03:23 AM »

Hi there!

See: data.scripts.world.SectorGen, specifically this bit of code:

SectorEntityToken deep_hyperspace = Misc.addNebulaFromPNG("data/campaign/terrain/hyperspace_map.png",
              Global.getSector().getHyperspace(), // location to add to
              "terrain", "deep_hyperspace", // "nebula_blue", // texture to use, uses xxx_map for map
              4, 4, Terrain.HYPERSPACE, null); // number of cells in texture

The hyperspace terrain is initialized from data/campaign/terrain/hyperspace_map.png.

In addition, com.fs.starfarer.api.impl.campaign.procgen.SectorProcGen randomly messes with the otherwise-solid hyperspace areas outside the core, starting on line 161.


Just a quick warning: making hyperspace terrain that big may (and probably will) have an effect on performance. Things to watch out for:

1) A frame rate (or idle time) drop, both in and out of hyperspace, but especially in; could be severe
2) An increase in savefile size; could be quite significant with the size you've got

There are some optimizations already in the hyperspace code that may help here, but that would only work to a certain point, so, definitely keep an eye on how it's affecting the game's performance.
Logged

Bad_Idea

  • Ensign
  • *
  • Posts: 17
    • View Profile
Re: Changing hyperspace terrain generation
« Reply #2 on: February 03, 2019, 12:55:11 PM »

Welp, guess we overlooked that...

Set up this:
Spoiler
[close]

Thanks for the help!

To report on performance: It's not actually that bad! The only real drops i have noticed are trying to zoom in the starmap, that momentarily drops the FPS until you stop zooming and it stabilizes up high again!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24956
    • View Profile
Re: Changing hyperspace terrain generation
« Reply #3 on: February 03, 2019, 01:00:55 PM »

Nice!

Edit: what's the impact on the savefile size like? I'm just curious.
Logged

Bad_Idea

  • Ensign
  • *
  • Posts: 17
    • View Profile
Re: Changing hyperspace terrain generation
« Reply #4 on: February 03, 2019, 01:40:09 PM »

Impact on the initial savefile is actually pretty large, 8MB for an unmodified vanilla map and 24MB for one running my map size mod! (It's really just a modified SystemProcGen file)

(That's the entire save folder i am looking at)
« Last Edit: February 03, 2019, 01:43:19 PM by Bad_Idea »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24956
    • View Profile
Re: Changing hyperspace terrain generation
« Reply #5 on: February 03, 2019, 01:56:30 PM »

After the first save, there's no backup files in the save folder yet, so that's pretty much the savefile size - an extra 16 mb. Ouch! Good news it wouldn't get larger as the game goes on, but, yeah, that'll make an impact on the save and load times. (Before you ask, the tile data is already being compressed...)
Logged