From 1e58c1875d9e2f48a306fe31a0626dbbb1990ff9 Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Thu, 30 Mar 2023 20:21:44 -0700 Subject: [PATCH] Fixes lava river genertation (It was broken for 2 YEARS) (#74359) ## About The Pull Request Post 9ee4703133d1ed86a60a0f425f1f3fd625120ea6, river generation was broken It broke things by moving ruin loading to BEFORE world gen (river gen happens w ruin loading for convienience), which, since rivers retain their old area (and world gen is area based), meant that rivers just got overriden. I've fixed things by moving river generation to AFTER world gen, since rivers rely on things like mineral walls existing ## Why It's Good For The Game If we're gonna spend cpu time on these they should like, exist. Closes #61371 ## Changelog :cl: fix: Lava and plasma rivers (openspace on icebox too) will generate now. This was broken for 2 years wtf man /:cl: --- code/controllers/subsystem/mapping.dm | 26 ++++++++++++++----- code/game/turfs/open/river.dm | 2 +- .../mapGenerators/lava_river.dm | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 84ef7086c7d..78e6da154a0 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -148,6 +148,8 @@ SUBSYSTEM_DEF(mapping) #endif // Run map generation after ruin generation to prevent issues run_map_generation() + // Generate our rivers, we do this here so the map doesn't load on top of them + setup_rivers() // Add the first transit level var/datum/space_level/base_transit = add_reservation_zlevel() require_area_resort() @@ -236,27 +238,37 @@ SUBSYSTEM_DEF(mapping) var/list/lava_ruins = levels_by_trait(ZTRAIT_LAVA_RUINS) if (lava_ruins.len) seedRuins(lava_ruins, CONFIG_GET(number/lavaland_budget), list(/area/lavaland/surface/outdoors/unexplored), themed_ruins[ZTRAIT_LAVA_RUINS], clear_below = TRUE) - for (var/lava_z in lava_ruins) - spawn_rivers(lava_z) var/list/ice_ruins = levels_by_trait(ZTRAIT_ICE_RUINS) if (ice_ruins.len) // needs to be whitelisted for underground too so place_below ruins work - seedRuins(ice_ruins, CONFIG_GET(number/icemoon_budget), list(/area/icemoon/surface/outdoors/unexplored, /area/icemoon/underground/unexplored), themed_ruins[ZTRAIT_ICE_RUINS], clear_below = TRUE) - for (var/ice_z in ice_ruins) - spawn_rivers(ice_z, 4, /turf/open/openspace/icemoon, /area/icemoon/surface/outdoors/unexplored/rivers) + seedRuins(ice_ruins, CONFIG_GET(number/icemoon_budget), list(/area/icemoon/surface/outdoors/unexplored), themed_ruins[ZTRAIT_ICE_RUINS], clear_below = TRUE) var/list/ice_ruins_underground = levels_by_trait(ZTRAIT_ICE_RUINS_UNDERGROUND) if (ice_ruins_underground.len) seedRuins(ice_ruins_underground, CONFIG_GET(number/icemoon_budget), list(/area/icemoon/underground/unexplored), themed_ruins[ZTRAIT_ICE_RUINS_UNDERGROUND], clear_below = TRUE) - for (var/ice_z in ice_ruins_underground) - spawn_rivers(ice_z, 4, level_trait(ice_z, ZTRAIT_BASETURF), /area/icemoon/underground/unexplored/rivers) // Generate deep space ruins var/list/space_ruins = levels_by_trait(ZTRAIT_SPACE_RUINS) if (space_ruins.len) seedRuins(space_ruins, CONFIG_GET(number/space_budget), list(/area/space), themed_ruins[ZTRAIT_SPACE_RUINS]) +/// Sets up rivers, and things that behave like rivers. So lava/plasma rivers, and chasms +/// It is important that this happens AFTER generating mineral walls and such, since we rely on them for river logic +/datum/controller/subsystem/mapping/proc/setup_rivers() + // Generate mining ruins + var/list/lava_ruins = levels_by_trait(ZTRAIT_LAVA_RUINS) + for (var/lava_z in lava_ruins) + spawn_rivers(lava_z, 4, /turf/open/lava/smooth/lava_land_surface, /area/lavaland/surface/outdoors/unexplored) + + var/list/ice_ruins = levels_by_trait(ZTRAIT_ICE_RUINS) + for (var/ice_z in ice_ruins) + spawn_rivers(ice_z, 4, /turf/open/openspace/icemoon, /area/icemoon/surface/outdoors/unexplored/rivers) + + var/list/ice_ruins_underground = levels_by_trait(ZTRAIT_ICE_RUINS_UNDERGROUND) + for (var/ice_z in ice_ruins_underground) + spawn_rivers(ice_z, 4, level_trait(ice_z, ZTRAIT_BASETURF), /area/icemoon/underground/unexplored/rivers) + /datum/controller/subsystem/mapping/proc/wipe_reservations(wipe_safety_delay = 100) if(clearing_reserved_turfs || !initialized) //in either case this is just not needed. return diff --git a/code/game/turfs/open/river.dm b/code/game/turfs/open/river.dm index e71488015e0..532fa869592 100644 --- a/code/game/turfs/open/river.dm +++ b/code/game/turfs/open/river.dm @@ -4,7 +4,7 @@ #define RANDOM_LOWER_X 50 #define RANDOM_LOWER_Y 50 -/proc/spawn_rivers(target_z, nodes = 4, turf_type = /turf/open/lava/smooth/lava_land_surface, whitelist_area = /area/lavaland/surface/outdoors/unexplored, min_x = RANDOM_LOWER_X, min_y = RANDOM_LOWER_Y, max_x = RANDOM_UPPER_X, max_y = RANDOM_UPPER_Y) +/proc/spawn_rivers(target_z, nodes, turf_type, whitelist_area, min_x = RANDOM_LOWER_X, min_y = RANDOM_LOWER_Y, max_x = RANDOM_UPPER_X, max_y = RANDOM_UPPER_Y) var/list/river_nodes = list() var/num_spawned = 0 var/width = max_x - min_x diff --git a/code/modules/procedural_mapping/mapGenerators/lava_river.dm b/code/modules/procedural_mapping/mapGenerators/lava_river.dm index 723bc5f5782..59e430e1791 100644 --- a/code/modules/procedural_mapping/mapGenerators/lava_river.dm +++ b/code/modules/procedural_mapping/mapGenerators/lava_river.dm @@ -24,4 +24,4 @@ var/datum/map_generator/lavaland/L = mother if(!istype(L)) return - spawn_rivers(L.start_z, river_nodes, river_type, min_x = L.min_x, min_y = L.min_y, max_x = L.max_x, max_y = L.max_y) + spawn_rivers(L.start_z, river_nodes, river_type, /area/lavaland/surface/outdoors/unexplored, min_x = L.min_x, min_y = L.min_y, max_x = L.max_x, max_y = L.max_y)