]> granicus.if.org Git - nethack/commitdiff
Use existing function to count containers
authorPasi Kallinen <paxed@alt.org>
Sat, 28 Mar 2015 14:24:25 +0000 (16:24 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 28 Mar 2015 14:24:25 +0000 (16:24 +0200)
src/pickup.c

index 476d85798e11cc9d9bac678f42e5518423ef0885..d2a76416cee7e5019f48f00ed29378e81c2c90f1 100644 (file)
@@ -1498,6 +1498,7 @@ doloot()  /* loot a container on the floor or loot saddle from mon. */
     char qbuf[BUFSZ];
     int prev_inquiry = 0;
     boolean prev_loot = FALSE;
+    int num_conts;
 
     if (check_capacity((char *)0)) {
        /* "Can't do that while carrying so much stuff." */
@@ -1518,15 +1519,11 @@ doloot()        /* loot a container on the floor or loot saddle from mon. */
 
 lootcont:
 
-    if (container_at(cc.x, cc.y, FALSE)) {
+    if ((num_conts = container_at(cc.x, cc.y, TRUE)) > 0) {
        boolean anyfound = FALSE;
-       int num_conts = 0;
 
        if (!able_to_loot(cc.x, cc.y, TRUE)) return 0;
 
-       for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = cobj->nexthere)
-           if (Is_container(cobj)) num_conts++;
-
        if (num_conts > 1) {
            /* use a menu to loot many containers */
            int n, i;