Re: [crossfire] NPC recursive bug

2006-08-07 Thread Mark Wedel

  I agree that adding new static variables may not be the best thing.

  And actually, for the NPC code, making it so it doesn't need them may not be 
so hard (since I think it recursives pretty locally).  OTOH, it may not be so 
easy - I briefly looked at the apply code before formulating my reply, and it 
can recurse, but pretty indirectly, which is probably why it uses a static.

  The advantage of it actually recursing with passed in value is that it 
eliminates any bug where the count isn't being decremented - to start out with, 
you pass in zero when the player is saying something.


___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire


Re: [crossfire] NPC recursive bug

2006-08-05 Thread Alex Schultz
Mark Wedel wrote:
>> * add a static variable somewhere to prevent infinite recursion
>> 
>   That'd probably work OK.
I'm a bit inclined against that, because if we ever want to add
threading to the server, a topic that had a significant amount of
discussion on IRC a while ago, we would want to avoid use of static
variables inside of functions wherever possible.
Currently there are many instances of functions returning an internally
defined static char array, to return a string, and to make it work with
threading those would need to be modified to take a char pointer in for
what to output to, and modify all calls to them. Removing unnecessary
static variables may be  a significant amount of work (as I once found
when attempting to start that conversion once), and perhaps one extra
static variable won't make much of a difference for when doing new code,
however I'm cautious of using static variables in newly written code as
it may set a precedent to use them even more which could be a pain for
eventual threading.

Alex Schultz

___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire


Re: [crossfire] NPC recursive bug

2006-08-05 Thread Mark Wedel
Nicolas Weeger (Laposte) wrote:
> Hello.
> 
> Related to bug: 
> https://sourceforge.net/tracker/index.php?func=detail&aid=1534889&group_id=13833&atid=113833
> 
> I can see 2 solutions:
> * prevent NPCs to react to other NPCs' chat

  I can't think of anyplace where that would break something, bu that doesn't 
mean it wouldn't.  So probably not a good solution.

> * add a static variable somewhere to prevent infinite recursion

  That'd probably work OK.


___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire


[crossfire] NPC recursive bug

2006-08-05 Thread Nicolas Weeger (Laposte)
Hello.

Related to bug: 
https://sourceforge.net/tracker/index.php?func=detail&aid=1534889&group_id=13833&atid=113833

I can see 2 solutions:
* prevent NPCs to react to other NPCs' chat
* add a static variable somewhere to prevent infinite recursion

First solution I wonder if that wouldn't break maps?

Probably a good compromise is just a static variable in talk_to_npc function.

Opinions?

Nicolas

___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire