Skip to content

Commit

Permalink
tweak: add crew transfer vote after blob death (#5557)
Browse files Browse the repository at this point in the history
* tweak: add crew transfer vote after blob death

* add qdels and qdels check

* removing unnecessary timers
  • Loading branch information
dageavtobusnick authored Jul 26, 2024
1 parent 197fcfd commit 6e3a6fb
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 13 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/blob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#define BLOB_BASE_TARGET_POINT 350
#define BLOB_TARGET_POINT_PER_CORE 350
#define BLOB_PLAYERS_PER_CORE 30
#define BLOB_DEATH_REPORT_FIRST 0
#define BLOB_DEATH_REPORT_SECOND 1
#define BLOB_DEATH_REPORT_THIRD 2
#define BLOB_DEATH_REPORT_FOURTH 3
#define AWAY_STATION_WARN span_userdanger("Вы готовы лопнуть, но это не подходящее место! Вы должны вернуться на станцию!")
#define FIRST_STAGE_WARN span_userdanger("Вы чувствуете усталость и раздутость.")
#define SECOND_STAGE_WARN span_userdanger("Вы чувствуете, что вот-вот лопнете.")
Expand Down
20 changes: 20 additions & 0 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,36 @@ SUBSYSTEM_DEF(vote)

/// Active vote, if any
var/datum/vote/active_vote
//Queue of votes being processed
var/list/votes_queue = list()

/datum/controller/subsystem/vote/fire()
if(active_vote)
active_vote.tick()

/datum/controller/subsystem/vote/proc/start_vote(datum/vote/V)
// This will be fun if DM ever gets concurrency
if(active_vote)
votes_queue += V
return
active_vote = V
active_vote.start()

/datum/controller/subsystem/vote/proc/on_vote_end()
for(var/datum/vote/vote in votes_queue)
votes_queue -= vote
if(QDELETED(vote))
continue
start_vote(vote)
break;

/datum/controller/subsystem/vote/proc/clear_transfer_votes()
for(var/datum/vote/vote in votes_queue)
if(istype(vote, /datum/vote/crew_transfer))
votes_queue -= vote
if(!QDELETED(vote))
qdel(vote)

/datum/controller/subsystem/vote/Topic(href, list/href_list)
if(href_list["vote"] == "open")
usr.client.vote()
25 changes: 17 additions & 8 deletions code/game/gamemodes/blob/blob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@

/datum/game_mode/proc/blob_died()
if(!GLOB.blob_cores.len && blob_stage >= BLOB_STAGE_FIRST && blob_stage < BLOB_STAGE_STORM)
addtimer(CALLBACK(src, PROC_REF(report_blob_death), SEC_LEVEL_RED), TIME_TO_ANNOUNCE_BLOBS_DIE)
addtimer(CALLBACK(src, PROC_REF(report_blob_death), BLOB_DEATH_REPORT_FIRST), TIME_TO_ANNOUNCE_BLOBS_DIE)


/datum/game_mode/proc/get_blobs_minds()
Expand All @@ -126,13 +126,22 @@
return blob_list


/datum/game_mode/proc/report_blob_death()
send_intercept(BLOB_THIRD_REPORT)
if(SSshuttle)
SSshuttle.stop_lockdown()
if(blob_stage >= BLOB_STAGE_SECOND && GLOB.security_level == SEC_LEVEL_GAMMA)
addtimer(CALLBACK(GLOBAL_PROC, /proc/set_security_level, SEC_LEVEL_RED), TIME_TO_SWITCH_CODE)
blob_stage = BLOB_STAGE_ZERO
/datum/game_mode/proc/report_blob_death(report_number)
switch(report_number)
if (BLOB_DEATH_REPORT_FIRST)
send_intercept(BLOB_THIRD_REPORT)
if (BLOB_DEATH_REPORT_SECOND)
SSshuttle?.stop_lockdown()
if (BLOB_DEATH_REPORT_THIRD)
if(blob_stage >= BLOB_STAGE_SECOND && GLOB.security_level == SEC_LEVEL_GAMMA)
set_security_level(SEC_LEVEL_RED)
if (BLOB_DEATH_REPORT_FOURTH)
blob_stage = BLOB_STAGE_ZERO
SSvote.start_vote(new /datum/vote/crew_transfer)
return
else
return
addtimer(CALLBACK(src, PROC_REF(report_blob_death), report_number + 1), TIME_TO_SWITCH_CODE)


/datum/game_mode/proc/make_blobs(count, need_new_blob = FALSE)
Expand Down
3 changes: 1 addition & 2 deletions code/modules/vote/vote_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@


/datum/vote/New(_initiator, _question, list/_choices, _is_custom = FALSE)
if(SSvote.active_vote)
CRASH("Attempted to start another vote with one already in progress!")

if(_initiator)
initiator = _initiator
Expand Down Expand Up @@ -141,6 +139,7 @@
SSvote.active_vote = null
if(ooc_auto_muted && !CONFIG_GET(flag/ooc_allowed))
toggle_ooc()
addtimer(CALLBACK(SSvote, TYPE_PROC_REF(/datum/controller/subsystem/vote, on_vote_end)), 3 SECONDS)
return ..()


Expand Down
1 change: 1 addition & 0 deletions code/modules/vote/vote_presets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/datum/vote/crew_transfer/handle_result(result)
if(result == "Initiate Crew Transfer")
SSvote.clear_transfer_votes()
init_shift_change(null, TRUE)

// Map vote
Expand Down
3 changes: 0 additions & 3 deletions code/modules/vote/vote_verb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
if(!check_rights(R_ADMIN))
return

if(SSvote.active_vote)
to_chat(usr, "A vote is already in progress")
return

// Ask admins which type of vote they want to start
var/vote_types = subtypesof(/datum/vote)
Expand Down

0 comments on commit 6e3a6fb

Please sign in to comment.