mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-13 16:13:19 +01:00
Cleans up some awful code from the ticker
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
SUBSYSTEM_DEF(statistics)
|
||||
name = "Statistics"
|
||||
wait = 6000 // 10 minute delay between fires
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME // Only count time actually ingame to avoid logging pre-round dips
|
||||
offline_implications = "Player count and admin count statistics will no longer be logged to the database. No immediate action is needed."
|
||||
|
||||
|
||||
/datum/controller/subsystem/statistics/Initialize(start_timeofday)
|
||||
if(!config.sql_enabled)
|
||||
flags |= SS_NO_FIRE // Disable firing if SQL is disabled
|
||||
return ..()
|
||||
|
||||
/datum/controller/subsystem/statistics/fire(resumed = 0)
|
||||
sql_poll_players()
|
||||
|
||||
/datum/controller/subsystem/statistics/proc/sql_poll_players()
|
||||
if(!config.sql_enabled)
|
||||
return
|
||||
var/playercount = GLOB.clients.len
|
||||
var/admincount = GLOB.admins.len
|
||||
if(!GLOB.dbcon.IsConnected())
|
||||
log_game("SQL ERROR during player polling. Failed to connect.")
|
||||
else
|
||||
var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
|
||||
var/DBQuery/query = GLOB.dbcon.NewQuery("INSERT INTO [format_table_name("legacy_population")] (playercount, admincount, time) VALUES ([playercount], [admincount], '[sqltime]')")
|
||||
if(!query.Execute())
|
||||
var/err = query.ErrorMsg()
|
||||
log_game("SQL ERROR during playercount polling. Error: \[[err]\]\n")
|
||||
@@ -29,7 +29,7 @@ SUBSYSTEM_DEF(ticker)
|
||||
var/pregame_timeleft // This is used for calculations
|
||||
var/delay_end = 0 //if set to nonzero, the round will not restart on it's own
|
||||
var/triai = 0//Global holder for Triumvirate
|
||||
var/initialtpass = 0 //holder for inital autotransfer vote timer
|
||||
var/next_autotransfer = 0 //holder for inital autotransfer vote timer
|
||||
var/obj/screen/cinematic = null //used for station explosion cinematic
|
||||
var/round_end_announced = 0 // Spam Prevention. Announce round end only once.
|
||||
var/ticker_going = TRUE // This used to be in the unused globals, but it turns out its actually used in a load of places. Its now a ticker var because its related to round stuff, -aa
|
||||
@@ -90,6 +90,11 @@ SUBSYSTEM_DEF(ticker)
|
||||
delay_end = 0 // reset this in case round start was delayed
|
||||
mode.process()
|
||||
mode.process_job_tasks()
|
||||
|
||||
if(world.time > next_autotransfer)
|
||||
SSvote.autotransfer()
|
||||
next_autotransfer = world.time + config.vote_autotransfer_interval
|
||||
|
||||
var/game_finished = SSshuttle.emergency.mode >= SHUTTLE_ENDGAME || mode.station_was_nuked
|
||||
if(config.continuous_rounds)
|
||||
mode.check_finished() // some modes contain var-changing code in here, so call even if we don't uses result
|
||||
@@ -111,19 +116,6 @@ SUBSYSTEM_DEF(ticker)
|
||||
else
|
||||
world.Reboot("Round ended.", "end_proper", "proper completion")
|
||||
|
||||
|
||||
/datum/controller/subsystem/ticker/proc/votetimer()
|
||||
var/timerbuffer = 0
|
||||
if(initialtpass == 0)
|
||||
timerbuffer = config.vote_autotransfer_initial
|
||||
else
|
||||
timerbuffer = config.vote_autotransfer_interval
|
||||
spawn(timerbuffer)
|
||||
SSvote.autotransfer()
|
||||
initialtpass = 1
|
||||
votetimer()
|
||||
|
||||
|
||||
/datum/controller/subsystem/ticker/proc/setup()
|
||||
cultdat = setupcult()
|
||||
//Create and announce mode
|
||||
@@ -281,11 +273,8 @@ SUBSYSTEM_DEF(ticker)
|
||||
auto_toggle_ooc(0) // Turn it off
|
||||
round_start_time = world.time
|
||||
|
||||
if(config.sql_enabled)
|
||||
spawn(3000)
|
||||
statistic_cycle() // Polls population totals regularly and stores them in an SQL DB
|
||||
|
||||
votetimer()
|
||||
// Sets the auto shuttle vote to happen after the config duration
|
||||
next_autotransfer = world.time + config.vote_autotransfer_initial
|
||||
|
||||
for(var/mob/new_player/N in GLOB.mob_list)
|
||||
if(N.client)
|
||||
|
||||
Reference in New Issue
Block a user