@@ -80,9 +80,9 @@ void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(
80
80
81
81
void AHBot_AuctionHouseScript::OnAuctionAdd (AuctionHouseObject* /* ah*/ , AuctionEntry* auction)
82
82
{
83
- //
83
+ //
84
84
// The the configuration for the auction house
85
- //
85
+ //
86
86
87
87
AuctionHouseEntry const * ahEntry = sAuctionMgr ->GetAuctionHouseEntryFromHouse (auction->GetHouseId ());
88
88
AHBConfig* config = gNeutralConfig ;
@@ -99,9 +99,9 @@ void AHBot_AuctionHouseScript::OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionE
99
99
}
100
100
}
101
101
102
- //
102
+ //
103
103
// Consider only those auctions handled by the bots
104
- //
104
+ //
105
105
106
106
if (config->ConsiderOnlyBotAuctions )
107
107
{
@@ -143,12 +143,9 @@ void AHBot_AuctionHouseScript::OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionE
143
143
144
144
void AHBot_AuctionHouseScript::OnAuctionRemove (AuctionHouseObject* /* ah*/ , AuctionEntry* auction)
145
145
{
146
- //
147
146
// Get the configuration for the auction house
148
- //
149
-
150
147
AuctionHouseEntry const * ahEntry = sAuctionMgr ->GetAuctionHouseEntryFromHouse (auction->GetHouseId ());
151
- AHBConfig* config = gNeutralConfig ;
148
+ AHBConfig* config = gNeutralConfig ;
152
149
153
150
if (ahEntry)
154
151
{
@@ -162,10 +159,7 @@ void AHBot_AuctionHouseScript::OnAuctionRemove(AuctionHouseObject* /*ah*/, Aucti
162
159
}
163
160
}
164
161
165
- //
166
162
// Consider only those auctions handled by the bots
167
- //
168
-
169
163
if (config->ConsiderOnlyBotAuctions )
170
164
{
171
165
if (gBotsId .find (auction->owner .GetCounter ()) != gBotsId .end ())
@@ -174,41 +168,41 @@ void AHBot_AuctionHouseScript::OnAuctionRemove(AuctionHouseObject* /*ah*/, Aucti
174
168
}
175
169
}
176
170
177
- //
178
171
// Verify if we can operate on the item
179
- //
180
-
181
172
Item* pItem = sAuctionMgr ->GetAItem (auction->item_guid );
182
173
174
+ ItemTemplate const * prototype = sObjectMgr ->GetItemTemplate (auction->item_template );
175
+
183
176
if (!pItem)
184
177
{
185
178
if (config->DebugOut )
186
179
{
187
180
LOG_ERROR (" module" , " AHBot: Item {} doesn't exist, perhaps bought already?" , auction->item_guid .ToString ());
188
181
}
189
182
183
+ // Decrement item counts even if the item does not exist
184
+ if (prototype)
185
+ {
186
+ config->DecItemCounts (prototype->Class , prototype->Quality );
187
+ }
188
+
190
189
return ;
191
190
}
192
191
193
- //
194
- // Decrements
195
- //
196
-
197
- ItemTemplate const * prototype = sObjectMgr ->GetItemTemplate (auction->item_template );
198
-
199
192
if (config->DebugOut )
200
193
{
201
194
LOG_INFO (" module" , " AHBot: ah={}, item={}, count={}" , auction->GetHouseId (), auction->item_template , config->GetItemCounts (prototype->Quality ));
202
195
}
203
196
197
+ // Decrement item counts
204
198
config->DecItemCounts (prototype->Class , prototype->Quality );
205
199
}
206
200
207
201
void AHBot_AuctionHouseScript::OnAuctionSuccessful (AuctionHouseObject* /* ah*/ , AuctionEntry* auction)
208
202
{
209
- //
203
+ //
210
204
// Get the configuration for the auction house
211
- //
205
+ //
212
206
213
207
AuctionHouseEntry const * ahEntry = sAuctionMgr ->GetAuctionHouseEntryFromHouse (auction->GetHouseId ());
214
208
AHBConfig* config = gNeutralConfig ;
@@ -225,19 +219,19 @@ void AHBot_AuctionHouseScript::OnAuctionSuccessful(AuctionHouseObject* /*ah*/, A
225
219
}
226
220
}
227
221
228
- //
222
+ //
229
223
// If the auction has been won, it means that it has been accepted by the market.
230
224
// Use the buyout as a reference since the price for the bid is downgraded during selling.
231
- //
225
+ //
232
226
233
227
config->UpdateItemStats (auction->item_template , auction->itemCount , auction->buyout );
234
228
}
235
229
236
230
void AHBot_AuctionHouseScript::OnAuctionExpire (AuctionHouseObject* /* ah*/ , AuctionEntry* auction)
237
231
{
238
- //
232
+ //
239
233
// Get the configuration for the auction house
240
- //
234
+ //
241
235
242
236
AuctionHouseEntry const * ahEntry = sAuctionMgr ->GetAuctionHouseEntryFromHouse (auction->GetHouseId ());
243
237
AHBConfig* config = gNeutralConfig ;
@@ -254,12 +248,22 @@ void AHBot_AuctionHouseScript::OnAuctionExpire(AuctionHouseObject* /*ah*/, Aucti
254
248
}
255
249
}
256
250
257
- //
251
+ //
258
252
// If the auction expired, then it means that the bid was unwanted by the market.
259
253
// Bid price is usually less or equal to the buyout, so this likely will bring the price down.
260
- //
254
+ //
261
255
262
256
config->UpdateItemStats (auction->item_template , auction->itemCount , auction->bid );
257
+
258
+ // Decrement item counts
259
+ ItemTemplate const * prototype = sObjectMgr ->GetItemTemplate (auction->item_template );
260
+
261
+ if (config->DebugOut )
262
+ {
263
+ LOG_INFO (" module" , " AHBot: ah={}, item={}, count={}" , auction->GetHouseId (), auction->item_template , config->GetItemCounts (prototype->Quality ));
264
+ }
265
+
266
+ config->DecItemCounts (prototype->Class , prototype->Quality );
263
267
}
264
268
265
269
void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrUpdate ()
0 commit comments