vis_contents behaves in an unpredictable and seemingly random way when setting it's value directly to a list on turfs. There are also some kind of rendering problems.
This originally came up when I was trying to update our atmospherics system (ParadiseSS13/Paradise), using code similar to, but not identical to https://github.com/tgstation/tgstation/pull/32569
I've been unable to reproduce the exact problems I found there on a test project- vis_contents was outright ignoring updates. Essentially, the difference boiled down to leaving line 119 (atmos_overlay_types = new_overlay_types) outside of the #if directive, therefore giving me something to compare vis_contents to; The only place atmos_overlay_types is set is inside the update_visuals() proc, after vis_contents is set to the exact same variable. And yet, using our debugging tools to compare the variables, the values were different- atmos_overlays_types had the correct list inside of it, and vis_contents was an empty list. These results were reflected in the visual rendering as well.
https://gfycat.com/ColossalEqualGoldenretriever
Numbered Steps to Reproduce Problem:
1. Make a map with icons which is suitably large (I have used 255x255 for my tests)
2. Start a loop that applies a 1-item list of some kind of stand-out visual to the vis_contents of each turf in the map, with suitable sleep() to avoid crashing
3. Include a world << message in your loop to confirm vis_contents has been set to the correct value (I use `world << "[json_encode(vis_contents)]"
4. Observe the inconsistent behavior as you walk along the map- some tiles flatly do not render at first, but if you move them out of range (specifically by walking to the right) and come back, they'll render correctly
Code Snippet (if applicable) to Reproduce Problem:
/world/fps = 60
/atom/icon = 'icons.dmi'
/mob/icon_state = "mob"
/mob/Stat() stat("loc", "[x] [y] [z]")
/obj/effect/New(loc, icon) {. = ..() ; icon_state = icon}
var/obj/effect/plmaster = new(null, "plmaster")
var/obj/effect/slmaster = new(null, "slmaster")
/turf
var/p
var/s
var/list/vis_contents_list = list()
icon_state = "turf"
/turf/New()
if(prob(50)) p = 1
else s = 1
/turf/proc/update_visuals()
var/list/overlays = get_overlay()
vis_contents = overlays
vis_contents_list = overlays
world << "turf at [x] [y] [z] set to [json_encode(vis_contents)]"
if(vis_contents.len != vis_contents_list.len)
world << "ERR [x] [y] [z] [p] [s]"
/turf/proc/get_overlay()
. = new /list
if(p) . += plmaster
if(s) . += slmaster
/client/New()
. = ..()
src << "starting in 5 seconds"
spawn(50)
while(1)
for(var/turf/T in block(locate(1, 1, 1), locate(255, 255, 1)))
T.update_visuals()
sleep(2)
src << "cycled"
sleep(20)
/mob/verb/check_turf_visuals()
var/turf/T = loc
src << "p: [T.p], s: [T.s] | [json_encode(T.vis_contents)], [json_encode(T.vis_contents_list)]"
Expected Results:
vis_contents would consistently render correctly to the user
Actual Results:
vis_contents does not consistently render correctly to the user
Does the problem occur:
Every time? Or how often? Every time.
In other games? SS13.
In other user accounts? Yes.
On other computers? Yes.
When does the problem NOT occur?
Unknown.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
The test project above functions correctly in 512.1391, 512.1392, 512.1393, and stops working in 512.1394 and 512.1395
Workarounds:
Unknown.
</<>