From eff86a449f3fa83c28fa80fcaa41d2f28ad42f98 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 14 Jan 2020 16:45:22 -0700
Subject: [PATCH 01/13] wew
---
code/controllers/subsystem/input.dm | 2 +-
code/controllers/subsystem/mapping.dm | 8 +++-
code/controllers/subsystem/nightshift.dm | 2 +-
code/controllers/subsystem/shuttle.dm | 4 ++
code/controllers/subsystem/time_track.dm | 42 +++++++++++++--------
code/modules/client/verbs/ping.dm | 4 +-
code/modules/keybindings/bindings_atom.dm | 2 +-
code/modules/keybindings/bindings_client.dm | 16 ++------
code/modules/keybindings/setup.dm | 4 +-
code/modules/mob/mob.dm | 32 ++++++----------
code/modules/mob/mob_movement.dm | 13 +++----
11 files changed, 65 insertions(+), 64 deletions(-)
diff --git a/code/controllers/subsystem/input.dm b/code/controllers/subsystem/input.dm
index cc09ca816e..0970b23a16 100644
--- a/code/controllers/subsystem/input.dm
+++ b/code/controllers/subsystem/input.dm
@@ -114,6 +114,6 @@ SUBSYSTEM_DEF(input)
/datum/controller/subsystem/input/fire()
var/list/clients = GLOB.clients // Let's sing the list cache song
- for(var/i in 1 to clients.len)
+ for(var/i in 1 to length(clients))
var/client/C = clients[i]
C.keyLoop()
diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm
index 8c8ad2d337..4850a67646 100644
--- a/code/controllers/subsystem/mapping.dm
+++ b/code/controllers/subsystem/mapping.dm
@@ -37,6 +37,8 @@ SUBSYSTEM_DEF(mapping)
var/datum/space_level/empty_space
var/num_of_res_levels = 1
+ var/stat_map_name = "Loading..."
+
//dlete dis once #39770 is resolved
/datum/controller/subsystem/mapping/proc/HACK_LoadMapConfig()
if(!config)
@@ -45,6 +47,7 @@ SUBSYSTEM_DEF(mapping)
#else
config = load_map_config(error_if_missing = FALSE)
#endif
+ stat_map_name = config.map_name
/datum/controller/subsystem/mapping/Initialize(timeofday)
HACK_LoadMapConfig()
@@ -330,7 +333,10 @@ GLOBAL_LIST_EMPTY(the_station_areas)
return
next_map_config = VM
- return TRUE
+
+ . = TRUE
+
+ stat_map_name = "[config.map_name] (Next: [next_map_config.map_name])"
/datum/controller/subsystem/mapping/proc/preloadTemplates(path = "_maps/templates/") //see master controller setup
var/list/filelist = flist(path)
diff --git a/code/controllers/subsystem/nightshift.dm b/code/controllers/subsystem/nightshift.dm
index 927f68eee7..7bf1ee42ba 100644
--- a/code/controllers/subsystem/nightshift.dm
+++ b/code/controllers/subsystem/nightshift.dm
@@ -35,7 +35,7 @@ SUBSYSTEM_DEF(nightshift)
if(!emergency)
announce("Restoring night lighting configuration to normal operation.")
else
- announce("Disabling night lighting: Station is in a state of emergency.")
+ announce("Disabling night lighting: Station is in a state of emergency.")
if(emergency)
night_time = FALSE
if(nightshift_active != night_time)
diff --git a/code/controllers/subsystem/shuttle.dm b/code/controllers/subsystem/shuttle.dm
index b406a8ccad..4d9eefae5b 100644
--- a/code/controllers/subsystem/shuttle.dm
+++ b/code/controllers/subsystem/shuttle.dm
@@ -30,6 +30,7 @@ SUBSYSTEM_DEF(shuttle)
var/list/hostileEnvironments = list() //Things blocking escape shuttle from leaving
var/list/tradeBlockade = list() //Things blocking cargo from leaving.
var/supplyBlocked = FALSE
+ var/emergency_shuttle_stat_text
//supply shuttle stuff
var/obj/docking_port/mobile/supply/supply
@@ -118,6 +119,9 @@ SUBSYSTEM_DEF(shuttle)
points += point_gain
//Cargo stuff end
+ var/esETA = emergency?.getModeStr()
+ emergency_shuttle_stat_text = "[esETA? "[esETA] [emergency.getTimerStr()]" : ""]"
+
if(!SSmapping.clearing_reserved_turfs)
while(transit_requesters.len)
var/requester = popleft(transit_requesters)
diff --git a/code/controllers/subsystem/time_track.dm b/code/controllers/subsystem/time_track.dm
index 3b19ae31cd..165386694d 100644
--- a/code/controllers/subsystem/time_track.dm
+++ b/code/controllers/subsystem/time_track.dm
@@ -1,6 +1,6 @@
SUBSYSTEM_DEF(time_track)
name = "Time Tracking"
- wait = 600
+ wait = 1 SECONDS
flags = SS_NO_INIT|SS_NO_TICK_CHECK
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
@@ -16,23 +16,33 @@ SUBSYSTEM_DEF(time_track)
var/last_tick_byond_time = 0
var/last_tick_tickcount = 0
+ var/last_measurement = 0
+ var/measurement_delay = 60
+
+ var/stat_time_text
+ var/time_dilation_text
+
/datum/controller/subsystem/time_track/fire()
+ stat_time_text = "TIME: Server [time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")] Round [WORLDTIME2TEXT("hh:mm:ss")] Station [STATION_TIME_TIMESTAMP("hh:mm:ss")]\n[time_dilation_text]"
- var/current_realtime = REALTIMEOFDAY
- var/current_byondtime = world.time
- var/current_tickcount = world.time/world.tick_lag
+ if(++last_measurement == measurement_delay)
+ last_measurement = 0
+ var/current_realtime = REALTIMEOFDAY
+ var/current_byondtime = world.time
+ var/current_tickcount = world.time/world.tick_lag
- if (!first_run)
- var/tick_drift = max(0, (((current_realtime - last_tick_realtime) - (current_byondtime - last_tick_byond_time)) / world.tick_lag))
+ if (!first_run)
+ var/tick_drift = max(0, (((current_realtime - last_tick_realtime) - (current_byondtime - last_tick_byond_time)) / world.tick_lag))
- time_dilation_current = tick_drift / (current_tickcount - last_tick_tickcount) * 100
+ time_dilation_current = tick_drift / (current_tickcount - last_tick_tickcount) * 100
- time_dilation_avg_fast = MC_AVERAGE_FAST(time_dilation_avg_fast, time_dilation_current)
- time_dilation_avg = MC_AVERAGE(time_dilation_avg, time_dilation_avg_fast)
- time_dilation_avg_slow = MC_AVERAGE_SLOW(time_dilation_avg_slow, time_dilation_avg)
- else
- first_run = FALSE
- last_tick_realtime = current_realtime
- last_tick_byond_time = current_byondtime
- last_tick_tickcount = current_tickcount
- SSblackbox.record_feedback("associative", "time_dilation_current", 1, list("[SQLtime()]" = list("current" = "[time_dilation_current]", "avg_fast" = "[time_dilation_avg_fast]", "avg" = "[time_dilation_avg]", "avg_slow" = "[time_dilation_avg_slow]")))
+ time_dilation_avg_fast = MC_AVERAGE_FAST(time_dilation_avg_fast, time_dilation_current)
+ time_dilation_avg = MC_AVERAGE(time_dilation_avg, time_dilation_avg_fast)
+ time_dilation_avg_slow = MC_AVERAGE_SLOW(time_dilation_avg_slow, time_dilation_avg)
+ else
+ first_run = FALSE
+ last_tick_realtime = current_realtime
+ last_tick_byond_time = current_byondtime
+ last_tick_tickcount = current_tickcount
+ SSblackbox.record_feedback("associative", "time_dilation_current", 1, list("[SQLtime()]" = list("current" = "[time_dilation_current]", "avg_fast" = "[time_dilation_avg_fast]", "avg" = "[time_dilation_avg]", "avg_slow" = "[time_dilation_avg_slow]")))
+ time_dilation_text = "Time Dilation: [round(SStime_track.time_dilation_current,1)]% AVG:([round(SStime_track.time_dalilation_avg_fast,1)]%, [round(SStime_track.time_dilation_avg,1)]%, [round(SStime_track.time_dilation_avg_slow,1)]%)"
diff --git a/code/modules/client/verbs/ping.dm b/code/modules/client/verbs/ping.dm
index de19d0d52c..02c5b5a7fd 100644
--- a/code/modules/client/verbs/ping.dm
+++ b/code/modules/client/verbs/ping.dm
@@ -14,9 +14,9 @@
/client/verb/display_ping(time as num)
set instant = TRUE
set name = ".display_ping"
- to_chat(src, "Round trip ping took [round(pingfromtime(time),1)]ms")
+ to_chat(src, "Round trip ping took [round(pingfromtime(time),1)]ms (Avg: [round(avgping, 1)]ms])")
/client/verb/ping()
set name = "Ping"
set category = "OOC"
- winset(src, null, "command=.display_ping+[world.time+world.tick_lag*TICK_USAGE_REAL/100]")
\ No newline at end of file
+ winset(src, null, "command=.display_ping+[world.time+world.tick_lag*TICK_USAGE_REAL/100]")
diff --git a/code/modules/keybindings/bindings_atom.dm b/code/modules/keybindings/bindings_atom.dm
index 4aac76bd67..5f3e879237 100644
--- a/code/modules/keybindings/bindings_atom.dm
+++ b/code/modules/keybindings/bindings_atom.dm
@@ -15,4 +15,4 @@
movement_dir &= ~(NORTH|SOUTH)
if((movement_dir & EAST) && (movement_dir & WEST))
movement_dir &= ~(EAST|WEST)
- user.Move(get_step(src, movement_dir), movement_dir)
\ No newline at end of file
+ user.Move(get_step(src, movement_dir), movement_dir)
diff --git a/code/modules/keybindings/bindings_client.dm b/code/modules/keybindings/bindings_client.dm
index 2b8bfa6860..315ba7a381 100644
--- a/code/modules/keybindings/bindings_client.dm
+++ b/code/modules/keybindings/bindings_client.dm
@@ -5,7 +5,7 @@
set hidden = TRUE
client_keysend_amount += 1
-
+
var/cache = client_keysend_amount
if(keysend_tripped && next_keysend_trip_reset <= world.time)
@@ -20,7 +20,7 @@
//don't want to kick people if a lag spike results in a huge flood of commands being sent
if(cache >= MAX_KEYPRESS_AUTOKICK)
if(!keysend_tripped)
- keysend_tripped = TRUE
+ keysend_tripped = TRUE
next_keysend_trip_reset = world.time + (2 SECONDS)
else
log_admin("Client [ckey] was just autokicked for flooding keysends; likely abuse but potentially lagspike.")
@@ -35,11 +35,7 @@
message_admins("Client [ckey] just attempted to send an invalid keypress. Keymessage was over [MAX_KEYPRESS_COMMANDLENGTH] characters, autokicking due to likely abuse.")
QDEL_IN(src, 1)
return
- //offset by 1 because the buffer address is 0 indexed because the math was simpler
- keys_held[current_key_address + 1] = _key
- //the time a key was pressed isn't actually used anywhere (as of 2019-9-10) but this allows easier access usage/checking
- keys_held[_key] = world.time
- current_key_address = ((current_key_address + 1) % HELD_KEY_BUFFER_LENGTH)
+ keys_held[_key] = TRUE
var/movement = SSinput.movement_keys[_key]
if(!(next_move_dir_sub & movement) && !keys_held["Ctrl"])
next_move_dir_add |= movement
@@ -70,11 +66,7 @@
set instant = TRUE
set hidden = TRUE
- //Can't just do a remove because it would alter the length of the rolling buffer, instead search for the key then null it out if it exists
- for(var/i in 1 to HELD_KEY_BUFFER_LENGTH)
- if(keys_held[i] == _key)
- keys_held[i] = null
- break
+ keys_held -= _key
var/movement = SSinput.movement_keys[_key]
if(!(next_move_dir_add & movement))
next_move_dir_sub |= movement
diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm
index 8433c9bf5a..90524f2c66 100644
--- a/code/modules/keybindings/setup.dm
+++ b/code/modules/keybindings/setup.dm
@@ -1,8 +1,6 @@
/client
- /// A rolling buffer of any keys held currently
+ /// Keys currently held
var/list/keys_held = list()
- ///used to keep track of the current rolling buffer position
- var/current_key_address = 0
/// These next two vars are to apply movement for keypresses and releases made while move delayed.
/// Because discarding that input makes the game less responsive.
/// On next move, add this dir to the move that would otherwise be done
diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm
index b4c3c93824..9c4c15f9af 100644
--- a/code/modules/mob/mob.dm
+++ b/code/modules/mob/mob.dm
@@ -565,29 +565,23 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0)
M.show_inv(user)
/mob/proc/is_muzzled()
- return 0
+ return FALSE
/mob/Stat()
..()
- if(statpanel("Status"))
- if (client)
- stat(null, "Ping: [round(client.lastping, 1)]ms (Average: [round(client.avgping, 1)]ms)")
- stat(null, "Map: [SSmapping.config?.map_name || "Loading..."]")
- var/datum/map_config/cached = SSmapping.next_map_config
- if(cached)
- stat(null, "Next Map: [cached.map_name]")
- stat(null, "Round ID: [GLOB.round_id ? GLOB.round_id : "NULL"]")
- stat(null, "Server Time: [time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")]")
- stat(null, "Round Time: [WORLDTIME2TEXT("hh:mm:ss")]")
- stat(null, "Station Time: [STATION_TIME_TIMESTAMP("hh:mm:ss")]")
- stat(null, "Time Dilation: [round(SStime_track.time_dilation_current,1)]% AVG:([round(SStime_track.time_dilation_avg_fast,1)]%, [round(SStime_track.time_dilation_avg,1)]%, [round(SStime_track.time_dilation_avg_slow,1)]%)")
- if(SSshuttle.emergency)
- var/ETA = SSshuttle.emergency.getModeStr()
- if(ETA)
- stat(null, "[ETA] [SSshuttle.emergency.getTimerStr()]")
+ //This is only called from client/Stat(), let's assume client exists.
- if(client && client.holder)
+ if(statpanel("Status"))
+ var/list/L = list()
+ L += "Ping: [round(client.lastping,1)]ms (Avg: [round(client.avgping,1)]ms)"
+ L += SSmapping.stat_map_name
+ L += "Round ID: [GLOB.round_id || "NULL"]")
+ L += SStime_track.stat_time_text
+ L += SSshuttle.emergency_shuttle_stat_text
+ stat(null, "[L.Join("\n")]")
+
+ if(client.holder)
if(statpanel("MC"))
var/turf/T = get_turf(client.eye)
stat("Location:", COORD(T))
@@ -637,8 +631,6 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0)
if(A.IsObscured())
continue
statpanel(listed_turf.name, null, A)
-
-
if(mind)
add_spells_to_statpanel(mind.spell_list)
var/datum/antagonist/changeling/changeling = mind.has_antag_datum(/datum/antagonist/changeling)
diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm
index f61d65146e..5f217d67fd 100644
--- a/code/modules/mob/mob_movement.dm
+++ b/code/modules/mob/mob_movement.dm
@@ -34,20 +34,19 @@
#define MOVEMENT_DELAY_BUFFER 0.75
#define MOVEMENT_DELAY_BUFFER_DELTA 1.25
-/client/Move(n, direct)
+/client/Move(n, direction)
if(world.time < move_delay) //do not move anything ahead of this check please
return FALSE
else
- next_move_dir_add = 0
- next_move_dir_sub = 0
+ next_move_dir_add = next_move_dir_sub = NONE
var/old_move_delay = move_delay
move_delay = world.time + world.tick_lag //this is here because Move() can now be called mutiple times per tick
- if(!mob || !mob.loc)
- return FALSE
- if(!n || !direct)
+ if(!n || !direction || !mob?.loc)
return FALSE
+ //GET RID OF THIS SOON AS MOBILITY FLAGS IS DONE
if(mob.notransform)
- return FALSE //This is sota the goto stop mobs from moving var
+ return FALSE
+
if(mob.control_object)
return Move_object(direct)
if(!isliving(mob))
From 6ead30eab32db6fdd37299b1be9c80dce2692561 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 14 Jan 2020 17:22:54 -0700
Subject: [PATCH 02/13] more shit
---
code/controllers/subsystem/air.dm | 3 +-
code/controllers/subsystem/air_turfs.dm | 1 -
code/controllers/subsystem/time_track.dm | 2 +-
.../atmospherics/gasmixtures/gas_mixture.dm | 34 ++++++------
code/modules/mob/mob.dm | 2 +-
code/modules/mob/mob_movement.dm | 52 +++++++++----------
6 files changed, 44 insertions(+), 50 deletions(-)
diff --git a/code/controllers/subsystem/air.dm b/code/controllers/subsystem/air.dm
index 2a59558bcd..52d2fe45cd 100644
--- a/code/controllers/subsystem/air.dm
+++ b/code/controllers/subsystem/air.dm
@@ -239,7 +239,6 @@ SUBSYSTEM_DEF(air)
if (MC_TICK_CHECK)
return
-
/datum/controller/subsystem/air/proc/remove_from_active(turf/open/T)
active_turfs -= T
SSair_turfs.currentrun -= T
@@ -257,7 +256,7 @@ SUBSYSTEM_DEF(air)
#ifdef VISUALIZE_ACTIVE_TURFS
T.add_atom_colour("#00ff00", TEMPORARY_COLOUR_PRIORITY)
#endif
- T.excited = 1
+ T.excited = TRUE
active_turfs |= T
SSair_turfs.currentrun |= T
if(blockchanges && T.excited_group)
diff --git a/code/controllers/subsystem/air_turfs.dm b/code/controllers/subsystem/air_turfs.dm
index 2902940bf9..9dd41aede5 100644
--- a/code/controllers/subsystem/air_turfs.dm
+++ b/code/controllers/subsystem/air_turfs.dm
@@ -11,7 +11,6 @@ SUBSYSTEM_DEF(air_turfs)
/datum/controller/subsystem/air_turfs/fire(resumed = 0)
var/fire_count = times_fired
- //cache for sanic speed
if (!resumed)
src.currentrun = SSair.active_turfs.Copy()
//cache for sanic speed (lists are references anyways)
diff --git a/code/controllers/subsystem/time_track.dm b/code/controllers/subsystem/time_track.dm
index 165386694d..ac09c3ce65 100644
--- a/code/controllers/subsystem/time_track.dm
+++ b/code/controllers/subsystem/time_track.dm
@@ -45,4 +45,4 @@ SUBSYSTEM_DEF(time_track)
last_tick_byond_time = current_byondtime
last_tick_tickcount = current_tickcount
SSblackbox.record_feedback("associative", "time_dilation_current", 1, list("[SQLtime()]" = list("current" = "[time_dilation_current]", "avg_fast" = "[time_dilation_avg_fast]", "avg" = "[time_dilation_avg]", "avg_slow" = "[time_dilation_avg_slow]")))
- time_dilation_text = "Time Dilation: [round(SStime_track.time_dilation_current,1)]% AVG:([round(SStime_track.time_dalilation_avg_fast,1)]%, [round(SStime_track.time_dilation_avg,1)]%, [round(SStime_track.time_dilation_avg_slow,1)]%)"
+ time_dilation_text = "Time Dilation: [round(time_dilation_current,1)]% AVG:([round(time_dilation_avg_fast,1)]%, [round(time_dilation_avg,1)]%, [round(time_dilation_avg_slow,1)]%)"
diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
index 12efa01a38..f59bf23b71 100644
--- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm
+++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
@@ -310,26 +310,22 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
/datum/gas_mixture/compare(datum/gas_mixture/sample)
var/list/sample_gases = sample.gases //accessing datum vars is slower than proc vars
var/list/cached_gases = gases
-
- for(var/id in cached_gases | sample_gases) // compare gases from either mixture
- var/gas_moles = cached_gases[id]
- var/sample_moles = sample_gases[id]
- var/delta = abs(gas_moles - sample_moles)
- if(delta > MINIMUM_MOLES_DELTA_TO_MOVE && \
- delta > gas_moles * MINIMUM_AIR_RATIO_TO_MOVE)
- return id
-
+ var/list/combined = cached_gases | sample_gases
+ // Do not use TOTAL_MOLES, that's an unnecessary iteration.
var/our_moles
- TOTAL_MOLES(cached_gases, our_moles)
- if(our_moles > MINIMUM_MOLES_DELTA_TO_MOVE)
- var/temp = temperature
- var/sample_temp = sample.temperature
-
- var/temperature_delta = abs(temp - sample_temp)
- if(temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND)
- return "temp"
-
- return ""
+ // Declarations are expensive.
+ var/us
+ var/them
+ var/diff
+ for(var/id in combined)
+ us = cached_gases[id]
+ them = sample_gases[id]
+ diff = abs(gas_moles - sample_moles)
+ if(diff > MINIMUM_MOLES_DELTA_TO_MOVE && diff > gas_moles * MINIMUM_AIR_RATIO_TO_MOVE)
+ return id
+ our_moles += us
+ if((our_moles > MINIMUM_MOLES_DELTA_TO_MOVE) && (abs(temperature - sample.temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEN))
+ return "temp"
/datum/gas_mixture/react(datum/holder)
. = NO_REACTION
diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm
index 9c4c15f9af..7f4274d43e 100644
--- a/code/modules/mob/mob.dm
+++ b/code/modules/mob/mob.dm
@@ -576,7 +576,7 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0)
var/list/L = list()
L += "Ping: [round(client.lastping,1)]ms (Avg: [round(client.avgping,1)]ms)"
L += SSmapping.stat_map_name
- L += "Round ID: [GLOB.round_id || "NULL"]")
+ L += "Round ID: [GLOB.round_id || "NULL"]"
L += SStime_track.stat_time_text
L += SSshuttle.emergency_shuttle_stat_text
stat(null, "[L.Join("\n")]")
diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm
index 5f217d67fd..4c7eba348d 100644
--- a/code/modules/mob/mob_movement.dm
+++ b/code/modules/mob/mob_movement.dm
@@ -21,15 +21,15 @@
mob.dropItemToGround(mob.get_active_held_item())
return
-/client/proc/Move_object(direct)
+/client/proc/Move_object(direction)
if(mob && mob.control_object)
if(mob.control_object.density)
- step(mob.control_object,direct)
+ step(mob.control_object,direction)
if(!mob.control_object)
return
- mob.control_object.setDir(direct)
+ mob.control_object.setDir(direction)
else
- mob.control_object.forceMove(get_step(mob.control_object,direct))
+ mob.control_object.forceMove(get_step(mob.control_object,direction))
#define MOVEMENT_DELAY_BUFFER 0.75
#define MOVEMENT_DELAY_BUFFER_DELTA 1.25
@@ -48,9 +48,9 @@
return FALSE
if(mob.control_object)
- return Move_object(direct)
+ return Move_object(direction)
if(!isliving(mob))
- return mob.Move(n, direct)
+ return mob.Move(n, direction)
if(mob.stat == DEAD)
mob.ghostize()
return FALSE
@@ -59,29 +59,29 @@
var/mob/living/L = mob //Already checked for isliving earlier
if(L.incorporeal_move) //Move though walls
- Process_Incorpmove(direct)
+ Process_Incorpmove(direction)
return FALSE
if(mob.remote_control) //we're controlling something, our movement is relayed to it
- return mob.remote_control.relaymove(mob, direct)
+ return mob.remote_control.relaymove(mob, direction)
if(isAI(mob))
- return AIMove(n,direct,mob)
+ return AIMove(n,direction,mob)
if(Process_Grab()) //are we restrained by someone's grip?
return
if(mob.buckled) //if we're buckled to something, tell it we moved.
- return mob.buckled.relaymove(mob, direct)
+ return mob.buckled.relaymove(mob, direction)
if(!mob.canmove)
return FALSE
if(isobj(mob.loc) || ismob(mob.loc)) //Inside an object, tell it we moved
var/atom/O = mob.loc
- return O.relaymove(mob, direct)
+ return O.relaymove(mob, direction)
- if(!mob.Process_Spacemove(direct))
+ if(!mob.Process_Spacemove(direction))
return FALSE
//We are now going to move
var/add_delay = mob.movement_delay()
@@ -96,16 +96,16 @@
if(L.confused > 40)
newdir = pick(GLOB.alldirs)
else if(prob(L.confused * 1.5))
- newdir = angle2dir(dir2angle(direct) + pick(90, -90))
+ newdir = angle2dir(dir2angle(direction) + pick(90, -90))
else if(prob(L.confused * 3))
- newdir = angle2dir(dir2angle(direct) + pick(45, -45))
+ newdir = angle2dir(dir2angle(direction) + pick(45, -45))
if(newdir)
- direct = newdir
- n = get_step(L, direct)
+ direction = newdir
+ n = get_step(L, direction)
. = ..()
- if((direct & (direct - 1)) && mob.loc == n) //moved diagonally successfully
+ if((direction & (direction - 1)) && mob.loc == n) //moved diagonally successfully
add_delay *= 2
if(mob.loc != oldloc)
move_delay += add_delay
@@ -114,7 +114,7 @@
mob.throwing.finalize(FALSE)
for(var/obj/O in mob.user_movement_hooks)
- O.intercept_user_move(direct, mob, n, oldloc)
+ O.intercept_user_move(direction, mob, n, oldloc)
var/atom/movable/P = mob.pulling
if(P && !ismob(P) && P.density)
@@ -138,22 +138,22 @@
///Process_Incorpmove
///Called by client/Move()
///Allows mobs to run though walls
-/client/proc/Process_Incorpmove(direct)
+/client/proc/Process_Incorpmove(direction)
var/turf/mobloc = get_turf(mob)
if(!isliving(mob))
return
var/mob/living/L = mob
switch(L.incorporeal_move)
if(INCORPOREAL_MOVE_BASIC)
- var/T = get_step(L,direct)
+ var/T = get_step(L,direction)
if(T)
L.forceMove(T)
- L.setDir(direct)
+ L.setDir(direction)
if(INCORPOREAL_MOVE_SHADOW)
if(prob(50))
var/locx
var/locy
- switch(direct)
+ switch(direction)
if(NORTH)
locx = mobloc.x
locy = (mobloc.y+2)
@@ -187,12 +187,12 @@
break
else
new /obj/effect/temp_visual/dir_setting/ninja/shadow(mobloc, L.dir)
- var/T = get_step(L,direct)
+ var/T = get_step(L,direction)
if(T)
L.forceMove(T)
- L.setDir(direct)
+ L.setDir(direction)
if(INCORPOREAL_MOVE_JAUNT) //Incorporeal move, but blocked by holy-watered tiles and salt piles.
- var/turf/open/floor/stepTurf = get_step(L, direct)
+ var/turf/open/floor/stepTurf = get_step(L, direction)
if(stepTurf)
for(var/obj/effect/decal/cleanable/salt/S in stepTurf)
to_chat(L, "[S] bars your passage!")
@@ -209,7 +209,7 @@
return
L.forceMove(stepTurf)
- L.setDir(direct)
+ L.setDir(direction)
return TRUE
From 59ab4c06701ca2f6c0a76051b7367e3466e374ab Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 14 Jan 2020 17:32:54 -0700
Subject: [PATCH 03/13] hm
---
code/modules/atmospherics/gasmixtures/gas_mixture.dm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
index f59bf23b71..e8fa825043 100644
--- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm
+++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
@@ -320,11 +320,11 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
for(var/id in combined)
us = cached_gases[id]
them = sample_gases[id]
- diff = abs(gas_moles - sample_moles)
- if(diff > MINIMUM_MOLES_DELTA_TO_MOVE && diff > gas_moles * MINIMUM_AIR_RATIO_TO_MOVE)
+ diff = abs(us - them)
+ if(diff > MINIMUM_MOLES_DELTA_TO_MOVE && diff > us * MINIMUM_AIR_RATIO_TO_MOVE)
return id
our_moles += us
- if((our_moles > MINIMUM_MOLES_DELTA_TO_MOVE) && (abs(temperature - sample.temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEN))
+ if((our_moles > MINIMUM_MOLES_DELTA_TO_MOVE) && (abs(temperature - sample.temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND))
return "temp"
/datum/gas_mixture/react(datum/holder)
From 41bbdae2207fb9178b27957aa31a916ec99c2310 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 14 Jan 2020 17:50:14 -0700
Subject: [PATCH 04/13] micro optimization
---
code/__DEFINES/admin.dm | 4 ++--
code/__HELPERS/game.dm | 18 +++++++-----------
code/modules/keybindings/bindings_client.dm | 3 +++
code/modules/lighting/lighting_object.dm | 1 -
4 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/code/__DEFINES/admin.dm b/code/__DEFINES/admin.dm
index 3acd1443af..c6be8318fd 100644
--- a/code/__DEFINES/admin.dm
+++ b/code/__DEFINES/admin.dm
@@ -87,5 +87,5 @@
#define MAX_KEYPRESS_COMMANDLENGTH 16
///Max amount of keypress messages per second over two seconds before client is autokicked
#define MAX_KEYPRESS_AUTOKICK 100
-///Length of held key rolling buffer
-#define HELD_KEY_BUFFER_LENGTH 15
+///Length of max held keys
+#define MAX_HELD_KEYS 15
diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm
index ca4b913369..8f41cd621c 100644
--- a/code/__HELPERS/game.dm
+++ b/code/__HELPERS/game.dm
@@ -238,27 +238,24 @@
return found_mobs
-
/proc/get_hearers_in_view(R, atom/source)
// Returns a list of hearers in view(R) from source (ignoring luminosity). Used in saycode.
- var/turf/T = get_turf(source)
- . = list()
-
- if(!T)
+ if(!(source = get_turf(source)))
return
+ . = list()
var/list/processing_list = list()
if (R == 0) // if the range is zero, we know exactly where to look for, we can skip view
- processing_list += T.contents // We can shave off one iteration by assuming turfs cannot hear
+ processing_list += source.contents // We can shave off one iteration by assuming turfs cannot hear
else // A variation of get_hear inlined here to take advantage of the compiler's fastpath for obj/mob in view
- var/lum = T.luminosity
- T.luminosity = 6 // This is the maximum luminosity
- var/list/cachedview = view(R, T)
+ var/lum = source.luminosity
+ source.luminosity = 6 // This is the maximum luminosity
+ var/list/cachedview = view(R, source)
for(var/mob/M in cachedview)
processing_list += M
for(var/obj/O in cachedview)
processing_list += O
- T.luminosity = lum
+ source.luminosity = lum
while(processing_list.len) // recursive_hear_check inlined here
var/atom/A = processing_list[1]
@@ -275,7 +272,6 @@
if(R)
. |= get_hearers_in_view(R.canhear_range, R)
-
#define SIGNV(X) ((X<0)?-1:1)
/proc/inLineOfSight(X1,Y1,X2,Y2,Z=1,PX1=16.5,PY1=16.5,PX2=16.5,PY2=16.5)
diff --git a/code/modules/keybindings/bindings_client.dm b/code/modules/keybindings/bindings_client.dm
index 315ba7a381..cff6bc149b 100644
--- a/code/modules/keybindings/bindings_client.dm
+++ b/code/modules/keybindings/bindings_client.dm
@@ -35,6 +35,9 @@
message_admins("Client [ckey] just attempted to send an invalid keypress. Keymessage was over [MAX_KEYPRESS_COMMANDLENGTH] characters, autokicking due to likely abuse.")
QDEL_IN(src, 1)
return
+
+ if(length(keys_held) > MAX_HELD_KEYS)
+ keys_held.Cut(1,2)
keys_held[_key] = TRUE
var/movement = SSinput.movement_keys[_key]
if(!(next_move_dir_sub & movement) && !keys_held["Ctrl"])
diff --git a/code/modules/lighting/lighting_object.dm b/code/modules/lighting/lighting_object.dm
index 9ceb341f91..e967008afe 100644
--- a/code/modules/lighting/lighting_object.dm
+++ b/code/modules/lighting/lighting_object.dm
@@ -56,7 +56,6 @@
var/turf/oldturf = get_turf(myturf)
var/turf/newturf = get_turf(loc)
warning("A lighting object realised it's loc had changed in update() ([myturf]\[[myturf ? myturf.type : "null"]]([COORD(oldturf)]) -> [loc]\[[ loc ? loc.type : "null"]]([COORD(newturf)]))!")
-
qdel(src, TRUE)
return
From 5f315ab418cdca8c357e2a1d514dbafd479bcbd2 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 14 Jan 2020 18:04:19 -0700
Subject: [PATCH 05/13] ok
---
code/modules/atmospherics/gasmixtures/gas_mixture.dm | 3 +++
code/modules/lighting/lighting_object.dm | 1 +
2 files changed, 4 insertions(+)
diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
index e8fa825043..5b54e58917 100644
--- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm
+++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
@@ -398,3 +398,6 @@ get_true_breath_pressure(pp) --> gas_pp = pp/breath_pp*total_moles()
10/20*5 = 2.5
10 = 2.5/5*20
*/
+
+/datum/gas_mixture/proc/test_garbage_collect()
+ GAS_GARBAGE_COLLECT(gases)
diff --git a/code/modules/lighting/lighting_object.dm b/code/modules/lighting/lighting_object.dm
index e967008afe..9ceb341f91 100644
--- a/code/modules/lighting/lighting_object.dm
+++ b/code/modules/lighting/lighting_object.dm
@@ -56,6 +56,7 @@
var/turf/oldturf = get_turf(myturf)
var/turf/newturf = get_turf(loc)
warning("A lighting object realised it's loc had changed in update() ([myturf]\[[myturf ? myturf.type : "null"]]([COORD(oldturf)]) -> [loc]\[[ loc ? loc.type : "null"]]([COORD(newturf)]))!")
+
qdel(src, TRUE)
return
From 97ded4b27b2b1402fe5ddea7bfda0259aeae6232 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 14 Jan 2020 18:09:12 -0700
Subject: [PATCH 06/13] ok
---
code/controllers/subsystem/time_track.dm | 2 +-
code/modules/keybindings/setup.dm | 3 ---
code/modules/mob/mob.dm | 2 +-
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/code/controllers/subsystem/time_track.dm b/code/controllers/subsystem/time_track.dm
index ac09c3ce65..81146f34d6 100644
--- a/code/controllers/subsystem/time_track.dm
+++ b/code/controllers/subsystem/time_track.dm
@@ -23,7 +23,7 @@ SUBSYSTEM_DEF(time_track)
var/time_dilation_text
/datum/controller/subsystem/time_track/fire()
- stat_time_text = "TIME: Server [time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")] Round [WORLDTIME2TEXT("hh:mm:ss")] Station [STATION_TIME_TIMESTAMP("hh:mm:ss")]\n[time_dilation_text]"
+ stat_time_text = "Server Time: [time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")]\n\nRound Time: [WORLDTIME2TEXT("hh:mm:ss")]\n\nStation Time: [STATION_TIME_TIMESTAMP("hh:mm:ss")]\n[time_dilation_text]"
if(++last_measurement == measurement_delay)
last_measurement = 0
diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm
index 90524f2c66..9a13bfb11c 100644
--- a/code/modules/keybindings/setup.dm
+++ b/code/modules/keybindings/setup.dm
@@ -34,10 +34,7 @@
/client/proc/set_macros()
set waitfor = FALSE
- //Reset and populate the rolling buffer
keys_held.Cut()
- for(var/i in 1 to HELD_KEY_BUFFER_LENGTH)
- keys_held += null
erase_all_macros()
diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm
index 7f4274d43e..53810a8a48 100644
--- a/code/modules/mob/mob.dm
+++ b/code/modules/mob/mob.dm
@@ -579,7 +579,7 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0)
L += "Round ID: [GLOB.round_id || "NULL"]"
L += SStime_track.stat_time_text
L += SSshuttle.emergency_shuttle_stat_text
- stat(null, "[L.Join("\n")]")
+ stat(null, "[L.Join("\n\n")]")
if(client.holder)
if(statpanel("MC"))
From ca47a4e7625e5fa8518406780e687b7dbf87561f Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Wed, 15 Jan 2020 01:23:49 -0700
Subject: [PATCH 07/13] a
---
code/controllers/subsystem/time_track.dm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/controllers/subsystem/time_track.dm b/code/controllers/subsystem/time_track.dm
index 81146f34d6..779b186d08 100644
--- a/code/controllers/subsystem/time_track.dm
+++ b/code/controllers/subsystem/time_track.dm
@@ -23,7 +23,7 @@ SUBSYSTEM_DEF(time_track)
var/time_dilation_text
/datum/controller/subsystem/time_track/fire()
- stat_time_text = "Server Time: [time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")]\n\nRound Time: [WORLDTIME2TEXT("hh:mm:ss")]\n\nStation Time: [STATION_TIME_TIMESTAMP("hh:mm:ss")]\n[time_dilation_text]"
+ stat_time_text = "Server Time: [time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")]\n\nRound Time: [WORLDTIME2TEXT("hh:mm:ss")]\n\nStation Time: [STATION_TIME_TIMESTAMP("hh:mm:ss")]\n\n[time_dilation_text]"
if(++last_measurement == measurement_delay)
last_measurement = 0
From 5c948132676b5295af71d619dd09b87eb1804dee Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Wed, 15 Jan 2020 01:31:49 -0700
Subject: [PATCH 08/13] WHYISTHISLITERALLYWASTINGCPUONANULLFUCKINGLIST
---
code/controllers/subsystem/fail2topic.dm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/controllers/subsystem/fail2topic.dm b/code/controllers/subsystem/fail2topic.dm
index a589ae2462..70080cd18f 100644
--- a/code/controllers/subsystem/fail2topic.dm
+++ b/code/controllers/subsystem/fail2topic.dm
@@ -31,8 +31,8 @@ SUBSYSTEM_DEF(fail2topic)
return ..()
/datum/controller/subsystem/fail2topic/fire()
- while (rate_limiting.len)
- var/ip = rate_limiting[1]
+ for(var/i in 1 to length(rate_limiting)
+ var/ip = rate_limiting[i]
var/last_attempt = rate_limiting[ip]
if (world.time - last_attempt > rate_limit)
From 7fb515173d29d6641746bb762a7273450bba7cad Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Wed, 15 Jan 2020 01:35:03 -0700
Subject: [PATCH 09/13] FUCK
---
code/controllers/subsystem/fail2topic.dm | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/code/controllers/subsystem/fail2topic.dm b/code/controllers/subsystem/fail2topic.dm
index 70080cd18f..b358cc2c5f 100644
--- a/code/controllers/subsystem/fail2topic.dm
+++ b/code/controllers/subsystem/fail2topic.dm
@@ -31,10 +31,9 @@ SUBSYSTEM_DEF(fail2topic)
return ..()
/datum/controller/subsystem/fail2topic/fire()
- for(var/i in 1 to length(rate_limiting)
+ for(var/i in 1 to length(rate_limiting))
var/ip = rate_limiting[i]
var/last_attempt = rate_limiting[ip]
-
if (world.time - last_attempt > rate_limit)
rate_limiting -= ip
fail_counts -= ip
From a99406b46a9658f387a77b9ef0edfd7ebaa96cb3 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Sun, 19 Jan 2020 22:33:16 -0700
Subject: [PATCH 10/13] oh fucking boy
---
code/__DEFINES/atmospherics.dm | 5 ++-
.../environmental/LINDA_turf_tile.dm | 1 +
.../atmospherics/gasmixtures/gas_mixture.dm | 34 ++++++++++++++-----
.../gasmixtures/immutable_mixtures.dm | 1 -
4 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm
index 456582c6a5..47ca0a8ada 100644
--- a/code/__DEFINES/atmospherics.dm
+++ b/code/__DEFINES/atmospherics.dm
@@ -16,6 +16,9 @@
#define T0C 273.15 // 0degC
#define T20C 293.15 // 20degC
+//Quantization
+#define ATMOS_QUANTIZATION_ACCURACY 0.0000001 //gases below this in mols are GC'd
+
#define MOLES_CELLSTANDARD (ONE_ATMOSPHERE*CELL_VOLUME/(T20C*R_IDEAL_GAS_EQUATION)) //moles in a 2.5 m^3 cell at 101.325 Pa and 20 degC
#define M_CELL_WITH_RATIO (MOLES_CELLSTANDARD * 0.005) //compared against for superconductivity
#define O2STANDARD 0.21 //percentage of oxygen in a normal mixture of air
@@ -255,7 +258,7 @@
//HELPERS
#define THERMAL_ENERGY(gas) (gas.temperature * gas.heat_capacity())
-#define QUANTIZE(variable) (round(variable,0.0000001))/*I feel the need to document what happens here. Basically this is used to catch most rounding errors, however it's previous value made it so that
+#define QUANTIZE(variable) (round(variable,ATMOS_QUANTIZATION_ACCURACY))/*I feel the need to document what happens here. Basically this is used to catch most rounding errors, however it's previous value made it so that
once gases got hot enough, most procedures wouldnt occur due to the fact that the mole counts would get rounded away. Thus, we lowered it a few orders of magnititude */
//prefer this to gas_mixture/total_moles in performance critical areas
diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm
index 389f1a69f3..a457482a06 100644
--- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm
+++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm
@@ -90,6 +90,7 @@
/turf/open/archive()
ARCHIVE_TEMPERATURE(air)
+ air.gases_archived = air.gases.Copy()
archived_cycle = SSair.times_fired
temperature_archived = temperature
diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
index 5b54e58917..ff46f9f3ad 100644
--- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm
+++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
@@ -15,15 +15,16 @@ GLOBAL_LIST_INIT(meta_gas_overlays, meta_gas_overlay_list())
GLOBAL_LIST_INIT(meta_gas_dangers, meta_gas_danger_list())
GLOBAL_LIST_INIT(meta_gas_ids, meta_gas_id_list())
GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
+
/datum/gas_mixture
var/list/gases = list()
+ var/tmp/list/gases_archived = list()
var/temperature = 0 //kelvins
var/tmp/temperature_archived = 0
var/volume = CELL_VOLUME //liters
var/last_share = 0
var/list/reaction_results = list()
var/list/analyzer_results //used for analyzer feedback - not initialized until its used
- var/gc_share = FALSE // Whether to call garbage_collect() on the sharer during shares, used for immutable mixtures
/datum/gas_mixture/New(volume)
if (!isnull(volume))
@@ -219,7 +220,7 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
/datum/gas_mixture/share(datum/gas_mixture/sharer, atmos_adjacent_turfs = 4)
- var/list/cached_gases = gases
+ var/list/cached_gases = gases_archived
var/list/sharer_gases = sharer.gases
var/temperature_delta = temperature_archived - sharer.temperature_archived
@@ -242,10 +243,28 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
var/gas_heat_capacity
//and also cache this shit rq because that results in sanic speed for reasons byond explanation
var/list/cached_gasheats = GLOB.meta_gas_specific_heats
+
+ //Do this early and save doing TWO MORE (probable) LIST ACCESSES!!
+ var/our_moles
+ var/their_moles
+
+ //decs are expensive
+ var/us
+ var/them
+
//GAS TRANSFER
for(var/id in cached_gases | sharer_gases) // transfer gases
+ us = cached_gases[id]
+ them = sharer_gases[id]
- delta = QUANTIZE(cached_gases[id] - sharer_gases[id])/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures
+ //buitl in garbage collect
+ if(max(us, them) <= ATMOS_QUANTIZATION_ACCURACY)
+ cached_gases -= id
+ sharer_gases -= id
+ continue
+
+ delta = QUANTIZE(us - them)/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures
+ our_moles += cached
if(delta && abs_temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER)
gas_heat_capacity = delta * cached_gasheats[id]
@@ -259,6 +278,9 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
moved_moles += delta
abs_moved_moles += abs(delta)
+ our_moles += cached_gases[id]
+ their_moles += sharer_gases[id]
+
last_share = abs_moved_moles
//THERMAL ENERGY TRANSFER
@@ -278,13 +300,7 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
if(abs(new_sharer_heat_capacity/old_sharer_heat_capacity - 1) < 0.1) // <10% change in sharer heat capacity
temperature_share(sharer, OPEN_HEAT_TRANSFER_COEFFICIENT)
- if (initial(sharer.gc_share))
- GAS_GARBAGE_COLLECT(sharer.gases)
if(temperature_delta > MINIMUM_TEMPERATURE_TO_MOVE || abs(moved_moles) > MINIMUM_MOLES_DELTA_TO_MOVE)
- var/our_moles
- TOTAL_MOLES(cached_gases,our_moles)
- var/their_moles
- TOTAL_MOLES(sharer_gases,their_moles)
return (temperature_archived*(our_moles + moved_moles) - sharer.temperature_archived*(their_moles - moved_moles)) * R_IDEAL_GAS_EQUATION / volume
/datum/gas_mixture/temperature_share(datum/gas_mixture/sharer, conduction_coefficient, sharer_temperature, sharer_heat_capacity)
diff --git a/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm b/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm
index 5527ba3fef..80f170c707 100644
--- a/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm
+++ b/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm
@@ -3,7 +3,6 @@
/datum/gas_mixture/immutable
var/initial_temperature
- gc_share = TRUE
/datum/gas_mixture/immutable/New()
..()
From 46376904e0594ebeb5a0b26a4625363989a31b84 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Sun, 19 Jan 2020 22:35:46 -0700
Subject: [PATCH 11/13] extra line
---
code/modules/atmospherics/gasmixtures/gas_mixture.dm | 1 -
1 file changed, 1 deletion(-)
diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
index ff46f9f3ad..0d238cd87d 100644
--- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm
+++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
@@ -264,7 +264,6 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
continue
delta = QUANTIZE(us - them)/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures
- our_moles += cached
if(delta && abs_temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER)
gas_heat_capacity = delta * cached_gasheats[id]
From d9a5d12c6365151bcdfc7aff195cb1f220dcd693 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Fri, 24 Jan 2020 03:42:55 -0700
Subject: [PATCH 12/13] Revert atmos
---
.../environmental/LINDA_turf_tile.dm | 1 -
.../atmospherics/gasmixtures/gas_mixture.dm | 70 ++++++++-----------
.../gasmixtures/immutable_mixtures.dm | 1 +
3 files changed, 29 insertions(+), 43 deletions(-)
diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm
index de05e1b4c7..632542f605 100644
--- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm
+++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm
@@ -90,7 +90,6 @@
/turf/open/archive()
ARCHIVE_TEMPERATURE(air)
- air.gases_archived = air.gases.Copy()
archived_cycle = SSair.times_fired
temperature_archived = temperature
diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
index 0d238cd87d..12efa01a38 100644
--- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm
+++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm
@@ -15,16 +15,15 @@ GLOBAL_LIST_INIT(meta_gas_overlays, meta_gas_overlay_list())
GLOBAL_LIST_INIT(meta_gas_dangers, meta_gas_danger_list())
GLOBAL_LIST_INIT(meta_gas_ids, meta_gas_id_list())
GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
-
/datum/gas_mixture
var/list/gases = list()
- var/tmp/list/gases_archived = list()
var/temperature = 0 //kelvins
var/tmp/temperature_archived = 0
var/volume = CELL_VOLUME //liters
var/last_share = 0
var/list/reaction_results = list()
var/list/analyzer_results //used for analyzer feedback - not initialized until its used
+ var/gc_share = FALSE // Whether to call garbage_collect() on the sharer during shares, used for immutable mixtures
/datum/gas_mixture/New(volume)
if (!isnull(volume))
@@ -220,7 +219,7 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
/datum/gas_mixture/share(datum/gas_mixture/sharer, atmos_adjacent_turfs = 4)
- var/list/cached_gases = gases_archived
+ var/list/cached_gases = gases
var/list/sharer_gases = sharer.gases
var/temperature_delta = temperature_archived - sharer.temperature_archived
@@ -243,27 +242,10 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
var/gas_heat_capacity
//and also cache this shit rq because that results in sanic speed for reasons byond explanation
var/list/cached_gasheats = GLOB.meta_gas_specific_heats
-
- //Do this early and save doing TWO MORE (probable) LIST ACCESSES!!
- var/our_moles
- var/their_moles
-
- //decs are expensive
- var/us
- var/them
-
//GAS TRANSFER
for(var/id in cached_gases | sharer_gases) // transfer gases
- us = cached_gases[id]
- them = sharer_gases[id]
- //buitl in garbage collect
- if(max(us, them) <= ATMOS_QUANTIZATION_ACCURACY)
- cached_gases -= id
- sharer_gases -= id
- continue
-
- delta = QUANTIZE(us - them)/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures
+ delta = QUANTIZE(cached_gases[id] - sharer_gases[id])/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures
if(delta && abs_temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER)
gas_heat_capacity = delta * cached_gasheats[id]
@@ -277,9 +259,6 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
moved_moles += delta
abs_moved_moles += abs(delta)
- our_moles += cached_gases[id]
- their_moles += sharer_gases[id]
-
last_share = abs_moved_moles
//THERMAL ENERGY TRANSFER
@@ -299,7 +278,13 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
if(abs(new_sharer_heat_capacity/old_sharer_heat_capacity - 1) < 0.1) // <10% change in sharer heat capacity
temperature_share(sharer, OPEN_HEAT_TRANSFER_COEFFICIENT)
+ if (initial(sharer.gc_share))
+ GAS_GARBAGE_COLLECT(sharer.gases)
if(temperature_delta > MINIMUM_TEMPERATURE_TO_MOVE || abs(moved_moles) > MINIMUM_MOLES_DELTA_TO_MOVE)
+ var/our_moles
+ TOTAL_MOLES(cached_gases,our_moles)
+ var/their_moles
+ TOTAL_MOLES(sharer_gases,their_moles)
return (temperature_archived*(our_moles + moved_moles) - sharer.temperature_archived*(their_moles - moved_moles)) * R_IDEAL_GAS_EQUATION / volume
/datum/gas_mixture/temperature_share(datum/gas_mixture/sharer, conduction_coefficient, sharer_temperature, sharer_heat_capacity)
@@ -325,22 +310,26 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
/datum/gas_mixture/compare(datum/gas_mixture/sample)
var/list/sample_gases = sample.gases //accessing datum vars is slower than proc vars
var/list/cached_gases = gases
- var/list/combined = cached_gases | sample_gases
- // Do not use TOTAL_MOLES, that's an unnecessary iteration.
- var/our_moles
- // Declarations are expensive.
- var/us
- var/them
- var/diff
- for(var/id in combined)
- us = cached_gases[id]
- them = sample_gases[id]
- diff = abs(us - them)
- if(diff > MINIMUM_MOLES_DELTA_TO_MOVE && diff > us * MINIMUM_AIR_RATIO_TO_MOVE)
+
+ for(var/id in cached_gases | sample_gases) // compare gases from either mixture
+ var/gas_moles = cached_gases[id]
+ var/sample_moles = sample_gases[id]
+ var/delta = abs(gas_moles - sample_moles)
+ if(delta > MINIMUM_MOLES_DELTA_TO_MOVE && \
+ delta > gas_moles * MINIMUM_AIR_RATIO_TO_MOVE)
return id
- our_moles += us
- if((our_moles > MINIMUM_MOLES_DELTA_TO_MOVE) && (abs(temperature - sample.temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND))
- return "temp"
+
+ var/our_moles
+ TOTAL_MOLES(cached_gases, our_moles)
+ if(our_moles > MINIMUM_MOLES_DELTA_TO_MOVE)
+ var/temp = temperature
+ var/sample_temp = sample.temperature
+
+ var/temperature_delta = abs(temp - sample_temp)
+ if(temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND)
+ return "temp"
+
+ return ""
/datum/gas_mixture/react(datum/holder)
. = NO_REACTION
@@ -413,6 +402,3 @@ get_true_breath_pressure(pp) --> gas_pp = pp/breath_pp*total_moles()
10/20*5 = 2.5
10 = 2.5/5*20
*/
-
-/datum/gas_mixture/proc/test_garbage_collect()
- GAS_GARBAGE_COLLECT(gases)
diff --git a/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm b/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm
index 80f170c707..5527ba3fef 100644
--- a/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm
+++ b/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm
@@ -3,6 +3,7 @@
/datum/gas_mixture/immutable
var/initial_temperature
+ gc_share = TRUE
/datum/gas_mixture/immutable/New()
..()
From 388e98bd675f93934017bba00a7af27bc668ac41 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Fri, 24 Jan 2020 03:43:52 -0700
Subject: [PATCH 13/13] revert atmos/helpers
---
code/__DEFINES/atmospherics.dm | 5 +----
code/__HELPERS/game.dm | 18 +++++++++++-------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm
index 998c0fe5d6..28554dbd99 100644
--- a/code/__DEFINES/atmospherics.dm
+++ b/code/__DEFINES/atmospherics.dm
@@ -16,9 +16,6 @@
#define T0C 273.15 // 0degC
#define T20C 293.15 // 20degC
-//Quantization
-#define ATMOS_QUANTIZATION_ACCURACY 0.0000001 //gases below this in mols are GC'd
-
#define MOLES_CELLSTANDARD (ONE_ATMOSPHERE*CELL_VOLUME/(T20C*R_IDEAL_GAS_EQUATION)) //moles in a 2.5 m^3 cell at 101.325 Pa and 20 degC
#define M_CELL_WITH_RATIO (MOLES_CELLSTANDARD * 0.005) //compared against for superconductivity
#define O2STANDARD 0.21 //percentage of oxygen in a normal mixture of air
@@ -270,7 +267,7 @@
T.pixel_y = (PipingLayer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_Y;
#define THERMAL_ENERGY(gas) (gas.temperature * gas.heat_capacity())
-#define QUANTIZE(variable) (round(variable,ATMOS_QUANTIZATION_ACCURACY))/*I feel the need to document what happens here. Basically this is used to catch most rounding errors, however it's previous value made it so that
+#define QUANTIZE(variable) (round(variable,0.0000001))/*I feel the need to document what happens here. Basically this is used to catch most rounding errors, however it's previous value made it so that
once gases got hot enough, most procedures wouldnt occur due to the fact that the mole counts would get rounded away. Thus, we lowered it a few orders of magnititude */
//prefer this to gas_mixture/total_moles in performance critical areas
diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm
index 8f41cd621c..ca4b913369 100644
--- a/code/__HELPERS/game.dm
+++ b/code/__HELPERS/game.dm
@@ -238,24 +238,27 @@
return found_mobs
+
/proc/get_hearers_in_view(R, atom/source)
// Returns a list of hearers in view(R) from source (ignoring luminosity). Used in saycode.
- if(!(source = get_turf(source)))
- return
+ var/turf/T = get_turf(source)
. = list()
+ if(!T)
+ return
+
var/list/processing_list = list()
if (R == 0) // if the range is zero, we know exactly where to look for, we can skip view
- processing_list += source.contents // We can shave off one iteration by assuming turfs cannot hear
+ processing_list += T.contents // We can shave off one iteration by assuming turfs cannot hear
else // A variation of get_hear inlined here to take advantage of the compiler's fastpath for obj/mob in view
- var/lum = source.luminosity
- source.luminosity = 6 // This is the maximum luminosity
- var/list/cachedview = view(R, source)
+ var/lum = T.luminosity
+ T.luminosity = 6 // This is the maximum luminosity
+ var/list/cachedview = view(R, T)
for(var/mob/M in cachedview)
processing_list += M
for(var/obj/O in cachedview)
processing_list += O
- source.luminosity = lum
+ T.luminosity = lum
while(processing_list.len) // recursive_hear_check inlined here
var/atom/A = processing_list[1]
@@ -272,6 +275,7 @@
if(R)
. |= get_hearers_in_view(R.canhear_range, R)
+
#define SIGNV(X) ((X<0)?-1:1)
/proc/inLineOfSight(X1,Y1,X2,Y2,Z=1,PX1=16.5,PY1=16.5,PX2=16.5,PY2=16.5)