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

Re: fixing bug in 0.91.0?



 This patch should make summon pet monster work safely:

 (apply to server/attack.c)
***************
*** 203,212 ****
     * to avoid ever being hit by monsters.
     */
    if (QUERY_FLAG(op, FLAG_MONSTER) && op->speed_left > -(FABS(op->speed))*0.3) {
      process_object(op);
      if (QUERY_FLAG(op, FLAG_FREED))
        return 1;
-     op->speed_left--;
    }
    add_refcount(op_name = op->name);
    if(hitter->head!=NULL)
--- 203,218 ----
     * to avoid ever being hit by monsters.
     */
    if (QUERY_FLAG(op, FLAG_MONSTER) && op->speed_left > -(FABS(op->speed))*0.3) {
+
+     /* Decrease speed BEFORE calling process_object.  Otherwise, an
+      * infinite loop occurs, with process_object calling move_monster,
+      * which then gets here again.  By decreasing the speed before
+      * we call process_object, the 'if' statement above will fail.
+      */
+     op->speed_left--;
      process_object(op);
      if (QUERY_FLAG(op, FLAG_FREED))
        return 1;
    }
    add_refcount(op_name = op->name);
    if(hitter->head!=NULL)


 You should probably use the '-l' option of patch to apply this, since
I just did a copy/paste between xterms, which tends to replace tabs by
spaces.

 --Mark