Skip to content

Commit

Permalink
Plexora (#2655)
Browse files Browse the repository at this point in the history
* feat: [DNM] first SSplexora commit

* fix: add "monkestation edit" comments

* fix: dont include prefix for slash command

* Update monkestation/code/controllers/subsystem/plexora.dm

Co-authored-by: Lucy <lucy@absolucy.moe>

* Update monkestation/code/controllers/subsystem/plexora.dm

Co-authored-by: Lucy <lucy@absolucy.moe>

* fix: make sure they are facing us!

* fix: no sanitization for plexora

* fix: disable by default

* wipfeat: twitch events, jailing

* feat: serverrestart

* more thingys

* feat: more things i dont want to explain

* feat: basic who, and notes

* shimmy shimmy aye shimmy hey i need to sleep

* yippe

* fix: mentor honk for external

* commiting some shit

* fix: linter complaining

* ah yes i see.

* mentor fixy

* feat: add interview things, fix things

* weh

* fix: name tagging

* meow

* fix for tming alongside 516

* Fix interview runtime

* disable SSplexora during CI, disable firing if init fails

* add SSplexora.Recover()

* hopefully fix this shit

* Some code cleanup

* Update stage1.dm

* lets get this bread

* oops last minute

---------

Co-authored-by: Lucy <lucy@absolucy.moe>
Co-authored-by: dwasint <82520990+dwasint@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent 006f66f commit 1fff894
Show file tree
Hide file tree
Showing 30 changed files with 1,286 additions and 77 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/chat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define MESSAGE_TYPE_ATTACKLOG "attacklog"
#define MESSAGE_TYPE_DEBUG "debug"

#define EXTERNALREPLYCOUNT 2 // monkestation edit
/// Max length of chat message in characters
#define CHAT_MESSAGE_MAX_LENGTH 110

Expand Down
4 changes: 3 additions & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
#define INIT_ORDER_VIS 80
#define INIT_ORDER_SECURITY_LEVEL 79 // We need to load before events so that it has a security level to choose from.
#define INIT_ORDER_DISCORD 78
#define INIT_ORDER_ACHIEVEMENTS 77
#define INIT_ORDER_PLEXORA 77 // monkestation addition
#define INIT_ORDER_ACHIEVEMENTS 76 // monkestation edit: 77 -> 76 for plexora
#define INIT_ORDER_STATION 74 //This is high priority because it manipulates a lot of the subsystems that will initialize after it.
#define INIT_ORDER_QUIRKS 73
#define INIT_ORDER_REAGENTS 72 //HAS to be before mapping and assets - both create objects, which creates reagents, which relies on lists made in this subsystem
Expand Down Expand Up @@ -227,6 +228,7 @@
#define FIRE_PRIORITY_ACID 40
#define FIRE_PRIORITY_BURNING 40
#define FIRE_PRIORITY_DEFAULT 50
#define FIRE_PRIORITY_PLEXORA 60 // monkestation addition: plexora
#define FIRE_PRIORITY_PARALLAX 65
#define FIRE_PRIORITY_INSTRUMENTS 80
#define FIRE_PRIORITY_STAMINA 95
Expand Down
8 changes: 8 additions & 0 deletions code/__DEFINES/~monkestation/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
#define POLICY_DEATH "Death"
#define POLICY_REVIVAL "Revival"
#define POLICY_REVIVAL_CLONER "Revival via Cloning"

#define AHELP_CLOSETYPE_CLOSE 0
#define AHELP_CLOSETYPE_REJECT 1
#define AHELP_CLOSETYPE_RESOLVE 2

#define AHELP_CLOSEREASON_NONE 0
#define AHELP_CLOSEREASON_IC 1
#define AHELP_CLOSEREASON_MENTOR 2
7 changes: 7 additions & 0 deletions code/__DEFINES/~monkestation/helpers.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// Until a condition is true, sleep, or until a certain amount of time has passed.
/// Basically, UNTIL() but with a timeout.
#define UNTIL_OR_TIMEOUT(Condition, Timeout) \
do { \
var/__end_time = REALTIMEOFDAY + (Timeout); \
UNTIL((Condition) || (REALTIMEOFDAY > __end_time)); \
} while(0)
2 changes: 2 additions & 0 deletions code/__HELPERS/roundend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ GLOBAL_LIST_INIT(round_end_images, world.file2list("data/image_urls.txt")) // MO
send2chat(new /datum/tgs_message_content("[GLOB.round_id ? "Round [GLOB.round_id]" : "The round has"] just ended."), CONFIG_GET(string/channel_announce_end_game))
send2adminchat("Server", "Round just ended.")


if(length(CONFIG_GET(keyed_list/cross_server)))
send_news_report()

Expand Down Expand Up @@ -303,6 +304,7 @@ GLOBAL_LIST_INIT(round_end_images, world.file2list("data/image_urls.txt")) // MO
ready_for_reboot = TRUE
var/datum/discord_embed/embed = format_roundend_embed("<@&999008528595419278>")
send2roundend_webhook(embed)
SSplexora.roundended()
// monkestation end
standard_reboot()

Expand Down
59 changes: 48 additions & 11 deletions code/controllers/failsafe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,72 @@ GLOBAL_REAL(Failsafe, /datum/controller/failsafe)
if(processing_interval > 0)
if(Master.processing && Master.iteration)
if (defcon > 1 && (!Master.stack_end_detector || !Master.stack_end_detector.check()))

to_chat(GLOB.admins, span_boldannounce("ERROR: The Master Controller code stack has exited unexpectedly, Restarting..."))
// Monkestation edit: start - plexora
var/msg = "ERROR: The Master Controller code stack has exited unexpectedly, Restarting..."
to_chat(GLOB.admins, span_boldannounce(msg))
SSplexora.mc_alert(msg, defcon)
// Monkestation edit: end
defcon = 0
var/rtn = Recreate_MC()
if(rtn > 0)
master_iteration = 0
to_chat(GLOB.admins, span_adminnotice("MC restarted successfully"))
// Monkestation edit: start - plexora
msg = "MC restarted successfully"
to_chat(GLOB.admins, span_adminnotice(msg))
SSplexora.mc_alert(msg, defcon)
// Monkestation edit: end
else if(rtn < 0)
log_game("FailSafe: Could not restart MC, runtime encountered. Entering defcon 0")
to_chat(GLOB.admins, span_boldannounce("ERROR: DEFCON [defcon_pretty()]. Could not restart MC, runtime encountered. I will silently keep retrying."))
// Monkestation edit: start - plexora
msg = "ERROR: DEFCON [defcon_pretty()]. Could not restart MC, runtime encountered. I will silently keep retrying."
to_chat(GLOB.admins, span_boldannounce(msg))
SSplexora.mc_alert(msg, defcon)
// Monkestation edit: end
// Check if processing is done yet.
if(Master.iteration == master_iteration)
switch(defcon)
if(4,5)
--defcon

if(3)
message_admins(span_adminnotice("Notice: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5-defcon) * processing_interval] ticks."))
// Monkestation edit: start - plexora
var/msg = "Notice: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5-defcon) * processing_interval] ticks."
message_admins(span_adminnotice(msg))
SSplexora.mc_alert(msg)
// Monkestation edit: end
--defcon

if(2)
to_chat(GLOB.admins, span_boldannounce("Warning: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5-defcon) * processing_interval] ticks. Automatic restart in [processing_interval] ticks."))
// Monkestation edit: start - plexora
var/msg = "Warning: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5-defcon) * processing_interval] ticks. Automatic restart in [processing_interval] ticks."
to_chat(GLOB.admins, span_boldannounce(msg))
SSplexora.mc_alert(msg)
// Monkestation edit: end
--defcon

if(1)
to_chat(GLOB.admins, span_boldannounce("Warning: DEFCON [defcon_pretty()]. The Master Controller has still not fired within the last [(5-defcon) * processing_interval] ticks. Killing and restarting..."))
// Monkestation edit: start - plexora
var/msg = "Warning: DEFCON [defcon_pretty()]. The Master Controller has still not fired within the last [(5-defcon) * processing_interval] ticks. Killing and restarting..."
to_chat(GLOB.admins, span_boldannounce(msg))
SSplexora.mc_alert(msg, defcon)
// Monkestation edit: end
--defcon
var/rtn = Recreate_MC()
if(rtn > 0)
defcon = 4
master_iteration = 0
to_chat(GLOB.admins, span_adminnotice("MC restarted successfully"))
// Monkestation edit: start - plexora
msg = "MC restarted successfully"
to_chat(GLOB.admins, span_adminnotice(msg))
SSplexora.mc_alert(msg, defcon)
// Monkestation edit: end
else if(rtn < 0)
log_game("FailSafe: Could not restart MC, runtime encountered. Entering defcon 0")
to_chat(GLOB.admins, span_boldannounce("ERROR: DEFCON [defcon_pretty()]. Could not restart MC, runtime encountered. I will silently keep retrying."))
// Monkestation edit: start - plexora
msg = "ERROR: DEFCON [defcon_pretty()]. Could not restart MC, runtime encountered. I will silently keep retrying."
to_chat(GLOB.admins, span_boldannounce(msg))
SSplexora.mc_alert(msg, defcon)
// Monkestation edit: end
//if the return number was 0, it just means the mc was restarted too recently, and it just needs some time before we try again
//no need to handle that specially when defcon 0 can handle it

Expand All @@ -111,7 +142,11 @@ GLOBAL_REAL(Failsafe, /datum/controller/failsafe)
if(rtn > 0)
defcon = 4
master_iteration = 0
to_chat(GLOB.admins, span_adminnotice("MC restarted successfully"))
// Monkestation edit: start - plexora
var/msg = "MC restarted successfully"
to_chat(GLOB.admins, span_adminnotice(msg))
SSplexora.mc_alert(msg, defcon)
// Monkestation edit: end
else
defcon = min(defcon + 1,5)
master_iteration = Master.iteration
Expand Down Expand Up @@ -156,7 +191,9 @@ GLOBAL_REAL(Failsafe, /datum/controller/failsafe)
if (. == 1) //We were able to create a new master
SSticker.Recover(); //Recover the ticket system so the Masters runlevel gets set
Master.Initialize(10, FALSE, FALSE) //Need to manually start the MC, normally world.new would do this
to_chat(GLOB.admins, span_adminnotice("MC successfully recreated after recovering all subsystems!"))
var/msg = "MC successfully recreated after recovering all subsystems!"
to_chat(GLOB.admins, span_adminnotice(msg))
SSplexora.mc_alert(msg, Failsafe.defcon)
else
message_admins(span_boldannounce("Failed to create new MC!"))

Expand Down
9 changes: 7 additions & 2 deletions code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ GLOBAL_REAL(Master, /datum/controller/master)
// because who knows how long we took for initializations, and whatever.
SSticker.SetTimeLeft(CONFIG_GET(number/lobby_countdown) * 10) // monkestation edit

SSplexora.serverinitdone(time) // Monkestation edit - plexora

if(world.system_type == MS_WINDOWS && CONFIG_GET(flag/toast_notification_on_init) && !length(GLOB.clients))
world.shelleo("start /min powershell -ExecutionPolicy Bypass -File tools/initToast/initToast.ps1 -name \"[world.name]\" -icon %CD%\\icons\\ui_icons\\common\\tg_16.png -port [world.port]")
Expand Down Expand Up @@ -390,8 +391,12 @@ GLOBAL_REAL(Master, /datum/controller/master)
if (rtn >= MC_LOOP_RTN_GRACEFUL_EXIT || processing < 0)
return //this was suppose to happen.
//loop ended, restart the mc
log_game("MC crashed or runtimed, restarting")
message_admins("MC crashed or runtimed, restarting")
// Monkestation edit: start - plexora
var/msg = "MC crashed or runtimed, restarting"
log_game(msg)
message_admins(msg)
SSplexora.mc_alert(msg)
// Monkestation edit: end
var/rtn2 = Recreate_MC()
if (rtn2 <= 0)
log_game("Failed to recreate MC (Error code: [rtn2]), it's up to the failsafe now")
Expand Down
5 changes: 5 additions & 0 deletions code/datums/http.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

var/_raw_response

/datum/http_request/New(...)
. = ..()
if(length(args))
src.prepare(arglist(args))

/datum/http_request/proc/prepare(method, url, body = "", list/headers, output_file)
if (!length(headers))
headers = ""
Expand Down
16 changes: 13 additions & 3 deletions code/datums/world_topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
if (input["format"] == "json")
. = list("error" = .)
else
. = Run(input)
// Monkestation edit start
if (input["json"])
. = Run(input + json_decode(input["json"]))
else
. = Run(input)
// Monkestation edit end
if (input["format"] == "json")
. = json_encode(.)
else if(islist(.))
Expand Down Expand Up @@ -234,8 +239,13 @@
.["bunkered"] = CONFIG_GET(flag/panic_bunker) || FALSE
.["interviews"] = CONFIG_GET(flag/panic_bunker_interview) || FALSE
if(SSshuttle?.emergency)
.["shuttle_mode"] = SSshuttle.emergency.mode
// monkestation start: move comments, add emergency reason
// Shuttle status, see /__DEFINES/stat.dm
.["shuttle_timer"] = SSshuttle.emergency.timeLeft()
.["shuttle_mode"] = SSshuttle.emergency.mode
// Shuttle timer, in seconds
.["shuttle_timer"] = SSshuttle.emergency.timeLeft()
// Shuttle reason
.["shuttle_emergency_reason"] = SSticker.emergency_reason
// monkestation end


1 change: 1 addition & 0 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ GLOBAL_VAR(tracy_log)
log_admin("[key_name(usr)] Has requested an immediate world restart via client side debugging tools")
message_admins("[key_name_admin(usr)] Has requested an immediate world restart via client side debugging tools")
to_chat(world, span_boldannounce("Rebooting World immediately due to host request."))
SSplexora.Shutdown(TRUE, usr ? key_name(usr) : null) // Monkestation edit: plexora
else
to_chat(world, span_boldannounce("Rebooting world..."))
Master.Shutdown() //run SS shutdowns
Expand Down
21 changes: 21 additions & 0 deletions code/modules/admin/sql_ban_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,27 @@
var/msg = "has created a [isnull(duration) ? "permanent" : "temporary [time_message]"] [applies_to_admins ? "admin " : ""][is_server_ban ? "server ban" : "role ban from [roles_to_ban.len] roles"] for [target]."
log_admin_private("[kn] [msg][is_server_ban ? "" : " Roles: [roles_to_ban.Join(", ")]"] Reason: [reason]")
message_admins("[kna] [msg][is_server_ban ? "" : " Roles: [roles_to_ban.Join("\n")]"]\nReason: [reason]")
// MONKESTATION EDIT: START - Plexora
// Mock player just in case they disconnect and we lose their preferences
var/datum/client_interface/mock_player = new(player_key)
mock_player.prefs = new /datum/preferences(mock_player)

var/list/plexora_ban = list(
"ckey" = player_ckey,
"roles" = roles_to_ban,
"expiration_time" = duration,
"expiration_interval" = interval,
"reason" = reason,
"admin_ckey" = admin_ckey,
"admin_key_name" = key_name(usr),
"round_id" = GLOB.round_id,
"round_timer" = ROUND_TIME(),
"world_time" = world.time,
)

plexora_ban["total_playtime"] = mock_player.get_exp_living()
SSplexora.new_ban(plexora_ban)
// MONKESTATION EDIT: END
if(applies_to_admins)
send2adminchat("BAN ALERT","[kn] [msg]")
if(player_ckey)
Expand Down
21 changes: 21 additions & 0 deletions code/modules/admin/sql_message_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,27 @@
log_admin_private(pm)
message_admins("[header]:<br>[text]")
admin_ticket_log(target_ckey, "<font color='blue'>[header]</font><br>[text]")
// Monkestation edit start - plexora
var/datum/client_interface/mock_player = new(target_ckey)
mock_player.prefs = new /datum/preferences(mock_player)

var/list/plexora_note = list(
"ckey" = target_ckey,
"type" = type,
"text" = text,
"secret" = secret,
"expiration_time" = expiry || null,
"note_severity" = note_severity,
"admin_ckey" = admin_ckey,
"admin_key_name" = key_name(usr),
"round_id" = GLOB.round_id,
"round_timer" = ROUND_TIME(),
"world_time" = world.time,
)

plexora_note["total_playtime"] = mock_player.get_exp_living()
SSplexora.new_note(plexora_note)
// Monkestation edit end
if(browse)
browse_messages("[type]")
else
Expand Down
32 changes: 28 additions & 4 deletions code/modules/admin/verbs/adminhelp.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// monkestation start
#define CHECK_AHELP_ACTIVE\
if(state != AHELP_ACTIVE) { \
return;\
};
// monkestation end

/// Client var used for returning the ahelp verb
/client/var/adminhelptimerid = 0
/// Client var used for tracking the ticket the (usually) not-admin client is dealing with
Expand Down Expand Up @@ -119,6 +126,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
C.current_ticket.initiator = C
C.current_ticket.AddInteraction("Client reconnected.")
SSblackbox.LogAhelp(C.current_ticket.id, "Reconnected", "Client reconnected", C.ckey)
SSplexora.aticket_connection(C.current_ticket, FALSE) // monkestation edit: PLEXORA

//Dissasociate ticket
/datum/admin_help_tickets/proc/ClientLogout(client/C)
Expand All @@ -128,6 +136,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
//Gotta async this cause clients only logout on destroy, and sleeping in destroy is disgusting
INVOKE_ASYNC(SSblackbox, TYPE_PROC_REF(/datum/controller/subsystem/blackbox, LogAhelp), T.id, "Disconnected", "Client disconnected", C.ckey)
T.initiator = null
SSplexora.aticket_connection(C.current_ticket) // monkestation edit: PLEXORA

//Get a ticket given a ckey
/datum/admin_help_tickets/proc/CKey2ActiveTicket(ckey)
Expand Down Expand Up @@ -239,7 +248,9 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
if(is_bwoink)
AddInteraction("<font color='blue'>[key_name_admin(usr)] PM'd [LinkedReplyName()]</font>", player_message = "<font color='blue'>[key_name_admin(usr, include_name = FALSE)] PM'd [LinkedReplyName()]</font>")
message_admins("<font color='blue'>Ticket [TicketHref("#[id]")] created</font>")
SSplexora.aticket_new(src, msg_raw, is_bwoink, urgent, usr.ckey) // monkestation edit: PLEXORA
else
SSplexora.aticket_new(src, msg_raw, is_bwoink, urgent) // monkestation edit: PLEXORA
MessageNoRecipient(msg_raw, urgent)
send_message_to_tgs(msg, urgent)
GLOB.ahelp_tickets.active_tickets += src
Expand Down Expand Up @@ -463,6 +474,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
log_admin_private(msg)
SSblackbox.LogAhelp(id, "Reopened", "Reopened by [usr.key]", usr.ckey)
SSblackbox.record_feedback("tally", "ahelp_stats", 1, "reopened")
SSplexora.aticket_reopened(src, usr.ckey) // monkestation edit: PLEXORA
TicketPanel() //can only be done from here, so refresh it

//private
Expand Down Expand Up @@ -504,6 +516,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)

AddInteraction("<font color='green'>Resolved by [key_name].</font>", player_message = "<font color='green'>Ticket resolved!</font>")
to_chat(initiator, span_adminhelp("Your ticket has been resolved by an admin. The Adminhelp verb will be returned to you shortly."), confidential = TRUE)

if(!silent)
SSblackbox.record_feedback("tally", "ahelp_stats", 1, "resolved")
var/msg = "Ticket [TicketHref("#[id]")] resolved by [key_name]"
Expand Down Expand Up @@ -531,6 +544,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
log_admin_private(msg)
AddInteraction("Rejected by [key_name].", player_message = "Ticket rejected!")
SSblackbox.LogAhelp(id, "Rejected", "Rejected by [usr.key]", null, usr.ckey)

Close(silent = TRUE)

//Resolve ticket with IC Issue message
Expand Down Expand Up @@ -630,18 +644,27 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
TicketPanel()
if("retitle")
Retitle()
if("reject")
Reject()
if("reply")
usr.client.cmd_ahelp_reply(initiator)
if("reopen")
CHECK_AHELP_ACTIVE
Reopen()
if("reject")
CHECK_AHELP_ACTIVE
SSplexora.aticket_closed(src, usr.ckey, AHELP_CLOSETYPE_REJECT)
Reject()
if("icissue")
CHECK_AHELP_ACTIVE
SSplexora.aticket_closed(src, usr.ckey, AHELP_CLOSETYPE_RESOLVE, AHELP_CLOSEREASON_IC)
ICIssue()
if("close")
CHECK_AHELP_ACTIVE
SSplexora.aticket_closed(src, usr.ckey, AHELP_CLOSETYPE_CLOSE)
Close()
if("resolve")
CHECK_AHELP_ACTIVE
SSplexora.aticket_closed(src, usr.ckey, AHELP_CLOSETYPE_RESOLVE)
Resolve()
if("reopen")
Reopen()

/datum/admin_help/proc/player_ticket_panel()
var/list/dat = list("<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><title>Player Ticket</title></head>")
Expand Down Expand Up @@ -1133,3 +1156,4 @@ GLOBAL_DATUM_INIT(admin_help_ui_handler, /datum/admin_help_ui_handler, new)
#undef WEBHOOK_URGENT
#undef WEBHOOK_NONE
#undef WEBHOOK_NON_URGENT
#undef CHECK_AHELP_ACTIVE
Loading

0 comments on commit 1fff894

Please sign in to comment.