diff --git a/code/WorkInProgress/computer3/computers/security.dm b/code/WorkInProgress/computer3/computers/security.dm
index 1c409da853..279cbf2dfc 100644
--- a/code/WorkInProgress/computer3/computers/security.dm
+++ b/code/WorkInProgress/computer3/computers/security.dm
@@ -543,7 +543,7 @@ What a mess.*/
if ("Change Criminal Status")
if (active2)
for(var/mob/living/carbon/human/H in player_list)
- H.hud_updateflag |= 1 << WANTED_HUD
+ BITSET(H.hud_updateflag, WANTED_HUD)
switch(href_list["criminal2"])
if("none")
active2.fields["criminal"] = "None"
@@ -608,4 +608,4 @@ What a mess.*/
/obj/machinery/computer3/secure_data/detective_computer
icon = 'icons/obj/computer.dmi'
- icon_state = "messyfiles"
\ No newline at end of file
+ icon_state = "messyfiles"
diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm
index 282224d567..e17fc84ddc 100644
--- a/code/__HELPERS/lists.dm
+++ b/code/__HELPERS/lists.dm
@@ -343,6 +343,12 @@ proc/listclearnulls(list/list)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
+// Macros to test for bits in a bitfield. Note, that this is for use with indexes, not bit-masks!
+#define BITTEST(bitfield,index) ((bitfield) & (1 << (index)))
+#define BITSET(bitfield,index) (bitfield) |= (1 << (index))
+#define BITRESET(bitfield,index) (bitfield) &= ~(1 << (index))
+#define BITFLIP(bitfield,index) (bitfield) ^= (1 << (index))
+
//Converts a bitfield to a list of numbers (or words if a wordlist is provided)
/proc/bitfield2list(bitfield = 0, list/wordlist)
var/list/r = list()
diff --git a/code/__HELPERS/maths.dm b/code/__HELPERS/maths.dm
index a0f4f9cb32..458602d49e 100644
--- a/code/__HELPERS/maths.dm
+++ b/code/__HELPERS/maths.dm
@@ -1,7 +1,8 @@
// Credits to Nickr5 for the useful procs I've taken from his library resource.
-var/const/E = 2.71828183
-var/const/Sqrt2 = 1.41421356
+var/const/E = 2.71828183
+var/const/Pi = 3.14159265
+var/const/Sqrt2 = 1.41421356
// List of square roots for the numbers 1-100.
var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
@@ -9,115 +10,127 @@ var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10)
-/proc/Atan2(x, y)
- if(!x && !y) return 0
- var/a = arccos(x / sqrt(x*x + y*y))
- return y >= 0 ? a : -a
-
-/proc/Ceiling(x)
- return -round(-x)
-
/proc/Clamp(val, min, max)
return max(min, min(val, max))
-// cotangent
-/proc/Cot(x)
- return 1 / Tan(x)
-
-// cosecant
-/proc/Csc(x)
- return 1 / sin(x)
-
-/proc/Default(a, b)
- return a ? a : b
-
-/proc/Floor(x)
- return round(x)
-
-// Greatest Common Divisor - Euclid's algorithm
-/proc/Gcd(a, b)
- return b ? Gcd(b, a % b) : a
-
-/proc/Inverse(x)
- return 1 / x
-
-/proc/IsAboutEqual(a, b, deviation = 0.1)
- return abs(a - b) <= deviation
-
-/proc/IsEven(x)
- return x % 2 == 0
-
-// Returns true if val is from min to max, inclusive.
-/proc/IsInRange(val, min, max)
- return min <= val && val <= max
-
-/proc/IsInteger(x)
- return Floor(x) == x
-
-/proc/IsOdd(x)
- return !IsEven(x)
-
-/proc/IsMultiple(x, y)
- return x % y == 0
-
-// Least Common Multiple
-/proc/Lcm(a, b)
- return abs(a) / Gcd(a, b) * abs(b)
-
-// Performs a linear interpolation between a and b.
-// Note that amount=0 returns a, amount=1 returns b, and
-// amount=0.5 returns the mean of a and b.
-/proc/Lerp(a, b, amount = 0.5)
- return a + (b - a) * amount
-
-/proc/Mean(...)
- var/values = 0
- var/sum = 0
- for(var/val in args)
- values++
- sum += val
- return sum / values
-
-
-// Returns the nth root of x.
-/proc/Root(n, x)
- return x ** (1 / n)
-
-// secant
-/proc/Sec(x)
- return 1 / cos(x)
-
-// The quadratic formula. Returns a list with the solutions, or an empty list
-// if they are imaginary.
-/proc/SolveQuadratic(a, b, c)
- ASSERT(a)
- . = list()
- var/d = b*b - 4 * a * c
- var/bottom = 2 * a
- if(d < 0) return
- var/root = sqrt(d)
- . += (-b + root) / bottom
- if(!d) return
- . += (-b - root) / bottom
-
-// tangent
-/proc/Tan(x)
- return sin(x) / cos(x)
-
-/proc/ToDegrees(radians)
- // 180 / Pi
- return radians * 57.2957795
-
-/proc/ToRadians(degrees)
- // Pi / 180
- return degrees * 0.0174532925
-
// min is inclusive, max is exclusive
/proc/Wrap(val, min, max)
var/d = max - min
var/t = Floor((val - min) / d)
return val - (t * d)
-proc/RaiseToPower(num, power)
- if(!power) return 1
- return (power-- > 1 ? num * RaiseToPower(num, power) : num)
+/proc/Default(a, b)
+ return a ? a : b
+
+// Trigonometric functions.
+/proc/Tan(x)
+ return sin(x) / cos(x)
+
+/proc/Csc(x)
+ return 1 / sin(x)
+
+/proc/Sec(x)
+ return 1 / cos(x)
+
+/proc/Cot(x)
+ return 1 / Tan(x)
+
+/proc/Atan2(x, y)
+ if(!x && !y) return 0
+ var/a = arccos(x / sqrt(x*x + y*y))
+ return y >= 0 ? a : -a
+
+/proc/Floor(x)
+ return round(x)
+
+/proc/Ceiling(x)
+ return -round(-x)
+
+// Greatest Common Divisor: Euclid's algorithm.
+/proc/Gcd(a, b)
+ while (1)
+ if (!b) return a
+ a %= b
+ if (!a) return b
+ b %= a
+
+// Least Common Multiple. The formula is a consequence of: a*b = LCM*GCD.
+/proc/Lcm(a, b)
+ return abs(a) * abs(b) / Gcd(a, b)
+
+// Useful in the cases when x is a large expression, e.g. x = 3a/2 + b^2 + Function(c)
+/proc/Square(x)
+ return x*x
+
+/proc/Inverse(x)
+ return 1 / x
+
+// Condition checks.
+/proc/IsAboutEqual(a, b, delta = 0.1)
+ return abs(a - b) <= delta
+
+// Returns true if val is from min to max, inclusive.
+/proc/IsInRange(val, min, max)
+ return (val >= min) && (val <= max)
+
+/proc/IsInteger(x)
+ return Floor(x) == x
+
+/proc/IsMultiple(x, y)
+ return x % y == 0
+
+/proc/IsEven(x)
+ return !(x & 0x1)
+
+/proc/IsOdd(x)
+ return (x & 0x1)
+
+// Performs a linear interpolation between a and b.
+// Note: weight=0 returns a, weight=1 returns b, and weight=0.5 returns the mean of a and b.
+/proc/Interpolate(a, b, weight = 0.5)
+ return a + (b - a) * weight // Equivalent to: a*(1 - weight) + b*weight
+
+/proc/Mean(...)
+ var/sum = 0
+ for(var/val in args)
+ sum += val
+ return sum / args.len
+
+// Returns the nth root of x.
+/proc/Root(n, x)
+ return x ** (1 / n)
+
+// The quadratic formula. Returns a list with the solutions, or an empty list
+// if they are imaginary.
+/proc/SolveQuadratic(a, b, c)
+ ASSERT(a)
+
+ . = list()
+ var/discriminant = b*b - 4*a*c
+ var/bottom = 2*a
+
+ // Return if the roots are imaginary.
+ if(discriminant < 0)
+ return
+
+ var/root = sqrt(discriminant)
+ . += (-b + root) / bottom
+
+ // If discriminant == 0, there would be two roots at the same position.
+ if(discriminant != 0)
+ . += (-b - root) / bottom
+
+/proc/ToDegrees(radians)
+ // 180 / Pi ~ 57.2957795
+ return radians * 57.2957795
+
+/proc/ToRadians(degrees)
+ // Pi / 180 ~ 0.0174532925
+ return degrees * 0.0174532925
+
+// Vector algebra.
+/proc/squaredNorm(x, y)
+ return x*x + y*y
+
+/proc/norm(x, y)
+ return sqrt(squaredNorm(x, y))
diff --git a/code/__HELPERS/time.dm b/code/__HELPERS/time.dm
index bcd52b9e88..ab949df44b 100644
--- a/code/__HELPERS/time.dm
+++ b/code/__HELPERS/time.dm
@@ -11,20 +11,6 @@ proc/worldtime2text(time = world.time)
proc/time_stamp()
return time2text(world.timeofday, "hh:mm:ss")
-/* Preserving this so future generations can see how fucking retarded some people are
-proc/time_stamp()
- var/hh = text2num(time2text(world.timeofday, "hh")) // Set the hour
- var/mm = text2num(time2text(world.timeofday, "mm")) // Set the minute
- var/ss = text2num(time2text(world.timeofday, "ss")) // Set the second
- var/ph
- var/pm
- var/ps
- if(hh < 10) ph = "0"
- if(mm < 10) pm = "0"
- if(ss < 10) ps = "0"
- return"[ph][hh]:[pm][mm]:[ps][ss]"
-*/
-
/* Returns 1 if it is the selected month and day */
proc/isDay(var/month, var/day)
if(isnum(month) && isnum(day))
diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm
index cfac858e25..59119650bc 100644
--- a/code/__HELPERS/type2type.dm
+++ b/code/__HELPERS/type2type.dm
@@ -9,183 +9,161 @@
* worldtime2text
*/
-//Returns an integer given a hex input
+// Returns an integer given a hexadecimal number string as input.
/proc/hex2num(hex)
- if (!( istext(hex) ))
+ if (!istext(hex))
return
- var/num = 0
- var/power = 0
- var/i = null
- i = length(hex)
- while(i > 0)
- var/char = copytext(hex, i, i + 1)
+ var/num = 0
+ var/power = 1
+ var/i = length(hex)
+
+ while (i)
+ var/char = text2ascii(hex, i)
switch(char)
- if("0")
- //Apparently, switch works with empty statements, yay! If that doesn't work, blame me, though. -- Urist
- if("9", "8", "7", "6", "5", "4", "3", "2", "1")
- num += text2num(char) * 16 ** power
- if("a", "A")
- num += 16 ** power * 10
- if("b", "B")
- num += 16 ** power * 11
- if("c", "C")
- num += 16 ** power * 12
- if("d", "D")
- num += 16 ** power * 13
- if("e", "E")
- num += 16 ** power * 14
- if("f", "F")
- num += 16 ** power * 15
+ if(48) // 0 -- do nothing
+ if(49 to 57) num += (char - 48) * power // 1-9
+ if(97, 65) num += power * 10 // A
+ if(98, 66) num += power * 11 // B
+ if(99, 67) num += power * 12 // C
+ if(100, 68) num += power * 13 // D
+ if(101, 69) num += power * 14 // E
+ if(102, 70) num += power * 15 // F
else
return
- power++
+ power *= 16
i--
return num
-//Returns the hex value of a number given a value assumed to be a base-ten value
-/proc/num2hex(num, placeholder)
+// Returns the hex value of a number given a value assumed to be a base-ten value
+/proc/num2hex(num, digits)
+ if (digits == null)
+ digits = 2
- if (placeholder == null)
- placeholder = 2
- if (!( isnum(num) ))
+ if (!isnum(num))
return
- if (num == 0)
- var/final = ""
- for(var/i=1 to placeholder) final = "[final]0"
- return final
- var/hex = ""
- var/i = 0
- while(16 ** i < num)
- i++
- var/power = null
- power = i - 1
- while(power >= 0)
- var/val = round(num / 16 ** power)
- num -= val * 16 ** power
- switch(val)
- if(9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
- hex += text("[]", val)
- if(10.0)
- hex += "A"
- if(11.0)
- hex += "B"
- if(12.0)
- hex += "C"
- if(13.0)
- hex += "D"
- if(14.0)
- hex += "E"
- if(15.0)
- hex += "F"
- else
- power--
- while(length(hex) < placeholder)
- hex = text("0[]", hex)
- return hex
+ // hex is our return value, to which each hex-digit of num is appended to.
+ var/hex = ""
+ var/power = -4
+ var/n = 1
+
+ // Figure out power. (power of 2)
+ while (n < num)
+ power += 4
+ n *= 16
+
+ // Note that we have to start appending to hex with the most-significant digits.
+ while (power >= 0)
+ var/m = (num >> power) & 15
+ hex += ascii2text(m + (m < 10 ? 48 : 87)) // Provided by the IconProcs library.
+ power -= 4
+
+ // Append zeroes to make sure that hex is atleast digits long.
+ var/left = length(hex) - digits
+ while (left-- > 0)
+ hex = text("0[]", hex)
+
+ return hex
// Concatenates a list of strings into a single string. A seperator may optionally be provided.
/proc/list2text(list/ls, sep)
- if(ls.len <= 1) // Early-out code for empty or singleton lists.
+ if (ls.len <= 1) // Early-out code for empty or singleton lists.
return ls.len ? ls[1] : ""
var/l = ls.len // Made local for sanic speed.
- var/i = 0 // Incremented every time a list index is accessed.
+ var/i = 0 // Incremented every time a list index is accessed.
- if(sep <> null)
+ if (sep <> null)
// Macros expand to long argument lists like so: sep, ls[++i], sep, ls[++i], sep, ls[++i], etc...
- #define S1 sep, ls[++i]
- #define S4 S1, S1, S1, S1
- #define S16 S4, S4, S4, S4
- #define S64 S16, S16, S16, S16
+ #define S1 sep, ls[++i]
+ #define S4 S1, S1, S1, S1
+ #define S16 S4, S4, S4, S4
+ #define S64 S16, S16, S16, S16
. = "[ls[++i]]" // Make sure the initial element is converted to text.
// Having the small concatenations come before the large ones boosted speed by an average of at least 5%.
- if(l-1 & 0x01) // 'i' will always be 1 here.
+ if (l-1 & 0x01) // 'i' will always be 1 here.
. = text("[][][]", ., S1) // Append 1 element if the remaining elements are not a multiple of 2.
- if(l-i & 0x02)
+ if (l-i & 0x02)
. = text("[][][][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4.
- if(l-i & 0x04)
+ if (l-i & 0x04)
. = text("[][][][][][][][][]", ., S4) // And so on....
- if(l-i & 0x08)
+ if (l-i & 0x08)
. = text("[][][][][][][][][][][][][][][][][]", ., S4, S4)
- if(l-i & 0x10)
+ if (l-i & 0x10)
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16)
- if(l-i & 0x20)
+ if (l-i & 0x20)
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16)
- if(l-i & 0x40)
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16)
+ if (l-i & 0x40)
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
- while(l > i) // Chomp through the rest of the list, 128 elements at a time.
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
+ while (l > i) // Chomp through the rest of the list, 128 elements at a time.
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
#undef S64
#undef S16
#undef S4
#undef S1
-
else
// Macros expand to long argument lists like so: ls[++i], ls[++i], ls[++i], etc...
- #define S1 ls[++i]
- #define S4 S1, S1, S1, S1
- #define S16 S4, S4, S4, S4
- #define S64 S16, S16, S16, S16
+ #define S1 ls[++i]
+ #define S4 S1, S1, S1, S1
+ #define S16 S4, S4, S4, S4
+ #define S64 S16, S16, S16, S16
. = "[ls[++i]]" // Make sure the initial element is converted to text.
- if(l-1 & 0x01) // 'i' will always be 1 here.
+ if (l-1 & 0x01) // 'i' will always be 1 here.
. += S1 // Append 1 element if the remaining elements are not a multiple of 2.
- if(l-i & 0x02)
+ if (l-i & 0x02)
. = text("[][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4.
- if(l-i & 0x04)
+ if (l-i & 0x04)
. = text("[][][][][]", ., S4) // And so on...
- if(l-i & 0x08)
+ if (l-i & 0x08)
. = text("[][][][][][][][][]", ., S4, S4)
- if(l-i & 0x10)
+ if (l-i & 0x10)
. = text("[][][][][][][][][][][][][][][][][]", ., S16)
- if(l-i & 0x20)
+ if (l-i & 0x20)
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16)
- if(l-i & 0x40)
+ if (l-i & 0x40)
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
- while(l > i) // Chomp through the rest of the list, 128 elements at a time.
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
+ while (l > i) // Chomp through the rest of the list, 128 elements at a time.
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
- [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
+ [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
#undef S64
#undef S16
#undef S4
#undef S1
-
-//slower then list2text, but correctly processes associative lists.
+// Slower then list2text, but correctly processes associative lists.
proc/tg_list2text(list/list, glue=",")
- if(!istype(list) || !list.len)
+ if (!istype(list) || !list.len)
return
var/output
for(var/i=1 to list.len)
output += (i!=1? glue : null)+(!isnull(list["[list[i]]"])?"[list["[list[i]]"]]":"[list[i]]")
return output
-
-//Converts a string into a list by splitting the string at each delimiter found. (discarding the seperator)
+// Converts a string into a list by splitting the string at each delimiter found. (discarding the seperator)
/proc/text2list(text, delimiter="\n")
var/delim_len = length(delimiter)
- if(delim_len < 1) return list(text)
+ if (delim_len < 1) return list(text)
. = list()
var/last_found = 1
var/found
@@ -193,18 +171,18 @@ proc/tg_list2text(list/list, glue=",")
found = findtext(text, delimiter, last_found, 0)
. += copytext(text, last_found, found)
last_found = found + delim_len
- while(found)
-
+ while (found)
+
/proc/text2numlist(text, delimiter="\n")
var/list/num_list = list()
for(var/x in text2list(text, delimiter))
num_list += text2num(x)
return num_list
-//Case Sensitive!
+// Case Sensitive!
/proc/text2listEx(text, delimiter="\n")
var/delim_len = length(delimiter)
- if(delim_len < 1) return list(text)
+ if (delim_len < 1) return list(text)
. = list()
var/last_found = 1
var/found
@@ -212,130 +190,110 @@ proc/tg_list2text(list/list, glue=",")
found = findtextEx(text, delimiter, last_found, 0)
. += copytext(text, last_found, found)
last_found = found + delim_len
- while(found)
+ while (found)
-//Splits the text of a file at seperator and returns them in a list.
+// Splits the text of a file at seperator and returns them in a list.
/proc/file2list(filename, seperator="\n")
return text2list(return_file_text(filename),seperator)
-
-//Turns a direction into text
-
+// Turns a direction into text
/proc/num2dir(direction)
- switch(direction)
- if(1.0) return NORTH
- if(2.0) return SOUTH
- if(4.0) return EAST
- if(8.0) return WEST
+ switch (direction)
+ if (1.0) return NORTH
+ if (2.0) return SOUTH
+ if (4.0) return EAST
+ if (8.0) return WEST
else
world.log << "UNKNOWN DIRECTION: [direction]"
-
-
-//Turns a direction into text
+// Turns a direction into text
/proc/dir2text(direction)
- switch(direction)
- if(1.0)
- return "north"
- if(2.0)
- return "south"
- if(4.0)
- return "east"
- if(8.0)
- return "west"
- if(5.0)
- return "northeast"
- if(6.0)
- return "southeast"
- if(9.0)
- return "northwest"
- if(10.0)
- return "southwest"
+ switch (direction)
+ if (1.0) return "north"
+ if (2.0) return "south"
+ if (4.0) return "east"
+ if (8.0) return "west"
+ if (5.0) return "northeast"
+ if (6.0) return "southeast"
+ if (9.0) return "northwest"
+ if (10.0) return "southwest"
else
- return
+ return
-//Turns text into proper directions
+// Turns text into proper directions
/proc/text2dir(direction)
- switch(uppertext(direction))
- if("NORTH")
- return 1
- if("SOUTH")
- return 2
- if("EAST")
- return 4
- if("WEST")
- return 8
- if("NORTHEAST")
- return 5
- if("NORTHWEST")
- return 9
- if("SOUTHEAST")
- return 6
- if("SOUTHWEST")
- return 10
+ switch (uppertext(direction))
+ if ("NORTH") return 1
+ if ("SOUTH") return 2
+ if ("EAST") return 4
+ if ("WEST") return 8
+ if ("NORTHEAST") return 5
+ if ("NORTHWEST") return 9
+ if ("SOUTHEAST") return 6
+ if ("SOUTHWEST") return 10
else
- return
+ return
-//Converts an angle (degrees) into an ss13 direction
+// Converts an angle (degrees) into an ss13 direction
/proc/angle2dir(var/degree)
- degree = ((degree+22.5)%365)
- if(degree < 45) return NORTH
- if(degree < 90) return NORTHEAST
- if(degree < 135) return EAST
- if(degree < 180) return SOUTHEAST
- if(degree < 225) return SOUTH
- if(degree < 270) return SOUTHWEST
- if(degree < 315) return WEST
+ degree = (degree + 22.5) % 365 // 22.5 = 45 / 2
+ if (degree < 45) return NORTH
+ if (degree < 90) return NORTHEAST
+ if (degree < 135) return EAST
+ if (degree < 180) return SOUTHEAST
+ if (degree < 225) return SOUTH
+ if (degree < 270) return SOUTHWEST
+ if (degree < 315) return WEST
return NORTH|WEST
-//returns the north-zero clockwise angle in degrees, given a direction
-
+// Returns the north-zero clockwise angle in degrees, given a direction
/proc/dir2angle(var/D)
- switch(D)
- if(NORTH) return 0
- if(SOUTH) return 180
- if(EAST) return 90
- if(WEST) return 270
- if(NORTHEAST) return 45
- if(SOUTHEAST) return 135
- if(NORTHWEST) return 315
- if(SOUTHWEST) return 225
- else return null
+ switch (D)
+ if (NORTH) return 0
+ if (SOUTH) return 180
+ if (EAST) return 90
+ if (WEST) return 270
+ if (NORTHEAST) return 45
+ if (SOUTHEAST) return 135
+ if (NORTHWEST) return 315
+ if (SOUTHWEST) return 225
+ else
+ return null
-//Returns the angle in english
+// Returns the angle in english
/proc/angle2text(var/degree)
return dir2text(angle2dir(degree))
-//Converts a blend_mode constant to one acceptable to icon.Blend()
+// Converts a blend_mode constant to one acceptable to icon.Blend()
/proc/blendMode2iconMode(blend_mode)
- switch(blend_mode)
- if(BLEND_MULTIPLY) return ICON_MULTIPLY
- if(BLEND_ADD) return ICON_ADD
- if(BLEND_SUBTRACT) return ICON_SUBTRACT
- else return ICON_OVERLAY
+ switch (blend_mode)
+ if (BLEND_MULTIPLY) return ICON_MULTIPLY
+ if (BLEND_ADD) return ICON_ADD
+ if (BLEND_SUBTRACT) return ICON_SUBTRACT
+ else return ICON_OVERLAY
-//Converts a rights bitfield into a string
+// Converts a rights bitfield into a string
/proc/rights2text(rights,seperator="")
- if(rights & R_BUILDMODE) . += "[seperator]+BUILDMODE"
- if(rights & R_ADMIN) . += "[seperator]+ADMIN"
- if(rights & R_BAN) . += "[seperator]+BAN"
- if(rights & R_FUN) . += "[seperator]+FUN"
- if(rights & R_SERVER) . += "[seperator]+SERVER"
- if(rights & R_DEBUG) . += "[seperator]+DEBUG"
- if(rights & R_POSSESS) . += "[seperator]+POSSESS"
- if(rights & R_PERMISSIONS) . += "[seperator]+PERMISSIONS"
- if(rights & R_STEALTH) . += "[seperator]+STEALTH"
- if(rights & R_REJUVINATE) . += "[seperator]+REJUVINATE"
- if(rights & R_VAREDIT) . += "[seperator]+VAREDIT"
- if(rights & R_SOUNDS) . += "[seperator]+SOUND"
- if(rights & R_SPAWN) . += "[seperator]+SPAWN"
- if(rights & R_MOD) . += "[seperator]+MODERATOR"
- if(rights & R_MENTOR) . += "[seperator]+MENTOR"
+ if (rights & R_BUILDMODE) . += "[seperator]+BUILDMODE"
+ if (rights & R_ADMIN) . += "[seperator]+ADMIN"
+ if (rights & R_BAN) . += "[seperator]+BAN"
+ if (rights & R_FUN) . += "[seperator]+FUN"
+ if (rights & R_SERVER) . += "[seperator]+SERVER"
+ if (rights & R_DEBUG) . += "[seperator]+DEBUG"
+ if (rights & R_POSSESS) . += "[seperator]+POSSESS"
+ if (rights & R_PERMISSIONS) . += "[seperator]+PERMISSIONS"
+ if (rights & R_STEALTH) . += "[seperator]+STEALTH"
+ if (rights & R_REJUVINATE) . += "[seperator]+REJUVINATE"
+ if (rights & R_VAREDIT) . += "[seperator]+VAREDIT"
+ if (rights & R_SOUNDS) . += "[seperator]+SOUND"
+ if (rights & R_SPAWN) . += "[seperator]+SPAWN"
+ if (rights & R_MOD) . += "[seperator]+MODERATOR"
+ if (rights & R_MENTOR) . += "[seperator]+MENTOR"
return .
/proc/ui_style2icon(ui_style)
- switch(ui_style)
- if("old") return 'icons/mob/screen1_old.dmi'
- if("Orange") return 'icons/mob/screen1_Orange.dmi'
- if("Midnight") return 'icons/mob/screen1_Midnight.dmi'
- else return 'icons/mob/screen1_White.dmi'
+ switch (ui_style)
+ if ("old") return 'icons/mob/screen1_old.dmi'
+ if ("Orange") return 'icons/mob/screen1_Orange.dmi'
+ if ("Midnight") return 'icons/mob/screen1_Midnight.dmi'
+ else return 'icons/mob/screen1_White.dmi'
diff --git a/code/datums/mind.dm b/code/datums/mind.dm
index a92712af50..9920252089 100644
--- a/code/datums/mind.dm
+++ b/code/datums/mind.dm
@@ -500,7 +500,7 @@ datum/mind
else if(href_list["implant"])
var/mob/living/carbon/human/H = current
- H.hud_updateflag |= (1 << IMPLOYAL_HUD) // updates that players HUD images so secHUD's pick up they are implanted or not.
+ BITSET(H.hud_updateflag, IMPLOYAL_HUD) // updates that players HUD images so secHUD's pick up they are implanted or not.
switch(href_list["implant"])
if("remove")
@@ -540,7 +540,7 @@ datum/mind
else if (href_list["revolution"])
- current.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(current.hud_updateflag, SPECIALROLE_HUD)
switch(href_list["revolution"])
if("clear")
@@ -635,7 +635,7 @@ datum/mind
usr << "\red Reequipping revolutionary goes wrong!"
else if (href_list["cult"])
- current.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(current.hud_updateflag, SPECIALROLE_HUD)
switch(href_list["cult"])
if("clear")
if(src in ticker.mode.cult)
@@ -685,7 +685,7 @@ datum/mind
usr << "\red Spawning amulet failed!"
else if (href_list["wizard"])
- current.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(current.hud_updateflag, SPECIALROLE_HUD)
switch(href_list["wizard"])
if("clear")
@@ -715,7 +715,7 @@ datum/mind
usr << "\blue The objectives for wizard [key] have been generated. You can edit them and anounce manually."
else if (href_list["changeling"])
- current.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(current.hud_updateflag, SPECIALROLE_HUD)
switch(href_list["changeling"])
if("clear")
if(src in ticker.mode.changelings)
@@ -751,7 +751,7 @@ datum/mind
else if (href_list["nuclear"])
var/mob/living/carbon/human/H = current
- current.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(current.hud_updateflag, SPECIALROLE_HUD)
switch(href_list["nuclear"])
if("clear")
@@ -805,7 +805,7 @@ datum/mind
usr << "\red No valid nuke found!"
else if (href_list["traitor"])
- current.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(current.hud_updateflag, SPECIALROLE_HUD)
switch(href_list["traitor"])
if("clear")
if(src in ticker.mode.traitors)
@@ -888,7 +888,7 @@ datum/mind
current.radiation -= 50
else if (href_list["silicon"])
- current.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(current.hud_updateflag, SPECIALROLE_HUD)
switch(href_list["silicon"])
if("unmalf")
if(src in ticker.mode.malf_ai)
diff --git a/code/game/gamemodes/autotraitor/autotraitor.dm b/code/game/gamemodes/autotraitor/autotraitor.dm
index e2c41fcbb4..020f19abc1 100644
--- a/code/game/gamemodes/autotraitor/autotraitor.dm
+++ b/code/game/gamemodes/autotraitor/autotraitor.dm
@@ -134,7 +134,7 @@
newtraitor << "\red No time like the present. \black It's time to take matters into your own hands..."
newtraitor << "You are now a traitor."
newtraitor.mind.special_role = "traitor"
- newtraitor.hud_updateflag |= 1 << SPECIALROLE_HUD
+ BITSET(newtraitor.hud_updateflag, SPECIALROLE_HUD)
newtraitor << "You have been selected this round as an antagonist!"
show_objectives(newtraitor.mind)
diff --git a/code/game/gamemodes/revolution/revolution.dm b/code/game/gamemodes/revolution/revolution.dm
index 051c112bbb..71e9704606 100644
--- a/code/game/gamemodes/revolution/revolution.dm
+++ b/code/game/gamemodes/revolution/revolution.dm
@@ -205,7 +205,7 @@
if(rev_mind in revolutionaries)
revolutionaries -= rev_mind
rev_mind.special_role = null
- rev_mind.current.hud_updateflag |= 1 << SPECIALROLE_HUD
+ BITSET(rev_mind.current.hud_updateflag, SPECIALROLE_HUD)
if(beingborged)
rev_mind.current << "\red The frame's firmware detects and deletes your neural reprogramming! You remember nothing from the moment you were flashed until now."
diff --git a/code/game/gamemodes/revolution/rp_revolution.dm b/code/game/gamemodes/revolution/rp_revolution.dm
index 2b9cc12e28..5899f04837 100644
--- a/code/game/gamemodes/revolution/rp_revolution.dm
+++ b/code/game/gamemodes/revolution/rp_revolution.dm
@@ -109,7 +109,7 @@
rev_mind.special_role = "Revolutionary"
show_objectives(rev_mind)
update_rev_icons_added(rev_mind)
- H.hud_updateflag |= 1 << SPECIALROLE_HUD
+ BITSET(H.hud_updateflag, SPECIALROLE_HUD)
return 1
/////////////////////////////
diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm
index b3918713e7..6805202155 100644
--- a/code/game/jobs/job_controller.dm
+++ b/code/game/jobs/job_controller.dm
@@ -538,9 +538,9 @@ var/global/datum/controller/occupations/job_master
G.prescription = 1
// H.update_icons()
- H.hud_updateflag |= (1 << ID_HUD)
- H.hud_updateflag |= (1 << IMPLOYAL_HUD)
- H.hud_updateflag |= (1 << SPECIALROLE_HUD)
+ BITSET(H.hud_updateflag, ID_HUD)
+ BITSET(H.hud_updateflag, IMPLOYAL_HUD)
+ BITSET(H.hud_updateflag, SPECIALROLE_HUD)
return H
@@ -648,4 +648,4 @@ var/global/datum/controller/occupations/job_master
else level4++ //not selected
tmp_str += "HIGH=[level1]|MEDIUM=[level2]|LOW=[level3]|NEVER=[level4]|BANNED=[level5]|YOUNG=[level6]|-"
- feedback_add_details("job_preferences",tmp_str)
\ No newline at end of file
+ feedback_add_details("job_preferences",tmp_str)
diff --git a/code/game/machinery/bots/mulebot.dm b/code/game/machinery/bots/mulebot.dm
index e7f766a5b4..16d58550c9 100644
--- a/code/game/machinery/bots/mulebot.dm
+++ b/code/game/machinery/bots/mulebot.dm
@@ -134,11 +134,11 @@
unload(0)
switch(severity)
if(2)
- wires &= ~(1 << rand(0,9))
- wires &= ~(1 << rand(0,9))
- wires &= ~(1 << rand(0,9))
+ BITRESET(wires, rand(0,9))
+ BITRESET(wires, rand(0,9))
+ BITRESET(wires, rand(0,9))
if(3)
- wires &= ~(1 << rand(0,9))
+ BITRESET(wires, rand(0,9))
..()
return
diff --git a/code/game/machinery/computer/security.dm b/code/game/machinery/computer/security.dm
index e14c277981..548ce6becf 100644
--- a/code/game/machinery/computer/security.dm
+++ b/code/game/machinery/computer/security.dm
@@ -534,7 +534,7 @@ What a mess.*/
if ("Change Criminal Status")
if (active2)
for(var/mob/living/carbon/human/H in player_list)
- H.hud_updateflag |= 1 << WANTED_HUD
+ BITSET(H.hud_updateflag, WANTED_HUD)
switch(href_list["criminal2"])
if("none")
active2.fields["criminal"] = "None"
@@ -612,4 +612,4 @@ What a mess.*/
/obj/machinery/computer/secure_data/detective_computer
icon = 'icons/obj/computer.dmi'
- icon_state = "messyfiles"
\ No newline at end of file
+ icon_state = "messyfiles"
diff --git a/code/game/magic/Uristrunes.dm b/code/game/magic/Uristrunes.dm
index 6e0abd177e..cecbefc798 100644
--- a/code/game/magic/Uristrunes.dm
+++ b/code/game/magic/Uristrunes.dm
@@ -68,7 +68,7 @@ var/list/uristrune_cache = list()
var/icon/I = icon('icons/effects/uristrunes.dmi', "blank")
for(var/i = 0, i < 10, i++)
- if(symbol_bits & (1 << i))
+ if(BITTEST(symbol_bits, i))
I.Blend(icon('icons/effects/uristrunes.dmi', "rune-[1 << i]"), ICON_OVERLAY)
diff --git a/code/game/objects/items/weapons/implants/implanter.dm b/code/game/objects/items/weapons/implants/implanter.dm
index 19cb00b999..6d6e5ad4cb 100644
--- a/code/game/objects/items/weapons/implants/implanter.dm
+++ b/code/game/objects/items/weapons/implants/implanter.dm
@@ -47,7 +47,7 @@
affected.implants += src.imp
imp.part = affected
- H.hud_updateflag |= 1 << IMPLOYAL_HUD
+ BITSET(H.hud_updateflag, IMPLOYAL_HUD)
src.imp = null
update()
diff --git a/code/modules/events/event_manager.dm b/code/modules/events/event_manager.dm
index 1ef4d22e91..5701415699 100644
--- a/code/modules/events/event_manager.dm
+++ b/code/modules/events/event_manager.dm
@@ -190,12 +190,12 @@
admin_log_and_message_admins("has [report_at_round_end ? "enabled" : "disabled"] the round end event report.")
else if(href_list["dec_timer"])
var/datum/event_container/EC = locate(href_list["event"])
- var/decrease = (60 * RaiseToPower(10, text2num(href_list["dec_timer"])))
+ var/decrease = 60 * (10 ** text2num(href_list["dec_timer"]))
EC.next_event_time -= decrease
admin_log_and_message_admins("decreased timer for [severity_to_string[EC.severity]] events by [decrease/600] minute(s).")
else if(href_list["inc_timer"])
var/datum/event_container/EC = locate(href_list["event"])
- var/increase = (60 * RaiseToPower(10, text2num(href_list["inc_timer"])))
+ var/increase = 60 * (10 ** text2num(href_list["inc_timer"]))
EC.next_event_time += increase
admin_log_and_message_admins("increased timer for [severity_to_string[EC.severity]] events by [increase/600] minute(s).")
else if(href_list["select_event"])
diff --git a/code/modules/icon generation/Uristrunes.dm b/code/modules/icon generation/Uristrunes.dm
index d9c129df8e..8dfe135a72 100644
--- a/code/modules/icon generation/Uristrunes.dm
+++ b/code/modules/icon generation/Uristrunes.dm
@@ -179,7 +179,7 @@ var/list/rune_animation = list(
var/icon/base = icon('icons/effects/uristrunes.dmi', "")
for(var/i = 0, i < 10, i++)
- if(rune_bits & (1 << i))
+ if(BITTEST(rune_bits, i))
base.Blend(icon('icons/effects/uristrunes.dmi', "rune-[1 << i]"), ICON_OVERLAY)
var/icon/result
@@ -217,7 +217,7 @@ var/list/rune_animation = list(
var/icon/I = icon('icons/effects/uristrunes.dmi', "blank")
for(var/i = 0, i < 10, i++)
- if(rune & (1 << i))
+ if(BITTEST(rune, i))
I.Blend(icon('icons/effects/uristrunes.dmi', "rune-[1 << i]"), ICON_OVERLAY)
var/obj/o = new(locate(x, y, z))
@@ -229,7 +229,7 @@ var/list/rune_animation = list(
var/rune = rand(1, 1023)
for(var/i = 0, i < 10, i++)
- if(rune & (1 << i))
+ if(BITTEST(rune, i))
I.Blend(icon('icons/effects/uristrunes.dmi', "rune-[1 << i]"), ICON_OVERLAY)
var/obj/o = new(t)
@@ -265,4 +265,4 @@ var/list/rune_animation = list(
list(0.250, 1),
list(0.125, 1),
))
-*/
\ No newline at end of file
+*/
diff --git a/code/modules/mob/living/carbon/human/death.dm b/code/modules/mob/living/carbon/human/death.dm
index 9ed050b5ae..9571a789a8 100644
--- a/code/modules/mob/living/carbon/human/death.dm
+++ b/code/modules/mob/living/carbon/human/death.dm
@@ -28,8 +28,9 @@
if(stat == DEAD) return
- hud_updateflag |= 1 << HEALTH_HUD
- hud_updateflag |= 1 << STATUS_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
+ BITSET(hud_updateflag, STATUS_HUD)
+
handle_hud_list()
//Handle species-specific deaths.
diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm
index a37933f57f..6972f3047a 100644
--- a/code/modules/mob/living/carbon/human/human.dm
+++ b/code/modules/mob/living/carbon/human/human.dm
@@ -412,7 +412,7 @@
modified = 1
spawn()
- hud_updateflag |= 1 << WANTED_HUD
+ BITSET(hud_updateflag, WANTED_HUD)
if(istype(usr,/mob/living/carbon/human))
var/mob/living/carbon/human/U = usr
U.handle_regular_hud_updates()
@@ -1299,4 +1299,4 @@
/mob/living/carbon/human/slip(var/slipped_on, stun_duration=8)
if((species.flags & NO_SLIP) || (shoes && (shoes.flags & NOSLIP)))
return 0
- ..(slipped_on,stun_duration)
\ No newline at end of file
+ ..(slipped_on,stun_duration)
diff --git a/code/modules/mob/living/carbon/human/human_damage.dm b/code/modules/mob/living/carbon/human/human_damage.dm
index 60f1f8a3a2..561659a27a 100644
--- a/code/modules/mob/living/carbon/human/human_damage.dm
+++ b/code/modules/mob/living/carbon/human/human_damage.dm
@@ -87,7 +87,7 @@
take_overall_damage(amount, 0)
else
heal_overall_damage(-amount, 0)
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
/mob/living/carbon/human/adjustFireLoss(var/amount)
if(species && species.burn_mod)
@@ -97,7 +97,7 @@
take_overall_damage(0, amount)
else
heal_overall_damage(0, -amount)
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
/mob/living/carbon/human/proc/adjustBruteLossByPart(var/amount, var/organ_name, var/obj/damage_source = null)
if(species && species.brute_mod)
@@ -112,7 +112,7 @@
//if you don't want to heal robot organs, they you will have to check that yourself before using this proc.
O.heal_damage(-amount, 0, internal=0, robo_repair=(O.status & ORGAN_ROBOT))
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
/mob/living/carbon/human/proc/adjustFireLossByPart(var/amount, var/organ_name, var/obj/damage_source = null)
if(species && species.burn_mod)
@@ -127,7 +127,7 @@
//if you don't want to heal robot organs, they you will have to check that yourself before using this proc.
O.heal_damage(0, -amount, internal=0, robo_repair=(O.status & ORGAN_ROBOT))
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
/mob/living/carbon/human/Stun(amount)
if(HULK in mutations) return
@@ -185,7 +185,7 @@
if (O.status & ORGAN_MUTATED)
O.unmutate()
src << "Your [O.display_name] is shaped normally again."
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
// Defined here solely to take species flags into account without having to recast at mob/living level.
/mob/living/carbon/human/getOxyLoss()
@@ -249,7 +249,7 @@
var/datum/organ/external/picked = pick(parts)
if(picked.heal_damage(brute,burn))
UpdateDamageIcon()
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
updatehealth()
@@ -265,7 +265,7 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
var/datum/organ/external/picked = pick(parts)
if(picked.take_damage(brute,burn,sharp,edge))
UpdateDamageIcon()
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
updatehealth()
speech_problem_flag = 1
@@ -288,7 +288,7 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
parts -= picked
updatehealth()
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
speech_problem_flag = 1
if(update) UpdateDamageIcon()
@@ -309,7 +309,7 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
parts -= picked
updatehealth()
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
if(update) UpdateDamageIcon()
@@ -336,7 +336,7 @@ This function restores all organs.
if(istype(E, /datum/organ/external))
if (E.heal_damage(brute, burn))
UpdateDamageIcon()
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
else
return 0
return
@@ -393,5 +393,5 @@ This function restores all organs.
// Will set our damageoverlay icon to the next level, which will then be set back to the normal level the next mob.Life().
updatehealth()
- hud_updateflag |= 1 << HEALTH_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
return 1
diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm
index 0f13a6dbfd..236598a08e 100644
--- a/code/modules/mob/living/carbon/human/life.dm
+++ b/code/modules/mob/living/carbon/human/life.dm
@@ -1608,8 +1608,7 @@
/mob/living/carbon/human/proc/handle_hud_list()
-
- if(hud_updateflag & 1 << HEALTH_HUD)
+ if (BITTEST(hud_updateflag, HEALTH_HUD))
var/image/holder = hud_list[HEALTH_HUD]
if(stat == 2)
holder.icon_state = "hudhealth-100" // X_X
@@ -1617,8 +1616,8 @@
var/percentage_health = RoundHealth((health-config.health_threshold_crit)/(maxHealth-config.health_threshold_crit)*100)
holder.icon_state = "hud[percentage_health]"
hud_list[HEALTH_HUD] = holder
-
- if(hud_updateflag & 1 << STATUS_HUD)
+
+ if (BITTEST(hud_updateflag, STATUS_HUD))
var/foundVirus = 0
for(var/datum/disease/D in viruses)
if(!D.hidden[SCANNER])
@@ -1654,8 +1653,8 @@
hud_list[STATUS_HUD] = holder
hud_list[STATUS_HUD_OOC] = holder2
-
- if(hud_updateflag & 1 << ID_HUD)
+
+ if (BITTEST(hud_updateflag, ID_HUD))
var/image/holder = hud_list[ID_HUD]
if(wear_id)
var/obj/item/weapon/card/id/I = wear_id.GetID()
@@ -1668,8 +1667,8 @@
hud_list[ID_HUD] = holder
-
- if(hud_updateflag & 1 << WANTED_HUD)
+
+ if (BITTEST(hud_updateflag, WANTED_HUD))
var/image/holder = hud_list[WANTED_HUD]
holder.icon_state = "hudblank"
var/perpname = name
@@ -1694,8 +1693,11 @@
holder.icon_state = "hudreleased"
break
hud_list[WANTED_HUD] = holder
-
- if(hud_updateflag & 1 << IMPLOYAL_HUD || hud_updateflag & 1 << IMPCHEM_HUD || hud_updateflag & 1 << IMPTRACK_HUD)
+
+ if ( BITTEST(hud_updateflag, IMPLOYAL_HUD) \
+ || BITTEST(hud_updateflag, IMPCHEM_HUD) \
+ || BITTEST(hud_updateflag, IMPTRACK_HUD))
+
var/image/holder1 = hud_list[IMPTRACK_HUD]
var/image/holder2 = hud_list[IMPLOYAL_HUD]
var/image/holder3 = hud_list[IMPCHEM_HUD]
@@ -1715,9 +1717,9 @@
hud_list[IMPTRACK_HUD] = holder1
hud_list[IMPLOYAL_HUD] = holder2
- hud_list[IMPCHEM_HUD] = holder3
-
- if(hud_updateflag & 1 << SPECIALROLE_HUD)
+ hud_list[IMPCHEM_HUD] = holder3
+
+ if (BITTEST(hud_updateflag, SPECIALROLE_HUD))
var/image/holder = hud_list[SPECIALROLE_HUD]
holder.icon_state = "hudblank"
if(mind)
diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm
index cc053f219d..30cbcd0ec2 100644
--- a/code/modules/mob/living/carbon/human/update_icons.dm
+++ b/code/modules/mob/living/carbon/human/update_icons.dm
@@ -567,8 +567,8 @@ proc/get_damage_icon_part(damage_state, body_part)
else
overlays_standing[ID_LAYER] = null
- hud_updateflag |= 1 << ID_HUD
- hud_updateflag |= 1 << WANTED_HUD
+ BITSET(hud_updateflag, ID_HUD)
+ BITSET(hud_updateflag, WANTED_HUD)
if(update_icons) update_icons()
diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm
index b9f898ab5d..d783c268f5 100644
--- a/code/modules/mob/living/living.dm
+++ b/code/modules/mob/living/living.dm
@@ -279,8 +279,8 @@
if (C.legcuffed && !initial(C.legcuffed))
C.drop_from_inventory(C.legcuffed)
C.legcuffed = initial(C.legcuffed)
- hud_updateflag |= 1 << HEALTH_HUD
- hud_updateflag |= 1 << STATUS_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
+ BITSET(hud_updateflag, STATUS_HUD)
/mob/living/proc/rejuvenate()
@@ -329,8 +329,8 @@
// make the icons look correct
regenerate_icons()
- hud_updateflag |= 1 << HEALTH_HUD
- hud_updateflag |= 1 << STATUS_HUD
+ BITSET(hud_updateflag, HEALTH_HUD)
+ BITSET(hud_updateflag, STATUS_HUD)
return
/mob/living/proc/UpdateDamageIcon()
@@ -841,4 +841,4 @@
return 1
/mob/living/proc/slip(var/slipped_on,stun_duration=8)
- return 0
\ No newline at end of file
+ return 0
diff --git a/code/modules/surgery/implant.dm b/code/modules/surgery/implant.dm
index bb7d25046a..4635d146e6 100644
--- a/code/modules/surgery/implant.dm
+++ b/code/modules/surgery/implant.dm
@@ -190,7 +190,7 @@
"\blue You take [obj] out of incision on [target]'s [affected.display_name]s with \the [tool]." )
affected.implants -= obj
- target.hud_updateflag |= 1 << IMPLOYAL_HUD
+ BITSET(target.hud_updateflag, IMPLOYAL_HUD)
//Handle possessive brain borers.
if(istype(obj,/mob/living/simple_animal/borer))
diff --git a/code/modules/virus2/disease2.dm b/code/modules/virus2/disease2.dm
index 977c9ab9ca..b4ae3bd033 100644
--- a/code/modules/virus2/disease2.dm
+++ b/code/modules/virus2/disease2.dm
@@ -100,7 +100,7 @@
for(var/datum/disease2/effectholder/e in effects)
e.effect.deactivate(mob)
mob.virus2.Remove("[uniqueID]")
- mob.hud_updateflag |= 1 << STATUS_HUD
+ BITSET(mob.hud_updateflag, STATUS_HUD)
/datum/disease2/disease/proc/minormutate()
//uniqueID = rand(0,10000)
diff --git a/code/modules/virus2/helpers.dm b/code/modules/virus2/helpers.dm
index 6118dade42..483f3a985f 100644
--- a/code/modules/virus2/helpers.dm
+++ b/code/modules/virus2/helpers.dm
@@ -94,7 +94,7 @@ proc/airborne_can_reach(turf/source, turf/target)
D.minormutate()
// log_debug("Adding virus")
M.virus2["[D.uniqueID]"] = D
- M.hud_updateflag |= 1 << STATUS_HUD
+ BITSET(M.hud_updateflag, STATUS_HUD)
//Infects mob M with random lesser disease, if he doesn't have one
/proc/infect_mob_random_lesser(var/mob/living/carbon/M)
@@ -102,14 +102,14 @@ proc/airborne_can_reach(turf/source, turf/target)
D.makerandom()
D.infectionchance = 1
infect_virus2(M,D,1)
- M.hud_updateflag |= 1 << STATUS_HUD
+ BITSET(M.hud_updateflag, STATUS_HUD)
//Infects mob M with random greated disease, if he doesn't have one
/proc/infect_mob_random_greater(var/mob/living/carbon/M)
var/datum/disease2/disease/D = new /datum/disease2/disease
D.makerandom(1)
infect_virus2(M,D,1)
- M.hud_updateflag |= 1 << STATUS_HUD
+ BITSET(M.hud_updateflag, STATUS_HUD)
//Fancy prob() function.
/proc/dprob(var/p)