Skip to content

Commit 341b103

Browse files
committed
temporary mentor load from DB
1 parent 41fcce8 commit 341b103

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

code/controllers/configuration/entries/monkestation.dm

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
/datum/config_entry/string/issue_slug
3636
protection = CONFIG_ENTRY_LOCKED
3737

38+
/datum/config_entry/flag/mentor_legacy_system
39+
3840
/datum/config_entry/flag/looc_enabled
3941

4042
/datum/config_entry/flag/log_storyteller

monkestation/code/modules/mentor/mentor_datum.dm

+22
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ GLOBAL_PROTECT(mentor_href_token)
6262
return "mentor_token=[RawMentorHrefToken(forceGlobal)]"
6363

6464
/proc/load_mentors()
65+
var/dbfail
66+
if(!CONFIG_GET(flag/admin_legacy_system) && !SSdbcore.Connect())
67+
message_admins("Failed to connect to database while loading mentors. Loading from backup.")
68+
log_sql("Failed to connect to database while loading mentors. Loading from backup.")
69+
dbfail = 1
6570
GLOB.mentor_datums.Cut()
6671
for(var/client/mentor_clients in GLOB.mentors)
6772
mentor_clients.remove_mentor_verbs()
@@ -74,3 +79,20 @@ GLOBAL_PROTECT(mentor_href_token)
7479
if(findtextEx(line, "#", 1, 2))
7580
continue
7681
new /datum/mentors(line)
82+
83+
if(!CONFIG_GET(flag/mentor_legacy_system) || dbfail)
84+
var/datum/db_query/query_load_mentors = SSdbcore.NewQuery("SELECT ckey, rank FROM [format_table_name("mentor")]")
85+
if(!query_load_mentors.Execute())
86+
message_admins("Error loading mentors from database. Loading from backup.")
87+
log_sql("Error loading mentors from database. Loading from backup.")
88+
dbfail = 1
89+
else
90+
while(query_load_mentors.NextRow())
91+
var/mentor_ckey = ckey(query_load_mentors.item[1])
92+
var/skip
93+
94+
if(GLOB.mentor_datums[mentor_ckey])
95+
skip = 1
96+
if(!skip)
97+
new /datum/mentors(mentor_ckey)
98+
qdel(query_load_mentors)

0 commit comments

Comments
 (0)