diff --git a/code/modules/mob/organ/organ.dm b/code/datums/organs/organ.dm similarity index 100% rename from code/modules/mob/organ/organ.dm rename to code/datums/organs/organ.dm diff --git a/code/modules/mob/organ/organ_external.dm b/code/datums/organs/organ_external.dm similarity index 100% rename from code/modules/mob/organ/organ_external.dm rename to code/datums/organs/organ_external.dm diff --git a/code/modules/mob/organ/organ_internal.dm b/code/datums/organs/organ_internal.dm similarity index 100% rename from code/modules/mob/organ/organ_internal.dm rename to code/datums/organs/organ_internal.dm diff --git a/code/modules/mob/organ/pain.dm b/code/datums/organs/pain.dm similarity index 100% rename from code/modules/mob/organ/pain.dm rename to code/datums/organs/pain.dm diff --git a/code/datums/vote.dm b/code/datums/vote.dm index 8856cb5193..2ed3e5f651 100644 --- a/code/datums/vote.dm +++ b/code/datums/vote.dm @@ -5,3 +5,349 @@ var/mode = 0 // 0 = restart vote, 1 = mode vote // modes which can be voted for var/winner = null // the vote winner + +/datum/vote/New() + + nextvotetime = world.timeofday // + 10*config.vote_delay + + +/datum/vote/proc/canvote()//marker1 + var/excess = world.timeofday - vote.nextvotetime + + if(excess < -10000) // handle clock-wrapping problems - very long delay (>20 hrs) if wrapped + vote.nextvotetime = world.timeofday + return 1 + return (excess >= 0) + +/datum/vote/proc/nextwait() + return timetext( round( (nextvotetime - world.timeofday)/10) ) + +/datum/vote/proc/endwait() + return timetext( round( (votetime - world.timeofday)/10) ) + +/datum/vote/proc/timetext(var/interval) + var/minutes = round(interval / 60) + var/seconds = round(interval % 60) + + var/tmin = "[minutes>0?num2text(minutes)+"min":null]" + var/tsec = "[seconds>0?num2text(seconds)+"sec":null]" + + if(tmin && tsec) // hack to skip inter-space if either field is blank + return "[tmin] [tsec]" + else + if(!tmin && !tsec) // return '0sec' if 0 time left + return "0sec" + return "[tmin][tsec]" + +/datum/vote/proc/getvotes() + var/list/L = list() + for(var/mob/M in player_list) + if(M.client && M.client.inactivity < 1200) // clients inactive for 2 minutes don't count + L[M.client.vote] += 1 + + return L + + +/datum/vote/proc/endvote() + + if(!voting) // means that voting was aborted by an admin + return + + world << "\red ***Voting has closed." + + log_vote("Voting closed, result was [winner]") + voting = 0 + nextvotetime = world.timeofday + 10*config.vote_delay + + for(var/mob/M in player_list) // clear vote window from all clients + if(M.client) + M << browse(null, "window=vote") + M.client.showvote = 0 + + calcwin() + + if(mode) + if(!ticker) + if(!going) + world << "The game will start soon." + going = 1 + var/wintext = capitalize(winner) + if(winner=="default") + world << "Result is \red No change." + return + + // otherwise change mode + + + world << "Result is change to \red [wintext]" + world.save_mode(winner) + + if(ticker && ticker.mode) + world <<"\red World will reboot in 10 seconds" + + feedback_set_details("end_error","mode vote - [winner]") + + if(blackbox) + blackbox.save_all_data_to_sql() + + sleep(100) + log_game("Rebooting due to mode vote") + world.Reboot() + else + master_mode = winner + + else + + if(winner=="default") + world << "Result is \red No restart." + return + + world << "Result is \red Restart round." + + world <<"\red World will reboot in 5 seconds" + + feedback_set_details("end_error","restart vote") + + if(blackbox) + blackbox.save_all_data_to_sql() + + sleep(50) + log_game("Rebooting due to restart vote") + world.Reboot() + return + + +/datum/vote/proc/calcwin() + + var/list/votes = getvotes() + + if(vote.mode) + var/best = -1 + + for(var/v in votes) + if(v=="none") + continue + if(best < votes[v]) + best = votes[v] + + + var/list/winners = list() + + for(var/v in votes) + if(votes[v] == best) + winners += v + + var/ret = "" + + + for(var/w in winners) + if(lentext(ret) > 0) + ret += "/" + if(w=="default") + winners = list("default") + ret = "No change" + break + else + ret += capitalize(w) + + + + if(winners.len != 1) + ret = "Tie: " + ret + + + if(winners.len == 0) + vote.winner = "default" + ret = "No change" + else + vote.winner = pick(winners) + + return ret + else + + if(votes["default"] < votes["restart"]) + + vote.winner = "restart" + return "Restart" + else + vote.winner = "default" + return "No restart" + + +/mob/verb/vote() + set category = "OOC" + set name = "Vote" + usr.client.showvote = 1 + + + var/text = "
Current winner: [vote.calcwin()]
"
+
+ text += footer
+
+ usr << browse(text, "window=vote")
+
+ else // voting to restart
+
+ text += "Restart the world?
Current winner: [vote.calcwin()]
"
+
+ text += footer
+
+ usr << browse(text, "window=vote")
+
+
+ else //no vote in progress
+
+ if(shuttlecoming == 1)
+ usr << "\blue Cannot start Vote - Shuttle has been called."
+ return
+
+ if(!config.allow_vote_restart && !config.allow_vote_mode)
+ text += "
Player voting is disabled.