Port SSoverlays & Convert turfs to use it (#5004)

* Added "Display Initialize() Log" admin debug command so you can see it mid-round.

* Ported the core of the overlays management subsystem from /tg

- Added SSoverlays subsystem for compiling overlay lists and applying them to atoms in a controlled anti-lag subsystem.
- Added vars and procs to atom which should eventually replace all direct interaction with BYOND's /atom/overlays var outside the subsystem.
- Added OVERLAY_QUEUED flag to var/atom/flags bitfield.
- Added small framework for subsystem performance tracking. So far used only by SSoverlays
- Added admin debug command "Display overlay Log" to see performance stats mid-round.

* Fix runtime on universal pipe adaptor update_icons

* Workaround for appearance_bro not initialized

Unfortuantely BYOND's initialization order is strange, and the appearance_bro var is only half initialized when map starts to load, causing errors.  We temporarily fix by moving it to be a global-scoped global.

* Convert fire alarms to use add_overlay() A good first test.

* Convert turfs to use add_overlays(), eliminating the turf_overlay_holder!

- Converted as much as I could find about turf overlays to use add_overlay().
- This should be enough to stop BYOND from crashing, so we can eliminate the turf_overlay_holder hack.
- This also lets us remove the anti-corruption hacks from walls and open space.
- ZAS gas overlays can use priority overlays, so this also fixes the gas-goes-away-when-crowbarring-plating issue.
- Stuff like that

* Convert turf overlay interactions to use add_overlay.

Note: This is a plain and simple conversion of existing code to use SSoverlays. However I look at the line changed, and note that that line likely never fully worked as intended, as it has no way of re-applying itself.
I would make it use a priority overlay, but there is no code present for *removing* said overlay from neighbors when it is no longer required.  That code should be implemented by original author.
This commit is contained in:
Leshana
2018-03-05 20:43:23 -05:00
committed by Anewbe
parent 9acf3f8297
commit 741e02407a
33 changed files with 454 additions and 248 deletions

View File

@@ -28,7 +28,7 @@
universal_underlays(node2)
else
universal_underlays(,dir)
universal_underlays(dir, -180)
universal_underlays(,turn(dir, -180))
/obj/machinery/atmospherics/pipe/simple/visible/universal/update_underlays()
..()

View File

@@ -6,9 +6,9 @@
/turf/simulated/proc/update_graphic(list/graphic_add = null, list/graphic_remove = null)
if(LAZYLEN(graphic_add))
overlays += graphic_add
add_overlay(graphic_add, priority = TRUE)
if(LAZYLEN(graphic_remove))
overlays -= graphic_remove
cut_overlay(graphic_remove, priority = TRUE)
/turf/proc/update_air_properties()
var/block = c_airblock(src)

View File

@@ -36,7 +36,7 @@
#define ACCESSORY_SLOT_ARMOR_M "Misc armor"
#define ACCESSORY_SLOT_HELM_C "Helmet cover"
// Flags bitmasks.
// Flags bitmasks. - Used in /atom/var/flags
#define NOBLUDGEON 0x1 // When an item has this it produces no "X has been hit by Y with Z" message with the default handler.
#define CONDUCT 0x2 // Conducts electricity. (metal etc.)
#define ON_BORDER 0x4 // Item has priority to check when entering or leaving.
@@ -45,8 +45,9 @@
#define PHORONGUARD 0x20 // Does not get contaminated by phoron.
#define NOREACT 0x40 // Reagents don't react inside this container.
#define PROXMOVE 0x80 // Does this object require proximity checking in Enter()?
#define OVERLAY_QUEUED 0x100 // Atom queued to SSoverlay for COMPILE_OVERLAYS
//Flags for items (equipment)
//Flags for items (equipment) - Used in /obj/item/var/item_flags
#define THICKMATERIAL 0x1 // Prevents syringes, parapens and hyposprays if equipped to slot_suit or slot_head.
#define STOPPRESSUREDAMAGE 0x2 // Counts towards pressure protection. Note that like temperature protection, body_parts_covered is considered here as well.
#define AIRTIGHT 0x4 // Functions with internals.
@@ -54,13 +55,13 @@
#define BLOCK_GAS_SMOKE_EFFECT 0x10 // Blocks the effect that chemical clouds would have on a mob -- glasses, mask and helmets ONLY! (NOTE: flag shared with ONESIZEFITSALL)
#define FLEXIBLEMATERIAL 0x20 // At the moment, masks with this flag will not prevent eating even if they are covering your face.
// Flags for pass_flags.
// Flags for pass_flags. - Used in /atom/var/pass_flags
#define PASSTABLE 0x1
#define PASSGLASS 0x2
#define PASSGRILLE 0x4
#define PASSBLOB 0x8
// Bitmasks for the flags_inv variable. These determine when a piece of clothing hides another, i.e. a helmet hiding glasses.
// Bitmasks for the /obj/item/var/flags_inv variable. These determine when a piece of clothing hides another, i.e. a helmet hiding glasses.
// WARNING: The following flags apply only to the external suit!
#define HIDEGLOVES 0x1
#define HIDESUITSTORAGE 0x2

View File

@@ -9,6 +9,8 @@
#define REALTIMEOFDAY (world.timeofday + (MIDNIGHT_ROLLOVER * MIDNIGHT_ROLLOVER_CHECK))
#define MIDNIGHT_ROLLOVER_CHECK ( rollovercheck_last_timeofday != world.timeofday ? update_midnight_rollover() : midnight_rollovers )
#define SHORT_REAL_LIMIT 16777216 // 2^24 - Maximum integer that can be exactly represented in a float (BYOND num var)
#define CEILING(x, y) ( -round(-(x) / (y)) * (y) )
// round() acts like floor(x, 1) by default but can't handle other values
#define FLOOR(x, y) ( round((x) / (y)) * (y) )

View File

@@ -0,0 +1,17 @@
//
// Defines used for advanced performance profiling of subsystems.
// Currently used only by SSoverlays (2018-02-24 ~Leshana)
//
#define STAT_ENTRY_TIME 1
#define STAT_ENTRY_COUNT 2
#define STAT_ENTRY_LENGTH 2
#define STAT_START_STOPWATCH var/STAT_STOP_WATCH = TICK_USAGE
#define STAT_STOP_STOPWATCH var/STAT_TIME = TICK_USAGE_TO_MS(STAT_STOP_WATCH)
#define STAT_LOG_ENTRY(entrylist, entryname) \
var/list/STAT_ENTRY = entrylist[entryname] || (entrylist[entryname] = new /list(STAT_ENTRY_LENGTH));\
STAT_ENTRY[STAT_ENTRY_TIME] += STAT_TIME;\
var/STAT_INCR_AMOUNT = min(1, 2**round((STAT_ENTRY[STAT_ENTRY_COUNT] || 0)/SHORT_REAL_LIMIT));\
if (STAT_INCR_AMOUNT == 1 || prob(100/STAT_INCR_AMOUNT)) {\
STAT_ENTRY[STAT_ENTRY_COUNT] += STAT_INCR_AMOUNT;\
};\

View File

@@ -28,5 +28,35 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G
#define INIT_ORDER_MACHINES 10
#define INIT_ORDER_SHUTTLES 3
#define INIT_ORDER_LIGHTING 0
#define INIT_ORDER_AIR -1
#define INIT_ORDER_AIR -1
#define INIT_ORDER_OVERLAY -6
#define INIT_ORDER_XENOARCH -20
// Subsystem fire priority, from lowest to highest priority
// If the subsystem isn't listed here it's either DEFAULT or PROCESS (if it's a processing subsystem child)
#define FIRE_PRIORITY_OVERLAYS 500
// Macro defining the actual code applying our overlays lists to the BYOND overlays list. (I guess a macro for speed)
// TODO - I don't really like the location of this macro define. Consider it. ~Leshana
#define COMPILE_OVERLAYS(A)\
if (TRUE) {\
var/list/oo = A.our_overlays;\
var/list/po = A.priority_overlays;\
if(LAZYLEN(po)){\
if(LAZYLEN(oo)){\
A.overlays = oo + po;\
}\
else{\
A.overlays = po;\
}\
}\
else if(LAZYLEN(oo)){\
A.overlays = oo;\
}\
else{\
A.overlays.Cut();\
}\
A.flags &= ~OVERLAY_QUEUED;\
}

View File

@@ -36,3 +36,9 @@
. = b.head_position - a.head_position
if (. == 0) //Already in head/nothead spot, sort by name
. = sorttext(b.title, a.title)
// Sorts entries in a performance stats list.
/proc/cmp_generic_stat_item_time(list/A, list/B)
. = B[STAT_ENTRY_TIME] - A[STAT_ENTRY_TIME]
if (!.)
. = B[STAT_ENTRY_COUNT] - A[STAT_ENTRY_COUNT]

View File

@@ -800,7 +800,6 @@ proc/GaussRandRound(var/sigma,var/roundto)
var/old_dir1 = T.dir
var/old_icon_state1 = T.icon_state
var/old_icon1 = T.icon
var/old_overlays = T.overlays.Copy()
var/old_underlays = T.underlays.Copy()
var/old_decals = T.decals ? T.decals.Copy() : null
@@ -808,11 +807,9 @@ proc/GaussRandRound(var/sigma,var/roundto)
X.set_dir(old_dir1)
X.icon_state = old_icon_state1
X.icon = old_icon1
X.overlays = old_overlays
X.copy_overlays(T, TRUE)
X.underlays = old_underlays
X.decals = old_decals
if(old_decals)
X.apply_decals()
//Move the air from source to dest
var/turf/simulated/ST = T
@@ -838,14 +835,10 @@ proc/GaussRandRound(var/sigma,var/roundto)
if(shuttlework)
var/turf/simulated/shuttle/SS = T
SS.landed_holder.leave_turf()
else if(turftoleave)
T.ChangeTurf(turftoleave)
T.apply_decals()
else
T.ChangeTurf(get_base_turf_by_area(T))
T.apply_decals()
refined_src -= T
refined_trg -= B

View File

@@ -1,28 +0,0 @@
//
// Floor Decals Initialization Subsystem
// This is part of the giant decal hack that works around a BYOND bug where DreamDaemon will crash if you
// update overlays on turfs too much.
// The master_controller on Polaris used to init decals prior to initializing areas (which initilized turfs)
// Now that we switched to subsystems we still want to do the same thing, so this takes care of it.
//
SUBSYSTEM_DEF(floor_decals)
name = "Floor Decals"
init_order = INIT_ORDER_DECALS
flags = SS_NO_FIRE
/datum/controller/subsystem/floor_decals/Initialize(timeofday)
if(floor_decals_initialized)
return ..()
to_world_log("Initializing Floor Decals")
admin_notice("<span class='danger'>Initializing Floor Decals</span>", R_DEBUG)
var/list/turfs_with_decals = list()
for(var/obj/effect/floor_decal/D in world)
var/T = D.add_to_turf_decals()
if(T) turfs_with_decals |= T
CHECK_TICK
for(var/item in turfs_with_decals)
var/turf/T = item
if(T.decals) T.apply_decals()
CHECK_TICK
floor_decals_initialized = TRUE
return ..()

View File

@@ -0,0 +1,255 @@
SUBSYSTEM_DEF(overlays)
name = "Overlay"
flags = SS_TICKER
wait = 1
priority = FIRE_PRIORITY_OVERLAYS
init_order = INIT_ORDER_OVERLAY
var/initialized = FALSE
var/list/queue // Queue of atoms needing overlay compiling (TODO-VERIFY!)
var/list/stats
var/list/overlay_icon_state_caches // Cache thing
var/list/overlay_icon_cache // Cache thing
var/global/image/appearance_bro = new() // Temporarily super-global because of BYOND init order dumbness.
/datum/controller/subsystem/overlays/PreInit()
overlay_icon_state_caches = list()
overlay_icon_cache = list()
queue = list()
stats = list()
/datum/controller/subsystem/overlays/Initialize()
initialized = TRUE
fire(mc_check = FALSE)
..()
/datum/controller/subsystem/overlays/stat_entry()
..("Ov:[length(queue)]")
/datum/controller/subsystem/overlays/Shutdown()
//text2file(render_stats(stats), "[GLOB.log_directory]/overlay.log")
var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day")
text2file(render_stats(stats), "data/logs/[date_string]-overlay.log")
/datum/controller/subsystem/overlays/Recover()
overlay_icon_state_caches = SSoverlays.overlay_icon_state_caches
overlay_icon_cache = SSoverlays.overlay_icon_cache
queue = SSoverlays.queue
/datum/controller/subsystem/overlays/fire(resumed = FALSE, mc_check = TRUE)
var/list/queue = src.queue
var/static/count = 0
if (count)
var/c = count
count = 0 //so if we runtime on the Cut, we don't try again.
queue.Cut(1,c+1)
for (var/thing in queue)
count++
if(thing)
STAT_START_STOPWATCH
var/atom/A = thing
COMPILE_OVERLAYS(A)
STAT_STOP_STOPWATCH
STAT_LOG_ENTRY(stats, A.type)
if(mc_check)
if(MC_TICK_CHECK)
break
else
CHECK_TICK
if (count)
queue.Cut(1,count+1)
count = 0
/proc/iconstate2appearance(icon, iconstate)
var/static/image/stringbro = new()
var/list/icon_states_cache = SSoverlays.overlay_icon_state_caches
var/list/cached_icon = icon_states_cache[icon]
if (cached_icon)
var/cached_appearance = cached_icon["[iconstate]"]
if (cached_appearance)
return cached_appearance
stringbro.icon = icon
stringbro.icon_state = iconstate
if (!cached_icon) //not using the macro to save an associated lookup
cached_icon = list()
icon_states_cache[icon] = cached_icon
var/cached_appearance = stringbro.appearance
cached_icon["[iconstate]"] = cached_appearance
return cached_appearance
/proc/icon2appearance(icon)
var/static/image/iconbro = new()
var/list/icon_cache = SSoverlays.overlay_icon_cache
. = icon_cache[icon]
if (!.)
iconbro.icon = icon
. = iconbro.appearance
icon_cache[icon] = .
/atom/proc/build_appearance_list(old_overlays)
// var/static/image/appearance_bro = new() // Moved to be superglobal due to BYOND insane init order stupidness.
var/list/new_overlays = list()
if (!islist(old_overlays))
old_overlays = list(old_overlays)
for (var/overlay in old_overlays)
if(!overlay)
continue
if (istext(overlay))
new_overlays += iconstate2appearance(icon, overlay)
else if(isicon(overlay))
new_overlays += icon2appearance(overlay)
else
if(isloc(overlay))
var/atom/A = overlay
if (A.flags & OVERLAY_QUEUED)
COMPILE_OVERLAYS(A)
appearance_bro.appearance = overlay //this works for images and atoms too!
if(!ispath(overlay))
var/image/I = overlay
appearance_bro.dir = I.dir
new_overlays += appearance_bro.appearance
return new_overlays
#define NOT_QUEUED_ALREADY (!(flags & OVERLAY_QUEUED))
#define QUEUE_FOR_COMPILE flags |= OVERLAY_QUEUED; SSoverlays.queue += src;
/**
* Cut all of atom's normal overlays. Usually leaves "priority" overlays untouched.
*
* @param priority If true, also will cut priority overlays.
*/
/atom/proc/cut_overlays(priority = FALSE)
var/list/cached_overlays = our_overlays
var/list/cached_priority = priority_overlays
var/need_compile = FALSE
if(LAZYLEN(cached_overlays)) //don't queue empty lists, don't cut priority overlays
cached_overlays.Cut() //clear regular overlays
need_compile = TRUE
if(priority && LAZYLEN(cached_priority))
cached_priority.Cut()
need_compile = TRUE
if(NOT_QUEUED_ALREADY && need_compile)
QUEUE_FOR_COMPILE
/**
* Removes specific overlay(s) from the atom. Usually does not remove them from "priority" overlays.
*
* @param overlays The overlays to removed, type can be anything that is allowed for add_overlay().
* @param priority If true, also will remove them from the "priority" overlays.
*/
/atom/proc/cut_overlay(list/overlays, priority)
if(!overlays)
return
overlays = build_appearance_list(overlays)
var/list/cached_overlays = our_overlays //sanic
var/list/cached_priority = priority_overlays
var/init_o_len = LAZYLEN(cached_overlays)
var/init_p_len = LAZYLEN(cached_priority) //starter pokemon
LAZYREMOVE(cached_overlays, overlays)
if(priority)
LAZYREMOVE(cached_priority, overlays)
if(NOT_QUEUED_ALREADY && ((init_o_len != LAZYLEN(cached_overlays)) || (init_p_len != LAZYLEN(cached_priority))))
QUEUE_FOR_COMPILE
/**
* Adds specific overlay(s) to the atom.
* It is designed so any of the types allowed to be added to /atom/overlays can be added here too. More details below.
*
* @param overlays The overlay(s) to add. These may be
* - A string: In which case it is treated as an icon_state of the atom's icon.
* - An icon: It is treated as an icon.
* - An atom: Its own overlays are compiled and then it's appearance is added. (Meaning its current apperance is frozen).
* - An image: Image's apperance is added (i.e. subsequently editing the image will not edit the overlay)
* - A type path: Added to overlays as is. Does whatever it is BYOND does when you add paths to overlays.
* - Or a list containing any of the above.
* @param priority The overlays are added to the "priority" list istead of the normal one.
*/
/atom/proc/add_overlay(list/overlays, priority = FALSE)
if(!overlays)
return
overlays = build_appearance_list(overlays)
LAZYINITLIST(our_overlays) //always initialized after this point
LAZYINITLIST(priority_overlays)
var/list/cached_overlays = our_overlays //sanic
var/list/cached_priority = priority_overlays
var/init_o_len = cached_overlays.len
var/init_p_len = cached_priority.len //starter pokemon
var/need_compile
if(priority)
cached_priority += overlays //or in the image. Can we use [image] = image?
need_compile = init_p_len != cached_priority.len
else
cached_overlays += overlays
need_compile = init_o_len != cached_overlays.len
if(NOT_QUEUED_ALREADY && need_compile) //have we caught more pokemon?
QUEUE_FOR_COMPILE
/**
* Copy the overlays from another atom, either replacing all of ours or appending to our existing overlays.
* Note: This copies only the normal overlays, not the "priority" overlays.
*
* @param other The atom to copy overlays from.
* @param cut_old If true, all of our overlays will be *replaced* by the other's. If other is null, that means cutting all ours.
*/
/atom/proc/copy_overlays(atom/other, cut_old) //copys our_overlays from another atom
if(!other)
if(cut_old)
cut_overlays()
return
var/list/cached_other = other.our_overlays
if(cached_other)
if(cut_old || !LAZYLEN(our_overlays))
our_overlays = cached_other.Copy()
else
our_overlays |= cached_other
if(NOT_QUEUED_ALREADY)
QUEUE_FOR_COMPILE
else if(cut_old)
cut_overlays()
#undef NOT_QUEUED_ALREADY
#undef QUEUE_FOR_COMPILE
//TODO: Better solution for these?
/image/proc/add_overlay(x)
overlays += x
/image/proc/cut_overlay(x)
overlays -= x
/image/proc/cut_overlays(x)
overlays.Cut()
/image/proc/copy_overlays(atom/other, cut_old)
if(!other)
if(cut_old)
cut_overlays()
return
var/list/cached_other = other.our_overlays
if(cached_other)
if(cut_old || !overlays.len)
overlays = cached_other.Copy()
else
overlays |= cached_other
else if(cut_old)
cut_overlays()

View File

@@ -22,6 +22,10 @@
// replaced by OPENCONTAINER flags and atom/proc/is_open_container()
///Chemistry.
// Overlays
var/list/our_overlays //our local copy of (non-priority) overlays without byond magic. Use procs in SSoverlays to manipulate
var/list/priority_overlays //overlays that should remain on top and not normally removed when using cut_overlay functions, like c4.
//Detective Work, used for the duplicate data points kept in the scanners
var/list/original_atom
// Track if we are already had initialize() called to prevent double-initialization.

View File

@@ -823,7 +823,7 @@ FIRE ALARM
alarms_hidden = TRUE
/obj/machinery/firealarm/update_icon()
overlays.Cut()
cut_overlays()
if(panel_open)
set_light(0)
@@ -846,8 +846,7 @@ FIRE ALARM
if("blue") set_light(l_range = 2, l_power = 0.5, l_color = "#1024A9")
if("red") set_light(l_range = 4, l_power = 2, l_color = "#ff0000")
if("delta") set_light(l_range = 4, l_power = 2, l_color = "#FF6633")
overlays += image('icons/obj/monitors.dmi', "overlay_[seclevel]")
add_overlay("overlay_[seclevel]")
/obj/machinery/firealarm/fire_act(datum/gas_mixture/air, temperature, volume)
if(detecting)

View File

@@ -14,16 +14,29 @@ var/list/floor_decals = list()
if(newcolour) color = newcolour
..(newloc)
// Hack to workaround byond crash bug
/obj/effect/floor_decal/initialize()
if(!floor_decals_initialized || !loc || QDELETED(src))
return
add_to_turf_decals()
var/turf/T = get_turf(src)
T.apply_decals()
initialized = TRUE
return INITIALIZE_HINT_QDEL
// This is a separate proc from initialize() to facilitiate its caching and other stuff. Look into it someday.
/obj/effect/floor_decal/proc/add_to_turf_decals()
if(supplied_dir)
set_dir(supplied_dir) // TODO - Why can't this line be done in initialize/New()?
var/turf/T = get_turf(src)
if(istype(T, /turf/simulated/floor) || istype(T, /turf/unsimulated/floor) || istype(T, /turf/simulated/shuttle/floor))
var/cache_key = "[alpha]-[color]-[dir]-[icon_state]-[T.layer]"
var/image/I = floor_decals[cache_key]
if(!I)
I = image(icon = icon, icon_state = icon_state, dir = dir)
I.layer = T.layer
I.color = color
I.alpha = alpha
floor_decals[cache_key] = I
LAZYADD(T.decals, I) // Add to its decals list (so it remembers to re-apply after it cuts overlays)
T.add_overlay(I) // Add to its current overlays too.
return T
/obj/effect/floor_decal/reset
name = "reset marker"

View File

@@ -230,9 +230,8 @@
oxygen = 0
nitrogen = 0
/turf/simulated/floor/reinforced/n20/New()
..()
sleep(-1)
/turf/simulated/floor/reinforced/n20/initialize()
. = ..()
if(!air) make_air()
air.adjust_gas("sleeping_agent", ATMOSTANK_NITROUSOXIDE)
@@ -411,11 +410,11 @@
. = ..()
/turf/snow/update_icon()
overlays.Cut()
cut_overlays()
for(var/d in crossed_dirs)
var/amt = crossed_dirs[d]
for(var/i in 1 to amt)
overlays += icon(icon, "footprint[i]", text2num(d))
add_overlay(image(icon, "footprint[i]", text2num(d)))
//**** Here ends snow ****

View File

@@ -1,95 +0,0 @@
//
// Initialize floor decals! Woo! This is crazy.
//
var/global/floor_decals_initialized = FALSE
// The Turf Decal Holder
// Since it is unsafe to add overlays to turfs, we hold them here for now.
// Since I want this object to basically not exist, I am modeling it in part after lighting_overlay
/atom/movable/turf_overlay_holder
name = "turf overlay holder"
density = 0
simulated = 0
anchored = 1
layer = TURF_LAYER
icon = null
icon_state = null
mouse_opacity = 0
// auto_init = 0
/atom/movable/turf_overlay_holder/initialize()
// doesn't need special init
initialized = TRUE
return INITIALIZE_HINT_NORMAL
/atom/movable/turf_overlay_holder/New(var/atom/newloc)
..()
verbs.Cut()
var/turf/T = loc
T.overlay_holder = src
/atom/movable/turf_overlay_holder/Destroy()
if(loc)
var/turf/T = loc
if(T.overlay_holder == src)
T.overlay_holder = null
. = ..()
// Variety of overrides so the overlays don't get affected by weird things.
/atom/movable/turf_overlay_holder/ex_act()
return
/atom/movable/turf_overlay_holder/singularity_act()
return
/atom/movable/turf_overlay_holder/singularity_pull()
return
/atom/movable/turf_overlay_holder/forceMove()
return 0 //should never move
/atom/movable/turf_overlay_holder/Move()
return 0
/atom/movable/turf_overlay_holder/throw_at()
return 0
/obj/effect/floor_decal/proc/add_to_turf_decals()
if(src.supplied_dir) src.set_dir(src.supplied_dir)
var/turf/T = get_turf(src)
if(istype(T, /turf/simulated/floor) || istype(T, /turf/unsimulated/floor) || istype(T, /turf/simulated/shuttle/floor))
var/cache_key = "[src.alpha]-[src.color]-[src.dir]-[src.icon_state]-[T.layer]"
var/image/I = floor_decals[cache_key]
if(!I)
I = image(icon = src.icon, icon_state = src.icon_state, dir = src.dir)
I.layer = T.layer
I.color = src.color
I.alpha = src.alpha
floor_decals[cache_key] = I
if(!T.decals) T.decals = list()
//world.log << "About to add img:\ref[I] onto decals at turf:\ref[T] ([T.x],[T.y],[T.z]) which has appearance:\ref[T.appearance] and decals.len=[T.decals.len]"
T.decals += I
return T
// qdel(D)
src.loc = null
src.tag = null
// Changes to turf to let us do this
/turf
var/atom/movable/turf_overlay_holder/overlay_holder = null
// After a turf change, destroy the old overlay holder since we will have lost access to it.
/turf/post_change()
var/atom/movable/turf_overlay_holder/TOH = locate(/atom/movable/turf_overlay_holder, src)
if(TOH)
qdel(TOH)
..()
/turf/proc/apply_decals()
if(decals)
if(!overlay_holder)
overlay_holder = new(src)
overlay_holder.overlays = src.decals
else if(overlay_holder)
overlay_holder.overlays.Cut()

View File

@@ -21,16 +21,15 @@
spawn(0)
wet = wet_val
if(wet_overlay)
overlays -= wet_overlay
wet_overlay = null
wet_overlay = image('icons/effects/water.dmi',src,"wet_floor")
overlays += wet_overlay
cut_overlay(wet_overlay)
wet_overlay = image('icons/effects/water.dmi', icon_state = "wet_floor")
add_overlay(wet_overlay)
sleep(800)
if(wet == 2)
sleep(3200)
wet = 0
if(wet_overlay)
overlays -= wet_overlay
cut_overlay(wet_overlay)
wet_overlay = null
/turf/simulated/proc/freeze_floor()
@@ -38,14 +37,14 @@
return
wet = 3 // icy
if(wet_overlay)
overlays -= wet_overlay
cut_overlay(wet_overlay)
wet_overlay = null
wet_overlay = image('icons/turf/overlays.dmi',src,"snowfloor")
overlays += wet_overlay
add_overlay(wet_overlay)
spawn(5 MINUTES)
wet = 0
if(wet_overlay)
overlays -= wet_overlay
cut_overlay(wet_overlay)
wet_overlay = null
/turf/simulated/clean_blood()

View File

@@ -24,7 +24,7 @@
var/place_dir = turn(direction, 180)
if(!mining_overlay_cache["rock_side_[place_dir]"])
mining_overlay_cache["rock_side_[place_dir]"] = image('icons/turf/walls.dmi', "rock_side", dir = place_dir)
T.overlays += mining_overlay_cache["rock_side_[place_dir]"]
T.add_overlay(mining_overlay_cache["rock_side_[place_dir]"])
/turf/simulated/wall/solidrock/initialize()
icon_state = base_state

View File

@@ -53,7 +53,7 @@
//This proc auto corrects the grass tiles' siding.
/turf/simulated/floor/proc/make_plating(var/place_product, var/defer_icon_update)
overlays.Cut()
cut_overlays()
if(islist(decals))
decals.Cut()
decals = null

View File

@@ -15,7 +15,7 @@ var/image/no_ceiling_image = null
if(lava)
return
overlays.Cut()
cut_overlays()
if(flooring)
// Set initial icon and strings.
@@ -38,17 +38,17 @@ var/image/no_ceiling_image = null
var/turf/simulated/floor/T = get_step(src, step_dir)
if(!istype(T) || !T.flooring || T.flooring.name != flooring.name)
has_border |= step_dir
overlays |= get_flooring_overlay("[flooring.icon_base]-edge-[step_dir]", "[flooring.icon_base]_edges", step_dir)
add_overlay(get_flooring_overlay("[flooring.icon_base]-edge-[step_dir]", "[flooring.icon_base]_edges", step_dir))
// There has to be a concise numerical way to do this but I am too noob.
if((has_border & NORTH) && (has_border & EAST))
overlays |= get_flooring_overlay("[flooring.icon_base]-edge-[NORTHEAST]", "[flooring.icon_base]_edges", NORTHEAST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-edge-[NORTHEAST]", "[flooring.icon_base]_edges", NORTHEAST))
if((has_border & NORTH) && (has_border & WEST))
overlays |= get_flooring_overlay("[flooring.icon_base]-edge-[NORTHWEST]", "[flooring.icon_base]_edges", NORTHWEST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-edge-[NORTHWEST]", "[flooring.icon_base]_edges", NORTHWEST))
if((has_border & SOUTH) && (has_border & EAST))
overlays |= get_flooring_overlay("[flooring.icon_base]-edge-[SOUTHEAST]", "[flooring.icon_base]_edges", SOUTHEAST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-edge-[SOUTHEAST]", "[flooring.icon_base]_edges", SOUTHEAST))
if((has_border & SOUTH) && (has_border & WEST))
overlays |= get_flooring_overlay("[flooring.icon_base]-edge-[SOUTHWEST]", "[flooring.icon_base]_edges", SOUTHWEST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-edge-[SOUTHWEST]", "[flooring.icon_base]_edges", SOUTHWEST))
if(flooring.flags & TURF_HAS_CORNERS)
// As above re: concise numerical way to do this.
@@ -56,37 +56,36 @@ var/image/no_ceiling_image = null
if(!(has_border & EAST))
var/turf/simulated/floor/T = get_step(src, NORTHEAST)
if(!(istype(T) && T.flooring && T.flooring.name == flooring.name))
overlays |= get_flooring_overlay("[flooring.icon_base]-corner-[NORTHEAST]", "[flooring.icon_base]_corners", NORTHEAST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-corner-[NORTHEAST]", "[flooring.icon_base]_corners", NORTHEAST))
if(!(has_border & WEST))
var/turf/simulated/floor/T = get_step(src, NORTHWEST)
if(!(istype(T) && T.flooring && T.flooring.name == flooring.name))
overlays |= get_flooring_overlay("[flooring.icon_base]-corner-[NORTHWEST]", "[flooring.icon_base]_corners", NORTHWEST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-corner-[NORTHWEST]", "[flooring.icon_base]_corners", NORTHWEST))
if(!(has_border & SOUTH))
if(!(has_border & EAST))
var/turf/simulated/floor/T = get_step(src, SOUTHEAST)
if(!(istype(T) && T.flooring && T.flooring.name == flooring.name))
overlays |= get_flooring_overlay("[flooring.icon_base]-corner-[SOUTHEAST]", "[flooring.icon_base]_corners", SOUTHEAST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-corner-[SOUTHEAST]", "[flooring.icon_base]_corners", SOUTHEAST))
if(!(has_border & WEST))
var/turf/simulated/floor/T = get_step(src, SOUTHWEST)
if(!(istype(T) && T.flooring && T.flooring.name == flooring.name))
overlays |= get_flooring_overlay("[flooring.icon_base]-corner-[SOUTHWEST]", "[flooring.icon_base]_corners", SOUTHWEST)
add_overlay(get_flooring_overlay("[flooring.icon_base]-corner-[SOUTHWEST]", "[flooring.icon_base]_corners", SOUTHWEST))
// Hack workaround to byond crash bug
//if(decals && decals.len)
//overlays |= decals
apply_decals()
// Re-apply floor decals
if(LAZYLEN(decals))
add_overlay(decals)
if(is_plating() && !(isnull(broken) && isnull(burnt))) //temp, todo
icon = 'icons/turf/flooring/plating.dmi'
icon_state = "dmg[rand(1,4)]"
else if(flooring)
if(!isnull(broken) && (flooring.flags & TURF_CAN_BREAK))
overlays |= get_flooring_overlay("[flooring.icon_base]-broken-[broken]","[flooring.icon_base]_broken[broken]")
add_overlay(get_flooring_overlay("[flooring.icon_base]-broken-[broken]","[flooring.icon_base]_broken[broken]"))
if(!isnull(burnt) && (flooring.flags & TURF_CAN_BURN))
overlays |= get_flooring_overlay("[flooring.icon_base]-burned-[burnt]","[flooring.icon_base]_burned[burnt]")
add_overlay(get_flooring_overlay("[flooring.icon_base]-burned-[burnt]","[flooring.icon_base]_burned[burnt]"))
if(weather_overlay)
overlays += weather_overlay
add_overlay(weather_overlay)
if(update_neighbors)
for(var/turf/simulated/floor/F in range(src, 1))
@@ -97,7 +96,7 @@ var/image/no_ceiling_image = null
// Show 'ceilingless' overlay.
var/turf/above = GetAbove(src)
if(above && isopenspace(above) && !istype(src, /turf/simulated/floor/outdoors)) // This won't apply to outdoor turfs since its assumed they don't have a ceiling anyways.
overlays |= no_ceiling_image
add_overlay(no_ceiling_image)
/turf/simulated/floor/proc/get_flooring_overlay(var/cache_key, var/icon_base, var/icon_dir = 0)
if(!flooring_cache[cache_key])

View File

@@ -15,17 +15,19 @@
var/list/decals
New(var/location = null, var/turf/simulated/shuttle/turf)
..(null)
my_turf = turf
/obj/landed_holder/proc/land_on(var/turf/T)
//Gather destination information
var/old_dest_type = T.type
var/old_dest_dir = T.dir
var/old_dest_icon_state = T.icon_state
var/old_dest_icon = T.icon
var/list/old_dest_overlays = T.overlays.Copy()
var/list/old_dest_underlays = T.underlays.Copy()
var/list/old_dest_decals = T.decals ? T.decals.Copy() : null
var/obj/landed_holder/new_holder = new(null)
new_holder.turf_type = T.type
new_holder.dir = T.dir
new_holder.icon = T.icon
new_holder.icon_state = T.icon_state
new_holder.copy_overlays(T, TRUE)
new_holder.underlays = T.underlays.Copy()
new_holder.decals = T.decals ? T.decals.Copy() : null
//Set the destination to be like us
T.Destroy()
@@ -33,7 +35,7 @@
new_dest.set_dir(my_turf.dir)
new_dest.icon_state = my_turf.icon_state
new_dest.icon = my_turf.icon
new_dest.overlays = my_turf.overlays
new_dest.copy_overlays(my_turf, TRUE)
new_dest.underlays = my_turf.underlays
new_dest.decals = my_turf.decals
//Shuttle specific stuff
@@ -43,18 +45,9 @@
new_dest.join_flags = my_turf.join_flags
new_dest.join_group = my_turf.join_group
if(new_dest.decals)
new_dest.apply_decals()
//Tell the new turf about what was there before
new_dest.landed_holder = new(turf = new_dest)
new_dest.landed_holder.turf_type = old_dest_type
new_dest.landed_holder.dir = old_dest_dir
new_dest.landed_holder.icon = old_dest_icon
new_dest.landed_holder.icon_state = old_dest_icon_state
new_dest.landed_holder.overlays = old_dest_overlays
new_dest.landed_holder.underlays = old_dest_underlays
new_dest.landed_holder.decals = old_dest_decals
// Associate the holder with the new turf.
new_holder.my_turf = new_dest
new_dest.landed_holder = new_holder
//Update underlays if necessary (interior corners won't have changed).
if(new_dest.takes_underlays && !new_dest.interior_corner)
@@ -70,11 +63,9 @@
new_source.set_dir(dir)
new_source.icon_state = icon_state
new_source.icon = icon
new_source.overlays = overlays
new_source.copy_overlays(src, TRUE)
new_source.underlays = underlays
new_source.decals = decals
if(new_source.decals)
new_source.apply_decals()
else
new_source = my_turf.ChangeTurf(get_base_turf_by_area(my_turf),,1)

View File

@@ -44,7 +44,9 @@ var/list/outdoor_turfs = list()
planet_controller.unallocateTurf(src)
else // This is happening during map gen, if there's no planet_controller (hopefully).
outdoor_turfs -= src
qdel(weather_overlay)
if(weather_overlay)
cut_overlay(weather_overlay)
qdel_null(weather_overlay)
update_icon()
/turf/simulated/post_change()
@@ -67,15 +69,14 @@ var/list/outdoor_turfs = list()
var/image/I = image(icon = 'icons/turf/outdoors_edge.dmi', icon_state = "[T.get_edge_icon_state()]-edge", dir = checkdir)
I.plane = 0
turf_edge_cache[cache_key] = I
overlays += turf_edge_cache[cache_key]
add_overlay(turf_edge_cache[cache_key])
/turf/simulated/proc/get_edge_icon_state()
return icon_state
/turf/simulated/floor/outdoors/update_icon()
overlays.Cut()
update_icon_edge()
..()
update_icon_edge()
/turf/simulated/floor/outdoors/mud
name = "mud"

View File

@@ -17,10 +17,9 @@
. = ..()
/turf/simulated/floor/outdoors/snow/update_icon()
overlays.Cut()
..()
for(var/d in crossed_dirs)
overlays += image(icon = 'icons/turf/outdoors.dmi', icon_state = "snow_footprints", dir = text2num(d))
add_overlay(image(icon = 'icons/turf/outdoors.dmi', icon_state = "snow_footprints", dir = text2num(d)))
/turf/simulated/floor/outdoors/snow/attackby(var/obj/item/W, var/mob/user)
if(istype(W, /obj/item/weapon/shovel))

View File

@@ -47,36 +47,36 @@
if(!damage_overlays[1]) //list hasn't been populated
generate_overlays()
overlays.Cut()
cut_overlays()
var/image/I
if(!density)
I = image('icons/turf/wall_masks.dmi', "[material.icon_base]fwall_open")
I.color = material.icon_colour
overlays += I
add_overlay(I)
return
for(var/i = 1 to 4)
I = image('icons/turf/wall_masks.dmi', "[material.icon_base][wall_connections[i]]", dir = 1<<(i-1))
I.color = material.icon_colour
overlays += I
add_overlay(I)
if(reinf_material)
if(construction_stage != null && construction_stage < 6)
I = image('icons/turf/wall_masks.dmi', "reinf_construct-[construction_stage]")
I.color = reinf_material.icon_colour
overlays += I
add_overlay(I)
else
if("[reinf_material.icon_reinf]0" in icon_states('icons/turf/wall_masks.dmi'))
// Directional icon
for(var/i = 1 to 4)
I = image('icons/turf/wall_masks.dmi', "[reinf_material.icon_reinf][wall_connections[i]]", dir = 1<<(i-1))
I.color = reinf_material.icon_colour
overlays += I
add_overlay(I)
else
I = image('icons/turf/wall_masks.dmi', reinf_material.icon_reinf)
I.color = reinf_material.icon_colour
overlays += I
add_overlay(I)
if(damage != 0)
var/integrity = material.integrity
@@ -87,7 +87,7 @@
if(overlay > damage_overlays.len)
overlay = damage_overlays.len
overlays += damage_overlays[overlay]
add_overlay(damage_overlays[overlay])
return
/turf/simulated/wall/proc/generate_overlays()

View File

@@ -224,7 +224,7 @@
/turf/simulated/shuttle/wall/voidcraft/update_icon()
if(stripe_color)
overlays.Cut()
cut_overlays()
var/image/I = image(icon = src.icon, icon_state = "o_[icon_state]")
I.color = stripe_color
overlays.Add(I)
add_overlay(I)

View File

@@ -16,7 +16,6 @@
update_icon()
/turf/simulated/floor/water/update_icon()
overlays.Cut()
..() // To get the edges.
icon_state = water_state
var/image/floorbed_sprite = image(icon = 'icons/turf/outdoors.dmi', icon_state = under_state)
@@ -129,16 +128,16 @@ var/list/shoreline_icon_cache = list()
// Water sprites are really annoying, so let BYOND sort it out.
/turf/simulated/floor/water/shoreline/update_icon()
underlays.Cut()
overlays.Cut()
cut_overlays()
..() // Get the underlay first.
var/cache_string = "[initial(icon_state)]_[water_state]_[dir]"
if(cache_string in shoreline_icon_cache) // Check to see if an icon already exists.
overlays += shoreline_icon_cache[cache_string]
add_overlay(shoreline_icon_cache[cache_string])
else // If not, make one, but only once.
var/icon/shoreline_water = icon(src.icon, "shoreline_water", src.dir)
var/icon/shoreline_subtract = icon(src.icon, "[initial(icon_state)]_subtract", src.dir)
shoreline_water.Blend(shoreline_subtract,ICON_SUBTRACT)
shoreline_icon_cache[cache_string] = shoreline_water
overlays += shoreline_icon_cache[cache_string]
add_overlay(shoreline_icon_cache[cache_string])

View File

@@ -26,12 +26,12 @@
. = ..()
/turf/snow/update_icon()
overlays.Cut()
cut_overlays()
for(var/d in crossed_dirs)
var/amt = crossed_dirs[d]
for(var/i in 1 to amt)
overlays += icon(icon, "footprint[i]", text2num(d))
add_overlay(image(icon, "footprint[i]", text2num(d)))
/turf/snow/snow2
name = "snow"

View File

@@ -10,7 +10,8 @@
/turf/space/cracked_asteroid/is_space() // So people don't start floating when standing on it.
return FALSE
/turf/space/cracked_asteroid/New()
..()
spawn(2 SECONDS)
overlays.Cut()
// u wot m8? ~Leshana
// /turf/space/cracked_asteroid/New()
// ..()
// spawn(2 SECONDS)
// overlays.Cut()

View File

@@ -17,7 +17,7 @@
/turf/unsimulated/beach/water/New()
..()
overlays += image("icon"='icons/misc/beach.dmi',"icon_state"="water2","layer"=MOB_LAYER+0.1)
add_overlay(image("icon"='icons/misc/beach.dmi',"icon_state"="water2","layer"=MOB_LAYER+0.1))
/turf/simulated/floor/beach
name = "Beach"
@@ -44,4 +44,4 @@
/turf/simulated/floor/beach/water/New()
..()
overlays += image("icon"='icons/misc/beach.dmi',"icon_state"="water5","layer"=MOB_LAYER+0.1)
add_overlay(image("icon"='icons/misc/beach.dmi',"icon_state"="water5","layer"=MOB_LAYER+0.1))

View File

@@ -193,6 +193,8 @@ var/list/admin_verbs_debug = list(
/client/proc/cmd_debug_del_all,
/client/proc/cmd_debug_tog_aliens,
/client/proc/cmd_display_del_log,
/client/proc/cmd_display_init_log,
/client/proc/cmd_display_overlay_log,
/client/proc/air_report,
/client/proc/reload_admins,
/client/proc/reload_eventMs,

View File

@@ -327,6 +327,36 @@
usr << browse(dellog.Join(), "window=dellog")
/client/proc/cmd_display_init_log()
set category = "Debug"
set name = "Display Initialize() Log"
set desc = "Displays a list of things that didn't handle Initialize() properly"
if(!check_rights(R_DEBUG)) return
src << browse(replacetext(SSatoms.InitLog(), "\n", "<br>"), "window=initlog")
/client/proc/cmd_display_overlay_log()
set category = "Debug"
set name = "Display overlay Log"
set desc = "Display SSoverlays log of everything that's passed through it."
if(!check_rights(R_DEBUG)) return
render_stats(SSoverlays.stats, src)
// Render stats list for round-end statistics.
/proc/render_stats(list/stats, user, sort = /proc/cmp_generic_stat_item_time)
sortTim(stats, sort, TRUE)
var/list/lines = list()
for (var/entry in stats)
var/list/data = stats[entry]
lines += "[entry] => [num2text(data[STAT_ENTRY_TIME], 10)]ms ([data[STAT_ENTRY_COUNT]]) (avg:[num2text(data[STAT_ENTRY_TIME]/(data[STAT_ENTRY_COUNT] || 1), 99)])"
if (user)
user << browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode("stats:\ref[stats]")]")
else
. = lines.Join("\n")
/client/proc/cmd_admin_grantfullaccess(var/mob/M in mob_list)
set category = "Admin"
set name = "Grant Full Access"

View File

@@ -107,7 +107,7 @@
/turf/simulated/floor/holofloor/desert/New()
..()
if(prob(10))
overlays += "asteroid[rand(0,9)]"
add_overlay("asteroid[rand(0,9)]")
/obj/structure/holostool
name = "stool"

View File

@@ -73,7 +73,7 @@
* Update icon and overlays of open space to be that of the turf below, plus any visible objects on that turf.
*/
/turf/simulated/open/update_icon()
overlays = list() // Edit - Overlays are being crashy when modified.
cut_overlays() // Edit - Overlays are being crashy when modified.
update_icon_edge()// Add - Get grass into open spaces and whatnot.
var/turf/below = GetBelow(src)
if(below)
@@ -86,12 +86,7 @@
bottom_turf.plane = src.plane
bottom_turf.color = below.color
underlays = list(bottom_turf)
// Hack workaround to byond crash bug - Include the magic overlay holder object.
overlays += below.overlays
// if(below.overlay_holder)
// overlays += (below.overlays + below.overlay_holder.overlays)
// else
// overlays += below.overlays
copy_overlays(below)
// get objects (not mobs, they are handled by /obj/zshadow)
var/list/o_img = list()
@@ -104,16 +99,10 @@
temp2.overlays += O.overlays
// TODO Is pixelx/y needed?
o_img += temp2
var/overlays_pre = overlays.len
overlays += o_img
var/overlays_post = overlays.len
if(overlays_post != (overlays_pre + o_img.len)) //Here we go!
world.log << "Corrupted openspace turf at [x],[y],[z] being replaced. Pre: [overlays_pre], Post: [overlays_post]"
new /turf/simulated/open(src)
return //Let's get out of here.
add_overlay(o_img)
if(!below_is_open)
overlays += over_OS_darkness
add_overlay(over_OS_darkness)
return 0
return PROCESS_KILL

View File

@@ -45,6 +45,7 @@
#include "code\__defines\qdel.dm"
#include "code\__defines\research.dm"
#include "code\__defines\species_languages.dm"
#include "code\__defines\stat_tracking.dm"
#include "code\__defines\subsystems.dm"
#include "code\__defines\targeting.dm"
#include "code\__defines\turfs.dm"
@@ -181,11 +182,11 @@
#include "code\controllers\subsystems\air.dm"
#include "code\controllers\subsystems\airflow.dm"
#include "code\controllers\subsystems\atoms.dm"
#include "code\controllers\subsystems\floor_decals.dm"
#include "code\controllers\subsystems\garbage.dm"
#include "code\controllers\subsystems\lighting.dm"
#include "code\controllers\subsystems\machines.dm"
#include "code\controllers\subsystems\orbits.dm"
#include "code\controllers\subsystems\overlays.dm"
#include "code\controllers\subsystems\shuttles.dm"
#include "code\controllers\subsystems\xenoarch.dm"
#include "code\datums\ai_law_sets.dm"
@@ -1109,7 +1110,6 @@
#include "code\game\turfs\flooring\flooring.dm"
#include "code\game\turfs\flooring\flooring_decals.dm"
#include "code\game\turfs\flooring\flooring_premade.dm"
#include "code\game\turfs\flooring\turf_overlay_holder.dm"
#include "code\game\turfs\initialization\init.dm"
#include "code\game\turfs\initialization\maintenance.dm"
#include "code\game\turfs\simulated\floor.dm"