Skip to content

Commit

Permalink
Merge branch 'master' into pubby
Browse files Browse the repository at this point in the history
  • Loading branch information
homexp13 authored Dec 3, 2023
2 parents e731ae6 + 7e1045a commit cd25698
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 23 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#define SANITIZE_FILENAME(text) (GLOB.filename_forbidden_chars.Replace(text, ""))

/// Simply removes the < and > characters, and limits the length of the message.
#define STRIP_HTML_SIMPLE(text, limit) (GLOB.angular_brackets.Replace(copytext(text, 1, limit), ""))
#define STRIP_HTML_SIMPLE(text, limit) (GLOB.angular_brackets.Replace_char(copytext_char(text, 1, limit), "")) //MASSMETA EDIT

/// Removes everything enclose in < and > inclusive of the bracket, and limits the length of the message.
#define STRIP_HTML_FULL(text, limit) (GLOB.html_tags.Replace(copytext(text, 1, limit), ""))
Expand Down
12 changes: 6 additions & 6 deletions code/__HELPERS/chat_filter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Given a text, will return what word is on the IC filter, with the reason.
/// Returns null if the message is OK.
/proc/is_ic_filtered(message)
if (config.ic_filter_regex?.Find(message))
if (config.ic_filter_regex?.Find_char(lowertext(message))) //MASSMETA EDIT
var/matched_group = GET_MATCHED_GROUP(config.ic_filter_regex)
return list(
matched_group,
Expand All @@ -17,7 +17,7 @@
/// Given a text, will return what word is on the soft IC filter, with the reason.
/// Returns null if the message is OK.
/proc/is_soft_ic_filtered(message)
if (config.soft_ic_filter_regex?.Find(message))
if (config.soft_ic_filter_regex?.Find_char(lowertext(message))) //MASSMETA EDIT
var/matched_group = GET_MATCHED_GROUP(config.soft_ic_filter_regex)
return list(
matched_group,
Expand All @@ -29,7 +29,7 @@
/// Given a text, will return what word is on the OOC filter, with the reason.
/// Returns null if the message is OK.
/proc/is_ooc_filtered(message)
if (config.ooc_filter_regex?.Find(message))
if (config.ooc_filter_regex?.Find_char(lowertext(message))) //MASSMETA EDIT
var/matched_group = GET_MATCHED_GROUP(config.ooc_filter_regex)
return list(matched_group, config.shared_filter_reasons[matched_group])

Expand All @@ -38,7 +38,7 @@
/// Given a text, will return that word is on the soft OOC filter, with the reason.
/// Returns null if the message is OK.
/proc/is_soft_ooc_filtered(message)
if (config.soft_ooc_filter_regex?.Find(message))
if (config.soft_ooc_filter_regex?.Find_char(lowertext(message))) //MASSMETA EDIT
var/matched_group = GET_MATCHED_GROUP(config.soft_ooc_filter_regex)
return list(matched_group, config.soft_shared_filter_reasons[matched_group])

Expand All @@ -64,7 +64,7 @@
/// Given a text, will return what word is on the IC filter, ignoring words allowed on the PDA, with the reason.
/// Returns null if the message is OK.
/proc/is_ic_filtered_for_pdas(message)
if (config.ic_outside_pda_filter_regex?.Find(message))
if (config.ic_outside_pda_filter_regex?.Find_char(lowertext(message))) //MASSMETA EDIT
var/matched_group = GET_MATCHED_GROUP(config.ic_outside_pda_filter_regex)
return list(
matched_group,
Expand All @@ -76,7 +76,7 @@
/// Given a text, will return what word is on the soft IC filter, ignoring words allowed on the PDA, with the reason.
/// Returns null if the message is OK.
/proc/is_soft_ic_filtered_for_pdas(message)
if (config.soft_ic_outside_pda_filter_regex?.Find(message))
if (config.soft_ic_outside_pda_filter_regex?.Find_char(lowertext(message))) //MASSMETA EDIT
var/matched_group = GET_MATCHED_GROUP(config.soft_ic_outside_pda_filter_regex)
return list(
matched_group,
Expand Down
28 changes: 14 additions & 14 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/// Runs byond's html encoding sanitization proc, after replacing new-lines and tabs for the # character.
/proc/sanitize(text)
var/static/regex/regex = regex(@"[\n\t]", "g")
return html_encode(regex.Replace(text, "#"))
return html_encode(regex.Replace_char(text, "#")) //MASSMETA EDIT


/// Runs STRIP_HTML_SIMPLE and sanitize.
Expand Down Expand Up @@ -66,14 +66,14 @@
*/
/proc/htmlrendertext(t)
// Trim "whitespace" by lazily capturing word characters in the middle
var/static/regex/matchMiddle = new(@"^\s*([\W\w]*?)\s*$")
if(matchMiddle.Find(t) == 0)
var/static/regex/matchMiddle = new(@"^\s*([\W\wа-яё]*?)\s*$", "i") //MASSMETA EDIT
if(matchMiddle.Find_char(t) == 0) //MASSMETA EDIT
return t
t = matchMiddle.group[1]

// Replace any non-space whitespace characters with spaces, and also multiple occurences with just one space
var/static/regex/matchSpacing = new(@"\s+", "g")
t = replacetext(t, matchSpacing, " ")
t = replacetext_char(t, matchSpacing, " ") //MASSMETA EDIT

return t

Expand Down Expand Up @@ -121,7 +121,7 @@
if(isnull(user_input)) // User pressed cancel
return
if(no_trim)
return copytext(html_encode(user_input), 1, max_length)
return copytext_char(html_encode(user_input), 1, max_length) //MASSMETA EDIT
else
return trim(html_encode(user_input), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into &lt;)

Expand Down Expand Up @@ -297,16 +297,16 @@

//Returns a string with reserved characters and spaces before the first letter removed
/proc/trim_left(text)
for (var/i = 1 to length(text))
if (text2ascii(text, i) > 32)
return copytext(text, i)
for (var/i = 1 to length_char(text)) //MASSMETA EDIT
if (text2ascii_char(text, i) > 32) //MASSMETA EDIT
return copytext_char(text, i) //MASSMETA EDIT
return ""

//Returns a string with reserved characters and spaces after the last letter removed
/proc/trim_right(text)
for (var/i = length(text), i > 0, i--)
if (text2ascii(text, i) > 32)
return copytext(text, 1, i + 1)
for (var/i = length_char(text), i > 0, i--) //MASSMETA EDIT
if (text2ascii_char(text, i) > 32) //MASSMETA EDIT
return copytext_char(text, 1, i + 1) //MASSMETA EDIT
return ""

//Returns a string with reserved characters and spaces after the first and last letters removed
Expand Down Expand Up @@ -339,8 +339,8 @@
* * max_length - integer length to truncate at
*/
/proc/truncate(text, max_length)
if(length(text) > max_length)
return copytext(text, 1, max_length)
if(length_char(text) > max_length) //MASSMETA EDIT
return copytext_char(text, 1, max_length) //MASSMETA EDIT
return text

//Returns a string with reserved characters and spaces before the first word and after the last word removed.
Expand All @@ -354,7 +354,7 @@
. = t
if(t)
. = t[1]
return uppertext(.) + copytext(t, 1 + length(.))
return uppertext(.) + copytext_char(t, 1 + length_char(.)) //MASSMETA EDIT

///Returns a string with the first letter of each word capitialized
/proc/full_capitalize(input)
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ Example config:
if (isnull(banned_words) || banned_words.len == 0)
return null

var/static/regex/should_join_on_word_bounds = regex(@"^\w+$")
var/static/regex/should_join_on_word_bounds = regex(@"^[\wа-яё]+$", "i") //MASSMETA EDIT

// Stuff like emoticons needs another split, since there's no way to get ":)" on a word bound.
// Furthermore, normal words need to be on word bounds, so "(adminhelp)" gets filtered.
Expand All @@ -493,7 +493,7 @@ Example config:

// We don't want a whitespace_split part if there's no stuff that requires it
var/whitespace_split = to_join_on_whitespace_splits.len > 0 ? @"(?:(?:^|\s+)(" + jointext(to_join_on_whitespace_splits, "|") + @")(?:$|\s+))" : ""
var/word_bounds = @"(\b(" + jointext(to_join_on_word_bounds, "|") + @")\b)"
var/word_bounds = @"((" + jointext(to_join_on_word_bounds, "|") + @"))" //MASSMETA EDIT
var/regex_filter = whitespace_split != "" ? "([whitespace_split]|[word_bounds])" : word_bounds
return regex(regex_filter, "i")

Expand Down
6 changes: 6 additions & 0 deletions code/modules/unit_tests/chat_filter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
null,
)

//MASSMETA EDIT REMOVAL BEGIN - CODE_WORDS - these words HAVE filtered words in them
/*
test_filter(
"these words have filtered words in them: ablockedinic blockedinicbbbb aablockedinicbb",
null,
Expand All @@ -34,6 +37,9 @@
null,
)
*/
//MASSMETA EDIT REMOVAL END

test_filter(
"<(0_0<) <(0_0)> (>0_0)> KIRBY DANCE!!!",
"<(0_0<)",
Expand Down
45 changes: 45 additions & 0 deletions massmeta/features/additional_circuit/code/_designs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//Mining Component
/datum/design/component/mining
name = "Mining Component"
id = "comp_mine"
build_path = /obj/item/circuit_component/mining

//Item Interact Component
/datum/design/component/item_interact
name = "Item Interact Component"
id = "comp_iinteract"
build_path = /obj/item/circuit_component/item_interact

/datum/techweb_node/comp_advanced_interacts
id = "comp_advanced_interacts"
display_name = "Advanced Action Components"
description = "Grants access to more advanced action components for the drone shell."
prereq_ids = list("movable_shells")
design_ids = list(
"comp_mine",
"comp_iinteract",
)
research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 1000)

//Target Scanner Component
/datum/design/component/radar_scanner
name = "Target Scanner Component"
id = "comp_tscanner"
build_path = /obj/item/circuit_component/target_scanner

//Cell Charge Component
/datum/design/component/cell_charge
name = "Cell Charge Component"
id = "comp_ccharge"
build_path = /obj/item/circuit_component/cell_charge

/datum/techweb_node/comp_advanced_sensors
id = "comp_advanced_sensors"
display_name = "Advanced Sensor Components"
description = "Grants access to advanced sensor components component for shells."
prereq_ids = list("adv_shells")
design_ids = list(
"comp_tscanner",
"comp_ccharge",
)
research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 500)
26 changes: 26 additions & 0 deletions massmeta/features/additional_circuit/code/cell_reader.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* # Cell Charge Component
*
* Allows for reading of the max/current charge of the cell in an integrated circuit.
*/
/obj/item/circuit_component/cell_charge
display_name = "Cell Charge"
desc = "A component that can read out the max and current charge of the cell."
category = "Sensor"

/// max and current charge for the cell
var/datum/port/output/max_charge
var/datum/port/output/current_charge

circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL

/obj/item/circuit_component/cell_charge/populate_ports()
max_charge = add_output_port("Max Charge", PORT_TYPE_NUMBER)
current_charge = add_output_port("Current Charge", PORT_TYPE_NUMBER)

/obj/item/circuit_component/cell_charge/input_received(datum/port/input/port)
var/obj/item/stock_parts/cell/read_cell = parent.cell
if(!read_cell || !istype(read_cell))
return
max_charge.set_output(read_cell.maxcharge)
current_charge.set_output(read_cell.charge)
47 changes: 47 additions & 0 deletions massmeta/features/additional_circuit/code/interact_item.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* # Item Interact Component
*
* Allows for interaction with an item. Drone shell only.
*/
/obj/item/circuit_component/item_interact
display_name = "Item Interact"
desc = "A component that can force the shell to interact with an item. Only works with drone shells. Only works on items. Must be directly next to the item."
category = "Action"

/// Whether to use primary attack_self or secondary attack_self
var/datum/port/input/primary_interact
var/datum/port/input/secondary_interact

circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL

/obj/item/circuit_component/item_interact/populate_ports()
primary_interact = add_input_port("Primary Interact", PORT_TYPE_ATOM)
secondary_interact = add_input_port("Secondary Interact", PORT_TYPE_ATOM)

/obj/item/circuit_component/item_interact/input_received(datum/port/input/port)
do_primary()
do_secondary()

/obj/item/circuit_component/item_interact/proc/do_primary()
var/atom/target_atom = primary_interact.value
if(!istype(target_atom, /obj/item))
return
var/obj/item/target_item = target_atom

var/mob/shell = parent.shell
if(!istype(shell) || get_dist(shell, target_item) > 1 || shell.z != target_item.z)
return

target_item.attack_self(shell)

/obj/item/circuit_component/item_interact/proc/do_secondary()
var/atom/target_atom = secondary_interact.value
if(!istype(target_atom, /obj/item))
return
var/obj/item/target_item = target_atom

var/mob/shell = parent.shell
if(!istype(shell) || get_dist(shell, target_item) > 1 || shell.z != target_item.z)
return

target_item.attack_self_secondary(shell)
28 changes: 28 additions & 0 deletions massmeta/features/additional_circuit/code/mining_circuit.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* # Mining Component
*
* Allows for mining of mineral walls (walls with ores). Requires a shell.
*/
/obj/item/circuit_component/mining
display_name = "Mine"
desc = "A component that can force the shell to mine a target. Only works with drone shells. Only works on mining surfaces."
category = "Action"

/// Frequency input
var/datum/port/input/target
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL

/obj/item/circuit_component/mining/populate_ports()
target = add_input_port("Target", PORT_TYPE_ATOM)

/obj/item/circuit_component/mining/input_received(datum/port/input/port)
var/atom/target_atom = target.value
if(!istype(target_atom, /turf/closed/mineral))
return
var/turf/closed/mineral/target_mineral = target_atom

var/mob/shell = parent.shell
if(!istype(shell) || get_dist(shell, target_mineral) > 1 || shell.z != target_mineral.z)
return

target_mineral.gets_drilled(shell, FALSE)
50 changes: 50 additions & 0 deletions massmeta/features/additional_circuit/code/target_scanner.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* # Target Scanner Component
*
* Allows for creating a list of atoms within a range of 1.
*/
/obj/item/circuit_component/target_scanner
display_name = "Target Scanner"
desc = "A component that will create a list of the things within a location depending on an offset to the shell."
category = "Action"

// the offsets required for scanning
var/datum/port/input/x_pos
var/datum/port/input/y_pos

COOLDOWN_DECLARE(scan_delay)
///the delay between each scan
var/time_delay = 0.5 SECONDS

/// The table filled of atoms or "entities"
var/datum/port/output/atom_table

circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL

/obj/item/circuit_component/target_scanner/populate_ports()
x_pos = add_input_port("X offset", PORT_TYPE_NUMBER)
y_pos = add_input_port("Y offset", PORT_TYPE_NUMBER)
atom_table = add_output_port("Output", PORT_TYPE_LIST(PORT_TYPE_ATOM))

/obj/item/circuit_component/target_scanner/input_received(datum/port/input/port)
//cooldown is important
if(!COOLDOWN_FINISHED(src, scan_delay))
return
COOLDOWN_START(src, scan_delay, time_delay)
//we need both a x pos and y pos
if(!x_pos || !y_pos)
return
//the turf that will be scanned
var/turf/target_turf = locate(parent.shell.x + x_pos.value, parent.shell.y + y_pos.value, parent.shell.z)
//for sanity
if(!target_turf)
return
//null the create_table
var/create_table = list()
//add the scanned turf to the create_table
create_table += target_turf
//add the contents of the scanned turf to create_table
for(var/iteration in target_turf.contents)
create_table += iteration
//send out the table
atom_table.set_output(create_table)
5 changes: 5 additions & 0 deletions massmeta/features/additional_circuit/includes.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "code\_designs.dm"
#include "code\cell_reader.dm"
#include "code\interact_item.dm"
#include "code\mining_circuit.dm"
#include "code\target_scanner.dm"
3 changes: 3 additions & 0 deletions massmeta/features/additional_circuit/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Credits

Jake Park
Loading

0 comments on commit cd25698

Please sign in to comment.