Skip to content

Commit 9c95f72

Browse files
Merge pull request #132 from MistakeNot4892/pyrelight
Updating from Neb dev.
2 parents 19842c1 + baf2751 commit 9c95f72

File tree

414 files changed

+2117
-1748
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

414 files changed

+2117
-1748
lines changed

code/__defines/chemistry.dm

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,30 @@
7878
#define HANDLE_REACTIONS(_reagents) if(!QDELETED(_reagents)) { SSmaterials.active_holders[_reagents] = TRUE; }
7979
#define UNQUEUE_REACTIONS(_reagents) SSmaterials.active_holders -= _reagents
8080

81-
#define REAGENT_LIST(R) (R.reagents?.get_reagents() || "No reagent holder")
81+
#define REAGENT_LIST(R) ((istype(R, /datum/reagents) && R:get_reagents()) || "No reagent holder")
82+
83+
#define REAGENT_TOTAL_VOLUME(R) (UNLINT((istype(R, /datum/reagents) && R:total_volume) || 0))
84+
#define REAGENT_TOTAL_LIQUID_VOLUME(R) (UNLINT((istype(R, /datum/reagents) && R:total_liquid_volume) || 0))
85+
86+
#define REAGENT_MAXIMUM_VOLUME(R) (UNLINT((istype(R, /datum/reagents) && R:maximum_volume) || 0))
87+
#define REAGENTS_FREE_SPACE(R) (UNLINT(istype(R, /datum/reagents) ? (R.maximum_volume - R.total_volume) : 0))
88+
89+
#define REAGENT_VOLUMES(R) ( (istype(R, /datum/reagents) && UNLINT(R:reagent_volumes)) || null )
90+
#define REAGENT_SOLID_VOLUMES(R) ( (istype(R, /datum/reagents) && UNLINT(R:solid_volumes)) || null )
91+
#define REAGENT_LIQUID_VOLUMES(R) ( (istype(R, /datum/reagents) && UNLINT(R:liquid_volumes)) || null )
92+
#define REAGENT_GET_MAX_VOL(R) ( (istype(R, /datum/reagents) && UNLINT(R:maximum_volume)) || 0 )
93+
#define REAGENT_GET_ATOM(R) ( (istype(R, /datum/reagents) && UNLINT(R:my_atom)) || null )
94+
95+
#define REAGENT_VOLUME(R, M) ( istype(R, /datum/reagents) && UNLINT(R:reagent_volumes && R:reagent_volumes[RESOLVE_TO_DECL(M)]) )
96+
#define LIQUID_VOLUME(R, M) ( istype(R, /datum/reagents) && UNLINT(R:liquid_volumes && R:liquid_volumes[RESOLVE_TO_DECL(M)]) )
97+
#define SOLID_VOLUME(R, M) ( istype(R, /datum/reagents) && UNLINT(R:solid_volumes && R:solid_volumes[RESOLVE_TO_DECL(M)]) )
98+
#define REAGENT_DATA(R, M) ( istype(R, /datum/reagents) && UNLINT(R:reagent_data && R:reagent_data[RESOLVE_TO_DECL(M)]) )
99+
100+
#define REAGENT_SET_MAX_VOL(R, V) if(istype(R, /datum/reagents)) { UNLINT(R:maximum_volume = V) }
101+
#define REAGENT_ADD_MAX_VOL(R, V) if(istype(R, /datum/reagents)) { UNLINT(R:maximum_volume += V) }
102+
#define REAGENT_SET_ATOM(R, A) if(istype(R, /datum/reagents)) { UNLINT(R:my_atom = A) }
103+
#define REAGENT_SET_DATA(R, M, D) if(istype(R, /datum/reagents)) { LAZYSET(UNLINT(R:reagent_data), M, D) }
82104

83-
#define REAGENTS_FREE_SPACE(R) (R?.maximum_volume - R?.total_volume)
84-
#define REAGENT_VOLUME(REAGENT_HOLDER, REAGENT_TYPE) (REAGENT_HOLDER?.reagent_volumes && REAGENT_HOLDER.reagent_volumes[RESOLVE_TO_DECL(REAGENT_TYPE)])
85-
#define LIQUID_VOLUME(REAGENT_HOLDER, REAGENT_TYPE) (REAGENT_HOLDER?.liquid_volumes && REAGENT_HOLDER.liquid_volumes[RESOLVE_TO_DECL(REAGENT_TYPE)])
86-
#define SOLID_VOLUME(REAGENT_HOLDER, REAGENT_TYPE) (REAGENT_HOLDER?.solid_volumes && REAGENT_HOLDER.solid_volumes[RESOLVE_TO_DECL(REAGENT_TYPE)])
87-
#define REAGENT_DATA(REAGENT_HOLDER, REAGENT_TYPE) (REAGENT_HOLDER?.reagent_data && REAGENT_HOLDER.reagent_data[RESOLVE_TO_DECL(REAGENT_TYPE)])
88105

89106
#define CHEM_DOSE(M, R) LAZYACCESS(M._chem_doses, RESOLVE_TO_DECL(R))
90107

code/__defines/damage_organs.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
#define ORGAN_CATEGORY_STANCE "stance"
7878
/// Limb is considered the 'root' of a given stance limb (leg) - also counted for stance damage a la ORGAN_CATEGORY_STANCE
7979
#define ORGAN_CATEGORY_STANCE_ROOT "stance_root"
80+
// Limb is considered a manipulator, currently only used when trying to pilot a wheelchair.
81+
#define ORGAN_CATEGORY_MANIPLE "maniple"
8082

8183
// Droplimb types.
8284
#define DISMEMBER_METHOD_EDGE 0

code/__defines/mobs.dm

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,30 +150,15 @@
150150
#define BP_EYES "eyes"
151151
#define BP_HEART "heart"
152152
#define BP_LUNGS "lungs"
153-
#define BP_TRACH "tracheae"
154153
#define BP_BRAIN "brain"
155154
#define BP_LIVER "liver"
156155
#define BP_KIDNEYS "kidneys"
157156
#define BP_STOMACH "stomach"
158-
#define BP_PLASMA "plasma vessel"
159157
#define BP_APPENDIX "appendix"
160158
#define BP_CELL "cell"
161-
#define BP_HIVE "hive node"
162-
#define BP_NUTRIENT "nutrient vessel"
163-
#define BP_ACID "acid gland"
164-
#define BP_EGG "egg sac"
165-
#define BP_RESIN "resin spinner"
166-
#define BP_STRATA "neural strata"
167-
#define BP_RESPONSE "response node"
168-
#define BP_GBLADDER "gas bladder"
169-
#define BP_POLYP "polyp segment"
170-
#define BP_ANCHOR "anchoring ligament"
171-
#define BP_ACETONE "acetone reactor"
172159

173160
// Robo Organs.
174161
#define BP_VOICE "vocal synthesiser"
175-
#define BP_STACK "stack"
176-
#define BP_OPTICS "optics"
177162

178163
//Augmetations
179164
#define BP_AUGMENT_R_ARM "right arm augment"
@@ -351,6 +336,7 @@ var/global/list/dexterity_levels = list(
351336
// Additional pronoun sets.
352337
#define NEUTER_ANIMATE "animate singular neutral"
353338
#define SECOND_PERSON_SINGULAR "second person singular"
339+
#define PSEUDOPLURAL "pseudoplural"
354340

355341
// Equipment Overlays Indices //
356342
#define HO_CONDITION_LAYER 1

code/_helpers/global_lists.dm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ var/global/list/string_slot_flags = list(
3737
)
3838

3939
// Used to avoid constantly generating new lists during movement.
40+
var/global/list/all_maniple_limbs = list(
41+
(ORGAN_CATEGORY_MANIPLE)
42+
)
4043
var/global/list/all_stance_limbs = list(
41-
ORGAN_CATEGORY_STANCE,
42-
ORGAN_CATEGORY_STANCE_ROOT
44+
(ORGAN_CATEGORY_STANCE),
45+
(ORGAN_CATEGORY_STANCE_ROOT)
4346
)
4447
var/global/list/child_stance_limbs = list(
45-
ORGAN_CATEGORY_STANCE
48+
(ORGAN_CATEGORY_STANCE)
4649
)
4750

4851
// TODO: Replace keybinding datums with keybinding decls to make this unnecessary.

code/_helpers/lists.dm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
input -= thing
2828
var/thing_string = isatom(thing) ? thing.name : "\proper [thing]"
2929
thing_count[thing_string] += 1
30-
thing_gender[thing_string] = isatom(thing) ? thing.gender : NEUTER
30+
if(ismob(thing))
31+
var/mob/mob_thing = thing
32+
thing_gender[thing_string] = mob_thing.get_gender()
33+
else
34+
thing_gender[thing_string] = isatom(thing) ? thing.gender : NEUTER
3135
input = list()
3236
for(var/thing_string in thing_count)
3337
if(thing_count[thing_string] == 1)
3438
input += "\the [thing_string]"
3539
else
36-
input += "[thing_count[thing_string]] [thing_string][thing_gender[thing_string] == PLURAL ? "" : "s"]"
40+
input += "[thing_count[thing_string]] [thing_gender[thing_string] == PLURAL ? text_make_plural(thing_string) : thing_string]"
3741

3842
switch(length(input))
3943
if(1)
@@ -172,7 +176,7 @@
172176

173177
//Checks for specific types in specifically structured (Assoc "type" = TRUE) lists ('typecaches')
174178
/proc/is_type_in_typecache(atom/A, list/cache)
175-
if(!cache || !cache.len || !A)
179+
if(!LAZYLEN(cache) || !A)
176180
return 0
177181
return cache[A.type]
178182

code/_helpers/medical_scans.dm

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@
4242
.["immune_system"] = get_immunity()
4343
.["reagents"] = list()
4444

45-
if(reagents?.total_volume)
46-
for(var/decl/material/reagent as anything in reagents.liquid_volumes)
45+
if(REAGENT_TOTAL_VOLUME(reagents))
46+
for(var/decl/material/reagent as anything in REAGENT_LIQUID_VOLUMES(reagents))
4747
var/list/reagent_data = list()
4848
reagent_data["name"] = reagent.get_reagent_name(reagents, MAT_PHASE_LIQUID)
4949
reagent_data["quantity"] = round(REAGENT_VOLUME(reagents, reagent),1)
5050
reagent_data["scannable"] = reagent.scannable
5151
.["reagents"] += list(reagent_data)
52-
53-
for(var/decl/material/reagent as anything in reagents.solid_volumes)
52+
for(var/decl/material/reagent as anything in REAGENT_SOLID_VOLUMES(reagents))
5453
var/list/reagent_data = list()
5554
reagent_data["name"] = reagent.get_reagent_name(reagents, MAT_PHASE_SOLID)
5655
reagent_data["quantity"] = round(REAGENT_VOLUME(reagents, reagent),1)
@@ -98,8 +97,8 @@
9897
.["blood_pressure"] = get_blood_pressure()
9998
.["blood_o2"] = get_blood_oxygenation()
10099
if(vessel)
101-
.["blood_volume"] = vessel.total_volume
102-
.["blood_volume_max"] = vessel.maximum_volume
100+
.["blood_volume"] = REAGENT_TOTAL_VOLUME(vessel)
101+
.["blood_volume_max"] = REAGENT_MAXIMUM_VOLUME(vessel)
103102

104103
/proc/display_medical_data_header(var/list/scan, skill_level = SKILL_DEFAULT)
105104
//In case of problems, abort.

code/_helpers/text.dm

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,22 @@ var/global/regex/starts_lowercase_regex = regex(@"^[a-z]")
366366
return trim_left(trim_right(text))
367367

368368
//Returns a string with the first element of the string capitalized.
369+
// NOTE: This will not work if there are any HTML tags.
369370
/proc/capitalize(text)
370371
if(text)
371372
text = uppertext(text[1]) + copytext(text, 1 + length(text[1]))
372373
return text
373374

375+
// Returns a string with the first alphabetical element of the string capitalized, skipping HTML tags.
376+
/proc/capitalize_proper_html(text)
377+
var/static/regex/split_html_regex = regex(@"(^<[^>]*>)([A-Za-z])(.+)$")
378+
if(!text)
379+
return text
380+
if(!split_html_regex.Find(text))
381+
return capitalize(text)
382+
split_html_regex.group[2] = uppertext(split_html_regex.group[2])
383+
return JOINTEXT(split_html_regex.group)
384+
374385
//Returns a string with the first element of the every word of the string capitalized.
375386
/proc/capitalize_words(text)
376387
var/list/S = splittext(text, " ")
@@ -784,6 +795,48 @@ var/global/list/plural_words_unchanged = list(
784795
word = "[jointext(splited, " ", 1, length(splited))] [word]"
785796
return word
786797

798+
var/global/list/copula_verbs = list("is" = TRUE, "am" = TRUE, "are" = TRUE)
799+
var/global/list/has_verbs = list("has" = TRUE, "have" = TRUE)
800+
var/global/list/does_verbs = list("does" = TRUE, "do" = TRUE)
801+
var/global/list/agreement_exception_verbs = list("can" = TRUE, "cannot" = TRUE, "can't" = TRUE, "will" = TRUE, "won't" = TRUE, "shall" = TRUE, "shan't" = TRUE, "may" = TRUE, "must" = TRUE, "ought" = TRUE, "could" = TRUE, "would" = TRUE, "should" = TRUE)
802+
/proc/verb_agree_with_pronouns(var/use_verb, var/decl/pronouns/use_pronouns, is_after_pronoun = TRUE)
803+
// deal with compound verb phrases here!
804+
// basically, skip all our adverbs, inflect only the first non-adverb word we find (which is hopefully a verb) and then keep everything after unchanged
805+
// this will properly handle "successfully finish doing" and "properly manage to do"
806+
// but not "somehow finish doing" which will get turned into "somehows finish doing" :(
807+
// todo: fix that
808+
var/list/words = splittext(use_verb, " ")
809+
if(length(words) > 1)
810+
var/last_adverb = 1
811+
for(var/word_index in 1 to length(words))
812+
if(text_ends_with(words[word_index], "ly"))
813+
last_adverb = max(word_index, last_adverb)
814+
use_verb = words[last_adverb]
815+
// This overengineered nonsense ensures that we shouldn't end up with any doubled or missing spaces.
816+
return jointext_no_nulls(list(jointext(words.Copy(1, last_adverb), " "), verb_agree_with_pronouns(use_verb, use_pronouns, is_after_pronoun = is_after_pronoun), jointext(words.Copy(last_adverb + 1, length(words) + 1), " ")), " ")
817+
if(!is_after_pronoun && use_pronouns.pluralize_verb == /decl/pronouns::PLURALIZE_PSEUDO)
818+
return use_verb // do not inflect pseudoplural unless after a pronoun
819+
if(global.copula_verbs[use_verb])
820+
return use_pronouns.is
821+
else if(global.has_verbs[use_verb])
822+
return use_pronouns.has
823+
else if(global.does_verbs[use_verb])
824+
return use_pronouns.does
825+
else if(global.agreement_exception_verbs[use_verb])
826+
return use_verb
827+
// text_make_plural is intended for nouns, but should hopefully work for "fly" -> "flies" and similar.
828+
switch(use_pronouns.pluralize_verb)
829+
if(/decl/pronouns::PLURALIZE_NONE)
830+
return use_verb
831+
if(/decl/pronouns::PLURALIZE_PSEUDO)
832+
// technically only the plural side can get hit here
833+
// but better safe than sorry
834+
return is_after_pronoun ? text_make_plural(use_verb) : use_verb
835+
if(/decl/pronouns::PLURALIZE_ALL)
836+
return text_make_plural(use_verb)
837+
else
838+
CRASH("Invalid value [use_pronouns.pluralize_verb] for [use_pronouns]!")
839+
787840
// Surely we have this defined somewhere already??
788841
/proc/repeatstring(str, num)
789842
. = list()

code/_helpers/unsorted.dm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -765,15 +765,17 @@ var/global/list/WALLITEMS = list(
765765

766766
/**Returns a number string with its ordinal suffix th, st, nd, rd */
767767
/proc/get_ordinal_string(var/num)
768-
if(num < 10 && num > 20) //11, 12, 13 are exceptions in english, and just get 'th' like everything else
768+
. = num
769+
num %= 100
770+
if(num < 10 || num > 20) //11, 12, 13 are exceptions in english, and just get 'th' like everything else
769771
switch(num % 10)
770772
if(1)
771-
return "[num]st"
773+
return "[.]st"
772774
if(2)
773-
return "[num]nd"
775+
return "[.]nd"
774776
if(3)
775-
return "[num]rd"
776-
return "[num]th"
777+
return "[.]rd"
778+
return "[.]th"
777779

778780
///A do nothing proc used to prevent empty block warnings
779781
///In hot code (like atmos checks), use EMPTY_BLOCK_GUARD instead.

code/controllers/subsystems/event.dm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ SUBSYSTEM_DEF(event)
2828
/datum/controller/subsystem/event/Initialize()
2929

3030
if(!event_containers)
31+
// Order must conform to EVENT_LEVEL_MUNDANE, EVENT_LEVEL_MODERATE, EVENT_LEVEL_MAJOR.
3132
event_containers = list(
32-
EVENT_LEVEL_MUNDANE = new global.using_map.event_container_mundane,
33-
EVENT_LEVEL_MODERATE = new global.using_map.event_container_moderate,
34-
EVENT_LEVEL_MAJOR = new global.using_map.event_container_major
33+
new global.using_map.event_container_mundane,
34+
new global.using_map.event_container_moderate,
35+
new global.using_map.event_container_major
3536
)
3637
all_events = null
3738

code/controllers/subsystems/fluids.dm

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ SUBSYSTEM_DEF(fluids)
100100
i++
101101
current_fluid_holder = processing_fluids[i]
102102

103-
if(QDELETED(current_fluid_holder) || !current_fluid_holder.reagents?.total_volume)
103+
if(QDELETED(current_fluid_holder) || !REAGENT_TOTAL_VOLUME(current_fluid_holder.reagents))
104104
REMOVE_ACTIVE_FLUID(current_fluid_holder)
105105
continue
106106

@@ -110,7 +110,7 @@ SUBSYSTEM_DEF(fluids)
110110

111111
reagent_holder = current_fluid_holder.reagents
112112
UPDATE_FLUID_BLOCKED_DIRS(current_fluid_holder)
113-
current_depth = reagent_holder?.total_volume || 0
113+
current_depth = REAGENT_TOTAL_VOLUME(reagent_holder)
114114

115115
// How is this happening
116116
if(QDELETED(reagent_holder) || current_depth == -1.#IND || current_depth == 1.#IND)
@@ -123,7 +123,7 @@ SUBSYSTEM_DEF(fluids)
123123
current_depth = current_fluid_holder.get_fluid_depth()
124124

125125
// Mimimum liquid depth for creation of slurries. Do this after evaporation since it may change the total depth.
126-
if(reagent_holder?.total_liquid_volume < FLUID_SLURRY)
126+
if(REAGENT_TOTAL_LIQUID_VOLUME(reagent_holder) < FLUID_SLURRY)
127127
current_fluid_holder.dump_solid_reagents()
128128
current_depth = current_fluid_holder.get_fluid_depth()
129129

@@ -135,7 +135,7 @@ SUBSYSTEM_DEF(fluids)
135135
// Wash our turf.
136136
current_fluid_holder.fluid_act(reagent_holder)
137137

138-
if(isspaceturf(current_fluid_holder) || (istype(current_fluid_holder, /turf/floor) && (current_fluid_holder.turf_flags & TURF_FLAG_ABSORB_LIQUID) && (current_fluid_holder.reagents?.total_volume + current_fluid_holder.get_physical_height()) > 0))
138+
if(isspaceturf(current_fluid_holder) || (istype(current_fluid_holder, /turf/floor) && (current_fluid_holder.turf_flags & TURF_FLAG_ABSORB_LIQUID) && (REAGENT_TOTAL_VOLUME(current_fluid_holder.reagents) + current_fluid_holder.get_physical_height()) > 0))
139139
removing = round(current_depth * 0.5)
140140
if(removing > 0)
141141
current_fluid_holder.remove_fluids(removing, defer_update = TRUE)
@@ -154,8 +154,9 @@ SUBSYSTEM_DEF(fluids)
154154
if(other_fluid_holder)
155155
UPDATE_FLUID_BLOCKED_DIRS(other_fluid_holder)
156156
if(!(other_fluid_holder.fluid_blocked_dirs & UP) && other_fluid_holder.CanFluidPass(UP))
157-
if(!QDELETED(other_fluid_holder) && other_fluid_holder.reagents?.total_volume < FLUID_MAX_DEPTH)
158-
current_fluid_holder.transfer_fluids_to(other_fluid_holder, min(floor(current_depth*0.5), FLUID_MAX_DEPTH - other_fluid_holder.reagents?.total_volume))
157+
var/other_volume = REAGENT_TOTAL_VOLUME(other_fluid_holder.reagents)
158+
if(!QDELETED(other_fluid_holder) && other_volume < FLUID_MAX_DEPTH)
159+
current_fluid_holder.transfer_fluids_to(other_fluid_holder, min(floor(current_depth*0.5), FLUID_MAX_DEPTH - other_volume))
159160
current_depth = current_fluid_holder.get_fluid_depth()
160161

161162
// Flow into the lowest level neighbor.
@@ -173,7 +174,7 @@ SUBSYSTEM_DEF(fluids)
173174
if((neighbor.fluid_blocked_dirs & coming_from) || !neighbor.CanFluidPass(coming_from) || neighbor.is_flooded(absolute = TRUE) || !neighbor.CanFluidPass(global.reverse_dir[spread_dir]))
174175
continue
175176
other_fluid_holder = neighbor
176-
neighbor_depth = (other_fluid_holder?.reagents?.total_volume || 0) + neighbor.get_physical_height()
177+
neighbor_depth = (REAGENT_TOTAL_VOLUME(other_fluid_holder.reagents)) + neighbor.get_physical_height()
177178
flow_amount = round((current_turf_depth - neighbor_depth)*0.5)
178179
// TODO: multiply flow amount or minimum transfer amount by some
179180
// viscosity calculation to allow for piles of jelly vs piles of water.
@@ -235,7 +236,7 @@ SUBSYSTEM_DEF(fluids)
235236
if(current_fluid_holder.last_flow_strength >= 10)
236237
// Catwalks mean items will be above the turf; subtract the turf height from our volume.
237238
// TODO: somehow handle stuff that is on a catwalk or on the turf within the same turf.
238-
var/effective_volume = current_fluid_holder.reagents?.total_volume
239+
var/effective_volume = REAGENT_TOTAL_VOLUME(current_fluid_holder.reagents)
239240
if(current_fluid_holder.get_supporting_platform())
240241
// Depth is negative height, hence +=. TODO: positive heights? No idea how to handle that.
241242
effective_volume += current_fluid_holder.get_physical_height()

0 commit comments

Comments
 (0)