Re: [Circle] Safe Character extraction.

From: George Greer (greerga@circlemud.org)
Date: 06/27/00


On Tue, 27 Jun 2000, Patrick Dughi wrote:

>        Right now, all I can think of is abstracting the character
>interface.  That is, if you want to access a player, you can't just do
>something like "FIGHTING(ch)"; you'd have to lookup_player(FIGHTING((ch)).
>The FIGHTING macro would no longer return a direct player reference, but a
>lookup reference.  As a programmer, you'd have to stick to using the
>indirect reference, and always checking for NULL values.
>
>        Any alternatives?  I see running through all potential references
>upon each extraction a bit time consuming, and hard to extend.  You'd also
>have to write some sort of check before each potential extraction case to
>deal with it if it does occur.

We need to get rid of the 'pointer twiddling' method of working with the
characters.  Access the characters simply by their ID# and call various
methods/functions (pick your term) to modify values.  Not only will this
make the code not crash, it'll allow characters to be stored in places that
cannot be described in terms of a pointer, like an SQL server or flat file.

In terms of now, I think instant extraction isn't too bad.  All loops with
character extraction could be written with 'restart' logic to stop the
loop, go back to the beginning, and locate the next unprocessed character.
The only downside being that it would suck eggs through a straw.  Anyway, a
more practical method would be locking the character extraction routines
while in a loop.  If a loop runs through, it first locks the list, does
processing, and unlocks the list.  As soon as the list is unlocked, any
pending characters to extract would be removed.  It works sort of like your
method except the notification of 'done' is more explicit.  You'd still
need to write the routines to ignore dead characters.  I think there's
already code to handle that case (as an error) in CircleMUD but you may
need more.

--
George Greer
greerga@circlemud.org


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT