mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 03:27:05 +01:00
Merge fix
This commit is contained in:
@@ -32,8 +32,10 @@ Pipelines + Other Objects -> Pipe network
|
||||
var/global/datum/pipe_icon_manager/icon_manager
|
||||
|
||||
/obj/machinery/atmospherics/New()
|
||||
if(!armor)
|
||||
armor = list(melee = 25, bullet = 10, laser = 10, energy = 100, bomb = 0, bio = 100, rad = 100)
|
||||
..()
|
||||
atmos_machinery += src
|
||||
SSair.atmos_machinery += src
|
||||
if(!icon_manager)
|
||||
icon_manager = new()
|
||||
|
||||
@@ -54,7 +56,7 @@ Pipelines + Other Objects -> Pipe network
|
||||
|
||||
/obj/machinery/atmospherics/Destroy()
|
||||
QDEL_NULL(stored)
|
||||
atmos_machinery -= src
|
||||
SSair.atmos_machinery -= src
|
||||
for(var/mob/living/L in src) //ventcrawling is serious business
|
||||
L.remove_ventcrawl()
|
||||
L.forceMove(get_turf(src))
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
|
||||
/obj/machinery/atmospherics/binary/passive_gate/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 385, 115, state = state)
|
||||
ui.open()
|
||||
@@ -174,7 +174,7 @@
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/atmospherics/binary/passive_gate/attackby(obj/item/weapon/W, mob/user, params)
|
||||
if(!istype(W, /obj/item/weapon/wrench))
|
||||
|
||||
@@ -157,7 +157,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
|
||||
/obj/machinery/atmospherics/binary/pump/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 385, 115, state = state)
|
||||
ui.open()
|
||||
@@ -194,7 +194,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/atmospherics/binary/pump/power_change()
|
||||
var/old_stat = stat
|
||||
|
||||
@@ -147,7 +147,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 310, 115, state = state)
|
||||
ui.open()
|
||||
@@ -184,7 +184,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", "atmos")
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/power_change()
|
||||
var/old_stat = stat
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
/obj/machinery/atmospherics/omni/filter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, force_open = 0)
|
||||
usr.set_machine(src)
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "omni_filter.tmpl", "Omni Filter Control", 330, 330)
|
||||
ui.open()
|
||||
@@ -197,7 +197,7 @@
|
||||
switch_filter(dir_flag(href_list["dir"]), mode_return_switch(new_filter))
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/omni/filter/proc/mode_return_switch(var/mode)
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
/obj/machinery/atmospherics/omni/mixer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, force_open = 0)
|
||||
usr.set_machine(src)
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "omni_mixer.tmpl", "Omni Mixer Control", 360, 330)
|
||||
ui.open()
|
||||
@@ -202,7 +202,7 @@
|
||||
con_lock(dir_flag(href_list["dir"]))
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/omni/mixer/proc/switch_mode(var/port = NORTH, var/mode = ATM_NONE)
|
||||
|
||||
@@ -162,7 +162,7 @@ Filter types:
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_filter.tmpl", name, 475, 155, state = state)
|
||||
ui.open()
|
||||
@@ -204,4 +204,4 @@ Filter types:
|
||||
. = TRUE
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
@@ -125,7 +125,7 @@
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_mixer.tmpl", name, 370, 165, state = state)
|
||||
ui.open()
|
||||
@@ -176,4 +176,4 @@
|
||||
. = TRUE
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
@@ -37,11 +37,11 @@
|
||||
if(!partner)
|
||||
return 0
|
||||
|
||||
if(!air_master || air_master.current_cycle <= update_cycle)
|
||||
if(!SSair || SSair.times_fired <= update_cycle)
|
||||
return 0
|
||||
|
||||
update_cycle = air_master.current_cycle
|
||||
partner.update_cycle = air_master.current_cycle
|
||||
update_cycle = SSair.times_fired
|
||||
partner.update_cycle = SSair.times_fired
|
||||
|
||||
var/air_heat_capacity = air_contents.heat_capacity()
|
||||
var/other_air_heat_capacity = partner.air_contents.heat_capacity()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#define EXTERNAL_PRESSURE_BOUND ONE_ATMOSPHERE
|
||||
#define INTERNAL_PRESSURE_BOUND 0
|
||||
#define PRESSURE_CHECKS 1
|
||||
#undefine
|
||||
|
||||
/obj/machinery/atmospherics/unary/vent_pump
|
||||
icon = 'icons/atmos/vent_pump.dmi'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
var/global/list/pipe_networks = list()
|
||||
var/global/list/deferred_pipenet_rebuilds = list()
|
||||
|
||||
/datum/pipeline
|
||||
@@ -13,10 +12,10 @@ var/global/list/deferred_pipenet_rebuilds = list()
|
||||
var/alert_pressure = 0
|
||||
|
||||
/datum/pipeline/New()
|
||||
pipe_networks += src
|
||||
SSair.networks += src
|
||||
|
||||
/datum/pipeline/Destroy()
|
||||
pipe_networks -= src
|
||||
SSair.networks -= src
|
||||
if(air && air.volume)
|
||||
temporarily_store_air()
|
||||
for(var/obj/machinery/atmospherics/pipe/P in members)
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
active_hotspot.temperature = exposed_temperature
|
||||
active_hotspot.volume = exposed_volume
|
||||
|
||||
active_hotspot.just_spawned = (current_cycle < air_master.current_cycle)
|
||||
active_hotspot.just_spawned = (current_cycle < SSair.times_fired)
|
||||
//remove just_spawned protection if no longer processing this cell
|
||||
air_master.add_to_active(src, 0)
|
||||
SSair.add_to_active(src, 0)
|
||||
return igniting
|
||||
|
||||
//This is the icon for fire on turfs, also helps for nurturing small fires until they are full tile
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
/obj/effect/hotspot/New()
|
||||
..()
|
||||
air_master.hotspots += src
|
||||
SSair.hotspots += src
|
||||
perform_exposure()
|
||||
dir = pick(cardinal)
|
||||
air_update_turf()
|
||||
@@ -154,7 +154,7 @@
|
||||
|
||||
/obj/effect/hotspot/Destroy()
|
||||
set_light(0)
|
||||
air_master.hotspots -= src
|
||||
SSair.hotspots -= src
|
||||
DestroyTurf()
|
||||
if(istype(loc, /turf/simulated))
|
||||
var/turf/simulated/T = loc
|
||||
|
||||
@@ -126,8 +126,8 @@ turf/CanPass(atom/movable/mover, turf/target, height=1.5)
|
||||
/turf/proc/air_update_turf(var/command = 0)
|
||||
if(command)
|
||||
CalculateAdjacentTurfs()
|
||||
if(air_master)
|
||||
air_master.add_to_active(src,command)
|
||||
if(SSair)
|
||||
SSair.add_to_active(src,command)
|
||||
|
||||
/atom/movable/proc/move_update_air(var/turf/T)
|
||||
if(istype(T,/turf))
|
||||
@@ -184,4 +184,4 @@ var/const/SPAWN_AIR = 256
|
||||
G.nitrogen += MOLES_N2STANDARD * amount
|
||||
|
||||
air.merge(G)
|
||||
air_master.add_to_active(src, 0)
|
||||
SSair.add_to_active(src, 0)
|
||||
|
||||
@@ -141,9 +141,9 @@
|
||||
|
||||
/turf/simulated/proc/process_cell()
|
||||
|
||||
if(archived_cycle < air_master.current_cycle) //archive self if not already done
|
||||
if(archived_cycle < SSair.times_fired) //archive self if not already done
|
||||
archive()
|
||||
current_cycle = air_master.current_cycle
|
||||
current_cycle = SSair.times_fired
|
||||
|
||||
var/remove = 1 //set by non simulated turfs who are sharing with this turf
|
||||
|
||||
@@ -184,7 +184,7 @@
|
||||
share_air(enemy_simulated) //share
|
||||
else
|
||||
if(!air.compare(enemy_simulated.air)) //compare if
|
||||
air_master.add_to_active(enemy_simulated) //excite enemy
|
||||
SSair.add_to_active(enemy_simulated) //excite enemy
|
||||
if(excited_group)
|
||||
excited_group.add_turf(enemy_simulated) //add enemy to group
|
||||
else
|
||||
@@ -227,14 +227,14 @@
|
||||
update_visuals()
|
||||
|
||||
if(!excited_group && remove == 1)
|
||||
air_master.remove_from_active(src)
|
||||
SSair.remove_from_active(src)
|
||||
|
||||
|
||||
/turf/simulated/proc/archive()
|
||||
if(air) //For open space like floors
|
||||
air.archive()
|
||||
temperature_archived = temperature
|
||||
archived_cycle = air_master.current_cycle
|
||||
archived_cycle = SSair.times_fired
|
||||
|
||||
/turf/simulated/proc/update_visuals()
|
||||
if(icy && !icyoverlay)
|
||||
@@ -288,7 +288,7 @@
|
||||
last_share_check()
|
||||
|
||||
/turf/proc/consider_pressure_difference(var/turf/simulated/T, var/difference)
|
||||
air_master.high_pressure_delta |= src
|
||||
SSair.high_pressure_delta |= src
|
||||
if(difference > pressure_difference)
|
||||
pressure_direction = get_dir(src, T)
|
||||
pressure_difference = difference
|
||||
@@ -309,24 +309,48 @@
|
||||
/atom/movable/var/last_forced_movement = 0
|
||||
|
||||
/atom/movable/proc/experience_pressure_difference(pressure_difference, direction)
|
||||
if(last_forced_movement >= air_master.current_cycle)
|
||||
if(last_forced_movement >= SSair.times_fired)
|
||||
return 0
|
||||
else if(!anchored && !pulledby)
|
||||
var/turf/target = get_turf(src)
|
||||
var/datum/gas_mixture/target_air = target.return_air()
|
||||
if(isunsimulatedturf(target) || pressure_resistance > target_air.return_pressure())
|
||||
return 0
|
||||
if(pressure_difference >= throw_pressure_limit)
|
||||
var/general_direction = get_edge_target_turf(src, direction)
|
||||
if(last_forced_movement + 10 < air_master.current_cycle && is_valid_tochat_target(src)) //the first check prevents spamming throw to_chat
|
||||
if(last_forced_movement + 10 < SSair.times_fired && is_valid_tochat_target(src)) //the first check prevents spamming throw to_chat
|
||||
to_chat(src, "<span class='userdanger'>The pressure sends you flying!</span>")
|
||||
if(ishuman(src))
|
||||
var/mob/living/carbon/human/H = src
|
||||
H.Weaken(min(pressure_difference / 10, 10))
|
||||
spawn()
|
||||
throw_at(general_direction, pressure_difference / 10, pressure_difference / 200, null, 0, 0, null)
|
||||
last_forced_movement = air_master.current_cycle
|
||||
var/max_distance = 14 // reduce by one each calculation to prevent infinate loops.
|
||||
var/min_observed_pressure = INFINITY
|
||||
var/turf/possible_target = get_turf(src)
|
||||
while(!isunsimulatedturf(target) && max_distance > 0)
|
||||
max_distance--
|
||||
target_air = target.return_air()
|
||||
min_observed_pressure = target_air.return_pressure()
|
||||
possible_target = get_step_towards(target,general_direction)
|
||||
if(istype(possible_target, /turf/space))
|
||||
target = possible_target
|
||||
break
|
||||
if(!CanAtmosPass(possible_target))
|
||||
target = possible_target
|
||||
max_distance = 0
|
||||
break
|
||||
var/datum/gas_mixture/possible_target_air = possible_target.return_air()
|
||||
if(possible_target_air.return_pressure() > min_observed_pressure)
|
||||
target = possible_target
|
||||
break
|
||||
target = possible_target
|
||||
if(max_distance)
|
||||
throw_at(target, get_dist(src, target), pressure_difference / 200, null, 0, 0, null)
|
||||
else
|
||||
throw_at(target, pressure_difference / 10, pressure_difference / 200, null, 0, 0, null)
|
||||
last_forced_movement = SSair.times_fired
|
||||
return 1
|
||||
else if(pressure_difference > pressure_resistance)
|
||||
spawn()
|
||||
step(src, direction)
|
||||
last_forced_movement = air_master.current_cycle
|
||||
last_forced_movement = SSair.times_fired
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -337,8 +361,8 @@
|
||||
var/breakdown_cooldown = 0
|
||||
|
||||
/datum/excited_group/New()
|
||||
if(air_master)
|
||||
air_master.excited_groups += src
|
||||
if(SSair)
|
||||
SSair.excited_groups += src
|
||||
|
||||
/datum/excited_group/proc/add_turf(var/turf/simulated/T)
|
||||
turf_list += T
|
||||
@@ -348,13 +372,13 @@
|
||||
|
||||
/datum/excited_group/proc/merge_groups(var/datum/excited_group/E)
|
||||
if(turf_list.len > E.turf_list.len)
|
||||
air_master.excited_groups -= E
|
||||
SSair.excited_groups -= E
|
||||
for(var/turf/simulated/T in E.turf_list)
|
||||
T.excited_group = src
|
||||
turf_list += T
|
||||
reset_cooldowns()
|
||||
else
|
||||
air_master.excited_groups -= src
|
||||
SSair.excited_groups -= src
|
||||
for(var/turf/simulated/T in turf_list)
|
||||
T.excited_group = E
|
||||
E.turf_list += T
|
||||
@@ -400,14 +424,14 @@
|
||||
T.excited = 0
|
||||
T.recently_active = 0
|
||||
T.excited_group = null
|
||||
air_master.active_turfs -= T
|
||||
SSair.active_turfs -= T
|
||||
garbage_collect()
|
||||
|
||||
/datum/excited_group/proc/garbage_collect()
|
||||
for(var/turf/simulated/T in turf_list)
|
||||
T.excited_group = null
|
||||
turf_list.Cut()
|
||||
air_master.excited_groups -= src
|
||||
SSair.excited_groups -= src
|
||||
|
||||
|
||||
|
||||
@@ -424,7 +448,7 @@ turf/simulated/proc/super_conduct()
|
||||
//Does not participate in air exchange, so will conduct heat across all four borders at this time
|
||||
conductivity_directions = NORTH|SOUTH|EAST|WEST
|
||||
|
||||
if(archived_cycle < air_master.current_cycle)
|
||||
if(archived_cycle < SSair.times_fired)
|
||||
archive()
|
||||
else
|
||||
//Does particate in air exchange so only consider directions not considered during process_cell()
|
||||
@@ -444,7 +468,7 @@ turf/simulated/proc/super_conduct()
|
||||
if(istype(neighbor, /turf/simulated)) //anything under this subtype will share in the exchange
|
||||
var/turf/simulated/T = neighbor
|
||||
|
||||
if(T.archived_cycle < air_master.current_cycle)
|
||||
if(T.archived_cycle < SSair.times_fired)
|
||||
T.archive()
|
||||
|
||||
if(T.air)
|
||||
@@ -452,7 +476,7 @@ turf/simulated/proc/super_conduct()
|
||||
air.temperature_share(T.air, WINDOW_HEAT_TRANSFER_COEFFICIENT)
|
||||
else //Solid but neighbor is open
|
||||
T.air.temperature_turf_share(src, T.thermal_conductivity)
|
||||
air_master.add_to_active(T, 0)
|
||||
SSair.add_to_active(T, 0)
|
||||
else
|
||||
if(air) //Open but neighbor is solid
|
||||
air.temperature_turf_share(T, T.thermal_conductivity)
|
||||
@@ -476,12 +500,12 @@ turf/simulated/proc/super_conduct()
|
||||
|
||||
//Make sure still hot enough to continue conducting heat
|
||||
if(air.temperature < MINIMUM_TEMPERATURE_FOR_SUPERCONDUCTION)
|
||||
air_master.active_super_conductivity -= src
|
||||
SSair.active_super_conductivity -= src
|
||||
return 0
|
||||
|
||||
else
|
||||
if(temperature < MINIMUM_TEMPERATURE_FOR_SUPERCONDUCTION)
|
||||
air_master.active_super_conductivity -= src
|
||||
SSair.active_super_conductivity -= src
|
||||
return 0
|
||||
|
||||
turf/simulated/proc/consider_superconductivity(starting)
|
||||
@@ -497,7 +521,7 @@ turf/simulated/proc/consider_superconductivity(starting)
|
||||
if(temperature < (starting?MINIMUM_TEMPERATURE_START_SUPERCONDUCTION:MINIMUM_TEMPERATURE_FOR_SUPERCONDUCTION))
|
||||
return 0
|
||||
|
||||
air_master.active_super_conductivity |= src
|
||||
SSair.active_super_conductivity |= src
|
||||
return 1
|
||||
|
||||
turf/simulated/proc/radiate_to_spess() //Radiate excess tile heat to space
|
||||
@@ -508,3 +532,24 @@ turf/simulated/proc/radiate_to_spess() //Radiate excess tile heat to space
|
||||
var/heat = thermal_conductivity*delta_temperature* \
|
||||
(heat_capacity*700000/(heat_capacity+700000)) //700000 is the heat_capacity from a space turf, hardcoded here
|
||||
temperature -= heat/heat_capacity
|
||||
|
||||
/turf/proc/Initialize_Atmos(times_fired)
|
||||
CalculateAdjacentTurfs()
|
||||
|
||||
/turf/simulated/Initialize_Atmos(times_fired)
|
||||
..()
|
||||
update_visuals()
|
||||
for(var/direction in cardinal)
|
||||
if(!(atmos_adjacent_turfs & direction))
|
||||
continue
|
||||
var/turf/enemy_tile = get_step(src, direction)
|
||||
if(istype(enemy_tile, /turf/simulated))
|
||||
var/turf/simulated/enemy_simulated = enemy_tile
|
||||
if(!air.compare(enemy_simulated.air))
|
||||
excited = 1
|
||||
SSair.active_turfs |= src
|
||||
break
|
||||
else
|
||||
if(!air.check_turf_total(enemy_tile))
|
||||
excited = 1
|
||||
SSair.active_turfs |= src
|
||||
@@ -0,0 +1,78 @@
|
||||
#define MC_TICK_CHECK ( ( TICK_USAGE > Master.current_ticklimit || src.state != SS_RUNNING ) ? pause() : 0 )
|
||||
|
||||
#define MC_SPLIT_TICK_INIT(phase_count) var/original_tick_limit = Master.current_ticklimit; var/split_tick_phases = ##phase_count
|
||||
#define MC_SPLIT_TICK \
|
||||
if(split_tick_phases > 1){\
|
||||
Master.current_ticklimit = ((original_tick_limit - TICK_USAGE) / split_tick_phases) + TICK_USAGE;\
|
||||
--split_tick_phases;\
|
||||
} else {\
|
||||
Master.current_ticklimit = original_tick_limit;\
|
||||
}
|
||||
|
||||
// Used to smooth out costs to try and avoid oscillation.
|
||||
#define MC_AVERAGE_FAST(average, current) (0.7 * (average) + 0.3 * (current))
|
||||
#define MC_AVERAGE(average, current) (0.8 * (average) + 0.2 * (current))
|
||||
#define MC_AVERAGE_SLOW(average, current) (0.9 * (average) + 0.1 * (current))
|
||||
|
||||
#define MC_AVG_FAST_UP_SLOW_DOWN(average, current) (average > current ? MC_AVERAGE_SLOW(average, current) : MC_AVERAGE_FAST(average, current))
|
||||
#define MC_AVG_SLOW_UP_FAST_DOWN(average, current) (average < current ? MC_AVERAGE_SLOW(average, current) : MC_AVERAGE_FAST(average, current))
|
||||
|
||||
#define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;}
|
||||
|
||||
#define START_PROCESSING(Processor, Datum) if (!Datum.isprocessing) {Datum.isprocessing = TRUE;Processor.processing += Datum}
|
||||
#define STOP_PROCESSING(Processor, Datum) Datum.isprocessing = FALSE;Processor.processing -= Datum
|
||||
|
||||
//SubSystem flags (Please design any new flags so that the default is off, to make adding flags to subsystems easier)
|
||||
|
||||
//subsystem does not initialize.
|
||||
#define SS_NO_INIT 1
|
||||
|
||||
//subsystem does not fire.
|
||||
// (like can_fire = 0, but keeps it from getting added to the processing subsystems list)
|
||||
// (Requires a MC restart to change)
|
||||
#define SS_NO_FIRE 2
|
||||
|
||||
//subsystem only runs on spare cpu (after all non-background subsystems have ran that tick)
|
||||
// SS_BACKGROUND has its own priority bracket
|
||||
#define SS_BACKGROUND 4
|
||||
|
||||
//subsystem does not tick check, and should not run unless there is enough time (or its running behind (unless background))
|
||||
#define SS_NO_TICK_CHECK 8
|
||||
|
||||
//Treat wait as a tick count, not DS, run every wait ticks.
|
||||
// (also forces it to run first in the tick, above even SS_NO_TICK_CHECK subsystems)
|
||||
// (implies all runlevels because of how it works)
|
||||
// (overrides SS_BACKGROUND)
|
||||
// This is designed for basically anything that works as a mini-mc (like SStimer)
|
||||
#define SS_TICKER 16
|
||||
|
||||
//keep the subsystem's timing on point by firing early if it fired late last fire because of lag
|
||||
// ie: if a 20ds subsystem fires say 5 ds late due to lag or what not, its next fire would be in 15ds, not 20ds.
|
||||
#define SS_KEEP_TIMING 32
|
||||
|
||||
//Calculate its next fire after its fired.
|
||||
// (IE: if a 5ds wait SS takes 2ds to run, its next fire should be 5ds away, not 3ds like it normally would be)
|
||||
// This flag overrides SS_KEEP_TIMING
|
||||
#define SS_POST_FIRE_TIMING 64
|
||||
|
||||
//SUBSYSTEM STATES
|
||||
#define SS_IDLE 0 //aint doing shit.
|
||||
#define SS_QUEUED 1 //queued to run
|
||||
#define SS_RUNNING 2 //actively running
|
||||
#define SS_PAUSED 3 //paused by mc_tick_check
|
||||
#define SS_SLEEPING 4 //fire() slept.
|
||||
#define SS_PAUSING 5 //in the middle of pausing
|
||||
|
||||
#define SUBSYSTEM_DEF(X) GLOBAL_REAL(SS##X, /datum/controller/subsystem/##X);\
|
||||
/datum/controller/subsystem/##X/New(){\
|
||||
NEW_SS_GLOBAL(SS##X);\
|
||||
PreInit();\
|
||||
}\
|
||||
/datum/controller/subsystem/##X
|
||||
|
||||
#define PROCESSING_SUBSYSTEM_DEF(X) GLOBAL_REAL(SS##X, /datum/controller/subsystem/processing/##X);\
|
||||
/datum/controller/subsystem/processing/##X/New(){\
|
||||
NEW_SS_GLOBAL(SS##X);\
|
||||
PreInit();\
|
||||
}\
|
||||
/datum/controller/subsystem/processing/##X
|
||||
@@ -0,0 +1,38 @@
|
||||
//See controllers/globals.dm
|
||||
#define GLOBAL_MANAGED(X, InitValue)\
|
||||
/datum/controller/global_vars/proc/InitGlobal##X(){\
|
||||
##X = ##InitValue;\
|
||||
gvars_datum_init_order += #X;\
|
||||
}
|
||||
#define GLOBAL_UNMANAGED(X) /datum/controller/global_vars/proc/InitGlobal##X() { return; }
|
||||
|
||||
#ifndef TESTING
|
||||
#define GLOBAL_PROTECT(X)\
|
||||
/datum/controller/global_vars/InitGlobal##X(){\
|
||||
..();\
|
||||
gvars_datum_protected_varlist[#X] = TRUE;\
|
||||
}
|
||||
#else
|
||||
#define GLOBAL_PROTECT(X)
|
||||
#endif
|
||||
|
||||
#define GLOBAL_REAL_VAR(X) var/global/##X
|
||||
#define GLOBAL_REAL(X, Typepath) var/global##Typepath/##X
|
||||
|
||||
#define GLOBAL_RAW(X) /datum/controller/global_vars/var/global##X
|
||||
|
||||
#define GLOBAL_VAR_INIT(X, InitValue) GLOBAL_RAW(/##X); GLOBAL_MANAGED(X, InitValue)
|
||||
|
||||
#define GLOBAL_VAR_CONST(X, InitValue) GLOBAL_RAW(/const/##X) = InitValue; GLOBAL_UNMANAGED(X)
|
||||
|
||||
#define GLOBAL_LIST_INIT(X, InitValue) GLOBAL_RAW(/list/##X); GLOBAL_MANAGED(X, InitValue)
|
||||
|
||||
#define GLOBAL_LIST_EMPTY(X) GLOBAL_LIST_INIT(X, list())
|
||||
|
||||
#define GLOBAL_DATUM_INIT(X, Typepath, InitValue) GLOBAL_RAW(Typepath/##X); GLOBAL_MANAGED(X, InitValue)
|
||||
|
||||
#define GLOBAL_VAR(X) GLOBAL_RAW(/##X); GLOBAL_UNMANAGED(X)
|
||||
|
||||
#define GLOBAL_LIST(X) GLOBAL_RAW(/list/##X); GLOBAL_UNMANAGED(X)
|
||||
|
||||
#define GLOBAL_DATUM(X, Typepath) GLOBAL_RAW(Typepath/##X); GLOBAL_UNMANAGED(X)
|
||||
@@ -76,9 +76,17 @@
|
||||
#define EMBEDDED_UNSAFE_REMOVAL_TIME 30 //A Time in ticks, total removal time = (this*item.w_class)
|
||||
|
||||
//Gun Stuff
|
||||
#define SAWN_INTACT 0
|
||||
#define SAWN_OFF 1
|
||||
#define SAWN_INTACT 0
|
||||
#define SAWN_OFF 1
|
||||
|
||||
#define WEAPON_LIGHT 0
|
||||
#define WEAPON_MEDIUM 1
|
||||
#define WEAPON_HEAVY 2
|
||||
#define WEAPON_LIGHT 0
|
||||
#define WEAPON_MEDIUM 1
|
||||
#define WEAPON_HEAVY 2
|
||||
|
||||
#define EXPLODE_NONE 0 //Don't even ask me why we need this.
|
||||
#define EXPLODE_DEVASTATE 1
|
||||
#define EXPLODE_HEAVY 2
|
||||
#define EXPLODE_LIGHT 3
|
||||
|
||||
#define EMP_HEAVY 1
|
||||
#define EMP_LIGHT 2
|
||||
|
||||
@@ -18,6 +18,35 @@
|
||||
#define RWALL_SUPPORT_RODS 5
|
||||
#define RWALL_SHEATH 6
|
||||
|
||||
//airlock assembly construction states
|
||||
#define AIRLOCK_ASSEMBLY_NEEDS_WIRES 0
|
||||
#define AIRLOCK_ASSEMBLY_NEEDS_ELECTRONICS 1
|
||||
#define AIRLOCK_ASSEMBLY_NEEDS_SCREWDRIVER 2
|
||||
|
||||
//plastic flaps construction states
|
||||
#define PLASTIC_FLAPS_NORMAL 0
|
||||
#define PLASTIC_FLAPS_DETACHED 1
|
||||
|
||||
//other construction-related things
|
||||
|
||||
//windows affected by nar-sie turn this color.
|
||||
#define NARSIE_WINDOW_COLOUR "#7D1919"
|
||||
|
||||
//Material defines, for determining how much of a given material an item contains
|
||||
#define MAT_METAL "$metal"
|
||||
#define MAT_GLASS "$glass"
|
||||
#define MAT_SILVER "$silver"
|
||||
#define MAT_GOLD "$gold"
|
||||
#define MAT_DIAMOND "$diamond"
|
||||
#define MAT_URANIUM "$uranium"
|
||||
#define MAT_PLASMA "$plasma"
|
||||
#define MAT_BANANIUM "$bananium"
|
||||
#define MAT_TRANQUILLITE "$tranquillite"
|
||||
#define MAT_TITANIUM "$titanium"
|
||||
#define MAT_BIOMASS "$biomass"
|
||||
//The amount of materials you get from a sheet of mineral like iron/diamond/glass etc
|
||||
#define MINERAL_MATERIAL_AMOUNT 2000
|
||||
//The maximum size of a stack object.
|
||||
#define MAX_STACK_SIZE 50
|
||||
//maximum amount of cable in a coil
|
||||
#define MAXCOIL 30
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#define ALL ~0 //For convenience.
|
||||
#define NONE 0
|
||||
|
||||
//FLAGS BITMASK
|
||||
#define STOPSPRESSUREDMAGE 1 //This flag is used on the flags variable for SUIT and HEAD items which stop pressure damage. Note that the flag 1 was previous used as ONBACK, so it is possible for some code to use (flags & 1) when checking if something can be put on your back. Replace this code with (inv_flags & SLOT_BACK) if you see it anywhere To successfully stop you taking all pressure damage you must have both a suit and head item with this flag.
|
||||
#define NODROP 2 // This flag makes it so that an item literally cannot be removed at all, or at least that's how it should be. Only deleted.
|
||||
@@ -66,6 +69,7 @@
|
||||
|
||||
//turf-only flags
|
||||
#define NOJAUNT 1
|
||||
#define RPD_ALLOWED_HERE 2//By default, RPD is disabled on turfs.
|
||||
|
||||
//ITEM INVENTORY SLOT BITMASKS
|
||||
#define SLOT_OCLOTHING 1
|
||||
@@ -89,3 +93,14 @@
|
||||
#define AFFECT_ROBOTIC_ORGAN 1
|
||||
#define AFFECT_ORGANIC_ORGAN 2
|
||||
#define AFFECT_ALL_ORGANS 3
|
||||
|
||||
//Fire stuff, for burn_state
|
||||
#define LAVA_PROOF -2
|
||||
#define FIRE_PROOF -1
|
||||
#define FLAMMABLE 0
|
||||
#define ON_FIRE 1
|
||||
|
||||
//resistance_flags
|
||||
#define INDESTRUCTIBLE 64 //doesn't take damage
|
||||
|
||||
GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768))
|
||||
|
||||
+18
-12
@@ -26,6 +26,11 @@
|
||||
#define PLANT_PEST_HUD "21"// Pest level
|
||||
#define PLANT_WEED_HUD "22"// Weed level
|
||||
#define DIAG_TRACK_HUD "23"// Mech tracking beacon
|
||||
#define DIAG_PATH_HUD "24"//Bot path indicators
|
||||
|
||||
//by default everything in the hud_list of an atom is an image
|
||||
//a value in hud_list with one of these will change that behavior
|
||||
#define HUD_LIST_LIST 1
|
||||
|
||||
//data HUD (medhud, sechud) defines
|
||||
//Don't forget to update human/New() if you change these!
|
||||
@@ -34,20 +39,21 @@
|
||||
#define DATA_HUD_MEDICAL_BASIC 3
|
||||
#define DATA_HUD_MEDICAL_ADVANCED 4
|
||||
#define DATA_HUD_DIAGNOSTIC 5
|
||||
#define DATA_HUD_HYDROPONIC 6
|
||||
#define DATA_HUD_DIAGNOSTIC_ADVANCED 6
|
||||
#define DATA_HUD_HYDROPONIC 7
|
||||
//NATIONS
|
||||
#define GAME_HUD_NATIONS 7
|
||||
#define GAME_HUD_NATIONS 8
|
||||
//antag HUD defines
|
||||
#define ANTAG_HUD_CULT 8
|
||||
#define ANTAG_HUD_REV 9
|
||||
#define ANTAG_HUD_OPS 10
|
||||
#define ANTAG_HUD_WIZ 11
|
||||
#define ANTAG_HUD_SHADOW 12
|
||||
#define ANTAG_HUD_TRAITOR 13
|
||||
#define ANTAG_HUD_NINJA 14 //For Daves Rework
|
||||
#define ANTAG_HUD_CHANGELING 15
|
||||
#define ANTAG_HUD_VAMPIRE 16
|
||||
#define ANTAG_HUD_ABDUCTOR 17 //For Fox
|
||||
#define ANTAG_HUD_CULT 9
|
||||
#define ANTAG_HUD_REV 10
|
||||
#define ANTAG_HUD_OPS 11
|
||||
#define ANTAG_HUD_WIZ 12
|
||||
#define ANTAG_HUD_SHADOW 13
|
||||
#define ANTAG_HUD_TRAITOR 14
|
||||
#define ANTAG_HUD_NINJA 15
|
||||
#define ANTAG_HUD_CHANGELING 16
|
||||
#define ANTAG_HUD_VAMPIRE 17
|
||||
#define ANTAG_HUD_ABDUCTOR 18
|
||||
|
||||
// Notification action types
|
||||
#define NOTIFY_JUMP "jump"
|
||||
|
||||
@@ -5,8 +5,15 @@
|
||||
// Mobs
|
||||
#define ismegafauna(A) istype(A, /mob/living/simple_animal/hostile/megafauna)
|
||||
|
||||
//Simple animals
|
||||
#define isshade(A) (istype(A, /mob/living/simple_animal/shade))
|
||||
|
||||
#define isconstruct(A) (istype(A, /mob/living/simple_animal/hostile/construct))
|
||||
|
||||
//Objects
|
||||
|
||||
#define ismecha(A) (istype(A, /obj/mecha))
|
||||
|
||||
#define is_cleanable(A) (istype(A, /obj/effect/decal/cleanable) || istype(A, /obj/effect/rune)) //if something is cleanable
|
||||
|
||||
#define is_pen(W) (istype(W, /obj/item/weapon/pen))
|
||||
|
||||
@@ -21,14 +21,17 @@
|
||||
#define LOW_OBJ_LAYER 2.5
|
||||
|
||||
#define BELOW_OPEN_DOOR_LAYER 2.6
|
||||
#define BLASTDOOR_LAYER 2.65
|
||||
#define OPEN_DOOR_LAYER 2.7
|
||||
#define PROJECTILE_HIT_THRESHHOLD_LAYER 2.75 //projectiles won't hit objects at or below this layer if possible
|
||||
#define TABLE_LAYER 2.8
|
||||
#define BELOW_OBJ_LAYER 2.9
|
||||
#define LOW_ITEM_LAYER 2.95
|
||||
//#define OBJ_LAYER 3 //For easy recordkeeping; this is a byond define
|
||||
#define CLOSED_BLASTDOOR_LAYER 3.05
|
||||
#define CLOSED_DOOR_LAYER 3.1
|
||||
#define CLOSED_FIREDOOR_LAYER 3.11
|
||||
#define SHUTTER_LAYER 3.12 // HERE BE DRAGONS
|
||||
#define ABOVE_OBJ_LAYER 3.2
|
||||
#define ABOVE_WINDOW_LAYER 3.3
|
||||
#define SIGN_LAYER 3.4
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone
|
||||
|
||||
#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_ICON 'icons/effects/lighting_overlay.dmi' // icon used for lighting shading effects
|
||||
|
||||
#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.
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#define FILE_DRM 16 // Some files want to not be copied/moved. This is them complaining that you tried.
|
||||
#define NETWORK_FAILURE 32
|
||||
|
||||
#define MINERAL_MATERIAL_AMOUNT 2000 //The amount of materials you get from a sheet of mineral like iron/diamond/glass etc
|
||||
|
||||
#define IMPRINTER 1 //For circuits. Uses glass/chemicals.
|
||||
#define PROTOLATHE 2 //New stuff. Uses glass/metal/chemicals
|
||||
#define AUTOLATHE 4 //Uses glass/metal only.
|
||||
|
||||
+17
-1
@@ -30,4 +30,20 @@
|
||||
#define Lcm(a, b) (abs(a) / Gcd((a), (b)) * abs(b))
|
||||
#define Root(n, x) ((x) ** (1 / (n)))
|
||||
#define ToDegrees(radians) ((radians) * 57.2957795) // 180 / Pi
|
||||
#define ToRadians(degrees) ((degrees) * 0.0174532925) // Pi / 180
|
||||
#define ToRadians(degrees) ((degrees) * 0.0174532925) // Pi / 180
|
||||
|
||||
//"fancy" math for calculating time in ms from tick_usage percentage and the length of ticks
|
||||
//percent_of_tick_used * (ticklag * 100(to convert to ms)) / 100(percent ratio)
|
||||
//collapsed to percent_of_tick_used * tick_lag
|
||||
#define TICK_DELTA_TO_MS(percent_of_tick_used) ((percent_of_tick_used) * world.tick_lag)
|
||||
#define TICK_USAGE_TO_MS(starting_tickusage) (TICK_DELTA_TO_MS(TICK_USAGE_REAL - starting_tickusage))
|
||||
|
||||
//time of day but automatically adjusts to the server going into the next day within the same round.
|
||||
//for when you need a reliable time number that doesn't depend on byond time.
|
||||
#define REALTIMEOFDAY (world.timeofday + (MIDNIGHT_ROLLOVER * MIDNIGHT_ROLLOVER_CHECK))
|
||||
#define MIDNIGHT_ROLLOVER_CHECK ( GLOB.rollovercheck_last_timeofday != world.timeofday ? update_midnight_rollover() : GLOB.midnight_rollovers )
|
||||
|
||||
#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) )
|
||||
|
||||
+4
-21
@@ -162,20 +162,6 @@
|
||||
#define MIN_SUPPLIED_LAW_NUMBER 15
|
||||
#define MAX_SUPPLIED_LAW_NUMBER 50
|
||||
|
||||
//Material defines
|
||||
#define MAT_METAL "$metal"
|
||||
#define MAT_GLASS "$glass"
|
||||
#define MAT_SILVER "$silver"
|
||||
#define MAT_GOLD "$gold"
|
||||
#define MAT_DIAMOND "$diamond"
|
||||
#define MAT_URANIUM "$uranium"
|
||||
#define MAT_PLASMA "$plasma"
|
||||
#define MAT_BANANIUM "$bananium"
|
||||
#define MAT_TRANQUILLITE "$tranquillite"
|
||||
#define MAT_BIOMASS "$biomass"
|
||||
|
||||
#define MAX_STACK_SIZE 50
|
||||
|
||||
//check_target_facings() return defines
|
||||
#define FACING_FAILED 0
|
||||
#define FACING_SAME_DIR 1
|
||||
@@ -308,12 +294,6 @@
|
||||
#define RADIO_CONNECTION_FAIL 0
|
||||
#define RADIO_CONNECTION_NON_SUBSPACE 1
|
||||
|
||||
//Fire stuff, for burn_state
|
||||
#define LAVA_PROOF -2
|
||||
#define FIRE_PROOF -1
|
||||
#define FLAMMABLE 0
|
||||
#define ON_FIRE 1
|
||||
|
||||
// Bluespace shelter deploy checks
|
||||
#define SHELTER_DEPLOY_ALLOWED "allowed"
|
||||
#define SHELTER_DEPLOY_BAD_TURFS "bad turfs"
|
||||
@@ -361,5 +341,8 @@
|
||||
#define BLOOD_STATE_XENO "xeno"
|
||||
#define BLOOD_STATE_NOT_BLOODY "no blood whatsoever"
|
||||
|
||||
//for obj explosion block calculation
|
||||
#define EXPLOSION_BLOCK_PROC -1
|
||||
|
||||
// The SQL version required by this version of the code
|
||||
#define SQL_VERSION 1
|
||||
#define SQL_VERSION 2
|
||||
|
||||
@@ -107,6 +107,12 @@
|
||||
#define AI_CHECK_WIRELESS 1
|
||||
#define AI_CHECK_RADIO 2
|
||||
|
||||
//determines if a mob can smash through it
|
||||
#define ENVIRONMENT_SMASH_NONE 0
|
||||
#define ENVIRONMENT_SMASH_STRUCTURES 1 //crates, lockers, ect
|
||||
#define ENVIRONMENT_SMASH_WALLS 2 //walls
|
||||
#define ENVIRONMENT_SMASH_RWALLS 4 //rwalls
|
||||
|
||||
#define POCKET_STRIP_DELAY 40 //time taken (in deciseconds) to search somebody's pockets
|
||||
|
||||
#define DEFAULT_ITEM_STRIP_DELAY 40 //time taken (in deciseconds) to strip somebody
|
||||
@@ -120,6 +126,7 @@
|
||||
|
||||
#define TINT_IMPAIR 2 //Threshold of tint level to apply weld mask overlay
|
||||
#define TINT_BLIND 3 //Threshold of tint level to obscure vision fully
|
||||
#define EYE_SHINE_THRESHOLD 6 //dark_view threshold past which a humanoid's eyes will 'shine' in the dark.
|
||||
|
||||
#define isliving(A) (istype((A), /mob/living))
|
||||
#define iscarbon(A) (istype((A), /mob/living/carbon))
|
||||
@@ -171,6 +178,3 @@
|
||||
#define hasorgans(A) (ishuman(A))
|
||||
|
||||
#define is_admin(user) (check_rights(R_ADMIN, 0, (user)) != 0)
|
||||
|
||||
//effects
|
||||
#define EFFECT_HIGHFIVE "highfiving"
|
||||
@@ -31,4 +31,4 @@
|
||||
if(##VARNAME == src)\
|
||||
##VARNAME = null;\
|
||||
else\
|
||||
message_admins("Controller '[name]' asked to release global control in spite of not having it!");}\
|
||||
message_admins("Controller '[name]' asked to release global control in spite of not having it!");}
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
#define CHANNEL_LOBBYMUSIC 1024
|
||||
#define CHANNEL_ADMIN 1023
|
||||
#define CHANNEL_VOX 1022
|
||||
#define CHANNEL_HEARTBEAT 1021 //sound channel for heartbeats
|
||||
#define CHANNEL_BUZZ 1020
|
||||
#define CHANNEL_AMBIENCE 1019
|
||||
#define CHANNEL_JUKEBOX 1021
|
||||
#define CHANNEL_HEARTBEAT 1020 //sound channel for heartbeats
|
||||
#define CHANNEL_BUZZ 1019
|
||||
#define CHANNEL_AMBIENCE 1018
|
||||
|
||||
//THIS SHOULD ALWAYS BE THE LOWEST ONE!
|
||||
//KEEP IT UPDATED
|
||||
|
||||
#define CHANNEL_HIGHEST_AVAILABLE 1018
|
||||
#define CHANNEL_HIGHEST_AVAILABLE 1017
|
||||
|
||||
|
||||
#define SOUND_MINIMUM_PRESSURE 10
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
//These are all the different status effects. Use the paths for each effect in the defines.
|
||||
|
||||
#define STATUS_EFFECT_MULTIPLE 0 //if it allows multiple instances of the effect
|
||||
|
||||
#define STATUS_EFFECT_UNIQUE 1 //if it allows only one, preventing new instances
|
||||
|
||||
#define STATUS_EFFECT_REPLACE 2 //if it allows only one, but new instances replace
|
||||
|
||||
#define BASIC_STATUS_EFFECT /datum/status_effect //Has no effect.
|
||||
|
||||
///////////
|
||||
// BUFFS //
|
||||
///////////
|
||||
|
||||
#define STATUS_EFFECT_SHADOW_MEND /datum/status_effect/shadow_mend //Quick, powerful heal that deals damage afterwards. Heals 15 brute/burn every second for 3 seconds.
|
||||
#define STATUS_EFFECT_VOID_PRICE /datum/status_effect/void_price //The price of healing yourself with void energy. Deals 3 brute damage every 3 seconds for 30 seconds.
|
||||
|
||||
//#define STATUS_EFFECT_VANGUARD /datum/status_effect/vanguard_shield //Grants temporary stun absorption, but will stun the user based on how many stuns they absorbed.
|
||||
//#define STATUS_EFFECT_INATHNEQS_ENDOWMENT /datum/status_effect/inathneqs_endowment //A 15-second invulnerability and stun absorption, granted by Inath-neq.
|
||||
//#define STATUS_EFFECT_WRAITHSPECS /datum/status_effect/wraith_spectacles
|
||||
|
||||
//#define STATUS_EFFECT_POWERREGEN /datum/status_effect/cyborg_power_regen //Regenerates power on a given cyborg over time
|
||||
|
||||
//#define STATUS_EFFECT_HISGRACE /datum/status_effect/his_grace //His Grace.
|
||||
|
||||
//#define STATUS_EFFECT_WISH_GRANTERS_GIFT /datum/status_effect/wish_granters_gift //If you're currently resurrecting with the Wish Granter
|
||||
|
||||
//#define STATUS_EFFECT_BLOODDRUNK /datum/status_effect/blooddrunk //Stun immunity and greatly reduced damage taken
|
||||
|
||||
/////////////
|
||||
// DEBUFFS //
|
||||
/////////////
|
||||
|
||||
//#define STATUS_EFFECT_STUN /datum/status_effect/incapacitating/stun //the affected is stunned
|
||||
|
||||
//#define STATUS_EFFECT_KNOCKDOWN /datum/status_effect/incapacitating/knockdown //the affected is knocked down
|
||||
|
||||
//#define STATUS_EFFECT_UNCONSCIOUS /datum/status_effect/incapacitating/unconscious //the affected is unconscious
|
||||
|
||||
//#define STATUS_EFFECT_SLEEPING /datum/status_effect/incapacitating/sleeping //the affected is asleep
|
||||
|
||||
//#define STATUS_EFFECT_BELLIGERENT /datum/status_effect/belligerent //forces the affected to walk, doing damage if they try to run
|
||||
|
||||
//#define STATUS_EFFECT_GEISTRACKER /datum/status_effect/geis_tracker //if you're using geis, this tracks that and keeps you from using scripture
|
||||
|
||||
//#define STATUS_EFFECT_MANIAMOTOR /datum/status_effect/maniamotor //disrupts, damages, and confuses the affected as long as they're in range of the motor
|
||||
//#define MAX_MANIA_SEVERITY 100 //how high the mania severity can go
|
||||
//#define MANIA_DAMAGE_TO_CONVERT 90 //how much damage is required before it'll convert affected targets
|
||||
|
||||
//#define STATUS_EFFECT_HISWRATH /datum/status_effect/his_wrath //His Wrath.
|
||||
|
||||
#define STATUS_EFFECT_SUMMONEDGHOST /datum/status_effect/cultghost //is a cult ghost and can't use manifest runes
|
||||
|
||||
//#define STATUS_EFFECT_CRUSHERMARK /datum/status_effect/crusher_mark //if struck with a proto-kinetic crusher, takes a ton of damage
|
||||
|
||||
//#define STATUS_EFFECT_SAWBLEED /datum/status_effect/saw_bleed //if the bleed builds up enough, takes a ton of damage
|
||||
|
||||
//#define STATUS_EFFECT_NECROPOLIS_CURSE /datum/status_effect/necropolis_curse
|
||||
//#define CURSE_BLINDING 1 //makes the edges of the target's screen obscured
|
||||
//#define CURSE_SPAWNING 2 //spawns creatures that attack the target only
|
||||
//#define CURSE_WASTING 4 //causes gradual damage
|
||||
//#define CURSE_GRASPING 8 //hands reach out from the sides of the screen, doing damage and stunning if they hit the target
|
||||
|
||||
//#define STATUS_EFFECT_KINDLE /datum/status_effect/kindle //A knockdown reduced by 1 second for every 3 points of damage the target takes.
|
||||
|
||||
//#define STATUS_EFFECT_ICHORIAL_STAIN /datum/status_effect/ichorial_stain //Prevents a servant from being revived by vitality matrices for one minute.
|
||||
|
||||
/////////////
|
||||
// NEUTRAL //
|
||||
/////////////
|
||||
|
||||
#define STATUS_EFFECT_HIGHFIVE /datum/status_effect/high_five
|
||||
|
||||
//#define STATUS_EFFECT_SIGILMARK /datum/status_effect/sigil_mark
|
||||
|
||||
//#define STATUS_EFFECT_CRUSHERDAMAGETRACKING /datum/status_effect/crusher_damage //tracks total kinetic crusher damage on a target
|
||||
|
||||
//#define STATUS_EFFECT_SYPHONMARK /datum/status_effect/syphon_mark //tracks kills for the KA death syphon module
|
||||
@@ -0,0 +1,116 @@
|
||||
//Timing subsystem
|
||||
//Don't run if there is an identical unique timer active
|
||||
//if the arguments to addtimer are the same as an existing timer, it doesn't create a new timer, and returns the id of the existing timer
|
||||
#define TIMER_UNIQUE 1
|
||||
//For unique timers: Replace the old timer rather then not start this one
|
||||
#define TIMER_OVERRIDE 2
|
||||
//Timing should be based on how timing progresses on clients, not the sever.
|
||||
// tracking this is more expensive,
|
||||
// should only be used in conjuction with things that have to progress client side, such as animate() or sound()
|
||||
#define TIMER_CLIENT_TIME 4
|
||||
//Timer can be stopped using deltimer()
|
||||
#define TIMER_STOPPABLE 8
|
||||
//To be used with TIMER_UNIQUE
|
||||
//prevents distinguishing identical timers with the wait variable
|
||||
#define TIMER_NO_HASH_WAIT 16
|
||||
|
||||
#define TIMER_NO_INVOKE_WARNING 600 //number of byond ticks that are allowed to pass before the timer subsystem thinks it hung on something
|
||||
|
||||
#define TIMER_ID_NULL -1
|
||||
|
||||
//For servers that can't do with any additional lag, set this to none in flightpacks.dm in subsystem/processing.
|
||||
#define FLIGHTSUIT_PROCESSING_NONE 0
|
||||
#define FLIGHTSUIT_PROCESSING_FULL 1
|
||||
|
||||
#define INITIALIZATION_INSSATOMS 0 //New should not call Initialize
|
||||
#define INITIALIZATION_INNEW_MAPLOAD 2 //New should call Initialize(TRUE)
|
||||
#define INITIALIZATION_INNEW_REGULAR 1 //New should call Initialize(FALSE)
|
||||
|
||||
#define INITIALIZE_HINT_NORMAL 0 //Nothing happens
|
||||
#define INITIALIZE_HINT_LATELOAD 1 //Call LateInitialize
|
||||
#define INITIALIZE_HINT_QDEL 2 //Call qdel on the atom
|
||||
|
||||
//type and all subtypes should always call Initialize in New()
|
||||
#define INITIALIZE_IMMEDIATE(X) ##X/New(loc, ...){\
|
||||
..();\
|
||||
if(!initialized) {\
|
||||
args[1] = TRUE;\
|
||||
SSatoms.InitAtom(src, args);\
|
||||
}\
|
||||
}
|
||||
|
||||
// Subsystem init_order, from highest priority to lowest priority
|
||||
// Subsystems shutdown in the reverse of the order they initialize in
|
||||
// The numbers just define the ordering, they are meaningless otherwise.
|
||||
|
||||
#define INIT_ORDER_GARBAGE 19
|
||||
#define INIT_ORDER_DBCORE 18
|
||||
#define INIT_ORDER_BLACKBOX 17
|
||||
#define INIT_ORDER_SERVER_MAINT 16
|
||||
#define INIT_ORDER_INPUT 15
|
||||
#define INIT_ORDER_RESEARCH 14
|
||||
#define INIT_ORDER_EVENTS 13
|
||||
#define INIT_ORDER_JOBS 12
|
||||
#define INIT_ORDER_TRAITS 11
|
||||
#define INIT_ORDER_TICKER 10
|
||||
#define INIT_ORDER_MAPPING 9
|
||||
#define INIT_ORDER_NETWORKS 8
|
||||
#define INIT_ORDER_ATOMS 7
|
||||
#define INIT_ORDER_LANGUAGE 6
|
||||
#define INIT_ORDER_MACHINES 5
|
||||
#define INIT_ORDER_CIRCUIT 4
|
||||
#define INIT_ORDER_TIMER 1
|
||||
#define INIT_ORDER_DEFAULT 0
|
||||
#define INIT_ORDER_AIR -1
|
||||
#define INIT_ORDER_MINIMAP -3
|
||||
#define INIT_ORDER_ASSETS -4
|
||||
#define INIT_ORDER_ICON_SMOOTHING -5
|
||||
#define INIT_ORDER_OVERLAY -6
|
||||
#define INIT_ORDER_XKEYSCORE -10
|
||||
#define INIT_ORDER_STICKY_BAN -10
|
||||
#define INIT_ORDER_LIGHTING -20
|
||||
#define INIT_ORDER_SHUTTLE -21
|
||||
#define INIT_ORDER_SQUEAK -40
|
||||
#define INIT_ORDER_PATH -50
|
||||
#define INIT_ORDER_PERSISTENCE -100
|
||||
|
||||
// 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_IDLE_NPC 10
|
||||
#define FIRE_PRIORITY_SERVER_MAINT 10
|
||||
#define FIRE_PRIORITY_RESEARCH 10
|
||||
#define FIRE_PRIORITY_GARBAGE 15
|
||||
#define FIRE_PRIORITY_WET_FLOORS 20
|
||||
#define FIRE_PRIORITY_AIR 20
|
||||
#define FIRE_PRIORITY_NPC 20
|
||||
#define FIRE_PRIORITY_PROCESS 25
|
||||
#define FIRE_PRIORITY_THROWING 25
|
||||
#define FIRE_PRIORITY_SPACEDRIFT 30
|
||||
#define FIRE_PRIORITY_FIELDS 30
|
||||
#define FIRE_PRIOTITY_SMOOTHING 35
|
||||
#define FIRE_PRIORITY_ORBIT 35
|
||||
#define FIRE_PRIORITY_NETWORKS 40
|
||||
#define FIRE_PRIORITY_OBJ 40
|
||||
#define FIRE_PRIORITY_ACID 40
|
||||
#define FIRE_PRIOTITY_BURNING 40
|
||||
#define FIRE_PRIORITY_INBOUNDS 40
|
||||
#define FIRE_PRIORITY_DEFAULT 50
|
||||
#define FIRE_PRIORITY_PARALLAX 65
|
||||
#define FIRE_PRIORITY_FLIGHTPACKS 80
|
||||
#define FIRE_PRIORITY_MOBS 100
|
||||
#define FIRE_PRIORITY_NANOUI 110
|
||||
#define FIRE_PRIORITY_TICKER 200
|
||||
#define FIRE_PRIORITY_OVERLAYS 500
|
||||
#define FIRE_PRIORITY_INPUT 1000 // This must always always be the max highest priority. Player input must never be lost.
|
||||
|
||||
|
||||
// SS runlevels
|
||||
|
||||
#define RUNLEVEL_INIT 0
|
||||
#define RUNLEVEL_LOBBY 1
|
||||
#define RUNLEVEL_SETUP 2
|
||||
#define RUNLEVEL_GAME 4
|
||||
#define RUNLEVEL_POSTGAME 8
|
||||
|
||||
#define RUNLEVELS_DEFAULT (RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME)
|
||||
@@ -1,5 +1,10 @@
|
||||
#define TICK_LIMIT_RUNNING 90
|
||||
#define TICK_LIMIT_TO_RUN 85
|
||||
#define TICK_LIMIT_RUNNING 80
|
||||
#define TICK_LIMIT_TO_RUN 70
|
||||
#define TICK_LIMIT_MC 70
|
||||
#define TICK_LIMIT_MC_INIT_DEFAULT 98
|
||||
|
||||
#define TICK_USAGE world.tick_usage //for general usage
|
||||
#define TICK_USAGE_REAL world.tick_usage //to be used where the result isn't checked
|
||||
|
||||
#define TICK_CHECK ( world.tick_usage > TICK_LIMIT_RUNNING ? stoplag() : 0 )
|
||||
#define CHECK_TICK if(world.tick_usage > TICK_LIMIT_RUNNING) stoplag()
|
||||
@@ -0,0 +1,38 @@
|
||||
/proc/cmp_numeric_dsc(a,b)
|
||||
return b - a
|
||||
|
||||
/proc/cmp_numeric_asc(a,b)
|
||||
return a - b
|
||||
|
||||
/proc/cmp_text_asc(a,b)
|
||||
return sorttext(b,a)
|
||||
|
||||
/proc/cmp_text_dsc(a,b)
|
||||
return sorttext(a,b)
|
||||
|
||||
/proc/cmp_name_asc(atom/a, atom/b)
|
||||
return sorttext(b.name, a.name)
|
||||
|
||||
/proc/cmp_name_dsc(atom/a, atom/b)
|
||||
return sorttext(a.name, b.name)
|
||||
|
||||
/proc/cmp_ckey_asc(client/a, client/b)
|
||||
return sorttext(b.ckey, a.ckey)
|
||||
|
||||
/proc/cmp_ckey_dsc(client/a, client/b)
|
||||
return sorttext(a.ckey, b.ckey)
|
||||
|
||||
/proc/cmp_subsystem_init(datum/controller/subsystem/a, datum/controller/subsystem/b)
|
||||
return initial(b.init_order) - initial(a.init_order) //uses initial() so it can be used on types
|
||||
|
||||
/proc/cmp_subsystem_display(datum/controller/subsystem/a, datum/controller/subsystem/b)
|
||||
return sorttext(b.name, a.name)
|
||||
|
||||
/proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b)
|
||||
return a.priority - b.priority
|
||||
|
||||
/proc/cmp_atom_layer_asc(atom/A,atom/B)
|
||||
if(A.plane != B.plane)
|
||||
return A.plane - B.plane
|
||||
else
|
||||
return A.layer - B.layer
|
||||
@@ -897,3 +897,12 @@ proc/rand_hex_color()
|
||||
for(var/i=0;i<6;i++)
|
||||
color = color+pick(colors)
|
||||
return "#[color]"
|
||||
|
||||
//Imagine removing pixels from the main icon that are covered by pixels from the mask icon.
|
||||
proc/get_icon_difference(var/icon/main, var/icon/mask)
|
||||
if(istype(main) && istype(mask))
|
||||
mask.Blend(rgb(255,255,255), ICON_SUBTRACT) //Make all pixels on the mask as black as possible.
|
||||
mask.Opaque(rgb(255,255,255)) //Make the transparent pixels (background) white.
|
||||
mask.BecomeAlphaMask() //Make all the black pixels vanish (fully transparent), leaving only the white pixels.
|
||||
main.AddAlphaMask(mask) //Make the pixels in the main icon that are in the transparent zone of the mask icon also vanish (fully transparent).
|
||||
return main
|
||||
|
||||
+81
-1
@@ -678,4 +678,84 @@ proc/dd_sortedObjectList(list/incoming)
|
||||
if(isnum(key))
|
||||
L |= key
|
||||
else
|
||||
L[key] = temp[key]
|
||||
L[key] = temp[key]
|
||||
|
||||
//Move a single element from position fromIndex within a list, to position toIndex
|
||||
//All elements in the range [1,toIndex) before the move will be before the pivot afterwards
|
||||
//All elements in the range [toIndex, L.len+1) before the move will be after the pivot afterwards
|
||||
//In other words, it's as if the range [fromIndex,toIndex) have been rotated using a <<< operation common to other languages.
|
||||
//fromIndex and toIndex must be in the range [1,L.len+1]
|
||||
//This will preserve associations ~Carnie
|
||||
/proc/moveElement(list/L, fromIndex, toIndex)
|
||||
if(fromIndex == toIndex || fromIndex + 1 == toIndex) //no need to move
|
||||
return
|
||||
if(fromIndex > toIndex)
|
||||
++fromIndex //since a null will be inserted before fromIndex, the index needs to be nudged right by one
|
||||
|
||||
L.Insert(toIndex, null)
|
||||
L.Swap(fromIndex, toIndex)
|
||||
L.Cut(fromIndex, fromIndex + 1)
|
||||
|
||||
|
||||
//Move elements [fromIndex,fromIndex+len) to [toIndex-len, toIndex)
|
||||
//Same as moveElement but for ranges of elements
|
||||
//This will preserve associations ~Carnie
|
||||
/proc/moveRange(list/L, fromIndex, toIndex, len = 1)
|
||||
var/distance = abs(toIndex - fromIndex)
|
||||
if(len >= distance) //there are more elements to be moved than the distance to be moved. Therefore the same result can be achieved (with fewer operations) by moving elements between where we are and where we are going. The result being, our range we are moving is shifted left or right by dist elements
|
||||
if(fromIndex <= toIndex)
|
||||
return //no need to move
|
||||
fromIndex += len //we want to shift left instead of right
|
||||
|
||||
for(var/i = 0, i < distance, ++i)
|
||||
L.Insert(fromIndex, null)
|
||||
L.Swap(fromIndex, toIndex)
|
||||
L.Cut(toIndex, toIndex + 1)
|
||||
else
|
||||
if(fromIndex > toIndex)
|
||||
fromIndex += len
|
||||
|
||||
for(var/i = 0, i < len, ++i)
|
||||
L.Insert(toIndex, null)
|
||||
L.Swap(fromIndex, toIndex)
|
||||
L.Cut(fromIndex, fromIndex + 1)
|
||||
|
||||
//Move elements from [fromIndex, fromIndex+len) to [toIndex, toIndex+len)
|
||||
//Move any elements being overwritten by the move to the now-empty elements, preserving order
|
||||
//Note: if the two ranges overlap, only the destination order will be preserved fully, since some elements will be within both ranges ~Carnie
|
||||
/proc/swapRange(list/L, fromIndex, toIndex, len = 1)
|
||||
var/distance = abs(toIndex - fromIndex)
|
||||
if(len > distance) //there is an overlap, therefore swapping each element will require more swaps than inserting new elements
|
||||
if(fromIndex < toIndex)
|
||||
toIndex += len
|
||||
else
|
||||
fromIndex += len
|
||||
|
||||
for(var/i = 0, i < distance, ++i)
|
||||
L.Insert(fromIndex, null)
|
||||
L.Swap(fromIndex, toIndex)
|
||||
L.Cut(toIndex, toIndex + 1)
|
||||
else
|
||||
if(toIndex > fromIndex)
|
||||
var/a = toIndex
|
||||
toIndex = fromIndex
|
||||
fromIndex = a
|
||||
|
||||
for(var/i = 0, i < len, ++i)
|
||||
L.Swap(fromIndex++, toIndex++)
|
||||
|
||||
//replaces reverseList ~Carnie
|
||||
/proc/reverseRange(list/L, start = 1, end = 0)
|
||||
if(L.len)
|
||||
start = start % L.len
|
||||
end = end % (L.len + 1)
|
||||
if(start <= 0)
|
||||
start += L.len
|
||||
if(end <= 0)
|
||||
end += L.len + 1
|
||||
|
||||
--end
|
||||
while(start < end)
|
||||
L.Swap(start++, end--)
|
||||
|
||||
return L
|
||||
@@ -116,3 +116,8 @@ var/gaussian_next
|
||||
if(num < 0)
|
||||
return 0
|
||||
return sqrt(num)
|
||||
|
||||
/proc/round_down(num)
|
||||
if(round(num) != num)
|
||||
return round(num--)
|
||||
else return num
|
||||
+17
-4
@@ -268,7 +268,7 @@ proc/add_logs(mob/user, mob/target, what_done, var/object=null, var/addition=nul
|
||||
return
|
||||
msg_admin_attack("[key_name_admin(user)] [what_done] [key_name_admin(target)][object ? " with [object]" : " "][addition]")
|
||||
|
||||
/proc/do_mob(var/mob/user, var/mob/target, var/time = 30, var/uninterruptible = 0, progress = 1)
|
||||
/proc/do_mob(var/mob/user, var/mob/target, var/time = 30, var/uninterruptible = 0, progress = 1, datum/callback/extra_checks = null)
|
||||
if(!user || !target)
|
||||
return 0
|
||||
var/user_loc = user.loc
|
||||
@@ -301,13 +301,13 @@ proc/add_logs(mob/user, mob/target, what_done, var/object=null, var/addition=nul
|
||||
drifting = 0
|
||||
user_loc = user.loc
|
||||
|
||||
if((!drifting && user.loc != user_loc) || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying )
|
||||
if((!drifting && user.loc != user_loc) || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying || (extra_checks && !extra_checks.Invoke()))
|
||||
. = 0
|
||||
break
|
||||
if(progress)
|
||||
qdel(progbar)
|
||||
|
||||
/proc/do_after(mob/user, delay, needhand = 1, atom/target = null, progress = 1)
|
||||
/proc/do_after(mob/user, delay, needhand = 1, atom/target = null, progress = 1, datum/callback/extra_checks = null)
|
||||
if(!user)
|
||||
return 0
|
||||
var/atom/Tloc = null
|
||||
@@ -342,7 +342,7 @@ proc/add_logs(mob/user, mob/target, what_done, var/object=null, var/addition=nul
|
||||
drifting = 0
|
||||
Uloc = user.loc
|
||||
|
||||
if(!user || user.stat || user.weakened || user.stunned || (!drifting && user.loc != Uloc))
|
||||
if(!user || user.stat || user.weakened || user.stunned || (!drifting && user.loc != Uloc)|| (extra_checks && !extra_checks.Invoke()))
|
||||
. = 0
|
||||
break
|
||||
|
||||
@@ -370,6 +370,19 @@ proc/add_logs(mob/user, mob/target, what_done, var/object=null, var/addition=nul
|
||||
if(H.get_species() == species_name)
|
||||
. = TRUE
|
||||
|
||||
/proc/spawn_atom_to_turf(spawn_type, target, amount, admin_spawn=FALSE, list/extra_args)
|
||||
var/turf/T = get_turf(target)
|
||||
if(!T)
|
||||
CRASH("attempt to spawn atom type: [spawn_type] in nullspace")
|
||||
|
||||
var/list/new_args = list(T)
|
||||
if(extra_args)
|
||||
new_args += extra_args
|
||||
|
||||
for(var/j in 1 to amount)
|
||||
var/atom/X = new spawn_type(arglist(new_args))
|
||||
X.admin_spawned = admin_spawn
|
||||
|
||||
/proc/admin_mob_info(mob/M, mob/user = usr)
|
||||
if(!ismob(M))
|
||||
to_chat(user, "This can only be used on instances of type /mob")
|
||||
|
||||
+3
-37
@@ -17,19 +17,7 @@ var/church_name = null
|
||||
|
||||
var/command_name = null
|
||||
/proc/command_name()
|
||||
if(command_name)
|
||||
return command_name
|
||||
|
||||
var/name = "Central Command"
|
||||
|
||||
command_name = name
|
||||
return name
|
||||
|
||||
/proc/change_command_name(var/name)
|
||||
|
||||
command_name = name
|
||||
|
||||
return name
|
||||
return using_map.dock_name
|
||||
|
||||
var/religion_name = null
|
||||
/proc/religion_name()
|
||||
@@ -44,20 +32,10 @@ var/religion_name = null
|
||||
return capitalize(name)
|
||||
|
||||
/proc/system_name()
|
||||
return "Nyx"
|
||||
return using_map.starsys_name
|
||||
|
||||
/proc/station_name()
|
||||
if(station_name)
|
||||
return station_name
|
||||
|
||||
var/name = ""
|
||||
|
||||
if(config && config.server_name)
|
||||
world.name = "[config.server_name]: [name]"
|
||||
else
|
||||
world.name = station_name
|
||||
|
||||
return station_name
|
||||
return using_map.station_name
|
||||
|
||||
/proc/new_station_name()
|
||||
var/random = rand(1,5)
|
||||
@@ -102,18 +80,6 @@ var/religion_name = null
|
||||
new_station_name += pick("13","XIII","Thirteen")
|
||||
return new_station_name
|
||||
|
||||
|
||||
/proc/world_name(var/name)
|
||||
|
||||
station_name = name
|
||||
|
||||
if(config && config.server_name)
|
||||
world.name = "[config.server_name]: [name]"
|
||||
else
|
||||
world.name = name
|
||||
|
||||
return name
|
||||
|
||||
var/syndicate_name = null
|
||||
/proc/syndicate_name()
|
||||
if(syndicate_name)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//simple insertion sort - generally faster than merge for runs of 7 or smaller
|
||||
/proc/sortInsert(list/L, cmp = /proc/cmp_numeric_asc, associative, fromIndex = 1, toIndex = 0)
|
||||
if(L && L.len >= 2)
|
||||
fromIndex = fromIndex % L.len
|
||||
toIndex = toIndex % (L.len + 1)
|
||||
if(fromIndex <= 0)
|
||||
fromIndex += L.len
|
||||
if(toIndex <= 0)
|
||||
toIndex += L.len + 1
|
||||
|
||||
var/datum/sortInstance/SI = GLOB.sortInstance
|
||||
if(!SI)
|
||||
SI = new
|
||||
SI.L = L
|
||||
SI.cmp = cmp
|
||||
SI.associative = associative
|
||||
|
||||
SI.binarySort(fromIndex, toIndex, fromIndex)
|
||||
return L
|
||||
@@ -0,0 +1,19 @@
|
||||
//merge-sort - gernerally faster than insert sort, for runs of 7 or larger
|
||||
/proc/sortMerge(list/L, cmp = /proc/cmp_numeric_asc, associative, fromIndex = 1, toIndex)
|
||||
if(L && L.len >= 2)
|
||||
fromIndex = fromIndex % L.len
|
||||
toIndex = toIndex % (L.len + 1)
|
||||
if(fromIndex <= 0)
|
||||
fromIndex += L.len
|
||||
if(toIndex <= 0)
|
||||
toIndex += L.len + 1
|
||||
|
||||
var/datum/sortInstance/SI = GLOB.sortInstance
|
||||
if(!SI)
|
||||
SI = new
|
||||
SI.L = L
|
||||
SI.cmp = cmp
|
||||
SI.associative = associative
|
||||
|
||||
SI.mergeSort(fromIndex, toIndex)
|
||||
return L
|
||||
@@ -0,0 +1,20 @@
|
||||
//TimSort interface
|
||||
/proc/sortTim(list/L, cmp = /proc/cmp_numeric_asc, associative, fromIndex = 1, toIndex = 0)
|
||||
if(L && L.len >= 2)
|
||||
fromIndex = fromIndex % L.len
|
||||
toIndex = toIndex % (L.len + 1)
|
||||
if(fromIndex <= 0)
|
||||
fromIndex += L.len
|
||||
if(toIndex <= 0)
|
||||
toIndex += L.len + 1
|
||||
|
||||
var/datum/sortInstance/SI = GLOB.sortInstance
|
||||
if(!SI)
|
||||
SI = new
|
||||
|
||||
SI.L = L
|
||||
SI.cmp = cmp
|
||||
SI.associative = associative
|
||||
|
||||
SI.timSort(fromIndex, toIndex)
|
||||
return L
|
||||
@@ -0,0 +1,647 @@
|
||||
//These are macros used to reduce on proc calls
|
||||
#define fetchElement(L, i) (associative) ? L[L[i]] : L[i]
|
||||
|
||||
//Minimum sized sequence that will be merged. Anything smaller than this will use binary-insertion sort.
|
||||
//Should be a power of 2
|
||||
#define MIN_MERGE 32
|
||||
|
||||
//When we get into galloping mode, we stay there until both runs win less often than MIN_GALLOP consecutive times.
|
||||
#define MIN_GALLOP 7
|
||||
|
||||
//This is a global instance to allow much of this code to be reused. The interfaces are kept separately
|
||||
GLOBAL_DATUM_INIT(sortInstance, /datum/sortInstance, new())
|
||||
/datum/sortInstance
|
||||
//The array being sorted.
|
||||
var/list/L
|
||||
|
||||
//The comparator proc-reference
|
||||
var/cmp = /proc/cmp_numeric_asc
|
||||
|
||||
//whether we are sorting list keys (0: L[i]) or associated values (1: L[L[i]])
|
||||
var/associative = 0
|
||||
|
||||
//This controls when we get *into* galloping mode. It is initialized to MIN_GALLOP.
|
||||
//The mergeLo and mergeHi methods nudge it higher for random data, and lower for highly structured data.
|
||||
var/minGallop = MIN_GALLOP
|
||||
|
||||
//Stores information regarding runs yet to be merged.
|
||||
//Run i starts at runBase[i] and extends for runLen[i] elements.
|
||||
//runBase[i] + runLen[i] == runBase[i+1]
|
||||
var/list/runBases = list()
|
||||
var/list/runLens = list()
|
||||
|
||||
|
||||
/datum/sortInstance/proc/timSort(start, end)
|
||||
runBases.Cut()
|
||||
runLens.Cut()
|
||||
|
||||
var/remaining = end - start
|
||||
|
||||
//If array is small, do a 'mini-TimSort' with no merges
|
||||
if(remaining < MIN_MERGE)
|
||||
var/initRunLen = countRunAndMakeAscending(start, end)
|
||||
binarySort(start, end, start + initRunLen)
|
||||
return
|
||||
|
||||
//March over the array finding natural runs
|
||||
//Extend any short natural runs to runs of length minRun
|
||||
var/minRun = minRunLength(remaining)
|
||||
|
||||
do
|
||||
//identify next run
|
||||
var/runLen = countRunAndMakeAscending(start, end)
|
||||
|
||||
//if run is short, extend to min(minRun, remaining)
|
||||
if(runLen < minRun)
|
||||
var/force = (remaining <= minRun) ? remaining : minRun
|
||||
|
||||
binarySort(start, start + force, start+runLen)
|
||||
runLen = force
|
||||
|
||||
//add data about run to queue
|
||||
runBases.Add(start)
|
||||
runLens.Add(runLen)
|
||||
|
||||
//maybe merge
|
||||
mergeCollapse()
|
||||
|
||||
//Advance to find next run
|
||||
start += runLen
|
||||
remaining -= runLen
|
||||
|
||||
while(remaining > 0)
|
||||
|
||||
|
||||
//Merge all remaining runs to complete sort
|
||||
//ASSERT(start == end)
|
||||
mergeForceCollapse();
|
||||
//ASSERT(runBases.len == 1)
|
||||
|
||||
//reset minGallop, for successive calls
|
||||
minGallop = MIN_GALLOP
|
||||
|
||||
return L
|
||||
|
||||
/*
|
||||
Sorts the specified portion of the specified array using a binary
|
||||
insertion sort. This is the best method for sorting small numbers
|
||||
of elements. It requires O(n log n) compares, but O(n^2) data
|
||||
movement (worst case).
|
||||
|
||||
If the initial part of the specified range is already sorted,
|
||||
this method can take advantage of it: the method assumes that the
|
||||
elements in range [lo,start) are already sorted
|
||||
|
||||
lo the index of the first element in the range to be sorted
|
||||
hi the index after the last element in the range to be sorted
|
||||
start the index of the first element in the range that is not already known to be sorted
|
||||
*/
|
||||
/datum/sortInstance/proc/binarySort(lo, hi, start)
|
||||
//ASSERT(lo <= start && start <= hi)
|
||||
if(start <= lo)
|
||||
start = lo + 1
|
||||
|
||||
for(,start < hi, ++start)
|
||||
var/pivot = fetchElement(L,start)
|
||||
|
||||
//set left and right to the index where pivot belongs
|
||||
var/left = lo
|
||||
var/right = start
|
||||
//ASSERT(left <= right)
|
||||
|
||||
//[lo, left) elements <= pivot < [right, start) elements
|
||||
//in other words, find where the pivot element should go using bisection search
|
||||
while(left < right)
|
||||
var/mid = (left + right) >> 1 //round((left+right)/2)
|
||||
if(call(cmp)(fetchElement(L, mid), pivot) > 0)
|
||||
right = mid
|
||||
else
|
||||
left = mid + 1
|
||||
|
||||
//ASSERT(left == right)
|
||||
moveElement(L, start, left) //move pivot element to correct location in the sorted range
|
||||
|
||||
/*
|
||||
Returns the length of the run beginning at the specified position and reverses the run if it is back-to-front
|
||||
|
||||
A run is the longest ascending sequence with:
|
||||
a[lo] <= a[lo + 1] <= a[lo + 2] <= ...
|
||||
or the longest descending sequence with:
|
||||
a[lo] > a[lo + 1] > a[lo + 2] > ...
|
||||
|
||||
For its intended use in a stable mergesort, the strictness of the
|
||||
definition of "descending" is needed so that the call can safely
|
||||
reverse a descending sequence without violating stability.
|
||||
*/
|
||||
/datum/sortInstance/proc/countRunAndMakeAscending(lo, hi)
|
||||
//ASSERT(lo < hi)
|
||||
|
||||
var/runHi = lo + 1
|
||||
if(runHi >= hi)
|
||||
return 1
|
||||
|
||||
var/last = fetchElement(L, lo)
|
||||
var/current = fetchElement(L, runHi++)
|
||||
|
||||
if(call(cmp)(current, last) < 0)
|
||||
while(runHi < hi)
|
||||
last = current
|
||||
current = fetchElement(L,runHi)
|
||||
if(call(cmp)(current, last) >= 0)
|
||||
break
|
||||
++runHi
|
||||
reverseRange(L, lo, runHi)
|
||||
else
|
||||
while(runHi < hi)
|
||||
last = current
|
||||
current = fetchElement(L,runHi)
|
||||
if(call(cmp)(current, last) < 0)
|
||||
break
|
||||
++runHi
|
||||
|
||||
return runHi - lo
|
||||
|
||||
//Returns the minimum acceptable run length for an array of the specified length.
|
||||
//Natural runs shorter than this will be extended with binarySort
|
||||
/datum/sortInstance/proc/minRunLength(n)
|
||||
//ASSERT(n >= 0)
|
||||
var/r = 0 //becomes 1 if any bits are shifted off
|
||||
while(n >= MIN_MERGE)
|
||||
r |= (n & 1)
|
||||
n >>= 1
|
||||
return n + r
|
||||
|
||||
//Examines the stack of runs waiting to be merged and merges adjacent runs until the stack invariants are reestablished:
|
||||
// runLen[i-3] > runLen[i-2] + runLen[i-1]
|
||||
// runLen[i-2] > runLen[i-1]
|
||||
//This method is called each time a new run is pushed onto the stack.
|
||||
//So the invariants are guaranteed to hold for i<stackSize upon entry to the method
|
||||
/datum/sortInstance/proc/mergeCollapse()
|
||||
while(runBases.len >= 2)
|
||||
var/n = runBases.len - 1
|
||||
if(n > 1 && runLens[n - 1] <= runLens[n] + runLens[n + 1])
|
||||
if(runLens[n - 1] < runLens[n + 1])
|
||||
--n
|
||||
mergeAt(n)
|
||||
else if(runLens[n] <= runLens[n + 1])
|
||||
mergeAt(n)
|
||||
else
|
||||
break //Invariant is established
|
||||
|
||||
|
||||
//Merges all runs on the stack until only one remains.
|
||||
//Called only once, to finalise the sort
|
||||
/datum/sortInstance/proc/mergeForceCollapse()
|
||||
while(runBases.len >= 2)
|
||||
var/n = runBases.len - 1
|
||||
if(n > 1 && runLens[n - 1] < runLens[n + 1])
|
||||
--n
|
||||
mergeAt(n)
|
||||
|
||||
|
||||
//Merges the two consecutive runs at stack indices i and i+1
|
||||
//Run i must be the penultimate or antepenultimate run on the stack
|
||||
//In other words, i must be equal to stackSize-2 or stackSize-3
|
||||
/datum/sortInstance/proc/mergeAt(i)
|
||||
//ASSERT(runBases.len >= 2)
|
||||
//ASSERT(i >= 1)
|
||||
//ASSERT(i == runBases.len - 1 || i == runBases.len - 2)
|
||||
|
||||
var/base1 = runBases[i]
|
||||
var/base2 = runBases[i + 1]
|
||||
var/len1 = runLens[i]
|
||||
var/len2 = runLens[i + 1]
|
||||
|
||||
//ASSERT(len1 > 0 && len2 > 0)
|
||||
//ASSERT(base1 + len1 == base2)
|
||||
|
||||
//Record the legth of the combined runs. If i is the 3rd last run now, also slide over the last run
|
||||
//(which isn't involved in this merge). The current run (i+1) goes away in any case.
|
||||
runLens[i] += runLens[i + 1]
|
||||
runLens.Cut(i + 1, i + 2)
|
||||
runBases.Cut(i + 1, i + 2)
|
||||
|
||||
|
||||
//Find where the first element of run2 goes in run1.
|
||||
//Prior elements in run1 can be ignored (because they're already in place)
|
||||
var/k = gallopRight(fetchElement(L, base2), base1, len1, 0)
|
||||
//ASSERT(k >= 0)
|
||||
base1 += k
|
||||
len1 -= k
|
||||
if(len1 == 0)
|
||||
return
|
||||
|
||||
//Find where the last element of run1 goes in run2.
|
||||
//Subsequent elements in run2 can be ignored (because they're already in place)
|
||||
len2 = gallopLeft(fetchElement(L, base1 + len1 - 1), base2, len2, len2 - 1)
|
||||
//ASSERT(len2 >= 0)
|
||||
if(len2 == 0)
|
||||
return
|
||||
|
||||
//Merge remaining runs, using tmp array with min(len1, len2) elements
|
||||
if(len1 <= len2)
|
||||
mergeLo(base1, len1, base2, len2)
|
||||
else
|
||||
mergeHi(base1, len1, base2, len2)
|
||||
|
||||
|
||||
/*
|
||||
Locates the position to insert key within the specified sorted range
|
||||
If the range contains elements equal to key, this will return the index of the LEFTMOST of those elements
|
||||
|
||||
key the element to be inserted into the sorted range
|
||||
base the index of the first element of the sorted range
|
||||
len the length of the sorted range, must be greater than 0
|
||||
hint the offset from base at which to begin the search, such that 0 <= hint < len; i.e. base <= hint < base+hint
|
||||
|
||||
Returns the index at which to insert element 'key'
|
||||
*/
|
||||
/datum/sortInstance/proc/gallopLeft(key, base, len, hint)
|
||||
//ASSERT(len > 0 && hint >= 0 && hint < len)
|
||||
|
||||
var/lastOffset = 0
|
||||
var/offset = 1
|
||||
if(call(cmp)(key, fetchElement(L,base + hint)) > 0)
|
||||
var/maxOffset = len - hint
|
||||
while(offset < maxOffset && call(cmp)(key, fetchElement(L, base + hint + offset)) > 0)
|
||||
lastOffset = offset
|
||||
offset = (offset << 1) + 1
|
||||
|
||||
if(offset > maxOffset)
|
||||
offset = maxOffset
|
||||
|
||||
lastOffset += hint
|
||||
offset += hint
|
||||
|
||||
else
|
||||
var/maxOffset = hint + 1
|
||||
while(offset < maxOffset && call(cmp)(key, fetchElement(L, base + hint - offset)) <= 0)
|
||||
lastOffset = offset
|
||||
offset = (offset << 1) + 1
|
||||
|
||||
if(offset > maxOffset)
|
||||
offset = maxOffset
|
||||
|
||||
var/temp = lastOffset
|
||||
lastOffset = hint - offset
|
||||
offset = hint - temp
|
||||
|
||||
//ASSERT(-1 <= lastOffset && lastOffset < offset && offset <= len)
|
||||
|
||||
//Now L[base+lastOffset] < key <= L[base+offset], so key belongs somewhere to the right of lastOffset but no farther than
|
||||
//offset. Do a binary search with invariant L[base+lastOffset-1] < key <= L[base+offset]
|
||||
++lastOffset
|
||||
while(lastOffset < offset)
|
||||
var/m = lastOffset + ((offset - lastOffset) >> 1)
|
||||
|
||||
if(call(cmp)(key, fetchElement(L,base + m)) > 0)
|
||||
lastOffset = m + 1
|
||||
else
|
||||
offset = m
|
||||
|
||||
//ASSERT(lastOffset == offset)
|
||||
return offset
|
||||
|
||||
/**
|
||||
* Like gallopLeft, except that if the range contains an element equal to
|
||||
* key, gallopRight returns the index after the rightmost equal element.
|
||||
*
|
||||
* @param key the key whose insertion point to search for
|
||||
* @param a the array in which to search
|
||||
* @param base the index of the first element in the range
|
||||
* @param len the length of the range; must be > 0
|
||||
* @param hint the index at which to begin the search, 0 <= hint < n.
|
||||
* The closer hint is to the result, the faster this method will run.
|
||||
* @param c the comparator used to order the range, and to search
|
||||
* @return the int k, 0 <= k <= n such that a[b + k - 1] <= key < a[b + k]
|
||||
*/
|
||||
/datum/sortInstance/proc/gallopRight(key, base, len, hint)
|
||||
//ASSERT(len > 0 && hint >= 0 && hint < len)
|
||||
|
||||
var/offset = 1
|
||||
var/lastOffset = 0
|
||||
if(call(cmp)(key, fetchElement(L, base + hint)) < 0) //key <= L[base+hint]
|
||||
var/maxOffset = hint + 1 //therefore we want to insert somewhere in the range [base,base+hint] = [base+,base+(hint+1))
|
||||
while(offset < maxOffset && call(cmp)(key, fetchElement(L, base + hint - offset)) < 0) //we are iterating backwards
|
||||
lastOffset = offset
|
||||
offset = (offset << 1) + 1 //1 3 7 15
|
||||
|
||||
if(offset > maxOffset)
|
||||
offset = maxOffset
|
||||
|
||||
var/temp = lastOffset
|
||||
lastOffset = hint - offset
|
||||
offset = hint - temp
|
||||
|
||||
else //key > L[base+hint]
|
||||
var/maxOffset = len - hint //therefore we want to insert somewhere in the range (base+hint,base+len) = [base+hint+1, base+hint+(len-hint))
|
||||
while(offset < maxOffset && call(cmp)(key, fetchElement(L, base + hint + offset)) >= 0)
|
||||
lastOffset = offset
|
||||
offset = (offset << 1) + 1
|
||||
|
||||
if(offset > maxOffset)
|
||||
offset = maxOffset
|
||||
|
||||
lastOffset += hint
|
||||
offset += hint
|
||||
|
||||
//ASSERT(-1 <= lastOffset && lastOffset < offset && offset <= len)
|
||||
|
||||
++lastOffset
|
||||
while(lastOffset < offset)
|
||||
var/m = lastOffset + ((offset - lastOffset) >> 1)
|
||||
|
||||
if(call(cmp)(key, fetchElement(L, base + m)) < 0) //key <= L[base+m]
|
||||
offset = m
|
||||
else //key > L[base+m]
|
||||
lastOffset = m + 1
|
||||
|
||||
//ASSERT(lastOffset == offset)
|
||||
|
||||
return offset
|
||||
|
||||
|
||||
//Merges two adjacent runs in-place in a stable fashion.
|
||||
//For performance this method should only be called when len1 <= len2!
|
||||
/datum/sortInstance/proc/mergeLo(base1, len1, base2, len2)
|
||||
//ASSERT(len1 > 0 && len2 > 0 && base1 + len1 == base2)
|
||||
|
||||
var/cursor1 = base1
|
||||
var/cursor2 = base2
|
||||
|
||||
//degenerate cases
|
||||
if(len2 == 1)
|
||||
moveElement(L, cursor2, cursor1)
|
||||
return
|
||||
|
||||
if(len1 == 1)
|
||||
moveElement(L, cursor1, cursor2 + len2)
|
||||
return
|
||||
|
||||
|
||||
//Move first element of second run
|
||||
moveElement(L, cursor2++, cursor1++)
|
||||
--len2
|
||||
|
||||
outer:
|
||||
while(1)
|
||||
var/count1 = 0 //# of times in a row that first run won
|
||||
var/count2 = 0 // " " " " " " second run won
|
||||
|
||||
//do the straightfoward thin until one run starts winning consistently
|
||||
|
||||
do
|
||||
//ASSERT(len1 > 1 && len2 > 0)
|
||||
if(call(cmp)(fetchElement(L, cursor2), fetchElement(L, cursor1)) < 0)
|
||||
moveElement(L, cursor2++, cursor1++)
|
||||
--len2
|
||||
|
||||
++count2
|
||||
count1 = 0
|
||||
|
||||
if(len2 == 0)
|
||||
break outer
|
||||
else
|
||||
++cursor1
|
||||
|
||||
++count1
|
||||
count2 = 0
|
||||
|
||||
if(--len1 == 1)
|
||||
break outer
|
||||
|
||||
while((count1 | count2) < minGallop)
|
||||
|
||||
|
||||
//one run is winning consistently so galloping may provide huge benifits
|
||||
//so try galloping, until such time as the run is no longer consistently winning
|
||||
do
|
||||
//ASSERT(len1 > 1 && len2 > 0)
|
||||
|
||||
count1 = gallopRight(fetchElement(L, cursor2), cursor1, len1, 0)
|
||||
if(count1)
|
||||
cursor1 += count1
|
||||
len1 -= count1
|
||||
|
||||
if(len1 <= 1)
|
||||
break outer
|
||||
|
||||
moveElement(L, cursor2, cursor1)
|
||||
++cursor2
|
||||
++cursor1
|
||||
if(--len2 == 0)
|
||||
break outer
|
||||
|
||||
count2 = gallopLeft(fetchElement(L, cursor1), cursor2, len2, 0)
|
||||
if(count2)
|
||||
moveRange(L, cursor2, cursor1, count2)
|
||||
|
||||
cursor2 += count2
|
||||
cursor1 += count2
|
||||
len2 -= count2
|
||||
|
||||
if(len2 == 0)
|
||||
break outer
|
||||
|
||||
++cursor1
|
||||
if(--len1 == 1)
|
||||
break outer
|
||||
|
||||
--minGallop
|
||||
|
||||
while((count1|count2) > MIN_GALLOP)
|
||||
|
||||
if(minGallop < 0)
|
||||
minGallop = 0
|
||||
minGallop += 2; // Penalize for leaving gallop mode
|
||||
|
||||
|
||||
if(len1 == 1)
|
||||
//ASSERT(len2 > 0)
|
||||
moveElement(L, cursor1, cursor2 + len2)
|
||||
|
||||
//else
|
||||
//ASSERT(len2 == 0)
|
||||
//ASSERT(len1 > 1)
|
||||
|
||||
|
||||
/datum/sortInstance/proc/mergeHi(base1, len1, base2, len2)
|
||||
//ASSERT(len1 > 0 && len2 > 0 && base1 + len1 == base2)
|
||||
|
||||
var/cursor1 = base1 + len1 - 1 //start at end of sublists
|
||||
var/cursor2 = base2 + len2 - 1
|
||||
|
||||
//degenerate cases
|
||||
if(len2 == 1)
|
||||
moveElement(L, base2, base1)
|
||||
return
|
||||
|
||||
if(len1 == 1)
|
||||
moveElement(L, base1, cursor2 + 1)
|
||||
return
|
||||
|
||||
moveElement(L, cursor1--, cursor2-- + 1)
|
||||
--len1
|
||||
|
||||
outer:
|
||||
while(1)
|
||||
var/count1 = 0 //# of times in a row that first run won
|
||||
var/count2 = 0 // " " " " " " second run won
|
||||
|
||||
//do the straightfoward thing until one run starts winning consistently
|
||||
do
|
||||
//ASSERT(len1 > 0 && len2 > 1)
|
||||
if(call(cmp)(fetchElement(L, cursor2), fetchElement(L, cursor1)) < 0)
|
||||
moveElement(L, cursor1--, cursor2-- + 1)
|
||||
--len1
|
||||
|
||||
++count1
|
||||
count2 = 0
|
||||
|
||||
if(len1 == 0)
|
||||
break outer
|
||||
else
|
||||
--cursor2
|
||||
--len2
|
||||
|
||||
++count2
|
||||
count1 = 0
|
||||
|
||||
if(len2 == 1)
|
||||
break outer
|
||||
while((count1 | count2) < minGallop)
|
||||
|
||||
//one run is winning consistently so galloping may provide huge benifits
|
||||
//so try galloping, until such time as the run is no longer consistently winning
|
||||
do
|
||||
//ASSERT(len1 > 0 && len2 > 1)
|
||||
|
||||
count1 = len1 - gallopRight(fetchElement(L, cursor2), base1, len1, len1 - 1) //should cursor1 be base1?
|
||||
if(count1)
|
||||
cursor1 -= count1
|
||||
|
||||
moveRange(L, cursor1 + 1, cursor2 + 1, count1) //cursor1+1 == cursor2 by definition
|
||||
|
||||
cursor2 -= count1
|
||||
len1 -= count1
|
||||
|
||||
if(len1 == 0)
|
||||
break outer
|
||||
|
||||
--cursor2
|
||||
|
||||
if(--len2 == 1)
|
||||
break outer
|
||||
|
||||
count2 = len2 - gallopLeft(fetchElement(L, cursor1), cursor1 + 1, len2, len2 - 1)
|
||||
if(count2)
|
||||
cursor2 -= count2
|
||||
len2 -= count2
|
||||
|
||||
if(len2 <= 1)
|
||||
break outer
|
||||
|
||||
moveElement(L, cursor1--, cursor2-- + 1)
|
||||
--len1
|
||||
|
||||
if(len1 == 0)
|
||||
break outer
|
||||
|
||||
--minGallop
|
||||
while((count1|count2) > MIN_GALLOP)
|
||||
|
||||
if(minGallop < 0)
|
||||
minGallop = 0
|
||||
minGallop += 2 // Penalize for leaving gallop mode
|
||||
|
||||
if(len2 == 1)
|
||||
//ASSERT(len1 > 0)
|
||||
|
||||
cursor1 -= len1
|
||||
moveRange(L, cursor1 + 1, cursor2 + 1, len1)
|
||||
|
||||
//else
|
||||
//ASSERT(len1 == 0)
|
||||
//ASSERT(len2 > 0)
|
||||
|
||||
|
||||
/datum/sortInstance/proc/mergeSort(start, end)
|
||||
var/remaining = end - start
|
||||
|
||||
//If array is small, do an insertion sort
|
||||
if(remaining < MIN_MERGE)
|
||||
binarySort(start, end, start/*+initRunLen*/)
|
||||
return
|
||||
|
||||
var/minRun = minRunLength(remaining)
|
||||
|
||||
do
|
||||
var/runLen = (remaining <= minRun) ? remaining : minRun
|
||||
|
||||
binarySort(start, start + runLen, start)
|
||||
|
||||
//add data about run to queue
|
||||
runBases.Add(start)
|
||||
runLens.Add(runLen)
|
||||
|
||||
//Advance to find next run
|
||||
start += runLen
|
||||
remaining -= runLen
|
||||
|
||||
while(remaining > 0)
|
||||
|
||||
while(runBases.len >= 2)
|
||||
var/n = runBases.len - 1
|
||||
if(n > 1 && runLens[n - 1] <= runLens[n] + runLens[n + 1])
|
||||
if(runLens[n - 1] < runLens[n + 1])
|
||||
--n
|
||||
mergeAt2(n)
|
||||
else if(runLens[n] <= runLens[n + 1])
|
||||
mergeAt2(n)
|
||||
else
|
||||
break //Invariant is established
|
||||
|
||||
while(runBases.len >= 2)
|
||||
var/n = runBases.len - 1
|
||||
if(n > 1 && runLens[n - 1] < runLens[n + 1])
|
||||
--n
|
||||
mergeAt2(n)
|
||||
|
||||
return L
|
||||
|
||||
/datum/sortInstance/proc/mergeAt2(i)
|
||||
var/cursor1 = runBases[i]
|
||||
var/cursor2 = runBases[i + 1]
|
||||
|
||||
var/end1 = cursor1+runLens[i]
|
||||
var/end2 = cursor2+runLens[i + 1]
|
||||
|
||||
var/val1 = fetchElement(L, cursor1)
|
||||
var/val2 = fetchElement(L, cursor2)
|
||||
|
||||
while(1)
|
||||
if(call(cmp)(val1, val2) <= 0)
|
||||
if(++cursor1 >= end1)
|
||||
break
|
||||
val1 = fetchElement(L, cursor1)
|
||||
else
|
||||
moveElement(L, cursor2, cursor1)
|
||||
|
||||
if(++cursor2 >= end2)
|
||||
break
|
||||
++end1
|
||||
++cursor1
|
||||
|
||||
val2 = fetchElement(L, cursor2)
|
||||
|
||||
|
||||
//Record the legth of the combined runs. If i is the 3rd last run now, also slide over the last run
|
||||
//(which isn't involved in this merge). The current run (i+1) goes away in any case.
|
||||
runLens[i] += runLens[i + 1]
|
||||
runLens.Cut(i + 1, i + 2)
|
||||
runBases.Cut(i + 1, i + 2)
|
||||
|
||||
#undef MIN_GALLOP
|
||||
#undef MIN_MERGE
|
||||
|
||||
#undef fetchElement
|
||||
@@ -505,6 +505,7 @@ proc/checkhtml(var/t)
|
||||
text = replacetext(text, "\[row\]", "</td><tr>")
|
||||
text = replacetext(text, "\[cell\]", "<td>")
|
||||
text = replacetext(text, "\[logo\]", "<img src = ntlogo.png>")
|
||||
text = replacetext(text, "\[time\]", "[gameTimestamp()]") // TO DO
|
||||
if(P)
|
||||
text = "<font face=\"[deffont]\" color=[P ? P.colour : "black"]>[text]</font>"
|
||||
else
|
||||
|
||||
+104
-1
@@ -69,4 +69,107 @@ proc/isDay(var/month, var/day)
|
||||
/proc/seconds_to_time(var/seconds as num)
|
||||
var/numSeconds = seconds % 60
|
||||
var/numMinutes = (seconds - numSeconds) / 60
|
||||
return "[numMinutes] [numMinutes > 1 ? "minutes" : "minute"] and [numSeconds] seconds."
|
||||
return "[numMinutes] [numMinutes > 1 ? "minutes" : "minute"] and [numSeconds] seconds."
|
||||
|
||||
//Takes a value of time in deciseconds.
|
||||
//Returns a text value of that number in hours, minutes, or seconds.
|
||||
/proc/DisplayTimeText(time_value)
|
||||
var/second = time_value * 0.1
|
||||
var/second_adjusted = null
|
||||
var/second_rounded = FALSE
|
||||
var/minute = null
|
||||
var/hour = null
|
||||
var/day = null
|
||||
|
||||
if(!second)
|
||||
return "0 seconds"
|
||||
if(second >= 60)
|
||||
minute = round_down(second / 60)
|
||||
second = round(second - (minute * 60), 0.1)
|
||||
second_rounded = TRUE
|
||||
if(second) //check if we still have seconds remaining to format, or if everything went into minute.
|
||||
second_adjusted = round(second) //used to prevent '1 seconds' being shown
|
||||
if(day || hour || minute)
|
||||
if(second_adjusted == 1 && second >= 1)
|
||||
second = " and 1 second"
|
||||
else if(second > 1)
|
||||
second = " and [second_adjusted] seconds"
|
||||
else //shows a fraction if seconds is < 1
|
||||
if(second_rounded) //no sense rounding again if it's already done
|
||||
second = " and [second] seconds"
|
||||
else
|
||||
second = " and [round(second, 0.1)] seconds"
|
||||
else
|
||||
if(second_adjusted == 1 && second >= 1)
|
||||
second = "1 second"
|
||||
else if(second > 1)
|
||||
second = "[second_adjusted] seconds"
|
||||
else
|
||||
if(second_rounded)
|
||||
second = "[second] seconds"
|
||||
else
|
||||
second = "[round(second, 0.1)] seconds"
|
||||
else
|
||||
second = null
|
||||
|
||||
if(!minute)
|
||||
return "[second]"
|
||||
if(minute >= 60)
|
||||
hour = round_down(minute / 60,1)
|
||||
minute = (minute - (hour * 60))
|
||||
if(minute) //alot simpler from here since you don't have to worry about fractions
|
||||
if(minute != 1)
|
||||
if((day || hour) && second)
|
||||
minute = ", [minute] minutes"
|
||||
else if((day || hour) && !second)
|
||||
minute = " and [minute] minutes"
|
||||
else
|
||||
minute = "[minute] minutes"
|
||||
else
|
||||
if((day || hour) && second)
|
||||
minute = ", 1 minute"
|
||||
else if((day || hour) && !second)
|
||||
minute = " and 1 minute"
|
||||
else
|
||||
minute = "1 minute"
|
||||
else
|
||||
minute = null
|
||||
|
||||
if(!hour)
|
||||
return "[minute][second]"
|
||||
if(hour >= 24)
|
||||
day = round_down(hour / 24,1)
|
||||
hour = (hour - (day * 24))
|
||||
if(hour)
|
||||
if(hour != 1)
|
||||
if(day && (minute || second))
|
||||
hour = ", [hour] hours"
|
||||
else if(day && (!minute || !second))
|
||||
hour = " and [hour] hours"
|
||||
else
|
||||
hour = "[hour] hours"
|
||||
else
|
||||
if(day && (minute || second))
|
||||
hour = ", 1 hour"
|
||||
else if(day && (!minute || !second))
|
||||
hour = " and 1 hour"
|
||||
else
|
||||
hour = "1 hour"
|
||||
else
|
||||
hour = null
|
||||
|
||||
if(!day)
|
||||
return "[hour][minute][second]"
|
||||
if(day > 1)
|
||||
day = "[day] days"
|
||||
else
|
||||
day = "1 day"
|
||||
|
||||
return "[day][hour][minute][second]"
|
||||
|
||||
GLOBAL_VAR_INIT(midnight_rollovers, 0)
|
||||
GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0)
|
||||
/proc/update_midnight_rollover()
|
||||
if(world.timeofday < GLOB.rollovercheck_last_timeofday) //TIME IS GOING BACKWARDS!
|
||||
return GLOB.midnight_rollovers++
|
||||
return GLOB.midnight_rollovers
|
||||
@@ -526,6 +526,14 @@ proc/GaussRandRound(var/sigma,var/roundto)
|
||||
|
||||
return toReturn
|
||||
|
||||
//Searches contents of the atom and returns the sum of all w_class of obj/item within
|
||||
/atom/proc/GetTotalContentsWeight(searchDepth = 5)
|
||||
var/weight = 0
|
||||
var/list/content = GetAllContents(searchDepth)
|
||||
for(var/obj/item/I in content)
|
||||
weight += I.w_class
|
||||
return weight
|
||||
|
||||
//Step-towards method of determining whether one atom can see another. Similar to viewers()
|
||||
/proc/can_see(var/atom/source, var/atom/target, var/length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate.
|
||||
var/turf/current = get_turf(source)
|
||||
@@ -777,15 +785,15 @@ proc/GaussRandRound(var/sigma,var/roundto)
|
||||
|
||||
if(toupdate.len)
|
||||
for(var/turf/simulated/T1 in toupdate)
|
||||
air_master.remove_from_active(T1)
|
||||
SSair.remove_from_active(T1)
|
||||
T1.CalculateAdjacentTurfs()
|
||||
air_master.add_to_active(T1,1)
|
||||
SSair.add_to_active(T1,1)
|
||||
|
||||
if(fromupdate.len)
|
||||
for(var/turf/simulated/T2 in fromupdate)
|
||||
air_master.remove_from_active(T2)
|
||||
SSair.remove_from_active(T2)
|
||||
T2.CalculateAdjacentTurfs()
|
||||
air_master.add_to_active(T2,1)
|
||||
SSair.add_to_active(T2,1)
|
||||
|
||||
|
||||
|
||||
@@ -941,7 +949,7 @@ proc/GaussRandRound(var/sigma,var/roundto)
|
||||
if(toupdate.len)
|
||||
for(var/turf/simulated/T1 in toupdate)
|
||||
T1.CalculateAdjacentTurfs()
|
||||
air_master.add_to_active(T1,1)
|
||||
SSair.add_to_active(T1,1)
|
||||
|
||||
|
||||
return copiedobjs
|
||||
@@ -1337,7 +1345,7 @@ Standard way to write links -Sayu
|
||||
if(covered_locations & HEAD)
|
||||
return 0
|
||||
if("eyes")
|
||||
if(covered_locations & HEAD || face_covered & HIDEEYES || eyesmouth_covered & GLASSESCOVERSEYES)
|
||||
if(face_covered & HIDEEYES || eyesmouth_covered & GLASSESCOVERSEYES || eyesmouth_covered & HEADCOVERSEYES)
|
||||
return 0
|
||||
if("mouth")
|
||||
if(covered_locations & HEAD || face_covered & HIDEFACE || eyesmouth_covered & MASKCOVERSMOUTH)
|
||||
@@ -1914,3 +1922,10 @@ var/mob/dview/dview_mob = new
|
||||
for(var/atom/thing in here)
|
||||
if(istype(thing, type) && (check_shift && thing.pixel_x == shift_x && thing.pixel_y == shift_y))
|
||||
. += thing
|
||||
|
||||
//gives us the stack trace from CRASH() without ending the current proc.
|
||||
/proc/stack_trace(msg)
|
||||
CRASH(msg)
|
||||
|
||||
/datum/proc/stack_trace(msg)
|
||||
CRASH(msg)
|
||||
@@ -2,7 +2,6 @@ var/datum/configuration/config = null
|
||||
|
||||
var/host = null
|
||||
var/join_motd = null
|
||||
var/station_name = "NSS Cyberiad"
|
||||
var/game_version = "Custom ParaCode"
|
||||
var/changelog_hash = md5('html/changelog.html') //used to check if the CL changed
|
||||
var/game_year = (text2num(time2text(world.realtime, "YYYY")) + 544)
|
||||
|
||||
@@ -25,6 +25,7 @@ var/global/list/respawnable_list = list() //List of all mobs, dead or in mindl
|
||||
var/global/list/non_respawnable_keys = list() //List of ckeys that are excluded from respawning for remainder of round.
|
||||
var/global/list/simple_animal_list = list() //List of all simple animals, including clientless
|
||||
var/global/list/snpc_list = list() //List of all snpc's, including clientless
|
||||
var/global/list/bots_list = list() //List of all bots(beepsky, medibots,etc)
|
||||
|
||||
var/global/list/med_hud_users = list()
|
||||
var/global/list/sec_hud_users = list()
|
||||
|
||||
@@ -13,6 +13,8 @@ var/list/diona_names = file2list ("config/names/diona.txt")
|
||||
|
||||
var/list/verbs = file2list("config/names/verbs.txt")
|
||||
var/list/adjectives = file2list("config/names/adjectives.txt")
|
||||
var/list/dream_strings = file2list("config/names/dreams.txt")
|
||||
var/list/nightmare_strings = file2list("config/names/nightmares.txt")
|
||||
//loaded on startup because of "
|
||||
//would include in rsc if ' was used
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ var/global/list/all_areas = list()
|
||||
var/global/list/machines = list()
|
||||
var/global/list/machine_processing = list()
|
||||
var/global/list/fast_processing = list()
|
||||
var/global/list/atmos_machinery = list()
|
||||
var/global/list/processing_power_items = list() //items that ask to be called every cycle
|
||||
var/global/list/rcd_list = list() //list of Rapid Construction Devices.
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ var/global/obj/effect/overlay/plmaster = null
|
||||
var/global/obj/effect/overlay/slmaster = null
|
||||
var/global/obj/effect/overlay/icemaster = null
|
||||
|
||||
// nanomanager, the manager for Nano UIs
|
||||
var/datum/nanomanager/nanomanager = new()
|
||||
// Event Manager, the manager for events.
|
||||
var/datum/event_manager/event_manager = new()
|
||||
// Announcer intercom, because too much stuff creates an intercom for one message then hard del()s it.
|
||||
|
||||
@@ -127,9 +127,7 @@
|
||||
if(A == loc || (A in loc) || (sdepth != -1 && sdepth <= 2))
|
||||
// No adjacency needed
|
||||
if(W)
|
||||
var/resolved = A.attackby(W,src)
|
||||
if(!resolved && A && W)
|
||||
W.afterattack(A,src,1,params) // 1 indicates adjacency
|
||||
W.melee_attack_chain(src, A, params)
|
||||
else
|
||||
if(ismob(A))
|
||||
changeNext_move(CLICK_CD_MELEE)
|
||||
@@ -145,10 +143,7 @@
|
||||
if(isturf(A) || isturf(A.loc) || (sdepth != -1 && sdepth <= 1))
|
||||
if(A.Adjacent(src)) // see adjacent.dm
|
||||
if(W)
|
||||
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example, params)
|
||||
var/resolved = A.attackby(W,src,params)
|
||||
if(!resolved && A && W)
|
||||
W.afterattack(A,src,1,params) // 1: clicking something Adjacent
|
||||
W.melee_attack_chain(src, A, params)
|
||||
else
|
||||
if(ismob(A))
|
||||
changeNext_move(CLICK_CD_MELEE)
|
||||
|
||||
@@ -81,10 +81,7 @@
|
||||
|
||||
// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc in contents)
|
||||
if(A == loc || (A in loc) || (A in contents))
|
||||
// No adjacency checks
|
||||
var/resolved = A.attackby(W,src,params, params)
|
||||
if(!resolved && A && W)
|
||||
W.afterattack(A,src,1,params)
|
||||
W.melee_attack_chain(src, A, params)
|
||||
return
|
||||
|
||||
if(!isturf(loc))
|
||||
@@ -93,9 +90,7 @@
|
||||
// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc && isturf(A.loc.loc))
|
||||
if(isturf(A) || isturf(A.loc))
|
||||
if(A.Adjacent(src)) // see adjacent.dm
|
||||
var/resolved = A.attackby(W, src, params, params)
|
||||
if(!resolved && A && W)
|
||||
W.afterattack(A, src, 1, params)
|
||||
W.melee_attack_chain(src, A, params)
|
||||
return
|
||||
else
|
||||
W.afterattack(A, src, 0, params)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
var/datum/hud/hud = null
|
||||
appearance_flags = NO_CLIENT_COLOR
|
||||
|
||||
/obj/screen/take_damage()
|
||||
return
|
||||
|
||||
/obj/screen/Destroy()
|
||||
master = null
|
||||
return ..()
|
||||
|
||||
+96
-148
@@ -1,36 +1,33 @@
|
||||
/obj/item/proc/melee_attack_chain(mob/user, atom/target, params)
|
||||
if(pre_attackby(target, user, params))
|
||||
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
|
||||
var/resolved = target.attackby(src, user, params)
|
||||
if(!resolved && target && !qdeleted(src))
|
||||
afterattack(target, user, 1, params) // 1: clicking something Adjacent
|
||||
|
||||
// Called when the item is in the active hand, and clicked; alternately, there is an 'activate held object' verb or you can hit pagedown.
|
||||
/obj/item/proc/attack_self(mob/user)
|
||||
return
|
||||
|
||||
/obj/item/proc/pre_attackby(atom/A, mob/living/user, params) //do stuff before attackby!
|
||||
return TRUE //return FALSE to avoid calling attackby after this proc does stuff
|
||||
|
||||
// No comment
|
||||
/atom/proc/attackby(obj/item/W, mob/living/user, params)
|
||||
/atom/proc/attackby(obj/item/W, mob/user, params)
|
||||
return
|
||||
|
||||
/atom/movable/attackby(obj/item/W, mob/living/user, params)
|
||||
user.changeNext_move(CLICK_CD_MELEE)
|
||||
user.do_attack_animation(src)
|
||||
if(!(W.flags&NOBLUDGEON))
|
||||
visible_message("<span class='danger'>[src] has been hit by [user] with [W].</span>")
|
||||
/obj/attackby(obj/item/I, mob/living/user, params)
|
||||
return I.attack_obj(src, user)
|
||||
|
||||
/mob/living/attackby(obj/item/I, mob/user, params)
|
||||
/mob/living/attackby(obj/item/I, mob/living/user, params)
|
||||
user.changeNext_move(CLICK_CD_MELEE)
|
||||
if(attempt_harvest(I, user))
|
||||
return
|
||||
I.attack(src, user)
|
||||
return 1
|
||||
return I.attack(src, user)
|
||||
|
||||
|
||||
// Proximity_flag is 1 if this afterattack was called on something adjacent, in your square, or on your person.
|
||||
// Click parameters is the params string from byond Click() code, see that documentation.
|
||||
/obj/item/proc/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
|
||||
return
|
||||
|
||||
|
||||
/obj/item/proc/attack(mob/living/M as mob, mob/living/user as mob, def_zone)
|
||||
|
||||
if(!istype(M)) // not sure if this is the right thing...
|
||||
/obj/item/proc/attack(mob/living/M, mob/living/user, def_zone)
|
||||
if(flags & (NOBLUDGEON))
|
||||
return 0
|
||||
var/messagesource = M
|
||||
|
||||
if(can_operate(M)) //Checks if mob is lying down on table for surgery
|
||||
if(istype(src,/obj/item/robot_parts))//popup override for direct attach
|
||||
@@ -46,7 +43,7 @@
|
||||
else
|
||||
return 1
|
||||
|
||||
if(istype(src,/obj/item/weapon/screwdriver) && M.get_species() == "Machine")
|
||||
if(isscrewdriver(src) && M.get_species() == "Machine")
|
||||
if(!attempt_initiate_surgery(src, M, user))
|
||||
return 0
|
||||
else
|
||||
@@ -57,136 +54,87 @@
|
||||
else
|
||||
return 1
|
||||
|
||||
if(istype(M,/mob/living/carbon/brain))
|
||||
var/mob/living/carbon/brain/B = M
|
||||
messagesource = B.container
|
||||
if(hitsound && force > 0)
|
||||
playsound(loc, hitsound, 50, 1, -1)
|
||||
/////////////////////////
|
||||
if(!force)
|
||||
playsound(loc, 'sound/weapons/tap.ogg', get_clamped_volume(), 1, -1)
|
||||
else if(hitsound)
|
||||
playsound(loc, hitsound, get_clamped_volume(), 1, -1)
|
||||
|
||||
user.lastattacked = M
|
||||
M.lastattacker = user
|
||||
add_logs(user, M, "attacked", name, "(INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])", print_attack_log = (force > 0))//print it if stuff deals damage
|
||||
|
||||
if(!iscarbon(user))
|
||||
M.LAssailant = null
|
||||
else
|
||||
M.LAssailant = user
|
||||
if(user != M)
|
||||
user.do_attack_animation(M)
|
||||
M.attacked_by(src, user, def_zone)
|
||||
|
||||
/////////////////////////
|
||||
|
||||
if(isanimal(M))
|
||||
var/mob/living/simple_animal/S = M
|
||||
S.attacked_by(src, user)
|
||||
return 0 // No sanic-speed double-attacks for you - simple mobs will handle being attacked on their own
|
||||
var/power = force
|
||||
|
||||
if(!istype(M, /mob/living/carbon/human))
|
||||
if(istype(M, /mob/living/carbon/slime))
|
||||
var/mob/living/carbon/slime/slime = M
|
||||
if(prob(25))
|
||||
to_chat(user, "<span class='warning'>[src] passes right through [M]!</span>")
|
||||
return
|
||||
|
||||
if(power > 0)
|
||||
slime.attacked += 10
|
||||
|
||||
if(slime.Discipline && prob(50)) // wow, buddy, why am I getting attacked??
|
||||
slime.Discipline = 0
|
||||
|
||||
if(power >= 3)
|
||||
if(slime.is_adult)
|
||||
if(prob(5 + round(power/2)))
|
||||
|
||||
if(slime.Victim)
|
||||
if(prob(80) && !slime.client)
|
||||
slime.Discipline++
|
||||
slime.Victim = null
|
||||
slime.anchored = 0
|
||||
|
||||
spawn()
|
||||
if(slime)
|
||||
slime.SStun = 1
|
||||
sleep(rand(5,20))
|
||||
if(slime)
|
||||
slime.SStun = 0
|
||||
|
||||
spawn(0)
|
||||
if(slime)
|
||||
slime.canmove = 0
|
||||
step_away(slime, user)
|
||||
if(prob(25 + power))
|
||||
sleep(2)
|
||||
if(slime && user)
|
||||
step_away(slime, user)
|
||||
slime.canmove = 1
|
||||
|
||||
else
|
||||
if(prob(10 + power*2))
|
||||
if(slime)
|
||||
if(slime.Victim)
|
||||
if(prob(80) && !slime.client)
|
||||
slime.Discipline++
|
||||
|
||||
if(slime.Discipline == 1)
|
||||
slime.attacked = 0
|
||||
|
||||
spawn()
|
||||
if(slime)
|
||||
slime.SStun = 1
|
||||
sleep(rand(5,20))
|
||||
if(slime)
|
||||
slime.SStun = 0
|
||||
|
||||
slime.Victim = null
|
||||
slime.anchored = 0
|
||||
|
||||
|
||||
spawn(0)
|
||||
if(slime && user)
|
||||
step_away(slime, user)
|
||||
slime.canmove = 0
|
||||
if(prob(25 + power*4))
|
||||
sleep(2)
|
||||
if(slime && user)
|
||||
step_away(slime, user)
|
||||
slime.canmove = 1
|
||||
|
||||
|
||||
var/showname = "."
|
||||
if(user)
|
||||
showname = " by [user]."
|
||||
user.do_attack_animation(src)
|
||||
if(!(user in viewers(M, null)))
|
||||
showname = "."
|
||||
|
||||
for(var/mob/O in viewers(messagesource, null))
|
||||
if(attack_verb.len)
|
||||
O.show_message("<span class='combat danger'>[M] has been [pick(attack_verb)] with [src][showname] </span>", 1)
|
||||
else
|
||||
O.show_message("<span class='combat danger'>[M] has been attacked with [src][showname] </span>", 1)
|
||||
|
||||
if(!showname && user)
|
||||
if(user.client)
|
||||
to_chat(user, "<span class='combat danger'>You attack [M] with [src]. </span>")
|
||||
|
||||
|
||||
|
||||
if(istype(M, /mob/living/carbon/human))
|
||||
return M:attacked_by(src, user, def_zone) //make sure to return whether we have hit or miss
|
||||
else
|
||||
switch(damtype)
|
||||
if("brute")
|
||||
if(istype(src, /mob/living/carbon/slime))
|
||||
M.adjustBrainLoss(power)
|
||||
|
||||
else
|
||||
|
||||
M.take_organ_damage(power)
|
||||
if(prob(33)) // Added blood for whacking non-humans too
|
||||
M.add_splatter_floor()
|
||||
if("fire")
|
||||
M.take_organ_damage(0, power)
|
||||
to_chat(M, "Aargh it burns!")
|
||||
M.updatehealth()
|
||||
add_logs(user, M, "attacked", name, "(INTENT: [uppertext(user.a_intent)]) (DAMTYPE: [uppertext(damtype)])", print_attack_log = (force > 0))//print it if stuff deals damage
|
||||
add_fingerprint(user)
|
||||
|
||||
|
||||
//the equivalent of the standard version of attack() but for object targets.
|
||||
/obj/item/proc/attack_obj(obj/O, mob/living/user)
|
||||
if(flags & (NOBLUDGEON))
|
||||
return
|
||||
user.changeNext_move(CLICK_CD_MELEE)
|
||||
user.do_attack_animation(O)
|
||||
O.attacked_by(src, user)
|
||||
|
||||
/atom/movable/proc/attacked_by()
|
||||
return
|
||||
|
||||
/obj/attacked_by(obj/item/I, mob/living/user)
|
||||
if(I.force)
|
||||
user.visible_message("<span class='danger'>[user] has hit [src] with [I]!</span>", "<span class='danger'>You hit [src] with [I]!</span>")
|
||||
take_damage(I.force, I.damtype, "melee", 1)
|
||||
|
||||
/mob/living/attacked_by(obj/item/I, mob/living/user, def_zone)
|
||||
send_item_attack_message(I, user)
|
||||
if(I.force)
|
||||
apply_damage(I.force, I.damtype, def_zone)
|
||||
if(I.damtype == BRUTE)
|
||||
if(prob(33))
|
||||
I.add_mob_blood(src)
|
||||
var/turf/location = get_turf(src)
|
||||
add_splatter_floor(location)
|
||||
if(get_dist(user, src) <= 1) //people with TK won't get smeared with blood
|
||||
user.add_mob_blood(src)
|
||||
return TRUE //successful attack
|
||||
|
||||
/mob/living/simple_animal/attacked_by(obj/item/I, mob/living/user)
|
||||
if(!I.force)
|
||||
user.visible_message("<span class='warning'>[user] gently taps [src] with [I].</span>",\
|
||||
"<span class='warning'>This weapon is ineffective, it does no damage!</span>")
|
||||
else if(I.force < force_threshold || I.damtype == STAMINA)
|
||||
visible_message("<span class='warning'>[I] bounces harmlessly off of [src].</span>",\
|
||||
"<span class='warning'>[I] bounces harmlessly off of [src]!</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
// Proximity_flag is 1 if this afterattack was called on something adjacent, in your square, or on your person.
|
||||
// Click parameters is the params string from byond Click() code, see that documentation.
|
||||
/obj/item/proc/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
|
||||
return
|
||||
|
||||
/obj/item/proc/get_clamped_volume()
|
||||
if(w_class)
|
||||
if(force)
|
||||
return Clamp((force + w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100
|
||||
else
|
||||
return Clamp(w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100
|
||||
|
||||
/mob/living/proc/send_item_attack_message(obj/item/I, mob/living/user, hit_area)
|
||||
if(I.discrete)
|
||||
return
|
||||
var/message_verb = "attacked"
|
||||
if(I.attack_verb && I.attack_verb.len)
|
||||
message_verb = "[pick(I.attack_verb)]"
|
||||
else if(!I.force)
|
||||
return
|
||||
var/message_hit_area = ""
|
||||
if(hit_area)
|
||||
message_hit_area = " in the [hit_area]"
|
||||
var/attack_message = "[src] has been [message_verb][message_hit_area] with [I]."
|
||||
if(user in viewers(src, null))
|
||||
attack_message = "[user] has [message_verb] [src][message_hit_area] with [I]!"
|
||||
visible_message("<span class='combat danger'>[attack_message]</span>",\
|
||||
"<span class='combat userdanger'>[attack_message]</span>")
|
||||
return 1
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
/**
|
||||
* Config vars
|
||||
*/
|
||||
// Process name
|
||||
var/name
|
||||
|
||||
// Process schedule interval
|
||||
// This controls how often the process would run under ideal conditions.
|
||||
@@ -364,7 +362,7 @@
|
||||
var/highestRunTime = round(highest_run_time, 0.001)
|
||||
var/deferTime = round(cpu_defer_count / 10 * world.tick_lag, 0.01)
|
||||
if(!statclick)
|
||||
statclick = new (src)
|
||||
statclick = new /obj/effect/statclick/debug(src)
|
||||
stat("[name]", statclick.update("T#[getTicks()] | AR [averageRunTime] | LR [lastRunTime] | HR [highestRunTime] | D [deferTime]"))
|
||||
|
||||
/datum/controller/process/proc/catchException(var/exception/e, var/thrower)
|
||||
|
||||
@@ -232,7 +232,7 @@ var/global/datum/controller/processScheduler/processScheduler
|
||||
stat("Processes", "Scheduler not running")
|
||||
return
|
||||
if(!statclick)
|
||||
statclick = new (src)
|
||||
statclick = new /obj/effect/statclick/debug(src)
|
||||
stat("Processes", statclick.update("[processes.len] (R [running.len] / Q [queued.len] / I [idle.len])"))
|
||||
for(var/datum/controller/process/p in processes)
|
||||
p.statProcess()
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
var/kill_air = 0
|
||||
|
||||
var/global/datum/controller/process/air_system/air_master
|
||||
|
||||
/datum/controller/process/air_system
|
||||
var/list/excited_groups = list()
|
||||
var/list/active_turfs = list()
|
||||
var/list/hotspots = list()
|
||||
|
||||
//Special functions lists
|
||||
var/list/turf/simulated/active_super_conductivity = list()
|
||||
var/list/turf/simulated/high_pressure_delta = list()
|
||||
|
||||
var/current_cycle = 0
|
||||
var/failed_ticks = 0
|
||||
var/tick_progress = 0
|
||||
|
||||
// Stats
|
||||
var/last_active = 0
|
||||
var/last_excited = 0
|
||||
var/last_hpd = 0
|
||||
var/last_hotspots = 0
|
||||
var/last_asc = 0
|
||||
|
||||
|
||||
/datum/controller/process/air_system/setup()
|
||||
name = "air"
|
||||
schedule_interval = 4
|
||||
start_delay = 4
|
||||
|
||||
var/watch = start_watch()
|
||||
log_startup_progress("Processing geometry...")
|
||||
setup_overlays() // Assign icons and such for gas-turf-overlays
|
||||
setup_allturfs() // Get all currently active tiles that need processing each atmos tick.
|
||||
log_startup_progress(" Geometry processed in [stop_watch(watch)]s.")
|
||||
|
||||
/datum/controller/process/air_system/doWork()
|
||||
if(kill_air)
|
||||
return 1
|
||||
current_cycle++
|
||||
process_pipenets()
|
||||
process_atmos_machinery()
|
||||
process_active_turfs()
|
||||
process_excited_groups()
|
||||
process_high_pressure_delta()
|
||||
process_hotspots()
|
||||
process_super_conductivity()
|
||||
return 1
|
||||
|
||||
/datum/controller/process/air_system/statProcess()
|
||||
..()
|
||||
stat(null, "[last_active] active")
|
||||
stat(null, "[last_excited] EG | [last_hpd] HPD | [last_asc] ASC | [last_hotspots] Hot")
|
||||
stat(null, "[pipe_networks.len] pipe nets, [deferred_pipenet_rebuilds.len] deferred")
|
||||
stat(null, "[atmos_machinery.len] atmos machines")
|
||||
|
||||
DECLARE_GLOBAL_CONTROLLER(air_system, air_master)
|
||||
|
||||
/datum/controller/process/air_system/proc/process_hotspots()
|
||||
last_hotspots = hotspots.len
|
||||
for(var/obj/effect/hotspot/H in hotspots)
|
||||
H.process()
|
||||
SCHECK
|
||||
|
||||
/datum/controller/process/air_system/proc/process_super_conductivity()
|
||||
last_asc = active_super_conductivity.len
|
||||
for(var/turf/simulated/T in active_super_conductivity)
|
||||
T.super_conduct()
|
||||
SCHECK
|
||||
|
||||
/datum/controller/process/air_system/proc/process_high_pressure_delta()
|
||||
last_hpd = high_pressure_delta.len
|
||||
for(var/turf/T in high_pressure_delta)
|
||||
T.high_pressure_movements()
|
||||
T.pressure_difference = 0
|
||||
SCHECK
|
||||
high_pressure_delta.Cut()
|
||||
|
||||
/datum/controller/process/air_system/proc/process_active_turfs()
|
||||
last_active = active_turfs.len
|
||||
for(var/turf/simulated/T in active_turfs)
|
||||
T.process_cell()
|
||||
SCHECK
|
||||
|
||||
/datum/controller/process/air_system/proc/process_pipenets()
|
||||
for(last_object in deferred_pipenet_rebuilds)
|
||||
var/obj/machinery/atmospherics/M = last_object
|
||||
if(istype(M) && isnull(M.gcDestroyed))
|
||||
try
|
||||
M.build_network()
|
||||
catch(var/exception/e)
|
||||
catchException(e, M)
|
||||
SCHECK
|
||||
else
|
||||
catchBadType(M)
|
||||
deferred_pipenet_rebuilds -= M
|
||||
|
||||
for(last_object in pipe_networks)
|
||||
var/datum/pipeline/pipeNetwork = last_object
|
||||
if(istype(pipeNetwork) && isnull(pipeNetwork.gcDestroyed))
|
||||
try
|
||||
pipeNetwork.process()
|
||||
catch(var/exception/e)
|
||||
catchException(e, pipeNetwork)
|
||||
SCHECK
|
||||
else
|
||||
catchBadType(pipeNetwork)
|
||||
pipe_networks -= pipeNetwork
|
||||
|
||||
/datum/controller/process/air_system/proc/process_atmos_machinery()
|
||||
for(last_object in atmos_machinery)
|
||||
var/obj/machinery/M = last_object
|
||||
if(istype(M) && isnull(M.gcDestroyed))
|
||||
try
|
||||
if(M.process_atmos() == PROCESS_KILL)
|
||||
atmos_machinery.Remove(M)
|
||||
continue
|
||||
catch(var/exception/e)
|
||||
catchException(e, M)
|
||||
else
|
||||
catchBadType(M)
|
||||
atmos_machinery -= M
|
||||
|
||||
SCHECK
|
||||
|
||||
|
||||
/datum/controller/process/air_system/proc/remove_from_active(var/turf/simulated/T)
|
||||
if(istype(T))
|
||||
T.excited = 0
|
||||
active_turfs -= T
|
||||
if(T.excited_group)
|
||||
T.excited_group.garbage_collect()
|
||||
|
||||
/datum/controller/process/air_system/proc/add_to_active(var/turf/simulated/T, var/blockchanges = 1)
|
||||
if(istype(T) && T.air)
|
||||
T.excited = 1
|
||||
active_turfs |= T
|
||||
if(blockchanges && T.excited_group)
|
||||
T.excited_group.garbage_collect()
|
||||
else
|
||||
for(var/direction in cardinal)
|
||||
if(!(T.atmos_adjacent_turfs & direction))
|
||||
continue
|
||||
var/turf/simulated/S = get_step(T, direction)
|
||||
if(istype(S))
|
||||
add_to_active(S)
|
||||
|
||||
/datum/controller/process/air_system/proc/setup_allturfs(var/turfs_in = world)
|
||||
for(var/turf/simulated/T in turfs_in)
|
||||
T.CalculateAdjacentTurfs()
|
||||
if(!T.blocks_air)
|
||||
T.update_visuals()
|
||||
for(var/direction in cardinal)
|
||||
if(!(T.atmos_adjacent_turfs & direction))
|
||||
continue
|
||||
var/turf/enemy_tile = get_step(T, direction)
|
||||
if(istype(enemy_tile,/turf/simulated/))
|
||||
var/turf/simulated/enemy_simulated = enemy_tile
|
||||
if(!T.air.compare(enemy_simulated.air))
|
||||
T.excited = 1
|
||||
active_turfs |= T
|
||||
break
|
||||
else
|
||||
if(!T.air.check_turf_total(enemy_tile))
|
||||
T.excited = 1
|
||||
active_turfs |= T
|
||||
|
||||
/datum/controller/process/air_system/proc/process_excited_groups()
|
||||
last_excited = excited_groups.len
|
||||
for(var/datum/excited_group/EG in excited_groups)
|
||||
EG.breakdown_cooldown++
|
||||
if(EG.breakdown_cooldown == 10)
|
||||
EG.self_breakdown()
|
||||
SCHECK
|
||||
return
|
||||
if(EG.breakdown_cooldown > 20)
|
||||
EG.dismantle()
|
||||
SCHECK
|
||||
|
||||
/datum/controller/process/air_system/proc/setup_overlays()
|
||||
plmaster = new /obj/effect/overlay()
|
||||
plmaster.icon = 'icons/effects/tile_effects.dmi'
|
||||
plmaster.icon_state = "plasma"
|
||||
plmaster.layer = FLY_LAYER
|
||||
plmaster.mouse_opacity = 0
|
||||
|
||||
slmaster = new /obj/effect/overlay()
|
||||
slmaster.icon = 'icons/effects/tile_effects.dmi'
|
||||
slmaster.icon_state = "sleeping_agent"
|
||||
slmaster.layer = FLY_LAYER
|
||||
slmaster.mouse_opacity = 0
|
||||
|
||||
icemaster = new /obj/effect/overlay()
|
||||
icemaster.icon = 'icons/turf/overlays.dmi'
|
||||
icemaster.icon_state = "snowfloor"
|
||||
icemaster.layer = TURF_LAYER+0.1
|
||||
icemaster.mouse_opacity = 0
|
||||
@@ -1,24 +0,0 @@
|
||||
var/global/datum/controller/process/fire/fire_master
|
||||
|
||||
/datum/controller/process/fire
|
||||
var/list/burning = list()
|
||||
|
||||
/datum/controller/process/fire/setup()
|
||||
name = "fire"
|
||||
schedule_interval = 20 //every 2 seconds
|
||||
log_startup_progress("Fire process starting up.")
|
||||
|
||||
/datum/controller/process/fire/statProcess()
|
||||
..()
|
||||
stat(null, "[burning.len] burning objects")
|
||||
|
||||
/datum/controller/process/fire/doWork()
|
||||
for(var/obj/burningobj in burning)
|
||||
if(burningobj.burn_state == ON_FIRE)
|
||||
if(burningobj.burn_world_time < world.time)
|
||||
burningobj.burn()
|
||||
SCHECK
|
||||
else
|
||||
burning.Remove(burningobj)
|
||||
|
||||
DECLARE_GLOBAL_CONTROLLER(fire, fire_master)
|
||||
@@ -1,16 +0,0 @@
|
||||
/*/datum/controller/process/inactivity/setup()
|
||||
name = "inactivity"
|
||||
schedule_interval = INACTIVITY_KICK
|
||||
|
||||
/datum/controller/process/inactivity/doWork()
|
||||
if(config.kick_inactive)
|
||||
for(var/client/C in clients)
|
||||
if(C.is_afk(INACTIVITY_KICK))
|
||||
if(!istype(C.mob, /mob/dead))
|
||||
log_access("AFK: [key_name(C)]")
|
||||
to_chat(C, "<SPAN CLASS='warning'>You have been inactive for more than 10 minutes and have been disconnected.</SPAN>")
|
||||
del(C)
|
||||
|
||||
SCHECK
|
||||
|
||||
#undef INACTIVITY_KICK*/
|
||||
@@ -1,53 +0,0 @@
|
||||
var/global/datum/controller/process/spacedrift/drift_master
|
||||
|
||||
/datum/controller/process/spacedrift
|
||||
var/list/processing_list = list()
|
||||
|
||||
/datum/controller/process/spacedrift/setup()
|
||||
name = "spacedrift"
|
||||
schedule_interval = 5
|
||||
start_delay = 20
|
||||
log_startup_progress("Spacedrift starting up.")
|
||||
|
||||
/datum/controller/process/spacedrift/statProcess()
|
||||
..()
|
||||
stat(null, "P:[processing_list.len]")
|
||||
|
||||
/datum/controller/process/spacedrift/doWork()
|
||||
var/list/currentrun = processing_list.Copy()
|
||||
|
||||
while(currentrun.len)
|
||||
var/atom/movable/AM = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(!AM)
|
||||
processing_list -= AM
|
||||
SCHECK
|
||||
continue
|
||||
|
||||
if(AM.inertia_next_move > world.time)
|
||||
SCHECK
|
||||
continue
|
||||
|
||||
if(!AM.loc || AM.loc != AM.inertia_last_loc || AM.Process_Spacemove(0))
|
||||
AM.inertia_dir = 0
|
||||
|
||||
if(!AM.inertia_dir)
|
||||
AM.inertia_last_loc = null
|
||||
processing_list -= AM
|
||||
SCHECK
|
||||
continue
|
||||
|
||||
var/old_dir = AM.dir
|
||||
var/old_loc = AM.loc
|
||||
AM.inertia_moving = TRUE
|
||||
step(AM, AM.inertia_dir)
|
||||
AM.inertia_moving = FALSE
|
||||
AM.inertia_next_move = world.time + AM.inertia_move_delay
|
||||
if(AM.loc == old_loc)
|
||||
AM.inertia_dir = 0
|
||||
|
||||
AM.setDir(old_dir)
|
||||
AM.inertia_last_loc = AM.loc
|
||||
SCHECK
|
||||
|
||||
DECLARE_GLOBAL_CONTROLLER(spacedrift, drift_master)
|
||||
@@ -1,61 +0,0 @@
|
||||
var/global/datum/controller/process/sun/sun
|
||||
|
||||
/datum/controller/process/sun
|
||||
var/angle
|
||||
var/dx
|
||||
var/dy
|
||||
var/rate
|
||||
var/list/solars = list() // for debugging purposes, references solars list at the constructor
|
||||
|
||||
/datum/controller/process/sun/setup()
|
||||
name = "sun"
|
||||
schedule_interval = 600 // every 60 seconds
|
||||
log_startup_progress("Sun ticker starting up.")
|
||||
|
||||
angle = rand (0,360) // the station position to the sun is randomised at round start
|
||||
rate = rand(50,200)/100 // 50% - 200% of standard rotation
|
||||
if(prob(50)) // same chance to rotate clockwise than counter-clockwise
|
||||
rate = -rate
|
||||
|
||||
/datum/controller/process/sun/doWork()
|
||||
calc_position()
|
||||
update_solar_machinery()
|
||||
|
||||
DECLARE_GLOBAL_CONTROLLER(sun, sun)
|
||||
|
||||
// calculate the sun's position given the time of day
|
||||
// at the standard rate (100%) the angle is increase/decreased by 6 degrees every minute.
|
||||
// a full rotation thus take a game hour in that case
|
||||
/datum/controller/process/sun/proc/calc_position()
|
||||
angle = (360 + angle + rate * 6) % 360 // increase/decrease the angle to the sun, adjusted by the rate
|
||||
|
||||
// now calculate and cache the (dx,dy) increments for line drawing
|
||||
var/s = sin(angle)
|
||||
var/c = cos(angle)
|
||||
|
||||
// Either "abs(s) < abs(c)" or "abs(s) >= abs(c)"
|
||||
// In both cases, the greater is greater than 0, so, no "if 0" check is needed for the divisions
|
||||
|
||||
if(abs(s) < abs(c))
|
||||
dx = s / abs(c)
|
||||
dy = c / abs(c)
|
||||
else
|
||||
dx = s / abs(s)
|
||||
dy = c / abs(s)
|
||||
|
||||
//now tell the solar control computers to update their status and linked devices
|
||||
/datum/controller/process/sun/proc/update_solar_machinery()
|
||||
for(last_object in solars)
|
||||
var/obj/machinery/power/solar_control/SC = last_object
|
||||
if(istype(SC) && isnull(SC.gcDestroyed))
|
||||
if(!SC.powernet)
|
||||
solars -= SC
|
||||
continue
|
||||
try
|
||||
SC.update()
|
||||
catch(var/exception/e)
|
||||
catchException(e, SC)
|
||||
SCHECK
|
||||
else
|
||||
catchBadType(SC)
|
||||
solars -= SC
|
||||
@@ -1,138 +0,0 @@
|
||||
#define MAX_THROWING_DIST 512 // 2 z-levels on default width
|
||||
#define MAX_TICKS_TO_MAKE_UP 3 //how many missed ticks will we attempt to make up for this run.
|
||||
|
||||
var/global/datum/controller/process/throwing/throw_master
|
||||
|
||||
/datum/controller/process/throwing
|
||||
var/list/processing_list
|
||||
|
||||
/datum/controller/process/throwing/setup()
|
||||
name = "throwing"
|
||||
schedule_interval = 1
|
||||
start_delay = 20
|
||||
log_startup_progress("Throw ticker starting up.")
|
||||
|
||||
/datum/controller/process/throwing/statProcess()
|
||||
..()
|
||||
stat(null, "P:[processing_list.len]")
|
||||
|
||||
/datum/controller/process/throwing/started()
|
||||
..()
|
||||
if(!processing_list)
|
||||
processing_list = list()
|
||||
|
||||
/datum/controller/process/throwing/doWork()
|
||||
for(last_object in processing_list)
|
||||
var/atom/movable/AM = last_object
|
||||
if(istype(AM) && isnull(AM.gcDestroyed))
|
||||
var/datum/thrownthing/TT = processing_list[AM]
|
||||
if(istype(TT) && isnull(TT.gcDestroyed))
|
||||
TT.tick()
|
||||
SCHECK
|
||||
else
|
||||
catchBadType(TT)
|
||||
processing_list -= AM
|
||||
AM.throwing = null
|
||||
else
|
||||
catchBadType(AM)
|
||||
processing_list -= AM
|
||||
SCHECK
|
||||
|
||||
DECLARE_GLOBAL_CONTROLLER(throwing, throw_master)
|
||||
|
||||
/datum/thrownthing
|
||||
var/atom/movable/thrownthing
|
||||
var/atom/target
|
||||
var/turf/target_turf
|
||||
var/init_dir
|
||||
var/maxrange
|
||||
var/speed
|
||||
var/mob/thrower
|
||||
var/diagonals_first
|
||||
var/dist_travelled = 0
|
||||
var/start_time
|
||||
var/dist_x
|
||||
var/dist_y
|
||||
var/dx
|
||||
var/dy
|
||||
var/pure_diagonal
|
||||
var/diagonal_error
|
||||
var/datum/callback/callback
|
||||
|
||||
/datum/thrownthing/proc/tick()
|
||||
var/atom/movable/AM = thrownthing
|
||||
if(!isturf(AM.loc) || !AM.throwing)
|
||||
finalize()
|
||||
return
|
||||
|
||||
if(dist_travelled && hitcheck()) //to catch sneaky things moving on our tile while we slept
|
||||
finalize()
|
||||
return
|
||||
|
||||
var/atom/step
|
||||
|
||||
// calculate how many tiles to move, making up for any missed ticks.
|
||||
if((dist_travelled >= maxrange || AM.loc == target_turf) && has_gravity(AM, AM.loc))
|
||||
finalize()
|
||||
return
|
||||
|
||||
if(dist_travelled <= max(dist_x, dist_y)) //if we haven't reached the target yet we home in on it, otherwise we use the initial direction
|
||||
step = get_step(AM, get_dir(AM, target_turf))
|
||||
else
|
||||
step = get_step(AM, init_dir)
|
||||
|
||||
if(!pure_diagonal && !diagonals_first) // not a purely diagonal trajectory and we don't want all diagonal moves to be done first
|
||||
if(diagonal_error >= 0 && max(dist_x, dist_y) - dist_travelled != 1) // we do a step forward unless we're right before the target
|
||||
step = get_step(AM, dx)
|
||||
diagonal_error += (diagonal_error < 0) ? dist_x / 2 : -dist_y
|
||||
|
||||
if(!step) // going off the edge of the map makes get_step return null, don't let things go off the edge
|
||||
finalize()
|
||||
return
|
||||
|
||||
AM.Move(step, get_dir(AM, step))
|
||||
|
||||
if(!AM.throwing) // we hit something during our move
|
||||
finalize(hit = TRUE)
|
||||
return
|
||||
|
||||
dist_travelled++
|
||||
|
||||
if(dist_travelled > MAX_THROWING_DIST)
|
||||
finalize()
|
||||
return
|
||||
|
||||
/datum/thrownthing/proc/finalize(hit = FALSE)
|
||||
set waitfor = 0
|
||||
throw_master.processing_list -= thrownthing
|
||||
// done throwning, either because it hit something or it finished moving
|
||||
thrownthing.throwing = null
|
||||
if(!hit)
|
||||
for(var/thing in get_turf(thrownthing)) //looking for our target on the turf we land on.
|
||||
var/atom/A = thing
|
||||
if(A == target)
|
||||
hit = 1
|
||||
thrownthing.throw_impact(A, src)
|
||||
break
|
||||
if(!hit)
|
||||
thrownthing.throw_impact(get_turf(thrownthing), src) // we haven't hit something yet and we still must, let's hit the ground.
|
||||
thrownthing.newtonian_move(init_dir)
|
||||
else
|
||||
thrownthing.newtonian_move(init_dir)
|
||||
if(callback)
|
||||
callback.Invoke()
|
||||
|
||||
/datum/thrownthing/proc/hit_atom(atom/A)
|
||||
thrownthing.throw_impact(A, src)
|
||||
thrownthing.newtonian_move(init_dir)
|
||||
finalize(TRUE)
|
||||
|
||||
/datum/thrownthing/proc/hitcheck()
|
||||
for(var/thing in get_turf(thrownthing))
|
||||
var/atom/movable/AM = thing
|
||||
if(AM == thrownthing)
|
||||
continue
|
||||
if(AM.density && !(AM.pass_flags & LETPASSTHROW) && !(AM.flags & ON_BORDER))
|
||||
thrownthing.throwing = null
|
||||
thrownthing.throw_impact(AM, src)
|
||||
return TRUE
|
||||
@@ -189,6 +189,16 @@
|
||||
|
||||
var/disable_karma = 0 // Disable all karma functions and unlock karma jobs by default
|
||||
|
||||
// StonedMC
|
||||
var/tick_limit_mc_init = TICK_LIMIT_MC_INIT_DEFAULT //SSinitialization throttling
|
||||
|
||||
// Highpop tickrates
|
||||
var/base_mc_tick_rate = 1
|
||||
var/high_pop_mc_tick_rate = 1.1
|
||||
|
||||
var/high_pop_mc_mode_amount = 65
|
||||
var/disable_high_pop_mc_mode_amount = 60
|
||||
|
||||
/datum/configuration/New()
|
||||
var/list/L = subtypesof(/datum/game_mode)
|
||||
for(var/T in L)
|
||||
@@ -597,6 +607,17 @@
|
||||
if("disable_karma")
|
||||
disable_karma = 1
|
||||
|
||||
if("tick_limit_mc_init")
|
||||
tick_limit_mc_init = text2num(value)
|
||||
if("base_mc_tick_rate")
|
||||
base_mc_tick_rate = text2num(value)
|
||||
if("high_pop_mc_tick_rate")
|
||||
high_pop_mc_tick_rate = text2num(value)
|
||||
if("high_pop_mc_mode_amount")
|
||||
high_pop_mc_mode_amount = text2num(value)
|
||||
if("disable_high_pop_mc_mode_amount")
|
||||
disable_high_pop_mc_mode_amount = text2num(value)
|
||||
|
||||
else
|
||||
diary << "Unknown setting in configuration: '[name]'"
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/datum/controller
|
||||
var/name
|
||||
// The object used for the clickable stat() button.
|
||||
var/obj/effect/statclick/statclick
|
||||
|
||||
/datum/controller/proc/Initialize()
|
||||
|
||||
//cleanup actions
|
||||
/datum/controller/proc/Shutdown()
|
||||
|
||||
//when we enter dmm_suite.load_map
|
||||
/datum/controller/proc/StartLoadingMap()
|
||||
|
||||
//when we exit dmm_suite.load_map
|
||||
/datum/controller/proc/StopLoadingMap()
|
||||
|
||||
/datum/controller/proc/Recover()
|
||||
|
||||
/datum/controller/proc/stat_entry()
|
||||
@@ -1,39 +1,97 @@
|
||||
var/global/datum/controller/failsafe/failsafe
|
||||
GLOBAL_REAL(Failsafe, /datum/controller/failsafe)
|
||||
|
||||
/datum/controller/failsafe // This thing pretty much just keeps poking the controllers.
|
||||
processing_interval = 100 // Poke the controllers every 10 seconds.
|
||||
|
||||
/*
|
||||
* Controller alert level.
|
||||
* For every poke that fails this is raised by 1.
|
||||
* When it reaches 5 the MC is replaced with a new one
|
||||
* (effectively killing any controller process() and starting a new one).
|
||||
*/
|
||||
/datum/controller/failsafe // This thing pretty much just keeps poking the master controller
|
||||
name = "Failsafe"
|
||||
|
||||
// master
|
||||
var/masterControllerIteration = 0
|
||||
var/masterControllerAlertLevel = 0
|
||||
// The length of time to check on the MC (in deciseconds).
|
||||
// Set to 0 to disable.
|
||||
var/processing_interval = 20
|
||||
// The alert level. For every failed poke, we drop a DEFCON level. Once we hit DEFCON 1, restart the MC.
|
||||
var/defcon = 5
|
||||
//the world.time of the last check, so the mc can restart US if we hang.
|
||||
// (Real friends look out for *eachother*)
|
||||
var/lasttick = 0
|
||||
|
||||
// Track the MC iteration to make sure its still on track.
|
||||
var/master_iteration = 0
|
||||
var/running = TRUE
|
||||
|
||||
/datum/controller/failsafe/New()
|
||||
. = ..()
|
||||
// Highlander-style: there can only be one! Kill off the old and replace it with the new.
|
||||
if(Failsafe != src)
|
||||
if(istype(Failsafe))
|
||||
qdel(Failsafe)
|
||||
Failsafe = src
|
||||
Initialize()
|
||||
|
||||
// There can be only one failsafe. Out with the old in with the new (that way we can restart the Failsafe by spawning a new one).
|
||||
if(failsafe != src)
|
||||
if(istype(failsafe))
|
||||
recover()
|
||||
qdel(failsafe)
|
||||
/datum/controller/failsafe/Initialize()
|
||||
set waitfor = 0
|
||||
Failsafe.Loop()
|
||||
if(!qdeleted(src))
|
||||
qdel(src) //when Loop() returns, we delete ourselves and let the mc recreate us
|
||||
|
||||
failsafe = src
|
||||
/datum/controller/failsafe/Destroy()
|
||||
running = FALSE
|
||||
..()
|
||||
return QDEL_HINT_HARDDEL_NOW
|
||||
|
||||
//failsafe.process()
|
||||
/datum/controller/failsafe/proc/Loop()
|
||||
while(running)
|
||||
lasttick = world.time
|
||||
if(!Master)
|
||||
// Replace the missing Master! This should never, ever happen.
|
||||
new /datum/controller/master()
|
||||
// Only poke it if overrides are not in effect.
|
||||
if(processing_interval > 0)
|
||||
if(Master.processing && Master.iteration)
|
||||
// Check if processing is done yet.
|
||||
if(Master.iteration == master_iteration)
|
||||
switch(defcon)
|
||||
if(4,5)
|
||||
--defcon
|
||||
if(3)
|
||||
message_admins("<span class='adminnotice'>Notice: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5 - defcon) * processing_interval] ticks.</span>")
|
||||
--defcon
|
||||
if(2)
|
||||
to_chat(admins, "<span class='boldannounce'>Warning: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5 - defcon) * processing_interval] ticks. Automatic restart in [processing_interval] ticks.</span>")
|
||||
--defcon
|
||||
if(1)
|
||||
|
||||
/datum/controller/failsafe/proc/process()
|
||||
processing = 1
|
||||
to_chat(admins, "<span class='boldannounce'>Warning: DEFCON [defcon_pretty()]. The Master Controller has still not fired within the last [(5 - defcon) * processing_interval] ticks. Killing and restarting...</span>")
|
||||
--defcon
|
||||
var/rtn = Recreate_MC()
|
||||
if(rtn > 0)
|
||||
defcon = 4
|
||||
master_iteration = 0
|
||||
to_chat(admins, "<span class='adminnotice'>MC restarted successfully</span>")
|
||||
else if(rtn < 0)
|
||||
log_game("FailSafe: Could not restart MC, runtime encountered. Entering defcon 0")
|
||||
to_chat(admins, "<span class='boldannounce'>ERROR: DEFCON [defcon_pretty()]. Could not restart MC, runtime encountered. I will silently keep retrying.</span>")
|
||||
//if the return number was 0, it just means the mc was restarted too recently, and it just needs some time before we try again
|
||||
//no need to handle that specially when defcon 0 can handle it
|
||||
if(0) //DEFCON 0! (mc failed to restart)
|
||||
var/rtn = Recreate_MC()
|
||||
if(rtn > 0)
|
||||
defcon = 4
|
||||
master_iteration = 0
|
||||
to_chat(admins, "<span class='adminnotice'>MC restarted successfully</span>")
|
||||
else
|
||||
defcon = min(defcon + 1,5)
|
||||
master_iteration = Master.iteration
|
||||
if(defcon <= 1)
|
||||
sleep(processing_interval * 2)
|
||||
else
|
||||
sleep(processing_interval)
|
||||
else
|
||||
defcon = 5
|
||||
sleep(initial(processing_interval))
|
||||
|
||||
spawn(0)
|
||||
set background = BACKGROUND_ENABLED
|
||||
/datum/controller/failsafe/proc/defcon_pretty()
|
||||
return defcon
|
||||
|
||||
while(1) // More efficient than recursivly calling ourself over and over. background = 1 ensures we do not trigger an infinite loop.
|
||||
iteration++
|
||||
/datum/controller/failsafe/stat_entry()
|
||||
if(!statclick)
|
||||
statclick = new/obj/effect/statclick/debug(src, "Initializing...")
|
||||
|
||||
sleep(processing_interval)
|
||||
stat("Failsafe Controller:", statclick.update("Defcon: [defcon_pretty()] (Interval: [Failsafe.processing_interval] | Iteration: [Failsafe.master_iteration])"))
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
GLOBAL_REAL(GLOB, /datum/controller/global_vars)
|
||||
|
||||
/datum/controller/global_vars
|
||||
name = "Global Variables"
|
||||
|
||||
var/list/gvars_datum_protected_varlist
|
||||
var/list/gvars_datum_in_built_vars
|
||||
var/list/gvars_datum_init_order
|
||||
|
||||
/datum/controller/global_vars/New()
|
||||
if(GLOB)
|
||||
CRASH("Multiple instances of global variable controller created")
|
||||
GLOB = src
|
||||
|
||||
var/datum/controller/exclude_these = new
|
||||
gvars_datum_in_built_vars = exclude_these.vars + list("gvars_datum_protected_varlist", "gvars_datum_in_built_vars", "gvars_datum_init_order")
|
||||
qdel(exclude_these)
|
||||
|
||||
log_to_dd("[vars.len - gvars_datum_in_built_vars.len] global variables")
|
||||
|
||||
Initialize()
|
||||
|
||||
/datum/controller/global_vars/Destroy(force)
|
||||
stack_trace("Some fucker qdel'd the global holder!")
|
||||
if(!force)
|
||||
return QDEL_HINT_LETMELIVE
|
||||
|
||||
QDEL_NULL(statclick)
|
||||
gvars_datum_protected_varlist.Cut()
|
||||
gvars_datum_in_built_vars.Cut()
|
||||
|
||||
GLOB = null
|
||||
|
||||
return ..()
|
||||
|
||||
/datum/controller/global_vars/stat_entry()
|
||||
if(!statclick)
|
||||
statclick = new/obj/effect/statclick/debug(src, "Initializing...")
|
||||
|
||||
stat("Globals:", statclick.update("Edit"))
|
||||
|
||||
/datum/controller/global_vars/can_vv_get(var_name)
|
||||
if(gvars_datum_protected_varlist[var_name])
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
/datum/controller/global_vars/vv_edit_var(var_name, var_value)
|
||||
if(gvars_datum_protected_varlist[var_name])
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
/datum/controller/global_vars/Initialize()
|
||||
gvars_datum_init_order = list()
|
||||
gvars_datum_protected_varlist = list("gvars_datum_protected_varlist" = TRUE)
|
||||
var/list/global_procs = typesof(/datum/controller/global_vars/proc)
|
||||
var/expected_len = vars.len - gvars_datum_in_built_vars.len
|
||||
if(global_procs.len != expected_len)
|
||||
warning("Unable to detect all global initialization procs! Expected [expected_len] got [global_procs.len]!")
|
||||
if(global_procs.len)
|
||||
var/list/expected_global_procs = vars - gvars_datum_in_built_vars
|
||||
for(var/I in global_procs)
|
||||
expected_global_procs -= replacetext("[I]", "InitGlobal", "")
|
||||
log_to_dd("Missing procs: [expected_global_procs.Join(", ")]")
|
||||
for(var/I in global_procs)
|
||||
var/start_tick = world.time
|
||||
call(src, I)()
|
||||
var/end_tick = world.time
|
||||
if(end_tick - start_tick)
|
||||
warning("Global [replacetext("[I]", "InitGlobal", "")] slept during initialization!")
|
||||
@@ -0,0 +1,612 @@
|
||||
/**
|
||||
* StonedMC
|
||||
*
|
||||
* Designed to properly split up a given tick among subsystems
|
||||
* Note: if you read parts of this code and think "why is it doing it that way"
|
||||
* Odds are, there is a reason
|
||||
*
|
||||
**/
|
||||
|
||||
//This is the ABSOLUTE ONLY THING that should init globally like this
|
||||
GLOBAL_REAL(Master, /datum/controller/master) = new
|
||||
|
||||
//THIS IS THE INIT ORDER
|
||||
//Master -> SSPreInit -> GLOB -> world -> config -> SSInit -> Failsafe
|
||||
//GOT IT MEMORIZED?
|
||||
|
||||
/datum/controller/master
|
||||
name = "Master"
|
||||
|
||||
// Are we processing (higher values increase the processing delay by n ticks)
|
||||
var/processing = TRUE
|
||||
// How many times have we ran
|
||||
var/iteration = 0
|
||||
|
||||
// world.time of last fire, for tracking lag outside of the mc
|
||||
var/last_run
|
||||
|
||||
// List of subsystems to process().
|
||||
var/list/subsystems
|
||||
|
||||
// Vars for keeping track of tick drift.
|
||||
var/init_timeofday
|
||||
var/init_time
|
||||
var/tickdrift = 0
|
||||
|
||||
var/sleep_delta = 1
|
||||
|
||||
var/make_runtime = 0
|
||||
|
||||
var/initializations_finished_with_no_players_logged_in //I wonder what this could be?
|
||||
|
||||
// The type of the last subsystem to be process()'d.
|
||||
var/last_type_processed
|
||||
|
||||
var/datum/controller/subsystem/queue_head //Start of queue linked list
|
||||
var/datum/controller/subsystem/queue_tail //End of queue linked list (used for appending to the list)
|
||||
var/queue_priority_count = 0 //Running total so that we don't have to loop thru the queue each run to split up the tick
|
||||
var/queue_priority_count_bg = 0 //Same, but for background subsystems
|
||||
var/map_loading = FALSE //Are we loading in a new map?
|
||||
|
||||
var/current_runlevel //for scheduling different subsystems for different stages of the round
|
||||
var/sleep_offline_after_initializations = TRUE
|
||||
|
||||
var/static/restart_clear = 0
|
||||
var/static/restart_timeout = 0
|
||||
var/static/restart_count = 0
|
||||
|
||||
var/static/random_seed
|
||||
|
||||
//current tick limit, assigned before running a subsystem.
|
||||
//used by CHECK_TICK as well so that the procs subsystems call can obey that SS's tick limits
|
||||
var/static/current_ticklimit = TICK_LIMIT_RUNNING
|
||||
|
||||
/datum/controller/master/New()
|
||||
makeDatumRefLists()
|
||||
load_configuration()
|
||||
// Highlander-style: there can only be one! Kill off the old and replace it with the new.
|
||||
|
||||
if(!random_seed)
|
||||
random_seed = rand(1, 1e9)
|
||||
rand_seed(random_seed)
|
||||
|
||||
var/list/_subsystems = list()
|
||||
subsystems = _subsystems
|
||||
if(Master != src)
|
||||
if(istype(Master))
|
||||
Recover()
|
||||
qdel(Master)
|
||||
else
|
||||
var/list/subsytem_types = subtypesof(/datum/controller/subsystem)
|
||||
sortTim(subsytem_types, /proc/cmp_subsystem_init)
|
||||
for(var/I in subsytem_types)
|
||||
_subsystems += new I
|
||||
Master = src
|
||||
|
||||
if(!GLOB)
|
||||
new /datum/controller/global_vars
|
||||
|
||||
/datum/controller/master/Destroy()
|
||||
..()
|
||||
// Tell qdel() to Del() this object.
|
||||
return QDEL_HINT_HARDDEL_NOW
|
||||
|
||||
/datum/controller/master/Shutdown()
|
||||
processing = FALSE
|
||||
sortTim(subsystems, /proc/cmp_subsystem_init)
|
||||
reverseRange(subsystems)
|
||||
for(var/datum/controller/subsystem/ss in subsystems)
|
||||
log_to_dd("Shutting down [ss.name] subsystem...")
|
||||
ss.Shutdown()
|
||||
log_to_dd("Shutdown complete")
|
||||
|
||||
// Returns 1 if we created a new mc, 0 if we couldn't due to a recent restart,
|
||||
// -1 if we encountered a runtime trying to recreate it
|
||||
/proc/Recreate_MC()
|
||||
. = -1 //so if we runtime, things know we failed
|
||||
if(world.time < Master.restart_timeout)
|
||||
return 0
|
||||
if(world.time < Master.restart_clear)
|
||||
Master.restart_count *= 0.5
|
||||
|
||||
var/delay = 50 * ++Master.restart_count
|
||||
Master.restart_timeout = world.time + delay
|
||||
Master.restart_clear = world.time + (delay * 2)
|
||||
Master.processing = FALSE //stop ticking this one
|
||||
try
|
||||
new/datum/controller/master()
|
||||
catch
|
||||
return -1
|
||||
return 1
|
||||
|
||||
|
||||
/datum/controller/master/Recover()
|
||||
var/msg = "## DEBUG: [time2text(world.timeofday)] MC restarted. Reports:\n"
|
||||
for(var/varname in Master.vars)
|
||||
switch (varname)
|
||||
if("name", "tag", "bestF", "type", "parent_type", "vars", "statclick") // Built-in junk.
|
||||
continue
|
||||
else
|
||||
var/varval = Master.vars[varname]
|
||||
if(istype(varval, /datum)) // Check if it has a type var.
|
||||
var/datum/D = varval
|
||||
msg += "\t [varname] = [D]([D.type])\n"
|
||||
else
|
||||
msg += "\t [varname] = [varval]\n"
|
||||
log_to_dd(msg)
|
||||
|
||||
var/datum/controller/subsystem/BadBoy = Master.last_type_processed
|
||||
var/FireHim = FALSE
|
||||
if(istype(BadBoy))
|
||||
msg = null
|
||||
LAZYINITLIST(BadBoy.failure_strikes)
|
||||
switch(++BadBoy.failure_strikes[BadBoy.type])
|
||||
if(2)
|
||||
msg = "The [BadBoy.name] subsystem was the last to fire for 2 controller restarts. It will be recovered now and disabled if it happens again."
|
||||
FireHim = TRUE
|
||||
if(3)
|
||||
msg = "The [BadBoy.name] subsystem seems to be destabilizing the MC and will be offlined."
|
||||
BadBoy.flags |= SS_NO_FIRE
|
||||
if(msg)
|
||||
to_chat(admins, "<span class='boldannounce'>[msg]</span>")
|
||||
log_to_dd(msg)
|
||||
|
||||
if(istype(Master.subsystems))
|
||||
if(FireHim)
|
||||
Master.subsystems += new BadBoy.type //NEW_SS_GLOBAL will remove the old one
|
||||
subsystems = Master.subsystems
|
||||
current_runlevel = Master.current_runlevel
|
||||
StartProcessing(10)
|
||||
else
|
||||
to_chat(world, "<span class='boldannounce'>The Master Controller is having some issues, we will need to re-initialize EVERYTHING</span>")
|
||||
Initialize(20, TRUE)
|
||||
|
||||
|
||||
// Please don't stuff random bullshit here,
|
||||
// Make a subsystem, give it the SS_NO_FIRE flag, and do your work in it's Initialize()
|
||||
/datum/controller/master/Initialize(delay, init_sss)
|
||||
set waitfor = 0
|
||||
|
||||
if(delay)
|
||||
sleep(delay)
|
||||
|
||||
if(init_sss)
|
||||
init_subtypes(/datum/controller/subsystem, subsystems)
|
||||
|
||||
to_chat(world, "<span class='boldannounce'>Initializing subsystems...</span>")
|
||||
|
||||
// Sort subsystems by init_order, so they initialize in the correct order.
|
||||
sortTim(subsystems, /proc/cmp_subsystem_init)
|
||||
|
||||
var/start_timeofday = REALTIMEOFDAY
|
||||
// Initialize subsystems.
|
||||
current_ticklimit = config.tick_limit_mc_init
|
||||
for(var/datum/controller/subsystem/SS in subsystems)
|
||||
if(SS.flags & SS_NO_INIT)
|
||||
continue
|
||||
SS.Initialize(REALTIMEOFDAY)
|
||||
CHECK_TICK
|
||||
current_ticklimit = TICK_LIMIT_RUNNING
|
||||
var/time = (REALTIMEOFDAY - start_timeofday) / 10
|
||||
|
||||
var/msg = "Initializations complete within [time] second[time == 1 ? "" : "s"]!"
|
||||
to_chat(world, "<span class='boldannounce'>[msg]</span>")
|
||||
log_to_dd(msg)
|
||||
|
||||
if(!current_runlevel)
|
||||
SetRunLevel(1)
|
||||
|
||||
// Sort subsystems by display setting for easy access.
|
||||
sortTim(subsystems, /proc/cmp_subsystem_display)
|
||||
// Set world options.
|
||||
if(sleep_offline_after_initializations)
|
||||
world.sleep_offline = TRUE
|
||||
// world.fps = CONFIG_GET(number/fps) // TIGER TODO
|
||||
world.tick_lag = config.Ticklag
|
||||
var/initialized_tod = REALTIMEOFDAY
|
||||
sleep(1)
|
||||
initializations_finished_with_no_players_logged_in = initialized_tod < REALTIMEOFDAY - 10
|
||||
// Loop.
|
||||
Master.StartProcessing(0)
|
||||
|
||||
/datum/controller/master/proc/SetRunLevel(new_runlevel)
|
||||
var/old_runlevel = current_runlevel
|
||||
if(isnull(old_runlevel))
|
||||
old_runlevel = "NULL"
|
||||
|
||||
testing("MC: Runlevel changed from [old_runlevel] to [new_runlevel]")
|
||||
current_runlevel = log(2, new_runlevel) + 1
|
||||
if(current_runlevel < 1)
|
||||
CRASH("Attempted to set invalid runlevel: [new_runlevel]")
|
||||
|
||||
// Starts the mc, and sticks around to restart it if the loop ever ends.
|
||||
/datum/controller/master/proc/StartProcessing(delay)
|
||||
set waitfor = 0
|
||||
if(delay)
|
||||
sleep(delay)
|
||||
testing("Master starting processing")
|
||||
var/rtn = Loop()
|
||||
if(rtn > 0 || processing < 0)
|
||||
return //this was suppose to happen.
|
||||
//loop ended, restart the mc
|
||||
log_game("MC crashed or runtimed, restarting")
|
||||
message_admins("MC crashed or runtimed, restarting")
|
||||
var/rtn2 = Recreate_MC()
|
||||
if(rtn2 <= 0)
|
||||
log_game("Failed to recreate MC (Error code: [rtn2]), it's up to the failsafe now")
|
||||
message_admins("Failed to recreate MC (Error code: [rtn2]), it's up to the failsafe now")
|
||||
Failsafe.defcon = 2
|
||||
|
||||
// Main loop.
|
||||
/datum/controller/master/proc/Loop()
|
||||
. = -1
|
||||
//Prep the loop (most of this is because we want MC restarts to reset as much state as we can, and because
|
||||
// local vars rock
|
||||
|
||||
//all this shit is here so that flag edits can be refreshed by restarting the MC. (and for speed)
|
||||
var/list/tickersubsystems = list()
|
||||
var/list/runlevel_sorted_subsystems = list(list(), list(), list(), list(), list(), list(), list(), list()) //ensure we always have as many runlevels as we need to operate with no subsystems (8 currently)
|
||||
var/timer = world.time
|
||||
for(var/thing in subsystems)
|
||||
var/datum/controller/subsystem/SS = thing
|
||||
if(SS.flags & SS_NO_FIRE)
|
||||
continue
|
||||
SS.queued_time = 0
|
||||
SS.queue_next = null
|
||||
SS.queue_prev = null
|
||||
SS.state = SS_IDLE
|
||||
if(SS.flags & SS_TICKER)
|
||||
tickersubsystems += SS
|
||||
timer += world.tick_lag * rand(1, 5)
|
||||
SS.next_fire = timer
|
||||
continue
|
||||
|
||||
var/ss_runlevels = SS.runlevels
|
||||
var/added_to_any = FALSE
|
||||
for(var/I in 1 to GLOB.bitflags.len)
|
||||
if(ss_runlevels & GLOB.bitflags[I])
|
||||
while(runlevel_sorted_subsystems.len < I)
|
||||
runlevel_sorted_subsystems += list(list())
|
||||
runlevel_sorted_subsystems[I] += SS
|
||||
added_to_any = TRUE
|
||||
if(!added_to_any)
|
||||
WARNING("[SS.name] subsystem is not SS_NO_FIRE but also does not have any runlevels set!")
|
||||
|
||||
queue_head = null
|
||||
queue_tail = null
|
||||
//these sort by lower priorities first to reduce the number of loops needed to add subsequent SS's to the queue
|
||||
//(higher subsystems will be sooner in the queue, adding them later in the loop means we don't have to loop thru them next queue add)
|
||||
sortTim(tickersubsystems, /proc/cmp_subsystem_priority)
|
||||
for(var/I in runlevel_sorted_subsystems)
|
||||
sortTim(runlevel_sorted_subsystems, /proc/cmp_subsystem_priority)
|
||||
I += tickersubsystems
|
||||
|
||||
var/cached_runlevel = current_runlevel
|
||||
var/list/current_runlevel_subsystems = runlevel_sorted_subsystems[cached_runlevel]
|
||||
|
||||
init_timeofday = REALTIMEOFDAY
|
||||
init_time = world.time
|
||||
|
||||
iteration = 1
|
||||
var/error_level = 0
|
||||
var/sleep_delta = 1
|
||||
var/list/subsystems_to_check
|
||||
//the actual loop.
|
||||
|
||||
while(1)
|
||||
tickdrift = max(0, MC_AVERAGE_FAST(tickdrift, (((REALTIMEOFDAY - init_timeofday) - (world.time - init_time)) / world.tick_lag)))
|
||||
var/starting_tick_usage = TICK_USAGE
|
||||
if(processing <= 0)
|
||||
current_ticklimit = TICK_LIMIT_RUNNING
|
||||
sleep(10)
|
||||
continue
|
||||
|
||||
//Anti-tick-contention heuristics:
|
||||
//if there are mutiple sleeping procs running before us hogging the cpu, we have to run later.
|
||||
// (because sleeps are processed in the order received, longer sleeps are more likely to run first)
|
||||
if(starting_tick_usage > TICK_LIMIT_MC) //if there isn't enough time to bother doing anything this tick, sleep a bit.
|
||||
sleep_delta *= 2
|
||||
current_ticklimit = TICK_LIMIT_RUNNING * 0.5
|
||||
sleep(world.tick_lag * (processing * sleep_delta))
|
||||
continue
|
||||
|
||||
//Byond resumed us late. assume it might have to do the same next tick
|
||||
if(last_run + CEILING(world.tick_lag * (processing * sleep_delta), world.tick_lag) < world.time)
|
||||
sleep_delta += 1
|
||||
|
||||
sleep_delta = MC_AVERAGE_FAST(sleep_delta, 1) //decay sleep_delta
|
||||
|
||||
if(starting_tick_usage > (TICK_LIMIT_MC * 0.75)) //we ran 3/4 of the way into the tick
|
||||
sleep_delta += 1
|
||||
|
||||
//debug
|
||||
if(make_runtime)
|
||||
var/datum/controller/subsystem/SS
|
||||
SS.can_fire = 0
|
||||
|
||||
if(!Failsafe || (Failsafe.processing_interval > 0 && (Failsafe.lasttick + (Failsafe.processing_interval * 5)) < world.time))
|
||||
new/datum/controller/failsafe() // (re)Start the failsafe.
|
||||
|
||||
//now do the actual stuff
|
||||
if(!queue_head || !(iteration % 3))
|
||||
var/checking_runlevel = current_runlevel
|
||||
if(cached_runlevel != checking_runlevel)
|
||||
//resechedule subsystems
|
||||
cached_runlevel = checking_runlevel
|
||||
current_runlevel_subsystems = runlevel_sorted_subsystems[cached_runlevel]
|
||||
var/stagger = world.time
|
||||
for(var/I in current_runlevel_subsystems)
|
||||
var/datum/controller/subsystem/SS = I
|
||||
if(SS.next_fire <= world.time)
|
||||
stagger += world.tick_lag * rand(1, 5)
|
||||
SS.next_fire = stagger
|
||||
|
||||
subsystems_to_check = current_runlevel_subsystems
|
||||
else
|
||||
subsystems_to_check = tickersubsystems
|
||||
|
||||
if(CheckQueue(subsystems_to_check) <= 0)
|
||||
if(!SoftReset(tickersubsystems, runlevel_sorted_subsystems))
|
||||
log_to_dd("MC: SoftReset() failed, crashing")
|
||||
return
|
||||
if(!error_level)
|
||||
iteration++
|
||||
error_level++
|
||||
current_ticklimit = TICK_LIMIT_RUNNING
|
||||
sleep(10)
|
||||
continue
|
||||
|
||||
if(queue_head)
|
||||
if(RunQueue() <= 0)
|
||||
if(!SoftReset(tickersubsystems, runlevel_sorted_subsystems))
|
||||
log_to_dd("MC: SoftReset() failed, crashing")
|
||||
return
|
||||
if(!error_level)
|
||||
iteration++
|
||||
error_level++
|
||||
current_ticklimit = TICK_LIMIT_RUNNING
|
||||
sleep(10)
|
||||
continue
|
||||
error_level--
|
||||
if(!queue_head) //reset the counts if the queue is empty, in the off chance they get out of sync
|
||||
queue_priority_count = 0
|
||||
queue_priority_count_bg = 0
|
||||
|
||||
iteration++
|
||||
last_run = world.time
|
||||
src.sleep_delta = MC_AVERAGE_FAST(src.sleep_delta, sleep_delta)
|
||||
current_ticklimit = TICK_LIMIT_RUNNING
|
||||
if(processing * sleep_delta <= world.tick_lag)
|
||||
current_ticklimit -= (TICK_LIMIT_RUNNING * 0.25) //reserve the tail 1/4 of the next tick for the mc if we plan on running next tick
|
||||
sleep(world.tick_lag * (processing * sleep_delta))
|
||||
|
||||
|
||||
|
||||
|
||||
// This is what decides if something should run.
|
||||
/datum/controller/master/proc/CheckQueue(list/subsystemstocheck)
|
||||
. = 0 //so the mc knows if we runtimed
|
||||
|
||||
//we create our variables outside of the loops to save on overhead
|
||||
var/datum/controller/subsystem/SS
|
||||
var/SS_flags
|
||||
|
||||
for(var/thing in subsystemstocheck)
|
||||
if(!thing)
|
||||
subsystemstocheck -= thing
|
||||
SS = thing
|
||||
if(SS.state != SS_IDLE)
|
||||
continue
|
||||
if(SS.can_fire <= 0)
|
||||
continue
|
||||
if(SS.next_fire > world.time)
|
||||
continue
|
||||
SS_flags = SS.flags
|
||||
if(SS_flags & SS_NO_FIRE)
|
||||
subsystemstocheck -= SS
|
||||
continue
|
||||
if((SS_flags & (SS_TICKER|SS_KEEP_TIMING)) == SS_KEEP_TIMING && SS.last_fire + (SS.wait * 0.75) > world.time)
|
||||
continue
|
||||
SS.enqueue()
|
||||
. = 1
|
||||
|
||||
|
||||
// Run thru the queue of subsystems to run, running them while balancing out their allocated tick precentage
|
||||
/datum/controller/master/proc/RunQueue()
|
||||
. = 0
|
||||
var/datum/controller/subsystem/queue_node
|
||||
var/queue_node_flags
|
||||
var/queue_node_priority
|
||||
var/queue_node_paused
|
||||
|
||||
var/current_tick_budget
|
||||
var/tick_precentage
|
||||
var/tick_remaining
|
||||
var/ran = TRUE //this is right
|
||||
var/ran_non_ticker = FALSE
|
||||
var/bg_calc //have we swtiched current_tick_budget to background mode yet?
|
||||
var/tick_usage
|
||||
|
||||
//keep running while we have stuff to run and we haven't gone over a tick
|
||||
// this is so subsystems paused eariler can use tick time that later subsystems never used
|
||||
while(ran && queue_head && TICK_USAGE < TICK_LIMIT_MC)
|
||||
ran = FALSE
|
||||
bg_calc = FALSE
|
||||
current_tick_budget = queue_priority_count
|
||||
queue_node = queue_head
|
||||
while(queue_node)
|
||||
if(ran && TICK_USAGE > TICK_LIMIT_RUNNING)
|
||||
break
|
||||
|
||||
queue_node_flags = queue_node.flags
|
||||
queue_node_priority = queue_node.queued_priority
|
||||
|
||||
//super special case, subsystems where we can't make them pause mid way through
|
||||
//if we can't run them this tick (without going over a tick)
|
||||
//we bump up their priority and attempt to run them next tick
|
||||
//(unless we haven't even ran anything this tick, since its unlikely they will ever be able run
|
||||
// in those cases, so we just let them run)
|
||||
if(queue_node_flags & SS_NO_TICK_CHECK)
|
||||
if(queue_node.tick_usage > TICK_LIMIT_RUNNING - TICK_USAGE && ran_non_ticker)
|
||||
queue_node.queued_priority += queue_priority_count * 0.1
|
||||
queue_priority_count -= queue_node_priority
|
||||
queue_priority_count += queue_node.queued_priority
|
||||
current_tick_budget -= queue_node_priority
|
||||
queue_node = queue_node.queue_next
|
||||
continue
|
||||
|
||||
if((queue_node_flags & SS_BACKGROUND) && !bg_calc)
|
||||
current_tick_budget = queue_priority_count_bg
|
||||
bg_calc = TRUE
|
||||
|
||||
tick_remaining = TICK_LIMIT_RUNNING - TICK_USAGE
|
||||
|
||||
if(current_tick_budget > 0 && queue_node_priority > 0)
|
||||
tick_precentage = tick_remaining / (current_tick_budget / queue_node_priority)
|
||||
else
|
||||
tick_precentage = tick_remaining
|
||||
|
||||
tick_precentage = max(tick_precentage*0.5, tick_precentage - queue_node.tick_overrun)
|
||||
|
||||
current_ticklimit = round(TICK_USAGE + tick_precentage)
|
||||
|
||||
if(!(queue_node_flags & SS_TICKER))
|
||||
ran_non_ticker = TRUE
|
||||
ran = TRUE
|
||||
|
||||
queue_node_paused = (queue_node.state == SS_PAUSED || queue_node.state == SS_PAUSING)
|
||||
last_type_processed = queue_node
|
||||
|
||||
queue_node.state = SS_RUNNING
|
||||
|
||||
tick_usage = TICK_USAGE
|
||||
var/state = queue_node.ignite(queue_node_paused)
|
||||
tick_usage = TICK_USAGE - tick_usage
|
||||
|
||||
if(state == SS_RUNNING)
|
||||
state = SS_IDLE
|
||||
current_tick_budget -= queue_node_priority
|
||||
|
||||
|
||||
if(tick_usage < 0)
|
||||
tick_usage = 0
|
||||
queue_node.tick_overrun = max(0, MC_AVG_FAST_UP_SLOW_DOWN(queue_node.tick_overrun, tick_usage - tick_precentage))
|
||||
queue_node.state = state
|
||||
|
||||
if(state == SS_PAUSED)
|
||||
queue_node.paused_ticks++
|
||||
queue_node.paused_tick_usage += tick_usage
|
||||
queue_node = queue_node.queue_next
|
||||
continue
|
||||
|
||||
queue_node.ticks = MC_AVERAGE(queue_node.ticks, queue_node.paused_ticks)
|
||||
tick_usage += queue_node.paused_tick_usage
|
||||
|
||||
queue_node.tick_usage = MC_AVERAGE_FAST(queue_node.tick_usage, tick_usage)
|
||||
|
||||
queue_node.cost = MC_AVERAGE_FAST(queue_node.cost, TICK_DELTA_TO_MS(tick_usage))
|
||||
queue_node.paused_ticks = 0
|
||||
queue_node.paused_tick_usage = 0
|
||||
|
||||
if(queue_node_flags & SS_BACKGROUND) //update our running total
|
||||
queue_priority_count_bg -= queue_node_priority
|
||||
else
|
||||
queue_priority_count -= queue_node_priority
|
||||
|
||||
queue_node.last_fire = world.time
|
||||
queue_node.times_fired++
|
||||
|
||||
if(queue_node_flags & SS_TICKER)
|
||||
queue_node.next_fire = world.time + (world.tick_lag * queue_node.wait)
|
||||
else if(queue_node_flags & SS_POST_FIRE_TIMING)
|
||||
queue_node.next_fire = world.time + queue_node.wait + (world.tick_lag * (queue_node.tick_overrun / 100))
|
||||
else if(queue_node_flags & SS_KEEP_TIMING)
|
||||
queue_node.next_fire += queue_node.wait
|
||||
else
|
||||
queue_node.next_fire = queue_node.queued_time + queue_node.wait + (world.tick_lag * (queue_node.tick_overrun / 100))
|
||||
|
||||
queue_node.queued_time = 0
|
||||
|
||||
//remove from queue
|
||||
queue_node.dequeue()
|
||||
|
||||
queue_node = queue_node.queue_next
|
||||
|
||||
. = 1
|
||||
|
||||
//resets the queue, and all subsystems, while filtering out the subsystem lists
|
||||
// called if any mc's queue procs runtime or exit improperly.
|
||||
/datum/controller/master/proc/SoftReset(list/ticker_SS, list/runlevel_SS)
|
||||
. = 0
|
||||
log_to_dd("MC: SoftReset called, resetting MC queue state.")
|
||||
if(!istype(subsystems) || !istype(ticker_SS) || !istype(runlevel_SS))
|
||||
log_to_dd("MC: SoftReset: Bad list contents: '[subsystems]' '[ticker_SS]' '[runlevel_SS]'")
|
||||
return
|
||||
var/subsystemstocheck = subsystems + ticker_SS
|
||||
for(var/I in runlevel_SS)
|
||||
subsystemstocheck |= I
|
||||
|
||||
for(var/thing in subsystemstocheck)
|
||||
var/datum/controller/subsystem/SS = thing
|
||||
if(!SS || !istype(SS))
|
||||
//list(SS) is so if a list makes it in the subsystem list, we remove the list, not the contents
|
||||
subsystems -= list(SS)
|
||||
ticker_SS -= list(SS)
|
||||
for(var/I in runlevel_SS)
|
||||
I -= list(SS)
|
||||
log_to_dd("MC: SoftReset: Found bad entry in subsystem list, '[SS]'")
|
||||
continue
|
||||
if(SS.queue_next && !istype(SS.queue_next))
|
||||
log_to_dd("MC: SoftReset: Found bad data in subsystem queue, queue_next = '[SS.queue_next]'")
|
||||
SS.queue_next = null
|
||||
if(SS.queue_prev && !istype(SS.queue_prev))
|
||||
log_to_dd("MC: SoftReset: Found bad data in subsystem queue, queue_prev = '[SS.queue_prev]'")
|
||||
SS.queue_prev = null
|
||||
SS.queued_priority = 0
|
||||
SS.queued_time = 0
|
||||
SS.state = SS_IDLE
|
||||
if(queue_head && !istype(queue_head))
|
||||
log_to_dd("MC: SoftReset: Found bad data in subsystem queue, queue_head = '[queue_head]'")
|
||||
queue_head = null
|
||||
if(queue_tail && !istype(queue_tail))
|
||||
log_to_dd("MC: SoftReset: Found bad data in subsystem queue, queue_tail = '[queue_tail]'")
|
||||
queue_tail = null
|
||||
queue_priority_count = 0
|
||||
queue_priority_count_bg = 0
|
||||
log_to_dd("MC: SoftReset: Finished.")
|
||||
. = 1
|
||||
|
||||
|
||||
|
||||
/datum/controller/master/stat_entry()
|
||||
if(!statclick)
|
||||
statclick = new/obj/effect/statclick/debug(src, "Initializing...")
|
||||
|
||||
stat("Byond", "(FPS:[world.fps]) (TickCount:[world.time/world.tick_lag]) (TickDrift:[round(Master.tickdrift,1)]([round((Master.tickdrift/(world.time/world.tick_lag))*100,0.1)]%))")
|
||||
stat("Master Controller", statclick.update("(TickRate:[Master.processing]) (Iteration:[Master.iteration])"))
|
||||
|
||||
// Currently unimplemented
|
||||
/datum/controller/master/StartLoadingMap()
|
||||
//disallow more than one map to load at once, multithreading it will just cause race conditions
|
||||
while(map_loading)
|
||||
stoplag()
|
||||
for(var/S in subsystems)
|
||||
var/datum/controller/subsystem/SS = S
|
||||
SS.StartLoadingMap()
|
||||
map_loading = TRUE
|
||||
|
||||
/datum/controller/master/StopLoadingMap(bounds = null)
|
||||
map_loading = FALSE
|
||||
for(var/S in subsystems)
|
||||
var/datum/controller/subsystem/SS = S
|
||||
SS.StopLoadingMap()
|
||||
|
||||
|
||||
/datum/controller/master/proc/UpdateTickRate()
|
||||
if(!processing)
|
||||
return
|
||||
var/client_count = length(clients)
|
||||
if(client_count < config.disable_high_pop_mc_mode_amount)
|
||||
processing = config.base_mc_tick_rate
|
||||
else if(client_count > config.high_pop_mc_mode_amount)
|
||||
processing = config.high_pop_mc_tick_rate
|
||||
@@ -1,6 +1,6 @@
|
||||
//simplified MC that is designed to fail when procs 'break'. When it fails it's just replaced with a new one.
|
||||
//It ensures master_controller.process() is never doubled up by killing the MC (hence terminating any of its sleeping procs)
|
||||
//WIP, needs lots of work still
|
||||
// old deprecated rusted piece of shit MC
|
||||
// All this does now is misc. world init stuff because too lazy to put it somewhere else
|
||||
// It used to run all of the repeating processes controlling the game but now the SMC and Process Scheduler do that
|
||||
|
||||
var/global/datum/controller/game_controller/master_controller //Set in world.New()
|
||||
|
||||
@@ -10,16 +10,6 @@ var/global/last_tick_duration = 0
|
||||
var/global/air_processing_killed = 0
|
||||
var/global/pipe_processing_killed = 0
|
||||
|
||||
/datum/controller
|
||||
var/processing = 0
|
||||
var/iteration = 0
|
||||
var/processing_interval = 0
|
||||
|
||||
// Dummy object to let us click it to debug while in the stat panel
|
||||
var/obj/effect/statclick/debug/statclick
|
||||
|
||||
/datum/controller/proc/recover() // If we are replacing an existing controller (due to a crash) we attempt to preserve as much as we can.
|
||||
|
||||
/datum/controller/game_controller
|
||||
var/list/shuttle_list // For debugging and VV
|
||||
|
||||
@@ -46,8 +36,6 @@ var/global/pipe_processing_killed = 0
|
||||
return QDEL_HINT_HARDDEL_NOW
|
||||
|
||||
/datum/controller/game_controller/proc/setup()
|
||||
world.tick_lag = config.Ticklag
|
||||
|
||||
preloadTemplates()
|
||||
if(!config.disable_away_missions)
|
||||
createRandomZlevel()
|
||||
@@ -94,26 +82,4 @@ var/global/pipe_processing_killed = 0
|
||||
count++
|
||||
log_startup_progress(" Initialized [count] objects in [stop_watch(watch)]s.")
|
||||
|
||||
watch = start_watch()
|
||||
count = 0
|
||||
log_startup_progress("Initializing atmospherics machinery...")
|
||||
for(var/obj/machinery/atmospherics/unary/U in machines)
|
||||
if(istype(U, /obj/machinery/atmospherics/unary/vent_pump))
|
||||
var/obj/machinery/atmospherics/unary/vent_pump/T = U
|
||||
T.broadcast_status()
|
||||
count++
|
||||
else if(istype(U, /obj/machinery/atmospherics/unary/vent_scrubber))
|
||||
var/obj/machinery/atmospherics/unary/vent_scrubber/T = U
|
||||
T.broadcast_status()
|
||||
count++
|
||||
log_startup_progress(" Initialized [count] atmospherics machines in [stop_watch(watch)]s.")
|
||||
|
||||
watch = start_watch()
|
||||
count = 0
|
||||
log_startup_progress("Initializing pipe networks...")
|
||||
for(var/obj/machinery/atmospherics/machine in machines)
|
||||
machine.build_network()
|
||||
count++
|
||||
log_startup_progress(" Initialized [count] pipes in [stop_watch(watch)]s.")
|
||||
|
||||
log_startup_progress("Finished object initializations in [stop_watch(overwatch)]s.")
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
|
||||
/datum/controller/subsystem
|
||||
// Metadata; you should define these.
|
||||
name = "fire coderbus" //name of the subsystem
|
||||
var/init_order = INIT_ORDER_DEFAULT //order of initialization. Higher numbers are initialized first, lower numbers later. Use defines in __DEFINES/subsystems.dm for easy understanding of order.
|
||||
var/wait = 20 //time to wait (in deciseconds) between each call to fire(). Must be a positive integer.
|
||||
var/priority = FIRE_PRIORITY_DEFAULT //When mutiple subsystems need to run in the same tick, higher priority subsystems will run first and be given a higher share of the tick before MC_TICK_CHECK triggers a sleep
|
||||
|
||||
var/flags = 0 //see MC.dm in __DEFINES Most flags must be set on world start to take full effect. (You can also restart the mc to force them to process again)
|
||||
|
||||
var/initialized = FALSE //set to TRUE after it has been initialized, will obviously never be set if the subsystem doesn't initialize
|
||||
|
||||
//set to 0 to prevent fire() calls, mostly for admin use or subsystems that may be resumed later
|
||||
// use the SS_NO_FIRE flag instead for systems that never fire to keep it from even being added to the list
|
||||
var/can_fire = TRUE
|
||||
|
||||
// Bookkeeping variables; probably shouldn't mess with these.
|
||||
var/last_fire = 0 //last world.time we called fire()
|
||||
var/next_fire = 0 //scheduled world.time for next fire()
|
||||
var/cost = 0 //average time to execute
|
||||
var/tick_usage = 0 //average tick usage
|
||||
var/tick_overrun = 0 //average tick overrun
|
||||
var/state = SS_IDLE //tracks the current state of the ss, running, paused, etc.
|
||||
var/paused_ticks = 0 //ticks this ss is taking to run right now.
|
||||
var/paused_tick_usage //total tick_usage of all of our runs while pausing this run
|
||||
var/ticks = 1 //how many ticks does this ss take to run on avg.
|
||||
var/times_fired = 0 //number of times we have called fire()
|
||||
var/queued_time = 0 //time we entered the queue, (for timing and priority reasons)
|
||||
var/queued_priority //we keep a running total to make the math easier, if priority changes mid-fire that would break our running total, so we store it here
|
||||
//linked list stuff for the queue
|
||||
var/datum/controller/subsystem/queue_next
|
||||
var/datum/controller/subsystem/queue_prev
|
||||
|
||||
var/runlevels = RUNLEVELS_DEFAULT //points of the game at which the SS can fire
|
||||
|
||||
var/static/list/failure_strikes //How many times we suspect a subsystem type has crashed the MC, 3 strikes and you're out!
|
||||
|
||||
//Do not override
|
||||
///datum/controller/subsystem/New()
|
||||
|
||||
// Used to initialize the subsystem BEFORE the map has loaded
|
||||
// Called AFTER Recover if that is called
|
||||
// Prefer to use Initialize if possible
|
||||
/datum/controller/subsystem/proc/PreInit()
|
||||
return
|
||||
|
||||
//This is used so the mc knows when the subsystem sleeps. do not override.
|
||||
/datum/controller/subsystem/proc/ignite(resumed = 0)
|
||||
set waitfor = 0
|
||||
. = SS_SLEEPING
|
||||
fire(resumed)
|
||||
. = state
|
||||
if(state == SS_SLEEPING)
|
||||
state = SS_IDLE
|
||||
if(state == SS_PAUSING)
|
||||
var/QT = queued_time
|
||||
enqueue()
|
||||
state = SS_PAUSED
|
||||
queued_time = QT
|
||||
|
||||
//previously, this would have been named 'process()' but that name is used everywhere for different things!
|
||||
//fire() seems more suitable. This is the procedure that gets called every 'wait' deciseconds.
|
||||
//Sleeping in here prevents future fires until returned.
|
||||
/datum/controller/subsystem/proc/fire(resumed = 0)
|
||||
flags |= SS_NO_FIRE
|
||||
throw EXCEPTION("Subsystem [src]([type]) does not fire() but did not set the SS_NO_FIRE flag. Please add the SS_NO_FIRE flag to any subsystem that doesn't fire so it doesn't get added to the processing list and waste cpu.")
|
||||
|
||||
/datum/controller/subsystem/Destroy()
|
||||
dequeue()
|
||||
can_fire = 0
|
||||
flags |= SS_NO_FIRE
|
||||
Master.subsystems -= src
|
||||
return ..()
|
||||
|
||||
//Queue it to run.
|
||||
// (we loop thru a linked list until we get to the end or find the right point)
|
||||
// (this lets us sort our run order correctly without having to re-sort the entire already sorted list)
|
||||
/datum/controller/subsystem/proc/enqueue()
|
||||
var/SS_priority = priority
|
||||
var/SS_flags = flags
|
||||
var/datum/controller/subsystem/queue_node
|
||||
var/queue_node_priority
|
||||
var/queue_node_flags
|
||||
|
||||
for(queue_node = Master.queue_head; queue_node; queue_node = queue_node.queue_next)
|
||||
queue_node_priority = queue_node.queued_priority
|
||||
queue_node_flags = queue_node.flags
|
||||
|
||||
if(queue_node_flags & SS_TICKER)
|
||||
if(!(SS_flags & SS_TICKER))
|
||||
continue
|
||||
if(queue_node_priority < SS_priority)
|
||||
break
|
||||
|
||||
else if(queue_node_flags & SS_BACKGROUND)
|
||||
if(!(SS_flags & SS_BACKGROUND))
|
||||
break
|
||||
if(queue_node_priority < SS_priority)
|
||||
break
|
||||
|
||||
else
|
||||
if(SS_flags & SS_BACKGROUND)
|
||||
continue
|
||||
if(SS_flags & SS_TICKER)
|
||||
break
|
||||
if(queue_node_priority < SS_priority)
|
||||
break
|
||||
|
||||
queued_time = world.time
|
||||
queued_priority = SS_priority
|
||||
state = SS_QUEUED
|
||||
if(SS_flags & SS_BACKGROUND) //update our running total
|
||||
Master.queue_priority_count_bg += SS_priority
|
||||
else
|
||||
Master.queue_priority_count += SS_priority
|
||||
|
||||
queue_next = queue_node
|
||||
if(!queue_node)//we stopped at the end, add to tail
|
||||
queue_prev = Master.queue_tail
|
||||
if(Master.queue_tail)
|
||||
Master.queue_tail.queue_next = src
|
||||
else //empty queue, we also need to set the head
|
||||
Master.queue_head = src
|
||||
Master.queue_tail = src
|
||||
|
||||
else if(queue_node == Master.queue_head)//insert at start of list
|
||||
Master.queue_head.queue_prev = src
|
||||
Master.queue_head = src
|
||||
queue_prev = null
|
||||
else
|
||||
queue_node.queue_prev.queue_next = src
|
||||
queue_prev = queue_node.queue_prev
|
||||
queue_node.queue_prev = src
|
||||
|
||||
|
||||
/datum/controller/subsystem/proc/dequeue()
|
||||
if(queue_next)
|
||||
queue_next.queue_prev = queue_prev
|
||||
if(queue_prev)
|
||||
queue_prev.queue_next = queue_next
|
||||
if(src == Master.queue_tail)
|
||||
Master.queue_tail = queue_prev
|
||||
if(src == Master.queue_head)
|
||||
Master.queue_head = queue_next
|
||||
queued_time = 0
|
||||
if(state == SS_QUEUED)
|
||||
state = SS_IDLE
|
||||
|
||||
|
||||
/datum/controller/subsystem/proc/pause()
|
||||
. = 1
|
||||
switch(state)
|
||||
if(SS_RUNNING)
|
||||
state = SS_PAUSED
|
||||
if(SS_SLEEPING)
|
||||
state = SS_PAUSING
|
||||
|
||||
|
||||
//used to initialize the subsystem AFTER the map has loaded
|
||||
/datum/controller/subsystem/Initialize(start_timeofday)
|
||||
initialized = TRUE
|
||||
var/time = (REALTIMEOFDAY - start_timeofday) / 10
|
||||
var/msg = "Initialized [name] subsystem within [time] second[time == 1 ? "" : "s"]!"
|
||||
to_chat(world, "<span class='boldannounce'>[msg]</span>")
|
||||
log_to_dd(msg)
|
||||
return time
|
||||
|
||||
//hook for printing stats to the "MC" statuspanel for admins to see performance and related stats etc.
|
||||
/datum/controller/subsystem/stat_entry(msg)
|
||||
if(!statclick)
|
||||
statclick = new/obj/effect/statclick/debug(src, "Initializing...")
|
||||
|
||||
if(can_fire && !(SS_NO_FIRE & flags))
|
||||
msg = "[round(cost, 1)]ms|[round(tick_usage, 1)]%([round(tick_overrun, 1)]%)|[round(ticks, 0.1)]\t[msg]"
|
||||
else
|
||||
msg = "OFFLINE\t[msg]"
|
||||
|
||||
var/title = name
|
||||
if(can_fire)
|
||||
title = "\[[state_letter()]][title]"
|
||||
|
||||
stat(title, statclick.update(msg))
|
||||
|
||||
/datum/controller/subsystem/proc/state_letter()
|
||||
switch(state)
|
||||
if(SS_RUNNING)
|
||||
. = "R"
|
||||
if(SS_QUEUED)
|
||||
. = "Q"
|
||||
if(SS_PAUSED, SS_PAUSING)
|
||||
. = "P"
|
||||
if(SS_SLEEPING)
|
||||
. = "S"
|
||||
if(SS_IDLE)
|
||||
. = " "
|
||||
|
||||
//could be used to postpone a costly subsystem for (default one) var/cycles, cycles
|
||||
//for instance, during cpu intensive operations like explosions
|
||||
/datum/controller/subsystem/proc/postpone(cycles = 1)
|
||||
if(next_fire - world.time < wait)
|
||||
next_fire += (wait*cycles)
|
||||
|
||||
//usually called via datum/controller/subsystem/New() when replacing a subsystem (i.e. due to a recurring crash)
|
||||
//should attempt to salvage what it can from the old instance of subsystem
|
||||
/datum/controller/subsystem/Recover()
|
||||
|
||||
/datum/controller/subsystem/vv_edit_var(var_name, var_value)
|
||||
switch(var_name)
|
||||
if("can_fire")
|
||||
//this is so the subsystem doesn't rapid fire to make up missed ticks causing more lag
|
||||
if(var_value)
|
||||
next_fire = world.time + wait
|
||||
if("queued_priority") //editing this breaks things.
|
||||
return 0
|
||||
. = ..()
|
||||
@@ -0,0 +1,370 @@
|
||||
#define SSAIR_DEFERREDPIPENETS 1
|
||||
#define SSAIR_PIPENETS 2
|
||||
#define SSAIR_ATMOSMACHINERY 3
|
||||
#define SSAIR_ACTIVETURFS 4
|
||||
#define SSAIR_EXCITEDGROUPS 5
|
||||
#define SSAIR_HIGHPRESSURE 6
|
||||
#define SSAIR_HOTSPOTS 7
|
||||
#define SSAIR_SUPERCONDUCTIVITY 8
|
||||
|
||||
SUBSYSTEM_DEF(air)
|
||||
name = "Atmospherics"
|
||||
init_order = INIT_ORDER_AIR
|
||||
priority = FIRE_PRIORITY_AIR
|
||||
wait = 5
|
||||
flags = SS_BACKGROUND
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
|
||||
var/cost_turfs = 0
|
||||
var/cost_groups = 0
|
||||
var/cost_highpressure = 0
|
||||
var/cost_hotspots = 0
|
||||
var/cost_superconductivity = 0
|
||||
var/cost_pipenets = 0
|
||||
var/cost_deferred_pipenets = 0
|
||||
var/cost_atmos_machinery = 0
|
||||
|
||||
var/list/excited_groups = list()
|
||||
var/list/active_turfs = list()
|
||||
var/list/hotspots = list()
|
||||
var/list/networks = list()
|
||||
var/list/atmos_machinery = list()
|
||||
var/list/pipe_init_dirs_cache = list()
|
||||
|
||||
|
||||
|
||||
//Special functions lists
|
||||
var/list/active_super_conductivity = list()
|
||||
var/list/high_pressure_delta = list()
|
||||
|
||||
|
||||
var/list/currentrun = list()
|
||||
var/currentpart = SSAIR_PIPENETS
|
||||
|
||||
/datum/controller/subsystem/air/stat_entry(msg)
|
||||
msg += "C:{"
|
||||
msg += "AT:[round(cost_turfs,1)]|"
|
||||
msg += "EG:[round(cost_groups,1)]|"
|
||||
msg += "HP:[round(cost_highpressure,1)]|"
|
||||
msg += "HS:[round(cost_hotspots,1)]|"
|
||||
msg += "SC:[round(cost_superconductivity,1)]|"
|
||||
msg += "PN:[round(cost_pipenets,1)]|"
|
||||
msg += "DPN:[round(cost_deferred_pipenets,1)]|"
|
||||
msg += "AM:[round(cost_atmos_machinery,1)]"
|
||||
msg += "} "
|
||||
msg += "AT:[active_turfs.len]|"
|
||||
msg += "EG:[excited_groups.len]|"
|
||||
msg += "HS:[hotspots.len]|"
|
||||
msg += "PN:[networks.len]|"
|
||||
msg += "HP:[high_pressure_delta.len]|"
|
||||
msg += "AS:[active_super_conductivity.len]|"
|
||||
msg += "AT/MS:[round((cost ? active_turfs.len/cost : 0),0.1)]"
|
||||
..(msg)
|
||||
|
||||
|
||||
/datum/controller/subsystem/air/Initialize(timeofday)
|
||||
setup_overlays() // Assign icons and such for gas-turf-overlays
|
||||
setup_allturfs()
|
||||
setup_atmos_machinery()
|
||||
setup_pipenets()
|
||||
..()
|
||||
|
||||
|
||||
/datum/controller/subsystem/air/fire(resumed = 0)
|
||||
var/timer = TICK_USAGE_REAL
|
||||
|
||||
if(currentpart == SSAIR_DEFERREDPIPENETS || !resumed)
|
||||
process_deferred_pipenets(resumed)
|
||||
cost_deferred_pipenets = MC_AVERAGE(cost_deferred_pipenets, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_PIPENETS
|
||||
|
||||
if(currentpart == SSAIR_PIPENETS || !resumed)
|
||||
process_pipenets(resumed)
|
||||
cost_pipenets = MC_AVERAGE(cost_pipenets, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_ATMOSMACHINERY
|
||||
|
||||
if(currentpart == SSAIR_ATMOSMACHINERY)
|
||||
timer = TICK_USAGE_REAL
|
||||
process_atmos_machinery(resumed)
|
||||
cost_atmos_machinery = MC_AVERAGE(cost_atmos_machinery, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_ACTIVETURFS
|
||||
|
||||
if(currentpart == SSAIR_ACTIVETURFS)
|
||||
timer = TICK_USAGE_REAL
|
||||
process_active_turfs(resumed)
|
||||
cost_turfs = MC_AVERAGE(cost_turfs, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_EXCITEDGROUPS
|
||||
|
||||
if(currentpart == SSAIR_EXCITEDGROUPS)
|
||||
timer = TICK_USAGE_REAL
|
||||
process_excited_groups(resumed)
|
||||
cost_groups = MC_AVERAGE(cost_groups, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_HIGHPRESSURE
|
||||
|
||||
if(currentpart == SSAIR_HIGHPRESSURE)
|
||||
timer = TICK_USAGE_REAL
|
||||
process_high_pressure_delta(resumed)
|
||||
cost_highpressure = MC_AVERAGE(cost_highpressure, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_HOTSPOTS
|
||||
|
||||
if(currentpart == SSAIR_HOTSPOTS)
|
||||
timer = TICK_USAGE_REAL
|
||||
process_hotspots(resumed)
|
||||
cost_hotspots = MC_AVERAGE(cost_hotspots, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_SUPERCONDUCTIVITY
|
||||
|
||||
if(currentpart == SSAIR_SUPERCONDUCTIVITY)
|
||||
timer = TICK_USAGE_REAL
|
||||
process_super_conductivity(resumed)
|
||||
cost_superconductivity = MC_AVERAGE(cost_superconductivity, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
||||
if(state != SS_RUNNING)
|
||||
return
|
||||
resumed = 0
|
||||
currentpart = SSAIR_PIPENETS
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_deferred_pipenets(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = deferred_pipenet_rebuilds.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/obj/machinery/atmospherics/A = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(A)
|
||||
A.build_network()
|
||||
else
|
||||
deferred_pipenet_rebuilds.Remove(A)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_pipenets(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = networks.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/datum/pipeline/thing = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(thing)
|
||||
thing.process()
|
||||
else
|
||||
networks.Remove(thing)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_atmos_machinery(resumed = 0)
|
||||
var/seconds = wait * 0.1
|
||||
if(!resumed)
|
||||
src.currentrun = atmos_machinery.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/obj/machinery/M = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(!M || (M.process_atmos(seconds) == PROCESS_KILL))
|
||||
atmos_machinery.Remove(M)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_super_conductivity(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = active_super_conductivity.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/turf/simulated/T = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
T.super_conduct()
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_hotspots(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = hotspots.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/obj/effect/hotspot/H = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(H)
|
||||
H.process()
|
||||
else
|
||||
hotspots -= H
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_high_pressure_delta(resumed = 0)
|
||||
while(high_pressure_delta.len)
|
||||
var/turf/simulated/T = high_pressure_delta[high_pressure_delta.len]
|
||||
high_pressure_delta.len--
|
||||
T.high_pressure_movements()
|
||||
T.pressure_difference = 0
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_active_turfs(resumed = 0)
|
||||
//cache for sanic speed
|
||||
var/fire_count = times_fired
|
||||
if(!resumed)
|
||||
src.currentrun = active_turfs.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/turf/simulated/T = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(T)
|
||||
T.process_cell(fire_count)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/process_excited_groups(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = excited_groups.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/datum/excited_group/EG = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
EG.breakdown_cooldown++
|
||||
if(EG.breakdown_cooldown == 10)
|
||||
EG.self_breakdown()
|
||||
else if(EG.breakdown_cooldown >= 20)
|
||||
EG.dismantle()
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
/datum/controller/subsystem/air/proc/remove_from_active(turf/simulated/T)
|
||||
active_turfs -= T
|
||||
active_super_conductivity -= T // bug: if a turf is hit by ex_act 1 while processing, it can end up in super conductivity as /turf/space and cause runtimes
|
||||
if(currentpart == SSAIR_ACTIVETURFS || currentpart == SSAIR_SUPERCONDUCTIVITY)
|
||||
currentrun -= T
|
||||
if(istype(T))
|
||||
T.excited = 0
|
||||
if(T.excited_group)
|
||||
T.excited_group.garbage_collect()
|
||||
|
||||
/datum/controller/subsystem/air/proc/add_to_active(turf/simulated/T, blockchanges = 1)
|
||||
if(istype(T) && T.air)
|
||||
T.excited = 1
|
||||
active_turfs |= T
|
||||
if(currentpart == SSAIR_ACTIVETURFS)
|
||||
currentrun |= T
|
||||
if(blockchanges && T.excited_group)
|
||||
T.excited_group.garbage_collect()
|
||||
else
|
||||
for(var/direction in cardinal)
|
||||
if(!(T.atmos_adjacent_turfs & direction))
|
||||
continue
|
||||
var/turf/simulated/S = get_step(T, direction)
|
||||
if(istype(S))
|
||||
add_to_active(S)
|
||||
|
||||
/datum/controller/subsystem/air/proc/setup_allturfs(var/list/turfs_to_init = block(locate(1, 1, 1), locate(world.maxx, world.maxy, world.maxz)))
|
||||
var/list/active_turfs = src.active_turfs
|
||||
|
||||
for(var/thing in turfs_to_init)
|
||||
var/turf/T = thing
|
||||
active_turfs -= T
|
||||
if(T.blocks_air)
|
||||
continue
|
||||
T.Initialize_Atmos(times_fired)
|
||||
CHECK_TICK
|
||||
|
||||
/turf/simulated/proc/resolve_active_graph()
|
||||
. = list()
|
||||
var/datum/excited_group/EG = excited_group
|
||||
if(blocks_air || !air)
|
||||
return
|
||||
if(!EG)
|
||||
EG = new
|
||||
EG.add_turf(src)
|
||||
|
||||
for(var/turf/simulated/ET in atmos_adjacent_turfs)
|
||||
if(ET.blocks_air || !ET.air)
|
||||
continue
|
||||
|
||||
var/ET_EG = ET.excited_group
|
||||
if(ET_EG)
|
||||
if(ET_EG != EG)
|
||||
EG.merge_groups(ET_EG)
|
||||
EG = excited_group //merge_groups() may decide to replace our current EG
|
||||
else
|
||||
EG.add_turf(ET)
|
||||
if(!ET.excited)
|
||||
ET.excited = 1
|
||||
. += ET
|
||||
|
||||
/datum/controller/subsystem/air/proc/setup_atmos_machinery()
|
||||
var/watch = start_watch()
|
||||
var/count = 0
|
||||
log_startup_progress("Initializing atmospherics machinery...")
|
||||
for(var/obj/machinery/atmospherics/unary/U in machines)
|
||||
if(istype(U, /obj/machinery/atmospherics/unary/vent_pump))
|
||||
var/obj/machinery/atmospherics/unary/vent_pump/T = U
|
||||
T.broadcast_status()
|
||||
count++
|
||||
else if(istype(U, /obj/machinery/atmospherics/unary/vent_scrubber))
|
||||
var/obj/machinery/atmospherics/unary/vent_scrubber/T = U
|
||||
T.broadcast_status()
|
||||
count++
|
||||
log_startup_progress(" Initialized [count] atmospherics machines in [stop_watch(watch)]s.")
|
||||
|
||||
//this can't be done with setup_atmos_machinery() because
|
||||
// all atmos machinery has to initalize before the first
|
||||
// pipenet can be built.
|
||||
/datum/controller/subsystem/air/proc/setup_pipenets()
|
||||
var/watch = start_watch()
|
||||
var/count = 0
|
||||
log_startup_progress("Initializing pipe networks...")
|
||||
for(var/obj/machinery/atmospherics/machine in machines)
|
||||
machine.build_network()
|
||||
count++
|
||||
log_startup_progress(" Initialized [count] pipes in [stop_watch(watch)]s.")
|
||||
|
||||
/datum/controller/subsystem/air/proc/setup_overlays()
|
||||
plmaster = new /obj/effect/overlay()
|
||||
plmaster.icon = 'icons/effects/tile_effects.dmi'
|
||||
plmaster.icon_state = "plasma"
|
||||
plmaster.layer = FLY_LAYER
|
||||
plmaster.mouse_opacity = 0
|
||||
|
||||
slmaster = new /obj/effect/overlay()
|
||||
slmaster.icon = 'icons/effects/tile_effects.dmi'
|
||||
slmaster.icon_state = "sleeping_agent"
|
||||
slmaster.layer = FLY_LAYER
|
||||
slmaster.mouse_opacity = 0
|
||||
|
||||
icemaster = new /obj/effect/overlay()
|
||||
icemaster.icon = 'icons/turf/overlays.dmi'
|
||||
icemaster.icon_state = "snowfloor"
|
||||
icemaster.layer = TURF_LAYER + 0.1
|
||||
icemaster.mouse_opacity = 0
|
||||
|
||||
#undef SSAIR_PIPENETS
|
||||
#undef SSAIR_ATMOSMACHINERY
|
||||
#undef SSAIR_ACTIVETURFS
|
||||
#undef SSAIR_EXCITEDGROUPS
|
||||
#undef SSAIR_HIGHPRESSURE
|
||||
#undef SSAIR_HOTSPOT
|
||||
#undef SSAIR_SUPERCONDUCTIVITY
|
||||
@@ -0,0 +1,37 @@
|
||||
SUBSYSTEM_DEF(fires)
|
||||
name = "Fires"
|
||||
priority = FIRE_PRIOTITY_BURNING
|
||||
flags = SS_NO_INIT|SS_BACKGROUND
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
|
||||
var/list/currentrun = list()
|
||||
var/list/processing = list()
|
||||
|
||||
/datum/controller/subsystem/fires/stat_entry()
|
||||
..("P:[processing.len]")
|
||||
|
||||
|
||||
/datum/controller/subsystem/fires/fire(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = processing.Copy()
|
||||
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
|
||||
while(currentrun.len)
|
||||
var/obj/O = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(!O || qdeleted(O))
|
||||
processing -= O
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
continue
|
||||
|
||||
if(O.burn_state == ON_FIRE)
|
||||
if(O.burn_world_time < world.time)
|
||||
O.burn()
|
||||
else
|
||||
processing -= O
|
||||
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
@@ -0,0 +1,33 @@
|
||||
SUBSYSTEM_DEF(nanoui)
|
||||
name = "Nanoui"
|
||||
wait = 9
|
||||
flags = SS_NO_INIT
|
||||
priority = FIRE_PRIORITY_NANOUI
|
||||
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
|
||||
|
||||
var/list/currentrun = list()
|
||||
var/list/open_uis = list() // A list of open UIs, grouped by src_object and ui_key.
|
||||
var/list/processing_uis = list() // A list of processing UIs, ungrouped.
|
||||
|
||||
/datum/controller/subsystem/nanoui/Shutdown()
|
||||
close_all_uis()
|
||||
|
||||
/datum/controller/subsystem/nanoui/stat_entry()
|
||||
..("P:[processing_uis.len]")
|
||||
|
||||
/datum/controller/subsystem/nanoui/fire(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = processing_uis.Copy()
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
|
||||
while(currentrun.len)
|
||||
var/datum/nanoui/ui = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(ui && ui.user && ui.src_object)
|
||||
ui.process()
|
||||
else
|
||||
processing_uis.Remove(ui)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
SUBSYSTEM_DEF(spacedrift)
|
||||
name = "Space Drift"
|
||||
priority = FIRE_PRIORITY_SPACEDRIFT
|
||||
wait = 5
|
||||
flags = SS_NO_INIT|SS_KEEP_TIMING
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
|
||||
var/list/currentrun = list()
|
||||
var/list/processing = list()
|
||||
|
||||
/datum/controller/subsystem/spacedrift/stat_entry()
|
||||
..("P:[processing.len]")
|
||||
|
||||
|
||||
/datum/controller/subsystem/spacedrift/fire(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = processing.Copy()
|
||||
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
|
||||
while(currentrun.len)
|
||||
var/atom/movable/AM = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(!AM)
|
||||
processing -= AM
|
||||
if (MC_TICK_CHECK)
|
||||
return
|
||||
continue
|
||||
|
||||
if(AM.inertia_next_move > world.time)
|
||||
if (MC_TICK_CHECK)
|
||||
return
|
||||
continue
|
||||
|
||||
if(!AM.loc || AM.loc != AM.inertia_last_loc || AM.Process_Spacemove(0))
|
||||
AM.inertia_dir = 0
|
||||
|
||||
if(!AM.inertia_dir)
|
||||
AM.inertia_last_loc = null
|
||||
processing -= AM
|
||||
if (MC_TICK_CHECK)
|
||||
return
|
||||
continue
|
||||
|
||||
var/old_dir = AM.dir
|
||||
var/old_loc = AM.loc
|
||||
AM.inertia_moving = TRUE
|
||||
step(AM, AM.inertia_dir)
|
||||
AM.inertia_moving = FALSE
|
||||
AM.inertia_next_move = world.time + AM.inertia_move_delay
|
||||
if(AM.loc == old_loc)
|
||||
AM.inertia_dir = 0
|
||||
|
||||
AM.setDir(old_dir)
|
||||
AM.inertia_last_loc = AM.loc
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
SUBSYSTEM_DEF(sun)
|
||||
name = "Sun"
|
||||
wait = 600
|
||||
flags = SS_NO_TICK_CHECK|SS_NO_INIT
|
||||
var/angle
|
||||
var/dx
|
||||
var/dy
|
||||
var/rate
|
||||
var/list/solars = list()
|
||||
|
||||
/datum/controller/subsystem/sun/PreInit()
|
||||
angle = rand (0,360) // the station position to the sun is randomised at round start
|
||||
rate = rand(50,200)/100 // 50% - 200% of standard rotation
|
||||
if(prob(50)) // same chance to rotate clockwise than counter-clockwise
|
||||
rate = -rate
|
||||
|
||||
/datum/controller/subsystem/sun/stat_entry(msg)
|
||||
..("P:[solars.len]")
|
||||
|
||||
/datum/controller/subsystem/sun/fire()
|
||||
angle = (360 + angle + rate * 6) % 360 // increase/decrease the angle to the sun, adjusted by the rate
|
||||
|
||||
// now calculate and cache the (dx,dy) increments for line drawing
|
||||
var/s = sin(angle)
|
||||
var/c = cos(angle)
|
||||
|
||||
// Either "abs(s) < abs(c)" or "abs(s) >= abs(c)"
|
||||
// In both cases, the greater is greater than 0, so, no "if 0" check is needed for the divisions
|
||||
|
||||
if(abs(s) < abs(c))
|
||||
dx = s / abs(c)
|
||||
dy = c / abs(c)
|
||||
else
|
||||
dx = s / abs(s)
|
||||
dy = c / abs(s)
|
||||
|
||||
//now tell the solar control computers to update their status and linked devices
|
||||
for(var/obj/machinery/power/solar_control/SC in solars)
|
||||
if(!SC.powernet)
|
||||
solars.Remove(SC)
|
||||
continue
|
||||
SC.update()
|
||||
@@ -0,0 +1,148 @@
|
||||
#define MAX_THROWING_DIST 512 // 2 z-levels on default width
|
||||
#define MAX_TICKS_TO_MAKE_UP 3 //how many missed ticks will we attempt to make up for this run.
|
||||
|
||||
SUBSYSTEM_DEF(throwing)
|
||||
name = "Throwing"
|
||||
priority = FIRE_PRIORITY_THROWING
|
||||
wait = 1
|
||||
flags = SS_NO_INIT|SS_KEEP_TIMING|SS_TICKER
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
|
||||
var/list/currentrun
|
||||
var/list/processing = list()
|
||||
|
||||
/datum/controller/subsystem/throwing/stat_entry()
|
||||
..("P:[processing.len]")
|
||||
|
||||
/datum/controller/subsystem/throwing/fire(resumed = 0)
|
||||
if(!resumed)
|
||||
src.currentrun = processing.Copy()
|
||||
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
|
||||
while(length(currentrun))
|
||||
var/atom/movable/AM = currentrun[currentrun.len]
|
||||
var/datum/thrownthing/TT = currentrun[AM]
|
||||
currentrun.len--
|
||||
if(!AM || !TT)
|
||||
processing -= AM
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
continue
|
||||
|
||||
TT.tick()
|
||||
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
currentrun = null
|
||||
|
||||
/datum/thrownthing
|
||||
var/atom/movable/thrownthing
|
||||
var/atom/target
|
||||
var/turf/target_turf
|
||||
var/init_dir
|
||||
var/maxrange
|
||||
var/speed
|
||||
var/mob/thrower
|
||||
var/diagonals_first
|
||||
var/dist_travelled = 0
|
||||
var/start_time
|
||||
var/dist_x
|
||||
var/dist_y
|
||||
var/dx
|
||||
var/dy
|
||||
var/pure_diagonal
|
||||
var/diagonal_error
|
||||
var/datum/callback/callback
|
||||
var/paused = FALSE
|
||||
var/delayed_time = 0
|
||||
var/last_move = 0
|
||||
|
||||
/datum/thrownthing/proc/tick()
|
||||
var/atom/movable/AM = thrownthing
|
||||
if(!isturf(AM.loc) || !AM.throwing)
|
||||
finalize()
|
||||
return
|
||||
|
||||
if(paused)
|
||||
delayed_time += world.time - last_move
|
||||
return
|
||||
|
||||
if(dist_travelled && hitcheck()) //to catch sneaky things moving on our tile while we slept
|
||||
finalize()
|
||||
return
|
||||
|
||||
var/atom/step
|
||||
|
||||
last_move = world.time
|
||||
|
||||
//calculate how many tiles to move, making up for any missed ticks.
|
||||
var/tilestomove = CEILING(min(((((world.time + world.tick_lag) - start_time + delayed_time) * speed) - (dist_travelled ? dist_travelled : -1)), speed * MAX_TICKS_TO_MAKE_UP) * (world.tick_lag * SSthrowing.wait), 1)
|
||||
while(tilestomove-- > 0)
|
||||
if((dist_travelled >= maxrange || AM.loc == target_turf) && has_gravity(AM, AM.loc))
|
||||
finalize()
|
||||
return
|
||||
|
||||
if(dist_travelled <= max(dist_x, dist_y)) //if we haven't reached the target yet we home in on it, otherwise we use the initial direction
|
||||
step = get_step(AM, get_dir(AM, target_turf))
|
||||
else
|
||||
step = get_step(AM, init_dir)
|
||||
|
||||
if(!pure_diagonal && !diagonals_first) // not a purely diagonal trajectory and we don't want all diagonal moves to be done first
|
||||
if (diagonal_error >= 0 && max(dist_x, dist_y) - dist_travelled != 1) //we do a step forward unless we're right before the target
|
||||
step = get_step(AM, dx)
|
||||
diagonal_error += (diagonal_error < 0) ? dist_x / 2 : -dist_y
|
||||
|
||||
if(!step) // going off the edge of the map makes get_step return null, don't let things go off the edge
|
||||
finalize()
|
||||
return
|
||||
|
||||
AM.Move(step, get_dir(AM, step))
|
||||
|
||||
if(!AM.throwing) // we hit something during our move
|
||||
finalize(hit = TRUE)
|
||||
return
|
||||
|
||||
dist_travelled++
|
||||
|
||||
if(dist_travelled > MAX_THROWING_DIST)
|
||||
finalize()
|
||||
return
|
||||
|
||||
/datum/thrownthing/proc/finalize(hit = FALSE, target = null)
|
||||
set waitfor = 0
|
||||
SSthrowing.processing -= thrownthing
|
||||
//done throwing, either because it hit something or it finished moving
|
||||
thrownthing.throwing = null
|
||||
if(!hit)
|
||||
for(var/thing in get_turf(thrownthing)) //looking for our target on the turf we land on.
|
||||
var/atom/A = thing
|
||||
if(A == target)
|
||||
hit = 1
|
||||
thrownthing.throw_impact(A, src)
|
||||
break
|
||||
if(!hit)
|
||||
thrownthing.throw_impact(get_turf(thrownthing), src) // we haven't hit something yet and we still must, let's hit the ground.
|
||||
thrownthing.newtonian_move(init_dir)
|
||||
else
|
||||
thrownthing.newtonian_move(init_dir)
|
||||
|
||||
if(target)
|
||||
thrownthing.throw_impact(target, src)
|
||||
|
||||
if(callback)
|
||||
callback.Invoke()
|
||||
|
||||
/datum/thrownthing/proc/hit_atom(atom/A)
|
||||
finalize(hit = TRUE, target = A)
|
||||
|
||||
/datum/thrownthing/proc/hitcheck()
|
||||
for(var/thing in get_turf(thrownthing))
|
||||
var/atom/movable/AM = thing
|
||||
if(AM == thrownthing)
|
||||
continue
|
||||
if(AM.density && !(AM.pass_flags & LETPASSTHROW) && !(AM.flags & ON_BORDER))
|
||||
finalize(hit = TRUE, target = AM)
|
||||
return TRUE
|
||||
@@ -17,7 +17,10 @@
|
||||
message_admins("Admin [key_name_admin(usr)] has restarted the [controller] controller.")
|
||||
return
|
||||
|
||||
/client/proc/debug_controller(controller in list("Master","failsafe","Ticker","Air","Jobs","Sun","Radio","Configuration","pAI", "Cameras","Garbage", "Transfer Controller","Event","Alarm","Scheduler","Nano","Vote","Diseases","Fires","Mob","NPC AI","Shuttle","Timer","Weather","Space","Mob Hunt Server"))
|
||||
/client/proc/debug_controller(controller in list("Master",
|
||||
"failsafe","Scheduler","StonedMaster","Ticker","Air","Jobs","Sun","Radio","Configuration","pAI",
|
||||
"Cameras","Garbage", "Transfer Controller","Event","Alarm","Nano","Vote","Fires",
|
||||
"Mob","NPC AI","Shuttle","Timer","Weather","Space","Mob Hunt Server"))
|
||||
set category = "Debug"
|
||||
set name = "Debug Controller"
|
||||
set desc = "Debug the various periodic loop controllers for the game (be careful!)"
|
||||
@@ -28,19 +31,25 @@
|
||||
debug_variables(master_controller)
|
||||
feedback_add_details("admin_verb","DMC")
|
||||
if("failsafe")
|
||||
debug_variables(failsafe)
|
||||
debug_variables(Failsafe)
|
||||
feedback_add_details("admin_verb", "dfailsafe")
|
||||
if("Scheduler")
|
||||
debug_variables(processScheduler)
|
||||
feedback_add_details("admin_verb","DprocessScheduler")
|
||||
if("StonedMaster")
|
||||
debug_variables(Master)
|
||||
feedback_add_details("admin_verb","Dsmc")
|
||||
if("Ticker")
|
||||
debug_variables(ticker)
|
||||
feedback_add_details("admin_verb","DTicker")
|
||||
if("Air")
|
||||
debug_variables(air_master)
|
||||
debug_variables(SSair)
|
||||
feedback_add_details("admin_verb","DAir")
|
||||
if("Jobs")
|
||||
debug_variables(job_master)
|
||||
feedback_add_details("admin_verb","DJobs")
|
||||
if("Sun")
|
||||
debug_variables(sun)
|
||||
debug_variables(SSsun)
|
||||
feedback_add_details("admin_verb","DSun")
|
||||
if("Radio")
|
||||
debug_variables(radio_controller)
|
||||
@@ -63,17 +72,14 @@
|
||||
if("Garbage")
|
||||
debug_variables(garbageCollector)
|
||||
feedback_add_details("admin_verb","DGarbage")
|
||||
if("Scheduler")
|
||||
debug_variables(processScheduler)
|
||||
feedback_add_details("admin_verb","DprocessScheduler")
|
||||
if("Nano")
|
||||
debug_variables(nanomanager)
|
||||
debug_variables(SSnanoui)
|
||||
feedback_add_details("admin_verb","DNano")
|
||||
if("Vote")
|
||||
debug_variables(vote)
|
||||
feedback_add_details("admin_verb","DVote")
|
||||
if("Fires")
|
||||
debug_variables(fire_master)
|
||||
debug_variables(SSfires)
|
||||
feedback_add_details("admin_verb","DFires")
|
||||
if("Mob")
|
||||
debug_variables(mob_master)
|
||||
|
||||
+14
-12
@@ -101,7 +101,7 @@
|
||||
//Presets for item actions
|
||||
/datum/action/item_action
|
||||
check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_CONSCIOUS
|
||||
|
||||
var/use_itemicon = TRUE
|
||||
/datum/action/item_action/New(Target)
|
||||
..()
|
||||
var/obj/item/I = target
|
||||
@@ -121,17 +121,19 @@
|
||||
return 1
|
||||
|
||||
/datum/action/item_action/ApplyIcon(obj/screen/movable/action_button/current_button)
|
||||
current_button.overlays.Cut()
|
||||
if(target)
|
||||
var/obj/item/I = target
|
||||
var/old_layer = I.layer
|
||||
var/old_plane = I.plane
|
||||
I.layer = 21
|
||||
I.plane = HUD_PLANE
|
||||
current_button.overlays += I
|
||||
I.layer = old_layer
|
||||
I.plane = old_plane
|
||||
|
||||
if(use_itemicon)
|
||||
current_button.overlays.Cut()
|
||||
if(target)
|
||||
var/obj/item/I = target
|
||||
var/old_layer = I.layer
|
||||
var/old_plane = I.plane
|
||||
I.layer = 21
|
||||
I.plane = HUD_PLANE
|
||||
current_button.overlays += I
|
||||
I.layer = old_layer
|
||||
I.plane = old_plane
|
||||
else
|
||||
..()
|
||||
/datum/action/item_action/toggle_light
|
||||
name = "Toggle Light"
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#define MAXCOIL 30
|
||||
/datum/cargoprofile
|
||||
var/name = "All Items"
|
||||
var/id = "all" // unique ID for the UI
|
||||
@@ -787,4 +786,3 @@
|
||||
var/punches = punch(M,remaining / PUNCH_WORK)
|
||||
if(punches>1)master.sleep++
|
||||
return punches * PUNCH_WORK
|
||||
#undef MAXCOIL
|
||||
|
||||
+15
-1
@@ -1,4 +1,5 @@
|
||||
/* HUD DATUMS */
|
||||
var/global/list/all_huds = list()
|
||||
|
||||
///GLOBAL HUD LIST
|
||||
var/datum/atom_hud/huds = list( \
|
||||
@@ -7,6 +8,7 @@ var/datum/atom_hud/huds = list( \
|
||||
DATA_HUD_MEDICAL_BASIC = new/datum/atom_hud/data/human/medical/basic(), \
|
||||
DATA_HUD_MEDICAL_ADVANCED = new/datum/atom_hud/data/human/medical/advanced(), \
|
||||
DATA_HUD_DIAGNOSTIC = new/datum/atom_hud/data/diagnostic(), \
|
||||
DATA_HUD_DIAGNOSTIC_ADVANCED = new/datum/atom_hud/data/diagnostic/advanced(), \
|
||||
DATA_HUD_HYDROPONIC = new/datum/atom_hud/data/hydroponic(), \
|
||||
GAME_HUD_NATIONS = new/datum/atom_hud/antag(), \
|
||||
ANTAG_HUD_CULT = new/datum/atom_hud/antag(), \
|
||||
@@ -26,6 +28,18 @@ var/datum/atom_hud/huds = list( \
|
||||
var/list/mob/hudusers = list() //list with all mobs who can see the hud
|
||||
var/list/hud_icons = list() //these will be the indexes for the atom's hud_list
|
||||
|
||||
|
||||
/datum/atom_hud/New()
|
||||
all_huds += src
|
||||
|
||||
/datum/atom_hud/Destroy()
|
||||
for(var/v in hudusers)
|
||||
remove_hud_from(v)
|
||||
for(var/v in hudatoms)
|
||||
remove_from_hud(v)
|
||||
all_huds -= src
|
||||
return ..()
|
||||
|
||||
/datum/atom_hud/proc/remove_hud_from(mob/M)
|
||||
if(!M)
|
||||
return
|
||||
@@ -82,7 +96,7 @@ var/datum/atom_hud/huds = list( \
|
||||
serv_huds += serv.thrallhud
|
||||
|
||||
|
||||
for(var/datum/atom_hud/hud in (huds|serv_huds))//|gang_huds))
|
||||
for(var/datum/atom_hud/hud in (all_huds|serv_huds))//|gang_huds))
|
||||
if(src in hud.hudusers)
|
||||
hud.add_hud_to(src)
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
materials[MAT_BANANIUM] = new /datum/material/bananium()
|
||||
if(mat_list[MAT_TRANQUILLITE])
|
||||
materials[MAT_TRANQUILLITE] = new /datum/material/tranquillite()
|
||||
if(mat_list[MAT_TITANIUM])
|
||||
materials[MAT_TITANIUM] = new /datum/material/titanium()
|
||||
|
||||
/datum/material_container/Destroy()
|
||||
QDEL_LIST_ASSOC_VAL(materials)
|
||||
@@ -276,6 +278,13 @@
|
||||
material_type = MAT_TRANQUILLITE
|
||||
sheet_type = /obj/item/stack/sheet/mineral/tranquillite
|
||||
|
||||
/datum/material/titanium
|
||||
|
||||
/datum/material/titanium/New()
|
||||
..()
|
||||
material_type = MAT_TITANIUM
|
||||
sheet_type = /obj/item/stack/sheet/mineral/titanium
|
||||
|
||||
/datum/material/biomass
|
||||
|
||||
/datum/material/biomass/New()
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@
|
||||
current.mind = null
|
||||
leave_all_huds() //leave all the huds in the old body, so it won't get huds if somebody else enters it
|
||||
|
||||
nanomanager.user_transferred(current, new_character)
|
||||
SSnanoui.user_transferred(current, new_character)
|
||||
|
||||
if(new_character.mind) //remove any mind currently in our new body's mind variable
|
||||
new_character.mind.current = null
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Mutable appearances are an inbuilt byond datastructure. Read the documentation on them by hitting F1 in DM.
|
||||
// Basically use them instead of images for overlays/underlays and when changing an object's appearance if you're doing so with any regularity.
|
||||
// Unless you need the overlay/underlay to have a different direction than the base object. Then you have to use an image due to a bug.
|
||||
|
||||
// Mutable appearances are children of images, just so you know.
|
||||
|
||||
// Helper similar to image()
|
||||
/proc/mutable_appearance(icon, icon_state = "", layer = FLOAT_LAYER)
|
||||
var/mutable_appearance/MA = new()
|
||||
MA.icon = icon
|
||||
MA.icon_state = icon_state
|
||||
MA.layer = layer
|
||||
return MA
|
||||
@@ -20,15 +20,8 @@ Make sure spells that are removed from spell_list are actually removed and delet
|
||||
Also, you never added distance checking after target is selected. I've went ahead and did that.
|
||||
*/
|
||||
/obj/effect/proc_holder/spell/targeted/mind_transfer/cast(list/targets, mob/user = usr, distanceoverride)
|
||||
if(!targets.len)
|
||||
to_chat(user, "No mind found.")
|
||||
return
|
||||
|
||||
if(targets.len > 1)
|
||||
to_chat(user, "Too many minds! You're not a hive damnit!")//Whaa...aat?
|
||||
return
|
||||
|
||||
var/mob/living/target = targets[1]
|
||||
var/mob/living/target = targets[range]
|
||||
|
||||
if(!(target in oview(range)) && !distanceoverride)//If they are not in overview after selection. Do note that !() is necessary for in to work because ! takes precedence over it.
|
||||
to_chat(user, "They are too far away!")
|
||||
@@ -50,6 +43,10 @@ Also, you never added distance checking after target is selected. I've went ahea
|
||||
to_chat(user, "Their mind is resisting your spell.")
|
||||
return
|
||||
|
||||
if(istype(target, /mob/living/silicon))
|
||||
to_chat(user, "You feel this enslaved being is just as dead as its cold, hard exoskeleton.")
|
||||
return
|
||||
|
||||
var/mob/living/victim = target//The target of the spell whos body will be transferred to.
|
||||
var/mob/caster = user//The wizard/whomever doing the body transferring.
|
||||
|
||||
|
||||
+16
-19
@@ -5,8 +5,8 @@
|
||||
var/target
|
||||
|
||||
/obj/effect/statclick/New(ntarget, text)
|
||||
name = text
|
||||
target = ntarget
|
||||
name = text
|
||||
|
||||
/obj/effect/statclick/proc/update(text)
|
||||
name = text
|
||||
@@ -15,25 +15,22 @@
|
||||
/obj/effect/statclick/debug
|
||||
var/class
|
||||
|
||||
/obj/effect/statclick/debug/New(ntarget)
|
||||
name = "Initializing..."
|
||||
target = ntarget
|
||||
if(istype(target, /datum/controller/process))
|
||||
class = "process"
|
||||
else if(istype(target, /datum/controller/processScheduler))
|
||||
class = "scheduler"
|
||||
else if(istype(target, /datum/controller))
|
||||
class = "controller"
|
||||
else if(istype(target, /datum))
|
||||
class = "datum"
|
||||
else
|
||||
class = "unknown"
|
||||
|
||||
// This bit is called when clicked in the stat panel
|
||||
/obj/effect/statclick/debug/Click()
|
||||
if(!is_admin(usr))
|
||||
if(!is_admin(usr) || !target)
|
||||
return
|
||||
if(!class)
|
||||
if(istype(target, /datum/controller/process))
|
||||
class = "process"
|
||||
else if(istype(target, /datum/controller/processScheduler))
|
||||
class = "scheduler"
|
||||
if(istype(target, /datum/controller/subsystem))
|
||||
class = "subsystem"
|
||||
else if(istype(target, /datum/controller))
|
||||
class = "controller"
|
||||
else if(istype(target, /datum))
|
||||
class = "datum"
|
||||
else
|
||||
class = "unknown"
|
||||
|
||||
usr.client.debug_variables(target)
|
||||
|
||||
message_admins("Admin [key_name_admin(usr)] is debugging the [target] [class].")
|
||||
message_admins("Admin [key_name_admin(usr)] is debugging the [target] [class].")
|
||||
@@ -0,0 +1,41 @@
|
||||
//Largely beneficial effects go here, even if they have drawbacks. An example is provided in Shadow Mend.
|
||||
|
||||
/datum/status_effect/shadow_mend
|
||||
id = "shadow_mend"
|
||||
duration = 30
|
||||
alert_type = /obj/screen/alert/status_effect/shadow_mend
|
||||
|
||||
/obj/screen/alert/status_effect/shadow_mend
|
||||
name = "Shadow Mend"
|
||||
desc = "Shadowy energies wrap around your wounds, sealing them at a price. After healing, you will slowly lose health every three seconds for thirty seconds."
|
||||
icon_state = "shadow_mend"
|
||||
|
||||
/datum/status_effect/shadow_mend/on_apply()
|
||||
owner.visible_message("<span class='notice'>Violet light wraps around [owner]'s body!</span>", "<span class='notice'>Violet light wraps around your body!</span>")
|
||||
playsound(owner, 'sound/magic/teleport_app.ogg', 50, 1)
|
||||
return ..()
|
||||
|
||||
/datum/status_effect/shadow_mend/tick()
|
||||
owner.adjustBruteLoss(-15)
|
||||
owner.adjustFireLoss(-15)
|
||||
|
||||
/datum/status_effect/shadow_mend/on_remove()
|
||||
owner.visible_message("<span class='warning'>The violet light around [owner] glows black!</span>", "<span class='warning'>The tendrils around you cinch tightly and reap their toll...</span>")
|
||||
playsound(owner, 'sound/magic/teleport_diss.ogg', 50, 1)
|
||||
owner.apply_status_effect(STATUS_EFFECT_VOID_PRICE)
|
||||
|
||||
|
||||
/datum/status_effect/void_price
|
||||
id = "void_price"
|
||||
duration = 300
|
||||
tick_interval = 30
|
||||
alert_type = /obj/screen/alert/status_effect/void_price
|
||||
|
||||
/obj/screen/alert/status_effect/void_price
|
||||
name = "Void Price"
|
||||
desc = "Black tendrils cinch tightly against you, digging wicked barbs into your flesh."
|
||||
icon_state = "shadow_mend"
|
||||
|
||||
/datum/status_effect/void_price/tick()
|
||||
playsound(owner, 'sound/weapons/bite.ogg', 50, 1)
|
||||
owner.adjustBruteLoss(3)
|
||||
@@ -0,0 +1,10 @@
|
||||
//OTHER DEBUFFS
|
||||
|
||||
/datum/status_effect/cultghost //is a cult ghost and can't use manifest runes
|
||||
id = "cult_ghost"
|
||||
duration = -1
|
||||
alert_type = null
|
||||
|
||||
/datum/status_effect/cultghost/tick()
|
||||
if(owner.reagents)
|
||||
owner.reagents.del_reagent("holywater") //can't be deconverted
|
||||
@@ -0,0 +1,9 @@
|
||||
//entirely neutral or internal status effects go here
|
||||
|
||||
/datum/status_effect/high_five
|
||||
id = "high_five"
|
||||
duration = 25
|
||||
alert_type = null
|
||||
|
||||
/datum/status_effect/high_five/on_timeout()
|
||||
owner.visible_message("[owner] was left hanging....")
|
||||
@@ -0,0 +1,120 @@
|
||||
|
||||
//Status effects are used to apply temporary or permanent effects to mobs. Mobs are aware of their status effects at all times.
|
||||
//This file contains their code, plus code for applying and removing them.
|
||||
//When making a new status effect, add a define to status_effects.dm in __DEFINES for ease of use!
|
||||
|
||||
/datum/status_effect
|
||||
var/id = "effect" //Used for screen alerts.
|
||||
var/duration = -1 //How long the status effect lasts in DECISECONDS. Enter -1 for an effect that never ends unless removed through some means.
|
||||
var/tick_interval = 10 //How many deciseconds between ticks, approximately. Leave at 10 for every second.
|
||||
var/mob/living/owner //The mob affected by the status effect.
|
||||
var/status_type = STATUS_EFFECT_UNIQUE //How many of the effect can be on one mob, and what happens when you try to add another
|
||||
var/on_remove_on_mob_delete = FALSE //if we call on_remove() when the mob is deleted
|
||||
var/examine_text //If defined, this text will appear when the mob is examined - to use he, she etc. use "SUBJECTPRONOUN" and replace it in the examines themselves
|
||||
var/alert_type = /obj/screen/alert/status_effect //the alert thrown by the status effect, contains name and description
|
||||
var/obj/screen/alert/status_effect/linked_alert = null //the alert itself, if it exists
|
||||
|
||||
/datum/status_effect/New(list/arguments)
|
||||
on_creation(arglist(arguments))
|
||||
|
||||
/datum/status_effect/proc/on_creation(mob/living/new_owner, ...)
|
||||
if(new_owner)
|
||||
owner = new_owner
|
||||
if(owner)
|
||||
LAZYADD(owner.status_effects, src)
|
||||
if(!owner || !on_apply())
|
||||
qdel(src)
|
||||
return
|
||||
if(duration != -1)
|
||||
duration = world.time + duration
|
||||
tick_interval = world.time + tick_interval
|
||||
if(alert_type)
|
||||
var/obj/screen/alert/status_effect/A = owner.throw_alert(id, alert_type)
|
||||
A.attached_effect = src //so the alert can reference us, if it needs to
|
||||
linked_alert = A //so we can reference the alert, if we need to
|
||||
fast_processing.Add(src)
|
||||
return TRUE
|
||||
|
||||
/datum/status_effect/Destroy()
|
||||
fast_processing.Remove(src)
|
||||
if(owner)
|
||||
owner.clear_alert(id)
|
||||
LAZYREMOVE(owner.status_effects, src)
|
||||
on_remove()
|
||||
owner = null
|
||||
return ..()
|
||||
|
||||
/datum/status_effect/proc/process()
|
||||
if(!owner)
|
||||
qdel(src)
|
||||
return
|
||||
if(tick_interval < world.time)
|
||||
tick()
|
||||
tick_interval = world.time + initial(tick_interval)
|
||||
if(duration != -1 && duration < world.time)
|
||||
on_timeout()
|
||||
qdel(src)
|
||||
|
||||
/datum/status_effect/proc/on_apply() //Called whenever the buff is applied; returning FALSE will cause it to autoremove itself.
|
||||
return TRUE
|
||||
/datum/status_effect/proc/tick() //Called every tick.
|
||||
/datum/status_effect/proc/on_timeout()//called when a buff times out
|
||||
/datum/status_effect/proc/on_remove() //Called whenever the buff expires or is removed; do note that at the point this is called, it is out of the owner's status_effects but owner is not yet null
|
||||
/datum/status_effect/proc/be_replaced() //Called instead of on_remove when a status effect is replaced by itself or when a status effect with on_remove_on_mob_delete = FALSE has its mob deleted
|
||||
owner.clear_alert(id)
|
||||
LAZYREMOVE(owner.status_effects, src)
|
||||
owner = null
|
||||
qdel(src)
|
||||
|
||||
////////////////
|
||||
// ALERT HOOK //
|
||||
////////////////
|
||||
|
||||
/obj/screen/alert/status_effect
|
||||
name = "Curse of Mundanity"
|
||||
desc = "You don't feel any different..."
|
||||
var/datum/status_effect/attached_effect
|
||||
|
||||
//////////////////
|
||||
// HELPER PROCS //
|
||||
//////////////////
|
||||
|
||||
/mob/living/proc/apply_status_effect(effect, ...) //applies a given status effect to this mob, returning the effect if it was successful
|
||||
. = FALSE
|
||||
var/datum/status_effect/S1 = effect
|
||||
LAZYINITLIST(status_effects)
|
||||
for(var/datum/status_effect/S in status_effects)
|
||||
if(S.id == initial(S1.id) && S.status_type)
|
||||
if(S.status_type == STATUS_EFFECT_REPLACE)
|
||||
S.be_replaced()
|
||||
else
|
||||
return
|
||||
var/list/arguments = args.Copy()
|
||||
arguments[1] = src
|
||||
S1 = new effect(arguments)
|
||||
. = S1
|
||||
|
||||
/mob/living/proc/remove_status_effect(effect) //removes all of a given status effect from this mob, returning TRUE if at least one was removed
|
||||
. = FALSE
|
||||
if(status_effects)
|
||||
var/datum/status_effect/S1 = effect
|
||||
for(var/datum/status_effect/S in status_effects)
|
||||
if(initial(S1.id) == S.id)
|
||||
qdel(S)
|
||||
. = TRUE
|
||||
|
||||
/mob/living/proc/has_status_effect(effect) //returns the effect if the mob calling the proc owns the given status effect
|
||||
. = FALSE
|
||||
if(status_effects)
|
||||
var/datum/status_effect/S1 = effect
|
||||
for(var/datum/status_effect/S in status_effects)
|
||||
if(initial(S1.id) == S.id)
|
||||
return S
|
||||
|
||||
/mob/living/proc/has_status_effect_list(effect) //returns a list of effects with matching IDs that the mod owns; use for effects there can be multiple of
|
||||
. = list()
|
||||
if(status_effects)
|
||||
var/datum/status_effect/S1 = effect
|
||||
for(var/datum/status_effect/S in status_effects)
|
||||
if(initial(S1.id) == S.id)
|
||||
. += S
|
||||
@@ -963,6 +963,13 @@ var/list/uplink_items = list()
|
||||
item = /obj/item/weapon/storage/backpack/duffel/syndie/surgery
|
||||
cost = 4
|
||||
|
||||
/datum/uplink_item/device_tools/bonerepair
|
||||
name = "Prototype Bone Repair Kit"
|
||||
desc = "Stolen prototype bone repair nanites. Contains one nanocalcium autoinjector and guide."
|
||||
reference = "NCAI"
|
||||
item = /obj/item/weapon/storage/box/syndie_kit/bonerepair
|
||||
cost = 6
|
||||
|
||||
/datum/uplink_item/device_tools/military_belt
|
||||
name = "Military Belt"
|
||||
desc = "A robust seven-slot red belt made for carrying a broad variety of weapons, ammunition and explosives"
|
||||
|
||||
@@ -58,7 +58,7 @@ var/const/AIRLOCK_WIRE_LIGHT = 512
|
||||
if(A.isElectrified())
|
||||
if(A.shock(L, 100))
|
||||
return 0
|
||||
if(A.p_open)
|
||||
if(A.panel_open)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -164,9 +164,10 @@ var/const/AIRLOCK_WIRE_LIGHT = 512
|
||||
//one wire for door bolts. Sending a pulse through this drops door bolts if they're not down (whether power's on or not),
|
||||
//raises them if they are down (only if power's on)
|
||||
if(!A.locked)
|
||||
A.lock()
|
||||
else
|
||||
A.unlock()
|
||||
if(A.lock())
|
||||
A.audible_message("<span class='italics'>You hear a click from the bottom of the door.</span>", null, 1)
|
||||
else if(A.unlock())
|
||||
A.audible_message("<span class='italics'>You hear a click from the bottom of the door.</span>", null, 1)
|
||||
|
||||
if(AIRLOCK_WIRE_BACKUP_POWER1)
|
||||
//two wires for backup power. Sending a pulse through either one causes a breaker to trip, but this does not disable it unless main power is down too (in which case it is disabled for 1 minute or however long it takes main power to come back, whichever is shorter).
|
||||
|
||||
@@ -10,10 +10,10 @@ var/const/AUTOLATHE_DISABLE_WIRE = 4
|
||||
switch(index)
|
||||
if(AUTOLATHE_HACK_WIRE)
|
||||
return "Hack"
|
||||
|
||||
|
||||
if(AUTOLATHE_SHOCK_WIRE)
|
||||
return "Shock"
|
||||
|
||||
|
||||
if(AUTOLATHE_DISABLE_WIRE)
|
||||
return "Disable"
|
||||
|
||||
@@ -69,6 +69,6 @@ var/const/AUTOLATHE_DISABLE_WIRE = 4
|
||||
updateUIs()
|
||||
|
||||
/datum/wires/autolathe/proc/updateUIs()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
if(holder)
|
||||
nanomanager.update_uis(holder)
|
||||
SSnanoui.update_uis(holder)
|
||||
@@ -11,12 +11,12 @@ var/const/NUCLEARBOMB_WIRE_SAFETY = 4
|
||||
switch(index)
|
||||
if(NUCLEARBOMB_WIRE_LIGHT)
|
||||
return "Bomb Light"
|
||||
|
||||
|
||||
if(NUCLEARBOMB_WIRE_TIMING)
|
||||
return "Bomb Timing"
|
||||
|
||||
|
||||
if(NUCLEARBOMB_WIRE_SAFETY)
|
||||
return "Bomb Safety"
|
||||
return "Bomb Safety"
|
||||
|
||||
/datum/wires/nuclearbomb/CanUse(mob/living/L)
|
||||
var/obj/machinery/nuclearbomb/N = holder
|
||||
@@ -77,6 +77,6 @@ var/const/NUCLEARBOMB_WIRE_SAFETY = 4
|
||||
N.lighthack = !N.lighthack
|
||||
|
||||
/datum/wires/nuclearbomb/proc/updateUIs()
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
if(holder)
|
||||
nanomanager.update_uis(holder)
|
||||
SSnanoui.update_uis(holder)
|
||||
@@ -76,7 +76,7 @@ var/list/wireColours = list("red", "blue", "green", "black", "orange", "brown",
|
||||
ui_interact(user)
|
||||
|
||||
/datum/wires/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "wires.tmpl", holder.name, window_x, window_y)
|
||||
ui.open()
|
||||
@@ -174,7 +174,7 @@ var/list/wireColours = list("red", "blue", "green", "black", "orange", "brown",
|
||||
else
|
||||
to_chat(L, "<span class='error'>You need a remote signaller!</span>")
|
||||
|
||||
nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
return 1
|
||||
|
||||
//
|
||||
@@ -184,12 +184,12 @@ var/list/wireColours = list("red", "blue", "green", "black", "orange", "brown",
|
||||
// Called when wires cut/mended.
|
||||
/datum/wires/proc/UpdateCut(index, mended)
|
||||
if(holder)
|
||||
nanomanager.update_uis(holder)
|
||||
SSnanoui.update_uis(holder)
|
||||
|
||||
// Called when wire pulsed. Add code here.
|
||||
/datum/wires/proc/UpdatePulsed(index)
|
||||
if(holder)
|
||||
nanomanager.update_uis(holder)
|
||||
SSnanoui.update_uis(holder)
|
||||
|
||||
/datum/wires/proc/CanUse(mob/L)
|
||||
return 1
|
||||
|
||||
@@ -61,6 +61,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
|
||||
var/no_teleportlocs = 0
|
||||
|
||||
var/outdoors = 0 //For space, the asteroid, lavaland, etc. Used with blueprints to determine if we are adding a new area (vs editing a station room)
|
||||
var/xenobiology_compatible = FALSE //Can the Xenobio management console transverse this area by default?
|
||||
|
||||
/*Adding a wizard area teleport list because motherfucking lag -- Urist*/
|
||||
/*I am far too lazy to make it a proper list of areas so I'll just make it run the usual telepot routine at the start of the game*/
|
||||
@@ -1868,6 +1869,7 @@ area/security/podbay
|
||||
/area/toxins/xenobiology
|
||||
name = "\improper Xenobiology Lab"
|
||||
icon_state = "toxmix"
|
||||
xenobiology_compatible = TRUE
|
||||
|
||||
/area/toxins/xenobiology/xenoflora_storage
|
||||
name = "\improper Xenoflora Storage"
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
if(!D.welded)
|
||||
D.activate_alarm()
|
||||
if(D.operating)
|
||||
D.nextstate = CLOSED
|
||||
D.nextstate = FD_CLOSED
|
||||
else if(!D.density)
|
||||
spawn(0)
|
||||
D.close()
|
||||
|
||||
+6
-3
@@ -153,9 +153,8 @@
|
||||
/atom/proc/emp_act(var/severity)
|
||||
return
|
||||
|
||||
/atom/proc/bullet_act(var/obj/item/projectile/Proj, def_zone)
|
||||
Proj.on_hit(src, 0, def_zone)
|
||||
return 0
|
||||
/atom/proc/bullet_act(obj/item/projectile/P, def_zone)
|
||||
. = P.on_hit(src, 0, def_zone)
|
||||
|
||||
/atom/proc/in_contents_of(container)//can take class or object instance as argument
|
||||
if(ispath(container))
|
||||
@@ -613,6 +612,10 @@ var/list/blood_splatter_icons = list()
|
||||
/atom/proc/ratvar_act()
|
||||
return
|
||||
|
||||
//This proc is called on the location of an atom when the atom is Destroy()'d
|
||||
/atom/proc/handle_atom_del(atom/A)
|
||||
return
|
||||
|
||||
/atom/proc/atom_say(message)
|
||||
if(!message)
|
||||
return
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
attempt_init()
|
||||
|
||||
/atom/movable/Destroy()
|
||||
if(loc)
|
||||
loc.handle_atom_del(src)
|
||||
for(var/atom/movable/AM in contents)
|
||||
qdel(AM)
|
||||
var/turf/un_opaque
|
||||
@@ -215,14 +217,15 @@
|
||||
return 1
|
||||
|
||||
inertia_last_loc = loc
|
||||
drift_master.processing_list[src] = src
|
||||
SSspacedrift.processing[src] = src
|
||||
return 1
|
||||
|
||||
|
||||
//called when src is thrown into hit_atom
|
||||
/atom/movable/proc/throw_impact(atom/hit_atom, throwingdatum)
|
||||
set waitfor = 0
|
||||
return hit_atom.hitby(src)
|
||||
if(exists(hit_atom))
|
||||
return hit_atom.hitby(src)
|
||||
|
||||
/atom/movable/hitby(atom/movable/AM, skipcatch, hitpush = 1, blocked)
|
||||
if(!anchored && hitpush)
|
||||
@@ -299,7 +302,7 @@
|
||||
if(spin && !no_spin && !no_spin_thrown)
|
||||
SpinAnimation(5, 1)
|
||||
|
||||
throw_master.processing_list[src] = TT
|
||||
SSthrowing.processing[src] = TT
|
||||
TT.tick()
|
||||
|
||||
|
||||
|
||||
+31
-14
@@ -46,6 +46,12 @@
|
||||
/datum/atom_hud/data/diagnostic
|
||||
hud_icons = list (DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD)
|
||||
|
||||
/datum/atom_hud/data/diagnostic/advanced
|
||||
hud_icons = list (DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD, DIAG_PATH_HUD)
|
||||
|
||||
/datum/atom_hud/data/bot_path
|
||||
hud_icons = list(DIAG_PATH_HUD)
|
||||
|
||||
/datum/atom_hud/data/hydroponic
|
||||
hud_icons = list (PLANT_NUTRIENT_HUD, PLANT_WATER_HUD, PLANT_STATUS_HUD, PLANT_HEALTH_HUD, PLANT_TOXIN_HUD, PLANT_PEST_HUD, PLANT_WEED_HUD)
|
||||
|
||||
@@ -70,8 +76,15 @@
|
||||
return 0
|
||||
|
||||
//helper for getting the appropriate health status UPDATED BY PUCKABOO2 TO INCLUDE NEGATIVES.
|
||||
/proc/RoundHealth(health)
|
||||
switch(health)
|
||||
/proc/RoundHealth(mob/living/M)
|
||||
if(M.stat == DEAD || (M.status_flags & FAKEDEATH))
|
||||
return "health-100" //what's our health? it doesn't matter, we're dead, or faking
|
||||
var/maxi_health = M.maxHealth
|
||||
if(iscarbon(M) && M.health < 0)
|
||||
maxi_health = 100 //so crit shows up right for aliens and other high-health carbon mobs; noncarbons don't have crit.
|
||||
var/resulthealth = (M.health / maxi_health) * 100
|
||||
|
||||
switch(resulthealth)
|
||||
if(100 to INFINITY)
|
||||
return "health100"
|
||||
if(95 to 100)
|
||||
@@ -120,6 +133,7 @@
|
||||
return "health-100" //doc u had 1 job
|
||||
return "0"
|
||||
|
||||
|
||||
///HOOKS
|
||||
|
||||
//called when a human changes suit sensors
|
||||
@@ -128,22 +142,26 @@
|
||||
B.update_suit_sensors(src)
|
||||
|
||||
|
||||
//called when a carbon changes health
|
||||
/mob/living/carbon/proc/med_hud_set_health()
|
||||
//called when a living mob changes health
|
||||
/mob/living/proc/med_hud_set_health()
|
||||
var/image/holder = hud_list[HEALTH_HUD]
|
||||
if(stat == 2)
|
||||
holder.icon_state = "hudhealth-100"
|
||||
else
|
||||
holder.icon_state = "hud[RoundHealth(health)]"
|
||||
holder.icon_state = "hud[RoundHealth(src)]"
|
||||
|
||||
|
||||
//called when a carbon changes stat, virus or XENO_HOST
|
||||
/mob/living/carbon/proc/med_hud_set_status()
|
||||
/mob/living/proc/med_hud_set_status()
|
||||
var/image/holder = hud_list[STATUS_HUD]
|
||||
//var/image/holder2 = hud_list[STATUS_HUD_OOC]
|
||||
var/mob/living/simple_animal/borer/B = has_brain_worms()
|
||||
if(stat == 2)
|
||||
if(stat == DEAD)
|
||||
holder.icon_state = "huddead"
|
||||
else
|
||||
holder.icon_state = "hudhealthy"
|
||||
|
||||
//called when a carbon changes stat, virus or XENO_HOST
|
||||
/mob/living/carbon/med_hud_set_status()
|
||||
var/image/holder = hud_list[STATUS_HUD]
|
||||
var/mob/living/simple_animal/borer/B = has_brain_worms()
|
||||
if(stat == DEAD)
|
||||
holder.icon_state = "huddead"
|
||||
//holder2.icon_state = "huddead"
|
||||
else if(status_flags & XENO_HOST)
|
||||
holder.icon_state = "hudxeno"
|
||||
else if(check_virus())
|
||||
@@ -152,7 +170,6 @@
|
||||
holder.icon_state = "hudbrainworm"
|
||||
else
|
||||
holder.icon_state = "hudhealthy"
|
||||
//holder2.icon_state = "hudhealthy"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -371,7 +371,7 @@
|
||||
I.forceMove(src)
|
||||
src.disk = I
|
||||
to_chat(user, "You insert [I].")
|
||||
nanomanager.update_uis(src) // update all UIs attached to src()
|
||||
SSnanoui.update_uis(src) // update all UIs attached to src()
|
||||
return
|
||||
else
|
||||
..()
|
||||
@@ -469,7 +469,7 @@
|
||||
return
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
@@ -580,7 +580,7 @@
|
||||
irradiating = src.radiation_duration
|
||||
var/lock_state = src.connected.locked
|
||||
src.connected.locked = 1//lock it
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
SSnanoui.update_uis(src) // update all UIs attached to src
|
||||
|
||||
sleep(10*src.radiation_duration) // sleep for radiation_duration seconds
|
||||
|
||||
@@ -685,7 +685,7 @@
|
||||
irradiating = src.radiation_duration
|
||||
var/lock_state = src.connected.locked
|
||||
src.connected.locked = 1//lock it
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
SSnanoui.update_uis(src) // update all UIs attached to src
|
||||
|
||||
sleep(10*src.radiation_duration) // sleep for radiation_duration seconds
|
||||
|
||||
@@ -753,7 +753,7 @@
|
||||
irradiating = src.radiation_duration
|
||||
var/lock_state = src.connected.locked
|
||||
src.connected.locked = 1 //lock it
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
SSnanoui.update_uis(src) // update all UIs attached to src
|
||||
|
||||
sleep(10*src.radiation_duration) // sleep for radiation_duration seconds
|
||||
|
||||
@@ -888,7 +888,7 @@
|
||||
irradiating = 2
|
||||
var/lock_state = src.connected.locked
|
||||
src.connected.locked = 1//lock it
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
SSnanoui.update_uis(src) // update all UIs attached to src
|
||||
|
||||
sleep(2 SECONDS)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user