-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New way of transferring air between zones. #1
Open
Kreastr
wants to merge
1
commit into
SS13:master
Choose a base branch
from
Kreastr:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#define QUANTIZE(variable) (round(variable,0.0001)) | ||
|
||
|
||
zone/proc/process() | ||
. = 1 | ||
|
||
|
@@ -82,16 +84,89 @@ zone/proc/process() | |
if(C.A.zone.air.compare(C.B.zone.air) || total_space) | ||
ZMerge(C.A.zone,C.B.zone) | ||
|
||
//Share some | ||
ShareRequired = 0 | ||
//Share test | ||
for(var/zone/Z in connected_zones) | ||
//Ensure we're not doing pointless calculations on equilibrium zones. | ||
if(abs(air.total_moles - Z.air.total_moles) > 0.1 || abs(air.temperature - Z.air.temperature) > 0.1) | ||
if(abs(Z.air.return_pressure() - air.return_pressure()) > vsc.airflow_lightest_pressure) | ||
Airflow(src,Z) | ||
ShareRatio( air , Z.air , connected_zones[Z]*vsc.zone_share_percent/200 ) | ||
ShareRequired = 1 | ||
//Divided by 200 since each zone is processed. Each connection is considered twice | ||
//Space tiles force it to try and move twice as much air. | ||
|
||
zone/proc/GroupShare() | ||
var/list/Cluster = new/list() | ||
ShareRequired = 0 | ||
Cluster += src | ||
Cluster = JoinCluster(Cluster) | ||
|
||
var/oxy = 0 | ||
var/nitro = 0 | ||
var/co2 = 0 | ||
var/plasma = 0 | ||
var/size = 0 | ||
var/heat = 0 | ||
var/heatcapacity = 0 | ||
var/list/traceavg = new/list() | ||
|
||
for (var/zone/Z in Cluster) | ||
var/zsize = max(1,Z.air.group_multiplier) | ||
oxy += Z.air.oxygen*zsize | ||
nitro += Z.air.nitrogen*zsize | ||
co2 += Z.air.carbon_dioxide*zsize | ||
plasma += Z.air.toxins*zsize | ||
heat += Z.air.temperature*Z.air.heat_capacity()*zsize | ||
heatcapacity += Z.air.heat_capacity()*zsize | ||
size += zsize | ||
for (var/datum/gas/G in Z.air.trace_gases) | ||
var/datum/gas/avgG = locate(G.type) in traceavg | ||
if (avgG) | ||
avgG.moles += G.moles*zsize | ||
else | ||
avgG = new G.type | ||
avgG.moles += G.moles*zsize | ||
traceavg += avgG | ||
|
||
oxy /= size | ||
nitro /= size | ||
plasma /= size | ||
co2 /= size | ||
heat /= heatcapacity //now it is actually an average temperature. | ||
for (var/datum/gas/G in traceavg) | ||
G.moles /= size | ||
|
||
//Each 40 tiles of Cluster size increase the convection process length by 100% | ||
var/ratio=vsc.zone_share_percent/(100+size*2.5) | ||
|
||
for (var/zone/Z in Cluster) | ||
Z.air.oxygen = (Z.air.oxygen - oxy) * (1-ratio) + oxy | ||
Z.air.nitrogen = (Z.air.nitrogen - nitro) * (1-ratio) + nitro | ||
Z.air.carbon_dioxide = (Z.air.carbon_dioxide - co2) * (1-ratio) + co2 | ||
Z.air.toxins = (Z.air.toxins - plasma) * (1-ratio) + plasma | ||
Z.air.temperature = (Z.air.temperature - heat) * (1-ratio) + heat | ||
for (var/datum/gas/G in Z.air.trace_gases) | ||
var/datum/gas/avgG = locate(G.type) in traceavg | ||
if (avgG) | ||
G.moles = (G.moles - avgG.moles)*(1-ratio) + avgG.moles | ||
|
||
for (var/zone/Z in Cluster) | ||
ShareRequired = 0 | ||
Z.air.update_values() | ||
|
||
|
||
|
||
//Iteratively get all connected zones | ||
zone/proc/JoinCluster(var/list/Cluster) | ||
for(var/zone/Z in connected_zones) | ||
if (!(Z in Cluster)) | ||
Cluster += Z | ||
Cluster = Z.JoinCluster(Cluster) | ||
return Cluster | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В этой функции каждая из зон пробегает по своему списку соединенных и добавляет в кластер те, которых там еще нет. После чего для добавленных вызывает себя рекурсивно. |
||
|
||
|
||
|
||
proc/ShareRatio(datum/gas_mixture/A, datum/gas_mixture/B, ratio) | ||
//Shares a specific ratio of gas between mixtures using simple weighted averages. | ||
var | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь происходит отсеивание ненужных вычислений. Если тебе кажется, что до разницы в 0.1 моделировать нет смысла, то можешь это число поднять.
PS Это уравнение неплохо бы дополнить || abs(air.oxygen - Z.air.oxygen) > 0.1 || abs(air.nitrogen - Z.air.nitrogen) > 0.1 || abs(air.carbon_dioxide -Z.air.carbon_dioxide) > 0.1