diff --git a/code/controllers/subsystem/non-firing/mapping.dm b/code/controllers/subsystem/non-firing/mapping.dm index ce5325f34a8..c0c6a4cd231 100644 --- a/code/controllers/subsystem/non-firing/mapping.dm +++ b/code/controllers/subsystem/non-firing/mapping.dm @@ -41,6 +41,8 @@ SUBSYSTEM_DEF(mapping) var/list/critical_planes /// The largest plane offset we've generated so far var/max_plane_offset = 0 + /// Maps played in previous rounds, stores typepaths + var/list/previous_maps // This has to be here because world/New() uses [station_name()], which looks this datum up @@ -57,7 +59,9 @@ SUBSYSTEM_DEF(mapping) catch map_datum = fallback_map // Assume delta if non-existent fdel("data/next_map.txt") // Remove to avoid the same map existing forever + return + map_datum = fallback_map // Assume delta if non-existent /datum/controller/subsystem/mapping/Shutdown() @@ -65,9 +69,41 @@ SUBSYSTEM_DEF(mapping) var/F = file("data/next_map.txt") F << next_map.type + +/datum/controller/subsystem/mapping/proc/convert_map_datums() + var/list/map_subtypes = subtypesof(/datum/map) + var/list/result = list() + for(var/datum/map/subtype as anything in map_subtypes) + result[initial(subtype.name)] = subtype + + return result + +/datum/controller/subsystem/mapping/proc/find_last_played_maps() + if(CONFIG_GET(flag/sql_enabled)) + var/datum/db_query/query = \ + SSdbcore.NewQuery("SELECT id, map_name \ + FROM [format_table_name("round")] \ + WHERE server_port=[world.port] \ + AND end_state IS NOT NULL \ + ORDER BY id DESC LIMIT 1") //Generally gets the last played map, but can be configured to get any count. + + if(!query.warn_execute()) + qdel(query) + return + + var/list/map_names = convert_map_datums() + var/list/maps = list() + //Query row structure: id, map_name + for(var/map in query.rows) + var/map_path = map_names[map[2]] + if(map_path) + maps += map_path + + previous_maps = maps + /datum/controller/subsystem/mapping/Initialize() setupPlanes() - + find_last_played_maps() var/datum/lavaland_theme/lavaland_theme_type = pick(subtypesof(/datum/lavaland_theme)) ASSERT(lavaland_theme_type) lavaland_theme = new lavaland_theme_type diff --git a/code/modules/vote/vote_presets.dm b/code/modules/vote/vote_presets.dm index 57948610b03..27882075ac0 100644 --- a/code/modules/vote/vote_presets.dm +++ b/code/modules/vote/vote_presets.dm @@ -31,6 +31,12 @@ if(CONFIG_GET(string/map_vote_mode) == "nodoubles") map_pool -= SSmapping.map_datum.type + if(CONFIG_GET(string/map_vote_mode) == "notriples") + if(SSmapping.previous_maps && length(SSmapping.previous_maps)) + var/current_map = SSmapping.map_datum.type + if(current_map == SSmapping.previous_maps[1]) + map_pool -= current_map + for(var/datum/map/possible_map as anything in map_pool) if(initial(possible_map.admin_only)) continue diff --git a/config/example/config.txt b/config/example/config.txt index ad4324f993c..e40ed4fc4a9 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -663,6 +663,7 @@ MAP_ROTATE none ## Server map voting mode: ## all - all maps can be selected ## nodoubles - current map can't be selected as next +## notriples - current map can't be selected as next if played twice in a row MAP_VOTE_MODE all ## Default server map