mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 03:57:13 +01:00
Converts configs to use TOML
This commit is contained in:
@@ -7,25 +7,15 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons
|
||||
|
||||
var/previous_rights = 0
|
||||
|
||||
//load text from file
|
||||
var/list/Lines = file2list("config/admin_ranks.txt")
|
||||
|
||||
//process each line seperately
|
||||
for(var/line in Lines)
|
||||
if(!length(line)) continue
|
||||
if(copytext(line,1,2) == "#") continue
|
||||
|
||||
var/list/List = splittext(line,"+")
|
||||
if(!List.len) continue
|
||||
|
||||
var/rank = ckeyEx(List[1])
|
||||
switch(rank)
|
||||
if(null,"") continue
|
||||
if("Removed") continue //Reserved
|
||||
// Process each rank set seperately
|
||||
// key: rank name | value: list of rights
|
||||
for(var/rankname in GLOB.configuration.admin.rank_rights_map)
|
||||
var/list/rank_right_tokens = GLOB.configuration.admin.rank_rights_map[rankname]
|
||||
|
||||
var/rights = 0
|
||||
for(var/i=2, i<=List.len, i++)
|
||||
switch(ckey(List[i]))
|
||||
for(var/right_token in rank_right_tokens)
|
||||
var/token = lowertext(splittext(right_token, "+")[2])
|
||||
switch(token)
|
||||
if("@","prev") rights |= previous_rights
|
||||
if("buildmode","build") rights |= R_BUILDMODE
|
||||
if("admin") rights |= R_ADMIN
|
||||
@@ -46,7 +36,7 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons
|
||||
if("proccall") rights |= R_PROCCALL
|
||||
if("viewruntimes") rights |= R_VIEWRUNTIMES
|
||||
|
||||
GLOB.admin_ranks[rank] = rights
|
||||
GLOB.admin_ranks[rankname] = rights
|
||||
previous_rights = rights
|
||||
|
||||
#ifdef TESTING
|
||||
@@ -73,29 +63,13 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons
|
||||
for(var/A in world.GetConfig("admin"))
|
||||
world.SetConfig("APP/admin", A, null)
|
||||
|
||||
if(config.admin_legacy_system)
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
load_admin_ranks()
|
||||
|
||||
//load text from file
|
||||
var/list/Lines = file2list("config/admins.txt")
|
||||
|
||||
//process each line seperately
|
||||
for(var/line in Lines)
|
||||
if(!length(line)) continue
|
||||
if(copytext(line,1,2) == "#") continue
|
||||
|
||||
//Split the line at every "-"
|
||||
var/list/List = splittext(line, "-")
|
||||
if(!List.len) continue
|
||||
|
||||
//ckey is before the first "-"
|
||||
var/ckey = ckey(List[1])
|
||||
if(!ckey) continue
|
||||
|
||||
//rank follows the first "-"
|
||||
var/rank = ""
|
||||
if(List.len >= 2)
|
||||
rank = ckeyEx(List[2])
|
||||
for(var/iterator_key in GLOB.configuration.admin.ckey_rank_map)
|
||||
var/ckey = ckey(iterator_key) // Snip out formatting
|
||||
var/rank = GLOB.configuration.admin.ckey_rank_map[iterator_key]
|
||||
|
||||
//load permissions associated with this rank
|
||||
var/rights = GLOB.admin_ranks[rank]
|
||||
@@ -113,7 +87,7 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons
|
||||
//The current admin system uses SQL
|
||||
if(!SSdbcore.IsConnected())
|
||||
log_world("Failed to connect to database in load_admins(). Reverting to legacy system.")
|
||||
config.admin_legacy_system = 1
|
||||
GLOB.configuration.admin.use_database_admins = FALSE
|
||||
load_admins()
|
||||
return
|
||||
|
||||
@@ -141,7 +115,7 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons
|
||||
|
||||
if(!GLOB.admin_datums)
|
||||
log_world("The database query in load_admins() resulted in no admins being added to the list. Reverting to legacy system.")
|
||||
config.admin_legacy_system = 1
|
||||
GLOB.configuration.admin.use_database_admins = FALSE
|
||||
load_admins()
|
||||
return
|
||||
|
||||
|
||||
@@ -672,21 +672,13 @@ GLOBAL_LIST_INIT(admin_verbs_ticket, list(
|
||||
|
||||
var/datum/admins/D = GLOB.admin_datums[ckey]
|
||||
var/rank = null
|
||||
if(config.admin_legacy_system)
|
||||
//load text from file
|
||||
var/list/Lines = file2list("config/admins.txt")
|
||||
for(var/line in Lines)
|
||||
if(findtext(line, "#")) // Skip comments
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
for(var/iterator_key in GLOB.configuration.admin.ckey_rank_map)
|
||||
var/_ckey = ckey(iterator_key) // Snip out formatting
|
||||
if(ckey != _ckey)
|
||||
continue
|
||||
|
||||
var/list/splitline = splittext(line, " - ")
|
||||
if(length(splitline) != 2) // Always 'ckey - rank'
|
||||
continue
|
||||
if(lowertext(splitline[1]) == ckey)
|
||||
rank = ckeyEx(splitline[2])
|
||||
break
|
||||
continue
|
||||
|
||||
rank = GLOB.configuration.admin.ckey_rank_map[iterator_key]
|
||||
break
|
||||
else
|
||||
if(!SSdbcore.IsConnected())
|
||||
to_chat(src, "Warning, MYSQL database is not connected.")
|
||||
@@ -706,7 +698,7 @@ GLOBAL_LIST_INIT(admin_verbs_ticket, list(
|
||||
|
||||
qdel(rank_read)
|
||||
if(!D)
|
||||
if(config.admin_legacy_system)
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
if(GLOB.admin_ranks[rank] == null)
|
||||
error("Error while re-adminning [src], admin rank ([rank]) does not exist.")
|
||||
to_chat(src, "Error while re-adminning, admin rank ([rank]) does not exist.")
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
usr << browse(output,"window=editrights;size=600x500")
|
||||
|
||||
/datum/admins/proc/log_admin_rank_modification(adm_ckey, new_rank)
|
||||
if(config.admin_legacy_system) return
|
||||
if(!GLOB.configuration.admin.use_database_admins) return
|
||||
|
||||
if(!usr.client)
|
||||
return
|
||||
@@ -140,7 +140,7 @@
|
||||
message_admins("[key_name(usr)] attempted to edit admin ranks via advanced proc-call")
|
||||
log_admin("[key_name(usr)] attempted to edit admin ranks via advanced proc-call")
|
||||
return
|
||||
if(config.admin_legacy_system)
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
return
|
||||
|
||||
if(!usr.client)
|
||||
|
||||
@@ -287,19 +287,19 @@
|
||||
if(null,"") return
|
||||
if("*New Rank*")
|
||||
new_rank = input("Please input a new rank", "New custom rank", null, null) as null|text
|
||||
if(config.admin_legacy_system)
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
new_rank = ckeyEx(new_rank)
|
||||
if(!new_rank)
|
||||
to_chat(usr, "<font color='red'>Error: Topic 'editrights': Invalid rank</font>")
|
||||
return
|
||||
if(config.admin_legacy_system)
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
if(GLOB.admin_ranks.len)
|
||||
if(new_rank in GLOB.admin_ranks)
|
||||
rights = GLOB.admin_ranks[new_rank] //we typed a rank which already exists, use its rights
|
||||
else
|
||||
GLOB.admin_ranks[new_rank] = 0 //add the new rank to admin_ranks
|
||||
else
|
||||
if(config.admin_legacy_system)
|
||||
if(!GLOB.configuration.admin.use_database_admins)
|
||||
new_rank = ckeyEx(new_rank)
|
||||
rights = GLOB.admin_ranks[new_rank] //we input an existing rank, use its rights
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@
|
||||
GLOB.directory[ckey] = src
|
||||
//Admin Authorisation
|
||||
// Automatically makes localhost connection an admin
|
||||
if(!config.disable_localhost_admin)
|
||||
if(GLOB.configuration.admin.enable_localhost_autoadmin)
|
||||
if(is_connecting_from_localhost())
|
||||
new /datum/admins("!LOCALHOST!", R_HOST, ckey) // Makes localhost rank
|
||||
holder = GLOB.admin_datums[ckey]
|
||||
|
||||
@@ -2025,8 +2025,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
|
||||
|
||||
if("afk_watch")
|
||||
if(!(toggles2 & PREFTOGGLE_2_AFKWATCH))
|
||||
to_chat(user, "<span class='info'>You will now get put into cryo dorms after [config.auto_cryo_afk] minutes. \
|
||||
Then after [config.auto_despawn_afk] minutes you will be fully despawned. You will receive a visual and auditory warning before you will be put into cryodorms.</span>")
|
||||
to_chat(user, "<span class='info'>You will now get put into cryo dorms after [GLOB.configuration.afk.auto_cryo_minutes] minutes. \
|
||||
Then after [GLOB.configuration.afk.auto_despawn_minutes] minutes you will be fully despawned. You will receive a visual and auditory warning before you will be put into cryodorms.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='info'>Automatic cryoing turned off.</span>")
|
||||
toggles2 ^= PREFTOGGLE_2_AFKWATCH
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
player_logged++
|
||||
if(istype(loc, /obj/machinery/cryopod))
|
||||
return
|
||||
if(config.auto_cryo_ssd_mins && (player_logged >= (config.auto_cryo_ssd_mins * 30)) && player_logged % 30 == 0)
|
||||
if(GLOB.configuration.afk.ssd_auto_cryo_minutes && (player_logged >= (GLOB.configuration.afk.ssd_auto_cryo_minutes * 30)) && player_logged % 30 == 0)
|
||||
var/turf/T = get_turf(src)
|
||||
if(!is_station_level(T.z))
|
||||
return
|
||||
|
||||
@@ -129,17 +129,11 @@
|
||||
if((head_organ.dna.species.name in tmp_hair.species_allowed) && (robohead.company in tmp_hair.models_allowed)) //Populate the list of available monitor styles only with styles that the monitor-head is allowed to use.
|
||||
hair += i
|
||||
|
||||
var/file = file2text("config/custom_sprites.txt") //Pulls up the custom_sprites list
|
||||
var/lines = splittext(file, "\n")
|
||||
|
||||
for(var/line in lines) // Looks for lines set up as screen:ckey:screen_name
|
||||
var/list/Entry = splittext(line, ":") // split lines
|
||||
for(var/i = 1 to Entry.len)
|
||||
Entry[i] = trim(Entry[i]) // Cleans up lines
|
||||
if(Entry.len != 3 || Entry[1] != "screen") // Ignore entries that aren't for screens
|
||||
continue
|
||||
if(Entry[2] == H.ckey) // They're in the list? Custom sprite time, var and icon change required
|
||||
hair += Entry[3] // Adds custom screen to list
|
||||
if(H.ckey in GLOB.configuration.custom_sprites.ipc_screen_map)
|
||||
// key: ckey | value: list of icon states
|
||||
for(var/style in GLOB.configuration.custom_sprites.ipc_screen_map[H.ckey])
|
||||
hair += style
|
||||
|
||||
var/new_style = input(H, "Select a monitor display", "Monitor Display", head_organ.h_style) as null|anything in hair
|
||||
var/new_color = input("Please select hair color.", "Monitor Color", head_organ.hair_colour) as null|color
|
||||
|
||||
@@ -365,20 +365,8 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
|
||||
if(stat || aiRestorePowerRoutine)
|
||||
return
|
||||
if(!custom_sprite) //Check to see if custom sprite time, checking the appopriate file to change a var
|
||||
var/file = file2text("config/custom_sprites.txt")
|
||||
var/lines = splittext(file, "\n")
|
||||
|
||||
for(var/line in lines)
|
||||
// split & clean up
|
||||
var/list/Entry = splittext(line, ":")
|
||||
for(var/i = 1 to Entry.len)
|
||||
Entry[i] = trim(Entry[i])
|
||||
|
||||
if(Entry.len < 2 || Entry[1] != "ai") //ignore incorrectly formatted entries or entries that aren't marked for AI
|
||||
continue
|
||||
|
||||
if(Entry[2] == ckey) //They're in the list? Custom sprite time, var and icon change required
|
||||
custom_sprite = 1
|
||||
if(ckey in GLOB.configuration.custom_sprites.ai_core_ckeys)
|
||||
custom_sprite = TRUE
|
||||
|
||||
var/display_choices = list(
|
||||
"Monochrome",
|
||||
@@ -963,21 +951,9 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
|
||||
|
||||
if(check_unable())
|
||||
return
|
||||
if(!custom_hologram) //Check to see if custom sprite time, checking the appopriate file to change a var
|
||||
var/file = file2text("config/custom_sprites.txt")
|
||||
var/lines = splittext(file, "\n")
|
||||
|
||||
for(var/line in lines)
|
||||
// split & clean up
|
||||
var/list/Entry = splittext(line, ":")
|
||||
for(var/i = 1 to Entry.len)
|
||||
Entry[i] = trim(Entry[i])
|
||||
|
||||
if(Entry.len < 2 || Entry[1] != "hologram")
|
||||
continue
|
||||
|
||||
if (Entry[2] == ckey) //Custom holograms
|
||||
custom_hologram = 1 // option is given in hologram menu
|
||||
if(!custom_hologram)
|
||||
if(ckey in GLOB.configuration.custom_sprites.ai_hologram_ckeys)
|
||||
custom_hologram = TRUE
|
||||
|
||||
var/input
|
||||
switch(alert("Would you like to select a hologram based on a crew member, an animal, or switch to a unique avatar?",,"Crew Member","Unique","Animal"))
|
||||
@@ -1319,7 +1295,7 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
|
||||
/mob/living/silicon/ai/proc/open_nearest_door(mob/living/target)
|
||||
if(!istype(target))
|
||||
return
|
||||
|
||||
|
||||
if(check_unable(AI_CHECK_WIRELESS))
|
||||
return
|
||||
|
||||
|
||||
@@ -286,21 +286,9 @@
|
||||
|
||||
//check for custom_sprite
|
||||
if(!custom_sprite)
|
||||
var/file = file2text("config/custom_sprites.txt")
|
||||
var/lines = splittext(file, "\n")
|
||||
|
||||
for(var/line in lines)
|
||||
// split & clean up
|
||||
var/list/Entry = splittext(line, ":")
|
||||
for(var/i = 1 to Entry.len)
|
||||
Entry[i] = trim(Entry[i])
|
||||
|
||||
if(Entry.len < 2 || Entry[1] != "pai") //ignore incorrectly formatted entries or entries that aren't marked for pAI
|
||||
continue
|
||||
|
||||
if(Entry[2] == ckey) //They're in the list? Custom sprite time, var and icon change required
|
||||
custom_sprite = 1
|
||||
my_choices["Custom"] = "[ckey]-pai"
|
||||
if(ckey in GLOB.configuration.custom_sprites.pai_holoform_ckeys)
|
||||
custom_sprite = TRUE
|
||||
my_choices["Custom"] = "[ckey]-pai"
|
||||
|
||||
my_choices = possible_chassis.Copy()
|
||||
if(custom_sprite)
|
||||
|
||||
@@ -49,35 +49,6 @@
|
||||
else
|
||||
..()
|
||||
|
||||
/mob/living/silicon/robot/drone/verb/customize()
|
||||
set name = "Customize Chassis"
|
||||
set desc = "Reconfigure your chassis into a customized version."
|
||||
set category = "Drone"
|
||||
|
||||
if(!custom_sprite) //Check to see if custom sprite time, checking the appopriate file to change a var
|
||||
var/file = file2text("config/custom_sprites.txt")
|
||||
var/lines = splittext(file, "\n")
|
||||
|
||||
for(var/line in lines)
|
||||
// split & clean up
|
||||
var/list/Entry = splittext(line, ":")
|
||||
for(var/i = 1 to Entry.len)
|
||||
Entry[i] = trim(Entry[i])
|
||||
|
||||
if(Entry.len < 2 || Entry[1] != "drone")
|
||||
continue
|
||||
|
||||
if (Entry[2] == ckey) //Custom holograms
|
||||
custom_sprite = 1 // option is given in hologram menu
|
||||
|
||||
if(!custom_sprite)
|
||||
to_chat(src, "<span class='warning'>Error 404: Custom chassis not found. Revoking customization option.</span>")
|
||||
else
|
||||
icon = 'icons/mob/custom_synthetic/custom-synthetic.dmi'
|
||||
icon_state = "[ckey]-drone"
|
||||
to_chat(src, "<span class='notice'>You reconfigure your chassis and improve the station through your new aesthetics.</span>")
|
||||
verbs -= /mob/living/silicon/robot/drone/verb/customize
|
||||
|
||||
/mob/living/silicon/robot/drone/get_scooped(mob/living/carbon/grabber)
|
||||
var/obj/item/holder/H = ..()
|
||||
if(!istype(H))
|
||||
|
||||
@@ -215,20 +215,8 @@ GLOBAL_LIST_INIT(robot_verbs_default, list(
|
||||
|
||||
//Check for custom sprite
|
||||
if(!custom_sprite)
|
||||
var/file = file2text("config/custom_sprites.txt")
|
||||
var/lines = splittext(file, "\n")
|
||||
|
||||
for(var/line in lines)
|
||||
// split & clean up
|
||||
var/list/Entry = splittext(line, ":")
|
||||
for(var/i = 1 to Entry.len)
|
||||
Entry[i] = trim(Entry[i])
|
||||
|
||||
if(Entry.len < 2 || Entry[1] != "cyborg") //ignore incorrectly formatted entries or entries that aren't marked for cyborg
|
||||
continue
|
||||
|
||||
if(Entry[2] == ckey) //They're in the list? Custom sprite time, var and icon change required
|
||||
custom_sprite = 1
|
||||
if(ckey in GLOB.configuration.custom_sprites.cyborg_ckeys)
|
||||
custom_sprite = TRUE
|
||||
|
||||
if(mmi && mmi.brainmob)
|
||||
mmi.brainmob.name = newname
|
||||
|
||||
@@ -1,43 +1,8 @@
|
||||
// Unit test to check SQL version has been updated properly.,
|
||||
/datum/unit_test/sql_version/Run()
|
||||
// Check if the SQL version set in the code is equal to the CI DB config
|
||||
if(config.sql_enabled && sql_version != SQL_VERSION)
|
||||
Fail("SQL version error: Game is running V[SQL_VERSION] but config is V[sql_version]. You may need to update tools/ci/dbconfig.txt")
|
||||
// Check if the CI DB config is up to date with the example dbconfig
|
||||
// This proc is a little unclean but it works
|
||||
var/example_db_version
|
||||
var/list/Lines = file2list("config/example/dbconfig.txt")
|
||||
for(var/t in Lines)
|
||||
if(!t) continue
|
||||
|
||||
t = trim(t)
|
||||
if(length(t) == 0)
|
||||
continue
|
||||
else if(copytext(t, 1, 2) == "#")
|
||||
continue
|
||||
|
||||
var/pos = findtext(t, " ")
|
||||
var/name = null
|
||||
var/value = null
|
||||
|
||||
if(pos)
|
||||
name = lowertext(copytext(t, 1, pos))
|
||||
value = copytext(t, pos + 1)
|
||||
else
|
||||
name = lowertext(t)
|
||||
|
||||
if(!name)
|
||||
continue
|
||||
|
||||
switch(name)
|
||||
if("db_version")
|
||||
example_db_version = text2num(value)
|
||||
|
||||
if(!example_db_version)
|
||||
Fail("SQL version error: File config/example/dbconfig.txt does not have a valid SQL version set!")
|
||||
|
||||
if(example_db_version != SQL_VERSION)
|
||||
Fail("SQL version error: Game is running V[SQL_VERSION] but config/example/dbconfig.txt is V[example_db_version].")
|
||||
if(GLOB.configuration.database.version != SQL_VERSION)
|
||||
Fail("SQL version error: Game is running V[SQL_VERSION] but config is V[sql_version]. You may need to update the example config.")
|
||||
|
||||
if(SSdbcore.total_errors > 0)
|
||||
Fail("SQL errors occured on startup. Please fix them.")
|
||||
|
||||
Reference in New Issue
Block a user