MP Server Ilor

From The Battle for Wesnoth Wiki


The "Multiplayer Improvements" Wesnoth project for Google Summer of Code has been completed. The main objectives of the project were:

  • to create a new lobby interface using the new widget toolkit being developed by Mordante. This new interface is functional, but still marked as experimental due to some unresolved issues. Improvements in the new lobby include:
    • More compact game list
    • More chat space with new whisper/room interface
    • More general flexibility -- many aspects can be changed in WML without having to rebuild
  • to add a room system to the Wesnoth server, similar to IRC channels. It is working, however only the experimental lobby has a convenient interface for it. See MultiplayerRooms.
  • to offload some random number generation to the server to prevent cheating. Combats now rely on a random number provided by the server which is generated after the decision to attack has been made.
  • to simplify server moderation by allowing server mnods to isue commands without having the game launched. While less interesting for players, this too has been done (with a big "thanks" to Soliton) and is working fine.

The results of the project can be seen in Wesnoth 1.7.3, to see the new lobby the --new-widgets command line switch must be used. Once the new lobby is declared stable, it will replace the old one and the switch will not be needed.

About me

My name is Tomasz Śniatowski, ilor on irc/gna/forums/wiki, I'm a third year software engineering student in the Wroclaw University of Technology in Poland. My preferred e-mail adress is kailoran(at]

I chose to participate again to allow myself to focus on Wesnoth development during the summer i.e. earn summer money while doing something fun. Wesnoth was my default choice for an organization as I feel that being already familiar with the code will allow me to be much more productive.



Last year I successfully participated in Summer of Code, completing the Editor2 project. I am currently maintaining the new map editor and sometimes doing some small random fixes or features around the code.


A few years back I wrote a (now defunct, but useful for a long time) helper utility for a browser based strategy game ([1]) that automated some tedious tasks. Some time later I got involved for a while in another browser based game, a local text MMORPG under construction ([2]). I wrote several helpful Greasemonkey scripts, such as a simple ajax-ification of part of the game, that I hope will be integrated into that game someday. I also had some chats with the game developer and helped him with some PHP and database stuff. I'm not more involved there because the developer wants to keep it a one man job for now, and it's a closed project which makes it appeal to me less and less.

I also have some intermediate-level database knowledge, mostly MySQL for webapps and MSSQL for a proprietary accounting application I helped deploy and maintain in a small company. Right now I'm in the middle of a database design course at my uni but I'd rather not talk about it. It's in MS Access and that should be enough.

I have also coded some websites as a kind of part-time job. This included using an established framework (Zend) and adapting and maintainng open-source software installations (oscommerce).

I have mostly worked on my own, though once or twice I coded something with 2 or 3 friends. A notable example from this school year was writing a simple raytracer from scratch (in C++), which later became the basis for a distributed systems project. This was a very interesting experience, especially since eventually it all worked fine. The raytracer I wrote on my own, the distributed bit was in cooperation with a friend. We ended up modularizing the project which allowed us to work efficiently, and the project was well-received by the profs.


I played lots of various games, from strategies both real-time and turn-based to shooters and RPGs. I tend to play mostly singleplayer, and like a good story in a game, though some games, like racing sims, don't really need one. I also think that bad gameplay can kill a game regardless of story. I also really prefer solid gameplay to stunning visuals, possibly because I could never justify buying a high-end gaming rig. I have played some Wesnoth campaigns, enjoyed them, but generally find myself not having time for a lot of games lately, including Wesnoth.

Communication skills

English is my second language -- my first is Polish. I have no trouble communicating in English in any way. I consider myself fairly good at interacting with other players and developers. I try to give advice when I can and when I am fairly confident it will be correct. I don't really like people who keep giving "advice" despite not knowing much. I'm perfectly fine with receiving advice, I generally prefer having someone look over my ideas especially when starting on something new. Sometimes I ask for help, sometimes I make it a point to figure out stuff by myself.


The project is to extend the wesnoth multiplayer server and the client-side lobby interface, as outlined in SoC_Ideas_Multiplayer_server. There are essentially two parts to the project, an UI ovarhaul in the client and some modifications to the server, with choices to be made in both cases.

Design considerations

Lobby channels/rooms/filters

Channels are probably the most common way of handling larger audiences, but there are concerns that it'd split the community, and make moderation more difficult. One other idea was a "chat filters" thing, but I'm not entirely convinced it'd work well. Regardless of the choice, I think all users should start in the general lobby by default and only move elsewhere if they really need to. Assuming channels, I'd make it so everyone's in the lobby always, but can join a different room if they want to. A tab-like interface would allow switching rooms, as is common in chat apps, irc etc.

Wesnoth-less wesnothd chat / moderation

In general starting up Wesnoth takes a while and keeping it on is a bit of a hassle. An irc-server-like interface to allow moderation would be very welcome, but I think might be too difficult. If we'd want to mirror the room structure into a server, I think the best approach would be to extend an existing modular ircd with a wesnoth interface.

Extending the lobby bot would be another option esp. if we don't do channels. The bot is in perl which I don't know well but I probably could manage if the scope of the canges required there would be small enough.


It seems well established that ranking should not be a part of the server. If anything, a method of veryfing that a game has been played (by e.g. the server publishing replays) could be desirable to help ladder efforts, but this has been determined to be fairly low priority. Also Soliton seems to have taken matters into his own hands and worked on that. Ditto for a surrender feature (as opposed to quit), which is possibly complicated and not really in the scope of the project.

Server-side RNG

It came up that it would be useful to delegate the random number generation to wesnothd to alleviate some potential cheating (predicting next RNG rolls since the client knows the seed). It would involve the client asking the server for a bunch of random numbers to be used as a seed whenever it needs to do some dice-rolling. This can potentially bring some unwanted lag, but the added security might just make it bearable.

After some discussion it seems that a reasonable idea would be to have a new delegating RNG in the game that would have a special state variable (validity). The RNG would become invalid after every action that involves user interaction (like unit movement, attack selection, deciding to recruit, answering a WML dialog question, etc). When a random number is required and the generator is invalid, it will ask the server for a new random seed. If the RNG is valid, it'll just generate another number. This way there are no changes to be done in WML and the random numbers become safe.

The WML side of this is a bit tricky, it might be required to add another method of RNG generation to split "private" and "shared" random numbers. This will also require in-depth investigation of how the data about what's happening ingame is sent around. It is much simpler in the (far more crucial imo) case of combat -- when the final decision to attack is made (attack type is selected) the game will ask the server for a seed to be usd in this combat only, making combats unpredictable and cheat-proof. This should be enough to test the validity of the entire approach.

Server-side details

Maintenance work

The server looks like it needs some maintenance. Having the lobby be a special game works, but isn't really logical and leads to hacks and workarounds. I'd extract the common actions for games and the lobby into a superclass and derive Lobby (or Room) and Game from that class. Documenting along the way would be helpul, too.

Options are not necessarily bad

I think that regardless of what we decide to implement, there should be a way of disabling it (other than reverting all the changes). For instance, if we implement rooms, there should be a simple "one_lobby=yes" value to set in order to revert to a behavior similar to the old one. Even if we decide not to do a feature, I'd rather have the code written in a way that would allow adding it later without having to redesign half the server (or client).

Server-side RNG

The server bit of the server RNG looks rather simple. The server just needs to maintain a RNG and send random numbers to clients when asked to.

Client details

Redo the interface in gui2

There's little point in trying to expand the old widgets lobby when there's a new toolkit around. Some new widgets will have to be created first, notably the minimap and a tab control. Tabs could be simulated by buttons though.

Concept sketch

I can code better than I can sketch, but anyway: [3]

More games shown at a time

The current UI shows only 4 or 5 games and wastes a lot of screen space. My idea would be to collapse all games except for the selected one into much smaller bars with a smaller minimap and less information, possibly by using icons and/or skipping some redundant text. The selected game would have a similar look to what's there now, with the notable addtion of the join and observe buttons which I think would work better near the game as opposed to somewhere on top. This would also help save some vertical space which is usually at a premium.

Powerful game filters

There should be a method of filtering to search for games with a particular era, games that allow obervers or not, game names, creator names etc. I think this should be accomplished by a combination of filtering and sorting the game list. To avoid confusion, I think the game list should display "Games: showing NNN of MMM" to indicate that a filter is active.

More chat space

A button to expand the chat window so more text fits, at the expense of the game list. The userlist could also be hidden, but I'm not sure what could reasonably be done with that space as there's usually enough space horizontally.

Private chat tab

We already allow private messaging via the /whisper command, but it's not very convenient. I think a query-like separate window for private chats could be useful, similar to what irc clients do. I also think that such windows should display a reminder on how to use the ignore list and how to restrict private messages to friends only to make it easy for people to avoid abusers.

Player list improvements

The colors and fonts used to signify players in the current gamel, nick registered status etc are not immediatelly obvious to me. I'd add small textual info to separate the groups, and avatar-like status icons to indicate different types of users (unregistered, registered, moderator etc.). If we consider adding a ranking system, the "rank" could also be indicated by a different icon. I'd rather not allow custom icons. Since there will be no ranking in the project, this bit is moot.

Server-side RNG

Implementing that in the client might require some engine changes but mostly will need lots of engine *understanding*. This is quite orthogonal to the rest of the project and also it's not yet certain how much of an impact the added delay would have. Therefore I think it'd be good to implement a prototype of this early (e.g. with combat only, disregarding WML random numbers) just to see how it works in practice. Then it should be decided whether or not to proceed and whether or not this feature should be optional so players can disable it if they can't stand the lag.


The idea page indicates that the first milestone should be a summary of studies and proposed interface changes, but disucssion revealed that a concrete list of features and milestones would be preferable now, and this is the approach I'm taking.


As for the design decisions, my take is:

  • Ranking is out, as a conscious design choice that I understand and kind of agree with.
  • I think that in general rooms are the way to go, but if another idea solidifies before the project begins, I can imagine adjusting the design and milestones accordingly if it is generally agreed to be better. Right now I think a flexible room system is the best option.
  • In particular, I think the room system should be flexible enough to allow limiting users to a predefined set of rooms, for example consisting of the main lobby and language-based channels only. (note that *allow limiting* is not the same as just *limit*)
  • regarding wesnoth-less moderation, after some thought I think that upgrading the lobby bot to accept mod commands is the most reasonable choice. It should be fairly simple to implement, unlike the irc server module idea, and just as useful unless we'd want to moderate dozens of channels which probably wouldn't work anyway.

Feature short list

  1. A gui2 lobby
    1. New gamelist
    2. New userlist
    3. "More chat" and "more games" modes
    4. Private messages tabs
  2. Game filters
  3. Configurable room system
  4. Server-side RNG
  5. Some method of wesnoth-less moderation

Things to do before the program starts

  • preliminary wesnothd refactoring (e.g. split lobby and game classes)
  • writing missing gui2 widgets (minimap, tabs)
  • investigate bug Mordante about gui2 tooltips
  • understand the current client-server protocol


  • May 26 (official program start) - have most of the initial stuff above done
  • June 28 have the server-side rooms in a working state, a protocol update with (possibly interface-less) support in the client, plus a (non-functional) prototype of the new lobby gui
  • July 5 have a prototype of the server-side RNG done, test how it works
  • July 12 (midterm evaluations deadline - 1 day) - have a working "new lobby" with basic room support, simple filters, user list. Possibly without mode switching (1.3). Decide on what to do with the server-side RNG.
  • July 26 - have the planned features roughly done. Start polishing and work on the wesnoth-less moderation. Have a decision on whether it's a lobby bot upgrade or something more.
  • August 3 - have the server-side RNG working (if it's decided worthy of more work after the prototype
  • August 15 (before final evaluations) - have a polished new lobby plus the game-less moderation feature.


note: .5 goal were added after the project was accepted.

0 Missing gui2 widgets


Write the minimap widget (unless someone beats me to it [1]) and probably test it somewhere in the editor. Also loook into a tabbed control (not really mandatory since I'll be able to make do with buttons) done (by others)
1 Initial wesnothd refactor


Make the lobby a separate class and not a hack in the game class. Extract common functionality into a base class or a utility class. Document code along the way. done
2 Gui2 tooltips


Look into being able to show gui2 widgets as tooltips (i.e. not just text). Optional, since it'd be nice to have but nothing will rely heavily on it. skipped
3 Understand the MP protocol


Figure out how the chat and games work now. Optionally this could result in writing some documentation. done
- 0th milestone


Would be nice, but not required, to have the above done when the program starts (May 26) n/a
4 Update to the MP protocol


Document how the room system will be reflected in client-server messages (MultiplayerServerWML) done. Updates to be done if protocol is expanded.
5 Server-side rooms


Implement the server part of the room system. Have a room class or equivalent, and the proper server behavior to react to "/joins", "/parts" and messages in general. done
6 Client-side rooms


Write a crude, possibly not very functional and heavy /command-based interface for rooms in the game client. Test the server implementation. done
7 Simple gui2 lobby


Write a simple lobby in gui2. Doesn't have to include any of the "new" ideas for the lobby look, can be just a crude imitation of the current lobby with "a" game list, "a" playerlist and "a" chat window. done (very crude)
- 1st milestone


Have the above done by June 28, with the exception of the lobby gui which might be non-functional yet. Delayed by a week, done.
7.5 Client-side rooms logic and logging


Write the non-gui parts of lobby room logic (keeping info about the rooms the player is in, what players arein what rooms, what games are on the server etc) done
8 Proper rooms in gui2 lobby


Write a proper tab-based (or fake tabs with buttons) interface for having many rooms open in the lobby, and interface for joining and quitting rooms. done
9 Proper game list in gui2 lobby


Write the new game list as outlined in the proposal, with emphasis on being more space-efficient. No filters here. done (two modes idea delayed for now)
10 Game list filters


Decide in the interface and implement some simple filters (text matching, free slots, with friends) for the new game list done
- 2nd milestone (midterm)


Have the above done by July 12. done
11 Advanced game list filters


Write more game list filters like filtering by era, filtering by eras the player has, text-matching for stuff beyond the game name etc. plus a fancy interface for it.

note: Will need a "widget wrapping horizontal container" to be "fancy" and allow more filters in a neat way that works on many resolutions withouit wasting space

delayed, 40%.
12 Tab interface for whispers


Write the tab interface for private messages done
13 Proper userlist in gui2 lobby


Write a rough equivalent of the current player list with some upgrades (group labels instead of just colors to distinguish player groups, ability to hide some of the groups) done
14 Advanced userlist


Implement all the outlined upgrades to the player list, with icons, nice interface for hiding groups, sorting options, possibly being able to hide the player list entirely. done
15 Lobby mode switching


Implement the swicthing between "more games, less chat" and "less games, more chat" idea. 0%, delayed
16 Server RNG prototype


Write a simple RNG service in wesnothd. Write a simple server-rng-using RNG in the client. Wire it up to do combats and test. If not feasible, write a descriription of the problems encountered. done
16.5 MP protocol cleanups


Clean up what the server sends to the client esp. in regard to game info to avoid some pointless tricks 0%, delayed
- 3rd milestone


Have the above done by July 26. There are a lot of "optional" features there -- at least one of those should be finished. done
17 Simple wesnoth-less moderation


Write "a" way of moderating wesnotd without launching the game. Could involve having to type a special password with each privmsg command to the lobby bot, but should work. done
18 Advanced wesnoth-less moderation


Write a proper bot or bot-like feature that will recognize moderators on IRC and allow them to moderate easily. done
19 Full server RNG


If the prototype is successful, wire all random numbers to use it, make it robust. 20% groundwork laid, delayed
20 General polishing


Touch up various areas of the code, especially make sure the gui behaves nicely. done as far as feasible, ready for more testing
- 4th milestone (final)


Have the project in a working and polished state by August 15 10. done

Remaining issues

[M] - Mordante, [I] - Ilor, [O] - other people


  • [M] The mouse focus dynamic cast fail (tm) discovered by Soliton. Confirmed and being worked on by Mordante [Fixed in 1.7.3]
  • [I/M] The log in to trunk, try logging into 1.7 server assert discovered by me, I need to get more info as it seems difficult to reproduce. [Fixed in 1.7.3]
  • [M] Resizing is not reliable, resizing down can result in an exception and a drop to titlescreen if there's not enough space; resizing up can create garbage in the output (at least on winxp). Mordante notified and working on fix.


  • [M/I] Vertical layout jumpiness (stuff changes size as more games appear and more chat lines are in the log). Alleviated somewhat, but not perfect.
  • [M] Tooltips don't work for icons inside a toggle panel
  • [I] Room system needs docs and testing [see MultiplayerRooms for the docs]


  • [M] A wrapping widget container would allow some nice layout effects
  • [I/O] Some icons desperately need changing [done in 1.7.3]
  • [M] Buttons working inside a toggle panel would be nice
  • [M] Scrollbars can appear for no particular reason
  • [M/I] Not everything is tweakable in WML - color/formatting for friends, game status, some icons etc


The project was completed on time, with the mandatory goals reached and most of the optional ones done as well. Notably skipped was the more chat or more games idea, mainly due to gui2 issues with getting the layout to work exactly as needed. Highlighting the current gamelist element with a more verbose item layout was not done because the "compact" layout seems to work fine. The UI part of the project in general was a major test of the GUI2 framework, and while there were and are some issues, the advantages of gui2 are very clear in many areas.

Regarding non-UI parts of the project:

  • the room system on the server works, but might need additional tests and tweaks as it gets used
  • basic server side RNG works, switching all MP random number generation to the server-based method is an objective for 1.8, as is some documentationa s to how the system actually works, which is sadly missing at the time. Expect it at Server RNG.
  • wesnothd-less moderation (lobby bot improvements) turned out to require only adapting existing code to expose more features and use more of what irc offers

Practical considerations

I have good knowledge of C++ (and STL), I'm moderately familiar with the Wesnoth codebase and I started to look into wesnothd sources. I learned C++ pretty much on my own, first by coding small problems for some local programming/algorithm contests. I even got to the country finals once, though I'm not a huge fan of 5-hour "reimplement the appropriate algorithm in each of the problems" events. At least this made me pay attention to computational etc. complexity issues. Later I got some more useful knowledge from various books and experimenting. I'm comfortable with Sub­­version and intent on finally trying git-s­­v­­n. I develop mainly on windows on MSVC but can switch to linux if it turns out toying with wesnothd is problematic on windows.

I use MSVC mainly because it's a powerful and helpful tool, though not without defects. I also use a lightweight smart text editor (notepad++) for general editing. Cygwin, putty, wireshark are some useful tools I use quite often. I am awake between around 0900 UTC and 0100 UTC, and online for an hour or two in the mornings and for most of the evening/night. I can sometimes be reached during the day on IRC if the campus wifi works good enough and I have my laptop with me. No objections towards talking on thephone, voip on whatnot, in English or Polish.

As I'm a student in Europe, I will have a lot of exams at the end of May and in the first half of June, and will not be able to do much work during that time. I will be generally available, just busy. I plan to offset this by doing some work during the "community bonding" period and, well, working hard in general :). This is also why I give myself quite a lot of time between the program start and the first item on the timeline.

This page was last edited on 21 March 2013, at 01:12.