Skip to content

Commit

Permalink
Docking with Baystation..
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieD1 committed May 9, 2015
1 parent c619579 commit fa4bc32
Showing 1,642 changed files with 71,634 additions and 80,113 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
*.dmb
*.lk
*.bak
*.backup
data/
baystation12.int
maps/Phoenix.dmm.backup
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
language: c

env:
BYOND_MAJOR="503"
BYOND_MINOR="1224"
BYOND_MAJOR="507"
BYOND_MINOR="1282"

before_install:
- sudo apt-get update -qq
@@ -17,4 +17,6 @@ install:
- cd ..

script:
- shopt -s globstar
- (! grep 'step_[xy]' maps/**/*.dmm)
- DreamMaker baystation12.dme
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Baystation12 is licensed under the GNU Affero General Public License version 3, which can be found in full in LICENSE-AGPL3.txt.

Commits with a git authorship date prior to `1420675200 +0000` (2015/01/08 00:00) are licensed under the GNU General Public License version 3, which can be found in full in LICENSE-GPL3.txt.

All commits whose authorship dates are not prior to `1420675200 +0000` are assumed to be licensed under AGPL v3, if you wish to license under GPL v3 please make this clear in the commit message and any added files.
8 changes: 6 additions & 2 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Baystation12
Copyright (C) 2010-2014 Baystation12 and tgstation13.
Copyright (C) 2010-2015 Baystation12 and tgstation13.

Baystation12 is licensed under the GNU Affero General Public License version 3, which can be found in full in LICENSE-AGPL3.txt.
Commits with a git authorship date prior to `1420675200 +0000` (2015/01/08 00:00) are licensed under the GNU General Public License version 3, which can be found in full in LICENSE-GPL3.txt.
All commits whose authorship dates are not prior to `1420675200 +0000` are assumed to be licensed under AGPL v3, if you wish to license under GPL v3 please make this clear in the commit message and any added files.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

661 changes: 661 additions & 0 deletions LICENSE-AGPL3.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE-GPL3.txt
Original file line number Diff line number Diff line change
@@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,17 @@

---

### LICENSE
Baystation12 is licensed under the GNU Affero General Public License version 3, which can be found in full in LICENSE-AGPL3.txt.

Commits with a git authorship date prior to `1420675200 +0000` (2015/01/08 00:00) are licensed under the GNU General Public License version 3, which can be found in full in LICENSE-GPL3.txt.

All commits whose authorship dates are not prior to `1420675200 +0000` are assumed to be licensed under AGPL v3, if you wish to license under GPL v3 please make this clear in the commit message and any added files.

If you wish to develop and host this codebase in a closed source manner you may use all commits prior to `1420675200 +0000`, which are licensed under GPL v3. The major change here is that if you host a server using any code licensed under AGPLv3 you are required to provide full source code for your servers users as well including addons and modifications you have made.

See [here](https://www.gnu.org/licenses/why-affero-gpl.html) for more information.

### GETTING THE CODE
The simplest way to obtain the code is using the github .zip feature.

4 changes: 4 additions & 0 deletions code/ATMOSPHERICS/_atmos_setup.dm
Original file line number Diff line number Diff line change
@@ -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)
106 changes: 72 additions & 34 deletions code/ATMOSPHERICS/_atmospherics_helpers.dm
Original file line number Diff line number Diff line change
@@ -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


@@ -25,11 +26,9 @@
//transfer_moles - Limits the amount of moles to transfer. The actual amount of gas moved may also be limited by available_power, if given.
//available_power - the maximum amount of power that may be used when moving gas. If null then the transfer is not limited by power.
/proc/pump_gas(var/obj/machinery/M, var/datum/gas_mixture/source, var/datum/gas_mixture/sink, var/transfer_moles = null, var/available_power = null)
if (source.total_moles < MINUMUM_MOLES_TO_PUMP) //if we cant transfer enough gas just stop to avoid further processing
if (source.total_moles < MINIMUM_MOLES_TO_PUMP) //if we cant transfer enough gas just stop to avoid further processing
return -1

//var/source_moles_initial = source.total_moles

if (isnull(transfer_moles))
transfer_moles = source.total_moles
else
@@ -40,7 +39,7 @@
if (!isnull(available_power) && specific_power > 0)
transfer_moles = min(transfer_moles, available_power / specific_power)

if (transfer_moles < MINUMUM_MOLES_TO_PUMP) //if we cant transfer enough gas just stop to avoid further processing
if (transfer_moles < MINIMUM_MOLES_TO_PUMP) //if we cant transfer enough gas just stop to avoid further processing
return -1

//Update flow rate meter
@@ -68,13 +67,47 @@

return power_draw

//Gas 'pumping' proc for the case where the gas flow is passive and driven entirely by pressure differences (but still one-way).
/proc/pump_gas_passive(var/obj/machinery/M, var/datum/gas_mixture/source, var/datum/gas_mixture/sink, var/transfer_moles = null)
if (source.total_moles < MINIMUM_MOLES_TO_PUMP) //if we cant transfer enough gas just stop to avoid further processing
return -1

if (isnull(transfer_moles))
transfer_moles = source.total_moles
else
transfer_moles = min(source.total_moles, transfer_moles)

var/equalize_moles = calculate_equalize_moles(source, sink)
transfer_moles = min(transfer_moles, equalize_moles)

if (transfer_moles < MINIMUM_MOLES_TO_PUMP) //if we cant transfer enough gas just stop to avoid further processing
return -1

//Update flow rate meter
if (istype(M, /obj/machinery/atmospherics))
var/obj/machinery/atmospherics/A = M
A.last_flow_rate = (transfer_moles/source.total_moles)*source.volume //group_multiplier gets divided out here
if (A.debug)
A.visible_message("[A]: moles transferred = [transfer_moles] mol")

if (istype(M, /obj/machinery/portable_atmospherics))
var/obj/machinery/portable_atmospherics/P = M
P.last_flow_rate = (transfer_moles/source.total_moles)*source.volume //group_multiplier gets divided out here

var/datum/gas_mixture/removed = source.remove(transfer_moles)
if(!removed) //Just in case
return -1
sink.merge(removed)

return 0

//Generalized gas scrubbing proc.
//Selectively moves specified gasses one gas_mixture to another and returns the amount of power needed (assuming 1 second), or -1 if no gas was filtered.
//filtering - A list of gasids to be scrubbed from source
//total_transfer_moles - Limits the amount of moles to scrub. The actual amount of gas scrubbed may also be limited by available_power, if given.
//available_power - the maximum amount of power that may be used when scrubbing gas. If null then the scrubbing is not limited by power.
/proc/scrub_gas(var/obj/machinery/M, var/list/filtering, var/datum/gas_mixture/source, var/datum/gas_mixture/sink, var/total_transfer_moles = null, var/available_power = null)
if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (source.total_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

filtering = filtering & source.gas //only filter gasses that are actually there. DO NOT USE &=
@@ -83,14 +116,14 @@
var/total_filterable_moles = 0 //the total amount of filterable gas
var/list/specific_power_gas = list() //the power required to remove one mole of pure gas, for each gas type
for (var/g in filtering)
if (source.gas[g] < MINUMUM_MOLES_TO_FILTER)
if (source.gas[g] < MINIMUM_MOLES_TO_FILTER)
continue

var/specific_power = calculate_specific_power_gas(g, source, sink)/ATMOS_FILTER_EFFICIENCY
specific_power_gas[g] = specific_power
total_filterable_moles += source.gas[g]

if (total_filterable_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (total_filterable_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

//now that we know the total amount of filterable gas, we can calculate the amount of power needed to scrub one mole of gas
@@ -109,7 +142,7 @@
if (!isnull(available_power) && total_specific_power > 0)
total_transfer_moles = min(total_transfer_moles, available_power/total_specific_power)

if (total_transfer_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (total_transfer_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

//Update flow rate var
@@ -145,7 +178,7 @@
//total_transfer_moles - Limits the amount of moles to input. The actual amount of gas filtered may also be limited by available_power, if given.
//available_power - the maximum amount of power that may be used when filtering gas. If null then the filtering is not limited by power.
/proc/filter_gas(var/obj/machinery/M, var/list/filtering, var/datum/gas_mixture/source, var/datum/gas_mixture/sink_filtered, var/datum/gas_mixture/sink_clean, var/total_transfer_moles = null, var/available_power = null)
if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (source.total_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

filtering = filtering & source.gas //only filter gasses that are actually there. DO NOT USE &=
@@ -155,7 +188,7 @@
var/total_unfilterable_moles = 0 //the total amount of non-filterable gas
var/list/specific_power_gas = list() //the power required to remove one mole of pure gas, for each gas type
for (var/g in source.gas)
if (source.gas[g] < MINUMUM_MOLES_TO_FILTER)
if (source.gas[g] < MINIMUM_MOLES_TO_FILTER)
continue

if (g in filtering)
@@ -178,7 +211,7 @@
if (!isnull(available_power) && total_specific_power > 0)
total_transfer_moles = min(total_transfer_moles, available_power/total_specific_power)

if (total_transfer_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (total_transfer_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

//Update flow rate var
@@ -217,7 +250,7 @@
//I don't like the copypasta, but I decided to keep both versions of gas filtering as filter_gas is slightly faster (doesn't create as many temporary lists, doesn't call update_values() as much)
//filter_gas can be removed and replaced with this proc if need be.
/proc/filter_gas_multi(var/obj/machinery/M, var/list/filtering, var/datum/gas_mixture/source, var/datum/gas_mixture/sink_clean, var/total_transfer_moles = null, var/available_power = null)
if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (source.total_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

filtering = filtering & source.gas //only filter gasses that are actually there. DO NOT USE &=
@@ -227,7 +260,7 @@
var/total_unfilterable_moles = 0 //the total amount of non-filterable gas
var/list/specific_power_gas = list() //the power required to remove one mole of pure gas, for each gas type
for (var/g in source.gas)
if (source.gas[g] < MINUMUM_MOLES_TO_FILTER)
if (source.gas[g] < MINIMUM_MOLES_TO_FILTER)
continue

if (g in filtering)
@@ -251,7 +284,7 @@
if (!isnull(available_power) && total_specific_power > 0)
total_transfer_moles = min(total_transfer_moles, available_power/total_specific_power)

if (total_transfer_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (total_transfer_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

//Update Flow Rate var
@@ -303,7 +336,7 @@
var/total_input_moles = 0 //for flow rate calculation
var/list/source_specific_power = list()
for (var/datum/gas_mixture/source in mix_sources)
if (source.total_moles < MINUMUM_MOLES_TO_FILTER)
if (source.total_moles < MINIMUM_MOLES_TO_FILTER)
return -1 //either mix at the set ratios or mix no gas at all

var/mix_ratio = mix_sources[source]
@@ -320,7 +353,7 @@
total_input_volume += source.volume
total_input_moles += source.total_moles

if (total_mixing_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (total_mixing_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

if (isnull(total_transfer_moles))
@@ -332,7 +365,7 @@
if (!isnull(available_power) && total_specific_power > 0)
total_transfer_moles = min(total_transfer_moles, available_power / total_specific_power)

if (total_transfer_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
if (total_transfer_moles < MINIMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1

//Update flow rate var
@@ -390,21 +423,26 @@

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)
//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)

//Calculates the APPROXIMATE amount of moles that would need to be transferred to bring source and sink to the same pressure
/proc/calculate_equalize_moles(datum/gas_mixture/source, datum/gas_mixture/sink)
if(source.temperature == 0) return 0

//Make the approximation that the sink temperature is unchanged after transferring gas
var/source_volume = source.volume * source.group_multiplier
var/sink_volume = sink.volume * sink.group_multiplier

var/source_pressure = source.return_pressure()
var/sink_pressure = sink.return_pressure()

switch (use_power)
if (0) return 0
if (1) return idle_power_usage
if (2 to INFINITY) return max(idle_power_usage, usage_amount)
return (source_pressure - sink_pressure)/(R_IDEAL_GAS_EQUATION * (source.temperature/source_volume + sink.temperature/sink_volume))
29 changes: 5 additions & 24 deletions code/ATMOSPHERICS/atmospherics.dm
Original file line number Diff line number Diff line change
@@ -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
@@ -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))
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
@@ -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

Loading

0 comments on commit fa4bc32

Please sign in to comment.