 ------------------------------------------------------------------------
    Documentation for the vendors and their chests!
 ------------------------------------------------------------------------

When a player vendor is set up to run his shop, he'll ask his owner for a 
chest. The vendor will then claim and lock the chest which now becomes 
inaccessible to players the normal way and which instead will now offer a 
gump to manage the content.

Upon doing so the structure in the box is changed as follows:

In the main container there are 3 subcontainers: 
Objtype 0x5050: 
  color 1169: items to buy - only stackable items allowed!!!!!
  color 1172: items to sell
  color 2060: duplicates of items that might as of yet be returned!
  
              IMPORTANT NOTE: this directory is not cleaned out on it's own.
                              Rather everytime the chest inventory is read, it checks the list of items
                              to see if any of these have run out. This may result in minor inaccuracies
                              when dealing with taxes, but I figured these unimportant compared to the 
                              alternative of using a background script to check these (after all unknown
                              in type) chests, which could result in all containers being polled.
                              
  
chests will have this seal:

    seal   [struct]
    .type == "vendor"      this is a chest, sealed by a vendor to use it as a warehouse!
                           this adds the following members:
                             .npc == array{serial1,serial2,...}; array of npc's selling of this box!
                             .gold == integer; amount of gold available for trading in this box!
  
 ------------------------------------------------------------------------
   The SALES container
 ------------------------------------------------------------------------
 
The sales container item will have this property:

  "vendordata"     [struct]       
        .type      [string]     Defines what type of item the object is. Choices are:
                                  "item"        An item for sale
                                  "stack"       Stacked items - partial sale possible
                                  "mobile"      A mobile - e.g. horses (not used yet)
                                  "folder"      a container acting as a directory
        .gmmode    [1]          Defines an item as being sold by staff - unlimited!!!
                                  (sale items only)
        .name      [string]     Defines the name for an item (or for a subdirectory)
                                  (no name -> default from container used!)
                                  (no default either -> item description used)
        .price     [integer]    Defines the price for an item
                                  (only sale items. No price -> container default used)
                                  (no default either? -> item is not for sale (display))
        .details   [string]     An optional, detailed description of an item.
                                  (This option is not available for subcontainers!)
        .defname   [string]     Defines default name for items inside a container!
                                  (optional, subdirectory containers only)
        .defprice  [integer]    Defines default price for items inside a container!
                                  (optional, subdirectory containers only)
                                  
  when moved to the refund container, they keep their original values, but are 
  added these values:
  
  "vendordata"     [struct]       
        .saletime  [timer]      Timestamp from the time when it was sold
        .copyitem  [serial]     When item is sold, a copy with this serial was created
        .rootcont  [serial]     Serial of the container this item has been in!
        .saleprice [integer]    Price paid for this item
        .saletax   [integer]    Tax paid for this item
        .townid    [integer]    Town to receive the tax        
 ------------------------------------------------------------------------
 
 The purchase container item will have this property:
 
  "vendordata"     [struct]       
        .type      [string]     Defines what type of item the object is. Choices are:
                                  "buyitem"         an item for spurchase
                                  "folder"      a container acting as a directory
        .gmmode    [1]          Defines an item as being sold by staff - unlimited!!!
                                  (purchase items only)
        .name      [string]     Defines the name for an item (or for a subdirectory)
                                  (no name -> default from container used!)
                                  (no default either -> item description used)
        .price     [integer]    Defines the price for an item
                                  (only purchase items. No price -> container default used)
                                  (no default either? -> item is not for purchase (display))
        .amount    [integer]    Defines the amount to be bought
                                  (only purchase items. No amount -> container default used)
                                  (no default either? -> item is not for purchase (display))
        .details   [array of strings] An optional, detailed description of an item.
                                  (Each entry represents a display line. Max: 8)
        .defname   [string]     Defines default name for items inside a container!
                                  (optional, subdirectory containers only)
        .defprice  [integer]    Defines default price for items inside a container!
                                  (optional, subdirectory containers only)
        .defamt [integer]       Defines default amount for *NEW* items inside this container!
                                  (optional, subdirectory containers only)
 
  ------------------------------------------------------------------------

  This is the docu, to specify which items can be bought: \config\merchantbuyable.cfg
  
#######################################################################################################
# This file is an include list of objects, that town-merchant npc's use to check it for purchaseable
# objects. Since many items are very complex, vendors will only be able to purchase basic items such
# as resources. This file tells them what to look out for.
#
# Note: Each package can have it's own config/merchantbuyable.cfg !!!
#######################################################################################################
# The system works in the following way... 
# Each item is checked against the complete list of legal entries... (at least until a match is found)
# 
#  - first it checks for objtype (this is a must!); if objtype matches, it then checks if also
#    all other entries specified are a match. Non-specified entries are ignored. If all entries match,
#    the vendor will buy any item matching the required criteria.
#    Each criteria at that, may either look for a specific value, or just if the property as such exists.
#    (Note that if you specify cprops, you need to enter their data packed!)
#
#  e.g.
#    object testentry1
#    { 
#      objtype 0x1234
#      color   check
#    } 
# 
#       Now if you give the vendor a sword, objtype 0x1234, then he will be ok to buy the item, because
#       it's objtype is 0x1234. He will then buy any other sword objtpye 0x1234 as long as the color 
#       matches.
# 
#
#  e.g. 
#    object testentry2
#    {
#      objtype 0x1234
#      objtype 0x1235
#      color   37
#      color   100
#    }
#     
#       In this case if you give the vendor a sword, objtype 0x1234 or 0x1235, he will only accept it 
#       for additional purchases, if it is either red (color 37) or light-blue (color 100). Again however,
#       he will only buy an item if it has the same objtype as the sample, and has the same color 
#       as the given object.
#
#  e.g.
#    object testentry3
#    {
#      objtype 0x1234
#    }
#
#       In this third case, he will accept any sword objtype 0x1234 for purchase. He will then buy 
#       any additional objtype 0x1234 sword, no matter if it matches the color of the sample given
#       to the vendor, or not.
#
# Note there's a difference though:
# 
# e.g. 
#    object testentry3
#    {
#      objtype 0x1234
#      cprop dummy s23
#      cprop dummytoo i14
#      cprop dummythree match
#    }
#
#       In this case the item needs not only the right objtype, but BOTH cprops (dummy and dummytoo) present.
#       The cprop dummythree will not be checked for presence in that case, however both the sample item
#       and the item-to-purchase must have the same value for this cprop, in order for the vendor to buy this
#       item. (Both not having the cprop will work too! The vendor is merely asked to look out for it! Using
#       that trick you can e.g. teach the vendor to not buy poisoned food...)
#
#       It's down to the scripter to decide, which of the items in his package should be buyable.
#       While basically everything (safe for containers!) could be buyable, (just specify one entry
#       with all objtypes) I feel it ends very frustrating to the player if he asks his vendor
#       to buy fresh bread roles, but all he gets are 3 day olds..... Thus we gotta teach the merchant
#       what he can handle, and how!
#
#       Note: invisible or unmoveable items will not be bought!
# 
#######################################################################################################
# Legal Check Values
# ------------------
#
# object <objectname> //each object needs to have a unique name... i suggest packagename+serial!
# {
#  objtype  0x1234  // objects of this type are being buyable - if they match the other criteria
#                   // (Note: both dez and hex values will work, but hex sure is prefered)
#
#  objtype  ...        -> Note: Each entry MUST have at least one objtype value !!!!
# 
#  color    0x1234  // objects of this color are sold. 
#  color    match   // => i will not mention this ability any further, but "match" means that this 
#                         value is not important for the item to become purchaseable, but 
#                         rather that only the bought item must match the sample item, for the
#                         NPC merchant to accept it.
#
#  graphic 0x1234   // only objects of this graphic will be traded!
#
#  cprop <cpropname> <packed value1> <packed value2> ...   // cprops existing on the item
#
#                   // WARNING: unlike color, where you can specify 2 entries where either is legal, this will NOT work for cprops.
#                   //          specifying multiple cpropnames will require them ALL to be true.
# }
#######################################################################################################
