Switch to using -I to find includes, rather than relative paths.
[gemrb.git] / gemrb / plugins / Core / Store.h
blobd66dd0785bb1bb5650c9f449c2e5b4ffb371a3d9
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.
21 /**
22 * @file Store.h
23 * Declares Store, class describing shops, temples and pubs, etc.
24 * @author The GemRB Project
28 #ifndef STORE_H
29 #define STORE_H
31 #include "exports.h"
32 #include <vector>
33 #include "ie_types.h"
34 #include "globals.h"
36 //bah!
37 class CREItem;
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
47 #define IE_STORE_ID 4
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
59 /**
60 * @struct STOItem
61 * Item in a store, together with available amount etc.
63 struct STOItem {
64 ieResRef ItemResRef;
65 ieWord PurchasedAmount;
66 ieWord Usages[CHARGE_COUNTERS];
67 ieDword Flags;
68 // 2 cached values from associated item. LEAVE IT SIGNED!
69 int Weight;
70 int StackAmount;
71 ieDword AmountInStock;
72 ieDwordSigned InfiniteSupply;
73 // V1.1
74 //ieDword TriggerRef; use infinitesupply
75 char unknown2[56];
79 /**
80 * @struct STODrink
81 * Kind of drink in a pub, with its associated rumour and price
84 struct STODrink {
85 ieResRef RumourResRef;
86 ieStrRef DrinkName;
87 ieDword Price;
88 ieDword Strength;
92 /**
93 * @struct STOCure
94 * Kind of cure available in a temple, with its associated price
97 struct STOCure {
98 ieResRef CureResRef;
99 ieDword Price;
103 * @class Store
104 * Class describing shops, temples, pubs, etc.
107 class GEM_EXPORT Store {
108 public:
109 Store();
110 ~Store();
112 std::vector< STOItem*> items;
113 STODrink* drinks;
114 STOCure* cures;
115 ieDword* purchased_categories;
117 ieResRef Name;
118 ieDword Type;
119 ieStrRef StoreName;
120 ieDword Flags;
121 ieDword SellMarkup;
122 ieDword BuyMarkup;
123 ieDword DepreciationRate;
124 ieWord StealFailureChance;
125 ieWord Capacity;
126 char unknown[8];
127 ieDword PurchasedCategoriesOffset;
128 ieDword PurchasedCategoriesCount;
129 ieDword ItemsOffset;
130 //don't use this value directly, use GetRealStockSize
131 ieDword ItemsCount;
132 ieDword Lore;
133 ieDword IDPrice;
134 ieResRef RumoursTavern;
135 ieDword DrinksOffset;
136 ieDword DrinksCount;
137 ieResRef RumoursTemple;
138 ieDword AvailableRooms;
139 ieDword RoomPrices[4];
140 ieDword CuresOffset;
141 ieDword CuresCount;
142 bool HasTriggers;
143 char unknown2[36];
145 // IWD2 only
146 char unknown3[80];
148 int version;
149 // the scripting name of the owner
150 ieVariable StoreOwner;
152 public: //queries
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);
168 private:
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;
174 #endif // ! STORE_H