Preferences SQL tests (#4016)

This commit is contained in:
Erki
2017-12-29 23:57:31 +02:00
committed by Lohikar
parent 139a0fa2b7
commit ba57b5a5e5
21 changed files with 205 additions and 37 deletions
@@ -22,7 +22,7 @@
return list("ss13_characters" = list("be_special_role", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/antagonism/candidacy/gather_save_parameters()
return list("be_special_role" = list2params(pref.be_special_role), "id" = pref.current_character, "ckey" = pref.client.ckey)
return list("be_special_role" = list2params(pref.be_special_role), "id" = pref.current_character, "ckey" = PREF_CLIENT_CKEY)
/datum/category_item/player_setup_item/antagonism/candidacy/sanitize_character(var/sql_load = 0)
if (sql_load)
@@ -17,13 +17,13 @@ var/global/list/uplink_locations = list("PDA", "Headset", "None")
"ss13_characters_flavour" = list(
"vars" = list(
"records_exploit" = "exploit_record"
),
),
"args" = list("char_id")
),
"ss13_characters" = list(
"vars" = list(
"uplink_location" = "uplinklocation"
),
),
"args" = list("id")
)
)
@@ -37,7 +37,7 @@ var/global/list/uplink_locations = list("PDA", "Headset", "None")
/datum/category_item/player_setup_item/antagonism/basic/gather_save_query()
return list(
"ss13_characters_flavour" = list(
"records_exploit",
"records_exploit",
"char_id" = 1
),
"ss13_characters" = list(
@@ -48,7 +48,7 @@ var/global/list/uplink_locations = list("PDA", "Headset", "None")
)
/datum/category_item/player_setup_item/antagonism/basic/gather_save_parameters()
return list("records_exploit" = pref.exploit_record, "char_id" = pref.current_character, "uplink_location" = pref.uplinklocation, "id" = pref.current_character, "ckey" = pref.client.ckey)
return list("records_exploit" = pref.exploit_record, "char_id" = pref.current_character, "uplink_location" = pref.uplinklocation, "id" = pref.current_character, "ckey" = PREF_CLIENT_CKEY)
/datum/category_item/player_setup_item/antagonism/basic/sanitize_character()
pref.uplinklocation = sanitize_inlist(pref.uplinklocation, uplink_locations, initial(pref.uplinklocation))
@@ -60,7 +60,7 @@
"spawnpoint" = pref.spawnpoint,
"species" = pref.species,
"id" = pref.current_character,
"ckey" = pref.client.ckey
"ckey" = PREF_CLIENT_CKEY
)
/datum/category_item/player_setup_item/general/basic/load_special()
@@ -13,7 +13,7 @@
"ss13_characters" = list(
"vars" = list(
"language" = "alternate_languages"
),
),
"args" = list("id")
)
)
@@ -34,7 +34,7 @@
return list(
"language" = list2params(pref.alternate_languages),
"id" = pref.current_character,
"ckey" = pref.client.ckey
"ckey" = PREF_CLIENT_CKEY
)
/datum/category_item/player_setup_item/general/language/sanitize_character(var/sql_load = 0)
@@ -22,7 +22,7 @@
"undershirt",
"socks",
"backbag"
),
),
"args" = list("id")
)
)
@@ -49,7 +49,7 @@
"socks" = pref.socks,
"backbag" = pref.backbag,
"id" = pref.current_character,
"ckey" = pref.client.ckey
"ckey" = PREF_CLIENT_CKEY
)
/datum/category_item/player_setup_item/general/equipment/sanitize_character(var/sql_load = 0)
@@ -36,9 +36,9 @@
"ss13_characters" = list(
"vars" = list(
"nt_relation" = "nanotrasen_relation",
"home_system",
"citizenship",
"faction",
"home_system",
"citizenship",
"faction",
"religion"
),
"args" = list("id")
@@ -60,8 +60,8 @@
"char_id" = 1
),
"ss13_characters" = list(
"nt_relation",
"home_system",
"nt_relation",
"home_system",
"citizenship",
"faction",
"religion","id" = 1,
@@ -81,7 +81,7 @@
"faction" = pref.faction,
"religion" = pref.religion,
"id" = pref.current_character,
"ckey" = pref.client.ckey
"ckey" = PREF_CLIENT_CKEY
)
/datum/category_item/player_setup_item/general/background/sanitize_character()
@@ -56,11 +56,11 @@
)
for (var/module in robot_module_types)
var_list["robot_[module]"] = "flavour_texts_robot/[module]"
var_list["robot_[lowertext(module)]"] = "flavour_texts_robot/[module]"
return list(
"ss13_characters_flavour" = list(
"vars" = var_list,
"vars" = var_list,
"args" = list("char_id")
)
)
@@ -86,7 +86,7 @@
)
for (var/module in robot_module_types)
var_list += "robot_[module]"
var_list += "robot_[lowertext(module)]"
return list("ss13_characters_flavour" = var_list)
@@ -108,7 +108,7 @@
)
for (var/module in robot_module_types)
var_list["robot_[module]"] += pref.flavour_texts_robot[module]
var_list["robot_[lowertext(module)]"] += pref.flavour_texts_robot[module]
return var_list
@@ -22,13 +22,13 @@
"UI_style_color",
"UI_style_alpha",
"ooccolor"
),
),
"args" = list("ckey")
)
)
/datum/category_item/player_setup_item/player_global/ui/gather_load_parameters()
return list("ckey" = pref.client.ckey)
return list("ckey" = PREF_CLIENT_CKEY)
/datum/category_item/player_setup_item/player_global/ui/gather_save_query()
return list(
@@ -43,7 +43,7 @@
/datum/category_item/player_setup_item/player_global/ui/gather_save_parameters()
return list(
"ckey" = pref.client.ckey,
"ckey" = PREF_CLIENT_CKEY,
"UI_style_alpha" = pref.UI_style_alpha,
"UI_style_color" = pref.UI_style_color,
"UI_style" = pref.UI_style,
@@ -32,7 +32,7 @@
"asfx_togs",
"lastmotd" = "motd_hash",
"lastmemo" = "memo_hash",
"toggles_secondary" = "toggles_secondary",
"toggles_secondary",
"parallax_speed"
),
"args" = list("ckey")
@@ -40,7 +40,7 @@
)
/datum/category_item/player_setup_item/player_global/settings/gather_load_parameters()
return list("ckey" = pref.client.ckey)
return list("ckey" = PREF_CLIENT_CKEY)
/datum/category_item/player_setup_item/player_global/settings/gather_save_query()
return list(
@@ -52,14 +52,14 @@
"lastmotd",
"lastmemo",
"ckey" = 1,
"parallax_toggles",
"toggles_secondary",
"parallax_speed"
)
)
/datum/category_item/player_setup_item/player_global/settings/gather_save_parameters()
return list(
"ckey" = pref.client.ckey,
"ckey" = PREF_CLIENT_CKEY,
"lastchangelog" = pref.lastchangelog,
"current_character" = pref.current_character,
"toggles" = pref.toggles,
@@ -12,13 +12,13 @@
return list("ss13_player_preferences" = list("vars" = list("language_prefixes"), "args" = list("ckey")))
/datum/category_item/player_setup_item/player_global/language/gather_load_parameters()
return list("ckey" = pref.client.ckey)
return list("ckey" = PREF_CLIENT_CKEY)
/datum/category_item/player_setup_item/player_global/language/gather_save_query()
return list("ss13_player_preferences" = list("language_prefixes", "ckey" = 1))
/datum/category_item/player_setup_item/player_global/language/gather_save_parameters()
return list("ckey" = pref.client.ckey, "language_prefixes" = list2params(pref.language_prefixes))
return list("ckey" = PREF_CLIENT_CKEY, "language_prefixes" = list2params(pref.language_prefixes))
/datum/category_item/player_setup_item/player_global/language/sanitize_preferences(var/sql_load = 0)
if (sql_load && pref.language_prefixes)
@@ -31,7 +31,7 @@
return list("ss13_player_pai" = list("vars" = list("name" = "pai/name", "description" = "pai/description", "role" = "pai/role", "comments" = "pai/comments"), "args" = list("ckey")))
/datum/category_item/player_setup_item/player_global/pai/gather_load_parameters()
return list("ckey" = pref.client.ckey)
return list("ckey" = PREF_CLIENT_CKEY)
/datum/category_item/player_setup_item/player_global/pai/gather_save_query()
return list("ss13_player_pai" = list("name", "description", "role", "comments", "ckey" = 1))
@@ -40,7 +40,7 @@
if (!candidate)
return list()
return list("ckey" = pref.client.ckey, "name" = candidate.name, "description" = candidate.description, "role" = candidate.role, "comments" = candidate.comments)
return list("ckey" = PREF_CLIENT_CKEY, "name" = candidate.name, "description" = candidate.description, "role" = candidate.role, "comments" = candidate.comments)
/datum/category_item/player_setup_item/player_global/pai/sanitize_preferences(var/sql_load = 0)
if (sql_load && candidate && pref.pai.len)
@@ -53,7 +53,7 @@ var/list/gear_datums = list()
return list("ss13_characters" = list("gear", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/loadout/gather_save_parameters()
return list("gear" = json_encode(pref.gear), "id" = pref.current_character, "ckey" = pref.client.ckey)
return list("gear" = json_encode(pref.gear), "id" = pref.current_character, "ckey" = PREF_CLIENT_CKEY)
/datum/category_item/player_setup_item/loadout/proc/valid_gear_choices(var/max_cost)
. = list()
@@ -77,7 +77,7 @@
"alternate_option" = pref.alternate_option,
"alternate_titles" = list2params(pref.player_alt_titles),
"id" = pref.current_character,
"ckey" = pref.client.ckey
"ckey" = PREF_CLIENT_CKEY
)
/datum/category_item/player_setup_item/occupation/sanitize_character(var/sql_load = 0)
@@ -10,6 +10,13 @@
// General-purpose helper for drawing a colored box.
#define HTML_RECT(color) "&nbsp;<div style=\"display:inline;height:10px;width:30px;background:'[color || "#FFFFFF"]'\"></div>&nbsp;"
// A bit of a hack to allow unit testing of category items.
#ifdef UNIT_TEST
# define PREF_CLIENT_CKEY ""
#else
# define PREF_CLIENT_CKEY pref.client.ckey
#endif
/datum/category_group/player_setup_category/general_preferences
name = "General"
sort_order = 1
@@ -18,7 +18,7 @@
"vars" = list(
"skills",
"skill_specialization"
),
),
"args" = list("id")
)
)
@@ -41,7 +41,7 @@
"skills" = list2params(pref.skills),
"skill_specialization" = pref.skill_specialization,
"id" = pref.current_character,
"ckey" = pref.client.ckey
"ckey" = PREF_CLIENT_CKEY
)
/datum/category_item/player_setup_item/skills/sanitize_character(var/sql_load = 0)