1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * Declares Store, class describing shops, temples and pubs, etc.
24 * @author The GemRB Project
39 typedef enum StoreType
{ STT_STORE
=0, STT_TAVERN
=1, STT_INN
=2, STT_TEMPLE
=3,
40 STT_BG2CONT
=4, STT_IWD2CONT
=5 } StoreType
;
42 typedef enum StoreActionType
{ STA_BUYSELL
=0, STA_IDENTIFY
=1, STA_STEAL
=2,
43 STA_CURE
=3, STA_DONATE
=4, STA_DRINK
=5, STA_ROOMRENT
=6, STA_OPTIONAL
=0x80} StoreActionType
;
45 #define IE_STORE_BUY 1
46 #define IE_STORE_SELL 2
48 #define IE_STORE_STEAL 8
49 #define IE_STORE_DONATE 16 //gemrb extension
50 #define IE_STORE_CURE 32
51 #define IE_STORE_DRINK 64
52 #define IE_STORE_SELECT 0x40 //valid when these flags used as store action
53 #define IE_STORE_RENT 128 //gemrb extension
54 #define IE_STORE_QUALITY 0x600 //2 bits
55 #define IE_STORE_FENCE 0x2000 //
56 #define IE_STORE_RECHARGE 0x4000 //gemrb extension, if set, store won't recharge
61 * Item in a store, together with available amount etc.
65 ieWord PurchasedAmount
;
66 ieWord Usages
[CHARGE_COUNTERS
];
68 // 2 cached values from associated item. LEAVE IT SIGNED!
71 ieDword AmountInStock
;
72 ieDwordSigned InfiniteSupply
;
74 //ieDword TriggerRef; use infinitesupply
81 * Kind of drink in a pub, with its associated rumour and price
85 ieResRef RumourResRef
;
94 * Kind of cure available in a temple, with its associated price
104 * Class describing shops, temples, pubs, etc.
107 class GEM_EXPORT Store
{
112 std::vector
< STOItem
*> items
;
115 ieDword
* purchased_categories
;
123 ieDword DepreciationRate
;
124 ieWord StealFailureChance
;
127 ieDword PurchasedCategoriesOffset
;
128 ieDword PurchasedCategoriesCount
;
130 //don't use this value directly, use GetRealStockSize
134 ieResRef RumoursTavern
;
135 ieDword DrinksOffset
;
137 ieResRef RumoursTemple
;
138 ieDword AvailableRooms
;
139 ieDword RoomPrices
[4];
149 // the scripting name of the owner
150 ieVariable StoreOwner
;
153 int AcceptableItemType(ieDword type
, ieDword invflags
, bool pc
) const;
154 STOCure
*GetCure(unsigned int idx
) const;
155 STODrink
*GetDrink(unsigned int idx
) const;
156 STOItem
*GetItem(unsigned int idx
);
157 /** Evaluates item availability triggers */
158 int GetRealStockSize();
159 /** Recharges item */
160 void RechargeItem(CREItem
*item
);
161 /** Adds a new item to the store (selling) */
162 void AddItem(CREItem
* item
);
163 void RemoveItem(unsigned int idx
);
164 /** Returns index of item */
165 unsigned int FindItem(const ieResRef item
, bool usetrigger
) const;
166 const char *GetOwner() const;
167 void SetOwner(const char* name
);
169 /** Finds a mergeable item in the stock, if exact is set, it checks for usage counts too */
170 STOItem
*FindItem(CREItem
*item
, bool exact
);
171 bool IsItemAvailable(unsigned int slot
) const;