GOTTA GO FAST!

This commit is contained in:
PJB3005
2015-06-11 12:56:12 +02:00
parent 9aad286c5a
commit fa77d9f2fc
14 changed files with 86 additions and 101 deletions

View File

@@ -25,7 +25,7 @@
var/frequency = 0
var/id_tag = null
var/datum/radio_frequency/radio_connection
machine_flags = MULTITOOL_MENU
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume
@@ -186,28 +186,16 @@
handled=1
if("set_input_pressure" in signal.data)
input_pressure_min = Clamp(
text2num(signal.data["set_input_pressure"]),
0,
ONE_ATMOSPHERE*50
)
handled=1
input_pressure_min = Clamp(text2num(signal.data["set_input_pressure"]), 0, ONE_ATMOSPHERE * 50)
handled = 1
if("set_output_pressure" in signal.data)
output_pressure_max = Clamp(
text2num(signal.data["set_output_pressure"]),
0,
ONE_ATMOSPHERE*50
)
handled=1
output_pressure_max = Clamp(text2num(signal.data["set_output_pressure"]), 0, ONE_ATMOSPHERE * 50)
handled = 1
if("set_external_pressure" in signal.data)
external_pressure_bound = Clamp(
text2num(signal.data["set_external_pressure"]),
0,
ONE_ATMOSPHERE*50
)
handled=1
external_pressure_bound = Clamp(text2num(signal.data["set_external_pressure"]), 0, ONE_ATMOSPHERE * 50)
handled = 1
if("status" in signal.data)
spawn(2)

View File

@@ -116,11 +116,7 @@
on = !on
if("set_output_pressure" in signal.data)
target_pressure = Clamp(
text2num(signal.data["set_output_pressure"]),
0,
ONE_ATMOSPHERE*50
)
target_pressure = Clamp(text2num(signal.data["set_output_pressure"]), 0, ONE_ATMOSPHERE * 50)
if("status" in signal.data)
spawn(2)

View File

@@ -132,11 +132,7 @@ Thus, the two variables affect pump operation are set in New():
on = !on
if("set_output_pressure" in signal.data)
target_pressure = Clamp(
text2num(signal.data["set_output_pressure"]),
0,
ONE_ATMOSPHERE*50
)
target_pressure = Clamp(text2num(signal.data["set_output_pressure"]), 0, ONE_ATMOSPHERE * 50)
if("status" in signal.data)
spawn(2)

View File

@@ -123,11 +123,7 @@ Thus, the two variables affect pump operation are set in New():
on = !on
if("set_transfer_rate" in signal.data)
transfer_rate = Clamp(
text2num(signal.data["set_transfer_rate"]),
0,
air1.volume
)
transfer_rate = Clamp(text2num(signal.data["set_transfer_rate"]), 0, air1.volume)
if("status" in signal.data)
spawn(2)

View File

@@ -216,59 +216,43 @@
if("stabilize" in signal.data)
pressure_checks |= 1
pump_direction = 1
handled=1
handled = 1
if("power" in signal.data)
on = text2num(signal.data["power"])
handled=1
handled = 1
if("power_toggle" in signal.data)
on = !on
handled=1
handled = 1
if("checks" in signal.data)
pressure_checks = text2num(signal.data["checks"])
handled=1
handled = 1
if("checks_toggle" in signal.data)
pressure_checks = (pressure_checks?0:3)
handled=1
handled = 1
if("direction" in signal.data)
pump_direction = text2num(signal.data["direction"])
handled=1
handled = 1
if("set_internal_pressure" in signal.data)
internal_pressure_bound = Clamp(
text2num(signal.data["set_internal_pressure"]),
0,
ONE_ATMOSPHERE*50
)
handled=1
internal_pressure_bound = Clamp(text2num(signal.data["set_internal_pressure"]), 0, ONE_ATMOSPHERE * 50)
handled =1
if("set_external_pressure" in signal.data)
external_pressure_bound = Clamp(
text2num(signal.data["set_external_pressure"]),
0,
ONE_ATMOSPHERE*50
)
handled=1
external_pressure_bound = Clamp(text2num(signal.data["set_external_pressure"]), 0, ONE_ATMOSPHERE * 50)
handled = 1
if("adjust_internal_pressure" in signal.data)
internal_pressure_bound = Clamp(
internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]),
0,
ONE_ATMOSPHERE*50
)
handled=1
internal_pressure_bound = Clamp(internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]), 0, ONE_ATMOSPHERE * 50)
handled = 1
if("adjust_external_pressure" in signal.data)
external_pressure_bound = Clamp(
external_pressure_bound + text2num(signal.data["adjust_external_pressure"]),
0,
ONE_ATMOSPHERE*50
)
handled=1
external_pressure_bound = Clamp(external_pressure_bound + text2num(signal.data["adjust_external_pressure"]), 0, ONE_ATMOSPHERE * 50)
handled = 1
if("init" in signal.data)
name = signal.data["init"]

View File

@@ -120,3 +120,8 @@
#define isbadmonkey(H) ((/datum/disease/jungle_fever in H.viruses) || H.mind in ticker.mode.infected_monkeys)
#define isdeathsquad(H) (H.mind in ticker.mode.deathsquads)
//1 line helper procs compressed into defines.
#define Clamp(x, y, z) (x <= y ? y : (x >= z ? z : x))
#define CLAMP01(x) (Clamp(x, 0, 1))

View File

@@ -27,6 +27,8 @@ proc/arctan(x)
/proc/Ceiling(x)
return -round(-x)
//Moved to macros.dm to reduce pure calling overhead, this was being called shitloads, like, most calls of all procs.
/*
/proc/Clamp(const/val, const/min, const/max)
if (val <= min)
return min
@@ -35,6 +37,7 @@ proc/arctan(x)
return max
return val
*/
// cotangent
/proc/Cot(x)
@@ -173,7 +176,3 @@ proc/arctan(x)
//Thanks to wwjnc for this.
/proc/test_bitflag(var/bitflag)
return bitflag != 0 && !(bitflag & (bitflag - 1))
//Some thing for lighting code
#define CLAMP01(x) Clamp(x, 0, 1)

View File

@@ -317,12 +317,16 @@ You are weak to holy things and starlight. Don't go into space and avoid the Cha
/datum/vampire/proc/OnLife()
if(!owner) return
if(!owner.druggy)
owner.see_invisible = SEE_INVISIBLE_LEVEL_TWO
if(VAMP_MATURE in powers)
owner.sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS
owner.see_in_dark = 8
owner.see_invisible = SEE_INVISIBLE_MINIMUM
else if(VAMP_VISION in powers)
owner.sight |= SEE_MOBS
if(!owner.druggy) owner.see_invisible = SEE_INVISIBLE_LEVEL_TWO
/mob/proc/handle_bloodsucking(mob/living/carbon/human/H)
src.mind.vampire.draining = H

View File

@@ -70,10 +70,10 @@
if(A.anchored && istype(A, /obj/machinery)) continue
if(istype(A, /obj/structure/disposalpipe )) continue
if(istype(A, /obj/structure/cable )) continue
if(istype(A, /atom/movable/lighting_overlay)) continue
var/turf/newloc = locate(A.x + x_distance, A.y + y_distance, TO.z) // calculate the new place
if(!A.Move(newloc)) // if the atom, for some reason, can't move, FORCE them to move! :) We try Move() first to invoke any movement-related checks the atom needs to perform after moving
A.loc = locate(A.x + x_distance, A.y + y_distance, TO.z)
A.forceMove(newloc)
spawn()
if(ismob(A) && !(A in flashers)) // don't flash if we're already doing an effect
@@ -88,4 +88,4 @@
M.client.screen += blueeffect
sleep(20)
M.client.screen -= blueeffect
del(blueeffect)
qdel(blueeffect)

View File

@@ -25,11 +25,11 @@
/datum/light_source/New(atom/owner, atom/top)
source_atom = owner
if(!source_atom.light_sources) source_atom.light_sources = list()
source_atom.light_sources |= src
source_atom.light_sources += src
top_atom = top
if(top_atom != source_atom)
if(!top.light_sources) top.light_sources = list()
top_atom.light_sources |= src
top_atom.light_sources += src
source_turf = top_atom
light_power = source_atom.light_power
@@ -59,14 +59,16 @@
top_atom = new_top_atom
if(top_atom != source_atom)
if(!top_atom.light_sources) top_atom.light_sources = list()
top_atom.light_sources |= src
lighting_update_lights |= src
needs_update = 1
top_atom.light_sources += src
if(!needs_update)
lighting_update_lights += src
needs_update = 1
/datum/light_source/proc/force_update()
needs_update = 1
force_update = 1
lighting_update_lights |= src
if(!needs_update)
needs_update = 1
lighting_update_lights += src
/datum/light_source/proc/check()
if(!source_atom || !light_range || !light_power)
@@ -146,6 +148,8 @@
for(var/turf/T in dview(light_range, source_turf, INVISIBILITY_LIGHTING))
if(T.lighting_overlay)
var/strength = light_power * falloff(T.lighting_overlay)
if(!strength) //Don't add turfs that aren't affected to the affected turfs.
continue
effect_r[T.lighting_overlay] = round(lum_r * strength, LIGHTING_ROUND_VALUE)
effect_g[T.lighting_overlay] = round(lum_g * strength, LIGHTING_ROUND_VALUE)
@@ -156,8 +160,8 @@
if(!T.affecting_lights)
T.affecting_lights = list()
T.affecting_lights |= src
effect_turf |= T
T.affecting_lights += src
effect_turf += T
#else
for(var/turf/T in dview(light_range, source_turf, INVISIBILITY_LIGHTING))
@@ -173,8 +177,8 @@
if(!T.affecting_lights)
T.affecting_lights = list()
T.affecting_lights |= src
effect_turf |= T
T.affecting_lights += src
effect_turf += T
#endif
/datum/light_source/proc/remove_lum()

View File

@@ -30,24 +30,25 @@
var/should_update = 0
if(max(lum_r, lum_g, lum_b) < 1) //Any change that could happen WILL change appearance.
should_update = 1
else if(max(lum_r + delta_r, lum_g + delta_g, lum_b + delta_b) < 1) //The change would bring us under 1 max lum, again, guaranteed to change appearance.
should_update = 1
else //We need to make sure that the colour ratios won't change in this code block.
var/mx1 = max(lum_r, lum_g, lum_b)
var/mx2 = max(lum_r + delta_r, lum_g + delta_g, lum_b + delta_b)
if(lum_r * mx1 != lum_r + delta_r * mx2 || lum_g * mx1 != lum_g + delta_g * mx2 || lum_b * mx1 != lum_b + delta_b * mx2) //Stuff would change.
if(!needs_update) //If this isn't true, we're already updating anyways.
if(max(lum_r, lum_g, lum_b) < 1) //Any change that could happen WILL change appearance.
should_update = 1
else if(max(lum_r + delta_r, lum_g + delta_g, lum_b + delta_b) < 1) //The change would bring us under 1 max lum, again, guaranteed to change appearance.
should_update = 1
else //We need to make sure that the colour ratios won't change in this code block.
var/mx1 = max(lum_r, lum_g, lum_b)
var/mx2 = max(lum_r + delta_r, lum_g + delta_g, lum_b + delta_b)
if(lum_r / mx1 != (lum_r + delta_r) / mx2 || lum_g / mx1 != (lum_g + delta_g) / mx2 || lum_b / mx1 != (lum_b + delta_b) / mx2) //Stuff would change.
should_update = 1
lum_r += delta_r
lum_g += delta_g
lum_b += delta_b
if(should_update)
if(!needs_update && should_update)
needs_update = 1
lighting_update_overlays |= src
@@ -59,7 +60,7 @@
#if LIGHTING_TRANSITIONS == 1
animate(src,
color = rgb(lum_r * 255 * ., lum_g * 255 * ., lum_b * 255 * .),
LIGHTING_INTERVAL - 1
LIGHTING_TRANSITION_SPEED
)
#else
color = rgb(lum_r * 255 * ., lum_g * 255 * ., lum_b * 255 * .)
@@ -72,7 +73,7 @@
T.luminosity = 1
else //No light, set the turf's luminosity to 0 to remove it from view()
#if LIGHTING_TRANSITIONS == 1
spawn(LIGHTING_INTERVAL - 1)
spawn(LIGHTING_TRANSITION_SPEED)
T.luminosity = 0
#else
T.luminosity = 0
@@ -121,3 +122,8 @@
/atom/movable/lighting_overlay/ex_act(severity)
return 0
//Override here to prevent things accidentally moving around overlays.
/atom/movable/lighting_overlay/forceMove(atom/destination, var/harderforce = 0)
if(harderforce)
.= ..()

View File

@@ -3,7 +3,7 @@
#if LIGHTING_RESOLUTION == 1
var/atom/movable/lighting_overlay/lighting_overlay
#else
var/list/lighting_overlays[LIGHTING_RESOLUTION ** 2]
var/list/lighting_overlays[0]
#endif
/turf/proc/reconsider_lights()
@@ -50,7 +50,11 @@
#endif
/turf/proc/get_lumcount(var/minlum = 0, var/maxlum = 1)
if(!dynamic_lighting) //We're not dynamic, whatever, return 50% lighting.
#if LIGHTING_RESOLUTION == 1
if(!lighting_overlay) //We're not dynamic, whatever, return 50% lighting.
#else
if(!lighting_overlays.len)
#endif
return 0.5
var/totallums = 0
@@ -74,7 +78,7 @@
return Clamp(totallums, 0, 1)
//Proc I made to dick around with update lumcount
//Proc I made to dick around with update lumcount.
/turf/proc/update_lumcount(delta_r, delta_g, delta_b)
#if LIGHTING_RESOLUTION == 1
if(lighting_overlay)

View File

@@ -152,7 +152,7 @@
return
/mob/living/proc/adjust_fire_stacks(add_fire_stacks) //Adjusting the amount of fire_stacks we have on person
fire_stacks = Clamp(fire_stacks + add_fire_stacks, min = -20, max = 20)
fire_stacks = Clamp(fire_stacks + add_fire_stacks, -20, 20)
/mob/living/proc/handle_fire()
if((flags & INVULNERABLE) && on_fire)

View File

@@ -1164,6 +1164,9 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse
#define LIGHTING_LAMBERTIAN 1 // 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_TRANSITIONS 1 // smooth, animated transitions, similar to TG station
#ifdef LIGHTING_TRANSITIONS
#define LIGHTING_TRANSITION_SPEED (LIGHTING_INTERVAL - 2)
#endif
#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_RESOLUTION 1 // resolution of the lighting overlays, powers of 2 only, max of 32