Up to Main Index                           Up to Journal for October, 2017

                     JOURNAL FOR FRIDAY 6TH OCTOBER, 2017
______________________________________________________________________________

SUBJECT: Command handling and Inventory changes are done
   DATE: Fri  6 Oct 23:44:50 BST 2017

For the last week or two I've been busy reworking and cleaning up two main
areas of WolfMUD - command handling and inventories. Both sets of changes have
recently landed on the public dev branch.

The command handling changes reimplement commands as types instead of just
functions. This makes it easier to add helper methods and to break up more
complex command handling. An example of this is the JUNK command which has
been broken up into several methods.

The command handler for the empty command has been untangled from the handler
code and moved into its own cmd.go file. The empty command has several
purposes. First of all it acknowledges the empty command by doing nothing. If
it wasn't for this handler a player would get a 'Eh?' response by just hitting
enter[1]. The empty command handler is also intended to be embedded by other
command handlers. This will enable helper methods to be added that are
generally useful when implementing other commands.

As a further clean up the state.handleCommand method has been replaced by
dispatchHandler in the handler code. This now means that all of the handling
code is in handler.go which logically makes sense.

The other large change is the more exciting of the two. The Inventory type now
fully utilises the new disabling functionality introduced a short while ago.
This means that all Thing are added to, or removed from, an Inventory in a
disabled state. The big advantage is when moving a Thing between Inventory.
For example when moving between locations, picking up or dropping an item. In
these common cases the code is faster and simpler. Most of the 'magic' in the
Inventory Move method has been removed and it is the commands GET, DROP, PUT,
TAKE and JUNK that now handle the adding and removing of events. Most of the
slow calls to finder methods have been removed from the Move method. In fact
most of the heavy book keeping is now only done when a Thing is added to, or
removed from, an Inventory and not every time something moves.

When disposing of items the ugly corner case of disposing of a Thing that
respawns and then having to dispose of the spawned copy is gone.

There is also a commit for the Inventory Copy and Free methods which did not
handle disabled Thing properly.

All of these changes span more than 30 commits. I could have squashed a lot of
the commits, but I know people like to look at the log and see how I go about
things as well as the why.

Hopefully the next release will be in 25 days, on Halloween... /\oo/\

--
Diddymus

  [1] Actually this is handled a lot sooner, before reaching the command
      processing code. If it didn't and this handler was not there the player
      would receive a 'Eh?' response the same as for an invalid command.


  Up to Main Index                           Up to Journal for October, 2017