Merge remote-tracking branch 'citadel/master' into stuff

This commit is contained in:
kevinz000
2020-02-13 04:14:44 -07:00
85 changed files with 998 additions and 457 deletions
@@ -68,8 +68,8 @@
/obj/item/clockwork/replica_fabricator/pre_attack(atom/target, mob/living/user, params)
if(!target || !user || !is_servant_of_ratvar(user) || istype(target, /obj/item/storage))
return TRUE
return fabricate(target, user)
return ..()
return !fabricate(target, user)
//A note here; return values are for if we CAN BE PUT ON A TABLE, not IF WE ARE SUCCESSFUL, unless no_table_check is TRUE
/obj/item/clockwork/replica_fabricator/proc/fabricate(atom/target, mob/living/user, silent, no_table_check)
@@ -470,7 +470,7 @@
/obj/item/claymore/ctf/pre_attack(atom/target, mob/user, params)
if(!is_ctf_target(target))
return FALSE
return TRUE
return ..()
/obj/item/claymore/ctf/dropped()
+1
View File
@@ -105,6 +105,7 @@ datum/bounty/reagent/complex_drink/New()
/datum/reagent/consumable/ethanol/hearty_punch,\
/datum/reagent/consumable/ethanol/manhattan_proj,\
/datum/reagent/consumable/ethanol/narsour,\
/datum/reagent/consumable/ethanol/cogchamp,\
/datum/reagent/consumable/ethanol/neurotoxin,\
/datum/reagent/consumable/ethanol/patron,\
/datum/reagent/consumable/ethanol/quadruple_sec,\
+1 -1
View File
@@ -272,7 +272,7 @@
/datum/outfit/wizard
name = "Blue Wizard"
uniform = /obj/item/clothing/under/color/lightpurple
uniform = /obj/item/clothing/under/color/lightpurple/trackless
suit = /obj/item/clothing/suit/wizrobe
shoes = /obj/item/clothing/shoes/sandal/magic
ears = /obj/item/radio/headset
+8 -1
View File
@@ -41,6 +41,10 @@
item_color = "black"
resistance_flags = NONE
/obj/item/clothing/under/color/black/trackless
desc = "A black jumpsuit that has its sensors removed."
has_sensor = NO_SENSORS
/obj/item/clothing/under/skirt/color/black
name = "black jumpskirt"
icon_state = "black_skirt"
@@ -189,13 +193,16 @@
item_state = "b_suit"
item_color = "teal_skirt"
/obj/item/clothing/under/color/lightpurple
name = "purple jumpsuit"
icon_state = "lightpurple"
item_state = "p_suit"
item_color = "lightpurple"
/obj/item/clothing/under/color/lightpurple/trackless
desc = "A magically colored jumpsuit. No sensors are attached!"
has_sensor = NO_SENSORS
/obj/item/clothing/under/skirt/color/lightpurple
name = "lightpurple jumpskirt"
icon_state = "lightpurple_skirt"
@@ -19,6 +19,13 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
log_world("The bug with recursion runtimes has been fixed. Please remove the snowflake check from world/Error in [__FILE__]:[__LINE__]")
return //this will never happen.
else if(copytext(E.name,1,18) == "Out of resources!")//18 == length() of that string + 1
log_world("BYOND out of memory. Restarting")
log_game("BYOND out of memory. Restarting")
TgsEndProcess()
Reboot(reason = 1)
return ..()
if (islist(stack_trace_storage))
for (var/line in splittext(E.desc, "\n"))
if (text2ascii(line) != 32)
@@ -585,6 +585,14 @@
mix_message = "The mixture develops a sinister glow."
mix_sound = 'sound/effects/singlebeat.ogg'
/datum/chemical_reaction/cogchamp
name = "CogChamp"
id = /datum/reagent/consumable/ethanol/cogchamp
results = list(/datum/reagent/consumable/ethanol/cogchamp = 3)
required_reagents = list(/datum/reagent/consumable/ethanol/cognac = 1, /datum/reagent/fuel = 1, /datum/reagent/consumable/ethanol/screwdrivercocktail = 1)
mix_message = "You hear faint sounds of gears turning as it mixes."
mix_sound = 'sound/effects/clockcult_gateway_closing.ogg'
/datum/chemical_reaction/quadruplesec
name = "Quadruple Sec"
id = /datum/reagent/consumable/ethanol/quadruple_sec
+1 -1
View File
@@ -46,7 +46,7 @@
/obj/item/resonator/pre_attack(atom/target, mob/user, params)
if(check_allowed_items(target, 1))
CreateResonance(target, user)
return TRUE
return ..()
//resonance field, crushes rock, damages mobs
/obj/effect/temp_visual/resonance
@@ -16,7 +16,7 @@
from doing this unless you absolutely know what you are doing, and have defined a
conversion in savefile.dm
*/
/proc/init_sprite_accessory_subtypes(prototype, list/L, list/male, list/female,var/roundstart = FALSE)//Roundstart argument builds a specific list for roundstart parts where some parts may be locked
/proc/init_sprite_accessory_subtypes(prototype, list/L, list/male, list/female, roundstart = FALSE, skip_prototype = TRUE)//Roundstart argument builds a specific list for roundstart parts where some parts may be locked
if(!istype(L))
L = list()
if(!istype(male))
@@ -25,7 +25,7 @@
female = list()
for(var/path in typesof(prototype))
if(path == prototype)
if(path == prototype && skip_prototype)
continue
if(roundstart)
var/datum/sprite_accessory/P = path
+3
View File
@@ -581,6 +581,9 @@ GLOBAL_LIST_INIT(ballmer_windows_me_msg, list("Yo man, what if, we like, uh, put
if(cultslurring)
cultslurring = max(cultslurring-1, 0)
if(clockcultslurring)
clockcultslurring = max(clockcultslurring-1, 0)
if(silent)
silent = max(silent-1, 0)
@@ -89,6 +89,7 @@
var/stuttering = 0
var/slurring = 0
var/cultslurring = 0
var/clockcultslurring = 0
var/derpspeech = 0
var/list/implants = null
+3
View File
@@ -354,6 +354,9 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
if(cultslurring)
message = cultslur(message)
if(clockcultslurring)
message = CLOCK_CULT_SLUR(message)
message = capitalize(message)
+4
View File
@@ -147,6 +147,10 @@
. += newletter
return sanitize(.)
//Ratvarian Slurring!
#define CLOCK_CULT_SLUR(phrase) sanitize(text2ratvar(phrase))
///Adds stuttering to the message passed in
/proc/stutter(phrase)
phrase = html_decode(phrase)
+1 -1
View File
@@ -1,6 +1,6 @@
/datum/outfit/ninja
name = "Space Ninja"
uniform = /obj/item/clothing/under/color/black
uniform = /obj/item/clothing/under/color/black/trackless
suit = /obj/item/clothing/suit/space/space_ninja
glasses = /obj/item/clothing/glasses/night
mask = /obj/item/clothing/mask/gas/space_ninja
@@ -15,15 +15,15 @@
. = ..()
/obj/item/ammo_casing/energy/gravity/repulse
projectile_type = /obj/item/projectile/gravityrepulse
projectile_type = /obj/item/projectile/gravity/repulse
select_name = "repulse"
/obj/item/ammo_casing/energy/gravity/attract
projectile_type = /obj/item/projectile/gravityattract
projectile_type = /obj/item/projectile/gravity/attract
select_name = "attract"
/obj/item/ammo_casing/energy/gravity/chaos
projectile_type = /obj/item/projectile/gravitychaos
projectile_type = /obj/item/projectile/gravity/chaos
select_name = "chaos"
+13 -3
View File
@@ -69,13 +69,10 @@
if(gun)
qdel(gun)
/obj/item/firing_pin/magic
name = "magic crystal shard"
desc = "A small enchanted shard which allows magical weapons to fire."
// Test pin, works only near firing range.
/obj/item/firing_pin/test_range
name = "test-range firing pin"
@@ -229,3 +226,16 @@
if(gun)
gun.pin = null
return ..()
//Station Locked
/obj/item/firing_pin/away
name = "station locked pin"
desc = "A firing pin that only will fire when off the station."
/obj/item/firing_pin/away/pin_auth(mob/living/user)
var/area/station_area = get_area(src)
if(!station_area || is_station_level(station_area.z))
to_chat(user, "<span class='warning'>The pin beeps, refusing to fire.</span>")
return FALSE
return TRUE
@@ -1,90 +1,65 @@
/obj/item/projectile/gravityrepulse
/obj/item/projectile/gravity
name = "gravity bolt"
icon = 'icons/effects/effects.dmi'
icon_state = "chronofield"
hitsound = 'sound/weapons/wave.ogg'
damage = 0
damage_type = BRUTE
nodamage = TRUE
var/power = 4
var/list/thrown = list() //normally we wouldn't need this but incase on_hit is called multiple times, yeah.. this is a good idea.
/obj/item/projectile/gravity/Initialize(mapload)
. = ..()
var/obj/item/ammo_casing/energy/gravity/G = loc
if(istype(G))
power = min(G.gun.power, 15)
/obj/item/projectile/gravity/on_hit()
. = ..()
var/turf/T = get_turf(src)
var/list/tothrow = list()
var/list/cachedrange = range(T, power)
for(var/mob/M in cachedrange)
tothrow += M
for(var/obj/O in cachedrange)
tothrow += O
var/safety = 50
for(var/i in tothrow)
if(!safety)
break
var/atom/movable/AM = i
if((AM == src) || (AM == firer) || (AM.move_resist > MOVE_FORCE_EXTREMELY_STRONG) || AM.anchored || thrown[AM])
continue
thrown[AM] = TRUE
safety--
var/target = get_target(T, AM)
if(!target)
return FALSE
AM.throw_at(target, power + 1, 1)
for(var/turf/F in range(T,power))
new /obj/effect/temp_visual/gravpush(F)
/obj/item/projectile/gravity/proc/get_target(turf/origin, atom/movable/AM)
return origin
/obj/item/projectile/gravity/repulse
name = "repulsion bolt"
icon = 'icons/effects/effects.dmi'
icon_state = "chronofield"
hitsound = 'sound/weapons/wave.ogg'
damage = 0
damage_type = BRUTE
nodamage = 1
color = "#33CCFF"
var/turf/T
var/power = 4
var/list/thrown_items = list()
/obj/item/projectile/gravityrepulse/Initialize()
. = ..()
var/obj/item/ammo_casing/energy/gravity/repulse/C = loc
if(istype(C)) //Hard-coded maximum power so servers can't be crashed by trying to throw the entire Z level's items
power = min(C.gun.power, 15)
/obj/item/projectile/gravity/repulse/get_target(turf/origin, atom/movable/AM)
return get_turf_in_angle(Get_Angle(origin, AM), origin, power)
/obj/item/projectile/gravityrepulse/on_hit()
. = ..()
T = get_turf(src)
for(var/atom/movable/A in range(T, power))
if(A == src || (firer && A == src.firer) || A.anchored || thrown_items[A])
continue
var/throwtarget = get_edge_target_turf(src, get_dir(src, get_step_away(A, src)))
A.throw_at(throwtarget,power+1,1)
thrown_items[A] = A
for(var/turf/F in range(T,power))
new /obj/effect/temp_visual/gravpush(F)
/obj/item/projectile/gravityattract
/obj/item/projectile/gravity/attract
name = "attraction bolt"
icon = 'icons/effects/effects.dmi'
icon_state = "chronofield"
hitsound = 'sound/weapons/wave.ogg'
damage = 0
damage_type = BRUTE
nodamage = 1
color = "#FF6600"
var/turf/T
var/power = 4
var/list/thrown_items = list()
/obj/item/projectile/gravityattract/Initialize()
. = ..()
var/obj/item/ammo_casing/energy/gravity/attract/C = loc
if(istype(C)) //Hard-coded maximum power so servers can't be crashed by trying to throw the entire Z level's items
power = min(C.gun.power, 15)
/obj/item/projectile/gravity/attract/get_target(turf/origin, atom/movable/AM)
return origin
/obj/item/projectile/gravityattract/on_hit()
. = ..()
T = get_turf(src)
for(var/atom/movable/A in range(T, power))
if(A == src || (firer && A == src.firer) || A.anchored || thrown_items[A])
continue
A.throw_at(T, power+1, 1)
thrown_items[A] = A
for(var/turf/F in range(T,power))
new /obj/effect/temp_visual/gravpush(F)
/obj/item/projectile/gravitychaos
/obj/item/projectile/gravity/chaos
name = "gravitational blast"
icon = 'icons/effects/effects.dmi'
icon_state = "chronofield"
hitsound = 'sound/weapons/wave.ogg'
damage = 0
damage_type = BRUTE
nodamage = 1
color = "#101010"
var/turf/T
var/power = 4
var/list/thrown_items = list()
/obj/item/projectile/gravitychaos/Initialize()
. = ..()
var/obj/item/ammo_casing/energy/gravity/chaos/C = loc
if(istype(C)) //Hard-coded maximum power so servers can't be crashed by trying to throw the entire Z level's items
power = min(C.gun.power, 15)
/obj/item/projectile/gravitychaos/on_hit()
. = ..()
T = get_turf(src)
for(var/atom/movable/A in range(T, power))
if(A == src|| (firer && A == src.firer) || A.anchored || thrown_items[A])
continue
A.throw_at(get_edge_target_turf(A, pick(GLOB.cardinals)), power+1, 1)
thrown_items[A] = A
for(var/turf/Z in range(T,power))
new /obj/effect/temp_visual/gravpush(Z)
/obj/item/projectile/gravity/chaos/get_target(turf/origin, atom/movable/AM)
return get_turf_in_angle(rand(0, 359), origin, power)
@@ -1513,6 +1513,23 @@ All effects don't start immediately, but rather get worse over time; the rate is
M.stuttering = min(M.stuttering + 3, 3)
..()
/datum/reagent/consumable/ethanol/cogchamp
name = "CogChamp"
description = "Now you can fill yourself with the power of Ratvar!"
color = rgb(255, 201, 49)
boozepwr = 10
quality = DRINK_FANTASTIC
taste_description = "a brass taste with a hint of oil"
glass_icon_state = "cogchamp"
glass_name = "CogChamp"
glass_desc = "Not even Ratvar's Four Generals could withstand this! Qevax Jryy!"
value = 8.13
/datum/reagent/consumable/ethanol/cogchamp/on_mob_life(mob/living/carbon/M)
M.clockcultslurring = min(M.clockcultslurring + 3, 3)
M.stuttering = min(M.stuttering + 3, 3)
..()
/datum/reagent/consumable/ethanol/triple_sec
name = "Triple Sec"
description = "A sweet and vibrant orange liqueur."
@@ -423,9 +423,9 @@
else
unload_hypo(vial,user)
/obj/item/hypospray/mkii/AltClick(mob/living/user)
/obj/item/hypospray/mkii/CtrlClick(mob/living/user)
. = ..()
if(user.canUseTopic(src, FALSE))
if(user.canUseTopic(src, FALSE) && user.get_active_held_item(src))
switch(mode)
if(HYPO_SPRAY)
mode = HYPO_INJECT
@@ -437,7 +437,7 @@
/obj/item/hypospray/mkii/examine(mob/user)
. = ..()
. += "<span class='notice'><b>Alt-Click</b> it to toggle its mode from spraying to injecting and vice versa.</span>"
. += "<span class='notice'><b>Ctrl-Click</b> it to toggle its mode from spraying to injecting and vice versa.</span>"
#undef HYPO_SPRAY
#undef HYPO_INJECT
@@ -225,6 +225,16 @@
category = list("Firing Pins")
departmental_flags = DEPARTMENTAL_FLAG_SECURITY
/datum/design/pin_away
name = "Station Locked Pin"
desc = "This is a security firing pin which only authorizes users who are off station."
id = "pin_away"
build_type = PROTOLATHE
materials = list(MAT_METAL = 1500, MAT_GLASS = 2000)
build_path = /obj/item/firing_pin/away
category = list("Firing Pins")
departmental_flags = DEPARTMENTAL_FLAG_SECURITY
//////////////
//Guns////////
//////////////
+1 -1
View File
@@ -22,7 +22,7 @@ If you create T5+ please take a pass at gene_modder.dm [L40]. Max_values MUST fi
if(works_from_distance)
user.Beam(T, icon_state = "rped_upgrade", time = 5)
T.exchange_parts(user, src)
return FALSE
return TRUE
return ..()
/obj/item/storage/part_replacer/afterattack(obj/machinery/T, mob/living/user, adjacent, params)
+1 -1
View File
@@ -666,7 +666,7 @@
display_name = "Weapon Development Technology"
description = "Our researchers have found new to weaponize just about everything now."
prereq_ids = list("engineering")
design_ids = list("pin_testing", "tele_shield", "lasercarbine")
design_ids = list("pin_testing", "tele_shield", "lasercarbine", "pin_away")
research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 7500)
export_price = 5000
+56 -36
View File
@@ -1,47 +1,60 @@
/world/TgsNew(datum/tgs_event_handler/event_handler)
var/tgs_version = world.params[TGS_VERSION_PARAMETER]
if(!tgs_version)
/world/TgsNew(datum/tgs_event_handler/event_handler, minimum_required_security_level = TGS_SECURITY_ULTRASAFE)
var/current_api = TGS_READ_GLOBAL(tgs)
if(current_api)
TGS_ERROR_LOG("TgsNew(): TGS API datum already set ([current_api])! Was TgsNew() called more than once?")
return
var/path = SelectTgsApi(tgs_version)
if(!path)
TGS_ERROR_LOG("Found unsupported API version: [tgs_version]. If this is a valid version please report this, backporting is done on demand.")
#ifdef TGS_V3_API
minimum_required_security_level = TGS_SECURITY_TRUSTED
#endif
var/raw_parameter = world.params[TGS_VERSION_PARAMETER]
if(!raw_parameter)
return
TGS_INFO_LOG("Activating API for version [tgs_version]")
var/datum/tgs_api/new_api = new path
var/datum/tgs_version/version = new(raw_parameter)
if(!version.Valid(FALSE))
TGS_ERROR_LOG("Failed to validate TGS version parameter: [raw_parameter]!")
return
var/result = new_api.OnWorldNew(event_handler ? event_handler : new /datum/tgs_event_handler/tgs_default)
if(result && result != TGS_UNIMPLEMENTED)
TGS_WRITE_GLOBAL(tgs, new_api)
else
var/api_datum
switch(version.suite)
if(3)
#ifndef TGS_V3_API
TGS_ERROR_LOG("Detected V3 API but TGS_V3_API isn't defined!")
#else
switch(version.major)
if(2)
api_datum = /datum/tgs_api/v3210
#endif
if(4)
switch(version.major)
if(0)
api_datum = /datum/tgs_api/v4
var/datum/tgs_version/max_api_version = TgsMaximumAPIVersion();
if(version.suite != null && version.major != null && version.minor != null && version.patch != null && version.deprefixed_parameter > max_api_version.deprefixed_parameter)
TGS_ERROR_LOG("Detected unknown API version! Defaulting to latest. Update the DMAPI to fix this problem.")
api_datum = /datum/tgs_api/latest
if(!api_datum)
TGS_ERROR_LOG("Found unsupported API version: [raw_parameter]. If this is a valid version please report this, backporting is done on demand.")
return
TGS_INFO_LOG("Activating API for version [version.deprefixed_parameter]")
var/datum/tgs_api/new_api = new api_datum(version)
TGS_WRITE_GLOBAL(tgs, new_api)
var/result = new_api.OnWorldNew(event_handler, minimum_required_security_level)
if(!result || result == TGS_UNIMPLEMENTED)
TGS_WRITE_GLOBAL(tgs, null)
TGS_ERROR_LOG("Failed to activate API!")
/world/proc/SelectTgsApi(tgs_version)
//remove the old 3.0 header
tgs_version = replacetext(tgs_version, "/tg/station 13 Server v", "")
var/list/version_bits = splittext(tgs_version, ".")
var/super = text2num(version_bits[1])
var/major = text2num(version_bits[2])
var/minor = text2num(version_bits[3])
var/patch = text2num(version_bits[4])
switch(super)
if(3)
switch(major)
if(2)
return /datum/tgs_api/v3210
if(super != null && major != null && minor != null && patch != null && tgs_version > TgsMaximumAPIVersion())
TGS_ERROR_LOG("Detected unknown API version! Defaulting to latest. Update the DMAPI to fix this problem.")
return /datum/tgs_api/latest
/world/TgsMaximumAPIVersion()
return "4.0.0.0"
return new /datum/tgs_version("4.0.x.x")
/world/TgsMinimumAPIVersion()
return "3.2.0.0"
return new /datum/tgs_version("3.2.0.0")
/world/TgsInitializationComplete()
var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
@@ -71,7 +84,9 @@
return TGS_READ_GLOBAL(tgs) != null
/world/TgsVersion()
return world.params[TGS_VERSION_PARAMETER]
var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
if(api)
return api.version
/world/TgsInstanceName()
var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
@@ -116,6 +131,11 @@
if(api)
api.ChatPrivateMessage(message, user)
/world/TgsSecurityLevel()
var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
if(api)
api.SecurityLevel()
/*
The MIT License
+9 -1
View File
@@ -1,9 +1,14 @@
TGS_DEFINE_AND_SET_GLOBAL(tgs, null)
/datum/tgs_api
var/datum/tgs_version/version
/datum/tgs_api/New(datum/tgs_version/version)
. = ..()
src.version = version
/datum/tgs_api/latest
parent_type = /datum/tgs_api/v3210
parent_type = /datum/tgs_api/v4
TGS_PROTECT_DATUM(/datum/tgs_api)
@@ -46,6 +51,9 @@ TGS_PROTECT_DATUM(/datum/tgs_api)
/datum/tgs_api/proc/ChatPrivateMessage(message, admin_only)
return TGS_UNIMPLEMENTED
/datum/tgs_api/proc/SecurityLevel()
return TGS_UNIMPLEMENTED
/*
The MIT License
@@ -1,30 +0,0 @@
/datum/tgs_event_handler/tgs_default/HandleEvent(event_code)
//TODO
return
/*
The MIT License
Copyright (c) 2017 Jordan Brown
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+22
View File
@@ -0,0 +1,22 @@
/datum/tgs_version/New(raw_parameter)
src.raw_parameter = raw_parameter
deprefixed_parameter = replacetext(raw_parameter, "/tg/station 13 Server v", "")
var/list/version_bits = splittext(deprefixed_parameter, ".")
suite = text2num(version_bits[1])
if(version_bits.len > 1)
major = text2num(version_bits[2])
if(version_bits.len > 2)
minor = text2num(version_bits[3])
if(version_bits.len == 4)
patch = text2num(version_bits[4])
/datum/tgs_version/proc/Valid(allow_wildcards = FALSE)
if(suite == null)
return FALSE
if(allow_wildcards)
return TRUE
return !Wildcard()
/datum/tgs_version/Wildcard()
return major == null || minor == null || patch == null
+5 -1
View File
@@ -1,6 +1,10 @@
#include "core\_definitions.dm"
#include "core\core.dm"
#include "core\datum.dm"
#include "core\default_event_handler.dm"
#include "core\tgs_version.dm"
#ifdef TGS_V3_API
#include "v3210\api.dm"
#include "v3210\commands.dm"
#endif
#include "v4\api.dm"
#include "v4\commands.dm"
+7 -2
View File
@@ -56,8 +56,9 @@
/datum/tgs_api/v3210/proc/file2list(filename)
return splittext(trim_left(trim_right(file2text(filename))), "\n")
/datum/tgs_api/v3210/OnWorldNew(datum/tgs_event_handler/event_handler) //don't use event handling in this version
/datum/tgs_api/v3210/OnWorldNew(datum/tgs_event_handler/event_handler, minimum_required_security_level) //don't use event handling in this version
. = FALSE
comms_key = world.params[SERVICE_WORLD_PARAM]
instance_name = world.params[SERVICE_INSTANCE_PARAM]
if(!instance_name)
@@ -170,6 +171,7 @@
var/datum/tgs_revision_information/ri = new
ri.commit = commit
ri.origin_commit = originmastercommit
return ri
/datum/tgs_api/v3210/EndProcess()
sleep(world.tick_lag) //flush the buffers
@@ -187,9 +189,12 @@
/datum/tgs_api/v3210/ChatTargetedBroadcast(message, admin_only)
ExportService("[admin_only ? SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE : SERVICE_REQUEST_IRC_BROADCAST] [message]")
/datum/tgs_api/v3210/ChatPrivateMessage(message, admin_only)
/datum/tgs_api/v3210/ChatPrivateMessage(message, datum/tgs_chat_user/user)
return TGS_UNIMPLEMENTED
/datum/tgs_api/v3210/SecurityLevel()
return TGS_SECURITY_TRUSTED
#undef REBOOT_MODE_NORMAL
#undef REBOOT_MODE_HARD
#undef REBOOT_MODE_SHUTDOWN
+342
View File
@@ -0,0 +1,342 @@
#define TGS4_PARAM_INFO_JSON "tgs_json"
#define TGS4_INTEROP_ACCESS_IDENTIFIER "tgs_tok"
#define TGS4_RESPONSE_SUCCESS "tgs_succ"
#define TGS4_TOPIC_CHANGE_PORT "tgs_port"
#define TGS4_TOPIC_CHANGE_REBOOT_MODE "tgs_rmode"
#define TGS4_TOPIC_CHAT_COMMAND "tgs_chat_comm"
#define TGS4_TOPIC_EVENT "tgs_event"
#define TGS4_TOPIC_INTEROP_RESPONSE "tgs_interop"
#define TGS4_COMM_NEW_PORT "tgs_new_port"
#define TGS4_COMM_VALIDATE "tgs_validate"
#define TGS4_COMM_SERVER_PRIMED "tgs_prime"
#define TGS4_COMM_WORLD_REBOOT "tgs_reboot"
#define TGS4_COMM_END_PROCESS "tgs_kill"
#define TGS4_COMM_CHAT "tgs_chat_send"
#define TGS4_PARAMETER_COMMAND "tgs_com"
#define TGS4_PARAMETER_DATA "tgs_data"
#define TGS4_PORT_CRITFAIL_MESSAGE " Must exit to let watchdog reboot..."
#define EXPORT_TIMEOUT_DS 200
/datum/tgs_api/v4
var/access_identifier
var/instance_name
var/json_path
var/chat_channels_json_path
var/chat_commands_json_path
var/server_commands_json_path
var/reboot_mode = TGS_REBOOT_MODE_NORMAL
var/security_level
var/requesting_new_port = FALSE
var/list/intercepted_message_queue
var/list/custom_commands
var/list/cached_test_merges
var/datum/tgs_revision_information/cached_revision
var/datum/tgs_event_handler/event_handler
var/export_lock = FALSE
var/list/last_interop_response
/datum/tgs_api/v4/ApiVersion()
return "4.0.0.0"
/datum/tgs_api/v4/OnWorldNew(datum/tgs_event_handler/event_handler, minimum_required_security_level)
json_path = world.params[TGS4_PARAM_INFO_JSON]
if(!json_path)
TGS_ERROR_LOG("Missing [TGS4_PARAM_INFO_JSON] world parameter!")
return
var/json_file = file2text(json_path)
if(!json_file)
TGS_ERROR_LOG("Missing specified json file: [json_path]")
return
var/cached_json = json_decode(json_file)
if(!cached_json)
TGS_ERROR_LOG("Failed to decode info json: [json_file]")
return
access_identifier = cached_json["accessIdentifier"]
server_commands_json_path = cached_json["serverCommandsJson"]
if(cached_json["apiValidateOnly"])
TGS_INFO_LOG("Validating API and exiting...")
Export(TGS4_COMM_VALIDATE, list(TGS4_PARAMETER_DATA = "[minimum_required_security_level]"))
del(world)
security_level = cached_json["securityLevel"]
chat_channels_json_path = cached_json["chatChannelsJson"]
chat_commands_json_path = cached_json["chatCommandsJson"]
src.event_handler = event_handler
instance_name = cached_json["instanceName"]
ListCustomCommands()
var/list/revisionData = cached_json["revision"]
if(revisionData)
cached_revision = new
cached_revision.commit = revisionData["commitSha"]
cached_revision.origin_commit = revisionData["originCommitSha"]
cached_test_merges = list()
var/list/json = cached_json["testMerges"]
for(var/entry in json)
var/datum/tgs_revision_information/test_merge/tm = new
tm.time_merged = text2num(entry["timeMerged"])
var/list/revInfo = entry["revision"]
if(revInfo)
tm.commit = revInfo["commitSha"]
tm.origin_commit = revInfo["originCommitSha"]
tm.title = entry["titleAtMerge"]
tm.body = entry["bodyAtMerge"]
tm.url = entry["url"]
tm.author = entry["author"]
tm.number = entry["number"]
tm.pull_request_commit = entry["pullRequestRevision"]
tm.comment = entry["comment"]
cached_test_merges += tm
return TRUE
/datum/tgs_api/v4/OnInitializationComplete()
Export(TGS4_COMM_SERVER_PRIMED)
var/tgs4_secret_sleep_offline_sauce = 24051994
var/old_sleep_offline = world.sleep_offline
world.sleep_offline = tgs4_secret_sleep_offline_sauce
sleep(1)
if(world.sleep_offline == tgs4_secret_sleep_offline_sauce) //if not someone changed it
world.sleep_offline = old_sleep_offline
/datum/tgs_api/v4/OnTopic(T)
var/list/params = params2list(T)
var/their_sCK = params[TGS4_INTEROP_ACCESS_IDENTIFIER]
if(!their_sCK)
return FALSE //continue world/Topic
if(their_sCK != access_identifier)
return "Invalid comms key!";
var/command = params[TGS4_PARAMETER_COMMAND]
if(!command)
return "No command!"
. = TGS4_RESPONSE_SUCCESS
switch(command)
if(TGS4_TOPIC_CHAT_COMMAND)
var/result = HandleCustomCommand(params[TGS4_PARAMETER_DATA])
if(result == null)
result = "Error running chat command!"
return result
if(TGS4_TOPIC_EVENT)
intercepted_message_queue = list()
var/list/event_notification = json_decode(params[TGS4_PARAMETER_DATA])
var/list/event_parameters = event_notification["Parameters"]
var/list/event_call = list(event_notification["Type"])
if(event_parameters)
event_call += event_parameters
if(event_handler != null)
event_handler.HandleEvent(arglist(event_call))
. = json_encode(intercepted_message_queue)
intercepted_message_queue = null
return
if(TGS4_TOPIC_INTEROP_RESPONSE)
last_interop_response = json_decode(params[TGS4_PARAMETER_DATA])
return
if(TGS4_TOPIC_CHANGE_PORT)
var/new_port = text2num(params[TGS4_PARAMETER_DATA])
if (!(new_port > 0))
return "Invalid port: [new_port]"
//the topic still completes, miraculously
//I honestly didn't believe byond could do it
if(event_handler != null)
event_handler.HandleEvent(TGS_EVENT_PORT_SWAP, new_port)
if(!world.OpenPort(new_port))
return "Port change failed!"
return
if(TGS4_TOPIC_CHANGE_REBOOT_MODE)
var/new_reboot_mode = text2num(params[TGS4_PARAMETER_DATA])
if(event_handler != null)
event_handler.HandleEvent(TGS_EVENT_REBOOT_MODE_CHANGE, reboot_mode, new_reboot_mode)
reboot_mode = new_reboot_mode
return
return "Unknown command: [command]"
/datum/tgs_api/v4/proc/Export(command, list/data, override_requesting_new_port = FALSE)
if(!data)
data = list()
data[TGS4_PARAMETER_COMMAND] = command
var/json = json_encode(data)
while(requesting_new_port && !override_requesting_new_port)
sleep(1)
//we need some port open at this point to facilitate return communication
if(!world.port)
requesting_new_port = TRUE
if(!world.OpenPort(0)) //open any port
TGS_ERROR_LOG("Unable to open random port to retrieve new port![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
//request a new port
export_lock = FALSE
var/list/new_port_json = Export(TGS4_COMM_NEW_PORT, list(TGS4_PARAMETER_DATA = "[world.port]"), TRUE) //stringify this on purpose
if(!new_port_json)
TGS_ERROR_LOG("No new port response from server![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
var/new_port = new_port_json[TGS4_PARAMETER_DATA]
if(!isnum(new_port) || new_port <= 0)
TGS_ERROR_LOG("Malformed new port json ([json_encode(new_port_json)])![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
if(new_port != world.port && !world.OpenPort(new_port))
TGS_ERROR_LOG("Unable to open port [new_port]![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
requesting_new_port = FALSE
while(export_lock)
sleep(1)
export_lock = TRUE
last_interop_response = null
fdel(server_commands_json_path)
text2file(json, server_commands_json_path)
for(var/I = 0; I < EXPORT_TIMEOUT_DS && !last_interop_response; ++I)
sleep(1)
if(!last_interop_response)
TGS_ERROR_LOG("Failed to get export result for: [json]")
else
. = last_interop_response
export_lock = FALSE
/datum/tgs_api/v4/OnReboot()
var/list/result = Export(TGS4_COMM_WORLD_REBOOT)
if(!result)
return
//okay so the standard TGS4 proceedure is: right before rebooting change the port to whatever was sent to us in the above json's data parameter
var/port = result[TGS4_PARAMETER_DATA]
if(!isnum(port))
return //this is valid, server may just want use to reboot
if(port == 0)
//to byond 0 means any port and "none" means close vOv
port = "none"
if(!world.OpenPort(port))
TGS_ERROR_LOG("Unable to set port to [port]!")
/datum/tgs_api/v4/InstanceName()
return instance_name
/datum/tgs_api/v4/TestMerges()
return cached_test_merges
/datum/tgs_api/v4/EndProcess()
Export(TGS4_COMM_END_PROCESS)
/datum/tgs_api/v4/Revision()
return cached_revision
/datum/tgs_api/v4/ChatBroadcast(message, list/channels)
var/list/ids
if(length(channels))
ids = list()
for(var/I in channels)
var/datum/tgs_chat_channel/channel = I
ids += channel.id
message = list("message" = message, "channelIds" = ids)
if(intercepted_message_queue)
intercepted_message_queue += list(message)
else
Export(TGS4_COMM_CHAT, message)
/datum/tgs_api/v4/ChatTargetedBroadcast(message, admin_only)
var/list/channels = list()
for(var/I in ChatChannelInfo())
var/datum/tgs_chat_channel/channel = I
if (!channel.is_private_channel && ((channel.is_admin_channel && admin_only) || (!channel.is_admin_channel && !admin_only)))
channels += channel.id
message = list("message" = message, "channelIds" = channels)
if(intercepted_message_queue)
intercepted_message_queue += list(message)
else
Export(TGS4_COMM_CHAT, message)
/datum/tgs_api/v4/ChatPrivateMessage(message, datum/tgs_chat_user/user)
message = list("message" = message, "channelIds" = list(user.channel.id))
if(intercepted_message_queue)
intercepted_message_queue += list(message)
else
Export(TGS4_COMM_CHAT, message)
/datum/tgs_api/v4/ChatChannelInfo()
. = list()
//no caching cause tgs may change this
var/list/json = json_decode(file2text(chat_channels_json_path))
for(var/I in json)
. += DecodeChannel(I)
/datum/tgs_api/v4/proc/DecodeChannel(channel_json)
var/datum/tgs_chat_channel/channel = new
channel.id = channel_json["id"]
channel.friendly_name = channel_json["friendlyName"]
channel.connection_name = channel_json["connectionName"]
channel.is_admin_channel = channel_json["isAdminChannel"]
channel.is_private_channel = channel_json["isPrivateChannel"]
channel.custom_tag = channel_json["tag"]
return channel
/datum/tgs_api/v4/SecurityLevel()
return security_level
/*
The MIT License
Copyright (c) 2017 Jordan Brown
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+69
View File
@@ -0,0 +1,69 @@
/datum/tgs_api/v4/proc/ListCustomCommands()
var/results = list()
custom_commands = list()
for(var/I in typesof(/datum/tgs_chat_command) - /datum/tgs_chat_command)
var/datum/tgs_chat_command/stc = new I
var/command_name = stc.name
if(!command_name || findtext(command_name, " ") || findtext(command_name, "'") || findtext(command_name, "\""))
TGS_ERROR_LOG("Custom command [command_name] ([I]) can't be used as it is empty or contains illegal characters!")
continue
if(results[command_name])
var/datum/other = custom_commands[command_name]
TGS_ERROR_LOG("Custom commands [other.type] and [I] have the same name (\"[command_name]\"), only [other.type] will be available!")
continue
results += list(list("name" = command_name, "help_text" = stc.help_text, "admin_only" = stc.admin_only))
custom_commands[command_name] = stc
var/commands_file = chat_commands_json_path
if(!commands_file)
return
text2file(json_encode(results), commands_file)
/datum/tgs_api/v4/proc/HandleCustomCommand(command_json)
var/list/data = json_decode(command_json)
var/command = data["command"]
var/user = data["user"]
var/params = data["params"]
var/datum/tgs_chat_user/u = new
u.id = user["id"]
u.friendly_name = user["friendlyName"]
u.mention = user["mention"]
u.channel = DecodeChannel(user["channel"])
var/datum/tgs_chat_command/sc = custom_commands[command]
if(sc)
var/result = sc.Run(u, params)
if(result == null)
result = ""
return result
return "Unknown command: [command]!"
/*
The MIT License
Copyright (c) 2017 Jordan Brown
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+32
View File
@@ -399,3 +399,35 @@
/obj/item/vending_refill/wardrobe/viro_wardrobe
machine_name = "ViroDrobe"
/obj/machinery/vending/wardrobe/cap_wardrobe
name = "Captain's Wardrobe"
desc = "The latest and greatest in Nanotrasen fashion for your great leader."
icon_state = "capsdrobe"
icon_deny = "capsdrobe-deny"
product_ads = "Only the greatest for a commander such as ours."
req_access = list(ACCESS_CAPTAIN)
vend_reply = "A wonderful day to you, great leader."
products = list(/obj/item/clothing/suit/hooded/wintercoat/captain = 1,
/obj/item/storage/backpack/captain = 1,
/obj/item/storage/backpack/satchel/cap = 1,
/obj/item/storage/backpack/duffelbag/captain = 1,
/obj/item/clothing/neck/cloak/cap = 1,
/obj/item/clothing/shoes/sneakers/brown = 2,
/obj/item/clothing/under/rank/captain = 1,
/obj/item/clothing/under/rank/captain/skirt = 1,
/obj/item/clothing/head/caphat = 1,
/obj/item/clothing/head/caphat/parade = 1,
/obj/item/clothing/head/caphat/beret = 1,
/obj/item/clothing/head/caphat/beret/white = 1,
/obj/item/clothing/under/captainparade = 1,
/obj/item/clothing/suit/captunic = 1,
/obj/item/clothing/under/rank/captain/femformal = 1,
/obj/item/clothing/glasses/sunglasses/gar/supergar = 1,
/obj/item/clothing/gloves/color/captain = 1)
refill_canister = /obj/item/vending_refill/wardrobe/cap_wardrobe
/obj/item/vending_refill/wardrobe/cap_wardrobe
machine_name = "Captain's Wardrobe"
icon_state = "refill_caps"