On Wed, 17 May 2006, Jimmy Huang wrote:
> > It's clear that setting closest_pl to NULL means
> > something, that the player
> > isn't near a planet.  Setting it to some random
> > planet will just make the
> > bot make mistakes.  What would be the correct thing
> > to do, would be to fix
> > the bug in closest_planet() that makes it fail,
> > rather than just making
> > random changes with no clue what effect they will
> > have.
>
> Been reading through that code. There's no reason why
> closest_pl should ever get set to NULL. There's ALWAYS
> a closest planet.
>
> The reason closest_pl gets set to NULL is because the
> enemy player cloaks, and so the client has no
> information. It sets it to NULL instead of some

Doesn't need to cloak, just be far enough away that it's not visisble to
the bot.

I think if keeping the stale information around was a good idea, Hadley
would have done that.  He clearly detects invisible players, and sets the
closest planet to NULL, then checks for this everytime closest_pl is
examined.

Also, have you considered what happens when the bots first joins, and has
never seen where some player is?  What will closest_pl be, some random
uninitialized data?  NULL anyway?

> Hey! I think that would work! I should add that in
> too!

That is a fix for the real bug.  The closest planet would get set to NULL
every other update.  Once that is fixed, me_p->closest_pl should never be
NULL.  p->closest_pl may be NULL for an invisible player, but every use of
that is always checked for NULL first.

> I plan to do that, as I am sure there are some
> consequences (even though they don't crash anymore).
> I originally did the same thing to
> test for NULL'ness for me_p->closest_pl. And just
> avoid the SIGSEV. This resulted in bots that started
> to not report where they wanted to take their armies
> to.

There is a bug in the function that generates RCDs.  I fixed it months ago,
but since CVS was down I never committed it.  The bot will crash if it
tries to bomb or take and can't see any friendly or any enemy players.

If you want to fix mfprintf, man stdarg