diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm
index 0b74b7132fd..12203b8155f 100644
--- a/code/modules/client/preference/preferences.dm
+++ b/code/modules/client/preference/preferences.dm
@@ -188,6 +188,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
// OOC Metadata:
var/metadata = ""
var/slot_name = ""
+ var/saved = FALSE // Indicates whether the character comes from the database or not
// Whether or not to use randomized character slots
var/randomslot = 0
@@ -263,10 +264,12 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "(Always Randomize)
"
dat += "
| " @@ -2078,6 +2081,11 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts load_preferences(user) load_character(user) + if("clear") + if(!saved || real_name != input("This will clear the current slot permanently. Please enter the character's full name to confirm.")) + return FALSE + clear_character_slot(user) + if("open_load_dialog") if(!IsGuestKey(user.key)) open_load_dialog(user) diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 94f724b77a6..5052a5b315d 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -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 |