Up to Main Index                            Up to Journal for August, 2016

                   JOURNAL FOR WEDNESDAY 17TH AUGUST, 2016
______________________________________________________________________________

SUBJECT: Throwing out code to make it better
   DATE: Wed 17 Aug 22:25:26 BST 2016

Busy coding away on WolfMUD this evening when I realised I hadn't written a
journal entry for last week. You didn't miss much. It's not that I didn't do
any coding, I just threw the changes out again.

What was I working on? I was making it so that the same account could not log
in multiple times. My initial attempt involved changing the current player
list in the stats package. Currently the list is a simple struct with a slice
and a sync.Mutex:


  var players = struct {
    list []has.Thing
    sync.Mutex
  }{}


The plan was to make the slice a map and use the account as the key:


  var players = struct {
    list map[string]has.Thing
    sync.Mutex
  }{}


For a number of reasons this didn't work out. First issue was that the player
is not put into the player list until they enter the game. This means it's
necessary to modify the player list to record when the player is 'in game' as
opposed to just sitting at one of the front end menus. Secondly it also makes
the currently simple player list implementation overly complicated with little
benefit. Thirdly there is also the issue of pushing non-game specific data and
processing into the main game code polluting it - which I hate doing.

So after throwing out that idea and all of the associated changes I came up
with a variation on the same idea: Just add an account list to the front end
driver:


  var accounts struct{
    inuse map[string]struct{}
    sync.Mutex
  }


Same idea as before but now we can record accounts currently logged in as soon
as we get a valid login. At the moment the list just stores an empty struct
but will eventually hold account specific information not related to the
actual player: creation date, total game time etc. Going down this path I'll
probably end up totally breaking the current player files :(

Why would this break the current player files? I'm planning on putting all of
the account information: creation time, account Id hash, password hash, salt,
creation time, game time etc. into an account record at the start of the
player file. This is similar to the initial zone record in zone files.

So that's what I'm currently working on.

In other news Go 1.7 is officially released :)

--
Diddymus


  Up to Main Index                            Up to Journal for August, 2016