diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm
index 2eb9710b5d0..3e2cfc56a3a 100644
--- a/code/controllers/subsystem/mapping.dm
+++ b/code/controllers/subsystem/mapping.dm
@@ -233,7 +233,7 @@ SUBSYSTEM_DEF(mapping)
station_start = world.maxz + 1
INIT_ANNOUNCE("Loading [config.map_name]...")
LoadGroup(FailedZs, "Station", config.map_path, config.map_file, config.traits, ZTRAITS_STATION)
-
+
if(SSdbcore.Connect())
var/datum/DBQuery/query_round_map_name = SSdbcore.NewQuery("UPDATE [format_table_name("round")] SET map_name = '[config.map_name]' WHERE id = [GLOB.round_id]")
query_round_map_name.Execute()
@@ -266,7 +266,7 @@ SUBSYSTEM_DEF(mapping)
fdel("_maps/custom/[config.map_file]")
// And as the file is now removed set the next map to default.
next_map_config = load_map_config(default_to_box = TRUE)
-
+
GLOBAL_LIST_EMPTY(the_station_areas)
/datum/controller/subsystem/mapping/proc/generate_station_area_list()
@@ -285,9 +285,8 @@ GLOBAL_LIST_EMPTY(the_station_areas)
/datum/controller/subsystem/mapping/proc/maprotate()
if(map_voted)
- map_voted = FALSE
return
-
+
var/players = GLOB.clients.len
var/list/mapvotes = list()
//count votes
diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm
index 3b80b54ad78..17554b8a513 100644
--- a/code/controllers/subsystem/persistence.dm
+++ b/code/controllers/subsystem/persistence.dm
@@ -1,4 +1,5 @@
#define FILE_ANTAG_REP "data/AntagReputation.json"
+#define FILE_RECENT_MAPS "data/RecentMaps.json"
SUBSYSTEM_DEF(persistence)
name = "Persistence"
@@ -8,6 +9,7 @@ SUBSYSTEM_DEF(persistence)
var/list/obj/structure/chisel_message/chisel_messages = list()
var/list/saved_messages = list()
var/list/saved_modes = list(1,2,3)
+ var/list/saved_maps = list(1,2)
var/list/saved_trophies = list()
var/list/antag_rep = list()
var/list/antag_rep_change = list()
@@ -20,6 +22,7 @@ SUBSYSTEM_DEF(persistence)
LoadChiselMessages()
LoadTrophies()
LoadRecentModes()
+ LoadRecentMaps()
LoadPhotoPersistence()
if(CONFIG_GET(flag/use_antag_rep))
LoadAntagReputation()
@@ -104,6 +107,15 @@ SUBSYSTEM_DEF(persistence)
return
saved_modes = json["data"]
+/datum/controller/subsystem/persistence/proc/LoadRecentMaps()
+ var/map_sav = FILE_RECENT_MAPS
+ if(!fexists(FILE_RECENT_MAPS))
+ return
+ var/list/json = json_decode(file2text(map_sav))
+ if(!json)
+ return
+ saved_maps = json["data"]
+
/datum/controller/subsystem/persistence/proc/LoadAntagReputation()
var/json = file2text(FILE_ANTAG_REP)
if(!json)
@@ -144,6 +156,7 @@ SUBSYSTEM_DEF(persistence)
CollectChiselMessages()
CollectTrophies()
CollectRoundtype()
+ CollectMaps()
SavePhotoPersistence() //THIS IS PERSISTENCE, NOT THE LOGGING PORTION.
if(CONFIG_GET(flag/use_antag_rep))
CollectAntagReputation()
@@ -270,6 +283,15 @@ SUBSYSTEM_DEF(persistence)
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data))
+/datum/controller/subsystem/persistence/proc/CollectMaps()
+ saved_maps[2] = saved_maps[1]
+ saved_maps[1] = SSmapping.config.map_name
+ var/json_file = file(FILE_RECENT_MAPS)
+ var/list/file_data = list()
+ file_data["data"] = saved_maps
+ fdel(json_file)
+ WRITE_FILE(json_file, json_encode(file_data))
+
/datum/controller/subsystem/persistence/proc/CollectAntagReputation()
var/ANTAG_REP_MAXIMUM = CONFIG_GET(number/antag_rep_maximum)
@@ -301,7 +323,7 @@ SUBSYSTEM_DEF(persistence)
loaded = TRUE
if(!loaded) //We do not have information for whatever reason, just generate new one
R.GenerateRecipe()
-
+
if(!R.HasConflicts()) //Might want to try again if conflicts happened in the future.
add_chemical_reaction(R)
@@ -323,6 +345,6 @@ SUBSYSTEM_DEF(persistence)
recipe_data["results"] = R.results
recipe_data["required_container"] = "[R.required_container]"
file_data["[R.id]"] = recipe_data
-
+
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data))
diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm
index 64a8e723020..732a7a6fd57 100644
--- a/code/controllers/subsystem/vote.dm
+++ b/code/controllers/subsystem/vote.dm
@@ -74,12 +74,12 @@ SUBSYSTEM_DEF(vote)
else if(mode == "map")
for (var/non_voter_ckey in non_voters)
var/client/C = non_voters[non_voter_ckey]
- if(C.prefs.preferred_map)
+ if(C.prefs.preferred_map && choices[C.prefs.preferred_map]) //No votes if the map isnt in the vote.
var/preferred_map = C.prefs.preferred_map
choices[preferred_map] += 1
greatest_votes = max(greatest_votes, choices[preferred_map])
- else if(global.config.defaultmap)
- var/default_map = global.config.defaultmap.map_name
+ else if(config.defaultmap && choices[config.defaultmap]) //No votes if the map isnt in the vote.
+ var/default_map = config.defaultmap.map_name
choices[default_map] += 1
greatest_votes = max(greatest_votes, choices[default_map])
//get all options with that many votes and return them in a list
@@ -121,27 +121,27 @@ SUBSYSTEM_DEF(vote)
/datum/controller/subsystem/vote/proc/result()
. = announce_result()
- var/restart = 0
+ var/restart = FALSE
if(.)
switch(mode)
if("restart")
if(. == "Restart Round")
- restart = 1
+ restart = TRUE
if("gamemode")
if(GLOB.master_mode != .)
SSticker.save_mode(.)
if(SSticker.HasRoundStarted())
- restart = 1
+ restart = TRUE
else
GLOB.master_mode = .
if("map")
SSmapping.changemap(global.config.maplist[.])
SSmapping.map_voted = TRUE
if(restart)
- var/active_admins = 0
+ var/active_admins = FALSE
for(var/client/C in GLOB.admins)
if(!C.is_afk() && check_rights_for(C, R_SERVER))
- active_admins = 1
+ active_admins = TRUE
break
if(!active_admins)
SSticker.Reboot("Restart vote successful.", "restart vote")
@@ -154,30 +154,31 @@ SUBSYSTEM_DEF(vote)
/datum/controller/subsystem/vote/proc/submit_vote(vote)
if(mode)
if(CONFIG_GET(flag/no_dead_vote) && usr.stat == DEAD && !usr.client.holder)
- return 0
+ return FALSE
if(!(usr.ckey in voted))
if(vote && 1<=vote && vote<=choices.len)
voted += usr.ckey
choices[choices[vote]]++ //check this
return vote
- return 0
+ return FALSE
/datum/controller/subsystem/vote/proc/initiate_vote(vote_type, initiator_key)
+ var/admin = FALSE
+ var/ckey = ckey(initiator_key)
+ if(GLOB.admin_datums[ckey])
+ admin = TRUE
+
if(!mode)
if(started_time)
var/next_allowed_time = (started_time + CONFIG_GET(number/vote_delay))
if(mode)
to_chat(usr, "There is already a vote in progress! please wait for it to finish.")
- return 0
+ return FALSE
- var/admin = FALSE
- var/ckey = ckey(initiator_key)
- if(GLOB.admin_datums[ckey])
- admin = TRUE
if(next_allowed_time > world.time && !admin)
to_chat(usr, "A vote was initiated recently, you must wait [DisplayTimeText(next_allowed_time-world.time)] before a new vote can be started!")
- return 0
+ return FALSE
reset()
switch(vote_type)
@@ -186,22 +187,31 @@ SUBSYSTEM_DEF(vote)
if("gamemode")
choices.Add(config.votable_modes)
if("map")
- for(var/map in global.config.maplist)
+ if(!admin && SSmapping.map_voted)
+ to_chat(usr, "The next map has already been selected.")
+ return FALSE
+ for(var/map in config.maplist)
var/datum/map_config/VM = config.maplist[map]
- if(!VM.votable)
+ var/run = 0
+ if(VM.map_name == SSmapping.config.map_name)
+ run++
+ for(var/name in SSpersistence.saved_maps)
+ if(VM.map_name == name)
+ run++
+ if(run >= 2 || !VM.votable) //If run twice in the last three (including current) as of time of writing, disable map for voting.
continue
choices.Add(VM.map_name)
if("custom")
question = stripped_input(usr,"What is the vote for?")
if(!question)
- return 0
+ return FALSE
for(var/i=1,i<=10,i++)
var/option = capitalize(stripped_input(usr,"Please enter an option or hit cancel to finish"))
if(!option || mode || !usr.client)
break
choices.Add(option)
else
- return 0
+ return FALSE
mode = vote_type
initiator = initiator_key
started_time = world.time
@@ -220,18 +230,18 @@ SUBSYSTEM_DEF(vote)
C.player_details.player_actions += V
V.Grant(C.mob)
generated_actions += V
- return 1
- return 0
+ return TRUE
+ return FALSE
/datum/controller/subsystem/vote/proc/interface(client/C)
if(!C)
return
- var/admin = 0
- var/trialmin = 0
+ var/admin = FALSE
+ var/trialmin = FALSE
if(C.holder)
- admin = 1
+ admin = TRUE
if(check_rights_for(C, R_ADMIN))
- trialmin = 1
+ trialmin = TRUE
voting |= C
if(mode)
@@ -291,11 +301,11 @@ SUBSYSTEM_DEF(vote)
if(!usr || !usr.client)
return //not necessary but meh...just in-case somebody does something stupid
- var/trialmin = 0
+ var/trialmin = FALSE
if(usr.client.holder)
if(check_rights_for(usr.client, R_ADMIN))
- trialmin = 1
-
+ trialmin = TRUE
+
switch(href_list["vote"])
if("close")
voting -= usr.client
@@ -357,7 +367,7 @@ SUBSYSTEM_DEF(vote)
Remove(owner)
/datum/action/vote/IsAvailable()
- return 1
+ return TRUE
/datum/action/vote/proc/remove_from_client()
if(!owner)