move the internal preview to canvas (#18930)

* move the internal preview to canvas

* use a helper

* basic readme prep

* .

* .

* transform  better

* byond can't handle icon states of large files...

* move fully to the rust version

* fix typing

* just wtf. NO

* fix the legacy path

* keep it all centralized

* tiny oversight

* unit test rewrite

* rename

* fix bad layering

* fixes a bunch of layering issues

* artifact

* move crash to log_runtime

* missing overlay warning

* why not
This commit is contained in:
Kashargul
2025-12-24 05:28:39 +01:00
committed by GitHub
parent c4134dbf04
commit 92182e0946
79 changed files with 477 additions and 310 deletions
+2 -2
View File
@@ -105,7 +105,6 @@
#include "map_tests.dm"
#include "mapping.dm"
#include "material_tests.dm"
#include "mob_vbo_test.dm"
// #include "nuke_cinematic.dm" // TODO: This is probably fixed later on
#include "poster_tests.dm"
// #include "preferences.dm" // This unit test is missing some other stuff
@@ -121,7 +120,8 @@
#include "timer_sanity.dm"
#include "trait_tests.dm"
#include "unit_test.dm"
// #include "vore_tests.dm" // FIXME: REWRITE OR FIX THIS
#include "vbo_tests.dm"
#include "vore_tests.dm"
// END_INCLUDE
#ifdef REFERENCE_TRACKING_DEBUG //Don't try and parse this file if ref tracking isn't turned on. IE: don't parse ref tracking please mr linter
#include "find_reference_sanity.dm"
@@ -1,3 +1,12 @@
/// Tests that all mobs with assigned bellies use valid datums
/datum/unit_test/vbo_has_state
/datum/unit_test/vbo_has_state/Run()
for(var/datum/belly_overlays/test_path as anything in subtypesof(/datum/belly_overlays))
var/icon_name = icon_states_fast(initial(test_path.belly_icon))[1]
if(!(icon_exists('icons/mob/vore_fullscreens/ui_lists/screen_full_vore_list_base.dmi', icon_name)))
TEST_FAIL("[test_path] is missing inside the screen_full_vore_list_base list dmi file.")
/// Tests that all mobs with assigned bellies use valid datums
/datum/unit_test/mobs_use_valid_belly_overlays
+64 -175
View File
@@ -1,214 +1,103 @@
/// converted unit test, maybe should be fully refactored
/datum/unit_test/proc/create_test_human(turf/loc = null)
if(!loc)
for(var/turf/simulated/floor/tiled/T in world)
var/pressure = T.zone.air.return_pressure()
if(90 < pressure && pressure < 120) // Find a turf between 90 and 120
loc = T
break
// FIXME: THIS SHOULD BE REPLACED WITH ALLOCATE IN THE END
// SEE unit_test.dm NEW() WHY THIS ISNT IMPLEMENTED YET
/datum/unit_test
var/static/default_mobloc = null
TEST_ASSERT(loc, "No valid turf available for test mob")
// FIXME: THIS SHOULD BE REPLACED WITH ALLOCATE IN THE END
// SEE unit_test.dm NEW() WHY THIS ISNT IMPLEMENTED YET
/datum/unit_test/proc/create_test_mob(var/turf/mobloc = null, var/mobtype = /mob/living/carbon/human, var/with_mind = FALSE)
if(isnull(mobloc))
if(!default_mobloc)
for(var/turf/simulated/floor/tiled/T in world)
var/pressure = T.zone.air.return_pressure()
if(90 < pressure && pressure < 120) // Find a turf between 90 and 120
default_mobloc = T
break
mobloc = default_mobloc
if(!mobloc)
fail("Unable to find a location to create test mob")
return 0
var/mob/living/carbon/human/test_human = allocate(/mob/living/carbon/human, loc)
var/mob/living/carbon/human/H = new mobtype(mobloc)
return test_human
if(with_mind)
H.mind_initialize("TestKey[rand(0,10000)]")
return H
/// Test that a human mob does not suffocate in a belly
/datum/unit_test/belly_nonsuffocation
var/startLifeTick
var/startOxyloss
var/endOxyloss
var/mob/living/carbon/human/pred
var/mob/living/carbon/human/prey
/datum/unit_test/belly_nonsuffocation/Run()
pred = create_test_mob()
if(!istype(pred))
return 0
prey = create_test_mob(pred.loc)
if(!istype(prey))
return 0
var/mob/living/carbon/human/pred = create_test_human()
var/mob/living/carbon/human/prey = create_test_human()
return 1
TEST_ASSERT(pred && prey, "Failed to create test mobs")
/datum/unit_test/belly_nonsuffocation/check_result()
// Unfortuantely we need to wait for the pred's belly to initialize. (Currently after a spawn())
if(!pred.vore_organs || !pred.vore_organs.len)
return 0
pred.init_vore(TRUE)
TEST_ASSERT(pred.vore_selected, "[pred] has no vore_selected")
// Now that pred belly exists, we can eat the prey.
if(!pred.vore_selected)
fail("[pred] has no vore_selected.")
return 1
pred.vore_selected.nom_mob(prey)
// Attempt to eat the prey
if(prey.loc != pred.vore_selected)
pred.vore_selected.nom_mob(prey)
TEST_ASSERT(prey.loc == pred.vore_selected, "Prey not inside predator belly")
if(prey.loc != pred.vore_selected)
fail("[pred.vore_selected].nom_mob([prey]) did not put prey inside [pred]")
return 1
var/start_oxy = prey.getOxyLoss()
var/end_tick = pred.life_tick + 10
// Okay, we succeeded in eating them, now lets wait a bit
startLifeTick = pred.life_tick
startOxyloss = prey.getOxyLoss()
return 0
while(pred.life_tick < end_tick)
sleep(1)
if(pred.life_tick < (startLifeTick + 10))
return 0 // Wait for them to breathe a few times
var/end_oxy = prey.getOxyLoss()
if(end_oxy > start_oxy)
TEST_FAIL("Prey took oxygen damage in belly (before: [start_oxy], after: [end_oxy])")
// Alright lets check it!
endOxyloss = prey.getOxyLoss()
if(startOxyloss < endOxyloss)
fail("Prey takes oxygen damage in a pred's belly! (Before: [startOxyloss]; after: [endOxyloss])")
else
pass("Prey is not taking oxygen damage in pred's belly. (Before: [startOxyloss]; after: [endOxyloss])")
qdel(prey)
qdel(pred)
return 1
////////////////////////////////////////////////////////////////
/datum/unit_test/belly_spacesafe
name = "MOB: human mob protected from space in a belly"
var/startLifeTick
var/startOxyloss
var/endOxyloss
var/mob/living/carbon/human/pred
var/mob/living/carbon/human/prey
async = 1
/datum/unit_test/belly_spacesafe/start_test()
pred = create_test_mob()
if(!istype(pred))
return 0
prey = create_test_mob(pred.loc)
if(!istype(prey))
return 0
/datum/unit_test/belly_spacesafe/Run()
var/mob/living/carbon/human/pred = create_test_human()
var/mob/living/carbon/human/prey = create_test_human()
return 1
TEST_ASSERT(pred && prey, "Failed to create test mobs")
/datum/unit_test/belly_spacesafe/check_result()
// Unfortuantely we need to wait for the pred's belly to initialize. (Currently after a spawn())
if(!pred.vore_organs || !pred.vore_organs.len)
return 0
pred.init_vore(TRUE)
TEST_ASSERT(pred.vore_selected, "[pred] has no vore_selected")
// Now that pred belly exists, we can eat the prey.
if(!pred.vore_selected)
fail("[pred] has no vore_selected.")
return 1
pred.vore_selected.nom_mob(prey)
// Attempt to eat the prey
if(prey.loc != pred.vore_selected)
pred.vore_selected.nom_mob(prey)
TEST_ASSERT(prey.loc == pred.vore_selected, "Prey not inside predator belly")
if(prey.loc != pred.vore_selected)
fail("[pred.vore_selected].nom_mob([prey]) did not put prey inside [pred]")
return 1
else
// Get an empty space level instead of just picking a random space turf
var/empty_z = using_map.get_empty_zlevel()
if(!empty_z)
fail("Unable to get empty z-level for vore space protection test!")
return 1
var/empty_z = using_map.get_empty_zlevel()
TEST_ASSERT(empty_z, "Failed to get empty z-level")
// Away from map edges so they don't transit while we're testing
var/mid_w = round(world.maxx*0.5)
var/mid_h = round(world.maxy*0.5)
var/turf/space_turf = locate(
round(world.maxx * 0.5),
round(world.maxy * 0.5),
empty_z
)
var/turf/T = locate(mid_w, mid_h, empty_z)
TEST_ASSERT(space_turf, "Failed to locate space turf")
if(!T)
fail("Unable to get turf for vore space protection test!")
return 1
else
pred.forceMove(T)
pred.forceMove(space_turf)
// Okay, we succeeded in eating them, now lets wait a bit
startLifeTick = pred.life_tick
startOxyloss = prey.getOxyLoss()
return 0
var/start_oxy = prey.getOxyLoss()
var/end_tick = pred.life_tick + 10
if(pred.life_tick < (startLifeTick + 10))
return 0 // Wait for them to breathe a few times
while(pred.life_tick < end_tick)
sleep(1)
// Alright lets check it!
endOxyloss = prey.getOxyLoss()
if(startOxyloss < endOxyloss)
fail("Prey takes oxygen damage in space! (Before: [startOxyloss]; after: [endOxyloss])")
else
pass("Prey is not taking oxygen damage in space. (Before: [startOxyloss]; after: [endOxyloss])")
var/end_oxy = prey.getOxyLoss()
if(end_oxy > start_oxy)
TEST_FAIL("Prey took oxygen damage in space belly (before: [start_oxy], after: [end_oxy])")
qdel(prey)
qdel(pred)
return 1
////////////////////////////////////////////////////////////////
/datum/unit_test/belly_damage
name = "MOB: human mob takes damage from digestion"
var/startLifeTick
var/startBruteBurn
var/endBruteBurn
var/mob/living/carbon/human/pred
var/mob/living/carbon/human/prey
async = 1
/datum/unit_test/belly_damage/start_test()
pred = create_test_mob()
if(!istype(pred))
return 0
prey = create_test_mob(pred.loc)
if(!istype(prey))
return 0
/datum/unit_test/belly_damage/Run()
var/mob/living/carbon/human/pred = create_test_human()
var/mob/living/carbon/human/prey = create_test_human()
return 1
TEST_ASSERT(pred && prey, "Failed to create test mobs")
/datum/unit_test/belly_damage/check_result()
// Unfortuantely we need to wait for the pred's belly to initialize. (Currently after a spawn())
if(!pred.vore_organs || !pred.vore_organs.len)
return 0
pred.init_vore(TRUE)
TEST_ASSERT(pred.vore_selected, "[pred] has no vore_selected")
// Now that pred belly exists, we can eat the prey.
if(!pred.vore_selected)
fail("[pred] has no vore_selected.")
return 1
pred.vore_selected.nom_mob(prey)
// Attempt to eat the prey
if(prey.loc != pred.vore_selected)
pred.vore_selected.nom_mob(prey)
TEST_ASSERT(prey.loc == pred.vore_selected, "Prey not inside predator belly")
if(prey.loc != pred.vore_selected)
fail("[pred.vore_selected].nom_mob([prey]) did not put prey inside [pred]")
return 1
pred.vore_selected.digest_mode = DM_DIGEST
// Okay, we succeeded in eating them, now lets wait a bit
pred.vore_selected.digest_mode = DM_DIGEST
startLifeTick = pred.life_tick
startBruteBurn = prey.getBruteLoss() + prey.getFireLoss()
return 0
var/start_damage = prey.getBruteLoss() + prey.getFireLoss()
var/end_tick = pred.life_tick + 10
if(pred.life_tick < (startLifeTick + 10))
return 0 // Wait a few ticks for damage to happen
while(pred.life_tick < end_tick)
sleep(1)
// Alright lets check it!
endBruteBurn = prey.getBruteLoss() + prey.getFireLoss()
if(startBruteBurn >= endBruteBurn)
fail("Prey doesn't take damage in digesting belly! (Before: [startBruteBurn]; after: [endBruteBurn])")
else
pass("Prey is taking damage in pred's belly. (Before: [startBruteBurn]; after: [endBruteBurn])")
qdel(prey)
qdel(pred)
return 1
var/end_damage = prey.getBruteLoss() + prey.getFireLoss()
if(end_damage <= start_damage)
TEST_FAIL("Prey took no digestion damage (before: [start_damage], after: [end_damage])")