Skip to content

Commit

Permalink
ZAS CBT (#20064)
Browse files Browse the repository at this point in the history
Let's see what broke this time
  • Loading branch information
FluffyGhoster authored Oct 16, 2024
1 parent b7ccc74 commit bec05df
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 5,642 deletions.
1 change: 0 additions & 1 deletion aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -4095,7 +4095,6 @@
#include "maps\random_ruins\exoplanets\asteroid\abandoned_prison\abandoned_prison.dm"
#include "maps\random_ruins\exoplanets\asteroid\coalition_base\coalition_base.dm"
#include "maps\random_ruins\exoplanets\asteroid\mystery_ship\mystery_ship_areas.dm"
#include "maps\random_ruins\exoplanets\asteroid\old_outpost\old_outpost.dm"
#include "maps\random_ruins\exoplanets\biesel\abandoned_warehouse_1.dm"
#include "maps\random_ruins\exoplanets\biesel\abandoned_warehouse_2.dm"
#include "maps\random_ruins\exoplanets\biesel\biesel_camp_site.dm"
Expand Down
2 changes: 1 addition & 1 deletion code/ZAS/Zone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Class Procs:

var/needs_update = 0

var/list/edges
var/list/connection_edge/edges

var/datum/gas_mixture/air = new

Expand Down
3 changes: 3 additions & 0 deletions code/modules/mapping/map_template.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@
return TRUE

/datum/map_template/proc/get_affected_turfs(turf/T, centered = FALSE)
SHOULD_NOT_SLEEP(TRUE)
RETURN_TYPE(/list/turf)

var/turf/placement = T
if(centered)
var/turf/corner = locate(placement.x - round(width / 2), placement.y - round(height / 2), placement.z)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mapping/planet_types/lore/uueoaesa.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
possible_themes = list(/datum/exoplanet_theme/barren/asteroid, /datum/exoplanet_theme/barren/asteroid/ice)
ruin_planet_type = PLANET_LORE
features_budget = 3
ruin_type_whitelist = list(/datum/map_template/ruin/exoplanet/heph_mining_station, /datum/map_template/ruin/exoplanet/miners_guild_outpost, /datum/map_template/ruin/exoplanet/sol_listening_post, /datum/map_template/ruin/exoplanet/crashed_sol_shuttle_01, /datum/map_template/ruin/exoplanet/crashed_skrell_shuttle_01, /datum/map_template/ruin/exoplanet/digsite, /datum/map_template/ruin/exoplanet/abandoned_outpost, /datum/map_template/ruin/exoplanet/izweski_probe, /datum/map_template/ruin/exoplanet/heph_survey_post, /datum/map_template/ruin/exoplanet/kazhkz_crash)
ruin_type_whitelist = list(/datum/map_template/ruin/exoplanet/heph_mining_station, /datum/map_template/ruin/exoplanet/miners_guild_outpost, /datum/map_template/ruin/exoplanet/sol_listening_post, /datum/map_template/ruin/exoplanet/crashed_sol_shuttle_01, /datum/map_template/ruin/exoplanet/crashed_skrell_shuttle_01, /datum/map_template/ruin/exoplanet/digsite, /datum/map_template/ruin/exoplanet/izweski_probe, /datum/map_template/ruin/exoplanet/heph_survey_post, /datum/map_template/ruin/exoplanet/kazhkz_crash)

/obj/effect/overmap/visitable/sector/exoplanet/barren/asteroid/ytizi/pre_ruin_preparation()
if(istype(theme, /datum/exoplanet_theme/barren/asteroid/ice))
Expand All @@ -97,7 +97,7 @@
ring_chance = 0
ruin_planet_type = PLANET_LORE
place_near_main = list(2,2)
ruin_type_whitelist = list(/datum/map_template/ruin/exoplanet/heph_mining_station, /datum/map_template/ruin/exoplanet/miners_guild_outpost, /datum/map_template/ruin/exoplanet/digsite, /datum/map_template/ruin/exoplanet/abandoned_outpost, /datum/map_template/ruin/exoplanet/crashed_sol_shuttle_01, /datum/map_template/ruin/exoplanet/crashed_skrell_shuttle_01, /datum/map_template/ruin/exoplanet/izweski_probe, /datum/map_template/ruin/exoplanet/heph_survey_post, /datum/map_template/ruin/exoplanet/kazhkz_crash)
ruin_type_whitelist = list(/datum/map_template/ruin/exoplanet/heph_mining_station, /datum/map_template/ruin/exoplanet/miners_guild_outpost, /datum/map_template/ruin/exoplanet/digsite, /datum/map_template/ruin/exoplanet/crashed_sol_shuttle_01, /datum/map_template/ruin/exoplanet/crashed_skrell_shuttle_01, /datum/map_template/ruin/exoplanet/izweski_probe, /datum/map_template/ruin/exoplanet/heph_survey_post, /datum/map_template/ruin/exoplanet/kazhkz_crash)
scanimage = "chanterel.png"

/obj/effect/overmap/visitable/sector/exoplanet/barren/asteroid/chanterel/generate_planet_image()
Expand Down
15 changes: 14 additions & 1 deletion code/modules/mapping/ruins.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ GLOBAL_LIST_EMPTY(banned_ruin_ids)
available -= ruin
continue

log_admin("Ruin \"[ruin.name]\" placed at ([choice.x], [choice.y], [choice.z])!")
log_admin("Loading ruin \"[ruin.name]\" ([ruin.type]) with center turf ([choice.x], [choice.y], [choice.z])!")
load_ruin(choice, ruin)
log_module_ruins("Ruin \"[ruin.name]\" ([ruin.type]) loaded with geometry: Lower X: [choice.x - round(ruin.width / 2)] - Lower Y [choice.y - round(ruin.height / 2)] -- Upper X: [choice.x + round(ruin.width / 2)] - Upper Y: [choice.y + round(ruin.height / 2)]")

#if defined(UNIT_TEST)
var/list/turf/affected_turfs = ruin.get_affected_turfs(choice, TRUE)
GLOB.turfs_to_map_type["[ruin.type]"] = affected_turfs
#endif

selected += ruin

for(var/ruin_path in ruin.force_ruins)
Expand Down Expand Up @@ -106,6 +113,12 @@ GLOBAL_LIST_EMPTY(banned_ruin_ids)

log_admin("Ruin \"[ruin.name]\" force-spawned at ([choice.x], [choice.y], [choice.z])!")
load_ruin(choice, ruin)

#if defined(UNIT_TEST)
var/list/turf/affected_turfs = ruin.get_affected_turfs(choice, TRUE)
GLOB.turfs_to_map_type["[ruin.type]"] = affected_turfs
#endif

selected += ruin

if(!(ruin.template_flags & TEMPLATE_FLAG_ALLOW_DUPLICATES))
Expand Down
107 changes: 89 additions & 18 deletions code/unit_tests/zas_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
#define FAILURE 0
#define SUCCESS 1

#if defined(UNIT_TEST)
/**
* A list of string-keyes lists that maps the type of what we put there to the turfs
*
* Keys are strings of typepaths, values are lists of turfs
*
* list("/datum/map_template/whatever" = list(/turf/simulated, /turf/simulated))
*/
GLOBAL_LIST_EMPTY(turfs_to_map_type)
#endif

//
// Generic check for an area.
//
Expand Down Expand Up @@ -211,54 +222,114 @@
compose a message and fail the test, let the poor soul try to figure out where the issue is, assuming it's not intermittent
*/
var/fail_message = "\n\n\n\n\n[SSair.active_edges.len] edges active at round-start!\n"

#if defined(UNIT_TEST)
var/list/affected_map_types = list()
#endif

for(var/connection_edge/E in SSair.active_edges)
var/connection_edge/unsimulated/U = E
if(istype(U))

//Unsimulated edge
if(istype(E, /connection_edge/unsimulated))
var/connection_edge/unsimulated/U = E
var/turf/T = U.B
var/zone/zas_zone = U.A

fail_message += "Unsimulated edge between [zas_zone] and [T]\n"

if(istype(T))
fail_message += "--> [U.A.name] and [T.name] ([T.x], [T.y], [T.z]) have mismatched gas mixtures! <--\n"
fail_message += "--> [zas_zone.name] and [T.name] ([T.x], [T.y], [T.z]) have mismatched gas mixtures! <--\n"

else
fail_message += "--> [U.A.name] and [U.B] have mismatched gas mixtures! <--\n"
fail_message += "--> [zas_zone.name] and [T] have mismatched gas mixtures! <--\n"

//Let's see if we can get what turfs are on the edge connection
fail_message += "[zas_zone.name] edge turfs:\n"
for(var/connection_edge/edge in zas_zone.edges)
if(edge.sleeping)
continue

for(var/turf/edge_turf in edge.connecting_turfs)
fail_message += "[edge_turf.type] ([edge_turf.x], [edge_turf.y], [edge_turf.z])\t"



fail_message += "\n\nMismatching edge gasses: [(zas_zone.air) ? json_encode(zas_zone.air.gas) : "vacuum"] <-----> [(T.air) ? json_encode(T.air.gas) : "vacuum"]\n\n"

var/zone/A = U.A
var/offending_turfs_text = "Problem turfs: \n"
fail_message += "Mismatching edge gasses: [(U.A.air) ? json_encode(U.A.air.gas) : "vacuum"] <-----> [(U.B.air) ? json_encode(U.B.air.gas) : "vacuum"]\n\n"
for(var/turf/simulated/S in A.contents)
for(var/turf/simulated/S in zas_zone.contents)
if(("oxygen" in S.initial_gas) || ("nitrogen" in S.initial_gas))
offending_turfs_text += "[S] \[[S.type]\] ([S.x], [S.y], [S.z])\t"
offending_turfs_text += "[S.type] ([S.x], [S.y], [S.z])\t"

fail_message += "[offending_turfs_text]"
#if defined(UNIT_TEST)
for(var/type in GLOB.turfs_to_map_type)
if(S in GLOB.turfs_to_map_type[type])
affected_map_types |= type
#endif

fail_message += "[offending_turfs_text]\n\n"


//Simulated edge (zone edge)
else
var/connection_edge/zone/Z = E
if(!istype(Z))
stack_trace("Somehow, an edge is neither an unsimulated edge nor a zone edge!")
return

var/zone/first_zone = Z.A
var/zone/second_zone = Z.B

fail_message += "Simulated edge between [first_zone.name] and [second_zone.name]\n"


//Let's see if we can get what turfs are on the edge connection
fail_message += "[first_zone.name] and [second_zone.name] edge turfs:\n"
for(var/connection_edge/edge in (first_zone.edges + second_zone.edges))
if(edge.sleeping)
continue

for(var/turf/edge_turf in edge.connecting_turfs)
fail_message += "[edge_turf.type] ([edge_turf.x], [edge_turf.y], [edge_turf.z])\t"

//A list of turfs that are related to the found issue
var/list/turf/problem_turfs = list()

if(!istype(Z))
return

fail_message += "--> [Z.A.name] and [Z.B.name] have mismatched gas mixtures! <--\n"
fail_message += "\n\n--> [first_zone.name] and [second_zone.name] have mismatched gas mixtures! <--\n"

if(Z.A.air.gas.len && Z.B.air.gas.len)
fail_message += "--> Both zones have gas mixtures defined; either one is a normally vacuum zone exposed to a breach, or two differing gases are mixing at round-start. <--\n"
problem_turfs = Z.A.contents + Z.B.contents
problem_turfs = first_zone.contents + second_zone.contents
else if(Z.A.air.gas.len)
problem_turfs = Z.A.contents
problem_turfs = first_zone.contents
else if(Z.B.air.gas.len)
problem_turfs = Z.B.contents
problem_turfs = second_zone.contents

if(!length(problem_turfs))
continue

fail_message += "Mismatching edge gasses: [(Z.A.air) ? json_encode(Z.A.air.gas) : "vacuum"] <-----> [(Z.B.air) ? json_encode(Z.B.air.gas) : "vacuum"]\n\n"
fail_message += "Mismatching edge gasses: [(first_zone.air) ? json_encode(first_zone.air.gas) : "vacuum"] <-----> [(second_zone.air) ? json_encode(second_zone.air.gas) : "vacuum"]\n\n"

var/offending_turfs_text = "Problem turfs: "
for(var/turf/simulated/S in problem_turfs)
if(("oxygen" in S.initial_gas) || ("nitrogen" in S.initial_gas))
offending_turfs_text += "[S] \[[S.type]\] ([S.x], [S.y], [S.z])\t"
offending_turfs_text += "[S.type] ([S.x], [S.y], [S.z])\t"

#if defined(UNIT_TEST)
for(var/type in GLOB.turfs_to_map_type)
if(S in GLOB.turfs_to_map_type[type])
affected_map_types |= type
#endif

fail_message += "[offending_turfs_text]\n\n"


#if defined(UNIT_TEST)
if(length(affected_map_types))
TEST_FAIL("Affected map types: [english_list(affected_map_types)]")
#endif

fail_message += "[offending_turfs_text]"

TEST_FAIL("[fail_message]")
return UNIT_TEST_FAILED
Expand Down
59 changes: 59 additions & 0 deletions html/changelogs/fluffyghost-zascbt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# - (fixes bugs)
# wip
# - (work in progress)
# qol
# - (quality of life)
# soundadd
# - (adds a sound)
# sounddel
# - (removes a sound)
# rscadd
# - (adds a feature)
# rscdel
# - (removes a feature)
# imageadd
# - (adds an image or sprite)
# imagedel
# - (removes an image or sprite)
# spellcheck
# - (fixes spelling or grammar)
# experiment
# - (experimental change)
# balance
# - (balance changes)
# code_imp
# - (misc internal code change)
# refactor
# - (refactors code)
# config
# - (makes a change to the config files)
# admin
# - (makes changes to administrator tools)
# server
# - (miscellaneous changes to server)
#################################

# Your name.
author: FluffyGhost

# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True

# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
changes:
- rscadd: "Improved ZAS error reporting."
- rscdel: "Removed a cursed ruin that was failing tests."
15 changes: 0 additions & 15 deletions maps/random_ruins/exoplanets/asteroid/asteroid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,3 @@
ruin_tags = RUIN_LOWPOP|RUIN_WRECK|RUIN_HOSTILE

unit_test_groups = list(1)

/datum/map_template/ruin/exoplanet/abandoned_outpost
name = "Abandoned Mining Outpost"
id = "miningoutpost"
description = "A long-abandoned mining outpost."

sectors = list(SECTOR_TAU_CETI, SECTOR_ROMANOVICH, SECTOR_CORP_ZONE, SECTOR_VALLEY_HALE, SECTOR_BADLANDS, ALL_COALITION_SECTORS, SECTOR_UUEOAESA)

prefix = "asteroid/old_outpost/"
suffix = "old_outpost.dmm"

planet_types = PLANET_ASTEROID|PLANET_BARREN|PLANET_GROVE|PLANET_LAVA|PLANET_DESERT
ruin_tags = RUIN_LOWPOP|RUIN_MINING

unit_test_groups = list(3)
22 changes: 0 additions & 22 deletions maps/random_ruins/exoplanets/asteroid/old_outpost/old_outpost.dm

This file was deleted.

Loading

0 comments on commit bec05df

Please sign in to comment.