Fix the bug with huge battle lists building over time

This bug wasn't an easy one to figure out.

After three days of uptime, server (with 1000+ players on night) sends
1800 battles on login, for the main channel. (obviously too much)

It's actually caused because battles are removed from the channel when
there's a result, and from the server when one of the player closes the
battle window. So if a player entered a channel after the battle had a
result but before it closed, the new battle would get added to the channel
but never removed.

It's fixed now! Fix #317

Incidentally this bug allowed me to also fix the dc + tie bug :) (previous
commit)

I also did some code refactoring, to move the channel server code in a
file of its own, in order to have a better vision of the code overall and
find the bug (stopped as soon as I found it)