Up to Main Index                          Up to Journal for February, 2014

                    JOURNAL FOR FRIDAY 27TH FEBRUARY, 2014
______________________________________________________________________________

SUBJECT: Player creation & saving - the whole story
   DATE: Thu 27 Feb 22:20:59 GMT 2014

After my last entry I had a couple of people ask why the player creation code
should be using the Marshalers. The reason mentioned was so that the same code
could create and save the player file. While correct, it wasn't the whole
story.

When a player is created it has - or will have - an associated race kit and
profession kit. Both kits modify the player by adding initial equipment and
items appropriate to the race and profession chosen for the player. The
equipment can get quite complicated. For example a player may start out with a
bag containing a bottle that contains 2 draughts of a potion. The bag may also
contain a box with things in it such as a pouch with several gems in it - so
now we have a player, with a bag which contains a box which contains a pouch
which contains gems[1]. The kits can also add initial skills and/or modify
money, health, mana, strength, racial friends and enemies.

Obviously all of this information needs saving to the player file. By using
Marshalers we tell the Player type to marshal itself. The Player type does so
and also calls the Marshalers on each inventory item which in turn can call
other Marshaler methods. In fact this is the opposite of what happens when we
load - Unmarshal - a Player. What we end up with are very simple Marshaler
methods that can cascade and save complex structures.

So yesterday evening I spent time working on the recordjar encoder and player
creation code. While doing so I realised I could simplify the account driver
while at the same time avoiding a lot of allocations, temporary variables and
type conversions. The reduced type conversions are especially good news - last
time I was lamenting the amount of shunting I was doing from one type to
another and back again all over the place :)

So, will you be able to create your own accounts and players any time soon? I
hope so, I really do, because that is when WolfMUD starts to become useful -
for a given specific definition of useful anyway ;)

I'm also trying to squeeze in some extra time to work on WolfMUD. Only an hour
here and there at the moment, but every little helps...

--
Diddymus

  [1] This is why parsers can be fun. For example: Put the cat in the hat on
      the table. What does this mean? Take the cat out of a hat and put the
      cat on the table? Or there is a hat on a table and the cat should be put
      into the hat? It's all about context...


  Up to Main Index                          Up to Journal for February, 2014