Up to Main Index                          Up to Journal for November, 2015

                    JOURNAL FOR FRIDAY 27TH NOVEMBER, 2015
______________________________________________________________________________

SUBJECT: Multiplayer networking and messaging
   DATE: Fri 27 Nov 23:43:22 GMT 2015

Is it possible that this was another good week for coding on WolfMUD? Yes it
was! WolfMUD Wednesday, and Thursday, saw most of the networking code being
written.

I said 'mostly' just now, did you notice? What is the actual state of play at
the moment then? The server listens for TELNET connections and accepts them.
For now player IDs are allocated when the client connects and players are just
called 'Player 1', 'Player 2' and so on - player accounts are not implemented
yet. The player is then put into the world.

Multiple players may run around but they might as well be playing on their own
for now. This is because all of the commands have to be updated to provide
feedback to other players about what is going on. At the moment only the
EXAMINE and QUIT commands have been updated. Here is a simple demonstration
using two players:


Player 1:

  [ Fireplace ]
  You are in the corner of a common room in the Dragon's Breath tavern.
  There is a fire burning away merrily in an ornate fireplace giving
  comfort to weary travellers. Shadows flicker around the room, changing
  light to darkness and back again. There is a small plaque above the
  fireplace. To the south the common room extends and east the common
  room leads to the tavern entrance.

  You can see some cheese here.
  You can see a mug here.
  You can see a box here.
  You can see a bag here.

  You can see exits east, southeast and south.
  >exam box
  You examine a box. This is a small, wooden box. It is empty.
  >quit

  Bye bye...

   Connection closed by foreign host.


Player 2:

  [ Fireplace ]
  You are in the corner of a common room in the Dragon's Breath tavern.
  There is a fire burning away merrily in an ornate fireplace giving
  comfort to weary travellers. Shadows flicker around the room, changing
  light to darkness and back again. There is a small plaque above the
  fireplace. To the south the common room extends and east the common
  room leads to the tavern entrance.

  You can see some cheese here.
  You can see a mug here.
  You can see a box here.
  You can see a bag here.
  You can see Player 1 here.

  You can see exits east, southeast and south.
  >
  You see Player 1 examine a box.
  >
  Player 1 gives a strangled cry of 'Bye Bye', slowly fades away and is
  gone.
  >
  Idle connection terminated by server.
  Bye bye...

  Connection closed by foreign host.


You'll notice that Player 1 does not see the arrival of Player 2 yet. Normally
when Player 2 enters the world at the same location as Player 1, Player 1
should see the message:


  There is a puff of smoke and Player 2 appears spluttering and coughing.


The changes required for the EXAMINE command were simple. The QUIT command
caused a bit of head scratching due to removing the player, then sending
messages and getting nil pointers. Trying to add messaging for movement showed
that the messaging mechanism definitely needs some refining. This should also
improve the code for the QUIT command. The messaging mechanism is what I'm
working on now, followed by updating the commands.

Compared to the previous version - PROTOTYPE 3 - the client networking code is
much cleaner and ultra simple. The code and comments come in at 114 lines[1]
compared to 253 lines previously - less than half the code.

The BRL - Big Room Lock - is working beautifully :)

--
Diddymus

  [1] Plus 22 lines of temporary code to generate the player IDs and a few
      constants that will eventually be in the configuration file[2].

  [2] File handling is still on the todo list.


  Up to Main Index                          Up to Journal for November, 2015