Skip to content

Commit

Permalink
Cleans up map rotation code, removes debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
MrStonedOne committed Sep 30, 2015
1 parent fcc8402 commit fb01e5c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@


#ifndef SERVERTOOLS
#define SERVERTOOLS 1
#define SERVERTOOLS 0
#endif
14 changes: 7 additions & 7 deletions code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -464,17 +464,17 @@ var/datum/subsystem/ticker/ticker
queue_delay = 0

/datum/subsystem/ticker/proc/check_maprotate(var/force = 0)
if (!config.maprotation && !force)
if (!config.maprotation || !SERVERTOOLS)
return
if ((SSshuttle.emergency.mode != SHUTTLE_ESCAPE || SSshuttle.canRecall()) && !force)
if (SSshuttle.emergency.mode != SHUTTLE_ESCAPE || SSshuttle.canRecall())
return
if (maprotatechecked && !force)
if (maprotatechecked)
return

maprotatechecked = 1

//map rotate chance is length of the round (in minutes) divided by 2
if (!prob((world.time/600)/2) && !force)
if (!prob((world.time/600)/2))
return

var/players = clients.len
Expand Down Expand Up @@ -523,13 +523,13 @@ var/datum/subsystem/ticker/ticker
if (0)
var/datum/votablemap/VM = config.maplist[pickedmap]
world << "<span class='boldannounce'>Map rotation has choosen [VM.friendlyname] for next round!</span>"
if (1)
if (11)
message_admins("Failed to rotate map: Map rotator script couldn't find file listing new map")
log_game("Failed to rotate map: Map rotator script couldn't find file listing new map")
if (2)
if (12)
message_admins("Failed to rotate map: Map rotator script couldn't find tgstation-tools framework")
log_game("Failed to rotate map: Map rotator script couldn't find tgstation-tools framework")
if (3)
if (13)
message_admins("Failed to rotate map: Could not compile new map:[pickedmap]")
log_game("Failed to rotate map: Could not compile new map:[pickedmap]")
else
Expand Down
16 changes: 15 additions & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,21 @@ var/global/list/special_roles = list( //keep synced with the defines BE_* in set
dat += "<b>Ghost Form:</b> <a href='?_src_=prefs;task=input;preference=ghostform'>[ghost_form]</a><br>"

if (SERVERTOOLS && config.maprotation)
dat += "<b>Preferred Map:</b> <a href='?_src_=prefs;preference=preferred_map;task=input'>[preferred_map ? preferred_map : "Default[config.defaultmap ? " ([config.defaultmap.friendlyname])":""]"]</a>"
var/p_map = preferred_map
if (!p_map)
p_map = "Default"
if (config.defaultmap)
p_map += " ([config.defaultmap.friendlyname])"
else
if (p_map in config.maplist)
var/datum/votablemap/VM = config.maplist[p_map]
if (!VM)
p_map += " (No longer exists)"
else
p_map = VM.friendlyname
else
p_map += " (No longer exists)"
dat += "<b>Preferred Map:</b> <a href='?_src_=prefs;preference=preferred_map;task=input'>[p_map]</a>"

dat += "</td><td width='300px' height='300px' valign='top'>"

Expand Down
2 changes: 1 addition & 1 deletion code/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
config.load("config/config.txt")
config.load("config/game_options.txt","game_options")
config.loadsql("config/dbconfig.txt")
if (config.maprotation)
if (config.maprotation && SERVERTOOLS)
config.loadmaplist("config/maps.txt")

// apply some settings from config..
Expand Down
7 changes: 6 additions & 1 deletion config/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,9 @@ AUTOCONVERT_NOTES
ANNOUNCE_ADMIN_LOGOUT

##Uncomment to have an admin message sent anytime an admin connects to a round in play, you can edit the messages in admin.dm
#ANNOUNCE_ADMIN_LOGIN
#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
32 changes: 32 additions & 0 deletions config/maps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
This file contains a list of maps for use in 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/
#Lines starting with # are ignored.
Lines not inside map blocks are also ignored
Duplicated entries use the latter one.
All whitespace at the start and end of lines is ignored. (including indentation, thats just for show)
Format:
#map [map name] (name of .dm file in _maps folder without the .dm part)
friendlyname [name] (name shown to players)
minplayers [number] (0 or less disables this requirement)
maxplayers [number] (0 or less disables this requirement)
default (The last map with this defined will get all votes of players who have not explicitly voted for a map)
voteweight [number] (How much to count each player vote as, defaults to 1, setting to 0.5 counts each vote as half a vote, 2 as double, etc, Setting to 0 disables the map but allows players to still pick it)
endmap

map tgstation2
friendlyname Box Station
default
#voteweight 1.5
endmap

map metastation
friendlyname Meta Station
minplayers 25
#voteweight 0.5
endmap

#map ministation
friendlyname Mini Station
maxplayers 30
voteweight 0
endmap

0 comments on commit fb01e5c

Please sign in to comment.