Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	code/datums/uplink/hardsuit_modules.dm
#	code/datums/uplink/highly_visible_and_dangerous_weapons.dm
#	code/game/objects/items/weapons/material/coins.dm
#	code/game/objects/structures/window.dm
#	code/game/turfs/simulated/walls.dm
#	code/modules/mob/living/simple_animal/hostile/hivebot.dm
#	maps/torch/items/clothing/solgov-suit.dm
  • Loading branch information
bear1ake committed Jul 2, 2021
2 parents ce69154 + 4439306 commit e1f8047
Show file tree
Hide file tree
Showing 115 changed files with 1,131 additions and 577 deletions.
3 changes: 3 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
#include "code\_helpers\atmospherics.dm"
#include "code\_helpers\atom_movables.dm"
#include "code\_helpers\builtin_proc_callers.dm"
#include "code\_helpers\client.dm"
#include "code\_helpers\cmp.dm"
#include "code\_helpers\functional.dm"
#include "code\_helpers\game.dm"
Expand All @@ -129,6 +130,7 @@
#include "code\_helpers\names.dm"
#include "code\_helpers\sanitize_values.dm"
#include "code\_helpers\spawn_sync.dm"
#include "code\_helpers\species.dm"
#include "code\_helpers\storage.dm"
#include "code\_helpers\text.dm"
#include "code\_helpers\time.dm"
Expand Down Expand Up @@ -1682,6 +1684,7 @@
#include "code\modules\clothing\under\accessories\stethoscope.dm"
#include "code\modules\clothing\under\accessories\storage.dm"
#include "code\modules\clothing\under\accessories\ties.dm"
#include "code\modules\clothing\under\accessories\wristwatches.dm"
#include "code\modules\clothing\under\jobs\civilian.dm"
#include "code\modules\clothing\under\jobs\engineering.dm"
#include "code\modules\clothing\under\jobs\medsci.dm"
Expand Down
40 changes: 40 additions & 0 deletions code/__defines/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,43 @@
__BIN_MID = __BIN_ITEM.##COMPARE > IN.##COMPARE ? __BIN_MID : __BIN_MID + 1;\
LIST.Insert(__BIN_MID, IN);\
}

/// Passed into BINARY_INSERT to compare keys
#define COMPARE_KEY __BIN_LIST[__BIN_MID]
/// Passed into BINARY_INSERT to compare values
#define COMPARE_VALUE __BIN_LIST[__BIN_LIST[__BIN_MID]]

/****
* Binary search sorted insert from TG
* INPUT: Object to be inserted
* LIST: List to insert object into
* TYPECONT: The typepath of the contents of the list
* COMPARE: The object to compare against, usualy the same as INPUT
* COMPARISON: The variable on the objects to compare
* COMPTYPE: How should the values be compared? Either COMPARE_KEY or COMPARE_VALUE.
*/
#define BINARY_INSERT_TG(INPUT, LIST, TYPECONT, COMPARE, COMPARISON, COMPTYPE) \
do {\
var/list/__BIN_LIST = LIST;\
var/__BIN_CTTL = length(__BIN_LIST);\
if(!__BIN_CTTL) {\
__BIN_LIST += INPUT;\
} else {\
var/__BIN_LEFT = 1;\
var/__BIN_RIGHT = __BIN_CTTL;\
var/__BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\
var ##TYPECONT/__BIN_ITEM;\
while(__BIN_LEFT < __BIN_RIGHT) {\
__BIN_ITEM = COMPTYPE;\
if(__BIN_ITEM.##COMPARISON <= COMPARE.##COMPARISON) {\
__BIN_LEFT = __BIN_MID + 1;\
} else {\
__BIN_RIGHT = __BIN_MID;\
};\
__BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\
};\
__BIN_ITEM = COMPTYPE;\
__BIN_MID = __BIN_ITEM.##COMPARISON > COMPARE.##COMPARISON ? __BIN_MID : __BIN_MID + 1;\
__BIN_LIST.Insert(__BIN_MID, INPUT);\
};\
} while(FALSE)
51 changes: 51 additions & 0 deletions code/_helpers/client.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Helpers related to /client
*/


/// Duck check to see if text looks like a ckey
/proc/valid_ckey(text)
var/static/regex/matcher = new (@"^[a-z0-9]{1,30}$")
return regex_find(matcher, text)


/// Duck check to see if text looks like a key
/proc/valid_key(text)
var/static/regex/matcher = new (@"^[0-9A-Za-z][0-9A-Za-z_\. -]{2,29}$")
return regex_find(matcher, text)


/// Get the client associated with ckey text if it is currently connected
/proc/ckey2client(text)
if (valid_ckey(text))
FOR_BLIND(client/C, GLOB.clients)
if (C.ckey == text)
return C


/// Get the client associated with key text if it is currently connected
/proc/key2client(text)
if (valid_key(text))
FOR_BLIND(client/C, GLOB.clients)
if (C.key == text)
return C


/// Null, or a client if thing is a client, a mob with a client, a connected ckey, or null
/proc/resolve_client(client/thing)
if (!thing)
return usr
if (istype(thing))
return thing
if (ismob(thing))
var/mob/M = thing
return M.client
return ckey2client(thing)


/// Null or a client from the list of connected clients, chosen by actor if actor is valid
/proc/select_client(client/actor, message = "Connected clients:", title = "Select Client")
actor = resolve_client(actor)
if (!actor)
return
return input(actor, message, title) as null | anything in GLOB.clients
13 changes: 13 additions & 0 deletions code/_helpers/species.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
Helpers related to /datum/species
*/


/// Null, or a species if thing is a species, a species path, or a species name
/proc/resolve_species(datum/species/thing)
if (ispath(thing, /datum/species))
thing = initial(thing.name)
if (istext(thing))
thing = all_species[thing]
if (istype(thing))
return thing
20 changes: 18 additions & 2 deletions code/_version.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ DM version compatibility macros & procs

#if DM_VERSION < 514


/proc/rgb2num(T) //Take "#RGB" or "#RGBA" or "#RRGGBB" or "#RRGGBBAA" and turn it into list(R, G, B[, A]). Ignores color space.
/// Create the list(R, G, B[, A]) for inputs "#RGB", "#RGBA", "#RRGGBB", or "#RRGGBBAA". IGNORES color space.
/proc/rgb2num(T)
var/static/regex/allowed = new(@"^#[0-9a-fA-F]{3,8}$")
if (findtext(T, allowed))
switch (length(T))
Expand All @@ -86,3 +86,19 @@ DM version compatibility macros & procs


#endif


/**
FOR_BLIND provides a common pattern for a typed for..in that SKIPS type checking.
This kind of loop provides a decent performance improvement but is best reserved
for hotspot code where the type of the members of the collection is never in doubt.
"as anything" became valid syntax in build 513.1540: <http://byond.com/docs/notes/513.html>
eg:
FOR_BLIND(client/C, GLOB.clients)
to_chat(C, "Hello [C].")
*/
#if DM_BUILD < 1540
#define FOR_BLIND(V, C) for (var/V as() in C)
#else
#define FOR_BLIND(V, C) for (var/V as anything in C)
#endif
4 changes: 4 additions & 0 deletions code/controllers/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var/list/gamemode_cache = list()
var/log_hrefs = 0 // logs all links clicked in-game. Could be used for debugging and tracking down exploits
var/log_runtime = 0 // logs world.log to a file
var/log_world_output = 0 // log world.log to game log
var/log_timers_on_bucket_reset = 0 // logs all timers in buckets on automatic bucket reset (Useful for timer debugging)
var/allow_admin_ooccolor = 0 // Allows admins with relevant permissions to have their own ooc colour
var/allow_vote_restart = 0 // allow votes to restart
var/ert_admin_call_only = 0
Expand Down Expand Up @@ -347,6 +348,9 @@ var/list/gamemode_cache = list()
if ("log_world_output")
config.log_world_output = 1

if("log_timers_on_bucket_reset")
config.log_timers_on_bucket_reset = 1

if ("log_hrefs")
config.log_hrefs = 1

Expand Down
Loading

0 comments on commit e1f8047

Please sign in to comment.