SQL Saves - Season 2 Episode 2 - The Fixening (#1286)

Update the schema
 Modify player_preferences and character related tables
 Readd the incidents + missing CCIAA tables to it
 Fix loading
 Fix saving
 Make it impossible to edit character name after a while
 Sanity check so you cannot enter without a valid (saved) character
 Fix New Character button
 Remove debug messages

Fixes #600 
Fixes #588
This commit is contained in:
skull132
2016-12-25 00:56:36 +02:00
committed by GitHub
parent 7c8cf8408e
commit 24258106da
19 changed files with 363 additions and 147 deletions
@@ -84,7 +84,11 @@
var/DBQuery/query = dbcon.NewQuery(query_text)
query.Execute(arg_list, 1)
if (query.ErrorMsg())
error("Error loading character from SQL: [query.ErrorMsg()]")
error("SQL CHARACTER LOAD: SQL query error: [query.ErrorMsg()]")
log_debug("SQL CHARACTER LOAD: SQL query error: [query.ErrorMsg()]")
log_debug("SQL CHARACTER LOAD: query args: [json_encode(arg_list)]")
continue
// Each query should only return exactly 1 row.
var/list/var_names = query_cache[type][query_text]
@@ -97,9 +101,9 @@
else
cc.preferences.vars[layers[1]][layers[2]] = query.item[i]
catch(var/exception/e)
error("Error loading character from SQL: [e.name]")
log_debug("SQL Saves: [e.name]")
log_debug("SQL Saves: [e.desc]")
error("SQL CHARACTER LOAD: bad variable name: [e.name]")
log_debug("SQL CHARACTER LOAD: bad variable name: [e.name]")
log_debug("SQL CHARACTER LOAD: var name: [var_names[i]]")
/datum/category_group/player_setup_category/proc/gather_load_parameters()
var/list/arg_list = list()
@@ -162,11 +166,15 @@
for (var/variable in var_names)
if (isnull(var_names[variable]))
query += " [variable] = [arg_names[i]]"
if (i < var_names.len)
query += ", "
if (i < var_names.len)
query += ","
i++
// Remove any potentially damaging commas from the end.
query = replacetext(query, ",", "", length(query) - 1)
// Save it.
query_cache[type] += query
@@ -180,7 +188,11 @@
query.Execute(arg_list, 1)
if (query.ErrorMsg())
error("Error saving character to SQL: [query.ErrorMsg()]")
error("SQL CHARACTER SAVE: SQL query error: [query.ErrorMsg()]")
log_debug("SQL CHARACTER SAVE: SQL query error: [query.ErrorMsg()]")
log_debug("SQL CHARACTER SAVE: query args: [json_encode(arg_list)]")
continue
if (role_type == SQL_CHARACTER && !cc.preferences.current_character)
// No current character, means we're doing insert queries.
@@ -193,9 +205,11 @@
arg_list[":char_id"] = text2num(query.item[1])
cc.preferences.current_character = text2num(query.item[1])
else
error("Error inserting character to SQL: New ID was not recovered.")
error("SQL CHARACTER SAVE: New ID was not recovered.")
log_debug("SQL CHARACTER SAVE: New ID was not recovered.")
if (query.ErrorMsg())
error("Error retreiving new character ID: [query.ErrorMsg()]")
error("SQL CHARACTER SAVE: SQL query error from last_insert_id: [query.ErrorMsg()]")
log_debug("SQL CHARACTER SAVE: SQL query error from last_insert_id: [query.ErrorMsg()]")
/datum/category_group/player_setup_category/proc/gather_save_parameters()
var/list/arg_list = list()