Show
Ignore:
Timestamp:
11/19/08 13:23:29 (17 years ago)
Author:
yumileroy
Message:

[svn] * Little fix in RandomMovementGenerator?
* Updated to 6731 and 680

Original author: Neo2003
Date: 2008-10-06 04:48:59-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Creature.h

    r14 r18  
    111111    uint32 Action; 
    112112    std::string Option; 
    113 }; 
    114  
    115 struct CreatureItem 
    116 { 
    117     CreatureItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) 
    118         : id(_item), count(_maxcount), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost), lastincr((uint32)time(NULL)) {} 
    119  
    120     uint32 id; 
    121     uint32 count; 
    122     uint32 maxcount; 
    123     uint32 incrtime; 
    124     uint32 lastincr; 
    125     uint32 ExtendedCost; 
    126113}; 
    127114 
     
    292279#endif 
    293280 
     281// Vendors 
     282struct VendorItem 
     283{ 
     284    VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) 
     285        : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {} 
     286 
     287    uint32 item; 
     288    uint32 maxcount;                                        // 0 for infinity item amount 
     289    uint32 incrtime;                                        // time for restore items amount if maxcount != 0 
     290    uint32 ExtendedCost; 
     291}; 
     292typedef std::vector<VendorItem*> VendorItemList; 
     293 
     294struct VendorItemData 
     295{ 
     296    VendorItemList m_items; 
     297 
     298    VendorItem* GetItem(uint32 slot) const 
     299    { 
     300        if(slot>=m_items.size()) return NULL; 
     301        return m_items[slot]; 
     302    } 
     303    bool Empty() const { return m_items.empty(); } 
     304    uint8 GetItemCount() const { return m_items.size(); } 
     305    void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) 
     306    { 
     307        m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost)); 
     308    } 
     309    bool RemoveItem( uint32 item_id ); 
     310    VendorItem const* FindItem(uint32 item_id) const; 
     311 
     312    void Clear() 
     313    { 
     314        for (VendorItemList::iterator itr = m_items.begin(); itr != m_items.end(); ++itr) 
     315            delete (*itr); 
     316    } 
     317}; 
     318 
     319struct VendorItemCount 
     320{ 
     321    explicit VendorItemCount(uint32 _item, uint32 _count) 
     322        : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {} 
     323 
     324    uint32 itemId; 
     325    uint32 count; 
     326    time_t lastIncrementTime; 
     327}; 
     328 
     329typedef std::list<VendorItemCount> VendorItemCounts; 
     330 
    294331struct TrainerSpell 
    295332{ 
     
    419456        float GetSpellDamageMod(int32 Rank); 
    420457 
    421         /*********************************************************/ 
    422         /***                    VENDOR SYSTEM                  ***/ 
    423         /*********************************************************/ 
    424         void LoadGoods();                                   // must be called before access to vendor items, lazy loading at first call 
    425         void ReloadGoods() { m_itemsLoaded = false; LoadGoods(); } 
    426  
    427         CreatureItem* GetItem(uint32 slot) 
    428         { 
    429             if(slot>=m_vendor_items.size()) return NULL; 
    430             return &m_vendor_items[slot]; 
    431         } 
    432         uint8 GetItemCount() const { return m_vendor_items.size(); } 
    433         void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) 
    434         { 
    435             m_vendor_items.push_back(CreatureItem(item, maxcount, ptime, ExtendedCost)); 
    436         } 
    437         bool RemoveItem( uint32 item_id ) 
    438         { 
    439             for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) 
    440             { 
    441                 if(i->id==item_id) 
    442                 { 
    443                     m_vendor_items.erase(i); 
    444                     return true; 
    445                 } 
    446             } 
    447             return false; 
    448         } 
    449         CreatureItem* FindItem(uint32 item_id) 
    450         { 
    451             for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) 
    452                 if(i->id==item_id) 
    453                     return &*i; 
    454             return NULL; 
    455         } 
     458        VendorItemData const* GetVendorItems() const; 
     459        uint32 GetVendorItemCurrentCount(VendorItem const* vItem); 
     460        uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count); 
    456461 
    457462        TrainerSpellData const* GetTrainerSpells() const; 
     
    563568 
    564569        // vendor items 
    565         typedef std::vector<CreatureItem> CreatureItems; 
    566         CreatureItems m_vendor_items; 
    567         bool m_itemsLoaded;                                 // vendor items loading state 
     570        VendorItemCounts m_vendorItemCounts; 
    568571 
    569572        void _RealtimeSetCreatureInfo(); 
     
    593596        MovementGeneratorType m_defaultMovementType; 
    594597        Cell m_currentCell;                                 // store current cell where creature listed 
    595         uint32 m_DBTableGuid; 
     598        uint32 m_DBTableGuid;                               ///< For new or temporary creatures is 0 for saved it is lowguid 
    596599        uint32 m_equipmentId; 
    597600