Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__DEFINES/chat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define MESSAGE_TYPE_ATTACKLOG "attacklog"
#define MESSAGE_TYPE_DEBUG "debug"
#define MESSAGE_TYPE_SUBTLE "subtle" // DARKPACK EDIT ADD - SUBTLE
#define MESSAGE_TYPE_MENTOR "mentor" // DARKPACK EDIT ADD - MENTORS

/// Max length of chat message in characters
#define CHAT_MESSAGE_MAX_LENGTH 110
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
#define LOG_CATEGORY_GAME_VOTE "game-vote"
#define LOG_CATEGORY_GAME_WHISPER "game-whisper"
#define LOG_CATEGORY_GAME_GHOST_POLLS "game-ghost-polls"
#define LOG_CATEGORY_GAME_MENTOR "game-mentor" // DARKPACK EDIT ADD - Mentors

// HREF categories
#define LOG_CATEGORY_HREF "href"
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/span.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
#define span_memo(str) ("<span class='memo'>" + str + "</span>")
#define span_memoedit(str) ("<span class='memoedit'>" + str + "</span>")
#define span_policy(str) ("<span class='policy'>" + str + "</span>")
#define span_mentor(str) ("<span class ='mentor'>" + str + "</span>") // DARKPACK EDIT ADD - MENTOR
#define span_mentornotice(str) ("<span class = 'mentornotice'>" + str + "</span>") // DARKPACK EDIT ADD - MENTOR
#define span_message(str) ("<span class='message'>" + str + "</span>")
#define span_mind_control(str) ("<span class='mind_control'>" + str + "</span>")
#define span_minorannounce(str) ("<span class='minorannounce'>" + str + "</span>")
Expand Down
2 changes: 1 addition & 1 deletion code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ GLOBAL_VAR(restart_counter)
SetupLogs()

load_admins(initial = TRUE)

load_mentors(initial = TRUE) // DARKPACK EDIT ADD - Mentors
load_poll_data()

// Initialize RETA system - code/modules/reta/reta_system.dm
Expand Down
5 changes: 5 additions & 0 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ GLOBAL_LIST_INIT(unrecommended_builds, list(
if(!usr || usr != mob) //stops us calling Topic for somebody else's client. Also helps prevent usr=null
return

// DARKPACK EDIT ADD BEGIN - MENTOR
if(mentor_client_procs(href_list))
return
// DARKPACK EDIT ADD END

#ifndef TESTING
if (LOWER_TEXT(hsrc_command) == "_debug") //disable the integrated byond vv in the client side debugging tools since it doesn't respect vv read protections
return
Expand Down
7 changes: 7 additions & 0 deletions config/admin_ranks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ Name = Coder
Include = DEBUG VAREDIT SERVER SPAWN POLL
Exclude = AUTOADMIN
Edit =

// DARKPACK EDIT ADD START - Mentors
Name = Mentor
Include =
Exclude = AUTOADMIN
Edit =
// DARKPACK EDIT ADD END - Mentors
8 changes: 8 additions & 0 deletions config/darkpack_config.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Defines whether or not mentors can see ckeys alongside mobnames.
## uncomment to hide ckeys from mentors
#MENTORS_MOBNAME_ONLY

## Defines whether the server uses the legacy mentor system with mentors.txt or the SQL system.
## uncomment to use mentors.txt instead of SQL
#MENTOR_LEGACY_SYSTEM

## Uncomment to use Requiem jump windup
#JUMP_WINDUP
## Comment to remove Apocrypha post-jump slowdown
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// Defines whether or not mentors can see ckeys alongside mobnames.
/datum/config_entry/flag/mentors_mobname_only

/// Defines whether the server uses the legacy mentor system with mentors.txt or the SQL system.
/datum/config_entry/flag/mentor_legacy_system
protection = CONFIG_ENTRY_LOCKED
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/datum/preference/toggle/admin
abstract_type = /datum/preference/toggle/admin

/datum/preference/toggle/admin/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE

return is_admin(preferences.parent)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/datum/preference/toggle/admin/auto_dementor
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "auto_dementor_pref"
savefile_identifier = PREFERENCE_PLAYER
default_value = FALSE // We want people to not automatically dementor by default, otherwise they just don't know about the fact they're mentors.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/datum/log_category/game_mentor
category = LOG_CATEGORY_GAME_MENTOR
master_category = /datum/log_category/game

3 changes: 3 additions & 0 deletions modular_darkpack/modules/mentor/code/_globalvars.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//all clients whom are mentors
GLOBAL_LIST_EMPTY(mentors)
GLOBAL_PROTECT(mentors)
43 changes: 43 additions & 0 deletions modular_darkpack/modules/mentor/code/client_procs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/client/New()
. = ..()
mentor_datum_set()

/client/Destroy()
if(GLOB.mentors[src])
GLOB.mentors -= src

return ..()
Comment on lines +1 to +9
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

techincily should be master files.


/client/proc/mentor_client_procs(href_list)
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 TRUE

/client/proc/mentor_datum_set()
mentor_datum = GLOB.mentor_datums[ckey]
if(!mentor_datum && is_admin(src)) // admin with no mentor datum? let's fix that
new /datum/mentors(ckey)

if(mentor_datum)
mentor_datum.owner = src
GLOB.mentors[src] = TRUE
add_mentor_verbs()

if(check_rights_for(src, R_ADMIN) && prefs.read_preference(/datum/preference/toggle/admin/auto_dementor))
cmd_mentor_dementor()


/**
* Returns whether or not the user is qualified as a mentor.
*
* Arguments:
* * admin_bypass - Whether or not admins can succeed this check, even if they
* do not actually possess the role. Defaults to `TRUE`.
*/
/client/proc/is_mentor(admin_bypass = TRUE)
if(mentor_datum || (admin_bypass && check_rights_for(src, R_ADMIN)))
return TRUE
22 changes: 22 additions & 0 deletions modular_darkpack/modules/mentor/code/dementor.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/client/proc/cmd_mentor_dementor()
set category = "Mentor"
set name = "dementor"
if(!is_mentor())
return
remove_mentor_verbs()
GLOB.mentors -= src
to_chat(src, span_interface("You are no longer a mentor."))
log_mentor("MENTOR: [src] dementored.")
add_verb(src,/client/proc/cmd_mentor_rementor)

/client/proc/cmd_mentor_rementor()
set category = "Mentor"
set name = "rementor"
if(!is_mentor())
return
add_mentor_verbs()
GLOB.mentors[src] = TRUE
to_chat(src, span_interface("You are now a mentor."))
log_mentor("MENTOR: [src] rementored.")
remove_verb(src,/client/proc/cmd_mentor_rementor)

15 changes: 15 additions & 0 deletions modular_darkpack/modules/mentor/code/logging.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
GLOBAL_LIST_EMPTY(mentorlog)
GLOBAL_PROTECT(mentorlog)

/proc/log_mentor(text, list/data)
GLOB.mentorlog.Add(text)
logger.Log(LOG_CATEGORY_GAME_MENTOR, text, data)

/datum/admins/proc/MentorLogSecret()
var/dat = "<B>Mentor Log<HR></B>"
for(var/l in GLOB.mentorlog)
dat += "<li>[l]</li>"

if(!GLOB.mentorlog.len)
dat += "No mentors have done anything this round!"
usr << browse(dat, "window=mentor_log")
123 changes: 123 additions & 0 deletions modular_darkpack/modules/mentor/code/mentor.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
GLOBAL_LIST_EMPTY(mentor_datums)
GLOBAL_PROTECT(mentor_datums)

GLOBAL_VAR_INIT(mentor_href_token, GenerateToken())
GLOBAL_PROTECT(mentor_href_token)

/datum/mentors
var/name = "someone's mentor datum"
var/client/owner // the actual mentor, client type
var/target // the mentor's ckey
var/href_token // href token for mentor commands, uses the same token used by admins.

/datum/mentors/New(ckey)
if(!ckey)
QDEL_IN(src, 0)
CRASH("Mentor datum created without a ckey")
target = ckey(ckey)
name = "[ckey]'s mentor datum"
href_token = GenerateToken()
GLOB.mentor_datums[target] = src
//set the owner var and load commands
owner = GLOB.directory[ckey]
if(owner)
owner.mentor_datum = src
owner.add_mentor_verbs()
if(!check_rights_for(owner, R_ADMIN,0)) // don't add admins to mentor list.
GLOB.mentors[owner] = TRUE

/datum/mentors/proc/remove_mentor()
if(owner)
owner.remove_mentor_verbs()
GLOB.mentors -= owner
owner.mentor_datum = null
owner = null
log_admin_private("[target] was removed from the rank of mentor.")
GLOB.mentor_datums -= target
qdel(src)

/datum/mentors/proc/CheckMentorHREF(href, href_list)
var/auth = href_list["mentor_token"]
. = auth && (auth == href_token || auth == GLOB.mentor_href_token)
if(.)
return
var/msg = !auth ? "no" : "a bad"
message_admins("[key_name_admin(usr)] clicked an href with [msg] authorization key!")
if(CONFIG_GET(flag/debug_admin_hrefs))
message_admins("Debug mode enabled, call not blocked. Please ask your coders to review this round's logs.")
log_world("UAH: [href]")
return TRUE
log_admin_private("[key_name(usr)] clicked an href with [msg] authorization key! [href]")

/proc/RawMentorHrefToken(forceGlobal = FALSE)
var/tok = GLOB.mentor_href_token
if(!forceGlobal && usr)
var/client/C = usr.client
to_chat(world, C)
to_chat(world, usr)
if(!C)
CRASH("No client for HrefToken()!")
var/datum/mentors/holder = C.mentor_datum
if(holder)
tok = holder.href_token
return tok

/proc/MentorHrefToken(forceGlobal = FALSE)
return "mentor_token=[RawMentorHrefToken(forceGlobal)]"

/proc/load_mentors(no_update, initial = FALSE)
if(!initial)
if(!global.config.PreConfigReload())
return

var/dbfail
if(!CONFIG_GET(flag/mentor_legacy_system) && !SSdbcore.Connect())
message_admins("Failed to connect to database while loading mentors. Loading from backup.")
log_sql("Failed to connect to database while loading mentors. Loading from backup.")
dbfail = TRUE

GLOB.mentor_datums.Cut()
for(var/client/C in GLOB.mentors)
C.remove_mentor_verbs()
C.mentor_datum = null
GLOB.mentors.Cut()

if(CONFIG_GET(flag/mentor_legacy_system))
var/list/lines = world.file2list("config/mentors.txt")
for(var/line in lines)
if(!length(line))
continue
if(findtextEx(line, "#", 1, 2))
continue
new /datum/mentors(line)
return

if(!dbfail)
var/datum/db_query/query_load_mentors = SSdbcore.NewQuery("SELECT ckey FROM [format_table_name("mentor")]")
if(!query_load_mentors.warn_execute())
message_admins("Error loading mentors from database. Loading from backup.")
log_sql("Error loading mentors from database. Loading from backup.")
dbfail = TRUE
else
while(query_load_mentors.NextRow())
var/mentor_ckey = ckey(query_load_mentors.item[1])
new /datum/mentors(mentor_ckey)
QDEL_NULL(query_load_mentors)

if(dbfail)
var/backup_file = file2text("data/mentors_backup.json")
if(backup_file == null)
log_world("Unable to locate mentors backup file.")
return
var/list/backup_file_json = json_decode(backup_file)
for(var/backup_mentor_ckey in backup_file_json["mentors"])
if(GLOB.mentor_datums[ckey(backup_mentor_ckey)])
continue
new /datum/mentors(ckey(backup_mentor_ckey))

return dbfail


/client
/// Acts the same way holder does towards admin: it holds the mentor datum. if set, the guy's a mentor.
var/datum/mentors/mentor_datum
12 changes: 12 additions & 0 deletions modular_darkpack/modules/mentor/code/mentor_verbs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
GLOBAL_LIST_INIT(mentor_verbs, list(
/client/proc/cmd_mentor_say,
/client/proc/cmd_mentor_dementor
))
GLOBAL_PROTECT(mentor_verbs)

/client/proc/add_mentor_verbs()
if(mentor_datum)
add_verb(src, GLOB.mentor_verbs)

/client/proc/remove_mentor_verbs()
remove_verb(src, GLOB.mentor_verbs)
Loading
Loading