Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telecomms housekeeping #9299

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@

//check if all bitflags specified are present
#define CHECK_MULTIPLE_BITFIELDS(flagvar, flags) ((flagvar & (flags)) == flags)


/// Right-shift of INT by BITS
#define SHIFTR(INT, BITS) ((INT) >> (BITS))


/// Left-shift of INT by BITS
#define SHIFTL(INT, BITS) ((INT) << (BITS))
69 changes: 69 additions & 0 deletions code/_version.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#if DM_VERSION < 515

#define call_ext(ARGS...) call(ARGS)

/proc/ceil(number)
return -round(-number)

/proc/floor(number)
return round(number)

/proc/fract(number)
return number - trunc(number)

/proc/ftime()
throw EXCEPTION("ftime not available below 515")

/proc/get_steps_to()
throw EXCEPTION("get_steps_to not available below 515")

/proc/isinf(number)
return number == POSITIVE_INFINITY || number == NEGATIVE_INFINITY

/proc/isnan(number)
return isnum(number) && number != number

/proc/ispointer()
throw EXCEPTION("ispointer not available below 515")

/proc/nameof(thing)
throw EXCEPTION("nameof not available below 515")

/proc/noise_hash()
throw EXCEPTION("noise_hash not available below 515")

/proc/refcount(datum)
throw EXCEPTION("refcount not available below 515")

/proc/trimtext(text)
var/static/regex/pattern
if (!pattern)
pattern = regex(@"^\s*(.*?)\s*$", "g")
return replacetext_char(text, pattern, "$1")

/proc/trunc(number)
if (number < 0)
return -round(-number)
return round(number)

/client/proc/RenderIcon(atom)
throw EXCEPTION("client::RenderIcon() not available below 515")

/* lists cannot have new procs. But if they could:
/list/proc/RemoveAll()
var/result = 0
for (var/entry in args)
while (Remove(entry))
++result
return result
*/

#define ANIMATION_SLICE 8
#define ANIMATION_CONTINUE 512

#define JSON_PRETTY_PRINT 1

#define JSON_STRICT 1
#define JSON_ALLOW_COMMENTS 2

#endif
119 changes: 119 additions & 0 deletions code/core/math/math.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/// IEEE 754-1985 positive infinity. As text, win: 1.#INF, lin: inf
var/global/const/POSITIVE_INFINITY = 1#INF

/// IEEE 754-1985 negative infinity. As text, win: -1.#INF, -lin: inf
var/global/const/NEGATIVE_INFINITY = -1#INF

// IEEE 754-1985 positive NaN. Creatable but not useful. As text, win: 1.#QNAN, lin: nan
//var/const/POSITIVE_NAN = -(1#INF/1#INF)

// IEEE 754-1985 nevative NaN. Creatable but not useful. As text, win: -1.#IND, lin: -nan
//var/const/NEGATIVE_NAN = (1#INF/1#INF)

/// Multiplier for converting degrees to radians, rounded to 10 places
var/global/const/DEG_TO_RAD = 0.0174532925

/// Multiplier for converting radians to degrees, rounded to 10 places
var/global/const/RAD_TO_DEG = 57.295779513

/// The mathematical constant pi, rounded to 10 places
var/global/const/PI = 3.1415926536

/// Twice the mathematical constant pi, rounded to 10 places
var/global/const/TWO_PI = 6.2831853072

/// Half the mathematical constant pi, rounded to 10 places
var/global/const/HALF_PI = 1.5707963268


/// True if number is a number that is not nan or an infinity.
/proc/isfinite(number)
return isnum(number) && !isnan(number) && !isinf(number)


/**
Sample t(0..1) into a quadratic binomial polynomial.
Generally this is useful for shaping rand() distribution.
see tools/polyvis.html for a parameter picker.
*/
/proc/poly_interp2(t, p0, p1, p2)
var/mt = 1 - t
return p0 * mt * mt +\
2 * p1 * mt * t +\
p2 * t * t

/**
Sample t(0..1) into a cubic binomial polynomial.
Generally this is useful for shaping rand() distribution.
see tools/polyvis.html for a parameter picker.
More expensive than poly_interp2.
*/
/proc/poly_interp3(t, p0, p1, p2, p3)
var/t2 = t * t
var/mt = 1 - t
var/mt2 = mt * mt
return p0 * mt2 * mt +\
3 * p1 * mt2 * t +\
3 * p2 * mt * t2 +\
p3 * t2 * t

/**
Sample t(0..1) into a quartic binomial polynomial.
Generally this is useful for shaping rand() distribution.
see tools/polyvis.html for a parameter picker.
More expensive than poly_interp3.
*/
/proc/poly_interp4(t, p0, p1, p2, p3, p4)
var/t2 = t * t
var/t3 = t2 * t
var/mt = 1 - t
var/mt2 = mt * mt
var/mt3 = mt2 * mt
return p0 * mt3 * mt +\
4 * p1 * mt3 * t +\
6 * p2 * mt2 * t2 +\
4 * p3 * mt * t3 +\
p4 * t3 * t


/**
Get the coordinates that make up a circle of radius on center, packed as (x | y left shift 12).
These coordinates are able to be outside the world: check (v < 1 || v > world.maxV) for safety.
Implements the Bresenham Circle Drawing Algorithm for the actual point picking.
*/
/proc/get_circle_coordinates(radius, center_x, center_y)
var/static/list/cache = list()
radius = round(radius, 1)
if (radius < 1)
return list(center_x | SHIFTL(center_y, 12))
center_x = round(center_x, 1)
center_y = round(center_y, 1)
var/list/points = length(cache) ? cache["[radius]"] : null
if (!points)
points = list()
var/y = radius
var/gradient = 3 - 2 * radius
for (var/x = 0 to radius)
points |= list(
radius + x | SHIFTL(radius + y, 12),
radius + x | SHIFTL(radius - y, 12),
radius - x | SHIFTL(radius + y, 12),
radius - x | SHIFTL(radius - y, 12),
radius + y | SHIFTL(radius + x, 12),
radius + y | SHIFTL(radius - x, 12),
radius - y | SHIFTL(radius + x, 12),
radius - y | SHIFTL(radius - x, 12)
)
if (x >= y)
break
if (gradient < 0)
gradient = gradient + 4 * x + 6
else
gradient = gradient + 4 * (x - y) + 10
--y
cache["[radius]"] = points
var/list/result = points.Copy()
var/center = center_x - radius | SHIFTL(center_y - radius, 12)
for (var/i = 1 to length(result))
result[i] += center
return result
91 changes: 0 additions & 91 deletions code/defines/procs/radio.dm

This file was deleted.

13 changes: 13 additions & 0 deletions code/game/machinery/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,16 @@ Class Procs:
// Stub for above proc. Implemented on exosuit fabricators and prosthetics fabricators.
/obj/machinery/proc/refresh_queue()
return


/obj/machinery/proc/get_multitool(mob/user)
var/obj/item/multitool/P = null
if (!issilicon(user) && istype(user.get_active_hand(), /obj/item/multitool))
P = user.get_active_hand()
else if (isAI(user))
var/mob/living/silicon/ai/U = user
P = U.aiMulti
else if (isrobot(user) && in_range(user, src))
if (istype(user.get_active_hand(), /obj/item/multitool))
P = user.get_active_hand()
return P
16 changes: 0 additions & 16 deletions code/game/machinery/newscaster.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,6 @@
NEWSCASTER.newsAlert(annoncement)
NEWSCASTER.update_icon()

// var/list/receiving_pdas = new
// for (var/obj/item/pda/P in PDAs)
// if(!P.owner)
// continue
// if(P.toff)
// continue
// receiving_pdas += P

// spawn(0) // get_receptions sleeps further down the line, spawn of elsewhere
// var/datum/receptions/receptions = get_receptions(null, receiving_pdas) // datums are not atoms, thus we have to assume the newscast network always has reception

// for(var/obj/item/pda/PDA in receiving_pdas)
// if(!(receptions.receiver_reception[PDA] & TELECOMMS_RECEPTION_RECEIVER))
// continue

// PDA.new_news(annoncement)

var/global/datum/feed_network/news_network = new /datum/feed_network //The global news-network, which is coincidentally a global list.

Expand Down
Loading