[Commits] [wesnoth/wesnoth] 2c7a64: Lobby Data: minor cleanup, fixup

GitHub noreply at github.com
Sun Oct 29 16:30:36 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 2c7a64143a28827993f6fd1fa858ff7a03f79b56
      https://github.com/wesnoth/wesnoth/commit/2c7a64143a28827993f6fd1fa858ff7a03f79b56
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-10-30 (Mon, 30 Oct 2017)

  Changed paths:
    M src/game_initialization/lobby_data.cpp

  Log Message:
  -----------
  Lobby Data: minor cleanup, fixup

* Wrap spaced_em_dash in a function since we can't guarantee font::unicode_em_dash will be initialized
  before this is, and Travis is crashing.
* Remove an unnecessary std::string::find_first_of result check. If no character match is found, that
  returns std::string::npos, which substr takes to mean the entire string.


  Commit: 7da37fd84a35962ed02c62cb9705affcc0928ff6
      https://github.com/wesnoth/wesnoth/commit/7da37fd84a35962ed02c62cb9705affcc0928ff6
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-10-30 (Mon, 30 Oct 2017)

  Changed paths:
    M src/gui/dialogs/multiplayer/lobby.cpp
    M src/gui/dialogs/multiplayer/lobby.hpp

  Log Message:
  -----------
  MP Lobby: refactored game entry code

This fixes #2121.

This code was an absolute mess. It relied entirely on finding games by-index, despite there also
being a simple function in lobby_data to get a game by id. I had even written code to take an id,
find a game_info ptr, then search the games vector for a match, get an index, and then use that
index to access the games vector later :| *facepalm*

Binding indices with callbacks meant  certain callbacks such as the list double click handler needed
to be constantly re-added. We also had no bounds checking in said callback. And for some reason, the
inline join/observe buttons were  handled by the same code as their global counterparts (#2121).

Just... a mess. Now we can directly handle joining by either index or game id directly. The former
is now only used for the global join/observe buttons' callback, but it could potentially be used
with the plugin context code, if applicable. It depends on whether the plugin data has an index key.


Compare: https://github.com/wesnoth/wesnoth/compare/699407d7f0a2...7da37fd84a35


More information about the Commits mailing list