Refactors roundstart checks slightly (#26131)

* Refactors roundstart checks slightly

* Fix
This commit is contained in:
Cyberboss
2017-04-26 18:05:41 -04:00
committed by oranges
parent 729010bbb2
commit 6c6fc719ec
18 changed files with 28 additions and 25 deletions

View File

@@ -513,7 +513,7 @@
winset(C, "mainwindow", "flash=5") winset(C, "mainwindow", "flash=5")
/proc/AnnounceArrival(var/mob/living/carbon/human/character, var/rank) /proc/AnnounceArrival(var/mob/living/carbon/human/character, var/rank)
if(SSticker.current_state != GAME_STATE_PLAYING || !character) if(!SSticker.IsRoundInProgress() || !character)
return return
var/area/A = get_area(character) var/area/A = get_area(character)
var/message = "<span class='game deadsay'><span class='name'>\ var/message = "<span class='game deadsay'><span class='name'>\

View File

@@ -48,7 +48,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
var/initializations_finished_with_no_players_logged_in //I wonder what this could be? var/initializations_finished_with_no_players_logged_in //I wonder what this could be?
// Has round started? (So we know what subsystems to run) // Has round started? (So we know what subsystems to run)
var/round_started = 0 var/local_round_started = FALSE //Don't read this var, use SSticker.HasRoundStarted() instead
// The type of the last subsystem to be process()'d. // The type of the last subsystem to be process()'d.
var/last_type_processed var/last_type_processed
@@ -189,7 +189,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
// Notify the MC that the round has started. // Notify the MC that the round has started.
/datum/controller/master/proc/RoundStart() /datum/controller/master/proc/RoundStart()
round_started = 1 local_round_started = TRUE
var/timer = world.time var/timer = world.time
for (var/datum/controller/subsystem/SS in subsystems) for (var/datum/controller/subsystem/SS in subsystems)
if (SS.flags & SS_FIRE_IN_LOBBY || SS.flags & SS_TICKER) if (SS.flags & SS_FIRE_IN_LOBBY || SS.flags & SS_TICKER)
@@ -222,7 +222,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
// local vars rock // local vars rock
// Schedule the first run of the Subsystems. // Schedule the first run of the Subsystems.
round_started = world.has_round_started() local_round_started = world.has_round_started()
//all this shit is here so that flag edits can be refreshed by restarting the MC. (and for speed) //all this shit is here so that flag edits can be refreshed by restarting the MC. (and for speed)
var/list/tickersubsystems = list() var/list/tickersubsystems = list()
var/list/normalsubsystems = list() var/list/normalsubsystems = list()
@@ -245,7 +245,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
lobbysubsystems += SS lobbysubsystems += SS
timer += world.tick_lag * rand(1, 5) timer += world.tick_lag * rand(1, 5)
SS.next_fire = timer SS.next_fire = timer
else if (round_started) else if (local_round_started)
timer += world.tick_lag * rand(1, 5) timer += world.tick_lag * rand(1, 5)
SS.next_fire = timer SS.next_fire = timer
normalsubsystems += SS normalsubsystems += SS
@@ -296,7 +296,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
if (!Failsafe || (Failsafe.processing_interval > 0 && (Failsafe.lasttick+(Failsafe.processing_interval*5)) < world.time)) if (!Failsafe || (Failsafe.processing_interval > 0 && (Failsafe.lasttick+(Failsafe.processing_interval*5)) < world.time))
new/datum/controller/failsafe() // (re)Start the failsafe. new/datum/controller/failsafe() // (re)Start the failsafe.
if (!queue_head || !(iteration % 3)) if (!queue_head || !(iteration % 3))
if (round_started) if (local_round_started)
subsystems_to_check = normalsubsystems subsystems_to_check = normalsubsystems
else else
subsystems_to_check = lobbysubsystems subsystems_to_check = lobbysubsystems

View File

@@ -238,7 +238,7 @@ SUBSYSTEM_DEF(ticker)
send2irc("Server", "Round of [hide_mode ? "secret":"[mode.name]"] has started[allmins.len ? ".":" with no active admins online!"]") send2irc("Server", "Round of [hide_mode ? "secret":"[mode.name]"] has started[allmins.len ? ".":" with no active admins online!"]")
/datum/controller/subsystem/ticker/proc/OnRoundstart(datum/callback/cb) /datum/controller/subsystem/ticker/proc/OnRoundstart(datum/callback/cb)
if(current_state < GAME_STATE_PLAYING) if(!HasRoundStarted())
LAZYADD(round_start_events, cb) LAZYADD(round_start_events, cb)
else else
cb.InvokeAsync() cb.InvokeAsync()
@@ -651,11 +651,11 @@ SUBSYSTEM_DEF(ticker)
return return
INVOKE_ASYNC(SSmapping, /datum/controller/subsystem/mapping/.proc/maprotate) INVOKE_ASYNC(SSmapping, /datum/controller/subsystem/mapping/.proc/maprotate)
/datum/controller/subsystem/ticker/proc/HasRoundStarted()
return current_state >= GAME_STATE_PLAYING
/world/proc/has_round_started() /datum/controller/subsystem/ticker/proc/IsRoundInProgress()
if (SSticker && SSticker.current_state >= GAME_STATE_PLAYING) return current_state == GAME_STATE_PLAYING
return TRUE
return FALSE
/datum/controller/subsystem/ticker/Recover() /datum/controller/subsystem/ticker/Recover()
current_state = SSticker.current_state current_state = SSticker.current_state

View File

@@ -89,7 +89,7 @@
to_chat(src, "Enforce Continuous Rounds: [config.continuous.len] of [config.modes.len] roundtypes") to_chat(src, "Enforce Continuous Rounds: [config.continuous.len] of [config.modes.len] roundtypes")
to_chat(src, "Allow Midround Antagonists: [config.midround_antag.len] of [config.modes.len] roundtypes") to_chat(src, "Allow Midround Antagonists: [config.midround_antag.len] of [config.modes.len] roundtypes")
if(config.show_game_type_odds) if(config.show_game_type_odds)
if(SSticker.current_state == GAME_STATE_PLAYING) if(SSticker.IsRoundInProgress())
var/prob_sum = 0 var/prob_sum = 0
var/current_odds_differ = FALSE var/current_odds_differ = FALSE
var/list/probs = list() var/list/probs = list()

View File

@@ -654,7 +654,7 @@ GLOBAL_LIST_EMPTY(possible_items_special)
for(var/mob/dead/new_player/P in GLOB.player_list) for(var/mob/dead/new_player/P in GLOB.player_list)
if(P.client && P.ready && P.mind!=owner) if(P.client && P.ready && P.mind!=owner)
n_p ++ n_p ++
else if (SSticker.current_state == GAME_STATE_PLAYING) else if (SSticker.IsRoundInProgress())
for(var/mob/living/carbon/human/P in GLOB.player_list) for(var/mob/living/carbon/human/P in GLOB.player_list)
if(P.client && !(P.mind in SSticker.mode.changelings) && P.mind!=owner) if(P.client && !(P.mind in SSticker.mode.changelings) && P.mind!=owner)
n_p ++ n_p ++

View File

@@ -398,7 +398,7 @@
/turf/proc/add_blueprints_preround(atom/movable/AM) /turf/proc/add_blueprints_preround(atom/movable/AM)
if(!SSticker || SSticker.current_state != GAME_STATE_PLAYING) if(!SSticker.HasRoundStarted())
add_blueprints(AM) add_blueprints(AM)
/turf/proc/empty(turf_type=/turf/open/space) /turf/proc/empty(turf_type=/turf/open/space)

View File

@@ -804,7 +804,7 @@
return 1 return 1
/client/proc/adminGreet(logout) /client/proc/adminGreet(logout)
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING) if(SSticker.HasRoundStarted())
var/string var/string
if(logout && config && config.announce_admin_logout) if(logout && config && config.announce_admin_logout)
string = pick( string = pick(

View File

@@ -310,7 +310,7 @@
usr << browse(dat, "window=players;size=600x480") usr << browse(dat, "window=players;size=600x480")
/datum/admins/proc/check_antagonists() /datum/admins/proc/check_antagonists()
if (SSticker && SSticker.current_state >= GAME_STATE_PLAYING) if (SSticker.HasRoundStarted())
var/dat = "<html><head><title>Round Status</title></head><body><h1><B>Round Status</B></h1>" var/dat = "<html><head><title>Round Status</title></head><body><h1><B>Round Status</B></h1>"
if(SSticker.mode.replacementmode) if(SSticker.mode.replacementmode)
dat += "Former Game Mode: <B>[SSticker.mode.name]</B><BR>" dat += "Former Game Mode: <B>[SSticker.mode.name]</B><BR>"

View File

@@ -2161,7 +2161,7 @@
else if(href_list["kick_all_from_lobby"]) else if(href_list["kick_all_from_lobby"])
if(!check_rights(R_ADMIN)) if(!check_rights(R_ADMIN))
return return
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING) if(SSticker.IsRoundInProgress())
var/afkonly = text2num(href_list["afkonly"]) var/afkonly = text2num(href_list["afkonly"])
if(alert("Are you sure you want to kick all [afkonly ? "AFK" : ""] clients from the lobby??","Message","Yes","Cancel") != "Yes") if(alert("Are you sure you want to kick all [afkonly ? "AFK" : ""] clients from the lobby??","Message","Yes","Cancel") != "Yes")
to_chat(usr, "Kick clients from lobby aborted") to_chat(usr, "Kick clients from lobby aborted")

View File

@@ -206,7 +206,7 @@
toggle_all_ctf(user) toggle_all_ctf(user)
return return
if(SSticker.current_state < GAME_STATE_PLAYING) if(!SSticker.HasRoundStarted())
return return
if(user.ckey in team_members) if(user.ckey in team_members)
if(user.ckey in recently_dead_ckeys) if(user.ckey in recently_dead_ckeys)

View File

@@ -22,7 +22,7 @@
anchored = 1 anchored = 1
/obj/effect/mob_spawn/attack_ghost(mob/user) /obj/effect/mob_spawn/attack_ghost(mob/user)
if(SSticker.current_state != GAME_STATE_PLAYING || !loc) if(!SSticker.HasRoundStarted() || !loc)
return return
if(!uses) if(!uses)
to_chat(user, "<span class='warning'>This spawner is out of charges!</span>") to_chat(user, "<span class='warning'>This spawner is out of charges!</span>")

View File

@@ -341,7 +341,7 @@ GLOBAL_LIST(external_rsc_urls)
holder.owner = null holder.owner = null
GLOB.admins -= src GLOB.admins -= src
if (!GLOB.admins.len && SSticker.current_state == GAME_STATE_PLAYING) //Only report this stuff if we are currently playing. if (!GLOB.admins.len && SSticker.IsRoundInProgress()) //Only report this stuff if we are currently playing.
if(!GLOB.admins.len) //Apparently the admin logging out is no longer an admin at this point, so we have to check this towards 0 and not towards 1. Awell. if(!GLOB.admins.len) //Apparently the admin logging out is no longer an admin at this point, so we have to check this towards 0 and not towards 1. Awell.
var/cheesy_message = pick( var/cheesy_message = pick(
"I have no admins online!",\ "I have no admins online!",\

View File

@@ -149,7 +149,7 @@
return 1 return 1
if(href_list["late_join"]) if(href_list["late_join"])
if(!SSticker || SSticker.current_state != GAME_STATE_PLAYING) if(!SSticker || !SSticker.IsRoundInProgress())
to_chat(usr, "<span class='danger'>The round is either not ready, or has already finished...</span>") to_chat(usr, "<span class='danger'>The round is either not ready, or has already finished...</span>")
return return

View File

@@ -337,7 +337,7 @@
. = 1 . = 1
/mob/living/simple_animal/proc/make_babies() // <3 <3 <3 /mob/living/simple_animal/proc/make_babies() // <3 <3 <3
if(gender != FEMALE || stat || next_scan_time > world.time || !childtype || !animal_species || SSticker.current_state != GAME_STATE_PLAYING) if(gender != FEMALE || stat || next_scan_time > world.time || !childtype || !animal_species || !SSticker.IsRoundInProgress())
return return
next_scan_time = world.time + 400 next_scan_time = world.time + 400
var/alone = 1 var/alone = 1

View File

@@ -304,7 +304,7 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
// Sound the alert if gravity was just enabled or disabled. // Sound the alert if gravity was just enabled or disabled.
var/alert = 0 var/alert = 0
var/area/area = get_area(src) var/area/area = get_area(src)
if(on && SSticker && SSticker.current_state == GAME_STATE_PLAYING) // If we turned on and the game is live. if(on && SSticker.IsRoundInProgress()) // If we turned on and the game is live.
if(gravity_in_level() == 0) if(gravity_in_level() == 0)
alert = 1 alert = 1
investigate_log("was brought online and is now producing gravity for this level.", "gravity") investigate_log("was brought online and is now producing gravity for this level.", "gravity")

View File

@@ -96,7 +96,7 @@
sparks.set_up(5, TRUE, src) sparks.set_up(5, TRUE, src)
/obj/machinery/power/emitter/Destroy() /obj/machinery/power/emitter/Destroy()
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING) if(SSticker && SSticker.IsRoundInProgress())
message_admins("Emitter deleted at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1) message_admins("Emitter deleted at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("Emitter deleted at ([x],[y],[z])") log_game("Emitter deleted at ([x],[y],[z])")
investigate_log("<font color='red'>deleted</font> at ([x],[y],[z]) at [get_area(src)]","singulo") investigate_log("<font color='red'>deleted</font> at ([x],[y],[z]) at [get_area(src)]","singulo")

View File

@@ -191,7 +191,7 @@
cell.charge = (charge / capacity) * cell.maxcharge cell.charge = (charge / capacity) * cell.maxcharge
/obj/machinery/power/smes/Destroy() /obj/machinery/power/smes/Destroy()
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING) if(SSticker && SSticker.IsRoundInProgress())
var/area/area = get_area(src) var/area/area = get_area(src)
message_admins("SMES deleted at (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>[area.name]</a>)") message_admins("SMES deleted at (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>[area.name]</a>)")
log_game("SMES deleted at ([area.name])") log_game("SMES deleted at ([area.name])")

View File

@@ -313,3 +313,6 @@
s += ": [jointext(features, ", ")]" s += ": [jointext(features, ", ")]"
status = s status = s
/world/proc/has_round_started()
return SSticker.HasRoundStarted()