Turf Icons Unit Test (#75488)

unit tests turf icons to find... well, missing icons. honk.

fixes #75372
corrects a bunch of things messed up in #65504

🆑 ShizCalev
code: Made a new unit test to find turfs with broken/missing icons!
Rejoice!
fix: Fixed a bunch of incorrect and missing turf icons.
/🆑
This commit is contained in:
ShizCalev
2023-05-19 12:52:31 -06:00
committed by GitHub
parent cb24c10d3c
commit dfed295ff3
17 changed files with 153 additions and 79 deletions
+2 -1
View File
@@ -662,6 +662,7 @@
/turf/closed/mineral/gibtonite
mineralAmt = 1
icon_state = "rock_Gibtonite_inactive"
scan_state = "rock_Gibtonite"
var/det_time = 8 //Countdown till explosion, but also rewards the player for how close you were to detonation when you defuse it
var/stage = GIBTONITE_UNSTRUCK //How far into the lifecycle of gibtonite we are
@@ -766,7 +767,7 @@
defer_change = TRUE
/turf/closed/mineral/gibtonite/ice
icon_state = "icerock_Gibtonite"
icon_state = "icerock_Gibtonite_inactive"
icon = MAP_SWITCH('icons/turf/walls/icerock_wall.dmi', 'icons/turf/mining.dmi')
base_icon_state = "icerock_wall"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_BORDER
+43
View File
@@ -8,6 +8,49 @@
var/clawfootstep = null
var/heavyfootstep = null
/// Determines the type of damage overlay that will be used for the tile
var/damaged_dmi = null
var/broken = FALSE
var/burnt = FALSE
/// Returns a list of every turf state considered "broken".
/// Will be randomly chosen if a turf breaks at runtime.
/turf/open/proc/broken_states()
return list()
/// Returns a list of every turf state considered "burnt".
/// Will be randomly chosen if a turf is burnt at runtime.
/turf/open/proc/burnt_states()
return list()
/turf/open/break_tile()
if(isnull(damaged_dmi) || broken)
return FALSE
broken = TRUE
update_appearance()
return TRUE
/turf/open/burn_tile()
if(isnull(damaged_dmi) || burnt)
return FALSE
burnt = TRUE
update_appearance()
return TRUE
/turf/open/update_overlays()
if(isnull(damaged_dmi))
return ..()
. = ..()
if(broken)
. += mutable_appearance(damaged_dmi, pick(broken_states()))
else if(burnt)
var/list/burnt_states = burnt_states()
if(burnt_states.len)
. += mutable_appearance(damaged_dmi, pick(burnt_states))
else
. += mutable_appearance(damaged_dmi, pick(broken_states()))
//direction is direction of travel of A
/turf/open/zPassIn(atom/movable/A, direction, turf/source)
if(direction == DOWN)
+30 -13
View File
@@ -6,6 +6,7 @@
desc = "It's coarse and rough and gets everywhere."
baseturfs = /turf/open/misc/asteroid
icon = 'icons/turf/floors.dmi'
damaged_dmi = 'icons/turf/floors.dmi'
icon_state = "asteroid"
base_icon_state = "asteroid"
@@ -24,13 +25,23 @@
var/obj/item/stack/dig_result = /obj/item/stack/ore/glass
/// Whether the turf has been dug or not
var/dug = FALSE
/// Icon state to use when broken
var/broken_state = "asteroid_dug"
/// Percentage chance of receiving a bonus worm
var/worm_chance = 30
/turf/open/misc/asteroid/broken_states()
if(initial(dug))
return list(icon_state)
return list("[base_icon_state]_dug")
/turf/open/misc/asteroid/break_tile()
icon_state = broken_state
. = ..()
if(!.)
return FALSE
dug = TRUE
return TRUE
/turf/open/misc/asteroid/burn_tile()
return
/turf/open/misc/asteroid/Initialize(mapload)
var/proper_name = name
@@ -42,10 +53,11 @@
/// Drops itemstack when dug and changes icon
/turf/open/misc/asteroid/proc/getDug()
dug = TRUE
broken = TRUE
new dig_result(src, 5)
if (prob(worm_chance))
new /obj/item/food/bait/worm(src)
icon_state = "[base_icon_state]_dug"
update_appearance()
/// If the user can dig the turf
/turf/open/misc/asteroid/proc/can_dig(mob/user)
@@ -99,6 +111,10 @@
base_icon_state = "asteroid_dug"
icon_state = "asteroid_dug"
/turf/open/misc/asteroid/dug/broken_states()
return list("asteroid_dug")
/turf/open/misc/asteroid/lavaland_atmos
initial_gas_mix = LAVALAND_DEFAULT_ATMOS
planetary_atmos = TRUE
@@ -115,7 +131,6 @@ GLOBAL_LIST_EMPTY(dug_up_basalt)
base_icon_state = "basalt"
floor_variance = 15
dig_result = /obj/item/stack/ore/glass/basalt
broken_state = "basalt_dug"
/turf/open/misc/asteroid/basalt/getDug()
set_light(0)
@@ -171,10 +186,10 @@ GLOBAL_LIST_EMPTY(dug_up_basalt)
name = "snow"
desc = "Looks cold."
icon = 'icons/turf/snow.dmi'
damaged_dmi = 'icons/turf/snow.dmi'
baseturfs = /turf/open/misc/asteroid/snow
icon_state = "snow"
base_icon_state = "snow"
broken_state = "snow_dug"
initial_gas_mix = FROZEN_ATMOS
slowdown = 2
flags_1 = NONE
@@ -182,17 +197,19 @@ GLOBAL_LIST_EMPTY(dug_up_basalt)
bullet_sizzle = TRUE
bullet_bounce_sound = null
dig_result = /obj/item/stack/sheet/mineral/snow
var/burnt = FALSE
/turf/open/misc/asteroid/snow/burn_tile()
if(!burnt)
visible_message(span_danger("[src] melts away!."))
slowdown = 0
burnt = TRUE
icon_state = "snow_dug"
update_appearance()
return TRUE
return FALSE
/turf/open/misc/grass/burnt_states()
return list("snow_dug")
/turf/open/misc/asteroid/snow/icemoon
baseturfs = /turf/open/openspace/icemoon
initial_gas_mix = ICEMOON_DEFAULT_ATMOS
@@ -222,9 +239,13 @@ GLOBAL_LIST_EMPTY(dug_up_basalt)
barefootstep = FOOTSTEP_HARD_BAREFOOT
clawfootstep = FOOTSTEP_HARD_CLAW
heavyfootstep = FOOTSTEP_GENERIC_HEAVY
damaged_dmi = null
/turf/open/misc/asteroid/snow/ice/break_tile()
return
return FALSE
/turf/open/misc/asteroid/snow/ice/burn_tile()
return FALSE
/turf/open/misc/asteroid/snow/ice/icemoon
baseturfs = /turf/open/misc/asteroid/snow/ice/icemoon
@@ -232,9 +253,6 @@ GLOBAL_LIST_EMPTY(dug_up_basalt)
planetary_atmos = TRUE
slowdown = 0
/turf/open/misc/asteroid/snow/ice/burn_tile()
return FALSE
/turf/open/misc/asteroid/snow/airless
initial_gas_mix = AIRLESS_ATMOS
worm_chance = 0
@@ -272,7 +290,6 @@ GLOBAL_LIST_EMPTY(dug_up_basalt)
base_icon_state = "moon"
floor_variance = 40
dig_result = /obj/item/stack/ore/glass/basalt
broken_state = "moon_dug"
/turf/open/misc/asteroid/moon/dug //When you want one of these to be already dug.
dug = TRUE
+3 -47
View File
@@ -20,11 +20,7 @@
overfloor_placed = TRUE
/// Determines the type of damage overlay that will be used for the tile
var/damaged_dmi = 'icons/turf/damaged.dmi'
var/broken = FALSE
var/burnt = FALSE
damaged_dmi = 'icons/turf/damaged.dmi'
/// Path of the tile that this floor drops
var/floor_tile = null
/// Determines if you can deconstruct this with a RCD
@@ -32,33 +28,16 @@
/turf/open/floor/Initialize(mapload)
. = ..()
if (PERFORM_ALL_TESTS(focus_only/valid_turf_states))
var/static/list/previous_errors = list()
if (!(type in previous_errors))
if (broken != (icon_state in broken_states()))
stack_trace("[icon_state] (from [type]), which should be [broken ? "NOT broken, IS" : "broken, IS NOT"]")
previous_errors[type] = TRUE
if (burnt != (icon_state in burnt_states()))
stack_trace("[icon_state] (from [type]), which should be [burnt ? "NOT burnt, IS" : "burnt, IS NOT"]")
previous_errors[type] = TRUE
if(mapload && prob(33))
MakeDirty()
if(is_station_level(z))
GLOB.station_turfs += src
/// Returns a list of every turf state considered "broken".
/// Will be randomly chosen if a turf breaks at runtime.
/turf/open/floor/proc/broken_states()
/turf/open/floor/broken_states()
return list("damaged1", "damaged2", "damaged3", "damaged4", "damaged5")
/// Returns a list of every turf state considered "burnt".
/// Will be randomly chosen if a turf is burnt at runtime.
/turf/open/floor/proc/burnt_states()
/turf/open/floor/burnt_states()
return list()
/turf/open/floor/Destroy()
@@ -123,29 +102,6 @@
return
T.break_tile()
/turf/open/floor/break_tile()
if(broken)
return
broken = TRUE
update_appearance()
/turf/open/floor/burn_tile()
if(burnt)
return
burnt = TRUE
update_appearance()
/turf/open/floor/update_overlays()
. = ..()
if(broken)
. += mutable_appearance(damaged_dmi, pick(broken_states()))
else if(burnt)
var/list/burnt_states = burnt_states()
if(burnt_states.len)
. += mutable_appearance(damaged_dmi, pick(burnt_states))
else
. += mutable_appearance(damaged_dmi, pick(broken_states()))
/// Things seem to rely on this actually returning plating. Override it if you have other baseturfs.
/turf/open/floor/proc/make_plating(force = FALSE)
return ScrapeAway(flags = CHANGETURF_INHERIT_AIR)
+6 -3
View File
@@ -133,7 +133,7 @@
/turf/open/floor/grass
name = "grass patch"
desc = "You can't tell if this is real grass or just cheap plastic imitation."
icon_state = "grass0"
icon_state = "grass"
floor_tile = /obj/item/stack/tile/grass
flags_1 = NONE
bullet_bounce_sound = null
@@ -144,7 +144,7 @@
tiled_dirt = FALSE
/turf/open/floor/grass/broken_states()
return list("sand")
return list("[initial(icon_state)]_damaged")
/turf/open/floor/grass/Initialize(mapload)
. = ..()
@@ -161,6 +161,7 @@
icon_state = "sand"
broken = TRUE
initial_gas_mix = LAVALAND_DEFAULT_ATMOS
damaged_dmi = 'icons/turf/damaged.dmi'
/turf/open/floor/grass/lavaland/spawniconchange()
return
@@ -168,7 +169,7 @@
/turf/open/floor/grass/fairy //like grass but fae-er
name = "fairygrass patch"
desc = "Something about this grass makes you want to frolic. Or get high."
icon_state = "fairygrass0"
icon_state = "fairygrass"
floor_tile = /obj/item/stack/tile/fairygrass
light_range = 2
light_power = 0.80
@@ -181,6 +182,7 @@
gender = PLURAL
name = "snow"
icon = 'icons/turf/snow.dmi'
damaged_dmi = 'icons/turf/snow.dmi'
desc = "Looks cold."
icon_state = "snow"
flags_1 = NONE
@@ -823,6 +825,7 @@
floor_tile = /obj/item/stack/tile/fakespace
plane = PLANE_SPACE
tiled_dirt = FALSE
damaged_dmi = 'icons/turf/space.dmi'
/turf/open/floor/fakespace/broken_states()
return list("damaged")
+3 -2
View File
@@ -11,7 +11,7 @@
/turf/open/floor/mineral
name = "mineral floor"
icon_state = ""
icon_state = null
material_flags = MATERIAL_EFFECTS
var/list/icons
tiled_dirt = FALSE
@@ -22,7 +22,7 @@
icons = typelist("icons", icons)
/turf/open/floor/mineral/broken_states()
return list("[initial(icon_state)]_dam")
return isnull(icon_state) ? list() : list("[initial(icon_state)]_dam")
/turf/open/floor/mineral/update_icon_state()
if(!broken && !burnt && !(icon_state in icons))
@@ -288,6 +288,7 @@
icons = list("alienpod1", "alienpod2", "alienpod3", "alienpod4", "alienpod5", "alienpod6", "alienpod7", "alienpod8", "alienpod9")
baseturfs = /turf/open/floor/plating/abductor2
custom_materials = list(/datum/material/alloy/alien = SMALL_MATERIAL_AMOUNT*5)
damaged_dmi = null
/turf/open/floor/mineral/abductor/Initialize(mapload)
. = ..()
@@ -17,9 +17,7 @@
tiled_dirt = FALSE
// Not actually broken, just should never break...yeah.
broken = TRUE
/turf/open/floor/plating/abductor/broken_states()
return list("alienpod1")
damaged_dmi = null
/turf/open/floor/plating/abductor/Initialize(mapload)
. = ..()
@@ -30,6 +28,7 @@
icon_state = "alienplating"
base_icon_state = "alienplating"
tiled_dirt = FALSE
damaged_dmi = null
/turf/open/floor/plating/abductor2/break_tile()
return //unbreakable
+10 -5
View File
@@ -2,7 +2,7 @@
name = "grass"
desc = "A patch of grass."
icon = 'icons/turf/floors.dmi'
icon_state = "grass0"
icon_state = "grass"
base_icon_state = "grass"
baseturfs = /turf/open/misc/sandy_dirt
bullet_bounce_sound = null
@@ -14,12 +14,14 @@
smoothing_groups = SMOOTH_GROUP_TURF_OPEN + SMOOTH_GROUP_FLOOR_GRASS
canSmoothWith = SMOOTH_GROUP_FLOOR_GRASS + SMOOTH_GROUP_CLOSED_TURFS
layer = HIGH_TURF_LAYER
var/damaged_dmi = 'icons/turf/floors/grass.dmi'
damaged_dmi = 'icons/turf/damaged.dmi'
var/smooth_icon = 'icons/turf/floors/grass.dmi'
/turf/open/misc/grass/break_tile()
. = ..()
icon_state = "damaged"
/turf/open/misc/grass/broken_states()
return list("grass_damaged")
/turf/open/misc/grass/burnt_states()
return list("grass_damaged")
/turf/open/misc/grass/Initialize(mapload)
. = ..()
@@ -29,5 +31,8 @@
transform = translation
icon = smooth_icon
if(is_station_level(z))
GLOB.station_turfs += src
/turf/open/misc/grass/lavaland
initial_gas_mix = LAVALAND_DEFAULT_ATMOS
-1
View File
@@ -4,7 +4,6 @@
/turf/open/misc
name = "coder/mapper fucked up"
desc = "report on github please"
icon_state = "BROKEN"
flags_1 = NO_SCREENTIPS_1
turf_flags = CAN_BE_DIRTY_1 | IS_SOLID | NO_RUST
+6 -1
View File
@@ -52,9 +52,14 @@
desc = "Greener on the other side."
icon_state = "junglegrass"
base_icon_state = "junglegrass"
damaged_dmi = 'icons/turf/floors/junglegrass.dmi'
smooth_icon = 'icons/turf/floors/junglegrass.dmi'
/turf/open/misc/grass/broken_states()
return list("jungle_damaged")
/turf/open/misc/grass/burnt_states()
return list("jungle_damaged")
/turf/closed/mineral/random/jungle
baseturfs = /turf/open/misc/dirt/dark
+3 -3
View File
@@ -2,6 +2,7 @@
gender = PLURAL
name = "snow"
icon = 'icons/turf/snow.dmi'
damaged_dmi = 'icons/turf/snow.dmi'
desc = "Looks cold."
icon_state = "snow"
planetary_atmos = TRUE
@@ -17,9 +18,8 @@
. = ..()
AddElement(/datum/element/diggable, /obj/item/stack/sheet/mineral/snow, 2)
/turf/open/misc/snow/break_tile()
. = ..()
icon_state = "snow_dug"
/turf/open/misc/snow/broken_states()
return list("snow_dug")
/turf/open/misc/snow/actually_safe
slowdown = 0
+1
View File
@@ -230,6 +230,7 @@
#include "timer_sanity.dm"
#include "trait_addition_and_removal.dm"
#include "traitor.dm"
#include "turf_icons.dm"
#include "tutorial_sanity.dm"
#include "unit_test.dm"
#include "verify_config_tags.dm"
+44
View File
@@ -0,0 +1,44 @@
/// Makes sure turf icons actually exist. :)
/datum/unit_test/turf_icons
/datum/unit_test/turf_icons/Run()
for(var/turf/turf_path as anything in (subtypesof(/turf) - typesof(/turf/closed/mineral)))
var/icon_state = initial(turf_path.icon_state)
var/icon_file = initial(turf_path.icon)
if(isnull(icon_state) || isnull(icon_file))
continue
if(!(icon_state in icon_states(icon_file)))
TEST_FAIL("[turf_path] using invalid icon_state - \"[icon_state]\" in icon file, '[icon_file]")
for(var/turf/closed/mineral/turf_path as anything in typesof(/turf/closed/mineral)) //minerals use a special (read: snowflake) MAP_SWITCH definition that changes their icon based on if we're just compiling or if we're actually PLAYING the game.
var/icon_state = initial(turf_path.icon_state)
var/icon_file = 'icons/turf/mining.dmi'
if(isnull(icon_state))
continue
if(!(icon_state in icon_states(icon_file)))
TEST_FAIL("[turf_path] using invalid icon_state - \"[icon_state]\" in icon file, '[icon_file]")
var/turf/initial_turf_type = run_loc_floor_bottom_left.type
for(var/turf/open/open_turf_path as anything in subtypesof(/turf/open))
var/damaged_dmi = initial(open_turf_path.damaged_dmi)
if(isnull(damaged_dmi))
continue
var/turf/open/instanced_turf = run_loc_floor_bottom_left.ChangeTurf(open_turf_path)
var/list/burnt_states = instanced_turf.burnt_states()
for(var/state in burnt_states)
if(!(state in icon_states(damaged_dmi)))
TEST_FAIL("[open_turf_path] has an invalid icon in burnt_states - \"[state]\", in '[damaged_dmi]'")
var/list/broken_states = instanced_turf.broken_states()
for(var/state in broken_states)
if(!(state in icon_states(damaged_dmi)))
TEST_FAIL("[open_turf_path] has an invalid icon in broken_states - \"[state]\", in '[damaged_dmi]'")
run_loc_floor_bottom_left = run_loc_floor_bottom_left.ChangeTurf(initial_turf_type) //cleanup.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 KiB

After

Width:  |  Height:  |  Size: 362 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB