Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__DEFINES/antagonists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ GLOBAL_LIST_INIT(ai_employers, list(

/// Checks if the given mob is a blood cultist
#define IS_CULTIST(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/cult) || mob?.mind?.has_antag_datum(/datum/antagonist/advanced_cult)) // NON-MODULE CHANGE
/// Gets the antagonist datum for a blood cultist, or null if they are not one.
#define GET_CULTIST(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/cult)) // NON-MODULE CHANGE

/// Checks if the given mob is a changeling
#define IS_CHANGELING(mob) (mob?.mind?.has_antag_datum(/datum/antagonist/changeling))
Expand Down
21 changes: 13 additions & 8 deletions code/__DEFINES/atmospherics/atmos_core.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
//LISTMOS
//indices of values in gas lists.
///Amount of total moles in said gas mixture
#define MOLES 1
///Archived version of MOLES
#define ARCHIVE 2
///All gas related variables
#define GAS_META 3
///Gas specific heat per mole
#define META_GAS_SPECIFIC_HEAT 1
///Name of the gas
Expand All @@ -22,6 +15,8 @@
#define META_GAS_FUSION_POWER 7
///Short description of the gas.
#define META_GAS_DESC 8
///Length of gas meta array
#define META_GAS_LENGTH 8
//ATMOS
//stuff you should probably leave well alone!
/// kPa*L/(K*mol)
Expand Down Expand Up @@ -56,7 +51,7 @@
/// Molar accuracy to round to
#define MOLAR_ACCURACY 1E-4
/// Types of gases (based on gaslist_cache)
#define GAS_TYPE_COUNT GLOB.gaslist_cache.len
#define GAS_TYPE_COUNT 20
/// Maximum error caused by QUANTIZE when removing gas (roughly, in reality around 2 * MOLAR_ACCURACY less)
#define MAXIMUM_ERROR_GAS_REMOVAL (MOLAR_ACCURACY * GAS_TYPE_COUNT)

Expand Down Expand Up @@ -182,3 +177,13 @@
#define ATMOS_PRESSURE_APPROXIMATION_ITERATIONS 20
/// We deal with big numbers and a lot of math, things are bound to get imprecise. Take this traveller.
#define ATMOS_PRESSURE_ERROR_TOLERANCE 0.01
/// Helper function for retrieving gas meta info for use in performace critical places
#define GAS_META /datum/gas_mixture::gas_meta

// Flags for gas-cargo handling
/// Gas can be sold in canisters
#define GAS_EXPORTABLE (1 << 0)
/// Gas can be purchased in canisters
#define GAS_PURCHASABLE (1 << 1)
/// Gas is dangerous and may need additional access
#define GAS_DANGEROUS (1 << 2)
37 changes: 10 additions & 27 deletions code/__DEFINES/atmospherics/atmos_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,24 @@
///Calculate the thermal energy of the selected gas (J)
#define THERMAL_ENERGY(gas) (gas.temperature * gas.heat_capacity())

///Directly adds a gas to a gas mixture without checking for its presence beforehand, use only if is certain the absence of said gas
#define ADD_GAS(gas_id, out_list)\
var/list/tmp_gaslist = GLOB.gaslist_cache[gas_id]; out_list[gas_id] = tmp_gaslist.Copy();

///Adds a gas to a gas mixture but checks if is already present, faster than the same proc
#define ASSERT_GAS(gas_id, gas_mixture) ASSERT_GAS_IN_LIST(gas_id, gas_mixture.gases)

///Adds a gas to a gas LIST but checks if is already present, accepts a list instead of a datum, so faster if the list is locally cached
#define ASSERT_GAS_IN_LIST(gas_id, gases) if (!gases[gas_id]) { ADD_GAS(gas_id, gases) };

//prefer this to gas_mixture/total_moles in performance critical areas
///Calculate the total moles of the gas mixture, faster than the proc, good for performance critical areas
#define TOTAL_MOLES(cached_gases, out_var)\
out_var = 0;\
for(var/total_moles_id in cached_gases){\
out_var += cached_gases[total_moles_id][MOLES];\
}

GLOBAL_LIST_INIT(nonoverlaying_gases, typecache_of_gases_with_no_overlays())
///Returns a list of overlays of every gas in the mixture
#define GAS_OVERLAYS(gases, out_var, z_layer_turf)\
#define GAS_OVERLAYS(moles, out_var, z_layer_turf)\
do { \
out_var = list();\
var/offset = GET_TURF_PLANE_OFFSET(z_layer_turf) + 1;\
for(var/_ID in gases){\
if(GLOB.nonoverlaying_gases[_ID]) continue;\
var/_GAS = gases[_ID];\
var/_GAS_META = _GAS[GAS_META];\
if(_GAS[MOLES] <= _GAS_META[META_GAS_MOLES_VISIBLE]) continue;\
var/_GAS_OVERLAY = _GAS_META[META_GAS_OVERLAY][offset];\
out_var += _GAS_OVERLAY[min(TOTAL_VISIBLE_STATES, CEILING(_GAS[MOLES] / MOLES_GAS_VISIBLE_STEP, 1))];\
} \
var/list/_META_MOLES_VISIBLE = GAS_META[META_GAS_MOLES_VISIBLE];\
var/list/_META_GAS_OVERLAY = GAS_META[META_GAS_OVERLAY];\
for(var/gas_id, amount in moles){\
if(GLOB.nonoverlaying_gases[gas_id]) continue;\
if(amount <= _META_MOLES_VISIBLE[gas_id]) continue;\
var/_GAS_OVERLAY = _META_GAS_OVERLAY[gas_id][offset];\
out_var += _GAS_OVERLAY[min(TOTAL_VISIBLE_STATES, CEILING(amount / MOLES_GAS_VISIBLE_STEP, 1))];\
}\
}\
while (FALSE)


#ifdef TESTING
GLOBAL_LIST_INIT(atmos_adjacent_savings, list(0,0))
#define CALCULATE_ADJACENT_TURFS(T, state) if (SSair.adjacent_rebuild[T]) { GLOB.atmos_adjacent_savings[1] += 1 } else { GLOB.atmos_adjacent_savings[2] += 1; SSair.adjacent_rebuild[T] = state}
Expand Down
7 changes: 7 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,10 @@

//from base of [/obj/effect/particle_effect/fluid/smoke/proc/smoke_mob]: (seconds_per_tick)
#define COMSIG_CARBON_EXPOSED_TO_SMOKE "carbon_exposed_to_smoke"

/// Before a mob starts dreaming - you can add dream datums to the dream pool to override the selection: (list/dream_pool)
#define COMSIG_PRE_DREAMING "pre_dreaming"
/// A mob has started dreaming: (datum/dream/current_dream)
#define COMSIG_START_DREAMING "start_dreaming"
/// A mob has finished dreaming: (datum/dream/finished_dream)
#define COMSIG_END_DREAMING "end_dreaming"
15 changes: 15 additions & 0 deletions code/__DEFINES/economy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@

#define MARKET_PROFIT_MODIFIER 0.8 //We don't make every sale a 1-1 of the actual buy price value, like with real life taxes and to encourage more smart trades

// Fair warning that these defines at present are not used in all tgui, static descriptions, or any varible names or comments
/// The symbol for the default type of money used in the code.
#define MONEY_SYMBOL "cr"
/// The name for the default type of money used in the code.
#define MONEY_NAME "credits"
#define MONEY_NAME_SINGULAR "credit"
#define MONEY_NAME_CAPITALIZED "Credits"
// Due to the ways macros work, I cant just directly use credit\s.
// You will need to verify there is no loose use cases of credit\s.
// As of present there is none left floating around.
#define MONEY_NAME_AUTOPURAL(amount) "credit[##amount == 1 ? "" : "s"]"

#define MONEY_MINING_SYMBOL "mp"
#define MONEY_BITRUNNING_SYMBOL "np"

/// Create quantity subtypes for stock market datums.
#define MARKET_QUANTITY_HELPERS(path) ##path/one {\
amount = 1; \
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
/// Increments a value and wraps it if it exceeds some value. Can be used to circularly iterate through a list through `idx = WRAP_UP(idx, length_of_list)`.
#define WRAP_UP(val, max) (((val) % (max)) + 1)

/// Helper that increments and wraps the passed in number when it hits the integer limit
#define WRAP_UID(val) WRAP_UP(val, SHORT_REAL_LIMIT - 1)

// Real modulus that handles decimals
#define MODULUS(x, y) ( (x) - FLOOR(x, y))

Expand Down
18 changes: 12 additions & 6 deletions code/__DEFINES/reactions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,23 @@

/// The number of moles of hyper-noblium required to prevent reactions.
#define REACTION_OPPRESSION_THRESHOLD 5
/// Minimum temperature required for hypernoblium to prevent reactions.
#define REACTION_OPPRESSION_MIN_TEMP 20

// Halon:
/// The minimum temperature required for halon to form from tritium and BZ.
#define HALON_FORMATION_MIN_TEMPERATURE 30
/// The maximum temperature required for halon to form from tritium and BZ.
#define HALON_FORMATION_MAX_TEMPERATURE 55
/// The amount of energy 4.25 moles of halon forming from tritium and BZ releases.
#define HALON_FORMATION_ENERGY 300
/// Energy released per mole of BZ consumed during halon formation.
#define HALON_FORMATION_ENERGY 91232.1

/// How much energy a mole of halon combusting consumes.
#define HALON_COMBUSTION_ENERGY 2500
/// The minimum temperature required for halon to combust.
#define HALON_COMBUSTION_MIN_TEMPERATURE (T0C + 70)
/// The temperature scale for halon combustion reaction rate.
#define HALON_COMBUSTION_TEMPERATURE_SCALE (FIRE_MINIMUM_TEMPERATURE_TO_EXIST * 10)
/// Amount of halon required to be consumed in order to release resin. This is always possible as long as there's enough gas.
#define HALON_COMBUSTION_MINIMUM_RESIN_MOLES (0.99 * HALON_COMBUSTION_MIN_TEMPERATURE / HALON_COMBUSTION_TEMPERATURE_SCALE)
/// The volume of the resin foam fluid when halon combusts, in turfs.
#define HALON_COMBUSTION_RESIN_VOLUME 1

// Healium:
/// The minimum temperature healium can form from BZ and freon at.
Expand Down
14 changes: 14 additions & 0 deletions code/__DEFINES/religion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@
#define PUNISHMENT_LIGHTNING "lightningbolt"
///brands the sinner
#define PUNISHMENT_BRAND "brand"

/// Failed to bless the target, beat them over the head
#define BLESSING_FAILED "failed"
/// Blessed unsuccessfully, no limbs to heal, robotic limbs, etc
#define BLESSING_IGNORED "ignored"
/// Blessed successfully by healing or whatever
#define BLESSING_SUCCESS "success"

///The rite will automatically delete itself by the religious tool calling it after it's invoked.
#define RITE_AUTO_DELETE (1<<0)
///The rite can be performed multiple times with a religious tool, so don't delete/null it.
#define RITE_ALLOW_MULTIPLE_PERFORMS (1<<1)
///The rite can only be fully performed once, so we'll completely remove it from the rite list afterwards.
#define RITE_ONE_TIME_USE (1<<2)
1 change: 1 addition & 0 deletions code/__DEFINES/span.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#define span_cultboldtalic(str) ("<span class='cultboldtalic'>" + str + "</span>")
#define span_cultitalic(str) ("<span class='cultitalic'>" + str + "</span>")
#define span_cultlarge(str) ("<span class='cultlarge'>" + str + "</span>")
#define span_cyan(str) ("<span class='cyan'>" + str + "</span>")
#define span_danger(str) ("<span class='danger'>" + str + "</span>")
#define span_deadsay(str) ("<span class='deadsay'>" + str + "</span>")
#define span_deconversion_message(str) ("<span class='deconversion_message'>" + str + "</span>")
Expand Down
98 changes: 21 additions & 77 deletions code/__HELPERS/atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
)
if(!gasmix)
return
for(var/gas_path in gasmix.gases)
var/list/cached_gas_id = GAS_META[META_GAS_ID]
var/list/cached_gas_name = GAS_META[META_GAS_NAME]
for(var/gas_path, amount in gasmix.moles)
.["gases"] += list(list(
gasmix.gases[gas_path][GAS_META][META_GAS_ID],
gasmix.gases[gas_path][GAS_META][META_GAS_NAME],
gasmix.gases[gas_path][MOLES],
cached_gas_id[gas_path],
cached_gas_name[gas_path],
amount,
))
for(var/datum/gas_reaction/reaction_result as anything in gasmix.reaction_results)
for(var/datum/gas_reaction/standard/reaction_result as anything in gasmix.reaction_results)
.["reactions"] += list(list(
initial(reaction_result.id),
initial(reaction_result.name),
Expand Down Expand Up @@ -75,17 +77,18 @@ GLOBAL_LIST_EMPTY(gas_handbook)

for (var/datum/gas/gas_path as anything in subtypesof(/datum/gas))
var/list/gas_info = list()
var/list/meta_information = GLOB.meta_gas_info[gas_path]
if(!meta_information)
var/list/meta_information = GLOB.meta_gas_info
if(!meta_information[META_GAS_ID])
continue
gas_info["id"] = meta_information[META_GAS_ID]
gas_info["name"] = meta_information[META_GAS_NAME]
gas_info["description"] = meta_information[META_GAS_DESC]
gas_info["specific_heat"] = meta_information[META_GAS_SPECIFIC_HEAT]
gas_info["id"] = meta_information[META_GAS_ID][gas_path]
gas_info["name"] = meta_information[META_GAS_NAME][gas_path]
gas_info["description"] = meta_information[META_GAS_DESC][gas_path]
gas_info["specific_heat"] = meta_information[META_GAS_SPECIFIC_HEAT][gas_path]
gas_info["export_value"] = (gas_path::cargo_flags & GAS_EXPORTABLE) ? gas_path::base_value : 0
gas_info["reactions"] = list()
momentary_gas_list[gas_path] = gas_info

for (var/datum/gas_reaction/reaction_path as anything in subtypesof(/datum/gas_reaction))
for (var/datum/gas_reaction/standard/reaction_path as anything in valid_subtypesof(/datum/gas_reaction))
var/datum/gas_reaction/reaction = new reaction_path
var/list/reaction_info = list()
reaction_info["id"] = reaction.id
Expand All @@ -107,9 +110,9 @@ GLOBAL_LIST_EMPTY(gas_handbook)
if(factor == "Temperature" || factor == "Pressure")
factor_info["tooltip"] = "Reaction is influenced by the [LOWER_TEXT(factor)] of the place where the reaction is occuring."
else if(factor == "Energy")
factor_info["tooltip"] = "Energy released by the reaction, may or may not result in linear temperature change depending on a slew of other factors."
factor_info["tooltip"] = "Energy released by the reaction. May or may not result in linear temperature change depending on a slew of other factors."
else if(factor == "Radiation")
factor_info["tooltip"] = "This reaction emits dangerous radiation! Take precautions."
factor_info["tooltip"] = "This reaction emits hazardous radiation - take precautions."
else if (factor == "Location")
factor_info["tooltip"] = "This reaction has special behaviour when occuring in specific locations."
else if(factor == "Hot Ice")
Expand All @@ -118,44 +121,13 @@ GLOBAL_LIST_EMPTY(gas_handbook)
GLOB.reaction_handbook += list(reaction_info)
qdel(reaction)

for (var/datum/electrolyzer_reaction/reaction_path as anything in subtypesof(/datum/electrolyzer_reaction))
var/datum/electrolyzer_reaction/reaction = new reaction_path
var/list/reaction_info = list()
reaction_info["id"] = reaction.id
reaction_info["name"] = reaction.name
reaction_info["description"] = reaction.desc
reaction_info["factors"] = list()
for (var/factor in reaction.factor)
var/list/factor_info = list()
factor_info["desc"] = reaction.factor[factor]

if(factor in momentary_gas_list)
momentary_gas_list[factor]["reactions"] += list(reaction.id = reaction.name)
factor_info["factor_id"] = momentary_gas_list[factor]["id"] //Gas id
factor_info["factor_type"] = "gas"
factor_info["factor_name"] = momentary_gas_list[factor]["name"] //Common name
else
factor_info["factor_name"] = factor
factor_info["factor_type"] = "misc"
if(factor == "Temperature" || factor == "Pressure")
factor_info["tooltip"] = "Reaction is influenced by the [LOWER_TEXT(factor)] of the place where the reaction is occuring."
else if(factor == "Energy")
factor_info["tooltip"] = "Energy released by the reaction, may or may not result in linear temperature change depending on a slew of other factors."
else if(factor == "Radiation")
factor_info["tooltip"] = "This reaction emits dangerous radiation! Take precautions."
else if (factor == "Location")
factor_info["tooltip"] = "This reaction has special behaviour when occuring in specific locations."
reaction_info["factors"] += list(factor_info)
GLOB.reaction_handbook += list(reaction_info)
qdel(reaction)

for (var/gas_info_index in momentary_gas_list)
GLOB.gas_handbook += list(momentary_gas_list[gas_info_index])

/// Returns an assoc list of the gas handbook and the reaction handbook.
/// For UIs, simply do data += return_atmos_handbooks() to use.
/proc/return_atmos_handbooks()
return list("gasInfo" = GLOB.gas_handbook, "reactionInfo" = GLOB.reaction_handbook)
return list("gasInfo" = GLOB.gas_handbook, "reactionInfo" = GLOB.reaction_handbook, "moneySymbol" = MONEY_SYMBOL, "moneyName" = MONEY_NAME)

/proc/extract_id_tags(list/objects)
var/list/tags = list()
Expand All @@ -172,37 +144,9 @@ GLOBAL_LIST_EMPTY(gas_handbook)

return null

/**
* A simple helped proc that checks if the contents of a list of gases are within acceptable terms.
*
* Arguments:
* * gases: The list of gases which contents are being checked
* * gases to check: An associated list of gas types and acceptable boundaries in moles. e.g. /datum/gas/oxygen = list(16, 30)
* * * if the assoc list is null, then it'll be considered a safe gas and won't return FALSE.
* * extraneous_gas_limit: If a gas not in gases is found, this is the limit above which the proc will return FALSE.
*/
/proc/check_gases(list/gases, list/gases_to_check, extraneous_gas_limit = 0.1)
gases_to_check = gases_to_check.Copy()
for(var/id in gases)
var/gas_moles = gases[id][MOLES]
if(!(id in gases_to_check))
if(gas_moles > extraneous_gas_limit)
return FALSE
continue
var/list/boundaries = gases_to_check[id]
if(boundaries && !ISINRANGE(gas_moles, boundaries[1], boundaries[2]))
return FALSE
gases_to_check -= id
///Check that gases absent from the turf have a lower boundary of zero or none at all, otherwise return FALSE
for(var/id in gases_to_check)
var/list/boundaries = gases_to_check[id]
if(boundaries && boundaries[1] > 0)
return FALSE
return TRUE

/proc/print_gas_mixture(datum/gas_mixture/gas_mixture)
var/message = "TEMPERATURE: [gas_mixture.temperature]K, QUANTITY: [gas_mixture.total_moles()] mols, VOLUME: [gas_mixture.volume]L; "
for(var/key in gas_mixture.gases)
var/list/gaslist = gas_mixture.gases[key]
message += "[gaslist[GAS_META][META_GAS_ID]]=[gaslist[MOLES]] mols;"
var/list/cached_gas_id = GAS_META[META_GAS_ID]
for(var/gas_id, amount in gas_mixture.moles)
message += "[cached_gas_id[gas_id]]=[amount] mols;"
return message
1 change: 0 additions & 1 deletion code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ GLOBAL_LIST_INIT(WALLITEMS_INTERIOR, typecacheof(list(
/obj/item/radio/intercom,
/obj/structure/secure_safe,
/obj/machinery/airalarm,
/obj/machinery/bluespace_vendor,
/obj/machinery/button,
/obj/machinery/computer/security/telescreen,
/obj/machinery/computer/security/telescreen/entertainment,
Expand Down
13 changes: 7 additions & 6 deletions code/__HELPERS/logging/atmos.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
/proc/log_atmos(text, datum/gas_mixture/gas_mixture)
var/message = "[text]\"[print_gas_mixture(gas_mixture)]\""
//Cache commonly accessed information.
var/list/gases = gas_mixture.gases //List of gas datum paths that are associated with a list of information related to the gases.
var/list/cached_moles = gas_mixture.moles
var/heat_capacity = gas_mixture.heat_capacity()
var/temperature = gas_mixture.return_temperature()
var/thermal_energy = temperature * heat_capacity
var/volume = gas_mixture.return_volume()
var/pressure = gas_mixture.return_pressure()
var/total_moles = gas_mixture.total_moles()
var/list/cached_specific_heat = GAS_META[META_GAS_SPECIFIC_HEAT]
var/list/cached_gas_name = GAS_META[META_GAS_NAME]
///The total value of the gas mixture in credits.
var/total_value = 0
var/list/specific_gas_data = list()

//Gas specific information assigned to each gas.
for(var/datum/gas/gas_path as anything in gases)
var/list/gas = gases[gas_path]
var/moles = gas[MOLES]
for(var/datum/gas/gas_path as anything in cached_moles)
var/moles = cached_moles[gas_path]
var/composition = moles / total_moles
var/energy = temperature * moles * gas[GAS_META][META_GAS_SPECIFIC_HEAT]
var/energy = temperature * moles * cached_specific_heat[gas_path]
var/value = initial(gas_path.base_value) * moles
total_value += value
specific_gas_data[gas[GAS_META][META_GAS_NAME]] = list(
specific_gas_data[cached_gas_name[gas_path]] = list(
"moles" = moles,
"composition" = composition,
"molar concentration" = moles / volume,
Expand Down
Loading
Loading