Skip to content

Commit

Permalink
[MIRROR] Fixes complex lights not handling moving well, renames light…
Browse files Browse the repository at this point in the history
…ing defines (#933)

* Fixes complex lights not handling moving well, renames lighting defines (#81423)

## About The Pull Request

[Fixes static lights not
moving](tgstation/tgstation@ffef43c)

Worked fine when the owner moved, but if the owner was inside something
else, it would try and trigger an update on the PARENT's lights, which
are obviously not us.

[Renames MOVABLE_LIGHT and STATIC_LIGHT to better describe what they
do](tgstation/tgstation@de73a63)

People keep trying to change the lighting system of lamps and it makes
me mad.
I choose OVERLAY_LIGHT and COMPLEX_LIGHT here, I couldn't figure out a
better name for turf matrix lighting. Suggestions welcome

## Why It's Good For The Game

Closes #80005
Hopefully improves understanding of lighting at a glance
## Changelog
:cl:
fix: Fixes fancy lights not updating their source location when picked
up and moved
/:cl:

* Fixes complex lights not handling moving well, renames lighting defines

* Updates modular defines

* Update dancing_pole.dm

---------

Co-authored-by: LemonInTheDark <[email protected]>
Co-authored-by: Mal <[email protected]>
  • Loading branch information
3 people authored and FFMirrorBot committed Feb 13, 2024
1 parent d016d1c commit 7e378a7
Show file tree
Hide file tree
Showing 73 changed files with 113 additions and 109 deletions.
10 changes: 5 additions & 5 deletions code/__DEFINES/lighting.dm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/// Object doesn't use any of the light systems. Should be changed to add a light source to the object.
#define NO_LIGHT_SUPPORT 0
/// Light made with the lighting datums, applying a matrix.
#define STATIC_LIGHT 1
#define COMPLEX_LIGHT 1
/// Light made by masking the lighting darkness plane.
#define MOVABLE_LIGHT 2
#define OVERLAY_LIGHT 2
/// Light made by masking the lighting darkness plane, and is directional.
#define MOVABLE_LIGHT_DIRECTIONAL 3
#define OVERLAY_LIGHT_DIRECTIONAL 3
///Light made by masking the lighting darkness plane, and is a directionally focused beam.
#define MOVABLE_LIGHT_BEAM 4
#define OVERLAY_LIGHT_BEAM 4
/// Nonesensical value for light color, used for null checks.
#define NONSENSICAL_VALUE -99999

/// Is a movable light source attached to another movable (its loc), meaning that the lighting component should go one level deeper.
/// Is our overlay light source attached to another movable (its loc), meaning that the lighting component should go one level deeper.
#define LIGHT_ATTACHED (1<<0)
/// Freezes a light in its current state, blocking any attempts at modification
#define LIGHT_FROZEN (1<<1)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/rendering/render_plate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
<br>That's how lighting functions at base. Because it uses BLEND_MULTIPLY and occasionally color matrixes, it needs a backdrop of blackness.\
<br>See <a href=\"https://secure.byond.com/forum/?post=2141928\">This byond post</a>\
<br>Lemme see uh, we're masked by the emissive plane so it can actually function (IE: make things glow in the dark).\
<br>We're also masked by the overlay lighting plane, which contains all the movable lights in the game. It draws to us and also the game plane.\
<br>We're also masked by the overlay lighting plane, which contains all the well overlay lights in the game. It draws to us and also the game plane.\
<br>Masks us out so it has the breathing room to apply its effect.\
<br>Oh and we quite often have our alpha changed to achive night vision effects, or things of that sort."
plane = RENDER_PLANE_LIGHTING
Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/overlay_lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
return COMPONENT_INCOMPATIBLE

var/atom/movable/movable_parent = parent
if(movable_parent.light_system != MOVABLE_LIGHT && movable_parent.light_system != MOVABLE_LIGHT_DIRECTIONAL && movable_parent.light_system != MOVABLE_LIGHT_BEAM)
stack_trace("[type] added to [parent], with [movable_parent.light_system] value for the light_system var. Use [MOVABLE_LIGHT], [MOVABLE_LIGHT_DIRECTIONAL] or [MOVABLE_LIGHT_BEAM] instead.")
if(movable_parent.light_system != OVERLAY_LIGHT && movable_parent.light_system != OVERLAY_LIGHT_DIRECTIONAL && movable_parent.light_system != OVERLAY_LIGHT_BEAM)
stack_trace("[type] added to [parent], with [movable_parent.light_system] value for the light_system var. Use [OVERLAY_LIGHT], [OVERLAY_LIGHT_DIRECTIONAL] or [OVERLAY_LIGHT_BEAM] instead.")
return COMPONENT_INCOMPATIBLE

. = ..()
Expand Down
4 changes: 2 additions & 2 deletions code/datums/elements/light_eaten.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
RegisterSignal(atom_target, COMSIG_ATOM_SET_LIGHT_ON, PROC_REF(block_light_on))
RegisterSignal(atom_target, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))

/// Because the lighting system does not like movable lights getting set_light() called.
/// Because the lighting system does not like overlay lights getting set_light() called.
switch(atom_target.light_system)
if(STATIC_LIGHT)
if(COMPLEX_LIGHT)
target.set_light(0, 0, null, l_on = FALSE)
else
target.set_light_power(0)
Expand Down
2 changes: 1 addition & 1 deletion code/game/atom/_atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
var/datum/wires/wires = null

///Light systems, both shouldn't be active at the same time.
var/light_system = STATIC_LIGHT
var/light_system = COMPLEX_LIGHT
///Range of the light in tiles. Zero means no light.
var/light_range = 0
///Intensity of the light. The stronger, the less shadows you will see on the lit area.
Expand Down
14 changes: 7 additions & 7 deletions code/game/atom/atom_vv.dm
Original file line number Diff line number Diff line change
Expand Up @@ -222,37 +222,37 @@
light_flags &= ~LIGHT_FROZEN
switch(var_name)
if(NAMEOF(src, light_range))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_range = var_value)
else
set_light_range(var_value)
. = TRUE
if(NAMEOF(src, light_power))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_power = var_value)
else
set_light_power(var_value)
. = TRUE
if(NAMEOF(src, light_color))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_color = var_value)
else
set_light_color(var_value)
. = TRUE
if(NAMEOF(src, light_angle))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_angle = var_value)
. = TRUE
if(NAMEOF(src, light_dir))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_dir = var_value)
. = TRUE
if(NAMEOF(src, light_height))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_height = var_value)
. = TRUE
if(NAMEOF(src, light_on))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_on = var_value)
else
set_light_on(var_value)
Expand Down
2 changes: 1 addition & 1 deletion code/game/atom/atoms_initializing_EXPENSIVE.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
if(color)
add_atom_colour(color, FIXED_COLOUR_PRIORITY)

if (light_system == STATIC_LIGHT && light_power && light_range)
if (light_system == COMPLEX_LIGHT && light_power && light_range)
update_light()

SETUP_SMOOTHING()
Expand Down
6 changes: 3 additions & 3 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@
if(opacity)
AddElement(/datum/element/light_blocking)
switch(light_system)
if(MOVABLE_LIGHT)
if(OVERLAY_LIGHT)
AddComponent(/datum/component/overlay_lighting)
if(MOVABLE_LIGHT_DIRECTIONAL)
if(OVERLAY_LIGHT_DIRECTIONAL)
AddComponent(/datum/component/overlay_lighting, is_directional = TRUE)
if(MOVABLE_LIGHT_BEAM)
if(OVERLAY_LIGHT_BEAM)
AddComponent(/datum/component/overlay_lighting, is_directional = TRUE, is_beam = TRUE)

/atom/movable/Destroy(force)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/effect_system/effects_sparks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
name = "sparks"
icon_state = "sparks"
anchored = TRUE
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 2
light_power = 0.5
light_color = LIGHT_COLOR_FIRE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
name = "lighting"
desc = "Tell a coder if you're seeing this."
icon_state = "nothing"
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = MINIMUM_USEFUL_LIGHT_RANGE
light_color = COLOR_WHITE
blocks_emissive = EMISSIVE_BLOCK_NONE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/portals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
anchored = TRUE
density = TRUE // dense for receiving bumbs
layer = HIGH_OBJ_LAYER
light_system = STATIC_LIGHT
light_system = COMPLEX_LIGHT
light_range = 3
light_power = 1
light_on = TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/cigs_lighters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
resistance_flags = FIRE_PROOF
grind_results = list(/datum/reagent/iron = 1, /datum/reagent/fuel = 5, /datum/reagent/fuel/oil = 5)
custom_price = PAYCHECK_CREW * 1.1
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 2
light_power = 0.6
light_color = LIGHT_COLOR_FIRE
Expand Down
22 changes: 11 additions & 11 deletions code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
slot_flags = ITEM_SLOT_BELT
custom_materials = list(/datum/material/iron= SMALL_MATERIAL_AMOUNT * 0.5, /datum/material/glass= SMALL_MATERIAL_AMOUNT * 0.2)
actions_types = list(/datum/action/item_action/toggle_light)
light_system = MOVABLE_LIGHT_DIRECTIONAL
light_system = OVERLAY_LIGHT_DIRECTIONAL
light_range = 4
light_power = 1
light_on = FALSE
Expand Down Expand Up @@ -76,7 +76,7 @@

/obj/item/flashlight/proc/update_brightness()
update_appearance(UPDATE_ICON)
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
update_light()

/obj/item/flashlight/proc/toggle_light(mob/user)
Expand Down Expand Up @@ -364,7 +364,7 @@
righthand_file = 'icons/mob/inhands/items_righthand.dmi'
force = 10
light_range = 3.5
light_system = STATIC_LIGHT
light_system = COMPLEX_LIGHT
light_color = LIGHT_COLOR_FAINT_BLUE
w_class = WEIGHT_CLASS_BULKY
obj_flags = CONDUCTS_ELECTRICITY
Expand Down Expand Up @@ -397,7 +397,7 @@
actions_types = list()
heat = 1000
light_color = LIGHT_COLOR_FLARE
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
grind_results = list(/datum/reagent/sulfur = 15)
sound_on = 'sound/items/match_strike.ogg'
toggle_context = FALSE
Expand Down Expand Up @@ -656,7 +656,7 @@
righthand_file = 'icons/mob/inhands/equipment/mining_righthand.dmi'
desc = "A mining lantern."
light_range = 6 // luminosity when on
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT

/obj/item/flashlight/lantern/heirloom_moth
name = "old lantern"
Expand Down Expand Up @@ -687,7 +687,7 @@
slot_flags = ITEM_SLOT_BELT
custom_materials = null
light_range = 7 //luminosity when on
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT

/obj/item/flashlight/emp
special_desc_requirement = EXAMINE_CHECK_SYNDICATE // NOVA EDIT
Expand Down Expand Up @@ -753,7 +753,7 @@
custom_price = PAYCHECK_LOWER
w_class = WEIGHT_CLASS_SMALL
light_range = 4
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
color = LIGHT_COLOR_GREEN
icon_state = "glowstick"
base_icon_state = "glowstick"
Expand Down Expand Up @@ -860,7 +860,7 @@
name = "disco light"
desc = "Groovy..."
icon_state = null
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 4
light_power = 10
alpha = 0
Expand Down Expand Up @@ -888,7 +888,7 @@
desc = "A strange device manufactured with mysterious elements that somehow emits darkness. Or maybe it just sucks in light? Nobody knows for sure."
icon_state = "flashdark"
inhand_icon_state = "flashdark"
light_system = STATIC_LIGHT //The overlay light component is not yet ready to produce darkness.
light_system = COMPLEX_LIGHT //The overlay light component is not yet ready to produce darkness.
light_range = 0
///Variable to preserve old lighting behavior in flashlights, to handle darkness.
var/dark_light_range = 2.5
Expand All @@ -907,7 +907,7 @@
/obj/item/flashlight/eyelight
name = "eyelight"
desc = "This shouldn't exist outside of someone's head, how are you seeing this?"
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 15
light_power = 1
obj_flags = CONDUCTS_ELECTRICITY
Expand All @@ -923,7 +923,7 @@
light_power = 0.07

/obj/item/flashlight/eyelight/glow
light_system = MOVABLE_LIGHT_BEAM
light_system = OVERLAY_LIGHT_BEAM
light_range = 4
light_power = 2

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/dualsaber.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
w_class = WEIGHT_CLASS_SMALL
hitsound = SFX_SWING_HIT
armour_penetration = 35
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 6 //TWICE AS BRIGHT AS A REGULAR ESWORD
light_color = LIGHT_COLOR_ELECTRIC_GREEN
light_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/flamethrower.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
custom_materials = list(/datum/material/iron= HALF_SHEET_MATERIAL_AMOUNT * 0.5)
resistance_flags = FIRE_PROOF
trigger_guard = TRIGGER_GUARD_NORMAL
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_on = FALSE
var/status = FALSE
var/lit = FALSE //on or off
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/melee/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
attack_verb_continuous = list("hits", "taps", "pokes")
attack_verb_simple = list("hit", "tap", "poke")
resistance_flags = FIRE_PROOF
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 3
light_power = 1
light_on = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
if (!.)
return
to_chat(owner, span_notice("You start to emit a healthy glow."))
owner.light_system = MOVABLE_LIGHT
owner.light_system = OVERLAY_LIGHT
lightbulb = owner.AddComponent(/datum/component/overlay_lighting, _range = glow_range, _power = glow_power, _color = glow_color)
owner.add_filter(LIGHTBULB_FILTER, 2, list("type" = "outline", "color" = glow_color, "alpha" = 60, "size" = 1))

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/tools/weldingtool.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
usesound = list('sound/items/welder.ogg', 'sound/items/welder2.ogg')
drop_sound = 'sound/items/handling/weldingtool_drop.ogg'
pickup_sound = 'sound/items/handling/weldingtool_pickup.ogg'
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 2
light_power = 0.75
light_color = LIGHT_COLOR_FIRE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/items/keyring.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
desc = "A crack in space, impossibly deep and painful to the eyes. Definitely not safe."
icon = 'icons/effects/eldritch.dmi'
icon_state = "realitycrack"
light_system = STATIC_LIGHT
light_system = COMPLEX_LIGHT
light_power = 1
light_on = TRUE
light_color = COLOR_GREEN
Expand Down
2 changes: 1 addition & 1 deletion code/modules/assembly/flash.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
throwforce = 0
w_class = WEIGHT_CLASS_TINY
custom_materials = list(/datum/material/iron = SMALL_MATERIAL_AMOUNT*3, /datum/material/glass = SMALL_MATERIAL_AMOUNT*3)
light_system = MOVABLE_LIGHT //Used as a flash here.
light_system = OVERLAY_LIGHT //Used as a flash here.
light_range = FLASH_LIGHT_RANGE
light_color = COLOR_WHITE
light_power = FLASH_LIGHT_POWER
Expand Down
2 changes: 1 addition & 1 deletion code/modules/atmospherics/environmental/LINDA_fire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
layer = GASFIRE_LAYER
plane = ABOVE_GAME_PLANE
blend_mode = BLEND_ADD
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = LIGHT_RANGE_FIRE
light_power = 1
light_color = LIGHT_COLOR_FIRE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/head/cakehat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
righthand_file = 'icons/mob/inhands/clothing/hats_righthand.dmi'
armor_type = /datum/armor/none
light_range = 2 //luminosity when on
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
flags_cover = HEADCOVERSEYES
heat = 999
wound_bonus = 10
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/head/hardhat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
clothing_flags = SNUG_FIT | STACKABLE_HELMET_EXEMPT
resistance_flags = FIRE_PROOF

light_system = MOVABLE_LIGHT_DIRECTIONAL
light_system = OVERLAY_LIGHT_DIRECTIONAL
light_range = 4
light_power = 0.8
light_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/shoes/kindlekicks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
icon_state = "kindleKicks"
inhand_icon_state = null
actions_types = list(/datum/action/item_action/kindle_kicks)
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 2
light_power = 3
light_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/spacesuits/plasmamen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
tint = 2
armor_type = /datum/armor/space_plasmaman
resistance_flags = FIRE_PROOF
light_system = MOVABLE_LIGHT_DIRECTIONAL
light_system = OVERLAY_LIGHT_DIRECTIONAL
light_range = 4
light_on = FALSE
var/helmet_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown/ambrosia.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
name = "ambrosia gaia branch"
desc = "Eating this <i>makes</i> you immortal."
icon_state = "ambrosia_gaia"
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_range = 3
seed = /obj/item/seeds/ambrosia/gaia
wine_power = 70
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/plant_genes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
return

var/obj/item/seeds/our_seed = our_plant.get_plant_seed()
our_plant.light_system = MOVABLE_LIGHT
our_plant.light_system = OVERLAY_LIGHT
our_plant.AddComponent(/datum/component/overlay_lighting, glow_range(our_seed), glow_power(our_seed), glow_color)

/*
Expand Down
Loading

0 comments on commit 7e378a7

Please sign in to comment.