[Freeciv-Dev] Re: (PR#6337) Hash registration
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cameron Morland wrote:
> Hi,
>
> I don't know what to do in this circumstance. In sanitycheck.c:279 we
> want to assert(!is_ground_unit(find_unit_by_id(punit->transported_by))),
> but find_unit_by_id returns NULL in my particular case, indicating that
> the unit is not "registered". I don't get this hash stuff; what should
> we do if the unit is not registered?
>
> Unfortunately I seem unable to cause this particular crash to occur
> again, but if someone could answer, I'll know next time.
find_unit_by_id returns NULL because the id is invalid. This is/was
because the transported_by field wasn't getting updated at some point,
and then the original transporter was destroyed. This should be fixed
now since transported_by is updated in server_remove_unit().
If transported_by was a pointer, then we'd be left with an invalid
pointer and get a harder-to-track bug. With the hash lookup returning
NULL it's easier to catch the bug. Of course there are disadvantages of
using the ID as well...
jason
|
|