Add character slot clearing

This commit is contained in:
mochi
2020-06-24 19:44:21 +02:00
parent 747b183207
commit 492c2d79c2
2 changed files with 32 additions and 1 deletions
@@ -121,6 +121,7 @@
return 1
/datum/preferences/proc/load_character(client/C,slot)
saved = FALSE
if(!slot) slot = default_slot
slot = sanitize_integer(slot, 1, max_save_slots, initial(default_slot))
@@ -132,6 +133,7 @@
// Let's not have this explode if you sneeze on the DB
var/DBQuery/query = GLOB.dbcon.NewQuery({"SELECT
OOC_Notes,
slot,
real_name,
name_is_always_random,
gender,
@@ -262,6 +264,8 @@
loadout_gear = params2list(query.item[51])
autohiss_mode = text2num(query.item[52])
saved = TRUE
//Sanitize
var/datum/species/SP = GLOB.all_species[species]
metadata = sanitize_text(metadata, initial(metadata))
@@ -474,6 +478,8 @@
log_game("SQL ERROR during character slot saving. Error : \[[err]\]\n")
message_admins("SQL ERROR during character slot saving. Error : \[[err]\]\n")
return
saved = TRUE
return 1
/datum/preferences/proc/load_random_character_slot(client/C)
@@ -495,3 +501,20 @@
load_character(C,pick(saves))
return 1
/datum/preferences/proc/clear_character_slot(client/C)
. = FALSE
// Is there a character in that slot?
var/DBQuery/query = GLOB.dbcon.NewQuery("SELECT slot FROM [format_table_name("characters")] WHERE ckey='[C.ckey]' AND slot='[default_slot]'")
query.Execute()
if(!query.RowCount())
return
query = GLOB.dbcon.NewQuery("DELETE FROM [format_table_name("characters")] WHERE ckey='[C.ckey]' AND slot='[default_slot]'")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during character slot clearing. Error : \[[err]\]\n")
message_admins("SQL ERROR during character slot clearing. Error : \[[err]\]\n")
return
saved = FALSE
return TRUE