Skip to content

Commit

Permalink
Adds a configuration option for disabling preferred maps (tgstation#2…
Browse files Browse the repository at this point in the history
…5137)

* Adds a config option to disable map voting
  • Loading branch information
Cyberboss authored and lzimann committed Mar 17, 2017
1 parent 5aeb4d7 commit 0bb7407
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
3 changes: 3 additions & 0 deletions code/controllers/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
var/datum/map_config/defaultmap = null
var/maprotation = 1
var/maprotatechancedelta = 0.75
var/allow_map_voting = TRUE

// Enables random events mid-round when set to 1
var/allow_random_events = 0
Expand Down Expand Up @@ -494,6 +495,8 @@
config.announce_admin_login = 1
if("maprotation")
config.maprotation = 1
if("allow_map_voting")
config.allow_map_voting = text2num(value)
if("maprotationchancedelta")
config.maprotatechancedelta = text2num(value)
if("autoadmin")
Expand Down
61 changes: 31 additions & 30 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,38 +149,39 @@ var/datum/controller/subsystem/mapping/SSmapping
var/players = clients.len
var/list/mapvotes = list()
//count votes
for (var/client/c in clients)
var/vote = c.prefs.preferred_map
if (!vote)
if (global.config.defaultmap)
mapvotes[global.config.defaultmap.map_name] += 1
continue
mapvotes[vote] += 1

//filter votes
for (var/map in mapvotes)
if (!map)
mapvotes.Remove(map)
if (!(map in global.config.maplist))
mapvotes.Remove(map)
continue
var/datum/map_config/VM = global.config.maplist[map]
if (!VM)
mapvotes.Remove(map)
continue
if (VM.voteweight <= 0)
mapvotes.Remove(map)
continue
if (VM.config_min_users > 0 && players < VM.config_min_users)
mapvotes.Remove(map)
continue
if (VM.config_max_users > 0 && players > VM.config_max_users)
mapvotes.Remove(map)
continue
if(global.config.allow_map_voting)
for (var/client/c in clients)
var/vote = c.prefs.preferred_map
if (!vote)
if (global.config.defaultmap)
mapvotes[global.config.defaultmap.map_name] += 1
continue
mapvotes[vote] += 1

//filter votes
for (var/map in mapvotes)
if (!map)
mapvotes.Remove(map)
if (!(map in global.config.maplist))
mapvotes.Remove(map)
continue
var/datum/map_config/VM = global.config.maplist[map]
if (!VM)
mapvotes.Remove(map)
continue
if (VM.voteweight <= 0)
mapvotes.Remove(map)
continue
if (VM.config_min_users > 0 && players < VM.config_min_users)
mapvotes.Remove(map)
continue
if (VM.config_max_users > 0 && players > VM.config_max_users)
mapvotes.Remove(map)
continue

mapvotes[map] = mapvotes[map]*VM.voteweight
mapvotes[map] = mapvotes[map]*VM.voteweight

var/pickedmap = pickweight(mapvotes)
var/pickedmap = global.config.allow_map_voting ? pickweight(mapvotes) : pick(global.config.maplist)
if (!pickedmap)
return
var/datum/map_config/VM = global.config.maplist[pickedmap]
Expand Down
3 changes: 2 additions & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ var/list/preferences_datums = list()
p_map = VM.map_name
else
p_map += " (No longer exists)"
dat += "<b>Preferred Map:</b> <a href='?_src_=prefs;preference=preferred_map;task=input'>[p_map]</a><br>"
if(config.allow_map_voting)
dat += "<b>Preferred Map:</b> <a href='?_src_=prefs;preference=preferred_map;task=input'>[p_map]</a><br>"

dat += "<b>FPS:</b> <a href='?_src_=prefs;preference=clientfps;task=input'>[clientfps]</a><br>"

Expand Down
6 changes: 5 additions & 1 deletion config/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,14 @@ ANNOUNCE_ADMIN_LOGOUT
#ANNOUNCE_ADMIN_LOGIN

## Map rotation
## This feature requires you are running a Windows OS (or can other wise run .bat files) and that you are using the tgstation-server toolset in tools/
## You should edit maps.txt to match your configuration when you enable this.
#MAPROTATION

## Map voting
## Allows players to vote for their preffered map
## When it's set to zero, the map will be randomly picked each round
ALLOW_MAP_VOTING 1

## Map rotate chance delta
## This is the chance of map rotation factored to the round length.
## A value of 1 would mean the map rotation chance is the round length in minutes (hour long round == 60% rotation chance)
Expand Down

0 comments on commit 0bb7407

Please sign in to comment.