Final MySQL playersave system

This commit is contained in:
ZomgPonies
2014-06-03 16:33:57 -04:00
parent 048ac0994d
commit 7aae02db38
3 changed files with 37 additions and 13 deletions
+26 -2
View File
@@ -163,14 +163,38 @@
//slower then list2text, but correctly processes associative lists.
proc/tg_list2text(list/list, glue=",")
proc/tg_list2text(list/list, glue=",", assocglue=";")
if(!istype(list) || !list.len)
return
var/output
for(var/i=1 to list.len)
output += (i!=1? glue : null)+(!isnull(list["[list[i]]"])?"[list["[list[i]]"]]":"[list[i]]")
if(!isnull(list["[list[i]]"]))
output += (i!=1? glue : null)+ "[list[i]]"+(i!=1? assocglue : null)+"[list["[list[i]]"]]"
else
output += (i!=1? glue : null)+ "[list[i]]"
return output
proc/tg_text2list(text, glue=",", assocglue=";")
var/length = length(glue)
if(length < 1) return list(text)
. = list()
var/lastglue_found = 1
var/foundglue
var/foundassocglue
var/searchtext
do
foundglue = findtext(text, glue, lastglue_found, 0)
searchtext = copytext(text, lastglue_found, foundglue)
foundassocglue = findtext(searchtext, assocglue, 1, 0)
if(foundassocglue)
var/sublist = copytext(searchtext, 1, foundassocglue)
sublist[1] = copytext(searchtext, foundassocglue, 0)
. += sublist
else
. += copytext(text, lastglue_found, foundglue)
lastglue_found = foundglue + length
while(foundglue)
//Converts a string into a list by splitting the string at each delimiter found. (discarding the seperator)
/proc/text2list(text, delimiter="\n")
+5 -5
View File
@@ -1430,11 +1430,6 @@ datum/preferences
proc/open_load_dialog(mob/user)
var/DBQuery/query = dbcon.NewQuery("SELECT slot,real_name FROM characters WHERE ckey='[user.ckey]' ORDER BY slot")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during character slot loading. Error : \[[err]\]\n")
message_admins("SQL ERROR during character slot loading. Error : \[[err]\]\n")
return
var/dat = "<body>"
dat += "<tt><center>"
@@ -1442,6 +1437,11 @@ datum/preferences
var/name
for(var/i=1, i<=MAX_SAVE_SLOTS, i++)
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during character slot loading. Error : \[[err]\]\n")
message_admins("SQL ERROR during character slot loading. Error : \[[err]\]\n")
return
while(query.NextRow())
if(i==text2num(query.item[1]))
name = query.item[2]
+6 -6
View File
@@ -115,8 +115,8 @@
gen_record = query.item[46]
be_special = query.item[47]
disabilities = query.item[48]
player_alt_titles = text2list(query.item[49],",")
organ_data = text2list(query.item[50],",")
player_alt_titles = params2list(query.item[49])
organ_data = params2list(query.item[50])
nanotrasen_relation = query.item[51]
@@ -176,14 +176,14 @@
var/organlist
var/playertitlelist
if(!isemptylist(organ_data))
organlist = tg_list2text(organ_data)
organlist = list2params(organ_data)
if(!isemptylist(player_alt_titles))
playertitlelist = tg_list2text(player_alt_titles)
playertitlelist = list2params(player_alt_titles)
var/DBQuery/firstquery = dbcon.NewQuery("SELECT slot FROM characters WHERE ckey='[C.ckey]' ORDER BY slot")
firstquery.Execute()
while(firstquery.NextRow())
if(firstquery.item[1] == default_slot)
if(text2num(firstquery.item[1]) == default_slot)
var/DBQuery/query = dbcon.NewQuery("UPDATE characters SET OOC_Notes='[metadata]',real_name='[real_name]',name_is_always_random='[be_random_name]',gender='[gender]',age='[age]',species='[species]',language='[language]',hair_red='[r_hair]',hair_green='[g_hair]',hair_blue='[b_hair]',facial_red='[r_facial]',facial_green='[g_facial]',facial_blue='[b_facial]',skin_tone='[s_tone]',skin_red='[r_skin]',skin_green='[g_skin]',skin_blue='[b_skin]',hair_style_name='[h_style]',facial_style_name='[f_style]',eyes_red='[r_eyes]',eyes_green='[g_eyes]',eyes_blue='[b_eyes]',underwear='[underwear]',undershirt='[undershirt]',backbag='[backbag]',b_type='[b_type]',alternate_option='[alternate_option]',job_civilian_high='[job_civilian_high]',job_civilian_med='[job_civilian_med]',job_civilian_low='[job_civilian_low]',job_medsci_high='[job_medsci_high]',job_medsci_med='[job_medsci_med]',job_medsci_low='[job_medsci_low]',job_engsec_high='[job_engsec_high]',job_engsec_med='[job_engsec_med]',job_engsec_low='[job_engsec_low]',job_karma_high='[job_karma_high]',job_karma_med='[job_karma_med]',job_karma_low='[job_karma_low]',flavor_text='[flavor_text]',med_record='[med_record]',sec_record='[sec_record]',gen_record='[gen_record]',player_alt_titles='[playertitlelist]',be_special='[be_special]',disabilities='[disabilities]',organ_data='[organlist]',nanotrasen_relation='[nanotrasen_relation]' WHERE ckey='[C.ckey]' AND slot='[default_slot]'")
if(!query.Execute())
var/err = query.ErrorMsg()
@@ -205,7 +205,7 @@
while(query.NextRow())
var/list/saves = list()
for(var/i=1, i<=MAX_SAVE_SLOTS, i++)
if(i==query.item[1])
if(i==text2num(query.item[1]))
saves += i
if(!saves.len)