New lighting, it's essentially just the old DAL system with a queue.

Comments for lighting:
	Like sd_DAL (what we used to use), it changes the shading overlays of areas by splitting each type of area into sub-areas
	by using the var/tag variable and moving turfs into the contents list of the correct sub-area.

	Unlike sd_DAL however it uses a queueing system. Everytime we  call a change to opacity or luminosity
	(through SetOpacity() or SetLuminosity()) we are  simply updating variables and scheduling certain lights/turfs for an
	update. Actual updates are handled periodically by the lighting_controller. This carries additional overheads, however it
	means that each thing is changed only once per lighting_controller.processing_interval ticks. Allowing for greater control
	over how much priority we'd like lighting updates to have. It also makes it possible for us to simply delay updates by
	setting lighting_controller.processing = 0 at say, the start of a large explosion, waiting for it to finish, and then
	turning it back on with lighting_controller.processing = 1.

	Unlike our old system there is a hardcoded maximum luminosity. This is to discourage coders using large luminosity values
	for dynamic lighting, as the cost of lighting grows rapidly at large luminosity levels (especially when changing opacity
	at runtime)

	Also, in order for the queueing system to work, each light remembers the effect it casts on each turf. This is going to
	have larger memory requirements than our previous system but hopefully it's worth the hassle for the greater control we
	gain. Besides, there are far far worse uses of needless lists in the game, it'd be worth pruning some of them to offset
	costs.

	Known Issues/TODO:
		admin-spawned turfs will have broken lumcounts. Not willing to fix it at this moment
		mob luminosity will be lower than expected when one of multiple light sources is dropped after exceeding the maximum luminosity
		Shuttles still do not have support for dynamic lighting (I hope to fix this at some point)
		No directional lighting support. Fairly easy to add this and the code is ready.
		When opening airlocks etc, lighting does not always update to account for the change in opacity.

Explosions now cause lighting to cease processing temporarily.

Moved controller datums to the code/controllers directory. I plan on standardising them.
"Master","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply Shuttle","Emergency Shuttle","Configuration","pAI" controller datums can be accessed via the debug controller verb (used to be the debug master controller verb)
Supply shuttle now uses a controller datum. Shuttles tend to arrive up to 30 seconds late, this is not a bug.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4537 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
elly1989@rocketmail.com
2012-08-25 16:06:57 +00:00
parent 676079cdba
commit 6e274cd395
89 changed files with 1519 additions and 2245 deletions
+14 -15
View File
@@ -193,20 +193,19 @@ var/global/list/obj/item/device/pda/PDAs = list()
* The Actual PDA
*/
/obj/item/device/pda/pickup(mob/user)
if (fon)
sd_SetLuminosity(0)
user.total_luminosity += f_lum
if(fon)
SetLuminosity(0)
user.SetLuminosity(user.luminosity + f_lum)
/obj/item/device/pda/dropped(mob/user)
if (fon)
user.total_luminosity -= f_lum
sd_SetLuminosity(f_lum)
if(fon)
user.SetLuminosity(user.luminosity - f_lum)
SetLuminosity(f_lum)
/obj/item/device/pda/New()
..()
PDAs += src
spawn(3)
if (default_cartridge)
if(default_cartridge)
cartridge = new default_cartridge(src)
/obj/item/device/pda/proc/can_use()
@@ -496,14 +495,14 @@ var/global/list/obj/item/device/pda/PDAs = list()
//MAIN FUNCTIONS===================================
if("Light")
fon = (!fon)
if (src in U.contents)
if (fon)
U.total_luminosity += f_lum
else
U.total_luminosity -= f_lum
if(fon)
fon = 0
if(src in U.contents) U.SetLuminosity(U.luminosity - f_lum)
else SetLuminosity(0)
else
sd_SetLuminosity(fon * f_lum)
fon = 1
if(src in U.contents) U.SetLuminosity(U.luminosity + f_lum)
else SetLuminosity(f_lum)
if("Medical Scan")
if(scanmode == 1)
scanmode = 0
+5 -5
View File
@@ -468,17 +468,17 @@ Code:
menu = "<h4><img src=pda_crate.png> Supply Record Interlink</h4>"
menu += "<BR><B>Supply shuttle</B><BR>"
menu += "Location: [supply_shuttle_moving ? "Moving to station ([supply_shuttle_timeleft] Mins.)":supply_shuttle_at_station ? "Station":"Dock"]<BR>"
menu += "Location: [supply_shuttle.moving ? "Moving to station ([supply_shuttle.eta] Mins.)":supply_shuttle.at_station ? "Station":"Dock"]<BR>"
menu += "Current approved orders: <BR><ol>"
for(var/S in supply_shuttle_shoppinglist)
for(var/S in supply_shuttle.shoppinglist)
var/datum/supply_order/SO = S
menu += "<li>[SO.object.name] approved by [SO.orderedby] [SO.comment ? "([SO.comment])":""]</li>"
menu += "<li>#[SO.ordernum] - [SO.object.name] approved by [SO.orderedby] [SO.comment ? "([SO.comment])":""]</li>"
menu += "</ol>"
menu += "Current requests: <BR><ol>"
for(var/S in supply_shuttle_requestlist)
for(var/S in supply_shuttle.requestlist)
var/datum/supply_order/SO = S
menu += "<li>[SO.object.name] requested by [SO.orderedby]</li>"
menu += "<li>#[SO.ordernum] - [SO.object.name] requested by [SO.orderedby]</li>"
menu += "</ol><font size=\"-3\">Upgrade NOW to Space Parts & Space Vendors PLUS for full remote order control and inventory management."
if (48) //mulebot control
+13 -14
View File
@@ -18,25 +18,24 @@
..()
if (on)
icon_state = icon_on
src.sd_SetLuminosity(brightness_on)
src.SetLuminosity(brightness_on)
else
icon_state = icon_off
src.sd_SetLuminosity(0)
src.SetLuminosity(0)
/obj/item/device/flashlight/proc/update_brightness(var/mob/user = null)
if (on)
if(on)
icon_state = icon_on
if(src.loc == user)
user.total_luminosity += brightness_on
else if (isturf(src.loc))
src.sd_SetLuminosity(brightness_on)
user.SetLuminosity(user.luminosity + brightness_on)
else if(isturf(loc))
SetLuminosity(brightness_on)
else
icon_state = icon_off
if(src.loc == user)
user.total_luminosity -= brightness_on
else if (isturf(src.loc))
src.sd_SetLuminosity(0)
user.SetLuminosity(user.luminosity - brightness_on)
else if(isturf(loc))
SetLuminosity(0)
/obj/item/device/flashlight/attack_self(mob/user)
if(!isturf(user.loc))
@@ -85,14 +84,14 @@
/obj/item/device/flashlight/pickup(mob/user)
if(on)
user.total_luminosity += brightness_on
src.sd_SetLuminosity(0)
user.SetLuminosity(user.luminosity + brightness_on)
SetLuminosity(0)
/obj/item/device/flashlight/dropped(mob/user)
if(on)
user.total_luminosity -= brightness_on
src.sd_SetLuminosity(brightness_on)
user.SetLuminosity(user.luminosity - brightness_on)
SetLuminosity(brightness_on)
/obj/item/device/flashlight/pen
+3 -5
View File
@@ -50,7 +50,7 @@
for(var/mob/M in viewers(user))
if(M == user) continue
M << "[user] detaches the power sink from the cable."
sd_SetLuminosity(0)
SetLuminosity(0)
icon_state = "powersink0"
return
@@ -85,7 +85,7 @@
if(M == user) continue
M << "[user] deactivates the power sink!"
mode = 1
sd_SetLuminosity(0)
SetLuminosity(0)
icon_state = "powersink0"
processing_objects.Remove(src)
@@ -93,9 +93,7 @@
if(attached)
var/datum/powernet/PN = attached.get_powernet()
if(PN)
if(!luminosity)
sd_SetLuminosity(12)
SetLuminosity(12)
// found a powernet, so drain up to max power from it
+1 -5
View File
@@ -175,6 +175,7 @@
icon_state = "weednode"
name = "purple sac"
desc = "Weird purple octopus-like thing."
luminosity = NODERANGE
/obj/effect/alien/weeds/New()
..()
@@ -187,11 +188,6 @@
Life()
return
/obj/effect/alien/weeds/node/New()
..()
sd_SetLuminosity(NODERANGE)
return
/obj/effect/alien/weeds/proc/Life()
set background = 1
var/turf/U = get_turf(src)
@@ -60,7 +60,5 @@
New()
..()
sd_SetLuminosity(1)
spawn(1200) // 2 minutes
del(src)
+4 -4
View File
@@ -936,7 +936,7 @@ steam.start() -- spawns the effect
icon = 'icons/effects/effects.dmi'
icon_state = "metalfoam"
density = 1
opacity = 0 // changed in New()
opacity = 1 // changed in New()
anchored = 1
name = "foamed metal"
desc = "A lightweight foamed metal wall."
@@ -945,11 +945,11 @@ steam.start() -- spawns the effect
New()
..()
update_nearby_tiles(1)
spawn(1)
sd_NewOpacity(1)
Del()
sd_NewOpacity(0)
density = 0
update_nearby_tiles(1)
..()
+4 -6
View File
@@ -21,7 +21,7 @@
spreadChance = 0
/obj/effect/glowshroom/New()
set background = 1
..()
dir = CalcDir()
@@ -40,11 +40,9 @@
else //if on the floor, glowshroom on-floor sprite
icon_state = "glowshroomf"
spawn(2) //allows the luminosity and spread rate to be affected by potency at the moment of creation
sd_SetLuminosity(potency/10)
spawn(delay)
if(src)
Spread()
spawn(delay)
SetLuminosity(round(potency/10))
Spread()
/obj/effect/glowshroom/proc/Spread()
set background = 1
+12 -4
View File
@@ -20,6 +20,10 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
playsound(epicenter, 'sound/effects/explosionfar.ogg', 100, 1, round(devastation_range*2,1) )
playsound(epicenter, "explosion", 100, 1, round(devastation_range,1) )
var/lighting_controller_was_processing = lighting_controller.processing //Pause the lighting updates for a bit
lighting_controller.processing = 0
var/powernet_rebuild_was_deferred_already = defer_powernet_rebuild
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
@@ -49,11 +53,15 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
for(var/atom/object in T.contents)
object.ex_act(dist)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
//here util we get explosions to be less laggy, might help us identify issues after changes to splosions (because let's face it we've had a few)
world.log << "## Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [(world.timeofday-start)/10] seconds."
world.log << "## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [(world.timeofday-start)/10] seconds."
sleep(10)
if(!lighting_controller.processing) lighting_controller.processing = lighting_controller_was_processing
if(!powernet_rebuild_was_deferred_already)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return 1
+2
View File
@@ -1,4 +1,6 @@
//TODO: Flash range does nothing currently
//NOTE: This has not yet been updated with the lighting deferal stuff. ~Carn
//Needs some work anyway.
proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1)
spawn(0)
+7 -7
View File
@@ -52,7 +52,7 @@
//src.damtype = "fire"
for(var/mob/O in viewers(usr, null))
O.show_message(flavor_text, 1)
sd_SetLuminosity(CANDLE_LUM)
SetLuminosity(CANDLE_LUM)
processing_objects.Add(src)
@@ -75,17 +75,17 @@
if(lit)
lit = 0
update_icon()
sd_SetLuminosity(0)
user.total_luminosity -= CANDLE_LUM
SetLuminosity(0)
user.SetLuminosity(user.luminosity - CANDLE_LUM)
pickup(mob/user)
if(lit)
src.sd_SetLuminosity(0)
user.total_luminosity += CANDLE_LUM
SetLuminosity(0)
user.SetLuminosity(user.luminosity + CANDLE_LUM)
dropped(mob/user)
if(lit)
user.total_luminosity -= CANDLE_LUM
src.sd_SetLuminosity(CANDLE_LUM)
user.SetLuminosity(user.luminosity - CANDLE_LUM)
SetLuminosity(CANDLE_LUM)
@@ -106,9 +106,6 @@ ZIPPO
if(M.lit > 0)
light("\red [user] lights their [name] with their [W].")
else if(istype(W, /obj/item/device/assembly/igniter))
light("\red [user] fiddles with [W], and manages to light their [name].")
//can't think of any other way to update the overlays :<
user.update_inv_wear_mask(0)
user.update_inv_l_hand(0)
@@ -448,7 +445,7 @@ ZIPPO
for(var/mob/O in viewers(user, null))
O.show_message("\red After a few attempts, [user] manages to light the [src], they however burn their finger in the process.", 1)
user.total_luminosity += 2
user.SetLuminosity(user.luminosity + 2)
processing_objects.Add(src)
else
src.lit = 0
@@ -461,7 +458,7 @@ ZIPPO
for(var/mob/O in viewers(user, null))
O.show_message("\red [user] quietly shuts off the [src].", 1)
user.total_luminosity -= 2
user.SetLuminosity(user.luminosity - 2)
processing_objects.Remove(src)
else
return ..()
@@ -490,13 +487,13 @@ ZIPPO
pickup(mob/user)
if(lit)
src.sd_SetLuminosity(0)
user.total_luminosity += 2
src.SetLuminosity(0)
user.SetLuminosity(user.luminosity+2)
return
dropped(mob/user)
if(lit)
user.total_luminosity -= 2
src.sd_SetLuminosity(2)
user.SetLuminosity(user.luminosity-2)
src.SetLuminosity(2)
return
+2 -2
View File
@@ -134,8 +134,8 @@
w_class = 2.0
force_unwielded = 3
force_wielded = 30
wieldsound = 'saberon.ogg'
unwieldsound = 'saberoff.ogg'
wieldsound = 'sound/weapons/saberon.ogg'
unwieldsound = 'sound/weapons/saberoff.ogg'
flags = FPRINT | TABLEPASS | NOSHIELD
origin_tech = "magnets=3;syndicate=4"
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
+8 -20
View File
@@ -470,20 +470,14 @@ obj/structure/meteorhit(obj/O as obj)
flick("[mineral]fwall_opening", src)
sleep(15)
src.density = 0
src.sd_SetOpacity(0)
var/turf/T = src.loc
T.sd_LumReset()
SetOpacity(0)
else
flick("[mineral]fwall_closing", src)
icon_state = "[mineral]0"
sleep(15)
src.density = 1
src.sd_SetOpacity(1)
var/turf/T = src.loc
//T.sd_LumUpdate()
SetOpacity(1)
src.relativewall()
T.sd_LumReset()
/obj/structure/falsewall/uranium/attack_hand(mob/user as mob)
radiate()
@@ -583,27 +577,21 @@ obj/structure/meteorhit(obj/O as obj)
icon_state = "frwall_open"
flick("frwall_opening", src)
sleep(15)
src.density = 0
src.sd_SetOpacity(0)
var/turf/T = src.loc
T.sd_LumReset()
density = 0
SetOpacity(0)
else
icon_state = "r_wall"
flick("frwall_closing", src)
sleep(15)
src.density = 1
src.sd_SetOpacity(1)
var/turf/T = src.loc
//T.sd_LumUpdate()
src.relativewall()
T.sd_LumReset()
density = 1
SetOpacity(1)
relativewall()
attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/screwdriver))
var/turf/T = get_turf(src)
user.visible_message("[user] tightens some bolts on the r wall.", "You tighten the bolts on the r wall.")
user.visible_message("[user] tightens some bolts on the r wall.", "You tighten the bolts on the wall.")
T.ReplaceWithWall() //Intentionally makes a regular wall instead of an r-wall (no cheap r-walls for you).
del(src)
@@ -198,10 +198,7 @@
/obj/structure/mineral_door/uranium
mineralType = "uranium"
hardness = 3
New()
..()
sd_SetLuminosity(3)
luminosity = 2
/obj/structure/mineral_door/sandstone
mineralType = "sandstone"