Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in insert_ob_in_map()



Hi,

I have found and fixed a bug in insert_ob_in_map() and
insert_ob_in_map_simple() in common/object.c that caused the game to crash
with "Trying to remove removed object.".

check_walk_on() could be called when not all parts of a multipart object
were inserted into the map. Consequently, if the object was moved or
killed by check_walk_on() the object was removed, but not all parts
were on the map at this time.

You will find a map to easily reproduce this bug at the end of this mail.
The dragon will be killed while it is not completely on the map.  Another
way is to shoot hundreds of bolts at the four dragonmans in
/Lake_Country/Mwizard/Mwizard5 until a dragonman steps with his lower part
on a bolt and attack_ob() calls process_object() which moves the dragonman
who can't be moved because he is not completely on the map.

Some system information:
	crossfire-0.92.5
	PC Compatible, Pentium 133, 16MB RAM, 1GB HD
	Linux 2.0.15
	X11R6.1 (XFree86 Version 3.1.2E)
	gcc version 2.7.2 (a.out, not ELF)


Jan Echternach (jan.echternach@informatik.uni-rostock.de)

-----snip-----------------------------------------------------------------
*** object.c	Fri Aug 30 15:42:11 1996
--- object.c-new	Fri Aug 30 15:41:20 1996
***************
*** 1012,1023 ****
    if(!QUERY_FLAG(op,FLAG_REMOVED)) {
      dump_object(op);
      LOG(llevError,"Trying to insert (map) inserted object.\n%s\n", errmsg);
      return;
    }
-   if(op->more!=NULL)
-     insert_ob_in_map_simple(op->more,m);
    CLEAR_FLAG(op,FLAG_REMOVED);
    op->ox=op->x,op->oy=op->y;
    op->map=m;
    CLEAR_FLAG(op,FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */
    CLEAR_FLAG(op, FLAG_INV_LOCKED);
--- 1012,1021 ----
***************
*** 1080,1089 ****
--- 1078,1089 ----
        }
      }
    }
    else
      set_map_ob(op->map,op->x,op->y,op);   /* Tell the map that we're here */
+   if(op->more!=NULL)
+     insert_ob_in_map_simple(op->more,m);
    update_object(op);
    check_walk_on(op);
    if(QUERY_FLAG(op,FLAG_FREED))	/* check_walk_on() killed it */
      return;
    if(op->type==PLAYER)
***************
*** 1124,1135 ****
    if(!QUERY_FLAG(op,FLAG_REMOVED)) {
      dump_object(op);
      LOG(llevError,"Trying to insert (map) inserted object.\n%s\n", errmsg);
      return;
    }
-   if(op->more!=NULL)
-     insert_ob_in_map(op->more,m);
    CLEAR_FLAG(op,FLAG_REMOVED);
    if(op->nrof)
      for(tmp=get_map_ob(m,op->x,op->y);tmp!=NULL;tmp=tmp->above)
        if (CAN_MERGE(op,tmp))
        {
--- 1124,1133 ----
***************
*** 1212,1221 ****
--- 1210,1221 ----
        }
      }
    }
    else
      set_map_ob(op->map,op->x,op->y,op);   /* Tell the map that we're here */
+   if(op->more!=NULL)
+     insert_ob_in_map(op->more,m);
    update_object(op);
    check_walk_on(op);
    if(QUERY_FLAG(op,FLAG_FREED))	/* check_walk_on() killed it */
      return;
    if(op->type==PLAYER)
-----snip-----------------------------------------------------------------

-----snip-----------------------------------------------------------------
arch map
name insert-bug
msg
Creator: Jan Echternach
Email: jan.echternach@informatik.uni-rostock.de
Date: Wed Aug 28 18:17:06 1996
endmsg
hp 15
sp 15
end
arch wall_0
y 2
end
arch wall_0
y 5
end
arch wall_0
x 2
y 2
end
arch wall_0
x 2
y 5
end
arch wall_0
x 4
y 2
end
arch wall_0
x 4
y 5
end
arch thorns
dam 10
wc -20
x 5
y 4
lifesave 1
end
arch wall_0
x 6
y 2
end
arch grate_closed_2
x 6
y 3
connected 1
end
arch grate_closed_2
x 6
y 4
connected 1
end
arch wall_0
x 6
y 5
end
arch button_lever
x 6
y 6
connected 1
end
arch wall_0
x 8
y 2
end
arch wall_0
x 8
y 5
end
arch wall_0
x 10
y 2
end
arch wall_0
x 10
y 5
end
arch wall_0
x 12
y 2
end
arch wall_0
x 12
y 5
end
arch sign
msg
Open the gates, and watch the bug!
endmsg
x 13
y 13
end
arch wall_0
x 14
y 2
end
arch wall_0
x 14
y 5
end
arch oakdoor
slaying /city/city
hp 9
sp 10
x 14
y 14
end
arch oakdoor
slaying /city/city
hp 9
sp 11
x 14
y 15
end
arch oakdoor
slaying /city/city
hp 10
sp 10
x 15
y 14
end
arch oakdoor
slaying /city/city
hp 10
sp 11
x 15
y 15
end
arch big_dragon
name weak dragon
hp 1
maxhp 1
exp 5
dam 1
wc 10
ac 0
x 9
y 3
level 1
can_cast_spell 0
end
More
arch big_dragon_2
name weak dragon
hp 1
maxhp 1
exp 5
dam 1
wc 10
x 10
y 3
level 1
end
More
arch big_dragon_3
name weak dragon
hp 1
maxhp 1
exp 5
dam 1
wc 10
x 11
y 3
level 1
end
More
arch big_dragon_4
name weak dragon
hp 1
maxhp 1
exp 5
dam 1
wc 10
x 9
y 4
level 1
end
More
arch big_dragon_5
name weak dragon
hp 1
maxhp 1
exp 5
dam 1
wc 10
x 10
y 4
level 1
end
More
arch big_dragon_6
name weak dragon
hp 1
maxhp 1
exp 5
dam 1
wc 10
x 11
y 4
level 1
end
-----snip-----------------------------------------------------------------