mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Splits up round table initialize, start, end and shutdown (#37665)
For planned change to how TGS initializes server instances ahead of time so rounds aren't tracked as being far longer than they really would be. Similarly end time split for a more accurate round duration.
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255.
|
||||
|
||||
The latest database version is 4.3; The query to update the schema revision table is:
|
||||
The latest database version is 4.4; The query to update the schema revision table is:
|
||||
|
||||
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (4, 3);
|
||||
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (4, 4);
|
||||
or
|
||||
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (4, 3);
|
||||
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (4, 4);
|
||||
|
||||
In any query remember to add a prefix to the table names if you use one.
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Version 4.4, 9 May 2018, by Jordie0608
|
||||
Modified table `round`, renaming column `start_datetime` to `initialize_datetime` and `end_datetime` to `shutdown_datetime` and adding columns to replace both under the same name in preparation for changes to TGS server initialization.
|
||||
|
||||
ALTER TABLE `round`
|
||||
ALTER `start_datetime` DROP DEFAULT;
|
||||
ALTER TABLE `round`
|
||||
CHANGE COLUMN `start_datetime` `initialize_datetime` DATETIME NOT NULL AFTER `id`,
|
||||
ADD COLUMN `start_datetime` DATETIME NULL DEFAULT NULL AFTER `initialize_datetime`,
|
||||
CHANGE COLUMN `end_datetime` `shutdown_datetime` DATETIME NULL DEFAULT NULL AFTER `start_datetime`,
|
||||
ADD COLUMN `end_datetime` DATETIME NULL DEFAULT NULL AFTER `shutdown_datetime`;
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Version 4.3, 9 May 2018, by MrStonedOne
|
||||
Added table `role_time_log` and triggers `role_timeTlogupdate`, `role_timeTloginsert` and `role_timeTlogdelete` to update it from changes to `role_time`
|
||||
|
||||
|
||||
@@ -421,7 +421,9 @@ DROP TABLE IF EXISTS `round`;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `round` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`start_datetime` DATETIME NOT NULL,
|
||||
`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,
|
||||
|
||||
@@ -421,7 +421,9 @@ DROP TABLE IF EXISTS `SS13_round`;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `SS13_round` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`start_datetime` DATETIME NOT NULL,
|
||||
`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,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//Update this whenever the db schema changes
|
||||
//make sure you add an update to the schema_version stable in the db changelog
|
||||
#define DB_MAJOR_VERSION 4
|
||||
#define DB_MINOR_VERSION 3
|
||||
#define DB_MINOR_VERSION 4
|
||||
|
||||
//Timing subsystem
|
||||
//Don't run if there is an identical unique timer active
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
log_game("[i]s[total_antagonists[i]].")
|
||||
|
||||
CHECK_TICK
|
||||
|
||||
SSdbcore.SetRoundEnd()
|
||||
//Collects persistence features
|
||||
if(mode.allow_persistence_save)
|
||||
SSpersistence.CollectData()
|
||||
|
||||
@@ -37,19 +37,18 @@ SUBSYSTEM_DEF(dbcore)
|
||||
message_admins("Database schema ([db_major].[db_minor]) doesn't match the latest schema version ([DB_MAJOR_VERSION].[DB_MINOR_VERSION]), this may lead to undefined behaviour or errors")
|
||||
if(2)
|
||||
message_admins("Could not get schema version from database")
|
||||
|
||||
|
||||
return ..()
|
||||
|
||||
|
||||
|
||||
/datum/controller/subsystem/dbcore/Recover()
|
||||
_db_con = SSdbcore._db_con
|
||||
|
||||
/datum/controller/subsystem/dbcore/Shutdown()
|
||||
//This is as close as we can get to the true round end before Disconnect() without changing where it's called, defeating the reason this is a subsystem
|
||||
if(SSdbcore.Connect())
|
||||
var/sql_station_name = sanitizeSQL(station_name())
|
||||
var/datum/DBQuery/query_round_end = SSdbcore.NewQuery("UPDATE [format_table_name("round")] SET end_datetime = Now(), game_mode_result = '[sanitizeSQL(SSticker.mode_result)]', end_state = '[sanitizeSQL(SSticker.end_state)]', station_name = '[sql_station_name]' WHERE id = [GLOB.round_id]")
|
||||
query_round_end.Execute()
|
||||
var/datum/DBQuery/query_round_shutdown = SSdbcore.NewQuery("UPDATE [format_table_name("round")] SET shutdown_datetime = Now(), end_state = '[sanitizeSQL(SSticker.end_state)]' WHERE id = [GLOB.round_id]")
|
||||
query_round_shutdown.Execute()
|
||||
if(IsConnected())
|
||||
Disconnect()
|
||||
|
||||
@@ -107,13 +106,26 @@ SUBSYSTEM_DEF(dbcore)
|
||||
/datum/controller/subsystem/dbcore/proc/SetRoundID()
|
||||
if(CONFIG_GET(flag/sql_enabled))
|
||||
if(SSdbcore.Connect())
|
||||
var/datum/DBQuery/query_round_start = SSdbcore.NewQuery("INSERT INTO [format_table_name("round")] (start_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(IF('[world.internet_address]' LIKE '', '0', '[world.internet_address]')), '[world.port]')")
|
||||
query_round_start.Execute()
|
||||
var/datum/DBQuery/query_round_initialize = SSdbcore.NewQuery("INSERT INTO [format_table_name("round")] (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(IF('[world.internet_address]' LIKE '', '0', '[world.internet_address]')), '[world.port]')")
|
||||
query_round_initialize.Execute()
|
||||
var/datum/DBQuery/query_round_last_id = SSdbcore.NewQuery("SELECT LAST_INSERT_ID()")
|
||||
query_round_last_id.Execute()
|
||||
if(query_round_last_id.NextRow())
|
||||
GLOB.round_id = query_round_last_id.item[1]
|
||||
|
||||
/datum/controller/subsystem/dbcore/proc/SetRoundStart()
|
||||
if(CONFIG_GET(flag/sql_enabled))
|
||||
if(SSdbcore.Connect())
|
||||
var/datum/DBQuery/query_round_start = SSdbcore.NewQuery("UPDATE [format_table_name("round")] SET start_datetime = Now() WHERE id = [GLOB.round_id]")
|
||||
query_round_start.Execute()
|
||||
|
||||
/datum/controller/subsystem/dbcore/proc/SetRoundEnd()
|
||||
if(CONFIG_GET(flag/sql_enabled))
|
||||
if(SSdbcore.Connect())
|
||||
var/sql_station_name = sanitizeSQL(station_name())
|
||||
var/datum/DBQuery/query_round_end = SSdbcore.NewQuery("UPDATE [format_table_name("round")] SET end_datetime = Now(), game_mode_result = '[sanitizeSQL(SSticker.mode_result)]', station_name = '[sql_station_name]' WHERE id = [GLOB.round_id]")
|
||||
query_round_end.Execute()
|
||||
|
||||
/datum/controller/subsystem/dbcore/proc/Disconnect()
|
||||
failed_connections = 0
|
||||
return _dm_db_close(_db_con)
|
||||
|
||||
@@ -282,6 +282,7 @@ SUBSYSTEM_DEF(ticker)
|
||||
|
||||
log_world("Game start took [(world.timeofday - init_start)/10]s")
|
||||
round_start_time = world.time
|
||||
SSdbcore.SetRoundStart()
|
||||
|
||||
to_chat(world, "<FONT color='blue'><B>Welcome to [station_name()], enjoy your stay!</B></FONT>")
|
||||
SEND_SOUND(world, sound('sound/ai/welcome.ogg'))
|
||||
|
||||
Reference in New Issue
Block a user