mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Implementing RoundIDs (#7740)
This commit is contained in:
@@ -289,13 +289,31 @@ CREATE TABLE IF NOT EXISTS `vr_player_hours` (
|
||||
|
||||
-- Data exporting was unselected.
|
||||
|
||||
-- CHOMPedit Start - Mentors Database Table
|
||||
-- CHOMPedit Start
|
||||
CREATE TABLE IF NOT EXISTS `erro_mentor` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`mentor` int(16) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) 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
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
|
||||
2
code/_global_vars/logging_ch.dm
Normal file
2
code/_global_vars/logging_ch.dm
Normal file
@@ -0,0 +1,2 @@
|
||||
GLOBAL_VAR(round_id)
|
||||
GLOBAL_PROTECT(round_id)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -95,11 +95,12 @@ SUBSYSTEM_DEF(dbcore)
|
||||
else
|
||||
log_debug("Database is not enabled in configuration.")
|
||||
|
||||
/*/datum/controller/subsystem/dbcore/proc/SetRoundID()
|
||||
/datum/controller/subsystem/dbcore/proc/InitializeRound()
|
||||
if(!Connect())
|
||||
return
|
||||
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]")
|
||||
)
|
||||
query_round_initialize.Execute(async = FALSE)
|
||||
@@ -110,7 +111,8 @@ SUBSYSTEM_DEF(dbcore)
|
||||
if(!Connect())
|
||||
return
|
||||
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)
|
||||
)
|
||||
query_round_start.Execute()
|
||||
@@ -120,11 +122,13 @@ SUBSYSTEM_DEF(dbcore)
|
||||
if(!Connect())
|
||||
return
|
||||
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",
|
||||
list("game_mode_result" = SSticker.mode_result, "station_name" = station_name(), "round_id" = GLOB.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",
|
||||
"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()
|
||||
qdel(query_round_end)*/
|
||||
qdel(query_round_end)
|
||||
|
||||
/datum/controller/subsystem/dbcore/proc/Disconnect()
|
||||
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()
|
||||
rows = null
|
||||
item = null
|
||||
item = null
|
||||
|
||||
@@ -540,6 +540,8 @@ var/global/datum/controller/subsystem/ticker/ticker
|
||||
for(var/i in total_antagonists)
|
||||
log_game("[i]s[total_antagonists[i]].")
|
||||
|
||||
SSdbcore.SetRoundEnd() // CHOMPEdit
|
||||
|
||||
return 1
|
||||
|
||||
/datum/controller/subsystem/ticker/stat_entry()
|
||||
|
||||
@@ -218,6 +218,7 @@ var/global/list/additional_antag_types = list()
|
||||
emergency_shuttle.auto_recall = 1
|
||||
|
||||
feedback_set_details("round_start","[time2text(world.realtime)]")
|
||||
INVOKE_ASYNC(SSdbcore, TYPE_PROC_REF(/datum/controller/subsystem/dbcore,SetRoundStart)) // CHOMPEdit
|
||||
if(ticker && ticker.mode)
|
||||
feedback_set_details("game_mode","[ticker.mode]")
|
||||
feedback_set_details("server_ip","[world.internet_address]:[world.port]")
|
||||
|
||||
@@ -1,102 +1,106 @@
|
||||
/*!
|
||||
* Copyright (c) 2020 Aleksej Komarov
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* tgui_panel datum
|
||||
* Hosts tgchat and other nice features.
|
||||
*/
|
||||
/datum/tgui_panel
|
||||
var/client/client
|
||||
var/datum/tgui_window/window
|
||||
var/broken = FALSE
|
||||
var/initialized_at
|
||||
var/oldchat = FALSE
|
||||
|
||||
/datum/tgui_panel/New(client/client, id)
|
||||
src.client = client
|
||||
window = new(client, id)
|
||||
window.subscribe(src, PROC_REF(on_message))
|
||||
|
||||
/datum/tgui_panel/Del()
|
||||
window.unsubscribe(src)
|
||||
window.close()
|
||||
return ..()
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* TRUE if panel is initialized and ready to receive messages.
|
||||
*/
|
||||
/datum/tgui_panel/proc/is_ready()
|
||||
return !broken && window.is_ready()
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Initializes tgui panel.
|
||||
*/
|
||||
/datum/tgui_panel/proc/initialize(force = FALSE)
|
||||
set waitfor = FALSE
|
||||
// Minimal sleep to defer initialization to after client constructor
|
||||
sleep(1 TICKS)
|
||||
initialized_at = world.time
|
||||
// Perform a clean initialization
|
||||
window.initialize(
|
||||
strict_mode = TRUE,
|
||||
assets = list(
|
||||
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/tgfont))
|
||||
window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat))
|
||||
// Other setup
|
||||
request_telemetry()
|
||||
addtimer(CALLBACK(src, PROC_REF(on_initialize_timed_out)), 5 SECONDS)
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Called when initialization has timed out.
|
||||
*/
|
||||
/datum/tgui_panel/proc/on_initialize_timed_out()
|
||||
// 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>")
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Callback for handling incoming tgui messages.
|
||||
*/
|
||||
/datum/tgui_panel/proc/on_message(type, payload)
|
||||
if(type == "ready")
|
||||
broken = FALSE
|
||||
window.send_message("update", list(
|
||||
"config" = list(
|
||||
"client" = list(
|
||||
"ckey" = client.ckey,
|
||||
"address" = client.address,
|
||||
"computer_id" = client.computer_id,
|
||||
),
|
||||
"window" = list(
|
||||
"fancy" = FALSE,
|
||||
"locked" = FALSE,
|
||||
),
|
||||
),
|
||||
))
|
||||
return TRUE
|
||||
if(type == "audio/setAdminMusicVolume")
|
||||
client.admin_music_volume = payload["volume"]
|
||||
return TRUE
|
||||
if(type == "telemetry")
|
||||
analyze_telemetry(payload)
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Sends a round restart notification.
|
||||
*/
|
||||
/datum/tgui_panel/proc/send_roundrestart()
|
||||
window.send_message("roundrestart")
|
||||
/*!
|
||||
* Copyright (c) 2020 Aleksej Komarov
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* tgui_panel datum
|
||||
* Hosts tgchat and other nice features.
|
||||
*/
|
||||
/datum/tgui_panel
|
||||
var/client/client
|
||||
var/datum/tgui_window/window
|
||||
var/broken = FALSE
|
||||
var/initialized_at
|
||||
var/oldchat = FALSE
|
||||
|
||||
/datum/tgui_panel/New(client/client, id)
|
||||
src.client = client
|
||||
window = new(client, id)
|
||||
window.subscribe(src, PROC_REF(on_message))
|
||||
|
||||
/datum/tgui_panel/Del()
|
||||
window.unsubscribe(src)
|
||||
window.close()
|
||||
return ..()
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* TRUE if panel is initialized and ready to receive messages.
|
||||
*/
|
||||
/datum/tgui_panel/proc/is_ready()
|
||||
return !broken && window.is_ready()
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Initializes tgui panel.
|
||||
*/
|
||||
/datum/tgui_panel/proc/initialize(force = FALSE)
|
||||
set waitfor = FALSE
|
||||
// Minimal sleep to defer initialization to after client constructor
|
||||
sleep(1 TICKS)
|
||||
initialized_at = world.time
|
||||
// Perform a clean initialization
|
||||
window.initialize(
|
||||
strict_mode = TRUE,
|
||||
assets = list(
|
||||
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/tgfont))
|
||||
window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat))
|
||||
// Other setup
|
||||
request_telemetry()
|
||||
addtimer(CALLBACK(src, PROC_REF(on_initialize_timed_out)), 5 SECONDS)
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Called when initialization has timed out.
|
||||
*/
|
||||
/datum/tgui_panel/proc/on_initialize_timed_out()
|
||||
// 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>")
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Callback for handling incoming tgui messages.
|
||||
*/
|
||||
/datum/tgui_panel/proc/on_message(type, payload)
|
||||
if(type == "ready")
|
||||
broken = FALSE
|
||||
window.send_message("update", list(
|
||||
"config" = list(
|
||||
"client" = list(
|
||||
"ckey" = client.ckey,
|
||||
"address" = client.address,
|
||||
"computer_id" = client.computer_id,
|
||||
),
|
||||
// CHOMPEdit - "server" section
|
||||
"server" = list(
|
||||
"round_id" = GLOB.round_id,
|
||||
),
|
||||
"window" = list(
|
||||
"fancy" = FALSE,
|
||||
"locked" = FALSE,
|
||||
),
|
||||
),
|
||||
))
|
||||
return TRUE
|
||||
if(type == "audio/setAdminMusicVolume")
|
||||
client.admin_music_volume = payload["volume"]
|
||||
return TRUE
|
||||
if(type == "telemetry")
|
||||
analyze_telemetry(payload)
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Sends a round restart notification.
|
||||
*/
|
||||
/datum/tgui_panel/proc/send_roundrestart()
|
||||
window.send_message("roundrestart")
|
||||
|
||||
@@ -126,6 +126,7 @@
|
||||
#include "code\__defines\dcs\signals_ch.dm"
|
||||
#include "code\_global_vars\_regexes.dm"
|
||||
#include "code\_global_vars\bitfields.dm"
|
||||
#include "code\_global_vars\logging_ch.dm"
|
||||
#include "code\_global_vars\misc.dm"
|
||||
#include "code\_global_vars\mobs.dm"
|
||||
#include "code\_global_vars\sensitive.dm"
|
||||
|
||||
Reference in New Issue
Block a user