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
41 typedef enum StoreType
{ STT_STORE
=0, STT_TAVERN
=1, STT_INN
=2, STT_TEMPLE
=3,
42 STT_BG2CONT
=4, STT_IWD2CONT
=5 } StoreType
;
44 typedef enum StoreActionType
{ STA_BUYSELL
=0, STA_IDENTIFY
=1, STA_STEAL
=2,
45 STA_CURE
=3, STA_DONATE
=4, STA_DRINK
=5, STA_ROOMRENT
=6, STA_OPTIONAL
=0x80} StoreActionType
;
47 #define IE_STORE_BUY 1
48 #define IE_STORE_SELL 2
50 #define IE_STORE_STEAL 8
51 #define IE_STORE_DONATE 16 //gemrb extension
52 #define IE_STORE_CURE 32
53 #define IE_STORE_DRINK 64
54 #define IE_STORE_SELECT 0x40 //valid when these flags used as store action
55 #define IE_STORE_RENT 128 //gemrb extension
56 #define IE_STORE_QUALITY 0x600 //2 bits
57 #define IE_STORE_FENCE 0x2000 //
58 #define IE_STORE_RECHARGE 0x4000 //gemrb extension, if set, store won't recharge
63 * Item in a store, together with available amount etc.
67 ieWord PurchasedAmount
;
68 ieWord Usages
[CHARGE_COUNTERS
];
70 // 2 cached values from associated item. LEAVE IT SIGNED!
73 ieDword AmountInStock
;
74 ieDwordSigned InfiniteSupply
;
77 //ieDword TriggerRef; use infinitesupply
84 * Kind of drink in a pub, with its associated rumour and price
88 ieResRef RumourResRef
;
97 * Kind of cure available in a temple, with its associated price
107 * Class describing shops, temples, pubs, etc.
110 class GEM_EXPORT Store
{
115 std::vector
< STOItem
*> items
;
118 ieDword
* purchased_categories
;
126 ieDword DepreciationRate
;
127 ieWord StealFailureChance
;
130 ieDword PurchasedCategoriesOffset
;
131 ieDword PurchasedCategoriesCount
;
133 //don't use this value directly, use GetRealStockSize
137 ieResRef RumoursTavern
;
138 ieDword DrinksOffset
;
140 ieResRef RumoursTemple
;
141 ieDword AvailableRooms
;
142 ieDword RoomPrices
[4];
152 // the scripting name of the owner
153 ieDword StoreOwnerID
;
156 int AcceptableItemType(ieDword type
, ieDword invflags
, bool pc
) const;
157 STOCure
*GetCure(unsigned int idx
) const;
158 STODrink
*GetDrink(unsigned int idx
) const;
159 STOItem
*GetItem(unsigned int idx
);
160 /** Evaluates item availability triggers */
161 int GetRealStockSize();
162 /** Recharges item */
163 void RechargeItem(CREItem
*item
);
164 /** Adds a new item to the store (selling) */
165 void AddItem(CREItem
* item
);
166 void RemoveItem(unsigned int idx
);
167 /** Returns index of item */
168 unsigned int FindItem(const ieResRef item
, bool usetrigger
) const;
169 const char *GetOwner() const;
170 ieDword
GetOwnerID() const;
171 void SetOwnerID(ieDword owner
);
173 /** Finds a mergeable item in the stock, if exact is set, it checks for usage counts too */
174 STOItem
*FindItem(CREItem
*item
, bool exact
);
175 bool IsItemAvailable(unsigned int slot
) const;