[CF-Devel] Strange problem, possible related to new attack fixes (hit player)
Jan Echternach
echter at informatik.uni-rostock.de
Fri Nov 24 02:10:34 CST 2000
On Thu, Nov 23, 2000 at 04:52:38PM -0800, Peter Mardahl wrote:
>
I checked in a "fix" for this problem, but I think the bug is
>
actually somewhere else than I "fixed" it.
Oops, my bug. And the bug really is in check_fired_arch().
hit_player() is allowed to do about anything. hit_player() can trigger
runes, runes can summon monster, monster can pick up stuff, etc. pp.
>
if (was_destroyed (op, op_tag) || ! was_destroyed (tmp, tmp_tag)
^^^^^^^^^^^^^^^^^^^^^^^^^^
>
|| (op->stats.dam -= dam) < 0)
>
{
>
if(!QUERY_FLAG(op,FLAG_REMOVED)) { /* line ADDED */
>
remove_ob (op);
^^^^^^^^^^^^^^^
>
free_object(op);
>
return;
>
}
Broken code (without the QUERY_FLAG) - if 'op' was already destroyed
(which means it was already freed), it will be removed and freed
again.
'op' may have been reused and therefore not have FLAG_REMOVED, even
though it's not the same object anymore. Correct fix would be this:
if (was_destroyed (op, op_tag))
return;
if ( ! was_destroyed (tmp, tmp_tag)
|| (op->stats.dam -= dam) < 0)
{
remove_ob (op);
free_object(op);
return;
}
Maybe remove_ob() and free_object() should just print an error message
and otherwise ignore objects that are already removed or freed. This
would prevent some needless server crashes.
--
Jan
More information about the crossfire
mailing list