Suspected bug in Shops

From: Ken Ray (
Date: 06/09/02

I believe I have noticed some strange behaviour with shops - in particular
if the shopkeeper has only one particular item for sale.  By the way, this
is with Circle30bpl21, running on Linux 6.1

What I have set up is a shopkeeper who only sells one particular object, and
doesn't buy anything.  The entry in the .shp file has the obj vnum for the
item he sells.  In the .zon fil, the shopkeeper is loaded in his shop, then
given lots of this one item (I assume a quantity of 999 results in

When I look at the shopkeeper with an immortal, he does in fact have the
item he sells, but if I type in list, the response is just:

"Presently, none of these are for sale."

If I type "buy <object that I know he has for sale>", then he sells it to me
in the expected manner (and also takes the money for it!!)

I looked in the shopping_list routine in shop.c, and found what I believe
the problem to be.  There is a for loop that goes through all the objects
the shopkeeper currently is carrying.  The first time through, the pointer
last_obj is NULL, so this executes a special section of the code, which sets
last_obj to the current object, and the count of that object to 1.  Note
that we haven't set the "found" flag to true yet.  We continue looping.

Lets assume that the shopkeeper has more of the same item - so the second
and subsequent times around this for loop, since last_obj is no longer NULL,
the first else clause will be executed.  But the first statement in this is
an if test to see if this object is the same as  the previous object, and if
so, all we do is increment the counter.  We still have not set "found" true,
nor have we listed anything.

What I believe is happenning is that since we never execute the code section
that actually lists the line showing the item and the quantity on hand
(because the trigger for this is when we find a new item that is not the
same as the last item).  This section also sets the flag "found".

Once we have added up the total number of items (all of hte same type), we
have not actually set this found flag.  Hence the program logic things that
there is nothing currently available.

I have checked the latest cvs on the ftp site, and also scanned through the
complete change log, and there is no mention of this.

Question:  Am I completely deluded, or is this an actual bug that has not
been discovered yet?

Ken Ray

MSN Photos is the easiest way to share and print your photos:

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT