Implementing RoundIDs (#7740)

This commit is contained in:
Selis
2024-02-14 03:07:35 +01:00
committed by GitHub
parent 64729dea85
commit e9effb63f5
8 changed files with 1317 additions and 1283 deletions

View File

@@ -289,13 +289,31 @@ CREATE TABLE IF NOT EXISTS `vr_player_hours` (
-- Data exporting was unselected. -- Data exporting was unselected.
-- CHOMPedit Start - Mentors Database Table -- CHOMPedit Start
CREATE TABLE IF NOT EXISTS `erro_mentor` ( CREATE TABLE IF NOT EXISTS `erro_mentor` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`ckey` varchar(32) NOT NULL, `ckey` varchar(32) NOT NULL,
`mentor` int(16) NOT NULL DEFAULT 0, `mentor` int(16) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT; ) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
CREATE TABLE IF NOT EXISTS `round` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`initialize_datetime` DATETIME NOT NULL,
`start_datetime` DATETIME NULL,
`shutdown_datetime` DATETIME NULL,
`end_datetime` DATETIME NULL,
`server_ip` INT(10) UNSIGNED NOT NULL,
`server_port` SMALLINT(5) UNSIGNED NOT NULL,
`commit_hash` CHAR(40) NULL,
`game_mode` VARCHAR(32) NULL,
`game_mode_result` VARCHAR(64) NULL,
`end_state` VARCHAR(64) NULL,
`shuttle_name` VARCHAR(64) NULL,
`map_name` VARCHAR(32) NULL,
`station_name` VARCHAR(80) NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- CHOMPedit End -- CHOMPedit End
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;

View File

@@ -0,0 +1,2 @@
GLOBAL_VAR(round_id)
GLOBAL_PROTECT(round_id)

File diff suppressed because it is too large Load Diff

View File

@@ -95,11 +95,12 @@ SUBSYSTEM_DEF(dbcore)
else else
log_debug("Database is not enabled in configuration.") log_debug("Database is not enabled in configuration.")
/*/datum/controller/subsystem/dbcore/proc/SetRoundID() /datum/controller/subsystem/dbcore/proc/InitializeRound()
if(!Connect()) if(!Connect())
return return
var/DBQuery/query_round_initialize = SSdbcore.NewQuery( var/DBQuery/query_round_initialize = SSdbcore.NewQuery(
"INSERT INTO [format_table_name("round")] (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(:internet_address), :port)", //"INSERT INTO [format_table_name("round")] (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(:internet_address), :port)",
"INSERT INTO round (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(:internet_address), :port)",
list("internet_address" = world.internet_address || "0", "port" = "[world.port]") list("internet_address" = world.internet_address || "0", "port" = "[world.port]")
) )
query_round_initialize.Execute(async = FALSE) query_round_initialize.Execute(async = FALSE)
@@ -110,7 +111,8 @@ SUBSYSTEM_DEF(dbcore)
if(!Connect()) if(!Connect())
return return
var/DBQuery/query_round_start = SSdbcore.NewQuery( var/DBQuery/query_round_start = SSdbcore.NewQuery(
"UPDATE [format_table_name("round")] SET start_datetime = Now() WHERE id = :round_id", //"UPDATE [format_table_name("round")] SET start_datetime = Now() WHERE id = :round_id",
"UPDATE round SET start_datetime = Now() WHERE id = :round_id",
list("round_id" = GLOB.round_id) list("round_id" = GLOB.round_id)
) )
query_round_start.Execute() query_round_start.Execute()
@@ -120,11 +122,13 @@ SUBSYSTEM_DEF(dbcore)
if(!Connect()) if(!Connect())
return return
var/DBQuery/query_round_end = SSdbcore.NewQuery( var/DBQuery/query_round_end = SSdbcore.NewQuery(
"UPDATE [format_table_name("round")] SET end_datetime = Now(), game_mode_result = :game_mode_result, station_name = :station_name WHERE id = :round_id", //"UPDATE [format_table_name("round")] SET end_datetime = Now(), game_mode_result = :game_mode_result, station_name = :station_name WHERE id = :round_id",
list("game_mode_result" = SSticker.mode_result, "station_name" = station_name(), "round_id" = GLOB.round_id) "UPDATE round SET end_datetime = Now(), game_mode_result = :game_mode_result, station_name = :station_name WHERE id = :round_id",
//list("game_mode_result" = SSticker.mode_result, "station_name" = station_name(), "round_id" = GLOB.round_id)
list("game_mode_result" = "extended", "station_name" = station_name(), "round_id" = GLOB.round_id) // FIXME: temporary solution as we only use extended so far
) )
query_round_end.Execute() query_round_end.Execute()
qdel(query_round_end)*/ qdel(query_round_end)
/datum/controller/subsystem/dbcore/proc/Disconnect() /datum/controller/subsystem/dbcore/proc/Disconnect()
failed_connections = 0 failed_connections = 0
@@ -367,4 +371,4 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
/DBQuery/proc/Close() /DBQuery/proc/Close()
rows = null rows = null
item = null item = null

View File

@@ -540,6 +540,8 @@ var/global/datum/controller/subsystem/ticker/ticker
for(var/i in total_antagonists) for(var/i in total_antagonists)
log_game("[i]s[total_antagonists[i]].") log_game("[i]s[total_antagonists[i]].")
SSdbcore.SetRoundEnd() // CHOMPEdit
return 1 return 1
/datum/controller/subsystem/ticker/stat_entry() /datum/controller/subsystem/ticker/stat_entry()

View File

@@ -218,6 +218,7 @@ var/global/list/additional_antag_types = list()
emergency_shuttle.auto_recall = 1 emergency_shuttle.auto_recall = 1
feedback_set_details("round_start","[time2text(world.realtime)]") feedback_set_details("round_start","[time2text(world.realtime)]")
INVOKE_ASYNC(SSdbcore, TYPE_PROC_REF(/datum/controller/subsystem/dbcore,SetRoundStart)) // CHOMPEdit
if(ticker && ticker.mode) if(ticker && ticker.mode)
feedback_set_details("game_mode","[ticker.mode]") feedback_set_details("game_mode","[ticker.mode]")
feedback_set_details("server_ip","[world.internet_address]:[world.port]") feedback_set_details("server_ip","[world.internet_address]:[world.port]")

View File

@@ -1,102 +1,106 @@
/*! /*!
* Copyright (c) 2020 Aleksej Komarov * Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/** /**
* tgui_panel datum * tgui_panel datum
* Hosts tgchat and other nice features. * Hosts tgchat and other nice features.
*/ */
/datum/tgui_panel /datum/tgui_panel
var/client/client var/client/client
var/datum/tgui_window/window var/datum/tgui_window/window
var/broken = FALSE var/broken = FALSE
var/initialized_at var/initialized_at
var/oldchat = FALSE var/oldchat = FALSE
/datum/tgui_panel/New(client/client, id) /datum/tgui_panel/New(client/client, id)
src.client = client src.client = client
window = new(client, id) window = new(client, id)
window.subscribe(src, PROC_REF(on_message)) window.subscribe(src, PROC_REF(on_message))
/datum/tgui_panel/Del() /datum/tgui_panel/Del()
window.unsubscribe(src) window.unsubscribe(src)
window.close() window.close()
return ..() return ..()
/** /**
* public * public
* *
* TRUE if panel is initialized and ready to receive messages. * TRUE if panel is initialized and ready to receive messages.
*/ */
/datum/tgui_panel/proc/is_ready() /datum/tgui_panel/proc/is_ready()
return !broken && window.is_ready() return !broken && window.is_ready()
/** /**
* public * public
* *
* Initializes tgui panel. * Initializes tgui panel.
*/ */
/datum/tgui_panel/proc/initialize(force = FALSE) /datum/tgui_panel/proc/initialize(force = FALSE)
set waitfor = FALSE set waitfor = FALSE
// Minimal sleep to defer initialization to after client constructor // Minimal sleep to defer initialization to after client constructor
sleep(1 TICKS) sleep(1 TICKS)
initialized_at = world.time initialized_at = world.time
// Perform a clean initialization // Perform a clean initialization
window.initialize( window.initialize(
strict_mode = TRUE, strict_mode = TRUE,
assets = list( assets = list(
get_asset_datum(/datum/asset/simple/tgui_panel), get_asset_datum(/datum/asset/simple/tgui_panel),
)) ))
window.send_asset(get_asset_datum(/datum/asset/simple/fontawesome)) window.send_asset(get_asset_datum(/datum/asset/simple/fontawesome))
window.send_asset(get_asset_datum(/datum/asset/simple/tgfont)) window.send_asset(get_asset_datum(/datum/asset/simple/tgfont))
window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat)) window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat))
// Other setup // Other setup
request_telemetry() request_telemetry()
addtimer(CALLBACK(src, PROC_REF(on_initialize_timed_out)), 5 SECONDS) addtimer(CALLBACK(src, PROC_REF(on_initialize_timed_out)), 5 SECONDS)
/** /**
* private * private
* *
* Called when initialization has timed out. * Called when initialization has timed out.
*/ */
/datum/tgui_panel/proc/on_initialize_timed_out() /datum/tgui_panel/proc/on_initialize_timed_out()
// Currently does nothing but sending a message to old chat. // Currently does nothing but sending a message to old chat.
// SEND_TEXT(client, "<span class=\"userdanger\">Failed to load fancy chat, click <a href='?src=[REF(src)];reload_tguipanel=1'>HERE</a> to attempt to reload it.</span>") // SEND_TEXT(client, "<span class=\"userdanger\">Failed to load fancy chat, click <a href='?src=[REF(src)];reload_tguipanel=1'>HERE</a> to attempt to reload it.</span>")
/** /**
* private * private
* *
* Callback for handling incoming tgui messages. * Callback for handling incoming tgui messages.
*/ */
/datum/tgui_panel/proc/on_message(type, payload) /datum/tgui_panel/proc/on_message(type, payload)
if(type == "ready") if(type == "ready")
broken = FALSE broken = FALSE
window.send_message("update", list( window.send_message("update", list(
"config" = list( "config" = list(
"client" = list( "client" = list(
"ckey" = client.ckey, "ckey" = client.ckey,
"address" = client.address, "address" = client.address,
"computer_id" = client.computer_id, "computer_id" = client.computer_id,
), ),
"window" = list( // CHOMPEdit - "server" section
"fancy" = FALSE, "server" = list(
"locked" = FALSE, "round_id" = GLOB.round_id,
), ),
), "window" = list(
)) "fancy" = FALSE,
return TRUE "locked" = FALSE,
if(type == "audio/setAdminMusicVolume") ),
client.admin_music_volume = payload["volume"] ),
return TRUE ))
if(type == "telemetry") return TRUE
analyze_telemetry(payload) if(type == "audio/setAdminMusicVolume")
return TRUE client.admin_music_volume = payload["volume"]
return TRUE
/** if(type == "telemetry")
* public analyze_telemetry(payload)
* return TRUE
* Sends a round restart notification.
*/ /**
/datum/tgui_panel/proc/send_roundrestart() * public
window.send_message("roundrestart") *
* Sends a round restart notification.
*/
/datum/tgui_panel/proc/send_roundrestart()
window.send_message("roundrestart")

View File

@@ -126,6 +126,7 @@
#include "code\__defines\dcs\signals_ch.dm" #include "code\__defines\dcs\signals_ch.dm"
#include "code\_global_vars\_regexes.dm" #include "code\_global_vars\_regexes.dm"
#include "code\_global_vars\bitfields.dm" #include "code\_global_vars\bitfields.dm"
#include "code\_global_vars\logging_ch.dm"
#include "code\_global_vars\misc.dm" #include "code\_global_vars\misc.dm"
#include "code\_global_vars\mobs.dm" #include "code\_global_vars\mobs.dm"
#include "code\_global_vars\sensitive.dm" #include "code\_global_vars\sensitive.dm"