Re: Question involving extract_pending_chars()

From: Peter Ajamian (
Date: 03/27/01

Kras Kresh wrote:
> I upgraded my version to pl18 from pl17.
> Some stuff I need it to kill off the guy immediately with extract_char()

Why?  What are you doing that makes it so critical that the extraction
can't wait a fraction of a second?

> The only problem is that it is used inside of extract_pending_chars(),

What is used inside extract_pending_chars()?  don't tell me you put code
in there that trys to do stuff with the characters being extracted, if
you did you're asking for disaster.  This was just added to bpl18 because
there were problems with characters getting extracted from a list which
was currently in use and crashing the game.  Delaying the extraction
until the end of the game_loop() allows for this situation to be avoided
but if you try to do stuff with characters in extract_pending_chars()
then you are just re-inventing the problem that the function was created
to solve ... in spades.

> either through extract_char_final() which calls on outside functions or just
> inside extract_pending_chars().

Okay, I see what you're saying (though you didn't do a very good job of
saying it).  Here's the deal, don't mess with a character in
mid-extraction, if you do you're asking for trouble.  Why don't you tell
us what you're trying to do and maybe you'll get a few suggestions.

> This would flag him and increment
> extractions_pending, but he might be b4 the current character being
> extracted.

Right, extract_pending_chars() was put in place to avoid exactly this
sort of problem.

> How can i solve this problem?

Set up your loop to work somewhere other than in the extract_char code.
Of course I could be much more helpfull if you give information on
exactly what you're trying to do.

> Should i just call on
> extract_char_final() on him instead of extract_char() or would that screw up
> next_vict?

You can call extract_char_final(), but you would be way better off coding
it so you don't have to.  You should be relatively safe as long as you
make ceartain that you are not going to call extract_char_final on a
character that is next in a loop that you're walking through.

I get the feeling that you're getting things backwards, though.  if you
call extract_char() then you will be safe to finish walking the loop
because the character will not be extracted until after that loop is
finished.  If you call extract_char_final() from a loop you are simply
asking for trouble as you will end up trying to access a character that
has been freed.  extract_char() is safe because it delays the freeing.

Regards, Peter

   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/04/01 PST