Skip to content

Commit

Permalink
Merge pull request Aurorastation#7964 from Baystation12/dev-freeze
Browse files Browse the repository at this point in the history
Dev-Freezer -> Master v0.1.17 Botswan Punchout
  • Loading branch information
MistakeNot4892 committed Feb 1, 2015
2 parents d0f5371 + 19f288e commit 20da846
Show file tree
Hide file tree
Showing 1,191 changed files with 44,268 additions and 39,363 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
# needs additional setup, see tools/mapmerge/install.txt
*.dmm merge=merge-dmm

# dmi icon merger hook
# needs additional setup, see tools/dmitool/merging.txt
*.dmi merge=merge-dmi

# force changelog merging to use union
html/changelog.html merge=union
121 changes: 94 additions & 27 deletions baystation12.dme

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions code/ATMOSPHERICS/_atmos_setup.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#define PIPE_COLOR_YELLOW "#ffcc00"
#define PIPE_COLOR_PURPLE "#5c1ec0"

#define CONNECT_TYPE_REGULAR 1
#define CONNECT_TYPE_SUPPLY 2
#define CONNECT_TYPE_SCRUBBER 4

var/global/list/pipe_colors = list("grey" = PIPE_COLOR_GREY, "red" = PIPE_COLOR_RED, "blue" = PIPE_COLOR_BLUE, "cyan" = PIPE_COLOR_CYAN, "green" = PIPE_COLOR_GREEN, "yellow" = PIPE_COLOR_YELLOW, "purple" = PIPE_COLOR_PURPLE)

/proc/pipe_color_lookup(var/color)
Expand Down
29 changes: 11 additions & 18 deletions code/ATMOSPHERICS/_atmospherics_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


/obj/machinery/atmospherics/var/last_flow_rate = 0
/obj/machinery/atmospherics/var/last_power_draw = 0
/obj/machinery/portable_atmospherics/var/last_flow_rate = 0


Expand Down Expand Up @@ -390,21 +391,13 @@

return specific_power

//This proc handles power usages.
//Calling update_use_power() or use_power() too often will result in lag since updating area power can be costly.
//This proc implements an approximation scheme that will cause area power updates to be triggered less often.
//By having atmos machinery use this proc it is easy to change the power usage approximation for all atmos machines
/obj/machinery/proc/handle_power_draw(var/usage_amount)
//This code errs on the side of using more power. Using this will mean that sometimes atmos machines use more power than they need, but won't get power for free.
if (usage_amount > idle_power_usage)
update_use_power(2)
else
if (use_power >= 2)
use_power = 1 //Don't update here. We will use more power than we are supposed to, but trigger less area power updates.
else
update_use_power(1)

switch (use_power)
if (0) return 0
if (1) return idle_power_usage
if (2 to INFINITY) return max(idle_power_usage, usage_amount)
//Calculates the APPROXIMATE amount of moles that would need to be transferred to change the pressure of sink by pressure_delta
//If set, sink_volume_mod adjusts the effective output volume used in the calculation. This is useful when the output gas_mixture is
//part of a pipenetwork, and so it's volume isn't representative of the actual volume since the gas will be shared across the pipenetwork when it processes.
/proc/calculate_transfer_moles(datum/gas_mixture/source, datum/gas_mixture/sink, var/pressure_delta, var/sink_volume_mod=0)
//Make the approximation that the sink temperature is unchanged after transferring gas
var/air_temperature = (sink.temperature > 0)? sink.temperature : source.temperature
var/output_volume = (sink.volume * sink.group_multiplier) + sink_volume_mod

//get the number of moles that would have to be transfered to bring sink to the target pressure
return pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION)
29 changes: 5 additions & 24 deletions code/ATMOSPHERICS/atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Pipelines + Other Objects -> Pipe network
active_power_usage = 0
power_channel = ENVIRON
var/nodealert = 0
var/power_rating //the maximum amount of power the machine can use to do work, affects how powerful the machine is, in Watts

layer = 2.4 //under wires with their 2.44

var/connect_types[] = list(1) //1=regular, 2=supply, 3=scrubber
var/connected_to = 1 //same as above, currently not used for anything
var/connect_types = CONNECT_TYPE_REGULAR
var/icon_connect_type = "" //"-supply" or "-scrubbers"

var/initialize_directions = 0
Expand Down Expand Up @@ -63,29 +63,10 @@ Pipelines + Other Objects -> Pipe network
return 0

obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/atmos1, obj/machinery/atmospherics/atmos2)
var/i
var/list1[] = atmos1.connect_types
var/list2[] = atmos2.connect_types
for(i=1,i<=list1.len,i++)
var/j
for(j=1,j<=list2.len,j++)
if(list1[i] == list2[j])
var/n = list1[i]
return n
return 0

obj/machinery/atmospherics/proc/check_connect_types_construction(obj/machinery/atmospherics/atmos1, obj/item/pipe/pipe2)
var/i
var/list1[] = atmos1.connect_types
var/list2[] = pipe2.connect_types
for(i=1,i<=list1.len,i++)
var/j
for(j=1,j<=list2.len,j++)
if(list1[i] == list2[j])
var/n = list1[i]
return n
return 0
return (atmos1.connect_types & atmos2.connect_types)

/obj/machinery/atmospherics/proc/check_connect_types_construction(obj/machinery/atmospherics/atmos1, obj/item/pipe/pipe2)
return (atmos1.connect_types & pipe2.connect_types)

/obj/machinery/atmospherics/proc/check_icon_cache(var/safety = 0)
if(!istype(icon_manager))
Expand Down
10 changes: 2 additions & 8 deletions code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,13 @@ obj/machinery/atmospherics/binary

for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if (c)
target.connected_to = c
src.connected_to = c
if (check_connect_types(target,src))
node1 = target
break

for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if (c)
target.connected_to = c
src.connected_to = c
if (check_connect_types(target,src))
node2 = target
break

Expand Down
4 changes: 2 additions & 2 deletions code/ATMOSPHERICS/components/binary_devices/circulator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
if (usr.stat || usr.restrained() || anchored)
return

src.dir = turn(src.dir, 90)
src.set_dir(turn(src.dir, 90))
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."


Expand All @@ -123,5 +123,5 @@
if (usr.stat || usr.restrained() || anchored)
return

src.dir = turn(src.dir, -90)
src.set_dir(turn(src.dir, -90))
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
56 changes: 21 additions & 35 deletions code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@

level = 1

use_power = 1
use_power = 0
idle_power_usage = 150 //internal circuitry, friction losses and stuff
active_power_usage = 7500 //This also doubles as a measure of how powerful the pump is, in Watts. 7500 W ~ 10 HP
var/last_power_draw = 0
power_rating = 7500 //7500 W ~ 10 HP

connect_types = list(1,2,3) //connects to regular, supply and scrubbers pipes
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER //connects to regular, supply and scrubbers pipes

var/on = 0
var/pump_direction = 1 //0 = siphoning, 1 = releasing

var/external_pressure_bound = EXTERNAL_PRESSURE_BOUND
Expand Down Expand Up @@ -77,7 +75,7 @@
if(!powered())
vent_icon += "off"
else
vent_icon += "[on ? "[pump_direction ? "out" : "in"]" : "off"]"
vent_icon += "[use_power ? "[pump_direction ? "out" : "in"]" : "off"]"

overlays += icon_manager.get_atmos_icon("device", , , vent_icon)

Expand Down Expand Up @@ -106,10 +104,10 @@
/obj/machinery/atmospherics/binary/dp_vent_pump/process()
..()

if(stat & (NOPOWER|BROKEN) || !on)
update_use_power(0) //usually we get here because a player turned a pump off - definitely want to update.
last_power_draw = 0
last_flow_rate = 0
last_power_draw = 0
last_flow_rate = 0

if(stat & (NOPOWER|BROKEN) || !use_power)
return 0

var/datum/gas_mixture/environment = loc.return_air()
Expand All @@ -122,35 +120,25 @@
if(pressure_delta > 0.5)
if(pump_direction) //internal -> external
if (node1 && (environment.temperature || air1.temperature))
var/output_volume = environment.volume * environment.group_multiplier
var/air_temperature = environment.temperature? environment.temperature : air1.temperature
var/transfer_moles = pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION)

power_draw = pump_gas(src, air1, environment, transfer_moles, active_power_usage)
var/transfer_moles = calculate_transfer_moles(air1, environment)
power_draw = pump_gas(src, air1, environment, transfer_moles, power_rating)

if(power_draw >= 0 && network1)
network1.update = 1
else //external -> internal
if (node2 && (environment.temperature || air2.temperature))
var/output_volume = air2.volume + (network2? network2.volume : 0)
var/air_temperature = air2.temperature? air2.temperature : environment.temperature
var/transfer_moles = pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION)
var/transfer_moles = calculate_transfer_moles(environment, air2, (network2)? network2.volume : 0)

//limit flow rate from turfs
transfer_moles = min(transfer_moles, environment.total_moles*air2.volume/environment.volume) //group_multiplier gets divided out here

power_draw = pump_gas(src, environment, air2, transfer_moles, active_power_usage)
power_draw = pump_gas(src, environment, air2, transfer_moles, power_rating)

if(power_draw >= 0 && network2)
network2.update = 1

if (power_draw < 0)
last_power_draw = 0
last_flow_rate = 0
//update_use_power(0)
use_power = 0 //don't force update - easier on CPU
else
last_power_draw = handle_power_draw(power_draw)
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)

return 1

Expand Down Expand Up @@ -191,7 +179,7 @@
signal.data = list(
"tag" = id,
"device" = "ADVP",
"power" = on,
"power" = use_power,
"direction" = pump_direction?("release"):("siphon"),
"checks" = pressure_checks,
"input" = input_pressure_min,
Expand All @@ -208,12 +196,10 @@
if(frequency)
set_frequency(frequency)

/obj/machinery/atmospherics/binary/dp_vent_pump/examine()
set src in oview(1)
..()
/obj/machinery/atmospherics/binary/dp_vent_pump/examine(mob/user)
if(..(user, 1))
user << "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"

if (get_dist(usr, src) <= 1)
usr << "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"

/obj/machinery/atmospherics/unary/vent_pump/power_change()
var/old_stat = stat
Expand All @@ -225,10 +211,10 @@
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"])
on = text2num(signal.data["power"])
use_power = text2num(signal.data["power"])

if(signal.data["power_toggle"])
on = !on
use_power = !use_power

if(signal.data["direction"])
pump_direction = text2num(signal.data["direction"])
Expand Down
40 changes: 17 additions & 23 deletions code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use_power = 0

var/on = 0 //doesn't actually use power. this is just whether the valve is open or not
var/unlocked = 0 //If 0, then the valve is locked closed, otherwise it is open(-able, it's a one-way valve so it closes if gas would flow backwards).
var/target_pressure = ONE_ATMOSPHERE
var/max_pressure_setting = 15000 //kPa
var/set_flow_rate = ATMOS_DEFAULT_VOLUME_PUMP * 2.5
Expand All @@ -32,7 +32,7 @@
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP * 2.5

/obj/machinery/atmospherics/binary/passive_gate/update_icon()
icon_state = (on && flowing)? "on" : "off"
icon_state = (unlocked && flowing)? "on" : "off"

/obj/machinery/atmospherics/binary/passive_gate/update_underlays()
if(..())
Expand All @@ -48,8 +48,10 @@

/obj/machinery/atmospherics/binary/passive_gate/process()
..()
if(!on)
last_flow_rate = 0

last_flow_rate = 0

if(!unlocked)
return 0

var/output_starting_pressure = air2.return_pressure()
Expand All @@ -73,30 +75,22 @@
//Figure out how much gas to transfer to meet the target pressure.
switch (regulate_mode)
if (REGULATE_INPUT)
var/air_temperature = (air1.temperature > 0)? air1.temperature : air2.temperature
var/input_volume = air1.volume + (network1? network1.volume : 0)
transfer_moles = min(transfer_moles, pressure_delta*input_volume/(air_temperature * R_IDEAL_GAS_EQUATION))
transfer_moles = min(transfer_moles, calculate_transfer_moles(air2, air1, pressure_delta, (network1)? network1.volume : 0))
if (REGULATE_OUTPUT)
var/air_temperature = (air2.temperature > 0)? air2.temperature : air1.temperature
var/output_volume = air2.volume + (network2? network2.volume : 0)

transfer_moles = min(transfer_moles, pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION))
transfer_moles = min(transfer_moles, calculate_transfer_moles(air1, air2, pressure_delta, (network2)? network2.volume : 0))

//pump_gas() will return a negative number if no flow occurred
returnval = pump_gas(src, air1, air2, transfer_moles, available_power=0) //available_power=0 means we only move gas if it would flow naturally

if (returnval < 0)
flowing = 0
last_flow_rate = 0
else
if (returnval >= 0)
if(network1)
network1.update = 1

if(network2)
network2.update = 1

if (!last_flow_rate)
flowing = 0
if (last_flow_rate)
flowing = 1

update_icon()

Expand All @@ -120,7 +114,7 @@
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = on,
"power" = unlocked,
"target_output" = target_pressure,
"regulate_mode" = regulate_mode,
"set_flow_rate" = set_flow_rate,
Expand All @@ -141,10 +135,10 @@
return 0

if("power" in signal.data)
on = text2num(signal.data["power"])
unlocked = text2num(signal.data["power"])

if("power_toggle" in signal.data)
on = !on
unlocked = !unlocked

if("set_target_pressure" in signal.data)
target_pressure = between(
Expand Down Expand Up @@ -188,7 +182,7 @@
var/data[0]

data = list(
"on" = on,
"on" = unlocked,
"pressure_set" = round(target_pressure*100), //Nano UI can't handle rounded non-integers, apparently.
"max_pressure" = max_pressure_setting,
"input_pressure" = round(air1.return_pressure()*100),
Expand All @@ -213,7 +207,7 @@
if(..()) return

if(href_list["toggle_valve"])
on = !on
unlocked = !unlocked

if(href_list["regulate_mode"])
switch(href_list["regulate_mode"])
Expand Down Expand Up @@ -247,7 +241,7 @@
/obj/machinery/atmospherics/binary/passive_gate/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (on)
if (unlocked)
user << "\red You cannot unwrench this [src], turn it off first."
return 1
var/datum/gas_mixture/int_air = return_air()
Expand Down
Loading

0 comments on commit 20da846

Please sign in to comment.