[CF-Devel] bug in remove_ob (object.c)

Kurt Fitzner kf_bulk at excelcia.org
Sat Sep 7 15:24:28 CDT 2002


I've noticed some funny behavior with exits.  When first travelling through an
exit, the exit will drop me on the correct drop coordinates.  If I travel
through the exit again, then it almost never does.  Try going back and forth
between exits and you'll see what I mean.

The issue seems to be around the P_IS_ALIVE flag not getting updated when a
player leaves a map.  This is causing the blocked() function to say the
destination square is blocked because the last person who left it didn't cause
the flag to get updated.

I think the problem is in remove_ob().  The code that looks bad to me is:

    /* last == NULL of there are no objects on this space */
    if (last==NULL) {
        /* comment removed */
        SET_MAP_FLAGS(op->map, op->x, op->y,  P_NEED_UPDATE);
        update_position(op->map, op->x, op->y);
    }
    else
        update_object(last, UP_OBJ_REMOVE);


This is at line 1255 or so.

The loop just before this code is looping through all the objects on the
square the player was at, activating the walk_off if needed.  'last' in this
case, is the last object remaining in the pile (the player using the exit has
already been unlinked from the chain at this point).  The issue is that
update_object() is being called given 'last', which is the last object still
in the list, instead of the object being removed.  update_object() then is not
doing an update of the player's square, because 'last' isn't an alive object.

I think update_object here needs to be called with op, which is the pointer to
the actual object being removed.

I've made this change on my server, and initial tests show that it fixed the
problem.  I'm not familliar enough with the workings of movement and map flag
updating, though, to know if this might not break something else.

        Kurt.


    
    


More information about the crossfire mailing list