Skip to content

Commit

Permalink
Merge pull request #578 from LLA-Gaming/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
jovandus committed May 31, 2016
2 parents b8949c4 + 6fb653a commit 57fb0e0
Show file tree
Hide file tree
Showing 153 changed files with 2,424 additions and 2,323 deletions.
69 changes: 39 additions & 30 deletions _maps/map_files/tgstation.2.1.3.dmm

Large diffs are not rendered by default.

35 changes: 34 additions & 1 deletion code/LINDA/LINDA_fire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@
air_master.add_to_active(src, 0)
return igniting

/proc/heat2color(temp)
return rgb(heat2color_r(temp), heat2color_g(temp), heat2color_b(temp))

/proc/heat2color_r(temp)
temp /= 100
if(temp <= 66)
. = 255
else
. = max(0, min(255, 329.698727446 * (temp - 60) ** -0.1332047592))

/proc/heat2color_g(temp)
temp /= 100
if(temp <= 66)
. = max(0, min(255, 99.4708025861 * log(temp) - 161.1195681661))
else
. = max(0, min(255, 288.1221695283 * ((temp - 60) ** -0.0755148492)))

/proc/heat2color_b(temp)
temp /= 100
if(temp >= 66)
. = 255
else
if(temp <= 16)
. = 0
else
. = max(0, min(255, 138.5177312231 * log(temp - 10) - 305.0447927307))

//This is the icon for fire on turfs, also helps for nurturing small fires until they are full tile
/obj/effect/hotspot
anchored = 1
Expand Down Expand Up @@ -88,8 +115,10 @@
var/atom/item = X
if(item && item != src) // It's possible that the item is deleted in temperature_expose
item.fire_act(null, temperature, volume)
return 0

set_light(luminosity, 1, heat2color(temperature))

return 0

/obj/effect/hotspot/process()
if(just_spawned)
Expand Down Expand Up @@ -150,6 +179,10 @@

/obj/effect/hotspot/proc/Kill()
air_master.hotspots -= src
set_light(0)
var/turf/T = get_turf(src)
T.set_light(T.luminosity, T.light_range, T.light_color)

DestroyTurf()
qdel(src)

Expand Down
69 changes: 69 additions & 0 deletions code/__DEFINES/lighting.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//Bay lighting engine shit, not in /code/modules/lighting because BYOND is being shit about it
#define LIGHTING_INTERVAL 5 // frequency, in 1/10ths of a second, of the lighting process

#ifndef LIGHTING_INSTANT_UPDATES
#define LIGHTING_INTERVAL 5 // Frequency, in 1/10ths of a second, of the lighting process.
#endif

#define LIGHTING_FALLOFF 1 // type of falloff to use for lighting; 1 for circular, 2 for square
#define LIGHTING_LAMBERTIAN 0 // use lambertian shading for light sources
#define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone
#define LIGHTING_ROUND_VALUE 1 / 128 //Value used to round lumcounts, values smaller than 1/255 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY.

#define LIGHTING_LAYER 10 // drawing layer for lighting overlays

#define LIGHTING_ICON 'icons/effects/lighting_overlay.png' // icon used for lighting shading effects

#define LIGHTING_SOFT_THRESHOLD 0.05 // If the max of the lighting lumcounts of each spectrum drops below this, disable luminosity on the lighting overlays.

// If I were you I'd leave this alone.
#define LIGHTING_BASE_MATRIX \
list \
( \
LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \
LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \
LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \
LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \
0, 0, 0, 1 \
) \

// Helpers so we can (more easily) control the colour matrices.
#define CL_MATRIX_RR 1
#define CL_MATRIX_RG 2
#define CL_MATRIX_RB 3
#define CL_MATRIX_RA 4
#define CL_MATRIX_GR 5
#define CL_MATRIX_GG 6
#define CL_MATRIX_GB 7
#define CL_MATRIX_GA 8
#define CL_MATRIX_BR 9
#define CL_MATRIX_BG 10
#define CL_MATRIX_BB 11
#define CL_MATRIX_BA 12
#define CL_MATRIX_AR 13
#define CL_MATRIX_AG 14
#define CL_MATRIX_AB 15
#define CL_MATRIX_AA 16
#define CL_MATRIX_CR 17
#define CL_MATRIX_CG 18
#define CL_MATRIX_CB 19
#define CL_MATRIX_CA 20

//Some defines to generalise colours used in lighting.
//Important note on colors. Colors can end up significantly different from the basic html picture, especially when saturated
#define LIGHT_COLOR_RED "#FA8282" //Warm but extremely diluted red. rgb(250, 130, 130)
#define LIGHT_COLOR_GREEN "#64C864" //Bright but quickly dissipating neon green. rgb(100, 200, 100)
#define LIGHT_COLOR_BLUE "#6496FA" //Cold, diluted blue. rgb(100, 150, 250)

#define LIGHT_COLOR_CYAN "#7DE1E1" //Diluted cyan. rgb(125, 225, 225)
#define LIGHT_COLOR_PINK "#E17DE1" //Diluted, mid-warmth pink. rgb(225, 125, 225)
#define LIGHT_COLOR_YELLOW "#E1E17D" //Dimmed yellow, leaning kaki. rgb(225, 225, 125)
#define LIGHT_COLOR_BROWN "#966432" //Clear brown, mostly dim. rgb(150, 100, 50)
#define LIGHT_COLOR_ORANGE "#FA9632" //Mostly pure orange. rgb(250, 150, 50)

//These ones aren't a direct colour like the ones above, because nothing would fit
#define LIGHT_COLOR_FIRE "#FAA019" //Warm orange color, leaning strongly towards yellow. rgb(250, 160, 25)
#define LIGHT_COLOR_FLARE "#FA644B" //Bright, non-saturated red. Leaning slightly towards pink for visibility. rgb(250, 100, 75)
#define LIGHT_COLOR_SLIME_LAMP "#AFC84B" //Weird color, between yellow and green, very slimy. rgb(175, 200, 75)
#define LIGHT_COLOR_TUNGSTEN "#FAE1AF" //Extremely diluted yellow, close to skin color (for some reason). rgb(250, 225, 175)
#define LIGHT_COLOR_HALOGEN "#F0FAFA" //Barely visible cyan-ish hue, as the doctor prescribed. rgb(240, 250, 250)
2 changes: 2 additions & 0 deletions code/__DEFINES/math.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
#define T0C 273.15 // 0degC
#define T20C 293.15 // 20degC
#define TCMB 2.7 // -270.3degC

#define CLAMP01(x) (Clamp(x, 0, 1))
21 changes: 12 additions & 9 deletions code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@
//The amount of materials you get from a sheet of mineral like iron/diamond/glass etc

//Event flags
#define EVENT_MINOR 1<<0 //minor events such as airlock malfunction and lights breaking
#define EVENT_MAJOR 1<<1 //events that involve people possibly dying
#define EVENT_SPECIAL 1<<2 //holidays and events not in rotation
#define EVENT_REWARD 1<<3 //events that are rewarding and nice
#define EVENT_CONSEQUENCE 1<<4 //events that are mean and cruel (and usually for naughty people)
#define EVENT_ENDGAME 1<<5 //events that most likely will end the round or at least change the face of it
#define EVENT_TASK 1<<6 //events that are not in rotation that involve the crew working towards a common goal
#define EVENT_ROUNDSTART 1<<7 //events that can happen ONLY at round start
#define EVENT_HIDDEN 1<<8 //secret events :^)
#define EVENT_STANDARD 1<<0 //standard events
#define EVENT_SPECIAL 1<<1 //holidays and events not in rotation
#define EVENT_TASK 1<<2 //events that are not in rotation that involve the crew working towards a common goal
#define EVENT_ROUNDSTART 1<<3 //events that can happen ONLY at round start
#define EVENT_HIDDEN 1<<4 //secret events :^)

#define FOR_DVIEW(type, range, center, invis_flags) \
dview_mob.loc = center; \
dview_mob.see_invisible = invis_flags; \
for(type in view(range, dview_mob))


16 changes: 16 additions & 0 deletions code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@
if(3*hue < 2) return (a+(b-a)*((2/3)-hue)*6)
return a

/proc/GetRedPart(const/hexa)
return hex2num(copytext(hexa, 2, 4))

/proc/GetGreenPart(const/hexa)
return hex2num(copytext(hexa, 4, 6))

/proc/GetBluePart(const/hexa)
return hex2num(copytext(hexa, 6, 8))

/proc/GetHexColors(const/hexa)
return list(
GetRedPart(hexa),
GetGreenPart(hexa),
GetBluePart(hexa),
)

// Very ugly, BYOND doesn't support unix time and rounding errors make it really hard to convert it to BYOND time.
// returns "YYYY-MM-DD" by default
/proc/unix2date(timestamp, seperator = "-")
Expand Down
31 changes: 25 additions & 6 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -943,9 +943,9 @@ atom/proc/GetTypeInAllContents(typepath)

// var/area/AR = X.loc

// if(AR.lighting_use_dynamic) //TODO: rewrite this code so it's not messed by lighting ~Carn
// if(AR.dynamic_lighting) //TODO: rewrite this code so it's not messed by lighting ~Carn
// X.opacity = !X.opacity
// X.SetOpacity(!X.opacity)
// X.set_opacity(!X.opacity)

toupdate += X

Expand All @@ -954,9 +954,9 @@ atom/proc/GetTypeInAllContents(typepath)

// var/area/AR2 = ttl.loc

// if(AR2.lighting_use_dynamic) //TODO: rewrite this code so it's not messed by lighting ~Carn
// if(AR2.dynamic_lighting) //TODO: rewrite this code so it's not messed by lighting ~Carn
// ttl.opacity = !ttl.opacity
// ttl.sd_SetOpacity(!ttl.opacity)
// ttl.sd_set_opacity(!ttl.opacity)

fromupdate += ttl

Expand Down Expand Up @@ -1109,9 +1109,9 @@ proc/DuplicateObject(obj/original, var/perfectcopy = 0 , var/sameloc = 0)

// var/area/AR = X.loc

// if(AR.lighting_use_dynamic)
// if(AR.dynamic_lighting)
// X.opacity = !X.opacity
// X.sd_SetOpacity(!X.opacity) //TODO: rewrite this code so it's not messed by lighting ~Carn
// X.sd_set_opacity(!X.opacity) //TODO: rewrite this code so it's not messed by lighting ~Carn

toupdate += X

Expand Down Expand Up @@ -1562,3 +1562,22 @@ proc/check_target_facings(mob/living/initator, mob/living/target)
S.update_icon()
S.power_change()

/var/mob/dview/dview_mob = new

//Version of view() which ignores darkness, because BYOND doesn't have it (I actually suggested it but it was tagged redundant, BUT HEARERS IS A T- /rant).
/proc/dview(var/range = world.view, var/center, var/invis_flags = 0)
if(!center)
return

dview_mob.loc = center

dview_mob.see_invisible = invis_flags

. = view(range, dview_mob)
dview_mob.loc = null

/mob/dview
invisibility = 101
density = 0
see_in_dark = 1e6
anchored = 1
2 changes: 2 additions & 0 deletions code/_globalvars/lists/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var/global/list/global_map = null
//3 - AI satellite
//5 - empty space

var/global/list/turfs = list()

var/list/landmarks_list = list() //list of all landmarks created
var/list/spawn_landmarks_list = list() //list of all spawn point landmarks created

Expand Down
2 changes: 1 addition & 1 deletion code/controllers/ProcessScheduler/processes/events.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/datum/controller/process/events/doWork()
//initial setup
if(!events.setup_events)
new /datum/event_cycler/rotation(6600,null,null,1) //Make the first cycler fire in 11 minutes.
new /datum/event_cycler/main(6600,null,null,1) //Make the first cycler fire in 11 minutes.
new /datum/event_cycler/roundstart(10,"Central","Command") //Make the round-start cycler fire a round start event
new /datum/event_cycler/holiday(3000,"???") //spawn holidays if they exist
events.spawn_orphan_event(/datum/round_event/engine_setup) //spawn the engine setup "event"
Expand Down
76 changes: 44 additions & 32 deletions code/controllers/ProcessScheduler/processes/lighting.dm
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
/var/list/lighting_update_lights = list() // List of lighting sources queued for update.
/var/list/lighting_update_corners = list() // List of lighting corners queued for update.
/var/list/lighting_update_overlays = list() // List of lighting overlays queued for update.

/datum/controller/process/lighting/setup()
name = "lighting"
schedule_interval = 5 // every .5 second
lighting_controller.Initialize()
schedule_interval = LIGHTING_INTERVAL
if(config && config.instant_lighting)
schedule_interval = 1 //instant lighting

create_all_lighting_corners()
create_all_lighting_overlays()

/datum/controller/process/lighting/doWork()
lighting_controller.lights_workload_max = \
max(lighting_controller.lights_workload_max, lighting_controller.lights.len)
var/i = 1
while(i<=lighting_controller.lights.len)
var/datum/light_source/L = lighting_controller.lights[i]
if(L)
if(L.check())
lighting_controller.lights.Remove(L)

scheck()
i++
continue
lighting_controller.lights.Cut(i,i+1)

lighting_controller.changed_turfs_workload_max = \
max(lighting_controller.changed_turfs_workload_max, lighting_controller.changed_turfs.len)
i = 1
while(i<=lighting_controller.changed_turfs.len)
var/turf/T = lighting_controller.changed_turfs[i]
if(T)
if(T.lighting_changed)
T.shift_to_subarea()

scheck()
i++
continue
lighting_controller.changed_turfs.Cut(i,i+1)

if(lighting_controller.changed_turfs && lighting_controller.changed_turfs.len)
lighting_controller.changed_turfs.Cut() // reset the changed list

var/list/lighting_update_lights_old = lighting_update_lights //We use a different list so any additions to the update lists during a delay from scheck() don't cause things to be cut from the list without being updated.
lighting_update_lights = list()
for(var/datum/light_source/L in lighting_update_lights_old)
if(L.check() || L.destroyed || L.force_update)
L.remove_lum()
if(!L.destroyed)
L.apply_lum()

else if(L.vis_update) //We smartly update only tiles that became (in) visible to use.
L.smart_vis_update()

L.vis_update = FALSE
L.force_update = FALSE
L.needs_update = FALSE

scheck()

var/list/lighting_update_corners_old = lighting_update_corners //Same as above.
lighting_update_corners = list()
for(var/A in lighting_update_corners_old)
var/datum/lighting_corner/C = A

C.update_overlays()

C.needs_update = FALSE

var/list/lighting_update_overlays_old = lighting_update_overlays //Same as above.
lighting_update_overlays = list()

for(var/atom/movable/lighting_overlay/O in lighting_update_overlays_old)
O.update_overlay()
O.needs_update = 0
scheck()
Loading

0 comments on commit 57fb0e0

Please sign in to comment.