diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index cf1613dcd2..ee557da241 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -89,6 +89,7 @@ var/metroid_delay = 0 var/animal_delay = 0 + var/admin_legacy_system = 0 //Defines whether the server uses the legacy admin system with admins.txt or the SQL system. /datum/configuration/New() var/list/L = typesof(/datum/game_mode) - /datum/game_mode @@ -145,6 +146,9 @@ if(type == "config") switch (name) + if ("admin_legacy_system") + config.admin_legacy_system = 1 + if ("log_ooc") config.log_ooc = 1 diff --git a/code/modules/assembly/signaler.dm b/code/modules/assembly/signaler.dm index 07e779c048..4ff38fc751 100644 --- a/code/modules/assembly/signaler.dm +++ b/code/modules/assembly/signaler.dm @@ -17,10 +17,6 @@ var/airlock_wire = null var/datum/radio_frequency/radio_connection - proc - signal() - - New() ..() spawn(40) @@ -103,7 +99,7 @@ return - signal() + proc/signal() if(!radio_connection) return var/datum/signal/signal = new diff --git a/code/world.dm b/code/world.dm index 481d4bfd96..9d67a7e14f 100644 --- a/code/world.dm +++ b/code/world.dm @@ -191,24 +191,59 @@ Starting up. [time2text(world.timeofday, "hh:mm.ss")] /world/proc/load_admins() - var/text = file2text("config/admins.txt") - if (!text) - diary << "Failed to load config/admins.txt\n" + if(config.admin_legacy_system) + //Legacy admin system uses admins.txt + var/text = file2text("config/admins.txt") + if (!text) + diary << "Failed to load config/admins.txt\n" + else + var/list/lines = dd_text2list(text, "\n") + for(var/line in lines) + if (!line) + continue + + if (copytext(line, 1, 2) == ";") + continue + + var/pos = findtext(line, " - ", 1, null) + if (pos) + var/m_key = copytext(line, 1, pos) + var/a_lev = copytext(line, pos + 3, length(line) + 1) + admins[m_key] = new /datum/admins(a_lev) + diary << ("ADMIN: [m_key] = [a_lev]") else - var/list/lines = dd_text2list(text, "\n") - for(var/line in lines) - if (!line) - continue + //The current admin system uses SQL + var/user = sqlfdbklogin + var/pass = sqlfdbkpass + var/db = sqlfdbkdb + var/address = sqladdress + var/port = sqlport - if (copytext(line, 1, 2) == ";") - continue + var/DBConnection/dbcon = new() + + dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") + if(!dbcon.IsConnected()) + diary << "Failed to connect to database in load_admins(). Reverting to legacy system." + config.admin_legacy_system + load_admins() + return + + var/DBQuery/query = dbcon.NewQuery("SELECT ckey, rank, level FROM erro_admin") + query.Execute() + while(query.NextRow()) + var/adminckey = query.item[1] + var/adminrank = query.item[2] + var/adminlevel = query.item[3] + var/datum/admins/AD = new /datum/admins(adminrank) + AD.level = adminlevel + admins[adminckey] = AD + + if(!admins) + diary << "The database query in load_admins() resulted in no admins being added to the list. Reverting to legacy system." + config.admin_legacy_system + load_admins() + return - var/pos = findtext(line, " - ", 1, null) - if (pos) - var/m_key = copytext(line, 1, pos) - var/a_lev = copytext(line, pos + 3, length(line) + 1) - admins[m_key] = new /datum/admins(a_lev) - diary << ("ADMIN: [m_key] = [a_lev]") /world/proc/load_configuration() diff --git a/config/config.txt b/config/config.txt index adb63df8e8..add31ac06b 100644 --- a/config/config.txt +++ b/config/config.txt @@ -6,6 +6,9 @@ ALERT_RED_UPTO There is an immediate serious threat to the station. Security may ALERT_RED_DOWNTO The self-destruct mechanism has been deactivated, there is still however an immediate serious threat to the station. Security may have weapons unholstered at all times, random searches are allowed and advised. ALERT_DELTA The station's self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill. +## Add a # infront of this if you want to use the SQL based admin system, the legacy system uses admins.txt +#ADMIN_LEGACY_SYSTEM + ## log OOC channel LOG_OOC