Skip to content

Commit

Permalink
önceden çalışmayan yazı şuan çalışıyo
Browse files Browse the repository at this point in the history
  • Loading branch information
RengaN02 committed Jan 14, 2025
1 parent fab2472 commit 85cf835
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions code/__DEFINES/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
/// 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), ""))

/// Simply removes the < and > characters, and limits the length of the message.
#define STRIP_HTML_LOCALE_SIMPLE(text, limit) (GLOB.angular_brackets.Replace(locale_copytext(text, 1, limit), ""))

/// Removes everything enclose in < and > inclusive of the bracket, and limits the length of the message.
#define STRIP_HTML_LOCALE_FULL(text, limit) (GLOB.html_tags.Replace(locale_copytext(text, 1, limit), ""))

/**
* stuff like `copytext(input, length(input))` will trim the last character of the input,
* because DM does it so it copies until the char BEFORE the `end` arg, so we need to bump `end` by 1 in these cases.
Expand Down
6 changes: 6 additions & 0 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,12 @@
else
. += c

/proc/locale_copytext(t, start, end)
var/list/char_list = text2charlist(t)
var/thend = end > length(char_list) ? PREVENT_CHARACTER_TRIM_LOSS(length(char_list)) : 0
var/list/copied_list = char_list.Copy(start, thend)
return jointext(copied_list, "")

/proc/stringmerge(text,compare,replace = "*")
//This proc fills in all spaces with the "replace" var (* by default) with whatever
//is in the other string at the same spot (assuming it is not a replace char).
Expand Down
4 changes: 2 additions & 2 deletions code/modules/client/preferences/background_data.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
return

/datum/preference/background_data/deserialize(input, datum/preferences/preferences)
return STRIP_HTML_FULL(input, 256)
return STRIP_HTML_LOCALE_FULL(input, 256)

/datum/preference/background_data/create_default_value()
return ""

/datum/preference/background_data/is_valid(value)
return istext(value) && length(value) <= 256
return istext(value) && length_char(value) <= 256

/datum/preference/background_data/character_desc
savefile_key = "character_desc"
Expand Down

0 comments on commit 85cf835

Please sign in to comment.