wesnoth/wesnoth-old — pull request #87 by cbeck88 (2013-12-05 04:01:38+00:00)
Title: New lua metatable "wesnoth.mp_settings".

Hoping to fill a feature request which I made here:

https://gna.org/bugs/?21208

I introduce a lua metatable to access all the fields that occur in "multiplayer" tag in save game files.

The lua expression "wesnoth.mp_settings.[field]" accesses any field of state_of_game.mp_settings(), if the current game type is multiplayer. The name "field" is chosen according to mp_game_settings::to_config(), so that the field name matches exactly what occurs in save games files.

I don't currently handle vector objects like "active_mods", or the std::map "side_users"... active_mods could be a very useful thing to have access to, if someone could provide a suggestion how best to pass this to lua that would be great.

Side Remark: I noticed when doing this that in mp_game_settings.hpp, .cpp, the fields "share_map" and "share_view" are defined and I assume match those features in game, but they are not written by to_config() and hence not saved in the save file... is this a bug or is it actually intentional? If these are indeed used and should be going to the save file then I will indeed want to add lua hooks to them as well for consistency.