From 937d7a2177b4eeac9275c16b29b28f3f03fbe017 Mon Sep 17 00:00:00 2001 From: urthub Date: Sun, 29 Mar 2015 16:27:56 +0200 Subject: [PATCH] Fix #28: Add dynamic mapcycle support --- conf/settings.conf | 7 +++++++ spunky.py | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/conf/settings.conf b/conf/settings.conf index 92ba71c..106b1a4 100644 --- a/conf/settings.conf +++ b/conf/settings.conf @@ -21,6 +21,13 @@ allow_teams_round_end = 0 ; Enable (1) or disable (0) spam_bomb_planted = 1 ; Enable (1) or disable (0) spamming the message "Bomb has been planted" in global chat verbose = 0 ; Enable (1) or disable (0) debug messages +[mapcycle] +dynamic_mapcycle = 0 ; Enable (1) or disable (0) dynamic mapcycle. If enabled, the rotation of small or big_cycle will be used +switch_count = 5 ; When server reaches the number of players, the map rotation will be switched to 'big_cycle' list +; Comma separated list of valid map names +small_cycle = ut4_turnpike, ut4_abbey +big_cycle = ut4_turnpike, ut4_algiers, ut4_casa, ut4_sanc + [lowgrav] support_lowgravity = 0 ; Enable (1) or disable (0) support for Low Gravity Server gravity = 100 ; Set g_gravity to given value, default: 800 \ No newline at end of file diff --git a/spunky.py b/spunky.py index a351de7..fcb39b0 100644 --- a/spunky.py +++ b/spunky.py @@ -2578,6 +2578,13 @@ def __init__(self, config_file, urt42_modversion): Rules(os.path.join(HOME, 'conf', 'rules.conf'), game_cfg.getint('rules', 'rules_frequency'), self.rcon_handle) logger.info("Load rotating messages: OK") + # dynamic mapcycle + self.dynamic_mapcycle = game_cfg.getboolean('mapcycle', 'dynamic_mapcycle') if game_cfg.has_option('mapcycle', 'dynamic_mapcycle') else False + if self.dynamic_mapcycle: + self.switch_count = game_cfg.getint('mapcycle', 'switch_count') if game_cfg.has_option('mapcycle', 'switch_count') else 4 + self.big_cycle = filter(None, game_cfg.get('mapcycle', 'big_cycle').replace(' ', '').split(',')) if game_cfg.has_option('mapcycle', 'big_cycle') else [] + self.small_cycle = filter(None, game_cfg.get('mapcycle', 'small_cycle').replace(' ', '').split(',')) if game_cfg.has_option('mapcycle', 'small_cycle') else [] + # add Spunky Bot as player 'World' to the game spunky_bot = Player(1022, '127.0.0.1', 'NONE', 'World') self.add_player(spunky_bot) @@ -2696,6 +2703,9 @@ def set_current_map(self): except KeyError: self.mapname = self.next_mapname + if self.dynamic_mapcycle: + self.maplist = filter(None, (self.small_cycle if len(self.players) < (self.switch_count + 1) else self.big_cycle)) + if self.maplist: if self.mapname in self.maplist: if self.maplist.index(self.mapname) < (len(self.maplist) - 1): @@ -2707,6 +2717,9 @@ def set_current_map(self): else: self.next_mapname = self.mapname + if self.dynamic_mapcycle: + self.send_rcon('g_nextmap %s' % self.next_mapname) + def set_all_maps(self): """ set a list of all available maps