diff --git a/code/modules/admin/admin_verb_lists.dm b/code/modules/admin/admin_verb_lists.dm index bee29ed14f8..aa37774d352 100644 --- a/code/modules/admin/admin_verb_lists.dm +++ b/code/modules/admin/admin_verb_lists.dm @@ -186,7 +186,8 @@ var/list/admin_verbs_server = list( /client/proc/panicbunker, /client/proc/paranoia_logging, /client/proc/ip_reputation, - /client/proc/debug_global_variables + /client/proc/debug_global_variables, + /client/proc/dbcon_fix ) var/list/admin_verbs_debug = list( diff --git a/code/modules/admin/verbs/dbcon_fix.dm b/code/modules/admin/verbs/dbcon_fix.dm new file mode 100644 index 00000000000..1d523145202 --- /dev/null +++ b/code/modules/admin/verbs/dbcon_fix.dm @@ -0,0 +1,39 @@ +// Will hoepfully fix the database when it breaks +// Use case: if the server is left in the lobby for long enough, players that join will see player_age = 0, restricting them from all age-locked jobs. +/client/proc/dbcon_fix() + set name = "Fix Database Connection" + set category = "Server" + set desc = "Experimental: Will hopefully perform a one-button fix for a database connection that has timed out." + + if(!check_rights(R_ADMIN|R_DEBUG|R_FUN)) + to_chat(src, "You must be an admin to do this.") + return FALSE + + log_admin("Attempting to fix database connection") + if(dbcon.IsConnected()) + dbcon.Disconnect() + else + log_admin("Database already disconnected") + + establish_db_connection() + var/errno = dbcon.ErrorMsg() + if(errno) + log_admin("Database connection returned error message `[errno]`. Aborting.") + return FALSE + if(!dbcon.IsConnected()) + log_admin("Database could not be reconnected! Aborting.") + return FALSE + log_admin("Database reconnected. Fixing player ages...") + + var/num = 0 + for(var/client/C in GLOB.clients) + C.log_client_to_db() + errno = dbcon.ErrorMsg() + if(errno) + log_admin("Database connection returned error message `[errno]` after adjusting player ages for [num] players. [C] was being updated when the error struck. Aborting.") + return FALSE + if(C.player_age) + num++ + + log_admin("Successfully updated non-0 player age for [num] clients.") + return FALSE \ No newline at end of file diff --git a/vorestation.dme b/vorestation.dme index 3b344e34912..773fff24bad 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -1678,6 +1678,7 @@ #include "code\modules\admin\verbs\check_customitem_activity.dm" #include "code\modules\admin\verbs\cinematic.dm" #include "code\modules\admin\verbs\custom_event.dm" +#include "code\modules\admin\verbs\dbcon_fix.dm" #include "code\modules\admin\verbs\deadsay.dm" #include "code\modules\admin\verbs\debug.dm" #include "code\modules\admin\verbs\debug_vr.dm"