[Commits] [wesnoth/wesnoth] 23ce3f: campaignd: Rename and refactor campaign_server cla...

GitHub noreply at github.com
Wed Jun 11 02:48:46 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 23ce3f8574f8888ff84e88e81a5b105f189fc712
      https://github.com/wesnoth/wesnoth/commit/23ce3f8574f8888ff84e88e81a5b105f189fc712
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp
    A src/campaign_server/campaign_server.hpp

  Log Message:
  -----------
  campaignd: Rename and refactor campaign_server class into campaignd::server

This is the first refactoring step.

This moves the class declaration to a separate header file and switches
around some implementation details. Included in this commit are a few
minor documentation changes, a lot of whitespace and placement changes,
and the following API and behavior changes:

 * Reordered server class fields, keeping net_manager_ and
   server_manager_ as the last to initialize.
 * The campaignd hooks configuration (which hasn't been used in ages) is
   now done in the load_config() method rather than directly in the
   constructor.
 * Both read-only mode configuration and control socket set-up are now
   done in load_config() rather than the run() method.

Included as well are a few Doxygen documentation changes of varying
scope. Most notably, the description for the fire() method's return
value is gone since the method was made to not return a value some time
after its inception.

I also took the liberty to spatially-reorganize some of the involved
code except for the fire() method's body (which is massive and had to be
reindented anyway), in order to make the code more fluid and clean to
read.

Overall, there are deliberately no behavior changes in this step other
than the aforementioned minor bits, in order to make the next steps
easier to plan, perform, and debug.


  Commit: 796b77d44023d0fa555dcca0856d596887d89205
      https://github.com/wesnoth/wesnoth/commit/796b77d44023d0fa555dcca0856d596887d89205
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp
    M src/campaign_server/campaign_server.hpp

  Log Message:
  -----------
  campaignd: Rename a server class field and some scoped_ostream objects

The file_ field is now cfg_file_ to avoid ambiguity ("what file and for
what?"). Since there are a lot of scoped_ostream instantiations around
named cfgfile which are used to write to the cfg_file_ path, those are
now renamed to simply out, also to avoid ambiguity -- just an
intermediate step before refactoring those into a separate method.


  Commit: ada5a7ca60a3280044d201ad5e33c8dbaed4c56f
      https://github.com/wesnoth/wesnoth/commit/ada5a7ca60a3280044d201ad5e33c8dbaed4c56f
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp
    M src/campaign_server/campaign_server.hpp

  Log Message:
  -----------
  campaignd: Refactor config commit boilerplate into a separate method


  Commit: deea32f9a5fd4bb4d2b365945ebc35e2e7a90585
      https://github.com/wesnoth/wesnoth/commit/deea32f9a5fd4bb4d2b365945ebc35e2e7a90585
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp
    M src/campaign_server/campaign_server.hpp

  Log Message:
  -----------
  campaignd: Make input_ a boost::scoped_ptr


  Commit: a8ea4796a0db6ef344da0259f2758048ac6997ce
      https://github.com/wesnoth/wesnoth/commit/a8ea4796a0db6ef344da0259f2758048ac6997ce
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Replace write_config() scheduling mechanism

Check time() deltas instead of incrementing a counter variable forever.
This should allow to extract a bit of the run() logic into a separate
method later.


  Commit: c164cb22b04601a1329274ab65934d02a83ec143
      https://github.com/wesnoth/wesnoth/commit/c164cb22b04601a1329274ab65934d02a83ec143
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp
    M src/campaign_server/campaign_server.hpp

  Log Message:
  -----------
  campaignd: Refactor request handling blocks into separate methods

These methods are tried and run in sequence by looking them up from a
request handler registry maintained as part of the server object. Since
every campaignd request is a single WML node with an identifying name, I
feel this approach makes things more readable than the previous massive
deeply-nested if-else-if chain approach, but that might be just me.


  Commit: e5354435b185dd4e4b02823de972d0630c3af59d
      https://github.com/wesnoth/wesnoth/commit/e5354435b185dd4e4b02823de972d0630c3af59d
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp
    M src/campaign_server/campaign_server.hpp

  Log Message:
  -----------
  campaignd: Refactor construct_message/error() functions and boilerplate

This replaces them with two methods that are part of the server class
itself.

These functions were always used in conjunction with
network::send_data() to send the generated WML object to a network
client. Because the config was created within the functions and not on
the callsite, this resulted in a call to the config copy constructor
that could be avoided by grouping the network::send_data() call together
with the WML generation.


  Commit: 0d81fae45ba767a8127cec896f9c0f5d16d1bb82
      https://github.com/wesnoth/wesnoth/commit/0d81fae45ba767a8127cec896f9c0f5d16d1bb82
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/CMakeLists.txt
    M src/SConscript
    A src/campaign_server/addon_utils.cpp
    A src/campaign_server/addon_utils.hpp
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Move several anonymous namespace members to a new file

This step covers the markup char check function and the add-on feedback
URL formatter.


  Commit: 42ee57c91934fff7f5920ce56eb413dff84963a8
      https://github.com/wesnoth/wesnoth/commit/42ee57c91934fff7f5920ce56eb413dff84963a8
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/addon_utils.cpp
    M src/campaign_server/addon_utils.hpp
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Move and document more ancillary functions

Since the move is between two files, I took this opportunity to rename
a "campaign" parameter to "addon" and tweak the code style for
consistency.


  Commit: 7535b916a3f03191bba3cf48b8d97a64e5930031
      https://github.com/wesnoth/wesnoth/commit/7535b916a3f03191bba3cf48b8d97a64e5930031
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Wrap request handler registration statements in macros

This should make it easier to add new handlers or change their API at a
later point.


  Commit: dff480bb0765beb34ed9192c5e2ca284ed522a2c
      https://github.com/wesnoth/wesnoth/commit/dff480bb0765beb34ed9192c5e2ca284ed522a2c
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Drop pointless use of lexical_cast to set WML attributes

Since 1.9.x, using lexical_cast to set config attributes is no longer
required and the engine will automatically try to cast string values to
a more "natural" type.

Thus, this commit incurs in no real behavior changes.


  Commit: 9b1fd86016d09fdc9d4999d04a7bff38cdaeec05
      https://github.com/wesnoth/wesnoth/commit/9b1fd86016d09fdc9d4999d04a7bff38cdaeec05
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Use empty C strings instead of t_strings to clear out attributes


  Commit: 603c06d1e7793f62e201df09dd5bfe3c46e84c5b
      https://github.com/wesnoth/wesnoth/commit/603c06d1e7793f62e201df09dd5bfe3c46e84c5b
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Show RO mode warning in load_config() rather than in run()


  Commit: e13570954a1abfec49df6d263cbe5b69130bc43f
      https://github.com/wesnoth/wesnoth/commit/e13570954a1abfec49df6d263cbe5b69130bc43f
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Code indentation and spacing style changes for consistency

No functional changes.


  Commit: fb5c5abeffc853665d68495085bdaf2014f6da13
      https://github.com/wesnoth/wesnoth/commit/fb5c5abeffc853665d68495085bdaf2014f6da13
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/campaign_server/campaign_server.cpp

  Log Message:
  -----------
  campaignd: Use const references or values where applicable

Some old code used copies or read-write refererences for strings that
are never deliberately modified afterwards; and a bit of my own code
gets a (arguably tiny) WML config by value from a method that always
returns a read-only reference, missing out on a tiny optimization
opportunity by avoiding a config copy.

There was also a once-written int variable in handle_request_campaign().


  Commit: 52f71d900f1f4a1478bcbebfa1ed963a24be638b
      https://github.com/wesnoth/wesnoth/commit/52f71d900f1f4a1478bcbebfa1ed963a24be638b
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/CMakeLists.txt
    M src/SConscript
    A src/campaign_server/addon_utils.cpp
    A src/campaign_server/addon_utils.hpp
    M src/campaign_server/campaign_server.cpp
    A src/campaign_server/campaign_server.hpp

  Log Message:
  -----------
  Merge branch 'feature/campaignd-refactoring'

Refactors most of campaignd's code to ease future feature additions and
bug fixes, making the code slightly more organized and readable.

No behavior changes expected or observed from the state previous to this
merge.


Compare: https://github.com/wesnoth/wesnoth/compare/148d42ea88a0...52f71d900f1f


More information about the Commits mailing list