Skip to content

Commit

Permalink
Merge branch 'master' into OverdoseChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinMan4455 authored Nov 11, 2024
2 parents 8029c1f + c8c7585 commit 4b3cfca
Show file tree
Hide file tree
Showing 27 changed files with 233 additions and 57 deletions.
6 changes: 6 additions & 0 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ The default value assumes youtube-dl is in your system PATH
/datum/config_entry/string/invoke_youtubedl
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN

/datum/config_entry/string/cobalt_base_api
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN


/datum/config_entry/string/cobalt_api_key
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN

/datum/config_entry/number/error_cooldown // The "cooldown" time for each occurrence of a unique error
config_entry_value = 600
Expand Down
6 changes: 6 additions & 0 deletions code/datums/ammo/bullet/rifle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@
to_chat(living_mob, SPAN_HIGHDANGER("The impact knocks you off-balance!"))
living_mob.apply_stamina_damage(fired_projectile.ammo.damage, fired_projectile.def_zone, ARMOR_BULLET)

/datum/ammo/bullet/rifle/heavy/iff/set_bullet_traits()
. = ..()
LAZYADD(traits_to_give, list(
BULLET_TRAIT_ENTRY(/datum/element/bullet_trait_iff)
))

//====== 10x31 Type 71

/datum/ammo/bullet/rifle/heavy/upp
Expand Down
112 changes: 112 additions & 0 deletions code/datums/internet_media.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* Generic implementation to get a URL that can be sent to
* clients to play audio via [/datum/tgui_panel/proc/play_music], from a provided URL
*/
/datum/internet_media
/**
* If we have encountered an error while attempting to retrieve the URL
*/
var/error

/**
* Handles a request for an audio file, from a provided media URL
* Must return a [/datum/media_response], which must have at least the [/datum/media_response/var/url] filled out
*
* If we are not returning a media_response, set the [/datum/internet_media/var/error] to be an error
*/
/datum/internet_media/proc/get_media(url)
RETURN_TYPE(/datum/media_response)

CRASH("[type] does not override [nameof(__PROC__)].")

/datum/internet_media/yt_dlp

/datum/internet_media/yt_dlp/get_media(url)
var/ytdl = CONFIG_GET(string/invoke_youtubedl)
if(!ytdl)
error = "Youtube-dl FAILED: Not configured"
return

if(findtext(url, ":") && !findtext(url, GLOB.is_http_protocol))
error = "Youtube-dl FAILED: Non-http(s) URIs are not allowed. For youtube-dl shortcuts like ytsearch: please use the appropriate full url from the website."
return

var/list/output = world.shelleo("[ytdl] --geo-bypass --format \"bestaudio\[ext=mp3]/best\[ext=mp4]\[height<=360]/bestaudio\[ext=m4a]/bestaudio\[ext=aac]\" --dump-single-json --no-playlist -- \"[shell_url_scrub(url)]\"")
var/errorlevel = output[SHELLEO_ERRORLEVEL]
var/stdout = output[SHELLEO_STDOUT]
var/stderr = output[SHELLEO_STDERR]

if(errorlevel)
error = "Youtube-dl URL retrieval FAILED: [stderr]"
return

var/data

try
data = json_decode(stdout)
catch(var/exception/decode_error)
error = "Youtube-dl JSON parsing FAILED: [decode_error]: [stdout]"
return

return new /datum/media_response(data["url"], data["title"], data["start_time"], data["end_time"])

/datum/internet_media/cobalt

/datum/internet_media/cobalt/get_media(url)
var/cobalt = CONFIG_GET(string/cobalt_base_api)
if(!cobalt)
error = "cobalt.tools FAILED: Not configured"
return

var/list/headers = list()
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"

var/auth_key = CONFIG_GET(string/cobalt_api_key)
if(auth_key)
headers["Authorization"] = "Api-Key [auth_key]"

var/datum/http_request/request = new
request.prepare(RUSTG_HTTP_METHOD_POST, cobalt, json_encode(list(
"url" = url,
"downloadMode" = "audio"
)), headers)

request.execute_blocking()

var/datum/http_response/response_raw = request.into_response()

if(response_raw.errored)
error = "cobalt.tools web request FAILED: [response_raw.error]"
return

var/list/response
try
response = json_decode(response_raw.body)
catch(var/exception/decode_error)
error = "cobalt.tools JSON parsing FAILED: [decode_error]: [response_raw.body]"
return

if(!(response["status"] in list("redirect", "tunnel")))
error = "cobalt.tools request FAILED - invalid response: [response_raw.body]"
return

return new /datum/media_response(response["url"])

/datum/media_response
var/url
var/title
var/start_time
var/end_time

/datum/media_response/New(url, title, start_time, end_time)
if(isnull(url))
CRASH("/datum/media_response created without a URL field.")

src.url = url
src.title = title
src.start_time = start_time
src.end_time = end_time

/datum/media_response/proc/get_list()
return list("url" = url, "title" = title, "start_time" = start_time, "end_time" = end_time)
8 changes: 4 additions & 4 deletions code/game/jobs/job/marine/squads.dm
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,10 @@
id.access.Remove(squad_one_access, squad_two_access)

for(var/obj/item/device/radio/headset/cycled_headset in H)
if(!("Platoon Sergeant" in cycled_headset.tracking_options))
if(!("Section Sergeant" in cycled_headset.tracking_options))
continue

cycled_headset.locate_setting = cycled_headset.tracking_options["Platoon Sergeant"]
cycled_headset.locate_setting = cycled_headset.tracking_options["Section Sergeant"]

/datum/squad/proc/assign_ft_leader(fireteam, mob/living/carbon/human/H, upd_ui = TRUE)
if(fireteam_leaders[fireteam])
Expand All @@ -843,10 +843,10 @@
to_chat(H, FONT_SIZE_HUGE(SPAN_BLUE("You were assigned as [fireteam] Team Leader.")))

for(var/obj/item/device/radio/headset/cycled_headset in H)
if(!("Platoon Sergeant" in cycled_headset.tracking_options))
if(!("Section Sergeant" in cycled_headset.tracking_options))
continue

cycled_headset.locate_setting = cycled_headset.tracking_options["Platoon Sergeant"]
cycled_headset.locate_setting = cycled_headset.tracking_options["Section Sergeant"]

/datum/squad/proc/unassign_ft_leader(fireteam, clear_group_id, upd_ui = TRUE)
if(!fireteam_leaders[fireteam])
Expand Down
10 changes: 10 additions & 0 deletions code/game/machinery/doors/airlock_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@
icon = 'icons/obj/structures/doors/securedoor.dmi'
req_access = list(ACCESS_MARINE_COMMAND)

/obj/structure/machinery/door/airlock/almayer/secure/glass
name = "\improper Secure Airlock"
icon = 'icons/obj/structures/doors/securedoor_glass.dmi'

/obj/structure/machinery/door/airlock/almayer/secure/colony
req_access = null
req_one_access = list(ACCESS_CIVILIAN_PUBLIC)
Expand Down Expand Up @@ -495,6 +499,12 @@
req_access = list()
req_one_access = list(ACCESS_MARINE_MEDBAY, ACCESS_MARINE_COMMAND)

/obj/structure/machinery/door/airlock/almayer/medical/plain
name = "\improper Airlock"
icon = 'icons/obj/structures/doors/medidoor_plain.dmi'
req_access = null
req_one_access = list(ACCESS_CIVILIAN_MEDBAY, ACCESS_CIVILIAN_RESEARCH, ACCESS_CIVILIAN_COMMAND, ACCESS_CIVILIAN_PUBLIC)

/obj/structure/machinery/door/airlock/almayer/medical/colony
req_access = null
req_one_access = list(ACCESS_CIVILIAN_MEDBAY, ACCESS_CIVILIAN_RESEARCH, ACCESS_CIVILIAN_COMMAND, ACCESS_CIVILIAN_PUBLIC)
Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/devices/radio/headset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

var/list/inbuilt_tracking_options = list(
"Platoon Commander" = TRACKER_PLTCO,
"Platoon Sergeant" = TRACKER_SL,
"Section Sergeant" = TRACKER_SL,
"Squad Sergeant" = TRACKER_FTL,
"Landing Zone" = TRACKER_LZ
)
Expand Down Expand Up @@ -410,8 +410,8 @@
/obj/item/device/radio/headset/almayer/equipped(mob/living/carbon/human/user, slot)
. = ..()

if((user == user.assigned_squad?.fireteam_leaders["SQ1"] || user == user.assigned_squad?.fireteam_leaders["SQ2"]) && ("Platoon Sergeant" in tracking_options))
locate_setting = tracking_options["Platoon Sergeant"]
if((user == user.assigned_squad?.fireteam_leaders["SQ1"] || user == user.assigned_squad?.fireteam_leaders["SQ2"]) && ("Section Sergeant" in tracking_options))
locate_setting = tracking_options["Section Sergeant"]
return

if(((user in user.assigned_squad?.fireteams["SQ1"]) || (user in user.assigned_squad?.fireteams["SQ2"])) && ("Squad Sergeant" in tracking_options))
Expand Down Expand Up @@ -614,7 +614,7 @@

inbuilt_tracking_options = list(
"Platoon Commander" = TRACKER_PLTCO,
"Platoon Sergeant" = TRACKER_ASL,
"Section Sergeant" = TRACKER_ASL,
"Landing Zone" = TRACKER_LZ
)

Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/items/storage/firstaid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
/obj/item/tool/surgery/scalpel,
/obj/item/tool/surgery/hemostat,
/obj/item/tool/surgery/retractor,
/obj/item/tool/surgery/FixOVein,
/obj/item/tool/surgery/surgical_line,
/obj/item/tool/surgery/synthgraft,
)

/obj/item/storage/surgical_case/regular
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/tools/flame_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
////////////
/obj/item/clothing/mask/cigarette/weed
name = "weed joint"
desc = "A rolled-up package of ambrosia vulgaris, aka space weed, in some smooth paper; you sure this is legal dude?"
desc = "A rolled-up package of marijuana, aka weed, in some smooth paper."
chem_volume = 39
smoketime = 20 MINUTES

Expand Down
15 changes: 13 additions & 2 deletions code/game/objects/structures/fence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
if(Proj.ammo.damage_type == HALLOSS || Proj.damage <= 0 || ammo_flags == AMMO_ENERGY)
return 0

health -= Proj.damage * 0.3
health -= Proj.damage * 0.02
..()
healthcheck()
return 1
Expand All @@ -62,7 +62,7 @@
tforce = 40
else if(isobj(AM))
var/obj/item/I = AM
tforce = I.throwforce
tforce = I.throwforce/10 //Adjust higher if needed to stop knife-throwing bampots
health = max(0, health - tforce)
healthcheck()

Expand Down Expand Up @@ -172,6 +172,17 @@
SPAN_NOTICE("You cut through [src] with [W]."))
cut_grille()
return

if(istype(W, /obj/item/attachable/bayonet) && get_dist(src, user) < 2)
user.visible_message(SPAN_NOTICE("[user] starts cutting through [src] with [W]."),
SPAN_NOTICE("You start cutting through [src] with [W]."))
playsound(src.loc, 'sound/items/Wirecutter.ogg', 25, 1)
if(do_after(user, 210 * user.get_skill_duration_multiplier(SKILL_CONSTRUCTION), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD))
playsound(loc, 'sound/items/Wirecutter.ogg', 25, 1)
user.visible_message(SPAN_NOTICE("[user] cuts through [src] with [W]."),
SPAN_NOTICE("You cut through [src] with [W]."))
cut_grille()
return
else
switch(W.damtype)
if("fire")
Expand Down
48 changes: 27 additions & 21 deletions code/modules/admin/verbs/playsound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,38 @@
var/announce_title = TRUE

if(sound_mode == "Web")
var/ytdl = CONFIG_GET(string/invoke_youtubedl)
if(!ytdl)
to_chat(src, SPAN_BOLDWARNING("Youtube-dl was not configured, action unavailable"), confidential = TRUE) //Check config.txt for the INVOKE_YOUTUBEDL value
var/list/datum/internet_media/media_players = list()

if(CONFIG_GET(string/invoke_youtubedl))
media_players += new /datum/internet_media/yt_dlp

if(CONFIG_GET(string/cobalt_base_api))
media_players += new /datum/internet_media/cobalt

if(!length(media_players))
to_chat(src, SPAN_BOLDWARNING("Your server host has not set up any web media players."))
return

web_sound_input = input("Enter content URL (supported sites only)", "Play Internet Sound via youtube-dl") as text|null
web_sound_input = input("Enter content URL (supported sites only)", "Play Internet Sound") as text|null
if(!istext(web_sound_input) || !length(web_sound_input))
return

web_sound_input = trim(web_sound_input)

if(findtext(web_sound_input, ":") && !findtext(web_sound_input, GLOB.is_http_protocol))
to_chat(src, SPAN_WARNING("Non-http(s) URIs are not allowed."))
to_chat(src, SPAN_WARNING("For youtube-dl shortcuts like ytsearch: please use the appropriate full url from the website."))
return
var/datum/media_response/response
for(var/datum/internet_media/player as anything in media_players)
response = player.get_media(web_sound_input)

var/list/output = world.shelleo("[ytdl] --geo-bypass --format \"bestaudio\[ext=mp3]/best\[ext=mp4]\[height<=360]/bestaudio\[ext=m4a]/bestaudio\[ext=aac]\" --dump-single-json --no-playlist -- \"[shell_url_scrub(web_sound_input)]\"")
var/errorlevel = output[SHELLEO_ERRORLEVEL]
var/stdout = output[SHELLEO_STDOUT]
var/stderr = output[SHELLEO_STDERR]
if(istype(response))
break

if(errorlevel)
to_chat(src, SPAN_WARNING("Youtube-dl URL retrieval FAILED: [stderr]"))
if(!istype(response))
to_chat(src, SPAN_BOLDWARNING("All configured web media players failed to provide a valid response:"))
for(var/datum/internet_media/player as anything in media_players)
to_chat(src, SPAN_WARNING("[player.type] error: [player.error]"))
return

try
data = json_decode(stdout)
catch(var/exception/e)
to_chat(src, SPAN_WARNING("Youtube-dl JSON parsing FAILED: [e]: [stdout]"))
return
data = response.get_list()

else if(sound_mode == "Upload")
var/current_transport = CONFIG_GET(string/asset_transport)
Expand Down Expand Up @@ -80,17 +82,21 @@
var/list/music_extra_data = list()
if(data["url"])
music_extra_data["link"] = data["url"]
music_extra_data["title"] = data["title"]
web_sound_url = data["url"]
title = data["title"]
music_extra_data["start"] = data["start_time"]
music_extra_data["end"] = data["end_time"]

if(isnull(data["title"]))
data["title"] = tgui_input_text(src, "What is the title of this media?", "Media Title")
title = data["title"]
music_extra_data["title"] = data["title"]

if(!must_send_assets && web_sound_url && !findtext(web_sound_url, GLOB.is_http_protocol))
to_chat(src, SPAN_BOLDWARNING("BLOCKED: Content URL not using http(s) protocol"), confidential = TRUE)
to_chat(src, SPAN_WARNING("The media provider returned a content URL that isn't using the HTTP or HTTPS protocol"), confidential = TRUE)
return


switch(tgui_alert(src, "Show the name of this sound to the players?", "Sound Name", list("Yes","No","Cancel")))
if("No")
music_extra_data["title"] = "Admin sound"
Expand Down
4 changes: 2 additions & 2 deletions code/modules/client/preferences_gear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@ GLOBAL_LIST_EMPTY(gear_datums_by_name)
cost = 4

/datum/gear/smoking/weed_joint
display_name = "Joint of space weed"
display_name = "Joint of weed"
path = /obj/item/clothing/mask/cigarette/weed
cost = 4
cost = 1

/datum/gear/smoking/lighter
display_name = "Lighter, cheap"
Expand Down
Loading

0 comments on commit 4b3cfca

Please sign in to comment.