Skip to content

Commit

Permalink
Adds support for 513(and unicode), additionally drops supports for 51…
Browse files Browse the repository at this point in the history
…2 in the process and updates dreamchecker(turdis) and casually fixes about 90 bugs in the codebase (#8324)

* Cherry picks the unicode part 2 PR from TG

* Things

* drop 512 support

* TAN --> tan

* Manually does the things that was in renamed files

* CLAMP --> clamp

* ismovableatom -> ismovable

* bugfixes, tg is bad

* Ports sanitize_name

* Bumps checks

* Fixes new linter errors (#48126)

About The Pull Request

This fixes the errors raised by the new feature I'm adding to the linter: SpaceManiac/SpacemanDMM#119

* Update SpacemanDMM suite to 1.2 (#48785)

* Update SpacemanDMM suite to 1.2

* Fix new lint errors

* Removes unreachable code (#48143)

About The Pull Request

As detected by SpaceManiac/SpacemanDMM#123

* casually fixes 50 bugs

* stoopid evil dreamchecker

* stoopid evil dreamchecker

* stoopid evil dreamchecker

* almost the same thing

* Makes all UIs UTF-8

* Fixes bugs

* Fixes runtimes, some related to 513, some not

* Fixes agent ids

Co-authored-by: MrPerson <[email protected]>
Co-authored-by: alexkar598 <>
Co-authored-by: spookydonut <[email protected]>
  • Loading branch information
3 people authored May 2, 2020
1 parent 4fd902c commit 2333d64
Show file tree
Hide file tree
Showing 442 changed files with 1,577 additions and 1,609 deletions.
2 changes: 2 additions & 0 deletions SpacemanDMM.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[langserver]
dreamchecker = true
10 changes: 0 additions & 10 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// simple is_type and similar inline helpers

#if DM_VERSION < 513
#define islist(L) (istype(L, /list))
#endif

#define in_range(source, user) (get_dist(source, user) <= 1 && (get_step(source, 0)?:z) == (get_step(user, 0)?:z))

#if DM_VERSION < 513
#define ismovableatom(A) (istype(A, /atom/movable))
#else
#define ismovableatom(A) ismovable(A)
#endif

#define isatom(A) (isloc(A))

#define isweakref(D) (istype(D, /datum/weakref))
Expand Down
21 changes: 4 additions & 17 deletions code/__DEFINES/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define TICK_USAGE_TO_MS(starting_tickusage) (TICK_DELTA_TO_MS(TICK_USAGE_REAL - starting_tickusage))

#define PERCENT(val) (round((val)*100, 0.1))
#define CLAMP01(x) (CLAMP(x, 0, 1))
#define CLAMP01(x) (clamp(x, 0, 1))

//time of day but automatically adjusts to the server going into the next day within the same round.
//for when you need a reliable time number that doesn't depend on byond time.
Expand All @@ -30,27 +30,14 @@
// round() acts like floor(x, 1) by default but can't handle other values
#define FLOOR(x, y) ( round((x) / (y)) * (y) )

#if DM_VERSION < 513
#define CLAMP(CLVALUE,CLMIN,CLMAX) ( max( (CLMIN), min((CLVALUE), (CLMAX)) ) )
#else
#define CLAMP(CLVALUE,CLMIN,CLMAX) clamp(CLVALUE, CLMIN, CLMAX)
#endif

// Similar to clamp but the bottom rolls around to the top and vice versa. min is inclusive, max is exclusive
#define WRAP(val, min, max) ( min == max ? min : (val) - (round(((val) - (min))/((max) - (min))) * ((max) - (min))) )

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

// Tangent
#if DM_VERSION < 513
#define TAN(x) (sin(x) / cos(x))
#else
#define TAN(x) tan(x)
#endif

// Cotangent
#define COT(x) (1 / TAN(x))
#define COT(x) (1 / tan(x))

// Secant
#define SEC(x) (1 / cos(x))
Expand Down Expand Up @@ -187,8 +174,8 @@
while(pixel_y < -16)
pixel_y += 32
new_y--
new_x = CLAMP(new_x, 0, world.maxx)
new_y = CLAMP(new_y, 0, world.maxy)
new_x = clamp(new_x, 0, world.maxx)
new_y = clamp(new_y, 0, world.maxy)
return locate(new_x, new_y, starting.z)

// Returns a list where [1] is all x values and [2] is all y values that overlap between the given pair of rectangles
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ GLOBAL_VAR_INIT(glide_size_multiplier, 1.0)
/// Then that's multiplied by the global glide size multiplier. 1.25 by default feels pretty close to spot on. This is just to try to get byond to behave.
/// The whole result is then clamped to within the range above.
/// Not very readable but it works
#define DELAY_TO_GLIDE_SIZE(delay) (CLAMP(((32 / max((delay) / world.tick_lag, 1)) * GLOB.glide_size_multiplier), MIN_GLIDE_SIZE, MAX_GLIDE_SIZE))
#define DELAY_TO_GLIDE_SIZE(delay) (clamp(((32 / max((delay) / world.tick_lag, 1)) * GLOB.glide_size_multiplier), MIN_GLIDE_SIZE, MAX_GLIDE_SIZE))
6 changes: 3 additions & 3 deletions code/__DEFINES/profile.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define PROFILE_START ;PROFILE_STORE = list();PROFILE_SET;
#define PROFILE_STOP ;PROFILE_STORE = null;
#define LINE_PROFILE_START ;PROFILE_STORE = list();PROFILE_SET;
#define LINE_PROFILE_STOP ;PROFILE_STORE = null;

#define PROFILE_SET ;PROFILE_TIME = TICK_USAGE_REAL; PROFILE_LINE = __LINE__; PROFILE_FILE = __FILE__; PROFILE_SLEEPCHECK = world.time;

Expand All @@ -26,4 +26,4 @@

#define PROFILE_ITEM_LEN 2
#define PROFILE_ITEM_TIME 1
#define PROFILE_ITEM_COUNT 2
#define PROFILE_ITEM_COUNT 2
2 changes: 1 addition & 1 deletion code/__DEFINES/typeids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define TYPEID_NULL "0"
#define TYPEID_NORMAL_LIST "f"
//helper macros
#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, length(ref)-6) ) )
#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, -7) ) )
#define IS_NORMAL_LIST(L) (GET_TYPEID("\ref[L]") == TYPEID_NORMAL_LIST)


2 changes: 1 addition & 1 deletion code/__HELPERS/files.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
continue
path += choice

if(copytext(path,-1,0) != "/") //didn't choose a directory, no need to iterate again
if(copytext_char(path, -1) != "/") //didn't choose a directory, no need to iterate again
break
var/extensions
for(var/i in valid_extensions)
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
var/list/result = list()
for(var/m in group)
var/mob/M = m
if(!M.key || !M.client || (ignore_category && GLOB.poll_ignore[ignore_category] && M.ckey in GLOB.poll_ignore[ignore_category]))
if(!M.key || !M.client || (ignore_category && GLOB.poll_ignore[ignore_category] && (M.ckey in GLOB.poll_ignore[ignore_category])))
continue
if(be_special_flag)
if(!(M.client.prefs) || !(be_special_flag in M.client.prefs.be_special))
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
var/adjacencies = 0

var/atom/movable/AM
if(ismovableatom(A))
if(ismovable(A))
AM = A
if(AM.can_be_unanchored && !AM.anchored)
return 0
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ world
var/icon/atom_icon = new(A.icon, A.icon_state)

if(!letter)
letter = copytext(A.name, 1, 2)
letter = A.name[1]
if(uppercase == 1)
letter = uppertext(letter)
else if(uppercase == -1)
Expand Down Expand Up @@ -1104,7 +1104,7 @@ GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0
WRITE_FILE(GLOB.iconCache[iconKey], icon)
var/iconData = GLOB.iconCache.ExportText(iconKey)
var/list/partial = splittext(iconData, "{")
return replacetext(copytext(partial[2], 3, -5), "\n", "")
return replacetext(copytext_char(partial[2], 3, -5), "\n", "")

/proc/icon2html(thing, target, icon_state, dir, frame = 1, moving = FALSE)
if (!thing)
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ GLOBAL_LIST_EMPTY(species_list)
continue
if(M.stat != DEAD && !override)
continue
if(speaker_key && speaker_key in prefs.ignoring)
if(speaker_key && (speaker_key in prefs.ignoring))
continue

switch(message_type)
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/pronouns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
. = "does"

/datum/proc/p_theyve(capitalized, temp_gender)
. = p_they(capitalized, temp_gender) + "'" + copytext(p_have(temp_gender), 3)
. = p_they(capitalized, temp_gender) + "'" + copytext_char(p_have(temp_gender), 3)

/datum/proc/p_theyre(capitalized, temp_gender)
. = p_they(capitalized, temp_gender) + "'" + copytext(p_are(temp_gender), 2)
. = p_they(capitalized, temp_gender) + "'" + copytext_char(p_are(temp_gender), 2)

/datum/proc/p_s(temp_gender) //is this a descriptive proc name, or what?
. = "s"
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/proc/sanitize_frequency(frequency, free = FALSE)
. = round(frequency)
if(free)
. = CLAMP(frequency, MIN_FREE_FREQ, MAX_FREE_FREQ)
. = clamp(frequency, MIN_FREE_FREQ, MAX_FREE_FREQ)
else
. = CLAMP(frequency, MIN_FREQ, MAX_FREQ)
. = clamp(frequency, MIN_FREQ, MAX_FREQ)
if(!(. % 2)) // Ensure the last digit is an odd number
. += 1

Expand Down
22 changes: 12 additions & 10 deletions code/__HELPERS/sanitize_values.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,32 @@

var/start = 1 + (text2ascii(color,1)==35)
var/len = length(color)
var/step_size = 1 + ((len+1)-start != desired_format)
var/char = ""

. = ""
for(var/i=start, i<=len, i+=step_size)
var/ascii = text2ascii(color,i)
switch(ascii)
for(var/i=start, i<=len, i+=length(char))
char = color[i]
switch(text2ascii(char))
if(48 to 57)
. += ascii2text(ascii) //numbers 0 to 9
. += char //numbers 0 to 9
if(97 to 102)
. += ascii2text(ascii) //letters a to f
. += char //letters a to f
if(65 to 70)
. += ascii2text(ascii+32) //letters A to F - translates to lowercase
. += lowertext(char) //letters A to F - translates to lowercase
else
break

if(length(.) != desired_format)
if(length_char(.) != desired_format)
if(default)
return default
return crunch + repeat_string(desired_format, "0")

return crunch + .

/proc/sanitize_ooccolor(color)
var/list/HSL = rgb2hsl(hex2num(copytext(color,2,4)),hex2num(copytext(color,4,6)),hex2num(copytext(color,6,8)))
if(length(color) != length_char(color))
CRASH("Invalid characters in color '[color]'")
var/list/HSL = rgb2hsl(hex2num(copytext(color, 2, 4)), hex2num(copytext(color, 4, 6)), hex2num(copytext(color, 6, 8)))
HSL[3] = min(HSL[3],0.4)
var/list/RGB = hsl2rgb(arglist(HSL))
return "#[num2hex(RGB[1],2)][num2hex(RGB[2],2)][num2hex(RGB[3],2)]"
return "#[num2hex(RGB[1],2)][num2hex(RGB[2],2)][num2hex(RGB[3],2)]"
2 changes: 1 addition & 1 deletion code/__HELPERS/shell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
if(bad_chars)
bad_match = url_encode(bad_chars_regex.match)
scrubbed_url += bad_match
last_good = bad_chars + length(bad_match)
last_good = bad_chars + length(bad_chars_regex.match)
while(bad_chars)
. = scrubbed_url
2 changes: 1 addition & 1 deletion code/__HELPERS/stat_tracking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
lines += "[entry] => [num2text(data[STAT_ENTRY_TIME], 10)]ms ([data[STAT_ENTRY_COUNT]]) (avg:[num2text(data[STAT_ENTRY_TIME]/(data[STAT_ENTRY_COUNT] || 1), 99)])"

if (user)
user << browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode("stats:[REF(stats)]")]")
user << browse("<html><head><meta charset='UTF-8'></head><body><ol><li>[lines.Join("</li><li>")]</li></ol></body></html>", "window=[url_encode("stats:[REF(stats)]")]")

. = lines.Join("\n")
Loading

0 comments on commit 2333d64

Please sign in to comment.