diff --git a/code/datums/configuration.dm b/code/datums/configuration.dm index 1fb3c027bf..68f358abc2 100644 --- a/code/datums/configuration.dm +++ b/code/datums/configuration.dm @@ -288,6 +288,12 @@ sqllogin = value if ("password") sqlpass = value + if ("feedback_database") + sqlfdbkdb = value + if ("feedback_login") + sqlfdbklogin = value + if ("feedback_password") + sqlfdbkpass = value if ("enable_stat_tracking") sqllogging = 1 else diff --git a/code/defines/global.dm b/code/defines/global.dm index 7c735b1f6b..33258062da 100644 --- a/code/defines/global.dm +++ b/code/defines/global.dm @@ -177,6 +177,12 @@ var sqllogin = "root" sqlpass = "" + // Feedback gathering sql connection + + sqlfdbkdb = "test" + sqlfdbklogin = "root" + sqlfdbkpass = "" + sqllogging = 0 // Should we log deaths, population stats, etc? diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 844f1c11ea..754e7d8936 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -49,6 +49,9 @@ ///post_setup() ///Everyone should now be on the station and have their normal gear. This is the place to give the special roles extra things /datum/game_mode/proc/post_setup() + feedback_set_details("round_start","[time2text(world.realtime)]") + if(ticker && ticker.mode) + feedback_set_details("game_mode","[ticker.mode]") return 1 diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index c2223f9d17..bb4c9775e9 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -207,4 +207,8 @@ var/global/datum/controller/gameticker/ticker if (findtext("[handler]","auto_declare_completion_")) call(mode, handler)() + feedback_set_details("round_end","[time2text(world.realtime)]") + if(blackbox) + blackbox.save_all_data_to_sql() + return 1 diff --git a/code/modules/research/message_server.dm b/code/modules/research/message_server.dm index 4d6966a54c..4b7ca85e7d 100644 --- a/code/modules/research/message_server.dm +++ b/code/modules/research/message_server.dm @@ -68,6 +68,7 @@ /datum/feedback_variable var/variable var/value + var/details New(var/param_variable,var/param_value = 0) variable = param_variable @@ -103,8 +104,15 @@ proc/get_variable() return variable + proc/set_details(var/text) + if(istext(text)) + details = text + + proc/get_details() + return details + proc/get_parsed() - return list(variable,value) + return list(variable,value,details) var/obj/machinery/blackbox_recorder/blackbox @@ -135,8 +143,8 @@ var/obj/machinery/blackbox_recorder/blackbox //Only one can exsist in the world! New() - for(var/obj/machinery/blackbox_recorder/BR in world) - if(BR != src) + if(blackbox) + if(istype(blackbox,/obj/machinery/blackbox_recorder)) del(src) blackbox = src @@ -151,6 +159,31 @@ var/obj/machinery/blackbox_recorder/blackbox proc/get_round_feedback() return feedback + //This proc is only to be called at round end. + proc/save_all_data_to_sql() + if(!feedback) return + + var/DBConnection/dbcon = new() + dbcon.Connect("dbi:mysql:test:fornoreason.servehttp.com:3306","erro","3rr0HatesGlov3s") + if(!dbcon.IsConnected()) return + var/round_id + + var/DBQuery/query = dbcon.NewQuery("SELECT MAX(round_id) AS round_id FROM erro_feedback") + query.Execute() + while(query.NextRow()) + round_id = query.item[1] + + if(!isnum(round_id)) + round_id = text2num(round_id) + round_id++ + + for(var/datum/feedback_variable/FV in feedback) + var/sql = "INSERT INTO erro_feedback VALUES (null, Now(), [round_id], \"[FV.get_variable()]\", [FV.get_value()], \"[FV.get_details()]\")" + var/DBQuery/query_insert = dbcon.NewQuery(sql) + query_insert.Execute() + + dbcon.Disconnect() + proc/feedback_set(var/variable,var/value) if(!blackbox) return @@ -176,4 +209,13 @@ proc/feedback_dec(var/variable,var/value) if(!FV) return - FV.dec(value) \ No newline at end of file + FV.dec(value) + +proc/feedback_set_details(var/variable,var/details) + if(!blackbox) return + + var/datum/feedback_variable/FV = blackbox.find_feedback_datum(variable) + + if(!FV) return + + FV.set_details(details) \ No newline at end of file diff --git a/config/dbconfig.txt b/config/dbconfig.txt index 92508a18d1..a0d6f28b7b 100644 --- a/config/dbconfig.txt +++ b/config/dbconfig.txt @@ -16,6 +16,11 @@ LOGIN mylogin # Password used to access the database PASSWORD mypassword +# The following information is for feedback tracking via the blackbox server +FEEDBACK_DATABASE test +FEEDBACK_LOGIN mylogin +FEEDBACK_PASSWORD mypassword + # Track population and death statistics # Comment this out to disable ENABLE_STAT_TRACKING \ No newline at end of file