Files
Bubberstation/code/datums/mapgen/JungleGenerator.dm
san7890 e1221c986f Chasm Hell On Icebox - 300 Active Turfs on Prod Moment (#74410)
## About The Pull Request

Spontaneous regressions introduced by #74359
(1e58c1875d).
```txt
 - Z-Level 2 has 150 active turf(s).
 - Z-Level 3 has 150 active turf(s).
 - Z-Level trait Ice Ruins Underground has 300 active turf(s).
 - Z-Level trait Mining has 300 active turf(s).
 - Z-Level trait Station has 300 active turf(s).
 - End of active turf list.
 ```

![image](https://user-images.githubusercontent.com/34697715/229213138-5a6a7a4f-edec-47ab-8def-ee4e4bddfe61.png)

Basically the lavaland ruin sucks dogshit and I had to do a lot of stuff to account for everything failing. There was even a moment where we were adding something to `flags_1` instead of `turf_flags` and that was also really bad to figure out.

![image](https://user-images.githubusercontent.com/34697715/229213428-63bb1f6e-6f88-4604-a3c6-e08e20cbfa7a.png)

i also had to add orange genturfs because it was really getting bad with all of the assertions we had to keep making, especially since stuff like this could also show up:

![image](https://user-images.githubusercontent.com/34697715/229213562-4a145453-5f90-4d05-b8cc-5c1beec2b0dd.png)

That's the prison in the red box, those are active turfs because a chasm scraped it away.

Sorry if this is hard to follow but I promise you everything in this is essential. I wish we didn't have to rely on turf flags as much as we do but this is a fix PR, not a refactor.
## Why It's Good For The Game

Even one active turf on IceBox ate up _three_ seconds of SSair's initialization every single time it was really fucking bad.

We haven't had to deal with chasms for about two years so there's a lot of mapping assertions we made since they just weren't a thing, but now they're back so lets do it properly.
## Changelog
🆑
fix: The prison on IceBox should no longer leak air as often.
/🆑

I have compiled this map about 30 times until active turfs stopped fucking happening and now I am content. This likely doesn't fix _everything_ because some stuff can still be hidden to me, and we still have PRs that need to be merged to reduce the amount of noise we're getting on prod.
2023-04-02 00:25:33 +01:00

106 lines
4.0 KiB
Plaintext

//the random offset applied to square coordinates, causes intermingling at biome borders
#define BIOME_RANDOM_SQUARE_DRIFT 2
/datum/map_generator/jungle_generator
///2D list of all biomes based on heat and humidity combos.
var/list/possible_biomes = list(
BIOME_LOW_HEAT = list(
BIOME_LOW_HUMIDITY = /datum/biome/plains,
BIOME_LOWMEDIUM_HUMIDITY = /datum/biome/mudlands,
BIOME_HIGHMEDIUM_HUMIDITY = /datum/biome/mudlands,
BIOME_HIGH_HUMIDITY = /datum/biome/water
),
BIOME_LOWMEDIUM_HEAT = list(
BIOME_LOW_HUMIDITY = /datum/biome/plains,
BIOME_LOWMEDIUM_HUMIDITY = /datum/biome/jungle,
BIOME_HIGHMEDIUM_HUMIDITY = /datum/biome/jungle,
BIOME_HIGH_HUMIDITY = /datum/biome/mudlands
),
BIOME_HIGHMEDIUM_HEAT = list(
BIOME_LOW_HUMIDITY = /datum/biome/plains,
BIOME_LOWMEDIUM_HUMIDITY = /datum/biome/plains,
BIOME_HIGHMEDIUM_HUMIDITY = /datum/biome/jungle/deep,
BIOME_HIGH_HUMIDITY = /datum/biome/jungle
),
BIOME_HIGH_HEAT = list(
BIOME_LOW_HUMIDITY = /datum/biome/wasteland,
BIOME_LOWMEDIUM_HUMIDITY = /datum/biome/plains,
BIOME_HIGHMEDIUM_HUMIDITY = /datum/biome/jungle,
BIOME_HIGH_HUMIDITY = /datum/biome/jungle/deep
)
)
///Used to select "zoom" level into the perlin noise, higher numbers result in slower transitions
var/perlin_zoom = 65
///Seeds the rust-g perlin noise with a random number.
/datum/map_generator/jungle_generator/generate_terrain(list/turfs, area/generate_in)
. = ..()
var/height_seed = rand(0, 50000)
var/humidity_seed = rand(0, 50000)
var/heat_seed = rand(0, 50000)
for(var/t in turfs) //Go through all the turfs and generate them
var/turf/gen_turf = t
var/drift_x = (gen_turf.x + rand(-BIOME_RANDOM_SQUARE_DRIFT, BIOME_RANDOM_SQUARE_DRIFT)) / perlin_zoom
var/drift_y = (gen_turf.y + rand(-BIOME_RANDOM_SQUARE_DRIFT, BIOME_RANDOM_SQUARE_DRIFT)) / perlin_zoom
var/height = text2num(rustg_noise_get_at_coordinates("[height_seed]", "[drift_x]", "[drift_y]"))
var/datum/biome/selected_biome
if(height <= 0.85) //If height is less than 0.85, we generate biomes based on the heat and humidity of the area.
var/humidity = text2num(rustg_noise_get_at_coordinates("[humidity_seed]", "[drift_x]", "[drift_y]"))
var/heat = text2num(rustg_noise_get_at_coordinates("[heat_seed]", "[drift_x]", "[drift_y]"))
var/heat_level //Type of heat zone we're in LOW-MEDIUM-HIGH
var/humidity_level //Type of humidity zone we're in LOW-MEDIUM-HIGH
switch(heat)
if(0 to 0.25)
heat_level = BIOME_LOW_HEAT
if(0.25 to 0.5)
heat_level = BIOME_LOWMEDIUM_HEAT
if(0.5 to 0.75)
heat_level = BIOME_HIGHMEDIUM_HEAT
if(0.75 to 1)
heat_level = BIOME_HIGH_HEAT
switch(humidity)
if(0 to 0.25)
humidity_level = BIOME_LOW_HUMIDITY
if(0.25 to 0.5)
humidity_level = BIOME_LOWMEDIUM_HUMIDITY
if(0.5 to 0.75)
humidity_level = BIOME_HIGHMEDIUM_HUMIDITY
if(0.75 to 1)
humidity_level = BIOME_HIGH_HUMIDITY
selected_biome = possible_biomes[heat_level][humidity_level]
else //Over 0.85; It's a mountain
selected_biome = /datum/biome/mountain
selected_biome = SSmapping.biomes[selected_biome] //Get the instance of this biome from SSmapping
selected_biome.generate_turf(gen_turf)
CHECK_TICK
/area/mine/planetgeneration
name = "planet generation area"
static_lighting = FALSE
base_lighting_alpha = 255
map_generator = /datum/map_generator/jungle_generator
/// This turf doesn't actually do anything beyond provide contrast for mappers and be very visible when stuff breaks in game. The actual areas are what drive cave generation.
/turf/open/genturf
name = "green ungenerated turf"
desc = "If you see this, and you're not a ghost, yell at coders"
icon = 'icons/turf/debug.dmi'
icon_state = "genturf_green"
// following two are currently used for edge cases in which you want a certain type of map generation intermingled with other genturfs
/turf/open/genturf/blue
name = "blue ungenerated turf"
icon_state = "genturf_blue"
/turf/open/genturf/orange
name = "orange ungenerated turf"
icon_state = "genturf_orange"
#undef BIOME_RANDOM_SQUARE_DRIFT