[MIRROR] Add support for auto admin when ran in single user mode (#5762)

* Add support for auto admin when ran in single user mode

* Update client_procs.dm

* fixes compile issues, also adds in some legacy mentor code
This commit is contained in:
CitadelStationBot
2018-03-04 13:06:42 -06:00
committed by Poojawa
parent 0b07e1772a
commit d3905c723f
4 changed files with 84 additions and 46 deletions

View File

@@ -120,6 +120,15 @@
/datum/config_entry/flag/admin_legacy_system //Defines whether the server uses the legacy admin system with admins.txt or the SQL system
protection = CONFIG_ENTRY_LOCKED
/datum/config_entry/flag/protect_legacy_admins //Stops any admins loaded by the legacy system from having their rank edited by the permissions panel
protection = CONFIG_ENTRY_LOCKED
/datum/config_entry/flag/protect_legacy_ranks //Stops any ranks loaded by the legacy system from having their flags edited by the permissions panel
protection = CONFIG_ENTRY_LOCKED
/datum/config_entry/flag/enable_localhost_rank //Gives the !localhost! rank to any client connecting from 127.0.0.1 or ::1
protection = CONFIG_ENTRY_LOCKED
/datum/config_entry/string/hostedby
/datum/config_entry/flag/norespawn
@@ -385,4 +394,4 @@
min_val = 0
/datum/config_entry/string/default_view
config_entry_value = "15x15"
config_entry_value = "15x15"

View File

@@ -22,8 +22,6 @@
if(!CheckAdminHref(href, href_list))
return
citaTopic(href, href_list) // Citadel
if(href_list["ahelp"])
if(!check_rights(R_ADMIN, TRUE))
return
@@ -273,6 +271,50 @@
return
create_message("note", banckey, null, banreason, null, null, 0, 0)
else if(href_list["mentor"])
if(!check_rights(R_ADMIN)) return
var/mob/M = locate(href_list["mentor"])
if(!ismob(M))
to_chat(usr, "<span class='danger'>this can be only used on instances of type /mob!</span>")
return
if(!M.client)
to_chat(usr, "<span class='danger'>No client.</span>")
return
log_admin("[key_name(usr)] has granted [key_name(M)] mentor access")
message_admins("<span class='adminnotice'> [key_name_admin(usr)] has granted [key_name_admin(M)] mentor access.</span>")
var/datum/DBQuery/query_add_mentors = SSdbcore.NewQuery("INSERT INTO [format_table_name("mentor")] (ckey) VALUES ('[M.client.ckey]')")
if(!query_add_mentors.Execute())
var/err = query_add_mentors.ErrorMsg()
log_game("SQL ERROR during adding new mentor. Error : \[[err]\]\n")
load_mentors()
M.verbs += /client/proc/cmd_mentor_say
M.verbs += /client/proc/show_mentor_memo
to_chat(M, "<span class='adminnotice'> You've been granted mentor access! Help people who send mentor-pms.</span>")
else if(href_list["removementor"])
if(!check_rights(R_ADMIN)) return
var/mob/living/carbon/human/M = locate(href_list["removementor"])
if(!ismob(M))
usr << "this can be only used on instances of type /mob"
return
log_admin("[key_name(usr)] has removed mentor access from [key_name(M)]")
message_admins("<span class='adminnotice'> [key_name_admin(usr)] has removed mentor access from [key_name_admin(M)].</span>")
var/datum/DBQuery/query_remove_mentors = SSdbcore.NewQuery("DELETE FROM [format_table_name("mentor")] WHERE ckey = '[M.client.ckey]'")
if(!query_remove_mentors.Execute())
var/err = query_remove_mentors.ErrorMsg()
log_game("SQL ERROR during removing mentor. Error : \[[err]\]\n")
load_mentors()
to_chat(M, "<span class='adminnotice'>Your mentor access has been revoked.</span>")
M.verbs -= /client/proc/cmd_mentor_say
M.verbs -= /client/proc/show_mentor_memo
else if(href_list["editrights"])
edit_rights_topic(href_list)

View File

@@ -6,7 +6,7 @@
GLOBAL_LIST_INIT(blacklisted_builds, list(
"1407" = "bug preventing client display overrides from working leads to clients being able to see things/mobs they shouldn't be able to see",
"1408" = "bug preventing client display overrides from working leads to clients being able to see things/mobs they shouldn't be able to see",
))
#define LIMITER_SIZE 5
@@ -88,6 +88,15 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
cmd_admin_pm(href_list["priv_msg"],null)
return
// Mentor PM
if(href_list["mentor_msg"])
if(CONFIG_GET(flag.mentors_mobname_only))
var/mob/M = locate(href_list["mentor_msg"])
cmd_mentor_pm(M,null)
else
cmd_mentor_pm(href_list["mentor_msg"],null)
return
switch(href_list["_src_"])
if("holder")
hsrc = holder
@@ -164,12 +173,14 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
GLOB.ahelp_tickets.ClientLogin(src)
var/connecting_admin = FALSE //because de-admined admins connecting should be treated like admins.
//Admin Authorisation
var/localhost_addresses = list("127.0.0.1", "::1")
if(address && (address in localhost_addresses))
var/datum/admin_rank/localhost_rank = new("!localhost!", 65535)
if(localhost_rank)
var/datum/admins/localhost_holder = new(localhost_rank, ckey)
localhost_holder.associate(src)
holder = GLOB.admin_datums[ckey]
if(holder)
GLOB.admins |= src
holder.owner = src
connecting_admin = TRUE
else if(GLOB.deadmins[ckey])
verbs += /client/proc/readmin
connecting_admin = TRUE
if(CONFIG_GET(flag/autoadmin))
if(!GLOB.admin_datums[ckey])
var/datum/admin_rank/autorank
@@ -180,19 +191,12 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
if(!autorank)
to_chat(world, "Autoadmin rank not found")
else
var/datum/admins/D = new(autorank, ckey)
GLOB.admin_datums[ckey] = D
holder = GLOB.admin_datums[ckey]
if(holder)
GLOB.admins |= src
holder.owner = src
connecting_admin = TRUE
else if(GLOB.deadmins[ckey])
verbs += /client/proc/readmin
connecting_admin = TRUE
mentor_datum_set()// Citadel mentor_holder setting
new /datum/admins(autorank, ckey)
if(CONFIG_GET(flag/enable_localhost_rank) && !connecting_admin)
var/localhost_addresses = list("127.0.0.1", "::1")
if(isnull(address) || (address in localhost_addresses))
var/datum/admin_rank/localhost_rank = new("!localhost!", 65535, 16384, 65535) //+EVERYTHING -DBRANKS *EVERYTHING
new /datum/admins(localhost_rank, ckey, 1, 1)
//preferences datum - also holds some persistent data for the client (because we may as well keep these datums to a minimum)
prefs = GLOB.preferences_datums[ckey]
if(!prefs)
@@ -242,7 +246,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
to_chat(src, "<span class='danger'>Please download a new version of byond. if [byond_build] is the latest, you can go to http://www.byond.com/download/build/ to download other versions.</span>")
if(connecting_admin)
to_chat(src, "As an admin, you are being allowed to continue using this version, but please consider changing byond versions")
else
else
qdel(src)
return
#endif
@@ -405,21 +409,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
"Someone come hold me :(",\
"I need someone on me :(",\
"What happened? Where has everyone gone?",\
"Forever alone :(",\
"My nipples are so stiff, but Zelda ain't here. :(",\
"Leon senpai, play more Spessmans. :(",\
"If only Serdy were here...",\
"Panic bunker can't keep my love for you out.",\
"Cebu needs to Awoo herself back into my heart.",\
"I don't even have a Turry to snuggle viciously here.",\
"MOM, WHERE ARE YOU??? D:",\
"It's a beautiful day outside. Birds are singing, flowers are blooming. On days like this...kids like you...SHOULD BE BURNING IN HELL.",\
"Sometimes when I have sex, I think about putting an entire peanut butter and jelly sandwich in the VCR.",\
"Oh good, no-one around to watch me lick Goofball's nipples. :D",\
"I've replaced Beepsky with a fidget spinner, glory be autism abuse.",\
"i shure hop dere are no PRED arund!!!!",\
"NO PRED CAN eVER CATCH MI",\
"help, the clown is honking his horn in front of dorms and its interrupting everyones erp"\
"Forever alone :("\
)
send2irc("Server", "[cheesy_message] (No admins online)")
@@ -726,12 +716,6 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
if (isnull(new_size))
CRASH("change_view called without argument.")
//CIT CHANGES START HERE - makes change_view change DEFAULT_VIEW to 15x15 depending on preferences
if(prefs && CONFIG_GET(string/default_view))
if(!prefs.widescreenpref && new_size == CONFIG_GET(string/default_view))
new_size = "15x15"
//END OF CIT CHANGES
view = new_size
apply_clickcatcher()
if (isliving(mob))
@@ -750,4 +734,4 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
/client/proc/AnnouncePR(announcement)
if(prefs && prefs.chat_toggles & CHAT_PULLR)
to_chat(src, announcement)
to_chat(src, announcement)

View File

@@ -46,6 +46,9 @@ MENTOR_LEGACY_SYSTEM
## Comment this out if you want to use the SQL based banning system. The legacy systems use the files in the data folder. You need to set up your database to use the SQL based system.
BAN_LEGACY_SYSTEM
## Comment this out to stop locally connected clients from being given the almost full access !localhost! admin rank
ENABLE_LOCALHOST_RANK
## Uncomment this entry to have certain jobs require your account to be at least a certain number of days old to select. You can configure the exact age requirement for different jobs by editing
## the minimal_player_age variable in the files in folder /code/game/jobs/job/.. for the job you want to edit. Set minimal_player_age to 0 to disable age requirement for that job.
## REQUIRES the database set up to work. Keep it hashed if you don't have a database set up.