-
Notifications
You must be signed in to change notification settings - Fork 71
tfn upstream - Mentors #970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chazzyjazzy
wants to merge
6
commits into
DarkPack13:master
Choose a base branch
from
chazzyjazzy:fishingyea
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
67d3d15
Mentors (#106)
buffyuwu 7cefd77
ok now remove tfn stuiff
chazzyjazzy 7d7ec45
modularization o ' toole
chazzyjazzy 520d655
modularizebob modularizepants
chazzyjazzy 42c2654
Apply suggestions from code review
chazzyjazzy aa06954
Merge branch 'master' into fishingyea
chazzyjazzy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...r_darkpack/master_files/code/controllers/configuration/entries/darkpack_config_entries.dm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
8 changes: 8 additions & 0 deletions
8
modular_darkpack/master_files/code/modules/client/preferences/_admin.dm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
5 changes: 5 additions & 0 deletions
5
modular_darkpack/master_files/code/modules/client/preferences/auto_dementor.dm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
4 changes: 4 additions & 0 deletions
4
modular_darkpack/master_files/code/modules/logging/categories/log_categories_game.dm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ..() | ||
|
|
||
| /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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.