diff options
author | Chaz Brown <iamparadox@netscape.net> | 2009-09-22 20:40:34 -0400 |
---|---|---|
committer | Chaz Brown <iamparadox@netscape.net> | 2009-09-22 20:40:34 -0400 |
commit | 7aa91dd81b5ea3bb85d97ff30389a2a1a0a7ab28 (patch) | |
tree | 43bb89474e720ab75ac4feaecde5cd2a96912393 /src | |
parent | a9086ea15a6ef297714aef3c50f9b003a016050f (diff) |
* AHBot rewritten to cause less lag spikes when checking for bids and when adding new auctions.
* AH Deposit function rewritten to generate deposits closer to official.
* AH Mail system rewritten to fix some bugs.
* MULTI_THREAD_MAP enabled by default (I have no idea why this was commented out before)
* CLIENT_VER added for allowing parts of the code to be enabled/disabled depending on the client version supported.
Only used in AHBot for now.
* Various code cleanups.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/framework/Platform/Define.h | 6 | ||||
-rw-r--r-- | src/game/AuctionHouseBot.cpp | 426 | ||||
-rw-r--r-- | src/game/AuctionHouseBot.h | 245 | ||||
-rw-r--r-- | src/game/AuctionHouseHandler.cpp | 205 | ||||
-rw-r--r-- | src/game/AuctionHouseMgr.cpp | 234 | ||||
-rw-r--r-- | src/game/AuctionHouseMgr.h | 23 | ||||
-rw-r--r-- | src/game/World.cpp | 612 |
7 files changed, 1063 insertions, 688 deletions
diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h index 35bc07f5656..dc5c248bf8c 100644 --- a/src/framework/Platform/Define.h +++ b/src/framework/Platform/Define.h @@ -137,7 +137,7 @@ typedef uint32 DWORD; typedef uint64 OBJECT_HANDLE; -//#define MULTI_THREAD_MAP +#define MULTI_THREAD_MAP #ifdef MULTI_THREAD_MAP #define MAP_BASED_RAND_GEN #endif @@ -156,6 +156,10 @@ typedef uint64 OBJECT_HANDLE; # endif #endif +#ifndef CLIENT_VER +#define CLIENT_VER 313 +#endif + #endif //TRINITY_DEFINE_H diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp index c92e5eca838..4d7fdaec59e 100644 --- a/src/game/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot.cpp @@ -1,12 +1,34 @@ #include "AuctionHouseBot.h" #include "ObjectMgr.h" #include "AuctionHouseMgr.h" +#if CLIENT_VER > 300 +#else if CLIENT_VER > 100 +#include <vector> +#endif #include "Policies/SingletonImp.h" INSTANTIATE_SINGLETON_1(AuctionHouseBot); using namespace std; - +#if CLIENT_VER > 300 +#else if CLIENT_VER > 100 +vector<uint32> npcItems; +vector<uint32> lootItems; +vector<uint32> greyTradeGoodsBin; +vector<uint32> whiteTradeGoodsBin; +vector<uint32> greenTradeGoodsBin; +vector<uint32> blueTradeGoodsBin; +vector<uint32> purpleTradeGoodsBin; +vector<uint32> orangeTradeGoodsBin; +vector<uint32> yellowTradeGoodsBin; +vector<uint32> greyItemsBin; +vector<uint32> whiteItemsBin; +vector<uint32> greenItemsBin; +vector<uint32> blueItemsBin; +vector<uint32> purpleItemsBin; +vector<uint32> orangeItemsBin; +vector<uint32> yellowItemsBin; +#endif AuctionHouseBot::AuctionHouseBot() { debug_Out = false; @@ -31,7 +53,9 @@ AuctionHouseBot::AuctionHouseBot() DisableBeta_PTR_Unused = false; DisablePermEnchant = false; +#if CLIENT_VER > 300 DisableConjured = false; +#endif DisableGems = false; DisableMoney = false; DisableMoneyLoot = false; @@ -92,10 +116,26 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config) return; } - AuctionHouseEntry const* ahEntry = auctionmgr.GetAuctionHouseEntry(config->GetAHFID()); - AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID()); uint32 minItems = config->GetMinItems(); uint32 maxItems = config->GetMaxItems(); + + if (maxItems == 0) + { + //if (debug_Out) sLog.outString("AHSeller: Auctions disabled"); + return; + } + + AuctionHouseEntry const* ahEntry = auctionmgr.GetAuctionHouseEntry(config->GetAHFID()); + if (!ahEntry) + { + return; + } + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID()); + if (!auctionHouse) + { + return; + } + uint32 auctions = auctionHouse->Getcount(); if (auctions >= minItems) @@ -111,7 +151,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config) } uint32 items = 0; - if ((maxItems - auctions) > ItemsPerCycle) + if ((maxItems - auctions) >= ItemsPerCycle) items = ItemsPerCycle; else items = (maxItems - auctions); @@ -158,87 +198,30 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config) + whiteIcount + greenIcount + blueIcount + purpleIcount + orangeIcount + yellowIcount; - uint32 greyTGoods = 0; - uint32 whiteTGoods = 0; - uint32 greenTGoods = 0; - uint32 blueTGoods = 0; - uint32 purpleTGoods = 0; - uint32 orangeTGoods = 0; - uint32 yellowTGoods = 0; - - uint32 greyItems = 0; - uint32 whiteItems = 0; - uint32 greenItems = 0; - uint32 blueItems = 0; - uint32 purpleItems = 0; - uint32 orangeItems = 0; - uint32 yellowItems = 0; - - for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr) - { - AuctionEntry *Aentry = itr->second; - Item *item = auctionmgr.GetAItem(Aentry->item_guidlow); - if (item) - { - ItemPrototype const *prototype = item->GetProto(); - if (prototype) - { - switch (prototype->Quality) - { - case 0: - if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - ++greyTGoods; - else - ++greyItems; - break; - case 1: - if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - ++whiteTGoods; - else - ++whiteItems; - break; - case 2: - if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - ++greenTGoods; - else - ++greenItems; - break; - case 3: - if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - ++blueTGoods; - else - ++blueItems; - break; - case 4: - if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - ++purpleTGoods; - else - ++purpleItems; - break; - case 5: - if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - ++orangeTGoods; - else - ++orangeItems; - break; - case 6: - if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - ++yellowTGoods; - else - ++yellowItems; - break; - } - } - } - } + uint32 greyTGoods = config->GetItemCounts(AHB_GREY_TG); + uint32 whiteTGoods = config->GetItemCounts(AHB_WHITE_TG); + uint32 greenTGoods = config->GetItemCounts(AHB_GREEN_TG); + uint32 blueTGoods = config->GetItemCounts(AHB_BLUE_TG); + uint32 purpleTGoods = config->GetItemCounts(AHB_PURPLE_TG); + uint32 orangeTGoods = config->GetItemCounts(AHB_ORANGE_TG); + uint32 yellowTGoods = config->GetItemCounts(AHB_YELLOW_TG); + + uint32 greyItems = config->GetItemCounts(AHB_GREY_I); + uint32 whiteItems = config->GetItemCounts(AHB_WHITE_I); + uint32 greenItems = config->GetItemCounts(AHB_GREEN_I); + uint32 blueItems = config->GetItemCounts(AHB_BLUE_I); + uint32 purpleItems = config->GetItemCounts(AHB_PURPLE_I); + uint32 orangeItems = config->GetItemCounts(AHB_ORANGE_I); + uint32 yellowItems = config->GetItemCounts(AHB_YELLOW_I); + if (debug_Out) sLog.outString("AHSeller: %u items", items); // only insert a few at a time, so as not to peg the processor for (uint32 cnt = 1;cnt <= items;cnt++) { + if (debug_Out) sLog.outString("AHSeller: %u count", cnt); uint32 itemID = 0; - uint32 loopBreaker = 0; uint32 itemColor = 99; - while (itemID == 0 && loopBreaker < 50) + while (itemID == 0) { uint32 choice = urand(0, 13); itemColor = choice; @@ -347,8 +330,8 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config) if (debug_Out) sLog.outError("AHSeller: itemID Switch - Default Reached"); break; } - ++loopBreaker; } + if (itemID == 0) { if (debug_Out) sLog.outError("AHSeller: Item::CreateItem() - ItemID is 0"); @@ -363,12 +346,12 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config) } Item* item = Item::CreateItem(itemID, 1, AHBplayer); - item->AddToUpdateQueueOf(AHBplayer); if (item == NULL) { if (debug_Out) sLog.outError("AHSeller: Item::CreateItem() returned NULL"); break; } + item->AddToUpdateQueueOf(AHBplayer); uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID); if (randomPropertyId != 0) @@ -405,6 +388,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config) { // quality is something it shouldn't be, let's get out of here if (debug_Out) sLog.outError("AHBuyer: Quality %u not Supported", prototype->Quality); + item->RemoveFromUpdateQueueOf(AHBplayer); continue; } @@ -504,32 +488,52 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con if (debug_Out) sLog.outError("AHBuyer: Disabled"); return; } + + /* + uint32 AuctioneerGUID = 0; + + switch (config->GetAHID()) + { + case 2: + AuctioneerGUID = 79707; //Human in stormwind. + break; + case 6: + AuctioneerGUID = 4656; //orc in Orgrimmar + break; + case 7: + AuctioneerGUID = 23442; //goblin in GZ + break; + default: + if (debug_Out) sLog.outError("AHSeller: GetAHID() - Default switch reached"); + AuctioneerGUID = 23442; //default to neutral 7 + break; + } + */ + + QueryResult* result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE itemowner<>%u AND buyguid<>%u", AHBplayerGUID, AHBplayerGUID); + + if (!result) + { + delete result; + return; + } + + if (result->GetRowCount() == 0) + { + delete result; + return; + } // Fetches content of selected AH AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID()); vector<uint32> possibleBids; - for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr) + do { - // Check if the auction is ours - // if it is, we skip this iteration. - if (itr->second->owner == AHBplayerGUID) - { - //if (debug_Out) sLog.outString("AHBuyer: I own this item."); - continue; - } - // Check that we haven't bidded in this auction already. - if (itr->second->bidder != AHBplayerGUID) - { - uint32 tmpdata = itr->second->Id; - possibleBids.push_back(tmpdata); - //if (debug_Out) sLog.outString("AHBuyer: I have not bid on %u"), itr->second->Id; - } - else - { - //if (debug_Out) sLog.outString("AHBuyer: I have bid on %u"), itr->second->Id; - } - } + uint32 tmpdata = result->Fetch()->GetUInt32(); + possibleBids.push_back(tmpdata); + }while (result->NextRow()); + delete result; for (uint32 count = 1;count <= config->GetBidsPerInterval();++count) { @@ -554,7 +558,6 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con if (!auction) { - if (debug_Out) sLog.outError("AHBuyer: Item doesn't exist, perhaps bought already?"); continue; } @@ -698,17 +701,9 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con else { //buyout - if (AHBplayer->GetGUIDLow() == auction->bidder) + if ((auction->bidder) && (AHBplayer->GetGUIDLow() != auction->bidder)) { - //pl->ModifyMoney(-int32(auction->buyout - auction->bid)); - } - else - { - //pl->ModifyMoney(-int32(auction->buyout)); - if (auction->bidder) - { - session->SendAuctionOutbiddedMail(auction, auction->buyout); - } + session->SendAuctionOutbiddedMail(auction, auction->buyout); } auction->bidder = AHBplayer->GetGUIDLow(); auction->bid = auction->buyout; @@ -717,14 +712,10 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con auctionmgr.SendAuctionSalePendingMail(auction); auctionmgr.SendAuctionSuccessfulMail(auction); auctionmgr.SendAuctionWonMail(auction); - - // Remove item from auctionhouse - auctionmgr.RemoveAItem(auction->item_guidlow); - // Remove auction - auctionHouse->RemoveAuction(auction->Id); - // Remove from database auction->DeleteFromDB(); - delete auction; + uint32 item_template = auction->item_template; + auctionmgr.RemoveAItem(auction->item_guidlow); + auctionHouse->RemoveAuction(auction, item_template); } } } @@ -740,6 +731,20 @@ void AuctionHouseBot::Update() _AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID); ObjectAccessor::Instance().AddObject(&_AHBplayer); + // Only for testing, this can likely be removed, once I know it's working as expected. + /* + AuctionHouseObject* auctionHouse1 = auctionmgr.GetAuctionsMap(55); + AuctionHouseObject* auctionHouse2 = auctionmgr.GetAuctionsMap(29); + AuctionHouseObject* auctionHouse3 = auctionmgr.GetAuctionsMap(120); + uint32 totalItemsAH = (auctionHouse1->Getcount() + auctionHouse2->Getcount() + auctionHouse3->Getcount()); + uint32 totalItems = (AllianceConfig.TotalItemCounts() + HordeConfig.TotalItemCounts() + NeutralConfig.TotalItemCounts()); + if (totalItemsAH != totalItems) + { + sLog.outError("AHBot: The AuctionHouses say there are %u auctions, but, I think there are %u auctions...", totalItemsAH, totalItems); + return; + } + */ + // Add New Bids if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { @@ -805,7 +810,9 @@ void AuctionHouseBot::Initialize() DisableBeta_PTR_Unused = sConfig.GetBoolDefault("AuctionHouseBot.DisableBeta_PTR_Unused", false); DisablePermEnchant = sConfig.GetBoolDefault("AuctionHouseBot.DisablePermEnchant", false); +#if CLIENT_VER > 300 DisableConjured = sConfig.GetBoolDefault("AuctionHouseBot.DisableConjured", false); +#endif DisableGems = sConfig.GetBoolDefault("AuctionHouseBot.DisableGems", false); DisableMoney = sConfig.GetBoolDefault("AuctionHouseBot.DisableMoney", false); DisableMoneyLoot = sConfig.GetBoolDefault("AuctionHouseBot.DisableMoneyLoot", false); @@ -844,7 +851,6 @@ void AuctionHouseBot::Initialize() DisableTGsAboveReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsAboveReqSkillRank", 0); //End Filters - if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { LoadValues(&AllianceConfig); @@ -878,7 +884,9 @@ void AuctionHouseBot::Initialize() "SELECT item FROM fishing_loot_template UNION " "SELECT item FROM gameobject_loot_template UNION " "SELECT item FROM item_loot_template UNION " +#if CLIENT_VER > 300 "SELECT item FROM milling_loot_template UNION " +#endif "SELECT item FROM pickpocketing_loot_template UNION " "SELECT item FROM prospecting_loot_template UNION " "SELECT item FROM skinning_loot_template"; @@ -909,23 +917,23 @@ void AuctionHouseBot::Initialize() switch (prototype->Bonding) { - case 0: + case NO_BIND: if (!No_Bind) continue; break; - case 1: + case BIND_WHEN_PICKED_UP: if (!Bind_When_Picked_Up) continue; break; - case 2: + case BIND_WHEN_EQUIPED: if (!Bind_When_Equipped) continue; break; - case 3: + case BIND_WHEN_USE: if (!Bind_When_Use) continue; break; - case 4: + case BIND_QUEST_ITEM: if (!Bind_Quest_Item) continue; break; @@ -1058,12 +1066,14 @@ void AuctionHouseBot::Initialize() continue; } +#if CLIENT_VER > 300 // Disable conjured items if ((DisableConjured) && (prototype->IsConjuredConsumable())) { if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Conjured Consumable)", prototype->ItemId); continue; } +#endif // Disable gems if ((DisableGems) && (prototype->Class == ITEM_CLASS_GEM)) @@ -1305,49 +1315,49 @@ void AuctionHouseBot::Initialize() switch (prototype->Quality) { - case 0: + case AHB_GREY: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) greyTradeGoodsBin.push_back(itemID); else greyItemsBin.push_back(itemID); break; - case 1: + case AHB_WHITE: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) whiteTradeGoodsBin.push_back(itemID); else whiteItemsBin.push_back(itemID); break; - case 2: + case AHB_GREEN: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) greenTradeGoodsBin.push_back(itemID); else greenItemsBin.push_back(itemID); break; - case 3: + case AHB_BLUE: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) blueTradeGoodsBin.push_back(itemID); else blueItemsBin.push_back(itemID); break; - case 4: + case AHB_PURPLE: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) purpleTradeGoodsBin.push_back(itemID); else purpleItemsBin.push_back(itemID); break; - case 5: + case AHB_ORANGE: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) orangeTradeGoodsBin.push_back(itemID); else orangeItemsBin.push_back(itemID); break; - case 6: + case AHB_YELLOW: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) yellowTradeGoodsBin.push_back(itemID); else @@ -1374,6 +1384,7 @@ void AuctionHouseBot::Initialize() sLog.outError("AuctionHouseBot: No items"); AHBSeller = 0; } + sLog.outString("AuctionHouseBot:"); sLog.outString("loaded %u grey trade goods", greyTradeGoodsBin.size()); sLog.outString("loaded %u white trade goods", whiteTradeGoodsBin.size()); @@ -1394,6 +1405,80 @@ void AuctionHouseBot::Initialize() sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox"); } +void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah) +{ + // from auctionhousehandler.cpp, creates auction pointer & player pointer + + // get exact item information + Item *pItem = auctionmgr.GetAItem(ah->item_guidlow); + if (!pItem) + { + if (debug_Out) sLog.outError("AHBot: Item %u doesn't exist, perhaps bought already?", ah->item_guidlow); + return; + } + + // get item prototype + ItemPrototype const* prototype = objmgr.GetItemPrototype(ah->item_template); + + AHBConfig *config; + + FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseId()); + if (!u_entry) + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. No Entry", ah->GetHouseId()); + config = &NeutralConfig; + } + else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. Alliance", ah->GetHouseId()); + config = &AllianceConfig; + } + else if (u_entry->ourMask & FACTION_MASK_HORDE) + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. Horde", ah->GetHouseId()); + config = &HordeConfig; + } + else + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. Neutral", ah->GetHouseId()); + config = &NeutralConfig; + } + + config->IncItemCounts(prototype->Class, prototype->Quality); +} + +void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 item_template) +{ + // get item prototype + ItemPrototype const* prototype = objmgr.GetItemPrototype(item_template); + + AHBConfig *config; + + FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseId()); + if (!u_entry) + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. No Entry", ah->GetHouseId()); + config = &NeutralConfig; + } + else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. Alliance", ah->GetHouseId()); + config = &AllianceConfig; + } + else if (u_entry->ourMask & FACTION_MASK_HORDE) + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. Horde", ah->GetHouseId()); + config = &HordeConfig; + } + else + { + if (debug_Out) sLog.outError("AHBot: %u returned as House ID. Neutral", ah->GetHouseId()); + config = &NeutralConfig; + } + + config->DecItemCounts(prototype->Class, prototype->Quality); +} + void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args) { AHBConfig *config; @@ -1709,6 +1794,83 @@ void AuctionHouseBot::LoadValues(AHBConfig *config) sLog.outString("maxStackOrange = %u", config->GetMaxStack(AHB_ORANGE)); sLog.outString("maxStackYellow = %u", config->GetMaxStack(AHB_YELLOW)); } + AuctionHouseEntry const* ahEntry = auctionmgr.GetAuctionHouseEntry(config->GetAHFID()); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID()); + + config->ResetItemCounts(); + uint32 auctions = auctionHouse->Getcount(); + + if (auctions) + { + for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr) + { + AuctionEntry *Aentry = itr->second; + Item *item = auctionmgr.GetAItem(Aentry->item_guidlow); + if (item) + { + ItemPrototype const *prototype = item->GetProto(); + if (prototype) + { + switch (prototype->Quality) + { + case 0: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + config->IncItemCounts(AHB_GREY_TG); + else + config->IncItemCounts(AHB_GREY_I); + break; + case 1: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + config->IncItemCounts(AHB_WHITE_TG); + else + config->IncItemCounts(AHB_WHITE_I); + break; + case 2: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + config->IncItemCounts(AHB_GREEN_TG); + else + config->IncItemCounts(AHB_GREEN_I); + break; + case 3: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + config->IncItemCounts(AHB_BLUE_TG); + else + config->IncItemCounts(AHB_BLUE_I); + break; + case 4: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + config->IncItemCounts(AHB_PURPLE_TG); + else + config->IncItemCounts(AHB_PURPLE_I); + break; + case 5: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + config->IncItemCounts(AHB_ORANGE_TG); + else + config->IncItemCounts(AHB_ORANGE_I); + break; + case 6: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + config->IncItemCounts(AHB_YELLOW_TG); + else + config->IncItemCounts(AHB_YELLOW_I); + break; + } + } + } + } + } + if (debug_Out) + { + sLog.outString("Current Items in %s Auctionhouses:", CharacterDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetString()); + sLog.outString("Grey Trade Goods\t%u\tGrey Items\t%u", config->GetItemCounts(AHB_GREY_TG), config->GetItemCounts(AHB_GREY_I)); + sLog.outString("White Trade Goods\t%u\tWhite Items\t%u", config->GetItemCounts(AHB_WHITE_TG), config->GetItemCounts(AHB_WHITE_I)); + sLog.outString("Green Trade Goods\t%u\tGreen Items\t%u", config->GetItemCounts(AHB_GREEN_TG), config->GetItemCounts(AHB_GREEN_I)); + sLog.outString("Blue Trade Goods\t%u\tBlue Items\t%u", config->GetItemCounts(AHB_BLUE_TG), config->GetItemCounts(AHB_BLUE_I)); + sLog.outString("Purple Trade Goods\t%u\tPurple Items\t%u", config->GetItemCounts(AHB_PURPLE_TG), config->GetItemCounts(AHB_PURPLE_I)); + sLog.outString("Orange Trade Goods\t%u\tOrange Items\t%u", config->GetItemCounts(AHB_ORANGE_TG), config->GetItemCounts(AHB_ORANGE_I)); + sLog.outString("Yellow Trade Goods\t%u\tYellow Items\t%u", config->GetItemCounts(AHB_YELLOW_TG), config->GetItemCounts(AHB_YELLOW_I)); + } } if (AHBBuyer) { diff --git a/src/game/AuctionHouseBot.h b/src/game/AuctionHouseBot.h index f306d1b5422..ed34f32e676 100644 --- a/src/game/AuctionHouseBot.h +++ b/src/game/AuctionHouseBot.h @@ -3,7 +3,11 @@ #include "World.h" #include "Config/ConfigEnv.h" +#if CLIENT_VER > 300 #include "ace/Vector_T.h" +#else if CLIENT_VER > 100 +#include <vector> +#endif #define AHB_GREY 0 #define AHB_WHITE 1 @@ -110,6 +114,22 @@ private: uint32 orangeip; uint32 yellowip; + uint32 greyTGoods; + uint32 whiteTGoods; + uint32 greenTGoods; + uint32 blueTGoods; + uint32 purpleTGoods; + uint32 orangeTGoods; + uint32 yellowTGoods; + + uint32 greyItems; + uint32 whiteItems; + uint32 greenItems; + uint32 blueItems; + uint32 purpleItems; + uint32 orangeItems; + uint32 yellowItems; + public: AHBConfig(uint32 ahid) { @@ -876,6 +896,225 @@ public: break; } } + + void DecItemCounts(uint32 Class, uint32 Quality) + { + switch(Class) + { + case ITEM_CLASS_TRADE_GOODS: + DecItemCounts(Quality); + break; + default: + DecItemCounts(Quality + 7); + break; + } + } + + void DecItemCounts(uint32 color) + { + switch(color) + { + case AHB_GREY_TG: + --greyTGoods; + break; + case AHB_WHITE_TG: + --whiteTGoods; + break; + case AHB_GREEN_TG: + --greenTGoods; + break; + case AHB_BLUE_TG: + --blueTGoods; + break; + case AHB_PURPLE_TG: + --purpleTGoods; + break; + case AHB_ORANGE_TG: + --orangeTGoods; + break; + case AHB_YELLOW_TG: + --yellowTGoods; + break; + case AHB_GREY_I: + --greyItems; + break; + case AHB_WHITE_I: + --whiteItems; + break; + case AHB_GREEN_I: + --greenItems; + break; + case AHB_BLUE_I: + --blueItems; + break; + case AHB_PURPLE_I: + --purpleItems; + break; + case AHB_ORANGE_I: + --orangeItems; + break; + case AHB_YELLOW_I: + --yellowItems; + break; + default: + break; + } + } + + void IncItemCounts(uint32 Class, uint32 Quality) + { + switch(Class) + { + case ITEM_CLASS_TRADE_GOODS: + IncItemCounts(Quality); + break; + default: + IncItemCounts(Quality + 7); + break; + } + } + + void IncItemCounts(uint32 color) + { + switch(color) + { + case AHB_GREY_TG: + ++greyTGoods; + break; + case AHB_WHITE_TG: + ++whiteTGoods; + break; + case AHB_GREEN_TG: + ++greenTGoods; + break; + case AHB_BLUE_TG: + ++blueTGoods; + break; + case AHB_PURPLE_TG: + ++purpleTGoods; + break; + case AHB_ORANGE_TG: + ++orangeTGoods; + break; + case AHB_YELLOW_TG: + ++yellowTGoods; + break; + case AHB_GREY_I: + ++greyItems; + break; + case AHB_WHITE_I: + ++whiteItems; + break; + case AHB_GREEN_I: + ++greenItems; + break; + case AHB_BLUE_I: + ++blueItems; + break; + case AHB_PURPLE_I: + ++purpleItems; + break; + case AHB_ORANGE_I: + ++orangeItems; + break; + case AHB_YELLOW_I: + ++yellowItems; + break; + default: + break; + } + } + + void ResetItemCounts() + { + greyTGoods = 0; + whiteTGoods = 0; + greenTGoods = 0; + blueTGoods = 0; + purpleTGoods = 0; + orangeTGoods = 0; + yellowTGoods = 0; + + greyItems = 0; + whiteItems = 0; + greenItems = 0; + blueItems = 0; + purpleItems = 0; + orangeItems = 0; + yellowItems = 0; + } + + uint32 TotalItemCounts() + { + return( + greyTGoods + + whiteTGoods + + greenTGoods + + blueTGoods + + purpleTGoods + + orangeTGoods + + yellowTGoods + + + greyItems + + whiteItems + + greenItems + + blueItems + + purpleItems + + orangeItems + + yellowItems); + } + + uint32 GetItemCounts(uint32 color) + { + switch(color) + { + case AHB_GREY_TG: + return greyTGoods; + break; + case AHB_WHITE_TG: + return whiteTGoods; + break; + case AHB_GREEN_TG: + return greenTGoods; + break; + case AHB_BLUE_TG: + return blueTGoods; + break; + case AHB_PURPLE_TG: + return purpleTGoods; + break; + case AHB_ORANGE_TG: + return orangeTGoods; + break; + case AHB_YELLOW_TG: + return yellowTGoods; + break; + case AHB_GREY_I: + return greyItems; + break; + case AHB_WHITE_I: + return whiteItems; + break; + case AHB_GREEN_I: + return greenItems; + break; + case AHB_BLUE_I: + return blueItems; + break; + case AHB_PURPLE_I: + return purpleItems; + break; + case AHB_ORANGE_I: + return orangeItems; + break; + case AHB_YELLOW_I: + return yellowItems; + break; + default: + return 0; + break; + } + } void SetBidsPerInterval(uint32 value) { buyerBidsPerInterval = value; @@ -891,6 +1130,7 @@ public: class AuctionHouseBot { private: +#if CLIENT_VER > 300 ACE_Vector<uint32> npcItems; ACE_Vector<uint32> lootItems; ACE_Vector<uint32> greyTradeGoodsBin; @@ -907,6 +1147,7 @@ private: ACE_Vector<uint32> purpleItemsBin; ACE_Vector<uint32> orangeItemsBin; ACE_Vector<uint32> yellowItemsBin; +#endif bool debug_Out; bool debug_Out_Filters; @@ -937,7 +1178,9 @@ private: bool DisableBeta_PTR_Unused; bool DisablePermEnchant; +#if CLIENT_VER > 300 bool DisableConjured; +#endif bool DisableGems; bool DisableMoney; bool DisableMoneyLoot; @@ -995,6 +1238,8 @@ public: void Update(); void Initialize(); void LoadValues(AHBConfig*); + void DecrementItemCounts(AuctionEntry* ah, uint32 item_template); + void IncrementItemCounts(AuctionEntry* ah); void Commands(uint32, uint32, uint32, char*); uint32 GetAHBplayerGUID() { return AHBplayerGUID; }; }; diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index becf541a1c5..52790526dd7 100644 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -36,7 +36,7 @@ //post-incrementation is always slower than pre-incrementation ! //void called when player click on auctioneer npc -void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data ) +void WorldSession::HandleAuctionHelloOpcode(WorldPacket & recv_data) { uint64 guid; //NPC guid recv_data >> guid; @@ -44,44 +44,44 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data ) Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER); if (!unit) { - sLog.outDebug( "WORLD: HandleAuctionHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + sLog.outDebug("WORLD: HandleAuctionHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); SendAuctionHello(guid, unit); } //this void causes that auction window is opened -void WorldSession::SendAuctionHello( uint64 guid, Creature* unit ) +void WorldSession::SendAuctionHello(uint64 guid, Creature* unit) { AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction()); - if(!ahEntry) + if (!ahEntry) return; - WorldPacket data( MSG_AUCTION_HELLO, 12 ); + WorldPacket data(MSG_AUCTION_HELLO, 12); data << (uint64) guid; data << (uint32) ahEntry->houseId; - SendPacket( &data ); + SendPacket(&data); } //call this method when player bids, creates, or deletes auction -void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError ) +void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError) { - WorldPacket data( SMSG_AUCTION_COMMAND_RESULT, 16 ); + WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 16); data << auctionId; data << Action; data << ErrorCode; - if ( !ErrorCode && Action ) + if (!ErrorCode && Action) data << bidError; //when bid, then send 0, once... SendPacket(&data); } //this function sends notification, if bidder is online -void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template) +void WorldSession::SendAuctionBidderNotification(uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template) { WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8*4)); data << uint32(location); @@ -95,7 +95,7 @@ void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctio } //this void causes on client to display: "Your auction sold" -void WorldSession::SendAuctionOwnerNotification( AuctionEntry* auction) +void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction) { WorldPacket data(SMSG_AUCTION_OWNER_NOTIFICATION, (7*4)); data << auction->Id; @@ -115,37 +115,37 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri Player *oldBidder = objmgr.GetPlayer(oldBidder_guid); uint32 oldBidder_accId = 0; - if(!oldBidder) + if (!oldBidder) oldBidder_accId = objmgr.GetPlayerAccountIdByGUID(oldBidder_guid); // old bidder exist - if(oldBidder || oldBidder_accId) + if (oldBidder || oldBidder_accId) { std::ostringstream msgAuctionOutbiddedSubject; msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED; if (oldBidder && !_player) - oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, auctionbot.GetAHBplayerGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template); + oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, auctionbot.GetAHBplayerGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template); if (oldBidder && _player) - oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template); + oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template); WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE); } } //this function sends mail, when auction is cancelled to old bidder -void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction ) +void WorldSession::SendAuctionCancelledToBidderMail(AuctionEntry* auction) { uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); Player *bidder = objmgr.GetPlayer(bidder_guid); uint32 bidder_accId = 0; - if(!bidder) + if (!bidder) bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid); // bidder exist - if(bidder || bidder_accId) + if (bidder || bidder_accId) { std::ostringstream msgAuctionCancelledSubject; msgAuctionCancelledSubject << auction->item_template << ":0:" << AUCTION_CANCELLED_TO_BIDDER; @@ -155,7 +155,7 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction ) } //this void creates new auction and adds auction to some auctionhouse -void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) +void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) { uint64 auctioneer, item; uint32 etime, bid, buyout; @@ -169,21 +169,24 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER); if (!pCreature) { - sLog.outDebug( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) ); + sLog.outDebug("WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer))); return; } AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction()); - if(!auctionHouseEntry) + if (!auctionHouseEntry) { - sLog.outDebug( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)) ); + sLog.outDebug("WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer))); return; } + sLog.outDebug("WORLD: HandleAuctionSellItem - ETIME: %u", etime); // client send time in minutes, convert to common used sec time etime *= MINUTE; + sLog.outDebug("WORLD: HandleAuctionSellItem - ETIME: %u", etime); + // client understand only 3 auction time switch(etime) { @@ -196,25 +199,25 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - Item *it = pl->GetItemByGuid( item ); + Item *it = pl->GetItemByGuid(item); //do not allow to sell already auctioned items - if(auctionmgr.GetAItem(GUID_LOPART(item))) + if (auctionmgr.GetAItem(GUID_LOPART(item))) { sLog.outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item)); SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR); return; } // prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction) - if(!it) + if (!it) { SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND); return; } - if(!it->CanBeTraded()) + if (!it->CanBeTraded()) { SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR); return; @@ -226,29 +229,29 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) return; } - AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction()); //we have to take deposit : - uint32 deposit = auctionmgr.GetAuctionDeposit( auctionHouseEntry, etime, it ); - if ( pl->GetMoney() < deposit ) + uint32 deposit = auctionmgr.GetAuctionDeposit(auctionHouseEntry, etime, it); + if (pl->GetMoney() < deposit) { SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY); return; } - if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)", GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount()); } - pl->ModifyMoney( -int32(deposit) ); + pl->ModifyMoney(-int32(deposit)); uint32 auction_time = uint32(etime * sWorld.getRate(RATE_AUCTION_TIME)); AuctionEntry *AH = new AuctionEntry; AH->Id = objmgr.GenerateAuctionID(); - if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) AH->auctioneer = 23442; else AH->auctioneer = GUID_LOPART(auctioneer); @@ -264,10 +267,10 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) AH->auctionHouseEntry = auctionHouseEntry; sLog.outDetail("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", GUID_LOPART(item), AH->auctioneer, bid, buyout, auction_time, AH->GetHouseId()); + auctionmgr.AddAItem(it); auctionHouse->AddAuction(AH); - auctionmgr.AddAItem(it); - pl->MoveItemFromInventory( it->GetBagSlot(), it->GetSlot(), true); + pl->MoveItemFromInventory(it->GetBagSlot(), it->GetSlot(), true); CharacterDatabase.BeginTransaction(); it->DeleteFromInventoryDB(); @@ -280,7 +283,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) } //this function is called when client bids or buys out auction -void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) +void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) { uint64 auctioneer; uint32 auctionId; @@ -294,37 +297,37 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER); if (!pCreature) { - sLog.outDebug( "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) ); + sLog.outDebug("WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer))); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction()); AuctionEntry *auction = auctionHouse->GetAuction(auctionId); Player *pl = GetPlayer(); - if( !auction || auction->owner == pl->GetGUIDLow() ) + if (!auction || auction->owner == pl->GetGUIDLow()) { //you cannot bid your own auction: - SendAuctionCommandResult( 0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR ); + SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR); return; } // impossible have online own another character (use this for speedup check in case online owner) Player* auction_owner = objmgr.GetPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)); - if( !auction_owner && objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId()) + if (!auction_owner && objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId()) { //you cannot bid your another character auction: - SendAuctionCommandResult( 0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR ); + SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR); return; } // cheating - if(price <= auction->bid) + if (price <= auction->bid) return; // price too low for next bid if not buyout @@ -346,20 +349,20 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) { if (auction->bidder > 0) { - if ( auction->bidder == pl->GetGUIDLow() ) + if (auction->bidder == pl->GetGUIDLow()) { - pl->ModifyMoney( -int32(price - auction->bid)); + pl->ModifyMoney(-int32(price - auction->bid)); } else { // mail to last bidder and return money - SendAuctionOutbiddedMail( auction , price ); - pl->ModifyMoney( -int32(price) ); + SendAuctionOutbiddedMail(auction , price); + pl->ModifyMoney(-int32(price)); } } else { - pl->ModifyMoney( -int32(price) ); + pl->ModifyMoney(-int32(price)); } auction->bidder = pl->GetGUIDLow(); auction->bid = price; @@ -368,38 +371,36 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) // after this update we should save player's money ... CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id); - SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0 ); + SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0); } else { //buyout: - if (pl->GetGUIDLow() == auction->bidder ) + if (pl->GetGUIDLow() == auction->bidder) { pl->ModifyMoney(-int32(auction->buyout - auction->bid)); } else { pl->ModifyMoney(-int32(auction->buyout)); - if ( auction->bidder ) //buyout for bidded auction .. + if (auction->bidder) //buyout for bidded auction .. { - SendAuctionOutbiddedMail( auction, auction->buyout ); + SendAuctionOutbiddedMail(auction, auction->buyout); } } auction->bidder = pl->GetGUIDLow(); auction->bid = auction->buyout; GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout); - auctionmgr.SendAuctionSalePendingMail( auction ); - auctionmgr.SendAuctionSuccessfulMail( auction ); - auctionmgr.SendAuctionWonMail( auction ); + auctionmgr.SendAuctionSalePendingMail(auction); + auctionmgr.SendAuctionSuccessfulMail(auction); + auctionmgr.SendAuctionWonMail(auction); SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK); - - auctionmgr.RemoveAItem(auction->item_guidlow); - auctionHouse->RemoveAuction(auction->Id); auction->DeleteFromDB(); - - delete auction; + uint32 item_template = auction->item_template; + auctionmgr.RemoveAItem(auction->item_guidlow); + auctionHouse->RemoveAuction(auction, item_template); } CharacterDatabase.BeginTransaction(); pl->SaveInventoryAndGoldToDB(); @@ -407,26 +408,26 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) } //this void is called when auction_owner cancels his auction -void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) +void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) { uint64 auctioneer; uint32 auctionId; recv_data >> auctioneer; recv_data >> auctionId; - //sLog.outDebug( "Cancel AUCTION AuctionID: %u", auctionId); + //sLog.outDebug("Cancel AUCTION AuctionID: %u", auctionId); Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER); if (!pCreature) { - sLog.outDebug( "WORLD: HandleAuctionRemoveItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) ); + sLog.outDebug("WORLD: HandleAuctionRemoveItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer))); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction()); AuctionEntry *auction = auctionHouse->GetAuction(auctionId); Player *pl = GetPlayer(); @@ -439,11 +440,11 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid { uint32 auctionCut = auction->GetAuctionCut(); - if ( pl->GetMoney() < auctionCut ) //player doesn't have enough money, maybe message needed + if (pl->GetMoney() < auctionCut) //player doesn't have enough money, maybe message needed return; //some auctionBidderNotification would be needed, but don't know that parts.. - SendAuctionCancelledToBidderMail( auction ); - pl->ModifyMoney( -int32(auctionCut) ); + SendAuctionCancelledToBidderMail(auction); + pl->ModifyMoney(-int32(auctionCut)); } // Return the item by mail std::ostringstream msgAuctionCanceledOwner; @@ -458,32 +459,32 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) else { sLog.outError("Auction id: %u has non-existed item (item guid : %u)!!!", auction->Id, auction->item_guidlow); - SendAuctionCommandResult( 0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR ); + SendAuctionCommandResult(0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR); return; } } else { - SendAuctionCommandResult( 0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR ); + SendAuctionCommandResult(0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR); //this code isn't possible ... maybe there should be assert - sLog.outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId ); + sLog.outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId); return; } //inform player, that auction is removed - SendAuctionCommandResult( auction->Id, AUCTION_CANCEL, AUCTION_OK ); + SendAuctionCommandResult(auction->Id, AUCTION_CANCEL, AUCTION_OK); // Now remove the auction CharacterDatabase.BeginTransaction(); - auction->DeleteFromDB(); pl->SaveInventoryAndGoldToDB(); CharacterDatabase.CommitTransaction(); - auctionmgr.RemoveAItem( auction->item_guidlow ); - auctionHouse->RemoveAuction( auction->Id ); - delete auction; + auction->DeleteFromDB(); + uint32 item_template = auction->item_template; + auctionmgr.RemoveAItem(auction->item_guidlow); + auctionHouse->RemoveAuction(auction, item_template); } //called when player lists his bids -void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) +void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) { uint64 guid; //NPC guid uint32 listfrom; //page of auctions @@ -492,37 +493,37 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) recv_data >> guid; recv_data >> listfrom; // not used in fact (this list not have page control in client) recv_data >> outbiddedCount; - if (recv_data.size() != (16 + outbiddedCount * 4 )) + if (recv_data.size() != (16 + outbiddedCount * 4)) { - sLog.outError("Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recv_data.size(),(16 + outbiddedCount * 4 )); + sLog.outError("Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recv_data.size(),(16 + outbiddedCount * 4)); outbiddedCount = 0; } Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER); if (!pCreature) { - sLog.outDebug( "WORLD: HandleAuctionListBidderItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + sLog.outDebug("WORLD: HandleAuctionListBidderItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction()); - WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) ); + WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4)); Player *pl = GetPlayer(); data << (uint32) 0; //add 0 as count uint32 count = 0; uint32 totalcount = 0; - while ( outbiddedCount > 0) //add all data, which client requires + while (outbiddedCount > 0) //add all data, which client requires { --outbiddedCount; uint32 outbiddedAuctionId; recv_data >> outbiddedAuctionId; - AuctionEntry * auction = auctionHouse->GetAuction( outbiddedAuctionId ); - if ( auction && auction->BuildAuctionInfo(data)) + AuctionEntry * auction = auctionHouse->GetAuction(outbiddedAuctionId); + if (auction && auction->BuildAuctionInfo(data)) { ++totalcount; ++count; @@ -530,14 +531,14 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) } auctionHouse->BuildListBidderItems(data,pl,count,totalcount); - data.put<uint32>( 0, count ); // add count to placeholder + data.put<uint32>(0, count); // add count to placeholder data << totalcount; data << (uint32)300; //unk 2.3.0 SendPacket(&data); } //this void sends player info about his auctions -void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data ) +void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recv_data) { uint32 listfrom; uint64 guid; @@ -548,17 +549,17 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data ) Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER); if (!pCreature) { - sLog.outDebug( "WORLD: HandleAuctionListOwnerItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + sLog.outDebug("WORLD: HandleAuctionListOwnerItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction()); - WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) ); + WorldPacket data(SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4)); data << (uint32) 0; // amount place holder uint32 count = 0; @@ -572,7 +573,7 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data ) } //this void is called when player clicks on search button -void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) +void WorldSession::HandleAuctionListItems(WorldPacket & recv_data) { std::string searchedname; uint8 levelmin, levelmax, usable; @@ -590,27 +591,27 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER); if (!pCreature) { - sLog.outDebug( "WORLD: HandleAuctionListItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + sLog.outDebug("WORLD: HandleAuctionListItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(pCreature->getFaction()); //sLog.outDebug("Auctionhouse search (GUID: %u TypeId: %u)", , list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", // GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable); - WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) ); + WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4)); uint32 count = 0; uint32 totalcount = 0; data << (uint32) 0; // converting string that we try to find to lower case std::wstring wsearchedname; - if(!Utf8toWStr(searchedname,wsearchedname)) + if (!Utf8toWStr(searchedname,wsearchedname)) return; wstrToLower(wsearchedname); @@ -626,7 +627,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) SendPacket(&data); } -void WorldSession::HandleAuctionListPendingSales( WorldPacket & recv_data ) +void WorldSession::HandleAuctionListPendingSales(WorldPacket & recv_data) { sLog.outDebug("CMSG_AUCTION_LIST_PENDING_SALES"); recv_data.hexlike(); @@ -635,7 +636,7 @@ void WorldSession::HandleAuctionListPendingSales( WorldPacket & recv_data ) WorldPacket data(SMSG_AUCTION_LIST_PENDING_SALES, 4); data << uint32(count); // count - /*for(uint32 i = 0; i < count; ++i) + /*for (uint32 i = 0; i < count; ++i) { data << ""; // string data << ""; // string diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 2edaa3f374c..1165b728ee7 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -35,7 +35,7 @@ #include "ProgressBar.h" -INSTANTIATE_SINGLETON_1( AuctionHouseMgr ); +INSTANTIATE_SINGLETON_1(AuctionHouseMgr); AuctionHouseMgr::AuctionHouseMgr() { @@ -43,22 +43,22 @@ AuctionHouseMgr::AuctionHouseMgr() AuctionHouseMgr::~AuctionHouseMgr() { - for(ItemMap::const_iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) + for (ItemMap::const_iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) delete itr->second; } -AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap( uint32 factionTemplateId ) +AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(uint32 factionTemplateId) { - if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) return &mNeutralAuctions; // team have linked auction houses FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); - if(!u_entry) + if (!u_entry) return &mNeutralAuctions; - else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) + else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) return &mAllianceAuctions; - else if(u_entry->ourMask & FACTION_MASK_HORDE) + else if (u_entry->ourMask & FACTION_MASK_HORDE) return &mHordeAuctions; else return &mNeutralAuctions; @@ -67,60 +67,49 @@ AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap( uint32 factionTemplateId ) uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem) { uint32 MSV = pItem->GetProto()->SellPrice; - double deposit; - double faction_pct; + int32 deposit; + uint32 timeHr = (((time / 60) / 60) / 12); + if (MSV > 0) { - if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - faction_pct = (0.75 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); - else - { - FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(entry->houseId); - if(!u_entry) - faction_pct = (0.75 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); - else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) - faction_pct = (0.15 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); - else if(u_entry->ourMask & FACTION_MASK_HORDE) - faction_pct = (0.15 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); - else - faction_pct = (0.75 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); - } - deposit = ((double)MSV * faction_pct * (double)pItem->GetCount()) * (double)(time / MIN_AUCTION_TIME ); + deposit = (int32)floor((double)MSV * (((double)(entry->depositPercent * 3) / 100.0f * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT) * (double)pItem->GetCount()))) * timeHr; } else { - faction_pct = 0.0f; - deposit = 0.0f; + deposit = 0; } sLog.outDebug("SellPrice:\t\t%u", MSV); - sLog.outDebug("Deposit Percent:\t%f", faction_pct); + sLog.outDebug("Deposit Percent:\t%f", ((double)entry->depositPercent / 100.0f)); sLog.outDebug("Auction Time1:\t\t%u", time); sLog.outDebug("Auction Time2:\t\t%u", MIN_AUCTION_TIME); - sLog.outDebug("Auction Time3:\t\t%u", (time / MIN_AUCTION_TIME )); + sLog.outDebug("Auction Time3:\t\t%u", timeHr); sLog.outDebug("Count:\t\t\t%u", pItem->GetCount()); - sLog.outDebug("Deposit:\t\t%f", deposit); if (deposit > 0) - return (uint32)deposit; + { + sLog.outDebug("Deposit:\t\t%u", deposit); + return deposit; + } else + { + sLog.outDebug("Deposit:\t\t0"); return 0; + } } //does not clear ram -void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) +void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction) { Item *pItem = GetAItem(auction->item_guidlow); - if(!pItem) + if (!pItem) return; + uint32 bidder_accId = 0; + uint32 bidder_security = 0; uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); Player *bidder = objmgr.GetPlayer(bidder_guid); - - uint32 bidder_accId = 0; - // data for gm.log - if( sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + if (sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { - uint32 bidder_security = 0; std::string bidder_name; if (bidder) { @@ -133,17 +122,16 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid); bidder_security = accmgr.GetSecurity(bidder_accId); - if(bidder_security > SEC_PLAYER ) // not do redundant DB requests + if (bidder_security > SEC_PLAYER) // not do redundant DB requests { - if(!objmgr.GetPlayerNameByGUID(bidder_guid,bidder_name)) + if (!objmgr.GetPlayerNameByGUID(bidder_guid,bidder_name)) bidder_name = objmgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); } } - - if( bidder_security > SEC_PLAYER ) + if (bidder_security > SEC_PLAYER) { std::string owner_name; - if(!objmgr.GetPlayerNameByGUID(auction->owner,owner_name)) + if (!objmgr.GetPlayerNameByGUID(auction->owner,owner_name)) owner_name = objmgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); uint32 owner_accid = objmgr.GetPlayerAccountIdByGUID(auction->owner); @@ -152,11 +140,9 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid); } } - else if(!bidder) - bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid); // receiver exist - if(bidder || bidder_accId) + if (bidder || bidder_accId) { std::ostringstream msgAuctionWonSubject; msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON; @@ -165,10 +151,10 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) msgAuctionWonBody.width(16); msgAuctionWonBody << std::right << std::hex << auction->owner; msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout; - sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() ); + sLog.outDebug("AuctionWon body string : %s", msgAuctionWonBody.str().c_str()); //prepare mail data... : - uint32 itemTextId = objmgr.CreateItemText( msgAuctionWonBody.str() ); + uint32 itemTextId = objmgr.CreateItemText(msgAuctionWonBody.str()); // set owner to bidder (to prevent delete item with sender char deleting) // owner in `data` will set at mail receive and item extracting @@ -179,29 +165,19 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) mi.AddItem(auction->item_guidlow, auction->item_template, pItem); if (bidder) - bidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, bidder_guid, 0, 0, auction->item_template); - else - RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! + bidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, bidder_guid, 0, 0, auction->item_template); - // will delete item or place to receiver mail list WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionWonSubject.str(), itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_AUCTION); } - // receiver not exist - else - { - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow()); - RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! - delete pItem; - } } -void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction ) +void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry * auction) { uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); Player *owner = objmgr.GetPlayer(owner_guid); - + uint32 owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid); // owner exist (online or offline) - if(owner || objmgr.GetPlayerAccountIdByGUID(owner_guid)) + if (owner || owner_accId) { std::ostringstream msgAuctionSalePendingSubject; msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING; @@ -219,24 +195,20 @@ void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction ) sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); - uint32 itemTextId = objmgr.CreateItemText( msgAuctionSalePendingBody.str() ); + uint32 itemTextId = objmgr.CreateItemText(msgAuctionSalePendingBody.str()); WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); } } //call this method to send mail to auction owner, when auction is successful, it does not clear ram -void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) +void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction) { uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); Player *owner = objmgr.GetPlayer(owner_guid); - - uint32 owner_accId = 0; - if(!owner) - owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid); - + uint32 owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid); // owner exist - if(owner || owner_accId) + if (owner || owner_accId) { std::ostringstream msgAuctionSuccessfulSubject; msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL; @@ -251,71 +223,53 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); - uint32 itemTextId = objmgr.CreateItemText( auctionSuccessfulBody.str() ); + uint32 itemTextId = objmgr.CreateItemText(auctionSuccessfulBody.str()); uint32 profit = auction->bid + auction->deposit - auctionCut; - if (owner) + //FIXME: what do if owner offline + if (owner && owner->GetGUIDLow() != auctionbot.GetAHBplayerGUID()) { - //FIXME: what do if owner offline owner->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, auction->bid); //send auction owner notification, bidder must be current! - owner->GetSession()->SendAuctionOwnerNotification( auction ); + owner->GetSession()->SendAuctionOwnerNotification(auction); } - WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->owner, msgAuctionSuccessfulSubject.str(), itemTextId, NULL, profit, 0, MAIL_CHECK_MASK_AUCTION, sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY)); } } //does not clear ram -void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction ) +void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction) { //return an item in auction to its owner by mail Item *pItem = GetAItem(auction->item_guidlow); - if(!pItem) - { - sLog.outError("Auction item (GUID: %u) not found, and lost.",auction->item_guidlow); + if (!pItem) return; - } uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); Player *owner = objmgr.GetPlayer(owner_guid); - - uint32 owner_accId = 0; - if(!owner) - owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid); - + uint32 owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid); // owner exist - if(owner || owner_accId) + if (owner || owner_accId) { std::ostringstream subject; subject << auction->item_template << ":0:" << AUCTION_EXPIRED; - if ( owner ) - owner->GetSession()->SendAuctionOwnerNotification( auction ); - else - RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! + if (owner && owner->GetGUIDLow() != auctionbot.GetAHBplayerGUID()) + owner->GetSession()->SendAuctionOwnerNotification(auction); MailItemsInfo mi; mi.AddItem(auction->item_guidlow, auction->item_template, pItem); - // will delete item or place to receiver mail list WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); } - // owner not found - else - { - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow()); - RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! - delete pItem; - } } void AuctionHouseMgr::LoadAuctionItems() { // data needs to be at first place for Item::LoadFromDB - QueryResult *result = CharacterDatabase.Query( "SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid" ); + QueryResult *result = CharacterDatabase.Query("SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid"); - if( !result ) + if (!result) { barGoLink bar(1); bar.step(); @@ -324,7 +278,7 @@ void AuctionHouseMgr::LoadAuctionItems() return; } - barGoLink bar( result->GetRowCount() ); + barGoLink bar(result->GetRowCount()); uint32 count = 0; @@ -339,15 +293,15 @@ void AuctionHouseMgr::LoadAuctionItems() ItemPrototype const *proto = objmgr.GetItemPrototype(item_template); - if(!proto) + if (!proto) { - sLog.outError( "ObjectMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template); + sLog.outError("ObjectMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template); continue; } Item *item = NewItemOrBag(proto); - if(!item->LoadFromDB(item_guid,0, result)) + if (!item->LoadFromDB(item_guid,0, result)) { delete item; continue; @@ -356,17 +310,17 @@ void AuctionHouseMgr::LoadAuctionItems() ++count; } - while( result->NextRow() ); + while(result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u auction items", count ); + sLog.outString(">> Loaded %u auction items", count); } void AuctionHouseMgr::LoadAuctions() { QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse"); - if( !result ) + if (!result) { barGoLink bar(1); bar.step(); @@ -379,7 +333,7 @@ void AuctionHouseMgr::LoadAuctions() uint32 AuctionCount=fields[0].GetUInt32(); delete result; - if(!AuctionCount) + if (!AuctionCount) { barGoLink bar(1); bar.step(); @@ -388,8 +342,8 @@ void AuctionHouseMgr::LoadAuctions() return; } - result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auctionhouse" ); - if( !result ) + result = CharacterDatabase.Query("SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auctionhouse"); + if (!result) { barGoLink bar(1); bar.step(); @@ -398,7 +352,7 @@ void AuctionHouseMgr::LoadAuctions() return; } - barGoLink bar( AuctionCount ); + barGoLink bar(AuctionCount); AuctionEntry *aItem; @@ -422,7 +376,7 @@ void AuctionHouseMgr::LoadAuctions() aItem->deposit = fields[10].GetUInt32(); CreatureData const* auctioneerData = objmgr.GetCreatureData(aItem->auctioneer); - if(!auctioneerData) + if (!auctioneerData) { aItem->DeleteFromDB(); sLog.outError("Auction %u has not a existing auctioneer (GUID : %u)", aItem->Id, aItem->auctioneer); @@ -431,7 +385,7 @@ void AuctionHouseMgr::LoadAuctions() } CreatureInfo const* auctioneerInfo = objmgr.GetCreatureTemplate(auctioneerData->id); - if(!auctioneerInfo) + if (!auctioneerInfo) { aItem->DeleteFromDB(); sLog.outError("Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", aItem->Id, aItem->auctioneer,auctioneerData->id); @@ -440,7 +394,7 @@ void AuctionHouseMgr::LoadAuctions() } aItem->auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(auctioneerInfo->faction_A); - if(!aItem->auctionHouseEntry) + if (!aItem->auctionHouseEntry) { aItem->DeleteFromDB(); sLog.outError("Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u", @@ -451,7 +405,7 @@ void AuctionHouseMgr::LoadAuctions() // check if sold item exists for guid // and item_template in fact (GetAItem will fail if problematic in result check in ObjectMgr::LoadAuctionItems) - if ( !GetAItem( aItem->item_guidlow ) ) + if (!GetAItem(aItem->item_guidlow)) { aItem->DeleteFromDB(); sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow); @@ -459,23 +413,23 @@ void AuctionHouseMgr::LoadAuctions() continue; } - GetAuctionsMap( auctioneerInfo->faction_A )->AddAuction(aItem); + GetAuctionsMap(auctioneerInfo->faction_A)->AddAuction(aItem); } while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u auctions", AuctionCount ); + sLog.outString(">> Loaded %u auctions", AuctionCount); } -void AuctionHouseMgr::AddAItem( Item* it ) +void AuctionHouseMgr::AddAItem(Item* it) { - ASSERT( it ); - ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end()); + ASSERT(it); + ASSERT(mAitems.find(it->GetGUIDLow()) == mAitems.end()); mAitems[it->GetGUIDLow()] = it; } -bool AuctionHouseMgr::RemoveAItem( uint32 id ) +bool AuctionHouseMgr::RemoveAItem(uint32 id) { ItemMap::iterator i = mAitems.find(id); if (i == mAitems.end()) @@ -497,7 +451,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem { uint32 houseid = 7; // goblin auction house - if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { //FIXME: found way for proper auctionhouse selection by another way // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races. @@ -517,11 +471,11 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem default: // for unknown case { FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); - if(!u_entry) + if (!u_entry) houseid = 7; // goblin auction house - else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) + else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) houseid = 1; // human auction house - else if(u_entry->ourMask & FACTION_MASK_HORDE) + else if (u_entry->ourMask & FACTION_MASK_HORDE) houseid = 6; // orc auction house else houseid = 7; // goblin auction house @@ -555,7 +509,7 @@ void AuctionHouseObject::Update() ///- Either cancel the auction if there was no bidder if (itr->second->bidder == 0) { - auctionmgr.SendAuctionExpiredMail( itr->second ); + auctionmgr.SendAuctionExpiredMail(itr->second); } ///- Or perform the transaction else @@ -563,15 +517,15 @@ void AuctionHouseObject::Update() //we should send an "item sold" message if the seller is online //we send the item to the winner //we send the money to the seller - auctionmgr.SendAuctionSuccessfulMail( itr->second ); - auctionmgr.SendAuctionWonMail( itr->second ); + auctionmgr.SendAuctionSuccessfulMail(itr->second); + auctionmgr.SendAuctionWonMail(itr->second); } ///- In any case clear the auction itr->second->DeleteFromDB(); + uint32 item_template = itr->second->item_template; auctionmgr.RemoveAItem(itr->second->item_guidlow); - delete itr->second; - RemoveAuction(itr->first); + RemoveAuction(itr->second, item_template); } // only check 50 items per update to not peg the CPU @@ -587,7 +541,7 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr) { AuctionEntry *Aentry = itr->second; - if( Aentry && Aentry->bidder == player->GetGUIDLow() ) + if (Aentry && Aentry->bidder == player->GetGUIDLow()) { if (itr->second->BuildAuctionInfo(data)) ++count; @@ -601,9 +555,9 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr) { AuctionEntry *Aentry = itr->second; - if( Aentry && Aentry->owner == player->GetGUIDLow() ) + if (Aentry && Aentry->owner == player->GetGUIDLow()) { - if(Aentry->BuildAuctionInfo(data)) + if (Aentry->BuildAuctionInfo(data)) ++count; ++totalcount; } @@ -641,15 +595,15 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax))) continue; - if (usable != 0x00 && player->CanUseItem( item ) != EQUIP_ERR_OK) + if (usable != 0x00 && player->CanUseItem(item) != EQUIP_ERR_OK) continue; std::string name = proto->Name1; - if(name.empty()) + if (name.empty()) continue; // local name - if ( loc_idx >= 0 ) + if (loc_idx >= 0) { ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId); if (il) @@ -659,7 +613,7 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player } } - if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname) ) + if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname)) continue; if (count < 50 && totalcount >= listfrom) @@ -708,13 +662,17 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const uint32 AuctionEntry::GetAuctionCut() const { - return uint32(auctionHouseEntry->cutPercent * bid * sWorld.getRate(RATE_AUCTION_CUT) / 100.0f); + int32 cut = int32(((double)auctionHouseEntry->cutPercent / 100.0f) * (double)sWorld.getRate(RATE_AUCTION_CUT)) * bid; + if (cut > 0) + return cut; + else + return 0; } /// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c uint32 AuctionEntry::GetAuctionOutBid() const { - uint32 outbid = (bid / 100) * 5; + uint32 outbid = (uint32)((double)bid / 100.0f) * 5; if (!outbid) outbid = 1; return outbid; diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h index 32635af43e8..85c24f15459 100644 --- a/src/game/AuctionHouseMgr.h +++ b/src/game/AuctionHouseMgr.h @@ -25,6 +25,8 @@ #include "SharedDefines.h" +#include "AuctionHouseBot.h" + class Item; class Player; class WorldPacket; @@ -93,19 +95,21 @@ class AuctionHouseObject void AddAuction(AuctionEntry *ah) { - ASSERT( ah ); + ASSERT(ah); AuctionsMap[ah->Id] = ah; + auctionbot.IncrementItemCounts(ah); } AuctionEntry* GetAuction(uint32 id) const { - AuctionEntryMap::const_iterator itr = AuctionsMap.find( id ); + AuctionEntryMap::const_iterator itr = AuctionsMap.find(id); return itr != AuctionsMap.end() ? itr->second : NULL; } - bool RemoveAuction(uint32 id) + bool RemoveAuction(AuctionEntry *auction, uint32 item_template) { - return AuctionsMap.erase(id) ? true : false; + auctionbot.DecrementItemCounts(auction, item_template); + return AuctionsMap.erase(auction->Id) ? true : false; } void Update(); @@ -132,7 +136,8 @@ class AuctionHouseMgr typedef UNORDERED_MAP<uint32, Item*> ItemMap; - AuctionHouseObject* GetAuctionsMap( uint32 factionTemplateId ); + AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId); + AuctionHouseObject* GetBidsMap(uint32 factionTemplateId); Item* GetAItem(uint32 id) { @@ -145,10 +150,10 @@ class AuctionHouseMgr } //auction messages - void SendAuctionWonMail( AuctionEntry * auction ); - void SendAuctionSalePendingMail( AuctionEntry * auction ); - void SendAuctionSuccessfulMail( AuctionEntry * auction ); - void SendAuctionExpiredMail( AuctionEntry * auction ); + void SendAuctionWonMail(AuctionEntry * auction); + void SendAuctionSalePendingMail(AuctionEntry * auction); + void SendAuctionSuccessfulMail(AuctionEntry * auction); + void SendAuctionExpiredMail(AuctionEntry * auction); static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem); static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId); diff --git a/src/game/World.cpp b/src/game/World.cpp index 6d264cb049c..f3288d8c076 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -69,7 +69,7 @@ #include "Transports.h" #include "ProgressBar.h" -INSTANTIATE_SINGLETON_1( World ); +INSTANTIATE_SINGLETON_1(World); volatile bool World::m_stopEvent = false; uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; @@ -133,7 +133,7 @@ World::~World() VMAP::VMapFactory::clear(); - if(m_resultQueue) delete m_resultQueue; + if (m_resultQueue) delete m_resultQueue; //TODO free addSessQueue } @@ -145,12 +145,12 @@ Player* World::FindPlayerInZone(uint32 zone) SessionMap::const_iterator itr; for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { - if(!itr->second) + if (!itr->second) continue; Player *player = itr->second->GetPlayer(); - if(!player) + if (!player) continue; - if( player->IsInWorld() && player->GetZoneId() == zone ) + if (player->IsInWorld() && player->GetZoneId() == zone) { // Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone. return player; @@ -164,7 +164,7 @@ WorldSession* World::FindSession(uint32 id) const { SessionMap::const_iterator itr = m_sessions.find(id); - if(itr != m_sessions.end()) + if (itr != m_sessions.end()) return itr->second; // also can return NULL for kicked session else return NULL; @@ -176,7 +176,7 @@ bool World::RemoveSession(uint32 id) ///- Find the session, kick the user, but we can't delete session at this moment to prevent iterator invalidation SessionMap::const_iterator itr = m_sessions.find(id); - if(itr != m_sessions.end() && itr->second) + if (itr != m_sessions.end() && itr->second) { if (itr->second->PlayerLoading()) return false; @@ -215,10 +215,10 @@ World::AddSession_ (WorldSession* s) { SessionMap::const_iterator old = m_sessions.find(s->GetAccountId ()); - if(old != m_sessions.end()) + if (old != m_sessions.end()) { // prevent decrease sessions count if session queued - if(RemoveQueuedPlayer(old->second)) + if (RemoveQueuedPlayer(old->second)) decrease_session = false; // not remove replaced session form queue if listed delete old->second; @@ -233,10 +233,10 @@ World::AddSession_ (WorldSession* s) //so we don't count the user trying to //login as a session and queue the socket that we are using - if(decrease_session) + if (decrease_session) --Sessions; - if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER && !HasRecentlyDisconnected(s) ) + if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER && !HasRecentlyDisconnected(s)) { AddQueuedPlayer (s); UpdateMaxSessionCounters (); @@ -275,15 +275,15 @@ World::AddSession_ (WorldSession* s) bool World::HasRecentlyDisconnected(WorldSession* session) { - if(!session) return false; + if (!session) return false; - if(uint32 tolerance = getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) + if (uint32 tolerance = getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) { - for(DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end(); ) + for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();) { - if(difftime(i->second, time(NULL)) < tolerance) + if (difftime(i->second, time(NULL)) < tolerance) { - if(i->first == session->GetAccountId()) + if (i->first == session->GetAccountId()) return true; ++i; } @@ -298,8 +298,8 @@ int32 World::GetQueuePos(WorldSession* sess) { uint32 position = 1; - for(Queue::const_iterator iter = m_QueuedPlayer.begin(); iter != m_QueuedPlayer.end(); ++iter, ++position) - if((*iter) == sess) + for (Queue::const_iterator iter = m_QueuedPlayer.begin(); iter != m_QueuedPlayer.end(); ++iter, ++position) + if ((*iter) == sess) return position; return 0; @@ -334,9 +334,9 @@ bool World::RemoveQueuedPlayer(WorldSession* sess) // search to remove and count skipped positions bool found = false; - for(;iter != m_QueuedPlayer.end(); ++iter, ++position) + for (;iter != m_QueuedPlayer.end(); ++iter, ++position) { - if(*iter==sess) + if (*iter==sess) { sess->SetInQueue(false); iter = m_QueuedPlayer.erase(iter); @@ -349,11 +349,11 @@ bool World::RemoveQueuedPlayer(WorldSession* sess) // position store position of removed socket and then new position next socket after removed // if session not queued then we need decrease sessions count - if(!found && sessions) + if (!found && sessions) --sessions; // accept first in queue - if( (!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty() ) + if ((!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty()) { WorldSession* pop_sess = m_QueuedPlayer.front(); pop_sess->SetInQueue(false); @@ -367,7 +367,7 @@ bool World::RemoveQueuedPlayer(WorldSession* sess) // update position from iter to end() // iter point to first not updated socket, position store new position - for(; iter != m_QueuedPlayer.end(); ++iter, ++position) + for (; iter != m_QueuedPlayer.end(); ++iter, ++position) (*iter)->SendAuthWaitQue(position); return found; @@ -378,7 +378,7 @@ Weather* World::FindWeather(uint32 id) const { WeatherMap::const_iterator itr = m_weathers.find(id); - if(itr != m_weathers.end()) + if (itr != m_weathers.end()) return itr->second; else return 0; @@ -390,7 +390,7 @@ void World::RemoveWeather(uint32 id) // not called at the moment. Kept for completeness WeatherMap::iterator itr = m_weathers.find(id); - if(itr != m_weathers.end()) + if (itr != m_weathers.end()) { delete itr->second; m_weathers.erase(itr); @@ -403,7 +403,7 @@ Weather* World::AddWeather(uint32 zone_id) WeatherZoneChances const* weatherChances = objmgr.GetWeatherChances(zone_id); // zone not have weather, ignore - if(!weatherChances) + if (!weatherChances) return NULL; Weather* w = new Weather(zone_id,weatherChances); @@ -416,9 +416,9 @@ Weather* World::AddWeather(uint32 zone_id) /// Initialize config values void World::LoadConfigSettings(bool reload) { - if(reload) + if (reload) { - if(!sConfig.Reload()) + if (!sConfig.Reload()) { sLog.outError("World settings reload fail: can't read settings from %s.",sConfig.GetFilename().c_str()); return; @@ -427,8 +427,8 @@ void World::LoadConfigSettings(bool reload) } ///- Read the player limit and the Message of the day from the config file - SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true ); - SetMotd( sConfig.GetStringDefault("Motd", "Welcome to a Trinity Core Server." ) ); + SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true); + SetMotd(sConfig.GetStringDefault("Motd", "Welcome to a Trinity Core Server.")); ///- Get string for new logins (newly created characters) SetNewCharString(sConfig.GetStringDefault("PlayerStart.String", "")); @@ -438,27 +438,27 @@ void World::LoadConfigSettings(bool reload) ///- Read all rates from the config file rate_values[RATE_HEALTH] = sConfig.GetFloatDefault("Rate.Health", 1); - if(rate_values[RATE_HEALTH] < 0) + if (rate_values[RATE_HEALTH] < 0) { sLog.outError("Rate.Health (%f) must be > 0. Using 1 instead.",rate_values[RATE_HEALTH]); rate_values[RATE_HEALTH] = 1; } rate_values[RATE_POWER_MANA] = sConfig.GetFloatDefault("Rate.Mana", 1); - if(rate_values[RATE_POWER_MANA] < 0) + if (rate_values[RATE_POWER_MANA] < 0) { sLog.outError("Rate.Mana (%f) must be > 0. Using 1 instead.",rate_values[RATE_POWER_MANA]); rate_values[RATE_POWER_MANA] = 1; } rate_values[RATE_POWER_RAGE_INCOME] = sConfig.GetFloatDefault("Rate.Rage.Income", 1); rate_values[RATE_POWER_RAGE_LOSS] = sConfig.GetFloatDefault("Rate.Rage.Loss", 1); - if(rate_values[RATE_POWER_RAGE_LOSS] < 0) + if (rate_values[RATE_POWER_RAGE_LOSS] < 0) { sLog.outError("Rate.Rage.Loss (%f) must be > 0. Using 1 instead.",rate_values[RATE_POWER_RAGE_LOSS]); rate_values[RATE_POWER_RAGE_LOSS] = 1; } rate_values[RATE_POWER_RUNICPOWER_INCOME] = sConfig.GetFloatDefault("Rate.RunicPower.Income", 1); rate_values[RATE_POWER_RUNICPOWER_LOSS] = sConfig.GetFloatDefault("Rate.RunicPower.Loss", 1); - if(rate_values[RATE_POWER_RUNICPOWER_LOSS] < 0) + if (rate_values[RATE_POWER_RUNICPOWER_LOSS] < 0) { sLog.outError("Rate.RunicPower.Loss (%f) must be > 0. Using 1 instead.",rate_values[RATE_POWER_RUNICPOWER_LOSS]); rate_values[RATE_POWER_RUNICPOWER_LOSS] = 1; @@ -478,7 +478,7 @@ void World::LoadConfigSettings(bool reload) rate_values[RATE_XP_QUEST] = sConfig.GetFloatDefault("Rate.XP.Quest", 1.0f); rate_values[RATE_XP_EXPLORE] = sConfig.GetFloatDefault("Rate.XP.Explore", 1.0f); rate_values[RATE_REPAIRCOST] = sConfig.GetFloatDefault("Rate.RepairCost", 1.0f); - if(rate_values[RATE_REPAIRCOST] < 0.0f) + if (rate_values[RATE_REPAIRCOST] < 0.0f) { sLog.outError("Rate.RepairCost (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_REPAIRCOST]); rate_values[RATE_REPAIRCOST] = 0.0f; @@ -514,27 +514,27 @@ void World::LoadConfigSettings(bool reload) rate_values[RATE_MINING_NEXT] = sConfig.GetFloatDefault("Rate.Mining.Next",1.0f); rate_values[RATE_INSTANCE_RESET_TIME] = sConfig.GetFloatDefault("Rate.InstanceResetTime",1.0f); rate_values[RATE_TALENT] = sConfig.GetFloatDefault("Rate.Talent",1.0f); - if(rate_values[RATE_TALENT] < 0.0f) + if (rate_values[RATE_TALENT] < 0.0f) { sLog.outError("Rate.Talent (%f) must be > 0. Using 1 instead.",rate_values[RATE_TALENT]); rate_values[RATE_TALENT] = 1.0f; } rate_values[RATE_MOVESPEED] = sConfig.GetFloatDefault("Rate.MoveSpeed",1.0f); - if(rate_values[RATE_MOVESPEED] < 0) + if (rate_values[RATE_MOVESPEED] < 0) { sLog.outError("Rate.MoveSpeed (%f) must be > 0. Using 1 instead.",rate_values[RATE_MOVESPEED]); rate_values[RATE_MOVESPEED] = 1.0f; } - for(uint8 i = 0; i < MAX_MOVE_TYPE; ++i) playerBaseMoveSpeed[i] = baseMoveSpeed[i] * rate_values[RATE_MOVESPEED]; + for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i) playerBaseMoveSpeed[i] = baseMoveSpeed[i] * rate_values[RATE_MOVESPEED]; rate_values[RATE_CORPSE_DECAY_LOOTED] = sConfig.GetFloatDefault("Rate.Corpse.Decay.Looted",0.5f); rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = sConfig.GetFloatDefault("TargetPosRecalculateRange",1.5f); - if(rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] < CONTACT_DISTANCE) + if (rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] < CONTACT_DISTANCE) { sLog.outError("TargetPosRecalculateRange (%f) must be >= %f. Using %f instead.",rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],CONTACT_DISTANCE,CONTACT_DISTANCE); rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = CONTACT_DISTANCE; } - else if(rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] > NOMINAL_MELEE_RANGE) + else if (rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] > NOMINAL_MELEE_RANGE) { sLog.outError("TargetPosRecalculateRange (%f) must be <= %f. Using %f instead.", rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],NOMINAL_MELEE_RANGE,NOMINAL_MELEE_RANGE); @@ -542,12 +542,12 @@ void World::LoadConfigSettings(bool reload) } rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = sConfig.GetFloatDefault("DurabilityLoss.OnDeath", 10.0f); - if(rate_values[RATE_DURABILITY_LOSS_ON_DEATH] < 0.0f) + if (rate_values[RATE_DURABILITY_LOSS_ON_DEATH] < 0.0f) { sLog.outError("DurabilityLoss.OnDeath (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ON_DEATH]); rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = 0.0f; } - if(rate_values[RATE_DURABILITY_LOSS_ON_DEATH] > 100.0f) + if (rate_values[RATE_DURABILITY_LOSS_ON_DEATH] > 100.0f) { sLog.outError("DurabilityLoss.OnDeath (%f) must be <=100. Using 100.0 instead.",rate_values[RATE_DURABILITY_LOSS_ON_DEATH]); rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = 0.0f; @@ -555,25 +555,25 @@ void World::LoadConfigSettings(bool reload) rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = rate_values[RATE_DURABILITY_LOSS_ON_DEATH] / 100.0f; rate_values[RATE_DURABILITY_LOSS_DAMAGE] = sConfig.GetFloatDefault("DurabilityLossChance.Damage",0.5f); - if(rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f) + if (rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f) { sLog.outError("DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_DAMAGE]); rate_values[RATE_DURABILITY_LOSS_DAMAGE] = 0.0f; } rate_values[RATE_DURABILITY_LOSS_ABSORB] = sConfig.GetFloatDefault("DurabilityLossChance.Absorb",0.5f); - if(rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f) + if (rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f) { sLog.outError("DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ABSORB]); rate_values[RATE_DURABILITY_LOSS_ABSORB] = 0.0f; } rate_values[RATE_DURABILITY_LOSS_PARRY] = sConfig.GetFloatDefault("DurabilityLossChance.Parry",0.05f); - if(rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f) + if (rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f) { sLog.outError("DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_PARRY]); rate_values[RATE_DURABILITY_LOSS_PARRY] = 0.0f; } rate_values[RATE_DURABILITY_LOSS_BLOCK] = sConfig.GetFloatDefault("DurabilityLossChance.Block",0.05f); - if(rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f) + if (rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f) { sLog.outError("DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_BLOCK]); rate_values[RATE_DURABILITY_LOSS_BLOCK] = 0.0f; @@ -584,7 +584,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_DURABILITY_LOSS_IN_PVP] = sConfig.GetBoolDefault("DurabilityLoss.InPvP", false); m_configs[CONFIG_COMPRESSION] = sConfig.GetIntDefault("Compression", 1); - if(m_configs[CONFIG_COMPRESSION] < 1 || m_configs[CONFIG_COMPRESSION] > 9) + if (m_configs[CONFIG_COMPRESSION] < 1 || m_configs[CONFIG_COMPRESSION] > 9) { sLog.outError("Compression level (%i) must be in range 1..9. Using default compression level (1).",m_configs[CONFIG_COMPRESSION]); m_configs[CONFIG_COMPRESSION] = 1; @@ -595,38 +595,38 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE] = sConfig.GetIntDefault("DisconnectToleranceInterval", 0); m_configs[CONFIG_INTERVAL_GRIDCLEAN] = sConfig.GetIntDefault("GridCleanUpDelay", 5 * MINUTE * IN_MILISECONDS); - if(m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY) + if (m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY) { sLog.outError("GridCleanUpDelay (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_GRIDCLEAN],MIN_GRID_DELAY); m_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY; } - if(reload) + if (reload) MapManager::Instance().SetGridCleanUpDelay(m_configs[CONFIG_INTERVAL_GRIDCLEAN]); m_configs[CONFIG_INTERVAL_MAPUPDATE] = sConfig.GetIntDefault("MapUpdateInterval", 100); - if(m_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY) + if (m_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY) { sLog.outError("MapUpdateInterval (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_MAPUPDATE],MIN_MAP_UPDATE_DELAY); m_configs[CONFIG_INTERVAL_MAPUPDATE] = MIN_MAP_UPDATE_DELAY; } - if(reload) + if (reload) MapManager::Instance().SetMapUpdateInterval(m_configs[CONFIG_INTERVAL_MAPUPDATE]); m_configs[CONFIG_INTERVAL_CHANGEWEATHER] = sConfig.GetIntDefault("ChangeWeatherInterval", 10 * MINUTE * IN_MILISECONDS); - if(reload) + if (reload) { uint32 val = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); - if(val!=m_configs[CONFIG_PORT_WORLD]) + if (val!=m_configs[CONFIG_PORT_WORLD]) sLog.outError("WorldServerPort option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_PORT_WORLD]); } else m_configs[CONFIG_PORT_WORLD] = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); - if(reload) + if (reload) { uint32 val = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); - if(val!=m_configs[CONFIG_SOCKET_SELECTTIME]) + if (val!=m_configs[CONFIG_SOCKET_SELECTTIME]) sLog.outError("SocketSelectTime option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_SOCKET_SELECTTIME]); } else @@ -637,19 +637,19 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50); m_configs[CONFIG_SIGHT_GUARDER] = sConfig.GetIntDefault("GuarderSight", 50); - if(reload) + if (reload) { uint32 val = sConfig.GetIntDefault("GameType", 0); - if(val!=m_configs[CONFIG_GAME_TYPE]) + if (val!=m_configs[CONFIG_GAME_TYPE]) sLog.outError("GameType option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_GAME_TYPE]); } else m_configs[CONFIG_GAME_TYPE] = sConfig.GetIntDefault("GameType", 0); - if(reload) + if (reload) { uint32 val = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); - if(val!=m_configs[CONFIG_REALM_ZONE]) + if (val!=m_configs[CONFIG_REALM_ZONE]) sLog.outError("RealmZone option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_REALM_ZONE]); } else @@ -670,21 +670,21 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_STRICT_PET_NAMES] = sConfig.GetIntDefault ("StrictPetNames", 0); m_configs[CONFIG_MIN_PLAYER_NAME] = sConfig.GetIntDefault ("MinPlayerName", 2); - if(m_configs[CONFIG_MIN_PLAYER_NAME] < 1 || m_configs[CONFIG_MIN_PLAYER_NAME] > MAX_PLAYER_NAME) + if (m_configs[CONFIG_MIN_PLAYER_NAME] < 1 || m_configs[CONFIG_MIN_PLAYER_NAME] > MAX_PLAYER_NAME) { sLog.outError("MinPlayerName (%i) must be in range 1..%u. Set to 2.",m_configs[CONFIG_MIN_PLAYER_NAME],MAX_PLAYER_NAME); m_configs[CONFIG_MIN_PLAYER_NAME] = 2; } m_configs[CONFIG_MIN_CHARTER_NAME] = sConfig.GetIntDefault ("MinCharterName", 2); - if(m_configs[CONFIG_MIN_CHARTER_NAME] < 1 || m_configs[CONFIG_MIN_CHARTER_NAME] > MAX_CHARTER_NAME) + if (m_configs[CONFIG_MIN_CHARTER_NAME] < 1 || m_configs[CONFIG_MIN_CHARTER_NAME] > MAX_CHARTER_NAME) { sLog.outError("MinCharterName (%i) must be in range 1..%u. Set to 2.",m_configs[CONFIG_MIN_CHARTER_NAME],MAX_CHARTER_NAME); m_configs[CONFIG_MIN_CHARTER_NAME] = 2; } m_configs[CONFIG_MIN_PET_NAME] = sConfig.GetIntDefault ("MinPetName", 2); - if(m_configs[CONFIG_MIN_PET_NAME] < 1 || m_configs[CONFIG_MIN_PET_NAME] > MAX_PET_NAME) + if (m_configs[CONFIG_MIN_PET_NAME] < 1 || m_configs[CONFIG_MIN_PET_NAME] > MAX_PET_NAME) { sLog.outError("MinPetName (%i) must be in range 1..%u. Set to 2.",m_configs[CONFIG_MIN_PET_NAME],MAX_PET_NAME); m_configs[CONFIG_MIN_PET_NAME] = 2; @@ -693,7 +693,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_CHARACTERS_CREATING_DISABLED] = sConfig.GetIntDefault ("CharactersCreatingDisabled", 0); m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10); - if(m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10) + if (m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10) { sLog.outError("CharactersPerRealm (%i) must be in range 1..10. Set to 10.",m_configs[CONFIG_CHARACTERS_PER_REALM]); m_configs[CONFIG_CHARACTERS_PER_REALM] = 10; @@ -701,14 +701,14 @@ void World::LoadConfigSettings(bool reload) // must be after CONFIG_CHARACTERS_PER_REALM m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50); - if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_configs[CONFIG_CHARACTERS_PER_REALM]) + if (m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_configs[CONFIG_CHARACTERS_PER_REALM]) { sLog.outError("CharactersPerAccount (%i) can't be less than CharactersPerRealm (%i).",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT],m_configs[CONFIG_CHARACTERS_PER_REALM]); m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = m_configs[CONFIG_CHARACTERS_PER_REALM]; } m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("HeroicCharactersPerRealm", 1); - if(int32(m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]) < 0 || m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] > 10) + if (int32(m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]) < 0 || m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] > 10) { sLog.outError("HeroicCharactersPerRealm (%i) must be in range 0..10. Set to 1.",m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]); m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] = 1; @@ -717,22 +717,22 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING] = sConfig.GetIntDefault("MinLevelForHeroicCharacterCreating", 55); m_configs[CONFIG_SKIP_CINEMATICS] = sConfig.GetIntDefault("SkipCinematics", 0); - if(int32(m_configs[CONFIG_SKIP_CINEMATICS]) < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2) + if (int32(m_configs[CONFIG_SKIP_CINEMATICS]) < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2) { sLog.outError("SkipCinematics (%i) must be in range 0..2. Set to 0.",m_configs[CONFIG_SKIP_CINEMATICS]); m_configs[CONFIG_SKIP_CINEMATICS] = 0; } - if(reload) + if (reload) { uint32 val = sConfig.GetIntDefault("MaxPlayerLevel", DEFAULT_MAX_LEVEL); - if(val!=m_configs[CONFIG_MAX_PLAYER_LEVEL]) + if (val!=m_configs[CONFIG_MAX_PLAYER_LEVEL]) sLog.outError("MaxPlayerLevel option can't be changed at config reload, using current value (%u).",m_configs[CONFIG_MAX_PLAYER_LEVEL]); } else m_configs[CONFIG_MAX_PLAYER_LEVEL] = sConfig.GetIntDefault("MaxPlayerLevel", DEFAULT_MAX_LEVEL); - if(m_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL) + if (m_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL) { sLog.outError("MaxPlayerLevel (%i) must be in range 1..%u. Set to %u.",m_configs[CONFIG_MAX_PLAYER_LEVEL],MAX_LEVEL,MAX_LEVEL); m_configs[CONFIG_MAX_PLAYER_LEVEL] = MAX_LEVEL; @@ -741,25 +741,25 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_MIN_DUALSPEC_LEVEL] = sConfig.GetIntDefault("MinDualSpecLevel", 40); m_configs[CONFIG_START_PLAYER_LEVEL] = sConfig.GetIntDefault("StartPlayerLevel", 1); - if(m_configs[CONFIG_START_PLAYER_LEVEL] < 1) + if (m_configs[CONFIG_START_PLAYER_LEVEL] < 1) { sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to 1.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); m_configs[CONFIG_START_PLAYER_LEVEL] = 1; } - else if(m_configs[CONFIG_START_PLAYER_LEVEL] > m_configs[CONFIG_MAX_PLAYER_LEVEL]) + else if (m_configs[CONFIG_START_PLAYER_LEVEL] > m_configs[CONFIG_MAX_PLAYER_LEVEL]) { sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); m_configs[CONFIG_START_PLAYER_LEVEL] = m_configs[CONFIG_MAX_PLAYER_LEVEL]; } m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] = sConfig.GetIntDefault("StartHeroicPlayerLevel", 55); - if(m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] < 1) + if (m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] < 1) { sLog.outError("StartHeroicPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to 55.", m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] = 55; } - else if(m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] > m_configs[CONFIG_MAX_PLAYER_LEVEL]) + else if (m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] > m_configs[CONFIG_MAX_PLAYER_LEVEL]) { sLog.outError("StartHeroicPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u.", m_configs[CONFIG_START_HEROIC_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); @@ -767,12 +767,12 @@ void World::LoadConfigSettings(bool reload) } m_configs[CONFIG_START_PLAYER_MONEY] = sConfig.GetIntDefault("StartPlayerMoney", 0); - if(int32(m_configs[CONFIG_START_PLAYER_MONEY]) < 0) + if (int32(m_configs[CONFIG_START_PLAYER_MONEY]) < 0) { sLog.outError("StartPlayerMoney (%i) must be in range 0..%u. Set to %u.",m_configs[CONFIG_START_PLAYER_MONEY],MAX_MONEY_AMOUNT,0); m_configs[CONFIG_START_PLAYER_MONEY] = 0; } - else if(m_configs[CONFIG_START_PLAYER_MONEY] > MAX_MONEY_AMOUNT) + else if (m_configs[CONFIG_START_PLAYER_MONEY] > MAX_MONEY_AMOUNT) { sLog.outError("StartPlayerMoney (%i) must be in range 0..%u. Set to %u.", m_configs[CONFIG_START_PLAYER_MONEY],MAX_MONEY_AMOUNT,MAX_MONEY_AMOUNT); @@ -780,20 +780,20 @@ void World::LoadConfigSettings(bool reload) } m_configs[CONFIG_MAX_HONOR_POINTS] = sConfig.GetIntDefault("MaxHonorPoints", 75000); - if(int32(m_configs[CONFIG_MAX_HONOR_POINTS]) < 0) + if (int32(m_configs[CONFIG_MAX_HONOR_POINTS]) < 0) { sLog.outError("MaxHonorPoints (%i) can't be negative. Set to 0.",m_configs[CONFIG_MAX_HONOR_POINTS]); m_configs[CONFIG_MAX_HONOR_POINTS] = 0; } m_configs[CONFIG_START_HONOR_POINTS] = sConfig.GetIntDefault("StartHonorPoints", 0); - if(int32(m_configs[CONFIG_START_HONOR_POINTS]) < 0) + if (int32(m_configs[CONFIG_START_HONOR_POINTS]) < 0) { sLog.outError("StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u.", m_configs[CONFIG_START_HONOR_POINTS],m_configs[CONFIG_MAX_HONOR_POINTS],0); m_configs[CONFIG_START_HONOR_POINTS] = 0; } - else if(m_configs[CONFIG_START_HONOR_POINTS] > m_configs[CONFIG_MAX_HONOR_POINTS]) + else if (m_configs[CONFIG_START_HONOR_POINTS] > m_configs[CONFIG_MAX_HONOR_POINTS]) { sLog.outError("StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u.", m_configs[CONFIG_START_HONOR_POINTS],m_configs[CONFIG_MAX_HONOR_POINTS],m_configs[CONFIG_MAX_HONOR_POINTS]); @@ -801,20 +801,20 @@ void World::LoadConfigSettings(bool reload) } m_configs[CONFIG_MAX_ARENA_POINTS] = sConfig.GetIntDefault("MaxArenaPoints", 5000); - if(int32(m_configs[CONFIG_MAX_ARENA_POINTS]) < 0) + if (int32(m_configs[CONFIG_MAX_ARENA_POINTS]) < 0) { sLog.outError("MaxArenaPoints (%i) can't be negative. Set to 0.",m_configs[CONFIG_MAX_ARENA_POINTS]); m_configs[CONFIG_MAX_ARENA_POINTS] = 0; } m_configs[CONFIG_START_ARENA_POINTS] = sConfig.GetIntDefault("StartArenaPoints", 0); - if(int32(m_configs[CONFIG_START_ARENA_POINTS]) < 0) + if (int32(m_configs[CONFIG_START_ARENA_POINTS]) < 0) { sLog.outError("StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u.", m_configs[CONFIG_START_ARENA_POINTS],m_configs[CONFIG_MAX_ARENA_POINTS],0); m_configs[CONFIG_START_ARENA_POINTS] = 0; } - else if(m_configs[CONFIG_START_ARENA_POINTS] > m_configs[CONFIG_MAX_ARENA_POINTS]) + else if (m_configs[CONFIG_START_ARENA_POINTS] > m_configs[CONFIG_MAX_ARENA_POINTS]) { sLog.outError("StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u.", m_configs[CONFIG_START_ARENA_POINTS],m_configs[CONFIG_MAX_ARENA_POINTS],m_configs[CONFIG_MAX_ARENA_POINTS]); @@ -833,7 +833,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL] = sConfig.GetIntDefault("MaxPrimaryTradeSkill", 2); m_configs[CONFIG_MIN_PETITION_SIGNS] = sConfig.GetIntDefault("MinPetitionSigns", 9); - if(m_configs[CONFIG_MIN_PETITION_SIGNS] > 9) + if (m_configs[CONFIG_MIN_PETITION_SIGNS] > 9) { sLog.outError("MinPetitionSigns (%i) must be in range 0..9. Set to 9.", m_configs[CONFIG_MIN_PETITION_SIGNS]); m_configs[CONFIG_MIN_PETITION_SIGNS] = 9; @@ -851,13 +851,13 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1); m_configs[CONFIG_ALLOW_GM_GROUP] = sConfig.GetBoolDefault("GM.AllowInvite", false); m_configs[CONFIG_ALLOW_GM_FRIEND] = sConfig.GetBoolDefault("GM.AllowFriend", false); - if(m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL]) + if (m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL]) { sLog.outError("GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..%u. Set to %u.", m_configs[CONFIG_START_GM_LEVEL],m_configs[CONFIG_START_PLAYER_LEVEL], MAX_LEVEL, m_configs[CONFIG_START_PLAYER_LEVEL]); m_configs[CONFIG_START_GM_LEVEL] = m_configs[CONFIG_START_PLAYER_LEVEL]; } - else if(m_configs[CONFIG_START_GM_LEVEL] > MAX_LEVEL) + else if (m_configs[CONFIG_START_GM_LEVEL] > MAX_LEVEL) { sLog.outError("GM.StartLevel (%i) must be in range 1..%u. Set to %u.", m_configs[CONFIG_START_GM_LEVEL], MAX_LEVEL, MAX_LEVEL); m_configs[CONFIG_START_GM_LEVEL] = MAX_LEVEL; @@ -870,12 +870,12 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_MAIL_DELIVERY_DELAY] = sConfig.GetIntDefault("MailDeliveryDelay",HOUR); m_configs[CONFIG_UPTIME_UPDATE] = sConfig.GetIntDefault("UpdateUptimeInterval", 10); - if(int32(m_configs[CONFIG_UPTIME_UPDATE])<=0) + if (int32(m_configs[CONFIG_UPTIME_UPDATE])<=0) { sLog.outError("UpdateUptimeInterval (%i) must be > 0, set to default 10.",m_configs[CONFIG_UPTIME_UPDATE]); m_configs[CONFIG_UPTIME_UPDATE] = 10; } - if(reload) + if (reload) { m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE*IN_MILISECONDS); m_timers[WUPDATE_UPTIME].Reset(); @@ -883,12 +883,12 @@ void World::LoadConfigSettings(bool reload) // log db cleanup interval m_configs[CONFIG_LOGDB_CLEARINTERVAL] = sConfig.GetIntDefault("LogDB.Opt.ClearInterval", 10); - if(int32(m_configs[CONFIG_LOGDB_CLEARINTERVAL]) <= 0) + if (int32(m_configs[CONFIG_LOGDB_CLEARINTERVAL]) <= 0) { sLog.outError("LogDB.Opt.ClearInterval (%i) must be > 0, set to default 10.", m_configs[CONFIG_LOGDB_CLEARINTERVAL]); m_configs[CONFIG_LOGDB_CLEARINTERVAL] = 10; } - if(reload) + if (reload) { m_timers[WUPDATE_CLEANDB].SetInterval(m_configs[CONFIG_LOGDB_CLEARINTERVAL] * MINUTE * IN_MILISECONDS); m_timers[WUPDATE_CLEANDB].Reset(); @@ -909,35 +909,35 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_SKILL_MILLING] = sConfig.GetBoolDefault("SkillChance.Milling",false); m_configs[CONFIG_SKILL_GAIN_CRAFTING] = sConfig.GetIntDefault("SkillGain.Crafting", 1); - if(m_configs[CONFIG_SKILL_GAIN_CRAFTING] < 0) + if (m_configs[CONFIG_SKILL_GAIN_CRAFTING] < 0) { sLog.outError("SkillGain.Crafting (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_CRAFTING]); m_configs[CONFIG_SKILL_GAIN_CRAFTING] = 1; } m_configs[CONFIG_SKILL_GAIN_DEFENSE] = sConfig.GetIntDefault("SkillGain.Defense", 1); - if(m_configs[CONFIG_SKILL_GAIN_DEFENSE] < 0) + if (m_configs[CONFIG_SKILL_GAIN_DEFENSE] < 0) { sLog.outError("SkillGain.Defense (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_DEFENSE]); m_configs[CONFIG_SKILL_GAIN_DEFENSE] = 1; } m_configs[CONFIG_SKILL_GAIN_GATHERING] = sConfig.GetIntDefault("SkillGain.Gathering", 1); - if(m_configs[CONFIG_SKILL_GAIN_GATHERING] < 0) + if (m_configs[CONFIG_SKILL_GAIN_GATHERING] < 0) { sLog.outError("SkillGain.Gathering (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_GATHERING]); m_configs[CONFIG_SKILL_GAIN_GATHERING] = 1; } m_configs[CONFIG_SKILL_GAIN_WEAPON] = sConfig.GetIntDefault("SkillGain.Weapon", 1); - if(m_configs[CONFIG_SKILL_GAIN_WEAPON] < 0) + if (m_configs[CONFIG_SKILL_GAIN_WEAPON] < 0) { sLog.outError("SkillGain.Weapon (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_WEAPON]); m_configs[CONFIG_SKILL_GAIN_WEAPON] = 1; } m_configs[CONFIG_MAX_OVERSPEED_PINGS] = sConfig.GetIntDefault("MaxOverspeedPings",2); - if(m_configs[CONFIG_MAX_OVERSPEED_PINGS] != 0 && m_configs[CONFIG_MAX_OVERSPEED_PINGS] < 2) + if (m_configs[CONFIG_MAX_OVERSPEED_PINGS] != 0 && m_configs[CONFIG_MAX_OVERSPEED_PINGS] < 2) { sLog.outError("MaxOverspeedPings (%i) must be in range 2..infinity (or 0 to disable check). Set to 2.",m_configs[CONFIG_MAX_OVERSPEED_PINGS]); m_configs[CONFIG_MAX_OVERSPEED_PINGS] = 2; @@ -950,10 +950,10 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL] = sConfig.GetBoolDefault("AlwaysMaxSkillForLevel", false); - if(reload) + if (reload) { uint32 val = sConfig.GetIntDefault("Expansion",1); - if(val!=m_configs[CONFIG_EXPANSION]) + if (val!=m_configs[CONFIG_EXPANSION]) sLog.outError("Expansion option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_EXPANSION]); } else @@ -974,10 +974,10 @@ void World::LoadConfigSettings(bool reload) // note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level MAX_LEVEL(100) m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.LowLevelHideDiff", 4); - if(m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > MAX_LEVEL) + if (m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > MAX_LEVEL) m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = MAX_LEVEL; m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.HighLevelHideDiff", 7); - if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > MAX_LEVEL) + if (m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > MAX_LEVEL) m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = MAX_LEVEL; m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true); @@ -1031,10 +1031,10 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN] = sConfig.GetBoolDefault("OffhandCheckAtSpellUnlearn", false); - if(int clientCacheId = sConfig.GetIntDefault("ClientCacheVersion", 0)) + if (int clientCacheId = sConfig.GetIntDefault("ClientCacheVersion", 0)) { // overwrite DB/old value - if(clientCacheId > 0) + if (clientCacheId > 0) { m_configs[CONFIG_CLIENTCACHE_VERSION] = clientCacheId; sLog.outString("Client cache version set to: %u", clientCacheId); @@ -1053,37 +1053,37 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_GUILD_BANK_EVENT_LOG_COUNT] = GUILD_BANK_MAX_LOGS; m_VisibleUnitGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Unit", 1); - if(m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + if (m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.Grey.Unit can't be greater %f",MAX_VISIBILITY_DISTANCE); m_VisibleUnitGreyDistance = MAX_VISIBILITY_DISTANCE; } m_VisibleObjectGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Object", 10); - if(m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + if (m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.Grey.Object can't be greater %f",MAX_VISIBILITY_DISTANCE); m_VisibleObjectGreyDistance = MAX_VISIBILITY_DISTANCE; } m_MaxVisibleDistanceForCreature = sConfig.GetFloatDefault("Visibility.Distance.Creature", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceForCreature < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceForCreature < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) { sLog.outError("Visibility.Distance.Creature can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); m_MaxVisibleDistanceForCreature = 45*sWorld.getRate(RATE_CREATURE_AGGRO); } - else if(m_MaxVisibleDistanceForCreature + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + else if (m_MaxVisibleDistanceForCreature + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outString("Visibility. Distance .Creature can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceForCreature = MAX_VISIBILITY_DISTANCE-m_VisibleUnitGreyDistance; } m_MaxVisibleDistanceForPlayer = sConfig.GetFloatDefault("Visibility.Distance.Player", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceForPlayer < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceForPlayer < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) { sLog.outError("Visibility.Distance.Player can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); m_MaxVisibleDistanceForPlayer = 45*sWorld.getRate(RATE_CREATURE_AGGRO); } - else if(m_MaxVisibleDistanceForPlayer + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + else if (m_MaxVisibleDistanceForPlayer + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outString("Visibility.Distance.Player can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceForPlayer = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; @@ -1091,37 +1091,37 @@ void World::LoadConfigSettings(bool reload) m_MaxVisibleDistance = std::max(m_MaxVisibleDistanceForPlayer, m_MaxVisibleDistanceForCreature); m_MaxVisibleDistanceForObject = sConfig.GetFloatDefault("Visibility.Distance.Object", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceForObject < INTERACTION_DISTANCE) + if (m_MaxVisibleDistanceForObject < INTERACTION_DISTANCE) { sLog.outError("Visibility.Distance.Object can't be less max aggro radius %f",float(INTERACTION_DISTANCE)); m_MaxVisibleDistanceForObject = INTERACTION_DISTANCE; } - else if(m_MaxVisibleDistanceForObject + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + else if (m_MaxVisibleDistanceForObject + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outString("Visibility.Distance.Object can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); m_MaxVisibleDistanceForObject = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; } - if(m_MaxVisibleDistance < m_MaxVisibleDistanceForObject) + if (m_MaxVisibleDistance < m_MaxVisibleDistanceForObject) m_MaxVisibleDistance = m_MaxVisibleDistanceForObject; m_MaxVisibleDistanceInFlight = sConfig.GetFloatDefault("Visibility.Distance.InFlight", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + if (m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outString("Visibility.Distance.InFlight can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); m_MaxVisibleDistanceInFlight = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; } - if(m_MaxVisibleDistance < m_MaxVisibleDistanceInFlight) + if (m_MaxVisibleDistance < m_MaxVisibleDistanceInFlight) m_MaxVisibleDistance = m_MaxVisibleDistanceInFlight; m_MaxVisibleDistance += 1.0f; ///- Read the "Data" directory from the config file std::string dataPath = sConfig.GetStringDefault("DataDir","./"); - if( dataPath.at(dataPath.length()-1)!='/' && dataPath.at(dataPath.length()-1)!='\\' ) + if (dataPath.at(dataPath.length()-1)!='/' && dataPath.at(dataPath.length()-1)!='\\') dataPath.append("/"); - if(reload) + if (reload) { - if(dataPath!=m_dataPath) + if (dataPath!=m_dataPath) sLog.outError("DataDir option can't be changed at Trinityd.conf reload, using current value (%s).",m_dataPath.c_str()); } else @@ -1138,9 +1138,9 @@ void World::LoadConfigSettings(bool reload) VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight); VMAP::VMapFactory::createOrGetVMapManager()->preventMapsFromBeingUsed(ignoreMapIds.c_str()); VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); - sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight); - sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); - sLog.outString( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds"); + sLog.outString("WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight); + sLog.outString("WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); + sLog.outString("WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds"); m_configs[CONFIG_MAX_WHO] = sConfig.GetIntDefault("MaxWhoListReturns", 49); @@ -1148,7 +1148,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_BG_START_MUSIC] = sConfig.GetBoolDefault("MusicInBattleground", false); m_configs[CONFIG_START_ALL_SPELLS] = sConfig.GetBoolDefault("PlayerStart.AllSpells", false); m_configs[CONFIG_HONOR_AFTER_DUEL] = sConfig.GetIntDefault("HonorPointsAfterDuel", 0); - if(m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) + if (m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) m_configs[CONFIG_HONOR_AFTER_DUEL]= 0; m_configs[CONFIG_START_ALL_EXPLORED] = sConfig.GetBoolDefault("PlayerStart.MapsExplored", false); m_configs[CONFIG_START_ALL_REP] = sConfig.GetBoolDefault("PlayerStart.AllReputation", false); @@ -1157,7 +1157,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = sConfig.GetIntDefault("PvPToken.MapAllowType", 4); m_configs[CONFIG_PVP_TOKEN_ID] = sConfig.GetIntDefault("PvPToken.ItemID", 29434); m_configs[CONFIG_PVP_TOKEN_COUNT] = sConfig.GetIntDefault("PvPToken.ItemCount", 1); - if(m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) + if (m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) m_configs[CONFIG_PVP_TOKEN_COUNT] = 1; m_configs[CONFIG_OUTDOORPVP_WINTERGRASP_START_TIME] = sConfig.GetIntDefault("OutdoorPvP.Wintergrasp.StartTime", 30); m_configs[CONFIG_OUTDOORPVP_WINTERGRASP_BATTLE_TIME] = sConfig.GetIntDefault("OutdoorPvP.Wintergrasp.BattleTime", 30); @@ -1216,7 +1216,7 @@ void World::SetInitialWorldSettings() objmgr.SetHighestGuids(); ///- Check the existence of the map files for all races' startup areas. - if( !MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f) + if (!MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f) ||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) ||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) ||!MapManager::ExistMapAndVMap(1,-618.518f,-4251.67f) @@ -1224,7 +1224,7 @@ void World::SetInitialWorldSettings() ||!MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f) ||!MapManager::ExistMapAndVMap(1,-2917.58f,-257.98f) ||m_configs[CONFIG_EXPANSION] && ( - !MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f) ) ) + !MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f))) { sLog.outError("Correct *.map files not found in path '%smaps' or *.vmap/*vmdir files in '%svmaps'. Please place *.map/*.vmap/*.vmdir files in appropriate directories or correct the DataDir value in the Trinityd.conf file.",m_dataPath.c_str(),m_dataPath.c_str()); exit(1); @@ -1232,7 +1232,7 @@ void World::SetInitialWorldSettings() ///- Loading strings. Getting no records means core load has to be canceled because no error message can be output. sLog.outString(); - sLog.outString( "Loading Trinity strings..." ); + sLog.outString("Loading Trinity strings..."); if (!objmgr.LoadTrinityStrings()) exit(1); // Error message displayed in function already @@ -1252,24 +1252,24 @@ void World::SetInitialWorldSettings() LoadDBCStores(m_dataPath); DetectDBCLang(); - sLog.outString( "Loading Script Names..."); + sLog.outString("Loading Script Names..."); objmgr.LoadScriptNames(); - sLog.outString( "Loading InstanceTemplate..." ); + sLog.outString("Loading InstanceTemplate..."); objmgr.LoadInstanceTemplate(); - sLog.outString( "Loading SkillLineAbilityMultiMap Data..." ); + sLog.outString("Loading SkillLineAbilityMultiMap Data..."); spellmgr.LoadSkillLineAbilityMap(); ///- Clean up and pack instances - sLog.outString( "Cleaning up instances..." ); + sLog.outString("Cleaning up instances..."); sInstanceSaveManager.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables - sLog.outString( "Packing instances..." ); + sLog.outString("Packing instances..."); sInstanceSaveManager.PackInstances(); sLog.outString(); - sLog.outString( "Loading Localization strings..." ); + sLog.outString("Loading Localization strings..."); objmgr.LoadCreatureLocales(); objmgr.LoadGameObjectLocales(); objmgr.LoadItemLocales(); @@ -1279,205 +1279,205 @@ void World::SetInitialWorldSettings() objmgr.LoadNpcOptionLocales(); objmgr.LoadPointOfInterestLocales(); objmgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts) - sLog.outString( ">>> Localization strings loaded" ); + sLog.outString(">>> Localization strings loaded"); sLog.outString(); - sLog.outString( "Loading Page Texts..." ); + sLog.outString("Loading Page Texts..."); objmgr.LoadPageTexts(); - sLog.outString( "Loading Player info in cache..." ); + sLog.outString("Loading Player info in cache..."); objmgr.LoadPlayerInfoInCache(); - sLog.outString( "Loading Game Object Templates..." ); // must be after LoadPageTexts + sLog.outString("Loading Game Object Templates..."); // must be after LoadPageTexts objmgr.LoadGameobjectInfo(); - sLog.outString( "Loading Spell Chain Data..." ); + sLog.outString("Loading Spell Chain Data..."); spellmgr.LoadSpellChains(); - sLog.outString( "Loading Spell Required Data..." ); + sLog.outString("Loading Spell Required Data..."); spellmgr.LoadSpellRequired(); - sLog.outString( "Loading Spell Elixir types..." ); + sLog.outString("Loading Spell Elixir types..."); spellmgr.LoadSpellElixirs(); - sLog.outString( "Loading Spell Learn Skills..." ); + sLog.outString("Loading Spell Learn Skills..."); spellmgr.LoadSpellLearnSkills(); // must be after LoadSpellChains - sLog.outString( "Loading Spell Learn Spells..." ); + sLog.outString("Loading Spell Learn Spells..."); spellmgr.LoadSpellLearnSpells(); - sLog.outString( "Loading Spell Proc Event conditions..." ); + sLog.outString("Loading Spell Proc Event conditions..."); spellmgr.LoadSpellProcEvents(); - sLog.outString( "Loading Spell Bonus Data..." ); + sLog.outString("Loading Spell Bonus Data..."); spellmgr.LoadSpellBonusess(); - sLog.outString( "Loading Aggro Spells Definitions..."); + sLog.outString("Loading Aggro Spells Definitions..."); spellmgr.LoadSpellThreats(); - sLog.outString( "Loading NPC Texts..." ); + sLog.outString("Loading NPC Texts..."); objmgr.LoadGossipText(); - sLog.outString( "Loading Enchant Spells Proc datas..."); + sLog.outString("Loading Enchant Spells Proc datas..."); spellmgr.LoadSpellEnchantProcData(); - sLog.outString( "Loading Item Random Enchantments Table..." ); + sLog.outString("Loading Item Random Enchantments Table..."); LoadRandomEnchantmentsTable(); - sLog.outString( "Loading Items..." ); // must be after LoadRandomEnchantmentsTable and LoadPageTexts + sLog.outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts objmgr.LoadItemPrototypes(); - sLog.outString( "Loading Item Texts..." ); + sLog.outString("Loading Item Texts..."); objmgr.LoadItemTexts(); - sLog.outString( "Loading Creature Model Based Info Data..." ); + sLog.outString("Loading Creature Model Based Info Data..."); objmgr.LoadCreatureModelInfo(); - sLog.outString( "Loading Equipment templates..."); + sLog.outString("Loading Equipment templates..."); objmgr.LoadEquipmentTemplates(); - sLog.outString( "Loading Creature templates..." ); + sLog.outString("Loading Creature templates..."); objmgr.LoadCreatureTemplates(); - sLog.outString( "Loading SpellsScriptTarget..."); + sLog.outString("Loading SpellsScriptTarget..."); spellmgr.LoadSpellScriptTarget(); // must be after LoadCreatureTemplates and LoadGameobjectInfo - sLog.outString( "Loading ItemRequiredTarget..."); + sLog.outString("Loading ItemRequiredTarget..."); objmgr.LoadItemRequiredTarget(); - sLog.outString( "Loading Creature Reputation OnKill Data..." ); + sLog.outString("Loading Creature Reputation OnKill Data..."); objmgr.LoadReputationOnKill(); - sLog.outString( "Loading Points Of Interest Data..." ); + sLog.outString("Loading Points Of Interest Data..."); objmgr.LoadPointsOfInterest(); - sLog.outString( "Loading Creature Data..." ); + sLog.outString("Loading Creature Data..."); objmgr.LoadCreatures(); - sLog.outString( "Loading Creature Linked Respawn..." ); + sLog.outString("Loading Creature Linked Respawn..."); objmgr.LoadCreatureLinkedRespawn(); // must be after LoadCreatures() - sLog.outString( "Loading pet levelup spells..." ); + sLog.outString("Loading pet levelup spells..."); spellmgr.LoadPetLevelupSpellMap(); - sLog.outString( "Loading pet default spell additional to levelup spells..." ); + sLog.outString("Loading pet default spell additional to levelup spells..."); spellmgr.LoadPetDefaultSpells(); - sLog.outString( "Loading Creature Addon Data..." ); + sLog.outString("Loading Creature Addon Data..."); sLog.outString(); objmgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures() - sLog.outString( ">>> Creature Addon Data loaded" ); + sLog.outString(">>> Creature Addon Data loaded"); sLog.outString(); - sLog.outString( "Loading Creature Respawn Data..." ); // must be after PackInstances() + sLog.outString("Loading Creature Respawn Data..."); // must be after PackInstances() objmgr.LoadCreatureRespawnTimes(); - sLog.outString( "Loading Gameobject Data..." ); + sLog.outString("Loading Gameobject Data..."); objmgr.LoadGameobjects(); - sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after PackInstances() + sLog.outString("Loading Gameobject Respawn Data..."); // must be after PackInstances() objmgr.LoadGameobjectRespawnTimes(); - sLog.outString( "Loading Objects Pooling Data..."); + sLog.outString("Loading Objects Pooling Data..."); poolhandler.LoadFromDB(); - sLog.outString( "Loading Game Event Data..."); + sLog.outString("Loading Game Event Data..."); sLog.outString(); gameeventmgr.LoadFromDB(); - sLog.outString( ">>> Game Event Data loaded" ); + sLog.outString(">>> Game Event Data loaded"); sLog.outString(); - sLog.outString( "Loading Weather Data..." ); + sLog.outString("Loading Weather Data..."); objmgr.LoadWeatherZoneChances(); - sLog.outString( "Loading Quests..." ); + sLog.outString("Loading Quests..."); objmgr.LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables - sLog.outString( "Loading Quests Relations..." ); + sLog.outString("Loading Quests Relations..."); sLog.outString(); objmgr.LoadQuestRelations(); // must be after quest load - sLog.outString( ">>> Quests Relations loaded" ); + sLog.outString(">>> Quests Relations loaded"); sLog.outString(); - sLog.outString( "Loading UNIT_NPC_FLAG_SPELLCLICK Data..." ); + sLog.outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data..."); objmgr.LoadNPCSpellClickSpells(); - sLog.outString( "Loading SpellArea Data..." ); // must be after quest load + sLog.outString("Loading SpellArea Data..."); // must be after quest load spellmgr.LoadSpellAreas(); - sLog.outString( "Loading AreaTrigger definitions..." ); + sLog.outString("Loading AreaTrigger definitions..."); objmgr.LoadAreaTriggerTeleports(); - sLog.outString( "Loading Access Requirements..." ); + sLog.outString("Loading Access Requirements..."); objmgr.LoadAccessRequirements(); // must be after item template load - sLog.outString( "Loading Quest Area Triggers..." ); + sLog.outString("Loading Quest Area Triggers..."); objmgr.LoadQuestAreaTriggers(); // must be after LoadQuests - sLog.outString( "Loading Tavern Area Triggers..." ); + sLog.outString("Loading Tavern Area Triggers..."); objmgr.LoadTavernAreaTriggers(); - sLog.outString( "Loading AreaTrigger script names..." ); + sLog.outString("Loading AreaTrigger script names..."); objmgr.LoadAreaTriggerScripts(); - sLog.outString( "Loading Graveyard-zone links..."); + sLog.outString("Loading Graveyard-zone links..."); objmgr.LoadGraveyardZones(); - sLog.outString( "Loading Spell target coordinates..." ); + sLog.outString("Loading Spell target coordinates..."); spellmgr.LoadSpellTargetPositions(); - sLog.outString( "Loading spell pet auras..." ); + sLog.outString("Loading spell pet auras..."); spellmgr.LoadSpellPetAuras(); - sLog.outString( "Loading spell extra attributes...(TODO)" ); + sLog.outString("Loading spell extra attributes...(TODO)"); spellmgr.LoadSpellCustomAttr(); - sLog.outString( "Loading enchant custom attributes..." ); + sLog.outString("Loading enchant custom attributes..."); spellmgr.LoadEnchantCustomAttr(); - sLog.outString( "Loading linked spells..." ); + sLog.outString("Loading linked spells..."); spellmgr.LoadSpellLinked(); - sLog.outString( "Loading Player Create Info & Level Stats..." ); + sLog.outString("Loading Player Create Info & Level Stats..."); sLog.outString(); objmgr.LoadPlayerInfo(); - sLog.outString( ">>> Player Create Info & Level Stats loaded" ); + sLog.outString(">>> Player Create Info & Level Stats loaded"); sLog.outString(); - sLog.outString( "Loading Exploration BaseXP Data..." ); + sLog.outString("Loading Exploration BaseXP Data..."); objmgr.LoadExplorationBaseXP(); - sLog.outString( "Loading Pet Name Parts..." ); + sLog.outString("Loading Pet Name Parts..."); objmgr.LoadPetNames(); - sLog.outString( "Loading the max pet number..." ); + sLog.outString("Loading the max pet number..."); objmgr.LoadPetNumber(); - sLog.outString( "Loading pet level stats..." ); + sLog.outString("Loading pet level stats..."); objmgr.LoadPetLevelInfo(); - sLog.outString( "Loading Player Corpses..." ); + sLog.outString("Loading Player Corpses..."); objmgr.LoadCorpses(); - sLog.outString( "Loading Disabled Spells..." ); + sLog.outString("Loading Disabled Spells..."); objmgr.LoadSpellDisabledEntrys(); - sLog.outString( "Loading Loot Tables..." ); + sLog.outString("Loading Loot Tables..."); sLog.outString(); LoadLootTables(); - sLog.outString( ">>> Loot Tables loaded" ); + sLog.outString(">>> Loot Tables loaded"); sLog.outString(); - sLog.outString( "Loading Skill Discovery Table..." ); + sLog.outString("Loading Skill Discovery Table..."); LoadSkillDiscoveryTable(); - sLog.outString( "Loading Skill Extra Item Table..." ); + sLog.outString("Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); - sLog.outString( "Loading Skill Fishing base level requirements..." ); + sLog.outString("Loading Skill Fishing base level requirements..."); objmgr.LoadFishingBaseSkillLevel(); - sLog.outString( "Loading Achievements..." ); + sLog.outString("Loading Achievements..."); sLog.outString(); achievementmgr.LoadAchievementReferenceList(); achievementmgr.LoadAchievementCriteriaList(); @@ -1485,69 +1485,69 @@ void World::SetInitialWorldSettings() achievementmgr.LoadRewards(); achievementmgr.LoadRewardLocales(); achievementmgr.LoadCompletedAchievements(); - sLog.outString( ">>> Achievements loaded" ); + sLog.outString(">>> Achievements loaded"); sLog.outString(); ///- Load dynamic data tables from the database - sLog.outString( "Loading Auctions..." ); + sLog.outString("Loading Auctions..."); sLog.outString(); auctionmgr.LoadAuctionItems(); auctionmgr.LoadAuctions(); - sLog.outString( ">>> Auctions loaded" ); + sLog.outString(">>> Auctions loaded"); sLog.outString(); - sLog.outString( "Loading Guilds..." ); + sLog.outString("Loading Guilds..."); objmgr.LoadGuilds(); - sLog.outString( "Loading ArenaTeams..." ); + sLog.outString("Loading ArenaTeams..."); objmgr.LoadArenaTeams(); - sLog.outString( "Loading Groups..." ); + sLog.outString("Loading Groups..."); objmgr.LoadGroups(); - sLog.outString( "Loading ReservedNames..." ); + sLog.outString("Loading ReservedNames..."); objmgr.LoadReservedPlayersNames(); - sLog.outString( "Loading GameObjects for quests..." ); + sLog.outString("Loading GameObjects for quests..."); objmgr.LoadGameObjectForQuests(); - sLog.outString( "Loading BattleMasters..." ); + sLog.outString("Loading BattleMasters..."); sBattleGroundMgr.LoadBattleMastersEntry(); - sLog.outString( "Loading GameTeleports..." ); + sLog.outString("Loading GameTeleports..."); objmgr.LoadGameTele(); - sLog.outString( "Loading Npc Text Id..." ); + sLog.outString("Loading Npc Text Id..."); objmgr.LoadNpcTextId(); // must be after load Creature and NpcText - sLog.outString( "Loading Npc Options..." ); + sLog.outString("Loading Npc Options..."); objmgr.LoadNpcOptions(); - sLog.outString( "Loading Vendors..." ); + sLog.outString("Loading Vendors..."); objmgr.LoadVendors(); // must be after load CreatureTemplate and ItemTemplate - sLog.outString( "Loading Trainers..." ); + sLog.outString("Loading Trainers..."); objmgr.LoadTrainerSpell(); // must be after load CreatureTemplate - sLog.outString( "Loading Waypoints..." ); + sLog.outString("Loading Waypoints..."); sLog.outString(); WaypointMgr.Load(); - sLog.outString( "Loading Creature Formations..." ); + sLog.outString("Loading Creature Formations..."); formation_mgr.LoadCreatureFormations(); - sLog.outString( "Loading GM tickets..."); + sLog.outString("Loading GM tickets..."); objmgr.LoadGMTickets(); ///- Handle outdated emails (delete/return) - sLog.outString( "Returning old mails..." ); + sLog.outString("Returning old mails..."); objmgr.ReturnOrDeleteOldMails(false); sLog.outString("Loading Autobroadcasts..."); LoadAutobroadcasts(); ///- Load and initialize scripts - sLog.outString( "Loading Scripts..." ); + sLog.outString("Loading Scripts..."); sLog.outString(); objmgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate objmgr.LoadQuestEndScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate @@ -1555,30 +1555,30 @@ void World::SetInitialWorldSettings() objmgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data) objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) objmgr.LoadWaypointScripts(); - sLog.outString( ">>> Scripts loaded" ); + sLog.outString(">>> Scripts loaded"); sLog.outString(); - sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls + sLog.outString("Loading Scripts text locales..."); // must be after Load*Scripts calls objmgr.LoadDbScriptStrings(); - sLog.outString( "Loading CreatureEventAI Texts..."); + sLog.outString("Loading CreatureEventAI Texts..."); CreatureEAI_Mgr.LoadCreatureEventAI_Texts(); - sLog.outString( "Loading CreatureEventAI Summons..."); + sLog.outString("Loading CreatureEventAI Summons..."); CreatureEAI_Mgr.LoadCreatureEventAI_Summons(); - sLog.outString( "Loading CreatureEventAI Scripts..."); + sLog.outString("Loading CreatureEventAI Scripts..."); CreatureEAI_Mgr.LoadCreatureEventAI_Scripts(); - sLog.outString( "Initializing Scripts..." ); - if(!LoadScriptingModule()) + sLog.outString("Initializing Scripts..."); + if (!LoadScriptingModule()) exit(1); /// Check db - if(m_configs[CONFIG_CHECK_DB]) + if (m_configs[CONFIG_CHECK_DB]) { - sLog.outString( "Checking DB..." ); - if(!objmgr.CheckDB() || !spellmgr.CheckDB()) + sLog.outString("Checking DB..."); + if (!objmgr.CheckDB() || !spellmgr.CheckDB()) { sLog.outError("Your world DB is outdated. Please reapply sqls in sql\\FULL folder, or disable CheckDB option in config file (not recommended)."); exit(1); @@ -1588,7 +1588,7 @@ void World::SetInitialWorldSettings() sLog.outError("You have disabled DB check. We strongly recommend you to enable it to prevent unpredictable bugs and crashes."); ///- Initialize game time and timers - sLog.outDebug( "DEBUG:: Initialize game time and timers" ); + sLog.outDebug("DEBUG:: Initialize game time and timers"); m_gameTime = time(NULL); m_startTime=m_gameTime; @@ -1597,7 +1597,7 @@ void World::SetInitialWorldSettings() time(&curr); local=*(localtime(&curr)); // dereference and assign char isoDate[128]; - sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d", + sprintf(isoDate, "%04d-%02d-%02d %02d:%02d:%02d", local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime, revision) VALUES('%u', " UI64FMTD ", '%s', 0, '%s')", @@ -1620,9 +1620,9 @@ void World::SetInitialWorldSettings() //to set mailtimer to return mails every day between 4 and 5 am //mailtimer is increased when updating auctions //one second is 1000 -(tested on win system) - mail_timer = ((((localtime( &m_gameTime )->tm_hour + 20) % 24)* HOUR * IN_MILISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval() ); + mail_timer = ((((localtime(&m_gameTime)->tm_hour + 20) % 24)* HOUR * IN_MILISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval()); //1440 - mail_timer_expires = ( (DAY * IN_MILISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); + mail_timer_expires = ((DAY * IN_MILISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); sLog.outDebug("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires); ///- Initilize static helper structures @@ -1630,36 +1630,36 @@ void World::SetInitialWorldSettings() Player::InitVisibleBits(); ///- Initialize MapManager - sLog.outString( "Starting Map System" ); + sLog.outString("Starting Map System"); MapManager::Instance().Initialize(); - sLog.outString("Starting Game Event system..." ); + sLog.outString("Starting Game Event system..."); uint32 nextGameEvent = gameeventmgr.Initialize(); m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event ///- Initialize Battlegrounds - sLog.outString( "Starting BattleGround System" ); + sLog.outString("Starting BattleGround System"); sBattleGroundMgr.CreateInitialBattleGrounds(); sBattleGroundMgr.InitAutomaticArenaPointDistribution(); ///- Initialize outdoor pvp - sLog.outString( "Starting Outdoor PvP System" ); + sLog.outString("Starting Outdoor PvP System"); sOutdoorPvPMgr.InitOutdoorPvP(); //Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager - sLog.outString( "Loading Transports..." ); + sLog.outString("Loading Transports..."); MapManager::Instance().LoadTransports(); - sLog.outString( "Loading Transports Events..." ); + sLog.outString("Loading Transports Events..."); objmgr.LoadTransportEvents(); - sLog.outString("Deleting expired bans..." ); + sLog.outString("Deleting expired bans..."); loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); - sLog.outString("Calculate next daily quest reset time..." ); + sLog.outString("Calculate next daily quest reset time..."); InitDailyQuestResetTime(); - sLog.outString("Starting objects Pooling system..." ); + sLog.outString("Starting objects Pooling system..."); poolhandler.Initialize(); sLog.outString("Initialize AuctionHouseBot..."); @@ -1678,14 +1678,14 @@ void World::SetInitialWorldSettings() sLog.SetLogDBLater(false); } - sLog.outString( "WORLD: World initialized" ); + sLog.outString("WORLD: World initialized"); } void World::DetectDBCLang() { uint32 m_lang_confid = sConfig.GetIntDefault("DBC.Locale", 255); - if(m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE) + if (m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE) { sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)",MAX_LOCALE); m_lang_confid = LOCALE_enUS; @@ -1698,7 +1698,7 @@ void World::DetectDBCLang() int default_locale = MAX_LOCALE; for (int i = MAX_LOCALE-1; i >= 0; --i) { - if ( strlen(race->name[i]) > 0) // check by race names + if (strlen(race->name[i]) > 0) // check by race names { default_locale = i; m_availableDbcLocaleMask |= (1 << i); @@ -1707,13 +1707,13 @@ void World::DetectDBCLang() } } - if( default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE && - (m_availableDbcLocaleMask & (1 << m_lang_confid)) ) + if (default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE && + (m_availableDbcLocaleMask & (1 << m_lang_confid))) { default_locale = m_lang_confid; } - if(default_locale >= MAX_LOCALE) + if (default_locale >= MAX_LOCALE) { sLog.outError("Unable to determine your DBC Locale! (corrupt DBC?)"); exit(1); @@ -1727,9 +1727,9 @@ void World::DetectDBCLang() void World::RecordTimeDiff(const char *text, ...) { - if(m_updateTimeCount != 1) + if (m_updateTimeCount != 1) return; - if(!text) + if (!text) { m_currentTime = getMSTime(); return; @@ -1738,12 +1738,12 @@ void World::RecordTimeDiff(const char *text, ...) uint32 thisTime = getMSTime(); uint32 diff = getMSTimeDiff(m_currentTime, thisTime); - if(diff > m_configs[CONFIG_MIN_LOG_UPDATE]) + if (diff > m_configs[CONFIG_MIN_LOG_UPDATE]) { va_list ap; char str [256]; va_start(ap, text); - vsnprintf(str,256,text, ap ); + vsnprintf(str,256,text, ap); va_end(ap); sLog.outDetail("Difftime %s: %u.", str, diff); } @@ -1757,13 +1757,13 @@ void World::LoadAutobroadcasts() QueryResult *result = WorldDatabase.Query("SELECT text FROM autobroadcast"); - if(!result) + if (!result) { barGoLink bar(1); bar.step(); sLog.outString(); - sLog.outString( ">> Loaded 0 autobroadcasts definitions"); + sLog.outString(">> Loaded 0 autobroadcasts definitions"); return; } @@ -1787,16 +1787,16 @@ void World::LoadAutobroadcasts() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u autobroadcasts definitions", count); + sLog.outString(">> Loaded %u autobroadcasts definitions", count); } /// Update the World ! void World::Update(uint32 diff) { m_updateTime = uint32(diff); - if(m_configs[CONFIG_INTERVAL_LOG_UPDATE]) + if (m_configs[CONFIG_INTERVAL_LOG_UPDATE]) { - if(m_updateTimeSum > m_configs[CONFIG_INTERVAL_LOG_UPDATE]) + if (m_updateTimeSum > m_configs[CONFIG_INTERVAL_LOG_UPDATE]) { sLog.outBasic("Update time diff: %u. Players online: %u.", m_updateTimeSum / m_updateTimeCount, GetActiveSessionCount()); m_updateTimeSum = m_updateTime; @@ -1810,8 +1810,8 @@ void World::Update(uint32 diff) } ///- Update the different timers - for(int i = 0; i < WUPDATE_COUNT; ++i) - if(m_timers[i].GetCurrent()>=0) + for (int i = 0; i < WUPDATE_COUNT; ++i) + if (m_timers[i].GetCurrent()>=0) m_timers[i].Update(diff); else m_timers[i].SetCurrent(0); @@ -1819,7 +1819,7 @@ void World::Update(uint32 diff) _UpdateGameTime(); /// Handle daily quests reset time - if(m_gameTime > m_NextDailyQuestReset) + if (m_gameTime > m_NextDailyQuestReset) { ResetDailyQuests(); m_NextDailyQuestReset += DAY; @@ -1862,7 +1862,7 @@ void World::Update(uint32 diff) ///- and remove Weather objects for zones with no player //As interval > WorldTick - if(!itr->second->Update(m_timers[WUPDATE_WEATHERS].GetInterval())) + if (!itr->second->Update(m_timers[WUPDATE_WEATHERS].GetInterval())) { delete itr->second; m_weathers.erase(itr); @@ -1880,7 +1880,7 @@ void World::Update(uint32 diff) } /// <li> Clean logs table - if(sWorld.getConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer + if (sWorld.getConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer { if (m_timers[WUPDATE_CLEANDB].Passed()) { @@ -1897,7 +1897,7 @@ void World::Update(uint32 diff) ///- Update objects when the timer has passed (maps, transport, creatures,...) MapManager::Instance().Update(diff); // As interval = 0 - /*if(m_timers[WUPDATE_OBJECTS].Passed()) + /*if (m_timers[WUPDATE_OBJECTS].Passed()) { m_timers[WUPDATE_OBJECTS].Reset(); MapManager::Instance().DoDelayedMovesAndRemoves(); @@ -1905,7 +1905,7 @@ void World::Update(uint32 diff) static uint32 autobroadcaston = 0; autobroadcaston = sConfig.GetIntDefault("AutoBroadcast.On", 0); - if(autobroadcaston == 1) + if (autobroadcaston == 1) { if (m_timers[WUPDATE_AUTOBROADCAST].Passed()) { @@ -1968,7 +1968,7 @@ void World::SendGlobalMessage(WorldPacket *packet, WorldSession *self, uint32 te itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld() && itr->second != self && - (team == 0 || itr->second->GetPlayer()->GetTeam() == team) ) + (team == 0 || itr->second->GetPlayer()->GetTeam() == team)) { itr->second->SendPacket(packet); } @@ -1986,7 +1986,7 @@ void World::SendGlobalGMMessage(WorldPacket *packet, WorldSession *self, uint32 itr->second->GetPlayer()->IsInWorld() && itr->second != self && itr->second->GetSecurity() > SEC_PLAYER && - (team == 0 || itr->second->GetPlayer()->GetTeam() == team) ) + (team == 0 || itr->second->GetPlayer()->GetTeam() == team)) { itr->second->SendPacket(packet); } @@ -2004,14 +2004,14 @@ namespace MaNGOS { char const* text = objmgr.GetMangosString(i_textId,loc_idx); - if(i_args) + if (i_args) { // we need copy va_list before use or original va_list will corrupted va_list ap; va_copy(ap,*i_args); char str [2048]; - vsnprintf(str,2048,text, ap ); + vsnprintf(str,2048,text, ap); va_end(ap); do_helper(data_list,&str[0]); @@ -2058,9 +2058,9 @@ void World::SendWorldText(int32 string_id, ...) MaNGOS::WorldWorldTextBuilder wt_builder(string_id, &ap); MaNGOS::LocalizedPacketListDo<MaNGOS::WorldWorldTextBuilder> wt_do(wt_builder); - for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { - if(!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld() ) + if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld()) continue; wt_do(itr->second->GetPlayer()); @@ -2077,12 +2077,12 @@ void World::SendGMText(int32 string_id, ...) MaNGOS::WorldWorldTextBuilder wt_builder(string_id, &ap); MaNGOS::LocalizedPacketListDo<MaNGOS::WorldWorldTextBuilder> wt_do(wt_builder); - for(SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { - if(!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld() ) + if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld()) continue; - if(itr->second->GetSecurity() < SEC_MODERATOR ) + if (itr->second->GetSecurity() < SEC_MODERATOR) continue; wt_do(itr->second->GetPlayer()); @@ -2120,7 +2120,7 @@ void World::SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self itr->second->GetPlayer()->IsInWorld() && itr->second->GetPlayer()->GetZoneId() == zone && itr->second != self && - (team == 0 || itr->second->GetPlayer()->GetTeam() == team) ) + (team == 0 || itr->second->GetPlayer()->GetTeam() == team)) { itr->second->SendPacket(packet); } @@ -2150,7 +2150,7 @@ void World::KickAllLess(AccountTypes sec) { // session not removed at kick and will removed in next update tick for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - if(itr->second->GetSecurity() < sec) + if (itr->second->GetSecurity() < sec) itr->second->KickPlayer(); } @@ -2185,9 +2185,9 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura return BAN_SYNTAX_ERROR; } - if(!resultAccounts) + if (!resultAccounts) { - if(mode==BAN_IP) + if (mode==BAN_IP) return BAN_SUCCESS; // ip correctly banned but nobody affected (yet) else return BAN_NOTFOUND; // Nobody to ban @@ -2199,7 +2199,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura Field* fieldsAccount = resultAccounts->Fetch(); uint32 account = fieldsAccount->GetUInt32(); - if(mode!=BAN_IP) + if (mode!=BAN_IP) { //No SQL injection as strings are escaped loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", @@ -2207,10 +2207,10 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura } if (WorldSession* sess = FindSession(account)) - if(std::string(sess->GetPlayerName()) != author) + if (std::string(sess->GetPlayerName()) != author) sess->KickPlayer(); } - while( resultAccounts->NextRow() ); + while(resultAccounts->NextRow()); delete resultAccounts; return BAN_SUCCESS; @@ -2250,12 +2250,12 @@ void World::_UpdateGameTime() m_gameTime = thisTime; ///- if there is a shutdown timer - if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) + if (!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) { ///- ... and it is overdue, stop the world (set m_stopEvent) - if( m_ShutdownTimer <= elapsed ) + if (m_ShutdownTimer <= elapsed) { - if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + if (!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; // minimum timer value to wait idle state @@ -2274,16 +2274,16 @@ void World::_UpdateGameTime() void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) { // ignore if server shutdown at next tick - if(m_stopEvent) + if (m_stopEvent) return; m_ShutdownMask = options; m_ExitCode = exitcode; ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) - if(time==0) + if (time==0) { - if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick @@ -2300,22 +2300,22 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) void World::ShutdownMsg(bool show, Player* player) { // not show messages for idle shutdown mode - if(m_ShutdownMask & SHUTDOWN_MASK_IDLE) + if (m_ShutdownMask & SHUTDOWN_MASK_IDLE) return; ///- Display a message every 12 hours, hours, 5 minutes, minute, 5 seconds and finally seconds - if ( show || + if (show || (m_ShutdownTimer < 10) || // < 30 sec; every 5 sec - (m_ShutdownTimer<30 && (m_ShutdownTimer % 5 )==0) || + (m_ShutdownTimer<30 && (m_ShutdownTimer % 5)==0) || // < 5 min ; every 1 min - (m_ShutdownTimer<5*MINUTE && (m_ShutdownTimer % MINUTE )==0) || + (m_ShutdownTimer<5*MINUTE && (m_ShutdownTimer % MINUTE)==0) || // < 30 min ; every 5 min (m_ShutdownTimer<30*MINUTE && (m_ShutdownTimer % (5*MINUTE))==0) || // < 12 h ; every 1 h - (m_ShutdownTimer<12*HOUR && (m_ShutdownTimer % HOUR )==0) || + (m_ShutdownTimer<12*HOUR && (m_ShutdownTimer % HOUR)==0) || // > 12 h ; every 12 h - (m_ShutdownTimer>12*HOUR && (m_ShutdownTimer % (12*HOUR) )==0)) + (m_ShutdownTimer>12*HOUR && (m_ShutdownTimer % (12*HOUR))==0)) { std::string str = secsToTimeString(m_ShutdownTimer); @@ -2330,7 +2330,7 @@ void World::ShutdownMsg(bool show, Player* player) void World::ShutdownCancel() { // nothing cancel or too later - if(!m_ShutdownTimer || m_stopEvent) + if (!m_ShutdownTimer || m_stopEvent) return; ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED; @@ -2348,16 +2348,16 @@ void World::SendServerMessage(ServerMessageType type, const char *text, Player* { WorldPacket data(SMSG_SERVER_MESSAGE, 50); // guess size data << uint32(type); - if(type <= SERVER_MSG_STRING) + if (type <= SERVER_MSG_STRING) data << text; - if(player) + if (player) player->GetSession()->SendPacket(&data); else - SendGlobalMessage( &data ); + SendGlobalMessage(&data); } -void World::UpdateSessions( uint32 diff ) +void World::UpdateSessions(uint32 diff) { ///- Add new sessions WorldSession* sess; @@ -2370,13 +2370,13 @@ void World::UpdateSessions( uint32 diff ) next = itr; ++next; - if(!itr->second) + if (!itr->second) continue; ///- and remove not active sessions from the list - if(!itr->second->Update(diff)) // As interval = 0 + if (!itr->second->Update(diff)) // As interval = 0 { - if(!RemoveQueuedPlayer(itr->second) && itr->second && getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) + if (!RemoveQueuedPlayer(itr->second) && itr->second && getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) m_disconnects[itr->second->GetAccountId()] = time(NULL); delete itr->second; m_sessions.erase(itr); @@ -2405,7 +2405,7 @@ void World::ProcessCliCommands() void World::SendRNDBroadcast() { - if(m_Autobroadcasts.empty()) + if (m_Autobroadcasts.empty()) return; std::string msg; @@ -2416,13 +2416,13 @@ void World::SendRNDBroadcast() static uint32 abcenter = 0; abcenter = sConfig.GetIntDefault("AutoBroadcast.Center", 0); - if(abcenter == 0) + if (abcenter == 0) { sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str()); sLog.outString("AutoBroadcast: '%s'",msg.c_str()); } - if(abcenter == 1) + if (abcenter == 1) { WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1)); data << msg; @@ -2430,7 +2430,7 @@ void World::SendRNDBroadcast() sLog.outString("AutoBroadcast: '%s'",msg.c_str()); } - if(abcenter == 2) + if (abcenter == 2) { sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str()); @@ -2476,7 +2476,7 @@ void World::InitDailyQuestResetTime() time_t mostRecentQuestTime; QueryResult* result = CharacterDatabase.Query("SELECT MAX(time) FROM character_queststatus_daily"); - if(result) + if (result) { Field *fields = result->Fetch(); @@ -2501,7 +2501,7 @@ void World::InitDailyQuestResetTime() time_t resetTime = (curTime < curDayResetTime) ? curDayResetTime - DAY : curDayResetTime; // need reset (if we have quest time before last reset time (not processed by some reason) - if(mostRecentQuestTime && mostRecentQuestTime <= resetTime) + if (mostRecentQuestTime && mostRecentQuestTime <= resetTime) m_NextDailyQuestReset = mostRecentQuestTime; else { @@ -2514,8 +2514,8 @@ void World::ResetDailyQuests() { sLog.outDetail("Daily quests reset for all characters."); CharacterDatabase.Execute("DELETE FROM character_queststatus_daily"); - for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - if(itr->second->GetPlayer()) + for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + if (itr->second->GetPlayer()) itr->second->GetPlayer()->ResetDailyQuestStatus(); } @@ -2530,7 +2530,7 @@ void World::UpdateAllowedSecurity() } } -void World::SetPlayerLimit( int32 limit, bool needUpdate ) +void World::SetPlayerLimit(int32 limit, bool needUpdate) { m_playerLimit = limit; } @@ -2545,7 +2545,7 @@ void World::LoadDBVersion() { QueryResult* result = WorldDatabase.Query("SELECT db_version, script_version, cache_id FROM version LIMIT 1"); //QueryResult* result = WorldDatabase.Query("SELECT version, creature_ai_version, cache_id FROM db_version LIMIT 1"); - if(result) + if (result) { Field* fields = result->Fetch(); @@ -2557,9 +2557,9 @@ void World::LoadDBVersion() delete result; } - if(m_DBVersion.empty()) + if (m_DBVersion.empty()) m_DBVersion = "Unknown world database."; - if(m_CreatureEventAIVersion.empty()) + if (m_CreatureEventAIVersion.empty()) m_CreatureEventAIVersion = "Unknown creature EventAI."; } |