Fix for game modes that uses old master controller process time computation.

This commit is contained in:
eswordthecat
2015-01-22 11:27:57 +08:00
parent e7ac6e0620
commit 49c84608d7
6 changed files with 33 additions and 13 deletions

View File

@@ -18,6 +18,7 @@
#include "code\world.dm"
#include "code\__HELPERS\_macros.dm"
#include "code\__HELPERS\cmp.dm"
#include "code\__HELPERS\constants.dm"
#include "code\__HELPERS\experimental.dm"
#include "code\__HELPERS\files.dm"
#include "code\__HELPERS\game.dm"

View File

@@ -0,0 +1,2 @@
var/global/const/TICKS_IN_DAY = 864000
var/global/const/TICKS_IN_SECOND = 10

View File

@@ -1,13 +1,35 @@
var/global/datum/controller/process/ticker/tickerProcess
/datum/controller/process/ticker
var/lastTickerTimeDuration
var/lastTickerTime
/datum/controller/process/ticker/setup()
name = "ticker"
schedule_interval = 20 // every 2 seconds
lastTickerTime = world.timeofday
if(!ticker)
ticker = new
tickerProcess = src
spawn(0)
if(ticker)
ticker.pregame()
/datum/controller/process/ticker/doWork()
var/currentTime = world.timeofday
if(currentTime < lastTickerTime) // check for midnight rollover
lastTickerTimeDuration = (currentTime - (lastTickerTime - TICKS_IN_DAY)) / TICKS_IN_SECOND
else
lastTickerTimeDuration = (currentTime - lastTickerTime) / TICKS_IN_SECOND
lastTickerTime = currentTime
ticker.process()
/datum/controller/process/ticker/proc/getLastTickerTimeDuration()
return lastTickerTimeDuration

View File

@@ -4,7 +4,6 @@
var/global/datum/controller/game_controller/master_controller //Set in world.New()
var/global/last_tick_timeofday = world.timeofday
var/global/last_tick_duration = 0
var/global/air_processing_killed = 0
@@ -144,10 +143,6 @@ datum/controller/game_controller/proc/setup_objects()
if (isnull(failsafe))
new /datum/controller/failsafe()
var/currenttime = world.timeofday
last_tick_duration = (currenttime - last_tick_timeofday) / 10
last_tick_timeofday = currenttime
if (processing)
iteration++
var/timer

View File

@@ -100,12 +100,12 @@ Once done, you will be able to interface with all systems, notably the onboard n
/datum/game_mode/malfunction/process()
if(apcs >= 3 && malf_mode_declared)
AI_win_timeleft -= ((apcs/6)*last_tick_duration) //Victory timer now de-increments based on how many APCs are hacked. --NeoFite
AI_win_timeleft -= ((apcs / 6) * tickerProcess.getLastTickerTimeDuration()) //Victory timer now de-increments based on how many APCs are hacked. --NeoFite
..()
if(AI_win_timeleft <= 0)
check_win()
return
/datum/game_mode/malfunction/check_win()
if (AI_win_timeleft <= 0 && !station_captured)

View File

@@ -1257,8 +1257,8 @@ note dizziness decrements automatically in the mob's Life() proc.
stat(null, "Instances:\t[world.contents.len]")
if (master_controller)
stat(null, "MasterController-[last_tick_duration] ([master_controller.processing?"On":"Off"]-[master_controller.iteration])")
/*stat(null, "Air-[master_controller.air_cost]")
/*stat(null, "MasterController-[last_tick_duration] ([master_controller.processing?"On":"Off"]-[master_controller.iteration])")
stat(null, "Air-[master_controller.air_cost]")
stat(null, "Sun-[master_controller.sun_cost]")
stat(null, "Mob-[master_controller.mobs_cost]\t#[mob_list.len]")
stat(null, "Dis-[master_controller.diseases_cost]\t#[active_diseases.len]")