Merge pull request #16560 from AffectedArc07/multi-instance-support

[READY] Multi instance support
This commit is contained in:
Fox McCloud
2021-10-20 15:25:26 -04:00
committed by GitHub
29 changed files with 534 additions and 48 deletions
+6
View File
@@ -27,6 +27,12 @@
if(A && (A.rights & R_ADMIN))
admin = 1
// Lets see if they are logged in on another paradise server
if(SSdbcore.IsConnected())
var/other_server_login = SSinstancing.check_player(ckey)
if(other_server_login)
return list("reason"="duplicate login", "desc"="\nReason: You are already logged in on server '[other_server_login]'. Please contact the server host if you believe this is an error.")
//Guest Checking
if(GLOB.configuration.general.guest_ban && IsGuestKey(key))
log_adminwarn("Failed Login: [key] [computer_id] [address] - Guests not allowed")
+3 -1
View File
@@ -45,6 +45,7 @@ GLOBAL_LIST_INIT(admin_verbs_admin, list(
/datum/admins/proc/toggleemoji, /*toggles using emoji in ooc for everyone*/
/client/proc/game_panel, /*game panel, allows to change game-mode etc*/
/client/proc/cmd_admin_say, /*admin-only ooc chat*/
/client/proc/gsay, /*cross-server asay*/
/datum/admins/proc/PlayerNotes,
/client/proc/cmd_mentor_say,
/datum/admins/proc/show_player_notes,
@@ -67,7 +68,8 @@ GLOBAL_LIST_INIT(admin_verbs_admin, list(
/client/proc/toggle_mentor_chat,
/client/proc/toggle_advanced_interaction, /*toggle admin ability to interact with not only machines, but also atoms such as buttons and doors*/
/client/proc/list_ssds_afks,
/client/proc/ccbdb_lookup_ckey
/client/proc/ccbdb_lookup_ckey,
/client/proc/view_instances
))
GLOBAL_LIST_INIT(admin_verbs_ban, list(
/client/proc/ban_panel,
+4 -3
View File
@@ -146,8 +146,8 @@
qdel(adm_query)
var/datum/db_query/query_insert = SSdbcore.NewQuery({"
INSERT INTO ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`,`ban_round_id`,`unbanned_round_id`)
VALUES (null, Now(), :serverip, :bantype_str, :reason, :job, :duration, :rounds, Now() + INTERVAL :duration MINUTE, :ckey, :computerid, :ip, :a_ckey, :a_computerid, :a_ip, :who, :adminwho, '', null, null, null, null, null, :roundid, null)
INSERT INTO ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`,`ban_round_id`,`unbanned_round_id`, `server_id`)
VALUES (null, Now(), :serverip, :bantype_str, :reason, :job, :duration, :rounds, Now() + INTERVAL :duration MINUTE, :ckey, :computerid, :ip, :a_ckey, :a_computerid, :a_ip, :who, :adminwho, '', null, null, null, null, null, :roundid, null, :server_id)
"}, list(
// Get ready for parameters
"serverip" = serverip,
@@ -164,7 +164,8 @@
"a_ip" = a_ip,
"who" = who,
"adminwho" = adminwho,
"roundid" = GLOB.round_id
"roundid" = GLOB.round_id,
"server_id" = GLOB.configuration.system.instance_id
))
if(!query_insert.warn_execute())
qdel(query_insert)
+2 -7
View File
@@ -1,5 +1,4 @@
// Do not attemtp to remove the blank string from the server arg. It will break DB saving.
/proc/add_note(target_ckey, notetext, timestamp, adminckey, logged = 1, server = "", checkrights = 1, show_after = TRUE, automated = FALSE)
/proc/add_note(target_ckey, notetext, timestamp, adminckey, logged = 1, checkrights = 1, show_after = TRUE, automated = FALSE)
if(checkrights && !check_rights(R_ADMIN|R_MOD))
return
if(!SSdbcore.IsConnected())
@@ -53,10 +52,6 @@
else if(usr && (usr.ckey == ckey(adminckey))) // Don't ckeyize special note sources
adminckey = ckey(adminckey)
if(!server)
if(GLOB.configuration.general.server_name)
server = GLOB.configuration.general.server_name
// Force cast this to 1/0 incase someone tries to feed bad data
automated = !!automated
@@ -67,7 +62,7 @@
"targetckey" = target_ckey,
"notetext" = notetext,
"adminkey" = adminckey,
"server" = server,
"server" = GLOB.configuration.system.instance_id,
"crewnum" = crew_number,
"roundid" = GLOB.round_id,
"automated" = automated
+27
View File
@@ -0,0 +1,27 @@
// GSAY
// Like asay but global between instances!
// *Insert changeling hivemind :g joke here*
/client/proc/gsay(msg as text)
set name = "gsay"
set hidden = TRUE
if(!check_rights(R_ADMIN))
return
if(!msg)
return
msg = sanitize(copytext(msg, 1, MAX_MESSAGE_LEN))
// To whoever says "Why dont you just topic the full message with formatting"
// This lets us use this in other apps, like a discord bot, without HTML parsing
// It also removes a way to put whatever HTML we want in the chat window
var/built_topic = "gsay&msg=[url_encode(msg)]&usr=[url_encode(usr.ckey)]&src=[url_encode(GLOB.configuration.system.instance_id)]"
// Send to peers
SSinstancing.topic_all_peers(built_topic)
// Send to online admins
for(var/client/C in GLOB.admins)
if(R_ADMIN & C.holder.rights)
to_chat(C, "<span class='admin_channel'>GSAY: [usr.ckey]@[GLOB.configuration.system.instance_id]: [msg]</span>")
SSblackbox.record_feedback("tally", "admin_verb", 1, "gsay") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
@@ -0,0 +1,33 @@
/client/proc/view_instances()
set name = "View Server Instances"
set desc = "View the running server instances"
set category = "Server"
if(!check_rights(R_ADMIN))
return
to_chat(usr, "<b>Server instances info</b>")
var/datum/db_query/dbq1 = SSdbcore.NewQuery({"
SELECT server_id, key_name, key_value FROM instance_data_cache WHERE server_id IN
(SELECT server_id FROM instance_data_cache WHERE
key_name='heartbeat' AND last_updated BETWEEN NOW() - INTERVAL 60 SECOND AND NOW())
AND key_name IN ("playercount")"})
if(!dbq1.warn_execute())
qdel(dbq1)
return
var/servers_outer = list()
while(dbq1.NextRow())
if(!servers_outer[dbq1.item[1]])
servers_outer[dbq1.item[1]] = list()
servers_outer[dbq1.item[1]][dbq1.item[2]] = dbq1.item[3] // This should assoc load our data
qdel(dbq1)
for(var/server in servers_outer)
var/server_data = servers_outer[server]
var/players = text2num(server_data["playercount"])
to_chat(usr, "<code>[server]</code> - [players] player[players == 1 ? "" : "s"] online.")
to_chat(usr, "<i>Offline instances are not reported</i>")
+5
View File
@@ -327,12 +327,16 @@
if(length(related_accounts_cid))
log_admin("[key_name(src)] Alts by CID: [jointext(related_accounts_cid, " ")]")
// This sleeps so it has to go here. Dont fucking move it.
SSinstancing.update_playercache(ckey)
// This has to go here to avoid issues
// If you sleep past this point, you will get SSinput errors as well as goonchat errors
// DO NOT STUFF RANDOM SQL QUERIES BELOW THIS POINT WITHOUT USING `INVOKE_ASYNC()` OR SIMILAR
// YOU WILL BREAK STUFF. SERIOUSLY. -aa07
GLOB.clients += src
spawn() // Goonchat does some non-instant checks in start()
chatOutput.start()
@@ -448,6 +452,7 @@
GLOB.admins -= src
GLOB.directory -= ckey
GLOB.clients -= src
SSinstancing.update_playercache() // Clear us out
QDEL_NULL(chatOutput)
QDEL_NULL(pai_save)
if(movingmob)
+4 -3
View File
@@ -16,15 +16,16 @@
return
var/datum/db_query/log_query = SSdbcore.NewQuery({"
INSERT INTO karma (spendername, spenderkey, receivername, receiverkey, receiverrole, receiverspecial, spenderip, time)
VALUES (:sname, :skey, :rname, :rkey, :rrole, :rspecial, :sip, Now())"}, list(
INSERT INTO karma (spendername, spenderkey, receivername, receiverkey, receiverrole, receiverspecial, spenderip, time, server_id)
VALUES (:sname, :skey, :rname, :rkey, :rrole, :rspecial, :sip, Now(), :server_id)"}, list(
"sname" = spender.name,
"skey" = spender.ckey,
"rname" = receiver.name,
"rkey" = receiver.ckey,
"rrole" = receiverrole,
"rspecial" = receiverspecial,
"sip" = spender.client.address
"sip" = spender.client.address,
"server_id" = GLOB.configuration.system.instance_id
))
if(!log_query.warn_execute())
+18
View File
@@ -0,0 +1,18 @@
// Just dumps the text in the admin chat box
/datum/world_topic_handler/gsay
topic_key = "gsay"
requires_commskey = TRUE
/datum/world_topic_handler/gsay/execute(list/input, key_valid)
if(!input["msg"] || !input["usr"] || !input["src"])
return json_encode(list("error" = "Malformed request"))
var/message = input["msg"]
var/user = input["usr"]
var/source = input["src"]
// Send to online admins
for(var/client/C in GLOB.admins)
if(R_ADMIN & C.holder.rights)
to_chat(C, "<span class='admin_channel'>GSAY: [user]@[source]: [message]</span>")
@@ -0,0 +1,8 @@
/datum/world_topic_handler/instance_announce
topic_key = "instance_announce"
requires_commskey = TRUE
/datum/world_topic_handler/instance_announce/execute(list/input, key_valid)
var/msg = input["msg"]
to_chat(world, "<center><span class='boldannounce'><big>Attention</big></span></center><hr>[msg]<hr>")
SEND_SOUND(world, sound('sound/misc/notice2.ogg')) // Same as captains priority announce