MinoMino / minqlbot-plugins

A collection of plugins for minqlbot.
GNU General Public License v3.0
5 stars 10 forks source link

Don't treat those forced to spec as leavers. #8

Open WalkerY opened 9 years ago

WalkerY commented 9 years ago

I added 2 lines after comment below in balance.py. If I understand correctly, those may be needed.

            if allow_spec:
                player = self.player(name)
                if not player:
                    return True
                if player.team != "spectator":
                    self.put(name, "spectator")

                    # Don't count those pushed to spec as leavers
                    if (self.game().state == "in_progress" and player in self.players_start):
                        self.players_start.remove(player)

                    if rating > max_rating and max_rating != 0:
                        self.tell("^7Sorry, but you can have at most ^6{}^7 rating to play here and you have ^6{}^7."
                            .format(max_rating, rating), name)
                    elif rating < (min_rating+delta) and min_rating != 0:
                        self.tell("^7Sorry, but you need at least ^6{}^7 rating to play NOW and you have ^6{}^7."
                            .format(min_rating+delta, rating), name)
MinoMino commented 9 years ago

Not quite that easy. players_start is a list in the ban plugin, not balance. Accessing it through Plugin.plugins without locks could lead to weird behavior because of race conditions, since the method in question can be called by a different thread. Will fix, though.