Changeset 1443 for trunk

Show
Ignore:
Timestamp:
06/15/09 12:47:15 (15 months ago)
Author:
ajps
Message:

Fix for bug reported on oook by zen0 where charged items bought from shops had too many charges. We now calculate the charges on a copied item using the relevant parts of distribute_charges().

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/object/obj-util.c

    r1435 r1443  
    17901790        /* Modify quantity */ 
    17911791        dst->number = amt; 
    1792          
    1793         /* If the item has charges, set them to the correct level too */ 
    1794         reduce_charges(dst, src->number - amt); 
     1792 
     1793        /*  
     1794         * If the item has charges/timeouts, set them to the correct level  
     1795         * too. We split off the same amount as distribute_charges. 
     1796         */ 
     1797        if (src->tval == TV_WAND || src->tval == TV_STAFF) 
     1798        { 
     1799                dst->pval = src->pval * amt / src->number; 
     1800        } 
     1801 
     1802        if (src->tval == TV_ROD) 
     1803        { 
     1804                int max_time = k_info[src->k_idx].time_base * amt; 
     1805 
     1806                if (src->timeout > max_time) 
     1807                        dst->timeout = max_time; 
     1808                else 
     1809                        dst->timeout = src->timeout; 
     1810        } 
    17951811} 
    17961812