Merge pull request #836 from skull132/SQL-updates

Sql updates
This commit is contained in:
skull132
2016-01-08 13:53:08 +02:00
3 changed files with 46 additions and 3 deletions
+11 -3
View File
@@ -117,7 +117,12 @@ DBQuery/proc/Execute(var/list/argument_list = null, var/pass_not_found = 0, sql_
if (argument_list)
sql_query = parseArguments(sql_query, argument_list, pass_not_found)
return _dm_db_execute(_db_query, sql_query, db_connection._db_con, cursor_handler, null)
var/return_value = _dm_db_execute(_db_query, sql_query, db_connection._db_con, cursor_handler, null)
if (ErrorMsg())
log_debug("SQL Error: [ErrorMsg()]")
return return_value
DBQuery/proc/NextRow()
return _dm_db_next_row(_db_query,item,conversions)
@@ -176,13 +181,15 @@ DBQuery/proc/SetConversion(column,conversion)
*/
DBQuery/proc/parseArguments(var/query_to_parse = null, var/list/argument_list, var/pass_not_found = 0)
if (!query_to_parse || !argument_list || !argument_list.len)
log_debug("SQL Error: parseArguments() called with an empty query_to_parse or argument_list.")
return 0
for (var/placeholder in argument_list)
if (!findtextEx(sql, placeholder))
if (!findtextEx(query_to_parse, placeholder))
if (pass_not_found)
continue
else
log_debug("SQL Error: parseArguments() failed to find placeholder. Placeholder value: [placeholder].")
return 0
var/argument = argument_list[placeholder]
@@ -194,9 +201,10 @@ DBQuery/proc/parseArguments(var/query_to_parse = null, var/list/argument_list, v
else if (isnum(argument))
argument = "'[argument]'"
else
log_debug("SQL Error: parseArguments() failed to identify argument type. Placeholder value: [placeholder].")
return 0
query_to_parse = replacetextEx(sql, placeholder, argument)
query_to_parse = replacetextEx(query_to_parse, placeholder, argument)
return query_to_parse
+24
View File
@@ -148,6 +148,7 @@ Implants;
var/surviving_total = 0
var/ghosts = 0
var/escaped_humans = 0
var/species_stats = list("Humans" = 0, "Unathi" = 0, "Tajaran" = 0, "Skrell" = 0, "Vaurca" = 0, "IPC" = 0, "Diona" = 0)
var/escaped_total = 0
var/escaped_on_pod_1 = 0
var/escaped_on_pod_2 = 0
@@ -165,6 +166,23 @@ Implants;
surviving_humans++
if(M.loc && M.loc.loc && M.loc.loc.type in escape_locations)
escaped_humans++
var/mob/living/carbon/human/H = M
if (H.species)
switch (H.species.name)
if ("Human")
species_stats["Human"]++
if ("Unathi")
species_stats["Unathi"]++
if ("Tajaran")
species_stats["Tajaran"]++
if ("Skrell")
species_stats["Skrell"]++
if ("Vaurca")
species_stats["Vaurca"]++
if ("Machine")
species_stats["IPC"]++
if ("Diona")
species_stats["Diona"]++
if(!M.stat)
surviving_total++
if(M.loc && M.loc.loc && M.loc.loc.type in escape_locations)
@@ -191,6 +209,12 @@ Implants;
feedback_set("round_end_ghosts",ghosts)
if(surviving_humans > 0)
feedback_set("survived_human",surviving_humans)
var/species_stats_string = ""
for (var/species_name in species_stats)
species_stats_string += "[species_name]: [species_stats[species_name]], "
feedback_set("species_statistics", species_stats_string)
if(surviving_total > 0)
feedback_set("survived_total",surviving_total)
if(escaped_humans > 0)
+11
View File
@@ -423,4 +423,15 @@ proc/establish_db_connection()
else
return 1
//This proc disconnects the database forcefully, and then establishes connection again.
proc/cycle_db_connection()
if (!dbcon)
return 0
log_debug("Cycling database connection.")
dbcon.Disconnect()
sleep(5)
setup_database_connection()
#undef FAILED_DB_CONNECTION_CUTOFF