Up to Main Index                              Up to Journal for July, 2021

                      JOURNAL FOR SUNDAY 25TH JULY, 2021
______________________________________________________________________________

SUBJECT: Suspend and resume events, disabled items
   DATE: Sun 25 Jul 18:50:25 BST 2021

This update is smaller than usual, I’m still working on resets and respawning
for items. However, I’m pushing out some changes I’ve been working on setting
the groundwork for resets and respawning.

Events can now be suspended, resumed and cancelled. The #DUMP now includes
details for events. Here is an example with the frog, when we get the frog the
action event is suspended with the event due to fire in 18.591 seconds. When
we drop the frog the action event timer continues, with the event due to fire
at 16:37. Note, I’ve only included the information relevant to events in the
#DUMP data below:


  >#dump frog
  DUMP: #UID-DD
  `- 0xc00020b400 *core.Thing - #UID-DD (a small frog)
     :
     |- Events - len: 1
     |  `- Action: 0xc0002580f0, at: Jul 25 16:32:08, in: 20.745s
     `- Int - len: 5
        |- ActionAfter: 15000000000
        |- ActionJitter: 15000000000
        |- ResetAfter: 60000000000
        |- ActionDueIn: 0
        `- ActionDueAt: 1627227128652254907

  >get frog
  You get a small frog.
  >#dump frog
  DUMP: #UID-DD
  `- 0xc00020b400 *core.Thing - #UID-DD (a small frog)
     :
     |- Events - len: 1
     |  `- Action: 0x0, at: -, in: 18.591s
     `- Int - len: 5
        |- ActionDueIn: 18591928192
        |- ActionDueAt: 0
        |- ActionAfter: 15000000000
        |- ActionJitter: 15000000000
        `- ResetAfter: 60000000000

  >drop frog
  You drop a small frog.
  >#dump frog
  DUMP: #UID-DD
  `- 0xc00020b400 *core.Thing - #UID-DD (a small frog)
     :
     |- Events - len: 1
     |  `- Action: 0xc000066550, at: Jul 25 16:37:00, in: 16.399s
     `- Int - len: 5
        |- ActionDueIn: 0
        |- ActionDueAt: 1627227420812322287
        |- ActionAfter: 15000000000
        |- ActionJitter: 15000000000
        `- ResetAfter: 60000000000

  >


The slight discrepancies in the event timing are due to the time it takes me
to type the right commands ;)

You might also notice that Thing.Int values have been changed from int to
int64. This works better with values like durations and also means it’s
consistent across 32 and 64 bit platforms.

The other main change is that a Thing can now hold disabled items that are
currently out of play. Disabled and out of play items, such as those waiting
to reset, are held in a Thing.Out inventory. The #DUMP command will show items
in Thing.Out the same way as Thing.In items are shown.

I did think of adding a Thing.Is Disabled bit for disabled items. However any
code that uses Thing.In would have to be careful to filter out disabled items.
By using another inventory disabled items are never seen by such code. The
trade-off for simpler code is that a Thing has to store another map ;(

A note on Thing and the maps it is using: I do plan on looking at where we can
safely set maps to nil. By safe I mean only setting maps to nil where it is
known that map will never be used. For example, if a Thing is not a location
then Thing.Who could be nil.

I could try to do this with maps not currently in use at runtime. However,
that would mean every time we want to add an element, and don’t want to cause
a runtime panic, a check has to be made and the map created if needed. I’m not
sure the reduced memory footprint would justify the added code complexity or
the additional allocation and garbage collection needed for creating and
deleting maps on the fly.

For now I’m just going to continue to keep things really simple, which is
really hard.

The changes above are on the experiment public Git branch. The reset and
spawning changes are still being developed but will probably be the next set
of changes I’ll be pushing out.

--
Diddymus


  Up to Main Index                              Up to Journal for July, 2021