]> granicus.if.org Git - nethack/commitdiff
Fix scattering - the splitting code doesn't look right - it will
authorwarwick <warwick>
Mon, 9 Sep 2002 05:44:32 +0000 (05:44 +0000)
committerwarwick <warwick>
Mon, 9 Sep 2002 05:44:32 +0000 (05:44 +0000)
leave avg 1/2 the object's quantity on the scatter point.
Return count of how many objects actually left the scatter point.

include/extern.h
src/explode.c

index 8e06bd3fe2ebc6202fd2311690f2ae94d7b12a14..27255567047350c7f9b902f79f5fc04212950a71 100644 (file)
@@ -582,7 +582,7 @@ E long FDECL(rndexp, (BOOLEAN_P));
 /* ### explode.c ### */
 
 E void FDECL(explode, (int,int,int,int,CHAR_P,int));
-E void FDECL(scatter, (int, int, int, unsigned int, struct obj *));
+E int FDECL(scatter, (int, int, int, unsigned int, struct obj *));
 E void FDECL(splatter_burning_oil, (int, int));
 
 /* ### extralev.c ### */
index 5413bdf8fa2533f054394006b5a3ebad3737d9b9..39deafc4fe532d11257290bc6a73af962b2d4d8a 100644 (file)
@@ -400,7 +400,8 @@ struct scatter_chain {
  *     MAY_FRACTURE    Stone objects can be fractured (statues, boulders)
  */
 
-void
+/* returns number of scattered objects */
+int
 scatter(sx,sy,blastforce,scflags, obj)
 int sx,sy;                             /* location of objects to scatter */
 int blastforce;                                /* force behind the scattering  */
@@ -413,11 +414,11 @@ struct obj *obj;                  /* only scatter this obj        */
        uchar typ;
        long qtmp;
        boolean used_up;
-       boolean split_up = FALSE;
        boolean individual_object = obj ? TRUE : FALSE;
        struct monst *mtmp;
        struct scatter_chain *stmp, *stmp2 = 0;
        struct scatter_chain *schain = (struct scatter_chain *)0;
+       int total = 0;
 
        while ((otmp = individual_object ? obj : level.objects[sx][sy]) != 0) {
            if (otmp->quan > 1L) {
@@ -425,17 +426,8 @@ struct obj *obj;                   /* only scatter this obj        */
                if (qtmp > LARGEST_INT) qtmp = LARGEST_INT;
                qtmp = (long)rnd((int)qtmp);
                otmp = splitobj(otmp, qtmp);
-               if (rn2(qtmp))
-                   split_up = TRUE;
-               else
-                   split_up = FALSE;
-           } else
-               split_up = FALSE;
-           if (individual_object) {
-               if (split_up) {
-                   obj = otmp;
-               } else
-                   obj = (struct obj *)0;
+           } else {
+               obj = (struct obj *)0; /* all used */
            }
            obj_extract_self(otmp);
            used_up = FALSE;
@@ -549,12 +541,16 @@ struct obj *obj;                  /* only scatter this obj        */
                stmp2 = stmp->next;
                x = stmp->ox; y = stmp->oy;
                if (stmp->obj) {
+                       if ( x!=sx || y!=sy )
+                           total += stmp->obj->quan;
                        place_object(stmp->obj, x, y);
                        stackobj(stmp->obj);
                }
                free((genericptr_t)stmp);
                newsym(x,y);
        }
+
+       return total;
 }