Up to Main Index                             Up to Journal for March, 2017

                     JOURNAL FOR SUNDAY 26TH MARCH, 2017
______________________________________________________________________________

SUBJECT: An update to resets and respawning
   DATE: Sun 26 Mar 22:33:41 BST 2017

I’ve spent this week continuing the work on item resets and respawning and its
been tough going. I expected it to be — implementing rolling resets and
spawning properly is not easy. There are a lot of things to be considered
besides just the mechanics. You want to make things as easy for other people
as possible while making system itself just do the right thing.

Just the mechanics themselves are complex. You can have items that don’t reset
or respawn. They just get all of their references removed and are garbage
collected. For an item that can be reset you remove it from the world for a
period of time and then it gets put back into the world in its original
location.

Items that respawn are a bit tricker.

For items that respawn you make a non-respawnable copy of the item, which is
what a player will actually pick up. You then remove the original item from
the game world and schedule it for a respawn. When it’s time to respawn you
put the original back into the game world at its original location.

Now comes the really tricky part.

Resettable and respawnable items can also be containers. Containers can have
other resettable / respawnable items in them. These items can also be
containers. In fact you can have containers in containers ad infinitum.

Now I believe I have managed to implement all of the above. For the most part
resetting and respawning are handled automatically. There may be some things
that could be done better, but it is all working.

When it’s time to get rid of an item you just call Thing.Dispose on it. The
item will then be reset or garbage collected as appropriate. When an item is
picked up it will automatically respawn, again if appropriate.

To make respawning automatic I’ve had to make more changes to Inventories. The
Add, Remove and Move methods now return a Thing that may or may not be the
Thing passed in originally to the Add, Remove or Move — it may be an
non-spawnable copy of the original Thing.

To help free resources used by a Thing and its Attributes I’ve implemented a
freeing mechanism. Thing and Attributes now have a Free method which can be
overridden by specific attributes that need to remove cyclic references,
cancel events and such. The older Thing.Close method is no more. This has
actually improved garbage collection a lot as the previous version had quite a
few memory leaks.

Items in the sample zones have been updated to either reset or respawn. The
“Zinara South” zone has also been cleaned up a bit.

I still need to implement automatic clean up of items left lying around. I’m
also still considering the best way to implement custom messages — at the
moment you still get the “There is a gentle pop...” message. The WAIT keyword
on the Reset attribute still needs implementing as well.

There are some minor improvements on the public dev branch. The Door.Unmarshal
method has been cleaned up. The Decode.ParseDuration method in the recordjar
package now handles upper and lower cased parameters. A nil pointer panic in
Locate.Dump has been fixed. Events now log more meaningful messages.

Everything has been updated to the public dev branch. I would welcome any
feedback on the resets and resetting work — good or bad, feedback, ideas or
just general comments: diddymus@wolfmud.org

--
Diddymus


  Up to Main Index                             Up to Journal for March, 2017