diff options
Diffstat (limited to 'src')
68 files changed, 2729 insertions, 1775 deletions
diff --git a/src/bindings/scripts/scripts/npc/npcs_special.cpp b/src/bindings/scripts/scripts/npc/npcs_special.cpp index 3a113b8fae6..dd043c73494 100644 --- a/src/bindings/scripts/scripts/npc/npcs_special.cpp +++ b/src/bindings/scripts/scripts/npc/npcs_special.cpp @@ -905,7 +905,7 @@ struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI if (apply) { // Initialize the action bar without the melee attack command - m_creature->InitCharmInfo(m_creature); + m_creature->InitCharmInfo(); m_creature->GetCharmInfo()->InitEmptyActionBar(false); m_creature->SetReactState(REACT_PASSIVE); diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp index 16fff2fac02..3abde8c307f 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp @@ -111,6 +111,9 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI PhaseChangeTimer = 60000; Phase1 = true; + + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, false); } void Aggro(Unit *who) @@ -292,6 +295,8 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI if(DoGetThreat(target)) DoModifyThreatPercent(target, -100); m_creature->AddThreat(target, 50000000.0f); + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); // If VMaps are disabled, this spell can call the whole instance DoCast(m_creature, SPELL_INSIGNIFIGANCE, true); DoCast(target, SPELL_FEL_RAGE_TARGET, true); @@ -325,6 +330,8 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI FelAcidTimer += 2000; EjectTimer += 2000; PhaseChangeTimer = 60000; + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, false); } }else PhaseChangeTimer -= diff; diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp index ac6d1091c60..3ae719effaf 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp @@ -91,6 +91,9 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI Phase1 = true; summons.DespawnAll(); + + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, false); } void Aggro(Unit *who) @@ -212,6 +215,8 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI PhaseSwitchTimer = 60000; m_creature->SetSpeed(MOVE_RUN, 1.2f); DoZoneInCombat(); + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, false); } else { @@ -222,6 +227,8 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI PhaseSwitchTimer = 60000; m_creature->SetSpeed(MOVE_RUN, 0.9f); DoZoneInCombat(); + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); } }else PhaseSwitchTimer -= diff; diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp index 8d6686bb56b..16628cce685 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp @@ -54,7 +54,7 @@ CreatureAI* GetAI_npc_jaina_proudmoore(Creature *_Creature) ai->Spell[0].TargetType = TARGETTYPE_RANDOM; ai->Spell[1].SpellId = SPELL_PYROBLAST; - ai->Spell[1].Cooldown = 2000 + rand()%7000; + ai->Spell[1].Cooldown = 5500 + rand()%4000; ai->Spell[1].TargetType = TARGETTYPE_RANDOM; ai->Spell[2].SpellId = SPELL_SUMMON_ELEMENTALS; diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp index 8ed47127e16..f2c683ac4bf 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp @@ -114,8 +114,7 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); m_creature->setActive(true); - pInstance->SetData(DATA_NIGHTBANE_EVENT, 6); - if(pInstance->GetData(DATA_NIGHTBANE_EVENT) > 1) + if(pInstance->GetData(DATA_NIGHTBANE_EVENT) == DONE || pInstance->GetData(DATA_NIGHTBANE_EVENT) == IN_PROGRESS) { m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); m_creature->RemoveCorpse(); diff --git a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp index f274e81b5c4..c43d5f69590 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp @@ -64,9 +64,6 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance uint64 MastersTerraceDoor[2]; uint64 ImageGUID; - uint8 Nightbane; - bool CheckNightbane; - void Initialize() { for (uint8 i = 0; i < ENCOUNTERS; ++i) @@ -91,10 +88,6 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance MastersTerraceDoor[0]= 0; MastersTerraceDoor[1]= 0; ImageGUID = 0; - - Nightbane = 0; - - CheckNightbane = false; } bool IsEncounterInProgress() const @@ -121,12 +114,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance case DATA_NETHERSPITE_EVENT: return Encounters[8]; case DATA_CHESS_EVENT: return Encounters[9]; case DATA_MALCHEZZAR_EVENT: return Encounters[10]; - case DATA_NIGHTBANE_EVENT: - if(CheckNightbane) - { - CheckNightbane = false; - return Nightbane; - }else return Encounters[11]; + case DATA_NIGHTBANE_EVENT: return Encounters[11]; case DATA_OPERA_PERFORMANCE: return OperaEvent; case DATA_OPERA_OZ_DEATHCOUNT: return OzDeathCount; case DATA_IMAGE_OF_MEDIVH: return ImageGUID; @@ -187,11 +175,9 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance case DATA_CHESS_EVENT: Encounters[9] = data; break; case DATA_MALCHEZZAR_EVENT: Encounters[10] = data; break; case DATA_NIGHTBANE_EVENT: - if(data == 6) - { - Nightbane; - CheckNightbane = true; - }else Encounters[11] = data; + if (Encounters[11] == DONE) + break; + Encounters[11] = data; break; case DATA_OPERA_OZ_DEATHCOUNT: ++OzDeathCount; break; } @@ -244,7 +230,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance std::ostringstream stream; stream << Encounters[0] << " " << Encounters[1] << " " << Encounters[2] << " " << Encounters[3] << " " << Encounters[4] << " " << Encounters[5] << " " << Encounters[6] << " " << Encounters[7] << " " - << Encounters[8] << " " << Encounters[9] << " " << Encounters[10]; + << Encounters[8] << " " << Encounters[9] << " " << Encounters[10] << " " << Encounters[11]; char* out = new char[stream.str().length() + 1]; strcpy(out, stream.str().c_str()); if(out) @@ -268,7 +254,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance std::istringstream stream(in); stream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3] >> Encounters[4] >> Encounters[5] >> Encounters[6] >> Encounters[7] - >> Encounters[8] >> Encounters[9] >> Encounters[10]; + >> Encounters[8] >> Encounters[9] >> Encounters[10] >> Encounters[11]; for(uint8 i = 0; i < ENCOUNTERS; ++i) if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead. Encounters[i] = NOT_STARTED; diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp index 93b653a344c..4fecea70363 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp @@ -201,9 +201,6 @@ struct TRINITY_DLL_DECL mob_ragin_flamesAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if (!UpdateVictim()) - return; - //Check_Timer if(Check_Timer < diff) { @@ -219,6 +216,9 @@ struct TRINITY_DLL_DECL mob_ragin_flamesAI : public ScriptedAI Check_Timer = 1000; }else Check_Timer -= diff; + if (!UpdateVictim()) + return; + if (!onlyonce) { if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0)) diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp index d2c62b89234..05866eb27fb 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp @@ -46,7 +46,8 @@ struct TRINITY_DLL_DECL instance_mechanar : public ScriptedInstance bool IsEncounterInProgress() const { for(uint8 i = 0; i < ENCOUNTERS; ++i) - if(Encounters[i]) return true; + if(Encounters[i] == IN_PROGRESS) + return true; return false; } diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index 06c4dde2ed3..326101d68dd 100644 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -60,16 +60,18 @@ class TRINITY_DLL_DECL Grid /** an object of interested enters the grid */ - template<class SPECIFIC_OBJECT> bool AddWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template<class SPECIFIC_OBJECT> void AddWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { - return i_objects.template insert<SPECIFIC_OBJECT>(hdl, obj); + if(!i_objects.template insert<SPECIFIC_OBJECT>(hdl, obj)) + assert(false); } /** an object of interested exits the grid */ - template<class SPECIFIC_OBJECT> bool RemoveWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { - return i_objects.template remove<SPECIFIC_OBJECT>(obj, hdl); + if(!i_objects.template remove<SPECIFIC_OBJECT>(obj, hdl)) + assert(false); } /** Accessors: Returns a specific type of object in the WORDL_OBJECT_TYPES @@ -114,20 +116,18 @@ class TRINITY_DLL_DECL Grid /** Inserts a container type object into the grid. */ - template<class SPECIFIC_OBJECT> bool AddGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { - //if(obj->isActiveObject()) - // m_activeGridObjects.insert(obj); - return i_container.template insert<SPECIFIC_OBJECT>(hdl, obj); + if(!i_container.template insert<SPECIFIC_OBJECT>(hdl, obj)) + assert(false); } /** Removes a containter type object from the grid */ - template<class SPECIFIC_OBJECT> bool RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { - //if(obj->isActiveObject()) - // m_activeGridObjects.erase(obj); - return i_container.template remove<SPECIFIC_OBJECT>(obj, hdl); + if(!i_container.template remove<SPECIFIC_OBJECT>(obj, hdl)) + assert(false); } /*bool NoWorldObjectInGrid() const diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp index bd3b51af4d2..cb3244ee456 100644 --- a/src/game/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot.cpp @@ -4,6 +4,7 @@ #include "Database/DatabaseEnv.h" #include "Item.h" #include "Log.h" +#include "AuctionHouseMgr.h" #include "ObjectMgr.h" #include "Player.h" #include "World.h" @@ -18,14 +19,20 @@ static bool debug_Out = sConfig.GetIntDefault("AuctionHouseBot.DEBUG", 0); static vector<uint32> npcItems; static vector<uint32> lootItems; -static vector<uint32> whiteTradeGoods; -static vector<uint32> greenTradeGoods; -static vector<uint32> blueTradeGoods; -static vector<uint32> purpleTradeGoods; -static vector<uint32> whiteItems; -static vector<uint32> greenItems; -static vector<uint32> blueItems; -static vector<uint32> purpleItems; +static vector<uint32> greyTradeGoodsBin; +static vector<uint32> whiteTradeGoodsBin; +static vector<uint32> greenTradeGoodsBin; +static vector<uint32> blueTradeGoodsBin; +static vector<uint32> purpleTradeGoodsBin; +static vector<uint32> orangeTradeGoodsBin; +static vector<uint32> yellowTradeGoodsBin; +static vector<uint32> greyItemsBin; +static vector<uint32> whiteItemsBin; +static vector<uint32> greenItemsBin; +static vector<uint32> blueItemsBin; +static vector<uint32> purpleItemsBin; +static vector<uint32> orangeItemsBin; +static vector<uint32> yellowItemsBin; static bool AHBSeller = 0; static bool AHBBuyer = 0; @@ -62,11 +69,23 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) { if (!AHBSeller) return; - AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID()); + AuctionHouseEntry const* ahEntry = auctionmgr.GetAuctionHouseEntry(config->GetAHFID()); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID()); uint32 items = 0; uint32 minItems = config->GetMinItems(); uint32 maxItems = config->GetMaxItems(); uint32 auctions = auctionHouse->Getcount(); + uint32 AuctioneerGUID = 0; + switch (config->GetAHID()){ + case 2: + AuctioneerGUID = 79707; //Human in stormwind. + case 6: + AuctioneerGUID = 4656; //orc in Orgrimmar + case 7: + AuctioneerGUID = 23442; //goblin in GZ + default: + AuctioneerGUID = 23442; //default to neutral 7 + } if (auctions >= minItems) return; @@ -77,28 +96,45 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) else items = (maxItems - auctions); } - uint32 wtgbin = config->GetPercents(AHB_WHITE_TG); - uint32 gtgbin = config->GetPercents(AHB_GREEN_TG); - uint32 btgbin = config->GetPercents(AHB_BLUE_TG); - uint32 ptgbin = config->GetPercents(AHB_PURPLE_TG); - uint32 wibin = config->GetPercents(AHB_WHITE_I); - uint32 gibin = config->GetPercents(AHB_GREEN_I); - uint32 bibin = config->GetPercents(AHB_BLUE_I); - uint32 pibin = config->GetPercents(AHB_PURPLE_I); - uint32 total = wtgbin + gtgbin + btgbin + ptgbin + wibin + gibin + bibin + pibin; - - uint32 pItems = 0; - uint32 bItems = 0; - uint32 gItems = 0; - uint32 wItems = 0; - uint32 pTGoods = 0; - uint32 bTGoods = 0; - uint32 gTGoods = 0; - uint32 wTGoods = 0; + uint32 greyTGcount = config->GetPercents(AHB_GREY_TG); + uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG); + uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG); + uint32 blueTGcount = config->GetPercents(AHB_BLUE_TG); + uint32 purpleTGcount = config->GetPercents(AHB_PURPLE_TG); + uint32 orangeTGcount = config->GetPercents(AHB_ORANGE_TG); + uint32 yellowTGcount = config->GetPercents(AHB_YELLOW_TG); + uint32 greyIcount = config->GetPercents(AHB_GREY_I); + uint32 whiteIcount = config->GetPercents(AHB_WHITE_I); + uint32 greenIcount = config->GetPercents(AHB_GREEN_I); + uint32 blueIcount = config->GetPercents(AHB_BLUE_I); + uint32 purpleIcount = config->GetPercents(AHB_PURPLE_I); + uint32 orangeIcount = config->GetPercents(AHB_ORANGE_I); + uint32 yellowIcount = config->GetPercents(AHB_YELLOW_I); + uint32 total = greyTGcount + whiteTGcount + greenTGcount + blueTGcount + + purpleTGcount + orangeTGcount + yellowTGcount + + 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::iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr) { AuctionEntry *Aentry = itr->second; - Item *item = objmgr.GetAItem(Aentry->item_guidlow); + Item *item = auctionmgr.GetAItem(Aentry->item_guidlow); if( item ) { ItemPrototype const *prototype = item->GetProto(); @@ -108,37 +144,51 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) { case 0: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - wTGoods = wTGoods + 1; + ++greyTGoods; else - wItems = wItems + 1; + ++greyItems; break; case 1: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - wTGoods = wTGoods + 1; + ++whiteTGoods; else - wItems = wItems + 1; + ++whiteItems; break; case 2: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - gTGoods = gTGoods + 1; + ++greenTGoods; else - gItems = gItems + 1; + ++greenItems; break; case 3: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - bTGoods = bTGoods + 1; + ++blueTGoods; else - bItems = bItems + 1; + ++blueItems; break; case 4: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - pTGoods = pTGoods + 1; + ++purpleTGoods; + else + ++purpleItems; + break; + + case 5: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + ++orangeTGoods; else - pItems = pItems + 1; + ++orangeItems; + break; + + case 6: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + ++yellowTGoods; + else + ++yellowItems; break; } } @@ -150,78 +200,132 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) uint32 itemID = 0; while (itemID == 0) { - uint32 choice = urand(1, 8); + uint32 choice = urand(0, 13); switch (choice) { + case 0: + { + if ((greyItemsBin.size() > 0) && (greyItems < greyIcount)) + { + itemID = greyItemsBin[urand(0, greyItemsBin.size() - 1)]; + ++greyItems; + break; + } + } case 1: { - if ((purpleItems.size() > 0) && (pItems < pibin)) + if ((whiteItemsBin.size() > 0) && (whiteItems < whiteIcount)) { - itemID = purpleItems[urand(0, purpleItems.size() - 1)]; - pItems = pItems + 1; - break; + itemID = whiteItemsBin[urand(0, whiteItemsBin.size() - 1)]; + ++whiteItems; + break; } } case 2: { - if ((blueItems.size() > 0) && (bItems < bibin)) + if ((greenItemsBin.size() > 0) && (greenItems < greenIcount)) { - itemID = blueItems[urand(0, blueItems.size() - 1)]; - bItems = bItems + 1; + itemID = greenItemsBin[urand(0, greenItemsBin.size() - 1)]; + ++greenItems; break; } } case 3: { - if ((greenItems.size() > 0) && (gItems < gibin)) + if ((blueItemsBin.size() > 0) && (blueItems < blueIcount)) { - itemID = greenItems[urand(0, greenItems.size() - 1)]; - gItems = gItems + 1; + itemID = blueItemsBin[urand(0, blueItemsBin.size() - 1)]; + ++blueItems; break; } } case 4: { - if ((whiteItems.size() > 0) && (wItems < wibin)) + if ((purpleItemsBin.size() > 0) && (purpleItems < purpleIcount)) { - itemID = whiteItems[urand(0, whiteItems.size() - 1)]; - wItems = wItems + 1; - break; + itemID = purpleItemsBin[urand(0, purpleItemsBin.size() - 1)]; + ++purpleItems; + break; } } case 5: { - if ((purpleTradeGoods.size() > 0) && (pTGoods < ptgbin)) + if ((orangeItemsBin.size() > 0) && (orangeItems < orangeIcount)) { - itemID = purpleTradeGoods[urand(0, purpleTradeGoods.size() - 1)]; - pTGoods = pTGoods + 1; - break; + itemID = orangeItemsBin[urand(0, orangeItemsBin.size() - 1)]; + ++orangeItems; + break; } } case 6: { - if ((blueTradeGoods.size() > 0) && (bTGoods < btgbin)) + if ((yellowItemsBin.size() > 0) && (yellowItems < yellowIcount)) { - itemID = blueTradeGoods[urand(0, blueTradeGoods.size() - 1)]; - bTGoods = bTGoods + 1; - break; + itemID = yellowItemsBin[urand(0, yellowItemsBin.size() - 1)]; + ++yellowItems; + break; } } case 7: { - if ((greenTradeGoods.size() > 0) && (gTGoods < gtgbin)) + if ((greyTradeGoodsBin.size() > 0) && (greyTGoods < greyTGcount)) { - itemID = greenTradeGoods[urand(0, greenTradeGoods.size() - 1)]; - gTGoods = gTGoods + 1; + itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)]; + ++greyTGoods; break; } } case 8: { - if ((whiteTradeGoods.size() > 0) && (wTGoods < wtgbin)) + if ((whiteTradeGoodsBin.size() > 0) && (whiteTGoods < whiteTGcount)) { - itemID = whiteTradeGoods[urand(0, whiteTradeGoods.size() - 1)]; - wTGoods = wTGoods + 1; + itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)]; + ++whiteTGoods; + break; + } + } + case 9: + { + if ((greenTradeGoodsBin.size() > 0) && (greenTGoods < greenTGcount)) + { + itemID = greenTradeGoodsBin[urand(0, greenTradeGoodsBin.size() - 1)]; + ++greenTGoods; + break; + } + } + case 10: + { + if ((blueTradeGoodsBin.size() > 0) && (blueTGoods < blueTGcount)) + { + itemID = blueTradeGoodsBin[urand(0, blueTradeGoodsBin.size() - 1)]; + ++blueTGoods; + break; + } + } + case 11: + { + if ((purpleTradeGoodsBin.size() > 0) && (purpleTGoods < purpleTGcount)) + { + itemID = purpleTradeGoodsBin[urand(0, purpleTradeGoodsBin.size() - 1)]; + ++purpleTGoods; + break; + } + } + case 12: + { + if ((orangeTradeGoodsBin.size() > 0) && (orangeTGoods < orangeTGcount)) + { + itemID = orangeTradeGoodsBin[urand(0, orangeTradeGoodsBin.size() - 1)]; + ++orangeTGoods; + break; + } + } + case 13: + { + if ((yellowTradeGoodsBin.size() > 0) && (yellowTGoods < yellowTGcount)) + { + itemID = yellowTradeGoodsBin[urand(0, yellowTradeGoodsBin.size() - 1)]; + ++yellowTGoods; break; } } @@ -270,6 +374,17 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) switch (prototype->Quality) { + case 0: + if (config->GetMaxStack(AHB_GREY) != 0) + { + stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_GREY))); + } + buyoutPrice *= urand(config->GetMinPrice(AHB_GREY), config->GetMaxPrice(AHB_GREY)) * stackCount; + buyoutPrice /= 100; + bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_GREY), config->GetMaxBidPrice(AHB_GREY)); + bidPrice /= 100; + break; + case 1: if (config->GetMaxStack(AHB_WHITE) != 0) { @@ -313,13 +428,33 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_PURPLE), config->GetMaxBidPrice(AHB_PURPLE)); bidPrice /= 100; break; + case 5: + if (config->GetMaxStack(AHB_ORANGE) != 0) + { + stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_ORANGE))); + } + buyoutPrice *= urand(config->GetMinPrice(AHB_ORANGE), config->GetMaxPrice(AHB_ORANGE)) * stackCount; + buyoutPrice /= 100; + bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_ORANGE), config->GetMaxBidPrice(AHB_ORANGE)); + bidPrice /= 100; + break; + case 6: + if (config->GetMaxStack(AHB_YELLOW) != 0) + { + stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_YELLOW))); + } + buyoutPrice *= urand(config->GetMinPrice(AHB_YELLOW), config->GetMaxPrice(AHB_YELLOW)) * stackCount; + buyoutPrice /= 100; + bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_YELLOW), config->GetMaxBidPrice(AHB_YELLOW)); + bidPrice /= 100; + break; } item->SetCount(stackCount); AuctionEntry* auctionEntry = new AuctionEntry; auctionEntry->Id = objmgr.GenerateAuctionID(); - auctionEntry->auctioneer = 0; + auctionEntry->auctioneer = AuctioneerGUID; auctionEntry->item_guidlow = item->GetGUIDLow(); auctionEntry->item_template = item->GetEntry(); auctionEntry->owner = AHBplayer->GetGUIDLow(); @@ -328,31 +463,13 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) auctionEntry->bidder = 0; auctionEntry->bid = 0; auctionEntry->deposit = 0; - auctionEntry->location = config->GetAHID(); - auctionEntry->time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL)); + auctionEntry->expire_time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL)); + auctionEntry->auctionHouseEntry = ahEntry; item->SaveToDB(); item->RemoveFromUpdateQueueOf(AHBplayer); - objmgr.AddAItem(item); + auctionmgr.AddAItem(item); auctionHouse->AddAuction(auctionEntry); - - CharacterDatabase.PExecute("INSERT INTO `auctionhouse` (`id`," - "`auctioneerguid`,`itemguid`,`item_template`," - "`itemowner`,`buyoutprice`,`time`,`buyguid`," - "`lastbid`,`startbid`,`deposit`,`location`) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', " - "'" I64FMTD "', '%u', '%u', '%u', '%u', '%u')", - auctionEntry->Id, - auctionEntry->auctioneer, - auctionEntry->item_guidlow, - auctionEntry->item_template, - auctionEntry->owner, - auctionEntry->buyout, - (uint64) auctionEntry->time, - auctionEntry->bidder, - auctionEntry->bid, - auctionEntry->startbid, - auctionEntry->deposit, - auctionEntry->location); + auctionEntry->SaveToDB(); } } @@ -362,7 +479,7 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World return; // Fetches content of selected AH - AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID()); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID()); AuctionHouseObject::AuctionEntryMap::iterator itr; itr = auctionHouse->GetAuctionsBegin(); @@ -395,11 +512,11 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World // Choose random auction from possible auctions uint32 auctionID = possibleBids[urand(0, possibleBids.size() - 1)]; - // from auctionhouse.cpp, creates auction pointer & player pointer + // from auctionhousehandler.cpp, creates auction pointer & player pointer AuctionEntry* auction = auctionHouse->GetAuction(auctionID); // get exact item information - Item *pItem = objmgr.GetAItem(auction->item_guidlow); + Item *pItem = auctionmgr.GetAItem(auction->item_guidlow); if (!pItem) { sLog.outError("Item doesn't exists, perhaps bought already?"); @@ -410,16 +527,14 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World ItemPrototype const* prototype = objmgr.GetItemPrototype(auction->item_template); // check which price we have to use, startbid or if it is bidded already - if(debug_Out) - {sLog.outError("Auction Number: %u", auction->Id);} - if(debug_Out) - {sLog.outError("Item Template: %u", auction->item_template);} - if(debug_Out) - {sLog.outError("Buy Price: %u", prototype->BuyPrice);} - if(debug_Out) - {sLog.outError("Sell Price: %u", prototype->SellPrice);} - if(debug_Out) - {sLog.outError("Quality: %u", prototype->Quality);} + if(debug_Out) + { + sLog.outError("Auction Number: %u", auction->Id); + sLog.outError("Item Template: %u", auction->item_template); + sLog.outError("Buy Price: %u", prototype->BuyPrice); + sLog.outError("Sell Price: %u", prototype->SellPrice); + sLog.outError("Quality: %u", prototype->Quality); + } uint32 currentprice; if(auction->bid) { @@ -480,6 +595,16 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World { bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE); } + case 5: + if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE)) + { + bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE); + } + case 6: + if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW)) + { + bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW); + } break; default: // quality is something it shouldn't be, let's get out of here @@ -521,6 +646,16 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World { bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE); } + case 5: + if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE)) + { + bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE); + } + case 6: + if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW)) + { + bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW); + } break; default: // quality is something it shouldn't be, let's get out of here @@ -564,9 +699,9 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World {sLog.outError("bidprice: %u", bidprice);} // Check our bid is high enough to be valid. If not, correct it to minimum. - if((currentprice + objmgr.GetAuctionOutBid(currentprice)) > bidprice) + if((currentprice + auction->GetAuctionOutBid()) > bidprice) { - bidprice = currentprice + objmgr.GetAuctionOutBid(currentprice); + bidprice = currentprice + auction->GetAuctionOutBid(); if(debug_Out) {sLog.outError("bidprice(>): %u", bidprice);} } @@ -614,15 +749,15 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World auction->bid = auction->buyout; // Send mails to buyer & seller - objmgr.SendAuctionSuccessfulMail( auction ); - objmgr.SendAuctionWonMail( auction ); + auctionmgr.SendAuctionSuccessfulMail( auction ); + auctionmgr.SendAuctionWonMail( auction ); // Remove item from auctionhouse - objmgr.RemoveAItem(auction->item_guidlow); + auctionmgr.RemoveAItem(auction->item_guidlow); // Remove auction auctionHouse->RemoveAuction(auction->Id); // Remove from database - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id); + auction->DeleteFromDB(); delete auction; } @@ -641,7 +776,7 @@ void AuctionHouseBot() _AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID); ObjectAccessor::Instance().AddObject(&_AHBplayer); - if(sConfig.GetIntDefault("AllowTwoSide.Interaction.Auction",0) == 0) + if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { addNewAuctions(&_AHBplayer, &AllianceConfig); if (((_newrun - _lastrun_a) > (AllianceConfig.GetBiddingInterval() * 60)) && (AllianceConfig.GetBidsPerInterval() > 0)) @@ -689,7 +824,7 @@ void AuctionHouseBotInit() Bind_When_Use = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Use", 1); Bind_Quest_Item = sConfig.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", 0); - if(sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",0) == 0) + if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { AuctionHouseBotLoadValues(&AllianceConfig); AuctionHouseBotLoadValues(&HordeConfig); @@ -796,7 +931,7 @@ void AuctionHouseBotInit() break; } - if ((prototype->Quality < 1) || (prototype->Quality > 4)) + if ((prototype->Quality < 0) || (prototype->Quality > 6)) continue; if (Vendor_Items == 0) @@ -848,58 +983,93 @@ void AuctionHouseBotInit() switch (prototype->Quality) { + case 0: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + greyTradeGoodsBin.push_back(itemID); + else + greyItemsBin.push_back(itemID); + break; + case 1: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - whiteTradeGoods.push_back(itemID); + whiteTradeGoodsBin.push_back(itemID); else - whiteItems.push_back(itemID); + whiteItemsBin.push_back(itemID); break; case 2: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - greenTradeGoods.push_back(itemID); + greenTradeGoodsBin.push_back(itemID); else - greenItems.push_back(itemID); + greenItemsBin.push_back(itemID); break; case 3: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - blueTradeGoods.push_back(itemID); + blueTradeGoodsBin.push_back(itemID); else - blueItems.push_back(itemID); + blueItemsBin.push_back(itemID); break; case 4: if (prototype->Class == ITEM_CLASS_TRADE_GOODS) - purpleTradeGoods.push_back(itemID); + purpleTradeGoodsBin.push_back(itemID); + else + purpleItemsBin.push_back(itemID); + break; + + case 5: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + orangeTradeGoodsBin.push_back(itemID); + else + orangeItemsBin.push_back(itemID); + break; + + case 6: + if (prototype->Class == ITEM_CLASS_TRADE_GOODS) + yellowTradeGoodsBin.push_back(itemID); else - purpleItems.push_back(itemID); + yellowItemsBin.push_back(itemID); break; } } - if ((whiteTradeGoods.size() == 0) && - (greenTradeGoods.size() == 0) && - (blueTradeGoods.size() == 0) && - (purpleTradeGoods.size() == 0) && - (whiteItems.size() == 0) && - (greenItems.size() == 0) && - (blueItems.size() == 0) && - (purpleItems.size() == 0)) + if ( + (greyTradeGoodsBin.size() == 0) && + (whiteTradeGoodsBin.size() == 0) && + (greenTradeGoodsBin.size() == 0) && + (blueTradeGoodsBin.size() == 0) && + (purpleTradeGoodsBin.size() == 0) && + (orangeTradeGoodsBin.size() == 0) && + (yellowTradeGoodsBin.size() == 0) && + (greyItemsBin.size() == 0) && + (whiteItemsBin.size() == 0) && + (greenItemsBin.size() == 0) && + (blueItemsBin.size() == 0) && + (purpleItemsBin.size() == 0) && + (orangeItemsBin.size() == 0) && + (yellowItemsBin.size() == 0) + ) { sLog.outString("AuctionHouseBot: No items"); AHBSeller = 0; } sLog.outString("AuctionHouseBot:"); - sLog.outString("loaded %d white trade goods", whiteTradeGoods.size()); - sLog.outString("loaded %d green trade goods", greenTradeGoods.size()); - sLog.outString("loaded %d blue trade goods", blueTradeGoods.size()); - sLog.outString("loaded %d purple trade goods", purpleTradeGoods.size()); - sLog.outString("loaded %d white items", whiteItems.size()); - sLog.outString("loaded %d green items", greenItems.size()); - sLog.outString("loaded %d blue items", blueItems.size()); - sLog.outString("loaded %d purple items", purpleItems.size()); + sLog.outString("loaded %d grey trade goods", greyTradeGoodsBin.size()); + sLog.outString("loaded %d white trade goods", whiteTradeGoodsBin.size()); + sLog.outString("loaded %d green trade goods", greenTradeGoodsBin.size()); + sLog.outString("loaded %d blue trade goods", blueTradeGoodsBin.size()); + sLog.outString("loaded %d purple trade goods", purpleTradeGoodsBin.size()); + sLog.outString("loaded %d orange trade goods", orangeTradeGoodsBin.size()); + sLog.outString("loaded %d yellow trade goods", yellowTradeGoodsBin.size()); + sLog.outString("loaded %d grey items", greyItemsBin.size()); + sLog.outString("loaded %d white items", whiteItemsBin.size()); + sLog.outString("loaded %d green items", greenItemsBin.size()); + sLog.outString("loaded %d blue items", blueItemsBin.size()); + sLog.outString("loaded %d purple items", purpleItemsBin.size()); + sLog.outString("loaded %d orange items", orangeItemsBin.size()); + sLog.outString("loaded %d yellow items", yellowItemsBin.size()); } sLog.outString("AuctionHouseBot by Paradox (original by ChrisK) has been loaded."); sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox"); @@ -938,14 +1108,20 @@ void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* a case AHB_PURPLE: color = "purple"; break; + case AHB_ORANGE: + color = "orange"; + break; + case AHB_YELLOW: + color = "yellow"; + break; default: break; } switch (command) { - case 0: //ahexpire + case 0: //ahexpire { - AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID()); AuctionHouseObject::AuctionEntryMap::iterator itr; itr = auctionHouse->GetAuctionsBegin(); @@ -953,40 +1129,40 @@ void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* a while (itr != auctionHouse->GetAuctionsEnd()) { if (itr->second->owner == AHBplayerGUID) - itr->second->time = sWorld.GetGameTime(); + itr->second->expire_time = sWorld.GetGameTime(); ++itr; } }break; - case 1: //min items + case 1: //min items { char * param1 = strtok(args, " "); uint32 minItems = (uint32) strtoul(param1, NULL, 0); CharacterDatabase.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems, ahMapID); config->SetMinItems(minItems); }break; - case 2: //max items + case 2: //max items { char * param1 = strtok(args, " "); uint32 maxItems = (uint32) strtoul(param1, NULL, 0); CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID); config->SetMaxItems(maxItems); }break; - case 3: //min time + case 3: //min time { char * param1 = strtok(args, " "); uint32 minTime = (uint32) strtoul(param1, NULL, 0); CharacterDatabase.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime, ahMapID); config->SetMinTime(minTime); }break; - case 4: //max time + case 4: //max time { char * param1 = strtok(args, " "); uint32 maxTime = (uint32) strtoul(param1, NULL, 0); CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime, ahMapID); config->SetMaxTime(maxTime); }break; - case 5: //percentages + case 5: //percentages { char * param1 = strtok(args, " "); char * param2 = strtok(NULL, " "); @@ -996,49 +1172,67 @@ void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* a char * param6 = strtok(NULL, " "); char * param7 = strtok(NULL, " "); char * param8 = strtok(NULL, " "); - uint32 wtg = (uint32) strtoul(param1, NULL, 0); - uint32 gtg = (uint32) strtoul(param2, NULL, 0); - uint32 btg = (uint32) strtoul(param3, NULL, 0); - uint32 ptg = (uint32) strtoul(param4, NULL, 0); - uint32 wi = (uint32) strtoul(param5, NULL, 0); - uint32 gi = (uint32) strtoul(param6, NULL, 0); - uint32 bi = (uint32) strtoul(param7, NULL, 0); - uint32 pi = (uint32) strtoul(param8, NULL, 0); + char * param9 = strtok(NULL, " "); + char * param10 = strtok(NULL, " "); + char * param11 = strtok(NULL, " "); + char * param12 = strtok(NULL, " "); + char * param13 = strtok(NULL, " "); + char * param14 = strtok(NULL, " "); + uint32 greytg = (uint32) strtoul(param1, NULL, 0); + uint32 whitetg = (uint32) strtoul(param2, NULL, 0); + uint32 greentg = (uint32) strtoul(param3, NULL, 0); + uint32 bluetg = (uint32) strtoul(param4, NULL, 0); + uint32 purpletg = (uint32) strtoul(param5, NULL, 0); + uint32 orangetg = (uint32) strtoul(param6, NULL, 0); + uint32 yellowtg = (uint32) strtoul(param7, NULL, 0); + uint32 greyi = (uint32) strtoul(param8, NULL, 0); + uint32 whitei = (uint32) strtoul(param9, NULL, 0); + uint32 greeni = (uint32) strtoul(param10, NULL, 0); + uint32 bluei = (uint32) strtoul(param11, NULL, 0); + uint32 purplei = (uint32) strtoul(param12, NULL, 0); + uint32 orangei = (uint32) strtoul(param13, NULL, 0); + uint32 yellowi = (uint32) strtoul(param14, NULL, 0); CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", wtg, ahMapID); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", gtg, ahMapID); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", btg, ahMapID); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", ptg, ahMapID); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", wi, ahMapID); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", gi, ahMapID); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bi, ahMapID); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", pi, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei, ahMapID); + CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi, ahMapID); CharacterDatabase.CommitTransaction(); - config->SetPercentages(wtg, gtg, btg, ptg, wi, gi, bi, pi); + config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi); }break; - case 6: //min prices + case 6: //min prices { char * param1 = strtok(args, " "); uint32 minPrice = (uint32) strtoul(param1, NULL, 0); CharacterDatabase.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minPrice, ahMapID); config->SetMinPrice(col, minPrice); }break; - case 7: //max prices + case 7: //max prices { char * param1 = strtok(args, " "); uint32 maxPrice = (uint32) strtoul(param1, NULL, 0); CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxPrice, ahMapID); config->SetMaxPrice(col, maxPrice); }break; - case 8: //min bid price + case 8: //min bid price { char * param1 = strtok(args, " "); uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0); CharacterDatabase.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minBidPrice, ahMapID); config->SetMinBidPrice(col, minBidPrice); }break; - case 9: //max bid price + case 9: //max bid price { char * param1 = strtok(args, " "); uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0); @@ -1094,25 +1288,44 @@ void AuctionHouseBotLoadValues(AHBConfig *config) {sLog.outError("minTime = %u", config->GetMinTime()); sLog.outError("maxTime = %u", config->GetMaxTime());} //load percentages - uint32 wtg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - uint32 gtg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - uint32 btg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - uint32 ptg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - uint32 wi = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - uint32 gi = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - uint32 bi = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - uint32 pi = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); - config->SetPercentages(wtg, gtg, btg, ptg, wi, gi, bi, pi); + uint32 greytg = CharacterDatabase.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 whitetg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 greentg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 bluetg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 purpletg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 orangetg = CharacterDatabase.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 yellowtg = CharacterDatabase.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 greyi = CharacterDatabase.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 whitei = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 greeni = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 bluei = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 purplei = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 orangei = CharacterDatabase.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + uint32 yellowi = CharacterDatabase.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); + config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi); if(debug_Out) - {sLog.outError("percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG)); - sLog.outError("percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG)); - sLog.outError("percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG)); - sLog.outError("percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG)); - sLog.outError("percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I)); - sLog.outError("percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I)); - sLog.outError("percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I)); - sLog.outError("percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I));} + { + sLog.outError("percentGreyTradeGoods = %u", config->GetPercentages(AHB_GREY_TG)); + sLog.outError("percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG)); + sLog.outError("percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG)); + sLog.outError("percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG)); + sLog.outError("percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG)); + sLog.outError("percentOrangeTradeGoods = %u", config->GetPercentages(AHB_ORANGE_TG)); + sLog.outError("percentYellowTradeGoods = %u", config->GetPercentages(AHB_YELLOW_TG)); + sLog.outError("percentGreyItems = %u", config->GetPercentages(AHB_GREY_I)); + sLog.outError("percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I)); + sLog.outError("percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I)); + sLog.outError("percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I)); + sLog.outError("percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I)); + sLog.outError("percentOrangeItems = %u", config->GetPercentages(AHB_ORANGE_I)); + sLog.outError("percentYellowItems = %u", config->GetPercentages(AHB_YELLOW_I)); + } //load min and max prices + config->SetMinPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + config->SetMaxPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("minPriceGrey = %u", config->GetMinPrice(AHB_GREY)); + sLog.outError("maxPriceGrey = %u", config->GetMaxPrice(AHB_GREY));} config->SetMinPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); config->SetMaxPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); if(debug_Out) @@ -1133,7 +1346,23 @@ void AuctionHouseBotLoadValues(AHBConfig *config) if(debug_Out) {sLog.outError("minPricePurple = %u", config->GetMinPrice(AHB_PURPLE)); sLog.outError("maxPricePurple = %u", config->GetMaxPrice(AHB_PURPLE));} + config->SetMinPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + config->SetMaxPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("minPriceOrange = %u", config->GetMinPrice(AHB_ORANGE)); + sLog.outError("maxPriceOrange = %u", config->GetMaxPrice(AHB_ORANGE));} + config->SetMinPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + config->SetMaxPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("minPriceYellow = %u", config->GetMinPrice(AHB_YELLOW)); + sLog.outError("maxPriceYellow = %u", config->GetMaxPrice(AHB_YELLOW));} //load min and max bid prices + config->SetMinBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError(",minBidPriceGrey = %u", config->GetMinBidPrice(AHB_GREY));} + config->SetMaxBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("maxBidPriceGrey = %u", config->GetMaxBidPrice(AHB_GREY));} config->SetMinBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); if(debug_Out) {sLog.outError(",minBidPriceWhite = %u", config->GetMinBidPrice(AHB_WHITE));} @@ -1158,7 +1387,22 @@ void AuctionHouseBotLoadValues(AHBConfig *config) config->SetMaxBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); if(debug_Out) {sLog.outError("maxBidPricePurple = %u", config->GetMaxBidPrice(AHB_PURPLE));} + config->SetMinBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("minBidPriceOrange = %u", config->GetMinBidPrice(AHB_ORANGE));} + config->SetMaxBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("maxBidPriceOrange = %u", config->GetMaxBidPrice(AHB_ORANGE));} + config->SetMinBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("minBidPriceYellow = %u", config->GetMinBidPrice(AHB_YELLOW));} + config->SetMaxBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("maxBidPriceYellow = %u", config->GetMaxBidPrice(AHB_YELLOW));} //load max stacks + config->SetMaxStack(AHB_GREY, CharacterDatabase.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("maxStackGrey = %u", config->GetMaxStack(AHB_GREY));} config->SetMaxStack(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); if(debug_Out) {sLog.outError("maxStackWhite = %u", config->GetMaxStack(AHB_WHITE));} @@ -1171,6 +1415,12 @@ void AuctionHouseBotLoadValues(AHBConfig *config) config->SetMaxStack(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); if(debug_Out) {sLog.outError("maxStackPurple = %u", config->GetMaxStack(AHB_PURPLE));} + config->SetMaxStack(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("maxStackOrange = %u", config->GetMaxStack(AHB_ORANGE));} + config->SetMaxStack(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + if(debug_Out) + {sLog.outError("maxStackYellow = %u", config->GetMaxStack(AHB_YELLOW));} } if (AHBBuyer) { @@ -1180,12 +1430,18 @@ void AuctionHouseBotLoadValues(AHBConfig *config) config->SetBuyerPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); config->SetBuyerPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); config->SetBuyerPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + config->SetBuyerPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); + config->SetBuyerPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); if(debug_Out) - {sLog.outError("buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY)); - sLog.outError("buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE)); - sLog.outError("buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN)); - sLog.outError("buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE)); - sLog.outError("buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE));} + { + sLog.outError("buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY)); + sLog.outError("buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE)); + sLog.outError("buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN)); + sLog.outError("buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE)); + sLog.outError("buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE)); + sLog.outError("buyerPriceOrange = %u", config->GetBuyerPrice(AHB_ORANGE)); + sLog.outError("buyerPriceYellow = %u", config->GetBuyerPrice(AHB_YELLOW)); + } //load bidding interval config->SetBiddingInterval(CharacterDatabase.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); if(debug_Out) @@ -1196,4 +1452,3 @@ void AuctionHouseBotLoadValues(AHBConfig *config) {sLog.outError("buyerBidsPerInterval = %u", config->GetBidsPerInterval());} } } - diff --git a/src/game/AuctionHouseBot.h b/src/game/AuctionHouseBot.h index 3a224b8f752..8d5c067a354 100644 --- a/src/game/AuctionHouseBot.h +++ b/src/game/AuctionHouseBot.h @@ -8,16 +8,22 @@ #define AHB_GREEN 2 #define AHB_BLUE 3 #define AHB_PURPLE 4 +#define AHB_ORANGE 5 +#define AHB_YELLOW 6 #define AHB_GREY_TG 0 #define AHB_WHITE_TG 1 #define AHB_GREEN_TG 2 #define AHB_BLUE_TG 3 #define AHB_PURPLE_TG 4 -#define AHB_GREY_I 5 -#define AHB_WHITE_I 6 -#define AHB_GREEN_I 7 -#define AHB_BLUE_I 8 -#define AHB_PURPLE_I 9 +#define AHB_ORANGE_TG 5 +#define AHB_YELLOW_TG 6 +#define AHB_GREY_I 7 +#define AHB_WHITE_I 8 +#define AHB_GREEN_I 9 +#define AHB_BLUE_I 10 +#define AHB_PURPLE_I 11 +#define AHB_ORANGE_I 12 +#define AHB_YELLOW_I 13 #define AHBplayerAccount sConfig.GetIntDefault("AuctionHouseBot.Account", 0) #define AHBplayerGUID sConfig.GetIntDefault("AuctionHouseBot.GUID", 0) #define ItemsPerCycle sConfig.GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200) @@ -28,18 +34,30 @@ class AHBConfig { private: uint32 AHID; + uint32 AHFID; uint32 minItems; uint32 maxItems; uint32 minTime; uint32 maxTime; + uint32 percentGreyTradeGoods; uint32 percentWhiteTradeGoods; uint32 percentGreenTradeGoods; uint32 percentBlueTradeGoods; uint32 percentPurpleTradeGoods; + uint32 percentOrangeTradeGoods; + uint32 percentYellowTradeGoods; + uint32 percentGreyItems; uint32 percentWhiteItems; uint32 percentGreenItems; uint32 percentBlueItems; uint32 percentPurpleItems; + uint32 percentOrangeItems; + uint32 percentYellowItems; + uint32 minPriceGrey; + uint32 maxPriceGrey; + uint32 minBidPriceGrey; + uint32 maxBidPriceGrey; + uint32 maxStackGrey; uint32 minPriceWhite; uint32 maxPriceWhite; uint32 minBidPriceWhite; @@ -60,27 +78,60 @@ class AHBConfig uint32 minBidPricePurple; uint32 maxBidPricePurple; uint32 maxStackPurple; + uint32 minPriceOrange; + uint32 maxPriceOrange; + uint32 minBidPriceOrange; + uint32 maxBidPriceOrange; + uint32 maxStackOrange; + uint32 minPriceYellow; + uint32 maxPriceYellow; + uint32 minBidPriceYellow; + uint32 maxBidPriceYellow; + uint32 maxStackYellow; uint32 buyerPriceGrey; uint32 buyerPriceWhite; uint32 buyerPriceGreen; uint32 buyerPriceBlue; uint32 buyerPricePurple; + uint32 buyerPriceOrange; + uint32 buyerPriceYellow; uint32 buyerBiddingInterval; uint32 buyerBidsPerInterval; - uint32 wtgp; - uint32 gtgp; - uint32 btgp; - uint32 ptgp; - uint32 wip; - uint32 gip; - uint32 bip; - uint32 pip; + uint32 greytgp; + uint32 whitetgp; + uint32 greentgp; + uint32 bluetgp; + uint32 purpletgp; + uint32 orangetgp; + uint32 yellowtgp; + uint32 greyip; + uint32 whiteip; + uint32 greenip; + uint32 blueip; + uint32 purpleip; + uint32 orangeip; + uint32 yellowip; public: AHBConfig(uint32 ahid) { AHID = ahid; + switch(ahid) + { + case 2: + AHFID = 55; + break; + case 6: + AHFID = 29; + break; + case 7: + AHFID = 120; + break; + default: + AHFID = 120; + break; + } } AHBConfig() { @@ -89,6 +140,10 @@ class AHBConfig { return AHID; } + uint32 GetAHFID() + { + return AHFID; + } void SetMinItems(uint32 value) { minItems = value; @@ -132,9 +187,9 @@ class AHBConfig { return maxTime; } - void SetPercentages(uint32 wtg, uint32 gtg, uint32 btg, uint32 ptg, uint32 wi, uint32 gi, uint32 bi, uint32 pi) + void SetPercentages(uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg, uint32 greyi, uint32 whitei, uint32 greeni, uint32 bluei, uint32 purplei, uint32 orangei, uint32 yellowi) { - uint32 totalPercent = wtg + gtg + btg + ptg + wi + gi + bi + pi; + uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi; if (totalPercent == 0) { @@ -142,26 +197,35 @@ class AHBConfig } else if (totalPercent != 100) { - double scale = (double) 100 / (double) totalPercent; - - wtg = (uint32) (scale * (double) pi); - gtg = (uint32) (scale * (double) gtg); - btg = (uint32) (scale * (double) btg); - ptg = (uint32) (scale * (double) ptg); - wi = (uint32) (scale * (double) wi); - gi = (uint32) (scale * (double) gi); - bi = (uint32) (scale * (double) bi); - pi = 100 - wtg - gtg - btg - ptg - wi - gi - bi; - + greytg = 0; + whitetg = 27; + greentg = 12; + bluetg = 10; + purpletg = 1; + orangetg = 0; + yellowtg = 0; + greyi = 0; + whitei = 10; + greeni = 30; + bluei = 8; + purplei = 2; + orangei = 0; + yellowi = 0; } - percentWhiteTradeGoods = wtg; - percentGreenTradeGoods = gtg; - percentBlueTradeGoods = btg; - percentPurpleTradeGoods = ptg; - percentWhiteItems = wi; - percentGreenItems = gi; - percentBlueItems = bi; - percentPurpleItems = pi; + percentGreyTradeGoods = greytg; + percentWhiteTradeGoods = whitetg; + percentGreenTradeGoods = greentg; + percentBlueTradeGoods = bluetg; + percentPurpleTradeGoods = purpletg; + percentOrangeTradeGoods = orangetg; + percentYellowTradeGoods = yellowtg; + percentGreyItems = greyi; + percentWhiteItems = whitei; + percentGreenItems = greeni; + percentBlueItems = bluei; + percentPurpleItems = purplei; + percentOrangeItems = orangei; + percentYellowItems = yellowi; CalculatePercents(); } uint32 GetPercentages(uint32 color) @@ -169,7 +233,7 @@ class AHBConfig switch(color) { case AHB_GREY_TG: - return 0; + return percentGreyTradeGoods; break; case AHB_WHITE_TG: return percentWhiteTradeGoods; @@ -183,8 +247,14 @@ class AHBConfig case AHB_PURPLE_TG: return percentPurpleTradeGoods; break; + case AHB_ORANGE_TG: + return percentOrangeTradeGoods; + break; + case AHB_YELLOW_TG: + return percentYellowTradeGoods; + break; case AHB_GREY_I: - return 0; + return percentGreyItems; break; case AHB_WHITE_I: return percentWhiteItems; @@ -198,6 +268,12 @@ class AHBConfig case AHB_PURPLE_I: return percentPurpleItems; break; + case AHB_ORANGE_I: + return percentOrangeItems; + break; + case AHB_YELLOW_I: + return percentYellowItems; + break; default: return 0; break; @@ -208,6 +284,7 @@ class AHBConfig switch(color) { case AHB_GREY: + minPriceGrey = value; break; case AHB_WHITE: minPriceWhite = value; @@ -221,6 +298,12 @@ class AHBConfig case AHB_PURPLE: minPricePurple = value; break; + case AHB_ORANGE: + minPriceOrange = value; + break; + case AHB_YELLOW: + minPriceYellow = value; + break; default: break; } @@ -231,7 +314,12 @@ class AHBConfig { case AHB_GREY: { - return 0; + if (minPriceGrey == 0) + return 100; + else if (minPriceGrey > maxPriceGrey) + return maxPriceGrey; + else + return minPriceGrey; break; } case AHB_WHITE: @@ -274,6 +362,26 @@ class AHBConfig return minPricePurple; break; } + case AHB_ORANGE: + { + if (minPriceOrange == 0) + return 400; + else if (minPriceOrange > maxPriceOrange) + return maxPriceOrange; + else + return minPriceOrange; + break; + } + case AHB_YELLOW: + { + if (minPriceYellow == 0) + return 500; + else if (minPriceYellow > maxPriceYellow) + return maxPriceYellow; + else + return minPriceYellow; + break; + } default: { return 0; @@ -286,6 +394,7 @@ class AHBConfig switch(color) { case AHB_GREY: + maxPriceGrey = value; break; case AHB_WHITE: maxPriceWhite = value; @@ -299,6 +408,12 @@ class AHBConfig case AHB_PURPLE: maxPricePurple = value; break; + case AHB_ORANGE: + maxPriceOrange = value; + break; + case AHB_YELLOW: + maxPriceYellow = value; + break; default: break; } @@ -309,7 +424,10 @@ class AHBConfig { case AHB_GREY: { - return 0; + if (maxPriceGrey == 0) + return 150; + else + return maxPriceGrey; break; } case AHB_WHITE: @@ -344,6 +462,22 @@ class AHBConfig return maxPricePurple; break; } + case AHB_ORANGE: + { + if (maxPriceOrange == 0) + return 550; + else + return maxPriceOrange; + break; + } + case AHB_YELLOW: + { + if (maxPriceYellow == 0) + return 650; + else + return maxPriceYellow; + break; + } default: { return 0; @@ -356,6 +490,7 @@ class AHBConfig switch(color) { case AHB_GREY: + minBidPriceGrey = value; break; case AHB_WHITE: minBidPriceWhite = value; @@ -369,6 +504,12 @@ class AHBConfig case AHB_PURPLE: minBidPricePurple = value; break; + case AHB_ORANGE: + minBidPriceOrange = value; + break; + case AHB_YELLOW: + minBidPriceYellow = value; + break; default: break; } @@ -379,7 +520,10 @@ class AHBConfig { case AHB_GREY: { - return 0; + if (minBidPriceGrey > 100) + return 100; + else + return minBidPriceGrey; break; } case AHB_WHITE: @@ -414,6 +558,22 @@ class AHBConfig return minBidPricePurple; break; } + case AHB_ORANGE: + { + if (minBidPriceOrange > 100) + return 100; + else + return minBidPriceOrange; + break; + } + case AHB_YELLOW: + { + if (minBidPriceYellow > 100) + return 100; + else + return minBidPriceYellow; + break; + } default: { return 0; @@ -426,6 +586,7 @@ class AHBConfig switch(color) { case AHB_GREY: + maxBidPriceGrey = value; break; case AHB_WHITE: maxBidPriceWhite = value; @@ -439,6 +600,12 @@ class AHBConfig case AHB_PURPLE: maxBidPricePurple = value; break; + case AHB_ORANGE: + maxBidPriceOrange = value; + break; + case AHB_YELLOW: + maxBidPriceYellow = value; + break; default: break; } @@ -449,7 +616,10 @@ class AHBConfig { case AHB_GREY: { - return 0; + if (maxBidPriceGrey > 100) + return 100; + else + return maxBidPriceGrey; break; } case AHB_WHITE: @@ -484,6 +654,22 @@ class AHBConfig return maxBidPricePurple; break; } + case AHB_ORANGE: + { + if (maxBidPriceOrange > 100) + return 100; + else + return maxBidPriceOrange; + break; + } + case AHB_YELLOW: + { + if (maxBidPriceYellow > 100) + return 100; + else + return maxBidPriceYellow; + break; + } default: { return 0; @@ -496,6 +682,7 @@ class AHBConfig switch(color) { case AHB_GREY: + maxStackGrey = value; break; case AHB_WHITE: maxStackWhite = value; @@ -509,6 +696,12 @@ class AHBConfig case AHB_PURPLE: maxStackPurple = value; break; + case AHB_ORANGE: + maxStackOrange = value; + break; + case AHB_YELLOW: + maxStackYellow = value; + break; default: break; } @@ -519,7 +712,7 @@ class AHBConfig { case AHB_GREY: { - return 0; + return maxStackGrey; break; } case AHB_WHITE: @@ -542,6 +735,16 @@ class AHBConfig return maxStackPurple; break; } + case AHB_ORANGE: + { + return maxStackOrange; + break; + } + case AHB_YELLOW: + { + return maxStackYellow; + break; + } default: { return 0; @@ -568,6 +771,12 @@ class AHBConfig case AHB_PURPLE: buyerPricePurple = value; break; + case AHB_ORANGE: + buyerPriceOrange = value; + break; + case AHB_YELLOW: + buyerPriceYellow = value; + break; default: break; } @@ -591,6 +800,12 @@ class AHBConfig case AHB_PURPLE: return buyerPricePurple; break; + case AHB_ORANGE: + return buyerPriceOrange; + break; + case AHB_YELLOW: + return buyerPriceYellow; + break; default: return 0; break; @@ -606,62 +821,79 @@ class AHBConfig } void CalculatePercents() { - wtgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems); - gtgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems); - btgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems); - ptgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems); - wip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems); - gip = (uint32) (((double)percentGreenItems / 100.0) * maxItems); - bip = (uint32) (((double)percentBlueItems / 100.0) * maxItems); - pip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems); - uint32 total = wtgp + gtgp + btgp + ptgp + wip + gip + bip + pip; - if (total != maxItems) + greytgp = (uint32) (((double)percentGreyTradeGoods / 100.0) * maxItems); + whitetgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems); + greentgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems); + bluetgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems); + purpletgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems); + orangetgp = (uint32) (((double)percentOrangeTradeGoods / 100.0) * maxItems); + yellowtgp = (uint32) (((double)percentYellowTradeGoods / 100.0) * maxItems); + greyip = (uint32) (((double)percentGreyItems / 100.0) * maxItems); + whiteip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems); + greenip = (uint32) (((double)percentGreenItems / 100.0) * maxItems); + blueip = (uint32) (((double)percentBlueItems / 100.0) * maxItems); + purpleip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems); + orangeip = (uint32) (((double)percentOrangeItems / 100.0) * maxItems); + yellowip = (uint32) (((double)percentYellowItems / 100.0) * maxItems); + uint32 total = greytgp + whitetgp + greentgp + bluetgp + purpletgp + orangetgp + yellowtgp + greyip + whiteip + greenip + blueip + purpleip + orangeip + yellowip; + int32 diff = (maxItems - total); + if (diff < 0) + { + if ((whiteip - diff) > 0) + whiteip -= diff; + else if ((greenip - diff) > 0) + greenip -= diff; + } + else if (diff < 0) { - wtgp = (uint32) (maxItems * (double) wtgp); - gtgp = (uint32) (maxItems * (double) gtgp); - btgp = (uint32) (maxItems * (double) btgp); - ptgp = (uint32) (maxItems * (double) ptgp); - wip = (uint32) (maxItems * (double) wip); - gip = (uint32) (maxItems * (double) gip); - bip = (uint32) (maxItems * (double) bip); - pip = (maxItems - (wtgp + gtgp + btgp + ptgp + wip + gip + bip)); - total = wtgp + gtgp + btgp + ptgp + wip + gip + bip + pip; + whiteip += diff; } - //sLog.outString("%u %u %u %u %u %u %u %u", wtgp, gtgp, btgp, ptgp, wip, gip, bip, pip); } uint32 GetPercents(uint32 color) { switch(color) { case AHB_GREY_TG: - return 0; + return greytgp; break; case AHB_WHITE_TG: - return wtgp; + return whitetgp; break; case AHB_GREEN_TG: - return gtgp; + return greentgp; break; case AHB_BLUE_TG: - return btgp; + return bluetgp; break; case AHB_PURPLE_TG: - return ptgp; + return purpletgp; + break; + case AHB_ORANGE_TG: + return orangetgp; + break; + case AHB_YELLOW_TG: + return yellowtgp; break; case AHB_GREY_I: - return 0; + return greyip; break; case AHB_WHITE_I: - return wip; + return whiteip; break; case AHB_GREEN_I: - return gip; + return greenip; break; case AHB_BLUE_I: - return bip; + return blueip; break; case AHB_PURPLE_I: - return pip; + return purpleip; + break; + case AHB_ORANGE_I: + return orangeip; + break; + case AHB_YELLOW_I: + return yellowip; break; default: return 0; @@ -685,4 +917,3 @@ void AuctionHouseBotInit(); void AuctionHouseBotLoadValues(AHBConfig*); void AuctionHouseBotCommands(uint32, uint32, uint32, char*); #endif - diff --git a/src/game/AuctionHouse.cpp b/src/game/AuctionHouseHandler.cpp index 9fc448cf20b..b36d1870b86 100644 --- a/src/game/AuctionHouse.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include "ObjectMgr.h" #include "Player.h" #include "UpdateMask.h" -#include "AuctionHouseObject.h" +#include "AuctionHouseMgr.h" #include "Util.h" #include "AuctionHouseBot.h" @@ -55,67 +55,19 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data ) SendAuctionHello(guid, unit); } -static uint8 AuctioneerFactionToLocation(uint32 faction) -{ - if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - return 7; // neutral - - FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(faction); - if(!u_entry) - return 7; // neutral - - if(u_entry->ourMask & FACTION_MASK_ALLIANCE) - return 2; - else if(u_entry->ourMask & FACTION_MASK_HORDE) - return 6; - else - return 7; -} - //this void causes that auction window is opened void WorldSession::SendAuctionHello( uint64 guid, Creature* unit ) { + AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction()); + if(!ahEntry) + return; + WorldPacket data( MSG_AUCTION_HELLO, 12 ); data << (uint64) guid; - data << (uint32) AuctioneerFactionToLocation(unit->getFaction()); + data << (uint32) ahEntry->houseId; SendPacket( &data ); } -//this function inserts to WorldPacket auction's data -bool WorldSession::SendAuctionInfo(WorldPacket & data, AuctionEntry* auction) -{ - Item *pItem = objmgr.GetAItem(auction->item_guidlow); - if (!pItem) - { - sLog.outError("auction to item, that doesn't exist !!!!"); - return false; - } - data << (uint32) auction->Id; - data << (uint32) pItem->GetEntry(); - - for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++) - { - data << (uint32) pItem->GetEnchantmentId(EnchantmentSlot(i)); - data << (uint32) pItem->GetEnchantmentDuration(EnchantmentSlot(i)); - data << (uint32) pItem->GetEnchantmentCharges(EnchantmentSlot(i)); - } - - data << (uint32) pItem->GetItemRandomPropertyId(); //random item property id - data << (uint32) pItem->GetItemSuffixFactor(); //SuffixFactor - data << (uint32) pItem->GetCount(); //item->count - data << (uint32) pItem->GetSpellCharges(); //item->charge FFFFFFF - data << (uint32) 0; //Unknown - data << (uint64) auction->owner; //Auction->owner - data << (uint32) auction->startbid; //Auction->startbid (not sure if useful) - data << (uint32) ((auction->bid)? objmgr.GetAuctionOutBid(auction->bid) : 0); - //minimal outbid - data << (uint32) auction->buyout; //auction->buyout - data << (uint32) (auction->time - time(NULL)) * 1000; //time left - data << (uint64) auction->bidder; //auction->bidder current - data << (uint32) auction->bid; //current bid - return true; -} - //call this method when player bids, creates, or deletes auction void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError ) { @@ -132,13 +84,13 @@ void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uin 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 << location; - data << auctionId; - data << (uint64) bidder; - data << bidSum; - data << (uint32) diff; - data << item_template; - data << (uint32) 0; + data << uint32(location); + data << uint32(auctionId); + data << uint64(bidder); + data << uint32(bidSum); + data << uint32(diff); + data << uint32(item_template); + data << uint32(0); SendPacket(&data); } @@ -173,16 +125,16 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED; if (oldBidder && !_player) - oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, AHBplayerGUID, newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template); + oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, AHBplayerGUID, newPrice, auction->GetAuctionOutBid(), auction->item_template); if (oldBidder && _player) - oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, _player->GetGUID(), newPrice, objmgr.GetAuctionOutBid(auction->bid), 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->location, auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE); + 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 canceled to old bidder +//this function sends mail, when auction is cancelled to old bidder void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction ) { uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); @@ -198,7 +150,7 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction ) std::ostringstream msgAuctionCancelledSubject; msgAuctionCancelledSubject << auction->item_template << ":0:" << AUCTION_CANCELLED_TO_BIDDER; - WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionCancelledSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE); + WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionCancelledSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE); } } @@ -223,6 +175,14 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) return; } + AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction()); + if(!auctionHouseEntry) + { + sLog.outDebug( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)) ); + return; + } + + // client send time in minutes, convert to common used sec time etime *= MINUTE; @@ -243,7 +203,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) Item *it = pl->GetItemByGuid( item ); //do not allow to sell already auctioned items - if(objmgr.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); @@ -268,12 +228,10 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) return; } - uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); - AuctionHouseObject * mAuctions; - mAuctions = objmgr.GetAuctionsMap( location ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); //we have to take deposit : - uint32 deposit = objmgr.GetAuctionDeposit( location, etime, it ); + uint32 deposit = auctionmgr.GetAuctionDeposit( auctionHouseEntry, etime, it ); if ( pl->GetMoney() < deposit ) { SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY); @@ -292,7 +250,10 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) AuctionEntry *AH = new AuctionEntry; AH->Id = objmgr.GenerateAuctionID(); - AH->auctioneer = GUID_LOPART(auctioneer); + if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + AH->auctioneer = 23442; + else + AH->auctioneer = GUID_LOPART(auctioneer); AH->item_guidlow = GUID_LOPART(item); AH->item_template = it->GetEntry(); AH->owner = pl->GetGUIDLow(); @@ -300,22 +261,20 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) AH->bidder = 0; AH->bid = 0; AH->buyout = buyout; - AH->time = time(NULL) + auction_time; + AH->expire_time = time(NULL) + auction_time; AH->deposit = deposit; - AH->location = location; + 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 location: %u", GUID_LOPART(item), GUID_LOPART(auctioneer), bid, buyout, auction_time, location); - mAuctions->AddAuction(AH); + 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()); + auctionHouse->AddAuction(AH); - objmgr.AddAItem(it); + auctionmgr.AddAItem(it); pl->MoveItemFromInventory( it->GetBagSlot(), it->GetSlot(), true); CharacterDatabase.BeginTransaction(); it->DeleteFromInventoryDB(); it->SaveToDB(); // recursive and not have transaction guard into self, not in inventiory and can be save standalone - CharacterDatabase.PExecute("INSERT INTO auctionhouse (id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit,location) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u', '%u')", - AH->Id, AH->auctioneer, AH->item_guidlow, AH->item_template, AH->owner, AH->buyout, (uint64)AH->time, AH->bidder, AH->bid, AH->startbid, AH->deposit, AH->location); + AH->SaveToDB(); pl->SaveInventoryAndGoldToDB(); CharacterDatabase.CommitTransaction(); @@ -347,12 +306,9 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); - - AuctionHouseObject * mAuctions; - mAuctions = objmgr.GetAuctionsMap( location ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); - AuctionEntry *auction = mAuctions->GetAuction(auctionId); + AuctionEntry *auction = auctionHouse->GetAuction(auctionId); Player *pl = GetPlayer(); if( !auction || auction->owner == pl->GetGUIDLow() ) @@ -377,7 +333,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) // price too low for next bid if not buyout if ((price < auction->buyout || auction->buyout == 0) && - price < auction->bid + objmgr.GetAuctionOutBid(auction->bid)) + price < auction->bid + auction->GetAuctionOutBid()) { //auction has already higher bid, client tests it! return; @@ -435,15 +391,15 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) auction->bidder = pl->GetGUIDLow(); auction->bid = auction->buyout; - objmgr.SendAuctionSalePendingMail( auction ); - objmgr.SendAuctionSuccessfulMail( auction ); - objmgr.SendAuctionWonMail( auction ); + auctionmgr.SendAuctionSalePendingMail( auction ); + auctionmgr.SendAuctionSuccessfulMail( auction ); + auctionmgr.SendAuctionWonMail( auction ); SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK); - objmgr.RemoveAItem(auction->item_guidlow); - mAuctions->RemoveAuction(auction->Id); - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id); + auctionmgr.RemoveAItem(auction->item_guidlow); + auctionHouse->RemoveAuction(auction->Id); + auction->DeleteFromDB(); delete auction; } @@ -474,22 +430,19 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); - AuctionHouseObject * mAuctions; - mAuctions = objmgr.GetAuctionsMap( location ); - - AuctionEntry *auction = mAuctions->GetAuction(auctionId); + AuctionEntry *auction = auctionHouse->GetAuction(auctionId); Player *pl = GetPlayer(); if (auction && auction->owner == pl->GetGUIDLow()) { - Item *pItem = objmgr.GetAItem(auction->item_guidlow); + Item *pItem = auctionmgr.GetAItem(auction->item_guidlow); if (pItem) { if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid { - uint32 auctionCut = objmgr.GetAuctionCut( auction->location, auction->bid); + uint32 auctionCut = auction->GetAuctionCut(); 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.. @@ -504,7 +457,7 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) mi.AddItem(auction->item_guidlow, auction->item_template, pItem); // item will deleted or added to received mail list - WorldSession::SendMailTo(pl, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, pl->GetGUIDLow(), msgAuctionCanceledOwner.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); + WorldSession::SendMailTo(pl, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), pl->GetGUIDLow(), msgAuctionCanceledOwner.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); } else { @@ -525,11 +478,11 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) SendAuctionCommandResult( auction->Id, AUCTION_CANCEL, AUCTION_OK ); // Now remove the auction CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id); + auction->DeleteFromDB(); pl->SaveInventoryAndGoldToDB(); CharacterDatabase.CommitTransaction(); - objmgr.RemoveAItem( auction->item_guidlow ); - mAuctions->RemoveAuction( auction->Id ); + auctionmgr.RemoveAItem( auction->item_guidlow ); + auctionHouse->RemoveAuction( auction->Id ); delete auction; } @@ -562,8 +515,7 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); - AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) ); Player *pl = GetPlayer(); @@ -575,23 +527,15 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) --outbiddedCount; uint32 outbiddedAuctionId; recv_data >> outbiddedAuctionId; - AuctionEntry * auction = mAuctions->GetAuction( outbiddedAuctionId ); - if ( auction && SendAuctionInfo(data, auction)) + AuctionEntry * auction = auctionHouse->GetAuction( outbiddedAuctionId ); + if ( auction && auction->BuildAuctionInfo(data)) { ++totalcount; ++count; } } - for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr) - { - AuctionEntry *Aentry = itr->second; - if( Aentry && Aentry->bidder == pl->GetGUIDLow() ) - { - if (SendAuctionInfo(data, itr->second)) - ++count; - ++totalcount; - } - } + + auctionHouse->BuildListBidderItems(data,pl,count,totalcount); data.put<uint32>( 0, count ); // add count to placeholder data << totalcount; data << (uint32)300; //unk 2.3.0 @@ -620,25 +564,15 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data ) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); - - AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) ); data << (uint32) 0; // amount place holder uint32 count = 0; uint32 totalcount = 0; - for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr) - { - AuctionEntry *Aentry = itr->second; - if( Aentry && Aentry->owner == _player->GetGUIDLow() ) - { - if(SendAuctionInfo(data, itr->second)) - ++count; - ++totalcount; - } - } + + auctionHouse->BuildListOwnerItems(data,_player,count,totalcount); data.put<uint32>(0, count); data << (uint32) totalcount; data << (uint32) 0; @@ -650,9 +584,9 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1); - std::string searchedname, name; - uint8 levelmin, levelmax, usable, location; - uint32 count, totalcount, listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality; + std::string searchedname; + uint8 levelmin, levelmax, usable; + uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality; uint64 guid; recv_data >> guid; @@ -677,15 +611,13 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - location = AuctioneerFactionToLocation(pCreature->getFaction()); - AuctionHouseObject * mAuctions; - mAuctions = objmgr.GetAuctionsMap( location ); + AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() ); //sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable); WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) ); - count = 0; - totalcount = 0; + uint32 count = 0; + uint32 totalcount = 0; data << (uint32) 0; // converting string that we try to find to lower case @@ -695,62 +627,11 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) wstrToLower(wsearchedname); - for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr) - { - AuctionEntry *Aentry = itr->second; - Item *item = objmgr.GetAItem(Aentry->item_guidlow); - if( item ) - { - ItemPrototype const *proto = item->GetProto(); - if( proto ) - { - if( auctionMainCategory == (0xffffffff) || proto->Class == auctionMainCategory ) - { - if( auctionSubCategory == (0xffffffff) || proto->SubClass == auctionSubCategory ) - { - if( auctionSlotID == (0xffffffff) || proto->InventoryType == auctionSlotID ) - { - if( quality == (0xffffffff) || proto->Quality == quality ) - { - if( usable == (0x00) || _player->CanUseItem( item ) == EQUIP_ERR_OK ) - { - if( ( levelmin == (0x00) || proto->RequiredLevel >= levelmin ) && ( levelmax == (0x00) || proto->RequiredLevel <= levelmax ) ) - { - name = proto->Name1; - - // local name - int loc_idx = GetSessionDbLocaleIndex(); - if ( loc_idx >= 0 ) - { - ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId); - if (il) - { - if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) - name = il->Name[loc_idx]; - } - } - - if(name.empty()) - continue; - - if( wsearchedname.empty() || Utf8FitTo(name, wsearchedname) ) - { - if ((count < 50) && (totalcount >= listfrom)) - { - ++count; - SendAuctionInfo( data, Aentry); - } - ++totalcount; - } - } - } - } - } - } - } - } - } - } + auctionHouse->BuildListAuctionItems(data,_player, + wsearchedname, listfrom, levelmin, levelmax, usable, + auctionSlotID, auctionMainCategory, auctionSubCategory, quality, + count,totalcount); + data.put<uint32>(0, count); data << (uint32) totalcount; data << (uint32) 300; // unk 2.3.0 const? diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp new file mode 100644 index 00000000000..1554013af99 --- /dev/null +++ b/src/game/AuctionHouseMgr.cpp @@ -0,0 +1,685 @@ +/* +* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "Database/DBCStores.h" +#include "Database/SQLStorage.h" +#include "ProgressBar.h" + +#include "AccountMgr.h" +#include "AuctionHouseMgr.h" +#include "Item.h" +#include "Language.h" +#include "Log.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" + +#include "Policies/SingletonImp.h" + +INSTANTIATE_SINGLETON_1( AuctionHouseMgr ); + +AuctionHouseMgr::AuctionHouseMgr() +{ +} + +AuctionHouseMgr::~AuctionHouseMgr() +{ + for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) + delete itr->second; +} + +AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap( uint32 factionTemplateId ) +{ + 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) + return &mNeutralAuctions; + else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) + return &mAllianceAuctions; + else if(u_entry->ourMask & FACTION_MASK_HORDE) + return &mHordeAuctions; + else + return &mNeutralAuctions; +} + +uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem) +{ + uint32 deposit = pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME ); + + return uint32(deposit * entry->depositPercent * 3 * sWorld.getRate(RATE_AUCTION_DEPOSIT) / 100.0f ); +} + +//does not clear ram +void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ) +{ + Item *pItem = GetAItem(auction->item_guidlow); + if(!pItem) + return; + + 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) ) + { + uint32 bidder_security = 0; + std::string bidder_name; + if (bidder) + { + bidder_accId = bidder->GetSession()->GetAccountId(); + bidder_security = bidder->GetSession()->GetSecurity(); + bidder_name = bidder->GetName(); + } + else + { + bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid); + bidder_security = accmgr.GetSecurity(bidder_accId); + + if(bidder_security > SEC_PLAYER ) // not do redundant DB requests + { + if(!objmgr.GetPlayerNameByGUID(bidder_guid,bidder_name)) + bidder_name = objmgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); + } + } + + if( bidder_security > SEC_PLAYER ) + { + std::string owner_name; + if(!objmgr.GetPlayerNameByGUID(auction->owner,owner_name)) + owner_name = objmgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); + + uint32 owner_accid = objmgr.GetPlayerAccountIdByGUID(auction->owner); + + sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", + 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) + { + std::ostringstream msgAuctionWonSubject; + msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON; + + std::ostringstream msgAuctionWonBody; + 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() ); + + //prepare mail data... : + 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 + CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow()); + CharacterDatabase.CommitTransaction(); + + MailItemsInfo mi; + 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 !! + + // 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 ) +{ + uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); + Player *owner = objmgr.GetPlayer(owner_guid); + + // owner exist (online or offline) + if(owner || objmgr.GetPlayerAccountIdByGUID(owner_guid)) + { + std::ostringstream msgAuctionSalePendingSubject; + msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING; + + std::ostringstream msgAuctionSalePendingBody; + uint32 auctionCut = auction->GetAuctionCut(); + + time_t distrTime = time(NULL) + HOUR; + + msgAuctionSalePendingBody.width(16); + msgAuctionSalePendingBody << std::right << std::hex << auction->bidder; + msgAuctionSalePendingBody << std::dec << ":" << auction->bid << ":" << auction->buyout; + msgAuctionSalePendingBody << ":" << auction->deposit << ":" << auctionCut << ":0:"; + msgAuctionSalePendingBody << secsToTimeBitFields(distrTime); + + sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_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 ) +{ + 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); + + // owner exist + if(owner || owner_accId) + { + std::ostringstream msgAuctionSuccessfulSubject; + msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL; + + std::ostringstream auctionSuccessfulBody; + uint32 auctionCut = auction->GetAuctionCut(); + + auctionSuccessfulBody.width(16); + auctionSuccessfulBody << std::right << std::hex << auction->bidder; + auctionSuccessfulBody << std::dec << ":" << auction->bid << ":" << auction->buyout; + auctionSuccessfulBody << ":" << auction->deposit << ":" << auctionCut; + + sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); + + uint32 itemTextId = objmgr.CreateItemText( auctionSuccessfulBody.str() ); + + uint32 profit = auction->bid + auction->deposit - auctionCut; + + if (owner) + { + //send auction owner notification, bidder must be current! + 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, HOUR); + } +} + +//does not clear ram +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); + 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); + + // owner exist + 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 !! + + 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" ); + + if( !result ) + { + barGoLink bar(1); + bar.step(); + sLog.outString(""); + sLog.outString(">> Loaded 0 auction items"); + return; + } + + barGoLink bar( result->GetRowCount() ); + + uint32 count = 0; + + Field *fields; + do + { + bar.step(); + + fields = result->Fetch(); + uint32 item_guid = fields[1].GetUInt32(); + uint32 item_template = fields[2].GetUInt32(); + + ItemPrototype const *proto = objmgr.GetItemPrototype(item_template); + + if(!proto) + { + 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)) + { + delete item; + continue; + } + AddAItem(item); + + ++count; + } + while( result->NextRow() ); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u auction items", count ); +} + +void AuctionHouseMgr::LoadAuctions() +{ + QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse"); + if( !result ) + { + barGoLink bar(1); + bar.step(); + sLog.outString(""); + sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty."); + return; + } + + Field *fields = result->Fetch(); + uint32 AuctionCount=fields[0].GetUInt32(); + delete result; + + if(!AuctionCount) + { + barGoLink bar(1); + bar.step(); + sLog.outString(""); + sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty."); + return; + } + + 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(); + sLog.outString(""); + sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty."); + return; + } + + barGoLink bar( AuctionCount ); + + AuctionEntry *aItem; + + do + { + fields = result->Fetch(); + + bar.step(); + + aItem = new AuctionEntry; + aItem->Id = fields[0].GetUInt32(); + aItem->auctioneer = fields[1].GetUInt32(); + aItem->item_guidlow = fields[2].GetUInt32(); + aItem->item_template = fields[3].GetUInt32(); + aItem->owner = fields[4].GetUInt32(); + aItem->buyout = fields[5].GetUInt32(); + aItem->expire_time = fields[6].GetUInt32(); + aItem->bidder = fields[7].GetUInt32(); + aItem->bid = fields[8].GetUInt32(); + aItem->startbid = fields[9].GetUInt32(); + aItem->deposit = fields[10].GetUInt32(); + + CreatureData const* auctioneerData = objmgr.GetCreatureData(aItem->auctioneer); + if(!auctioneerData) + { + aItem->DeleteFromDB(); + sLog.outError("Auction %u has not a existing auctioneer (GUID : %u)", aItem->Id, aItem->auctioneer); + delete aItem; + continue; + } + + CreatureInfo const* auctioneerInfo = objmgr.GetCreatureTemplate(auctioneerData->id); + if(!auctioneerInfo) + { + aItem->DeleteFromDB(); + sLog.outError("Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", aItem->Id, aItem->auctioneer,auctioneerData->id); + delete aItem; + continue; + } + + aItem->auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(auctioneerInfo->faction_A); + if(!aItem->auctionHouseEntry) + { + aItem->DeleteFromDB(); + sLog.outError("Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u", + aItem->Id, aItem->auctioneer,auctioneerData->id,auctioneerInfo->faction_A); + delete aItem; + continue; + } + + // 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 ) ) + { + aItem->DeleteFromDB(); + sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow); + delete aItem; + continue; + } + + GetAuctionsMap( auctioneerInfo->faction_A )->AddAuction(aItem); + + } while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u auctions", AuctionCount ); +} + +void AuctionHouseMgr::AddAItem( Item* it ) +{ + ASSERT( it ); + ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end()); + mAitems[it->GetGUIDLow()] = it; +} + +bool AuctionHouseMgr::RemoveAItem( uint32 id ) +{ + ItemMap::iterator i = mAitems.find(id); + if (i == mAitems.end()) + { + return false; + } + mAitems.erase(i); + return true; +} + +void AuctionHouseMgr::Update() +{ + mHordeAuctions.Update(); + mAllianceAuctions.Update(); + mNeutralAuctions.Update(); +} + +AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId) +{ + uint32 houseid = 7; // goblin auction house + + 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. + // but no easy way convert creature faction to player race faction for specific city + switch(factionTemplateId) + { + case 12: houseid = 1; break; // human + case 29: houseid = 6; break; // orc, and generic for horde + case 55: houseid = 2; break; // dwarf, and generic for alliance + case 68: houseid = 4; break; // undead + case 80: houseid = 3; break; // n-elf + case 104: houseid = 5; break; // trolls + case 120: houseid = 7; break; // booty bay, neutral + case 474: houseid = 7; break; // gadgetzan, neutral + case 855: houseid = 7; break; // everlook, neutral + case 1604: houseid = 6; break; // b-elfs, + default: // for unknown case + { + FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); + if(!u_entry) + houseid = 7; // goblin auction house + else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) + houseid = 1; // human auction house + else if(u_entry->ourMask & FACTION_MASK_HORDE) + houseid = 6; // orc auction house + else + houseid = 7; // goblin auction house + break; + } + } + } + + return sAuctionHouseStore.LookupEntry(houseid); +} + +void AuctionHouseObject::Update() +{ + time_t curTime = sWorld.GetGameTime(); + ///- Handle expired auctions + AuctionEntryMap::iterator next; + for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end();itr = next) + { + next = itr; + ++next; + if (curTime > (itr->second->expire_time)) + { + ///- Either cancel the auction if there was no bidder + if (itr->second->bidder == 0) + { + auctionmgr.SendAuctionExpiredMail( itr->second ); + } + ///- Or perform the transaction + else + { + //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 ); + } + + ///- In any case clear the auction + itr->second->DeleteFromDB(); + auctionmgr.RemoveAItem(itr->second->item_guidlow); + delete itr->second; + RemoveAuction(itr->first); + } + } +} + +void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount) +{ + for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr) + { + AuctionEntry *Aentry = itr->second; + if( Aentry && Aentry->bidder == player->GetGUIDLow() ) + { + if (itr->second->BuildAuctionInfo(data)) + ++count; + ++totalcount; + } + } +} + +void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount) +{ + for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr) + { + AuctionEntry *Aentry = itr->second; + if( Aentry && Aentry->owner == player->GetGUIDLow() ) + { + if(Aentry->BuildAuctionInfo(data)) + ++count; + ++totalcount; + } + } +} + +void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player, + std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable, + uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, + uint32& count, uint32& totalcount) +{ + int loc_idx = player->GetSession()->GetSessionDbLocaleIndex(); + + for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr) + { + AuctionEntry *Aentry = itr->second; + Item *item = auctionmgr.GetAItem(Aentry->item_guidlow); + if (!item) + continue; + + ItemPrototype const *proto = item->GetProto(); + + if (itemClass != (0xffffffff) && proto->Class != itemClass) + continue; + + if (itemSubClass != (0xffffffff) && proto->SubClass != itemSubClass) + continue; + + if (inventoryType != (0xffffffff) && proto->InventoryType != inventoryType) + continue; + + if (quality != (0xffffffff) && proto->Quality != quality) + continue; + + if( levelmin != (0x00) && (proto->RequiredLevel < levelmin || levelmax != (0x00) && proto->RequiredLevel > levelmax ) ) + continue; + + if( usable != (0x00) && player->CanUseItem( item ) != EQUIP_ERR_OK ) + continue; + + std::string name = proto->Name1; + if(name.empty()) + continue; + + // local name + if ( loc_idx >= 0 ) + { + ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId); + if (il) + { + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) + name = il->Name[loc_idx]; + } + } + + if( !wsearchedname.empty() && !Utf8FitTo(name, wsearchedname) ) + continue; + + if ((count < 50) && (totalcount >= listfrom)) + { + ++count; + Aentry->BuildAuctionInfo(data); + } + ++totalcount; + } +} + +//this function inserts to WorldPacket auction's data +bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const +{ + Item *pItem = auctionmgr.GetAItem(item_guidlow); + if (!pItem) + { + sLog.outError("auction to item, that doesn't exist !!!!"); + return false; + } + data << (uint32) Id; + data << (uint32) pItem->GetEntry(); + + for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++) + { + data << (uint32) pItem->GetEnchantmentId(EnchantmentSlot(i)); + data << (uint32) pItem->GetEnchantmentDuration(EnchantmentSlot(i)); + data << (uint32) pItem->GetEnchantmentCharges(EnchantmentSlot(i)); + } + + data << (uint32) pItem->GetItemRandomPropertyId(); //random item property id + data << (uint32) pItem->GetItemSuffixFactor(); //SuffixFactor + data << (uint32) pItem->GetCount(); //item->count + data << (uint32) pItem->GetSpellCharges(); //item->charge FFFFFFF + data << (uint32) 0; //Unknown + data << (uint64) owner; //Auction->owner + data << (uint32) startbid; //Auction->startbid (not sure if useful) + data << (uint32) (bid ? GetAuctionOutBid() : 0); + //minimal outbid + data << (uint32) buyout; //auction->buyout + data << (uint32) (expire_time - time(NULL))* 1000; //time left + data << (uint64) bidder; //auction->bidder current + data << (uint32) bid; //current bid + return true; +} + +uint32 AuctionEntry::GetAuctionCut() const +{ + return uint32(auctionHouseEntry->cutPercent * bid * sWorld.getRate(RATE_AUCTION_CUT) / 100.f); +} + +/// 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; + if (!outbid) + outbid = 1; + return outbid; +} + +void AuctionEntry::DeleteFromDB() const +{ + //No SQL injection (Id is integer) + CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",Id); +} + +void AuctionEntry::SaveToDB() const +{ + //No SQL injection (no strings) + CharacterDatabase.PExecute("INSERT INTO auctionhouse (id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit) " + "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u')", + Id, auctioneer, item_guidlow, item_template, owner, buyout, (uint64)expire_time, bidder, bid, startbid, deposit); +} diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h new file mode 100644 index 00000000000..cfc68497e47 --- /dev/null +++ b/src/game/AuctionHouseMgr.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> + * + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _AUCTION_HOUSE_MGR_H +#define _AUCTION_HOUSE_MGR_H + +#include "SharedDefines.h" +#include "Policies/Singleton.h" + +class Item; +class Player; +class WorldPacket; + +#define MIN_AUCTION_TIME (12*HOUR) + +enum AuctionError +{ + AUCTION_OK = 0, + AUCTION_INTERNAL_ERROR = 2, + AUCTION_NOT_ENOUGHT_MONEY = 3, + AUCTION_ITEM_NOT_FOUND = 4, + CANNOT_BID_YOUR_AUCTION_ERROR = 10 +}; + +enum AuctionAction +{ + AUCTION_SELL_ITEM = 0, + AUCTION_CANCEL = 1, + AUCTION_PLACE_BID = 2 +}; + +struct AuctionEntry +{ + uint32 Id; + uint32 auctioneer; // creature low guid + uint32 item_guidlow; + uint32 item_template; + uint32 owner; + uint32 startbid; //maybe useless + uint32 bid; + uint32 buyout; + time_t expire_time; + uint32 bidder; + uint32 deposit; //deposit can be calculated only when creating auction + AuctionHouseEntry const* auctionHouseEntry; // in AuctionHouse.dbc + + // helpers + uint32 GetHouseId() const { return auctionHouseEntry->houseId; } + uint32 GetHouseFaction() const { return auctionHouseEntry->faction; } + uint32 GetAuctionCut() const; + uint32 GetAuctionOutBid() const; + bool BuildAuctionInfo(WorldPacket & data) const; + void DeleteFromDB() const; + void SaveToDB() const; +}; + +//this class is used as auctionhouse instance +class AuctionHouseObject +{ + public: + AuctionHouseObject() {} + ~AuctionHouseObject() + { + for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) + delete itr->second; + } + + typedef std::map<uint32, AuctionEntry*> AuctionEntryMap; + + uint32 Getcount() { return AuctionsMap.size(); } + + AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();} + AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();} + + void AddAuction(AuctionEntry *ah) + { + ASSERT( ah ); + AuctionsMap[ah->Id] = ah; + } + + AuctionEntry* GetAuction(uint32 id) const + { + AuctionEntryMap::const_iterator itr = AuctionsMap.find( id ); + return itr != AuctionsMap.end() ? itr->second : NULL; + } + + bool RemoveAuction(uint32 id) + { + return AuctionsMap.erase(id) ? true : false; + } + + void Update(); + + void BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount); + void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount); + void BuildListAuctionItems(WorldPacket& data, Player* player, + std::wstring const& searchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable, + uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, + uint32& count, uint32& totalcount); + + private: + AuctionEntryMap AuctionsMap; +}; + +class AuctionHouseMgr +{ + public: + AuctionHouseMgr(); + ~AuctionHouseMgr(); + + typedef UNORDERED_MAP<uint32, Item*> ItemMap; + + AuctionHouseObject* GetAuctionsMap( uint32 factionTemplateId ); + + Item* GetAItem(uint32 id) + { + ItemMap::const_iterator itr = mAitems.find(id); + if (itr != mAitems.end()) + { + return itr->second; + } + return NULL; + } + + //auction messages + 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); + + public: + //load first auction items, because of check if item exists, when loading + void LoadAuctionItems(); + void LoadAuctions(); + + void AddAItem(Item* it); + bool RemoveAItem(uint32 id); + + void Update(); + + private: + AuctionHouseObject mHordeAuctions; + AuctionHouseObject mAllianceAuctions; + AuctionHouseObject mNeutralAuctions; + + ItemMap mAitems; +}; + +#define auctionmgr Trinity::Singleton<AuctionHouseMgr>::Instance() + +#endif diff --git a/src/game/AuctionHouseObject.h b/src/game/AuctionHouseObject.h deleted file mode 100644 index 83fd19d19c6..00000000000 --- a/src/game/AuctionHouseObject.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> - * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _AUCTION_HOUSE_H -#define _AUCTION_HOUSE_H - -#include "SharedDefines.h" - -#define MIN_AUCTION_TIME (12*HOUR) - -enum AuctionError -{ - AUCTION_OK = 0, - AUCTION_INTERNAL_ERROR = 2, - AUCTION_NOT_ENOUGHT_MONEY = 3, - AUCTION_ITEM_NOT_FOUND = 4, - CANNOT_BID_YOUR_AUCTION_ERROR = 10 -}; - -enum AuctionAction -{ - AUCTION_SELL_ITEM = 0, - AUCTION_CANCEL = 1, - AUCTION_PLACE_BID = 2 -}; - -struct AuctionEntry -{ - uint32 Id; - uint32 auctioneer; - uint32 item_guidlow; - uint32 item_template; - uint32 owner; - uint32 startbid; //maybe useless - uint32 bid; - uint32 buyout; - time_t time; - uint32 bidder; - uint32 deposit; //deposit can be calculated only when creating auction - uint32 location; -}; - -//this class is used as auctionhouse instance -class AuctionHouseObject -{ - public: - AuctionHouseObject() {} - ~AuctionHouseObject() - { - for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) - delete itr->second; - } - - typedef std::map<uint32, AuctionEntry*> AuctionEntryMap; - - uint32 Getcount() { return AuctionsMap.size(); } - - AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();} - AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();} - - void AddAuction(AuctionEntry *ah) - { - ASSERT( ah ); - AuctionsMap[ah->Id] = ah; - } - - AuctionEntry* GetAuction(uint32 id) const - { - AuctionEntryMap::const_iterator itr = AuctionsMap.find( id ); - if( itr != AuctionsMap.end() ) - return itr->second; - return NULL; - } - - bool RemoveAuction(uint32 id) - { - AuctionEntryMap::iterator i = AuctionsMap.find(id); - if (i == AuctionsMap.end()) - { - return false; - } - AuctionsMap.erase(i); - return true; - } - - private: - AuctionEntryMap AuctionsMap; -}; -#endif - diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index ccaab6cf6bc..8ef926b4aaf 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -621,42 +621,29 @@ void BattleGround::RewardMark(Player *plr,uint32 count) if(plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) return; - BattleGroundMarks mark; - bool IsSpell; + if(!plr || !count) + return; + + BattleGroundMarks mark; switch(GetTypeID()) { case BATTLEGROUND_AV: - IsSpell = true; - if(count == ITEM_WINNER_COUNT) - mark = SPELL_AV_MARK_WINNER; - else - mark = SPELL_AV_MARK_LOSER; + mark = ITEM_AV_MARK_OF_HONOR; break; case BATTLEGROUND_WS: - IsSpell = true; - if(count == ITEM_WINNER_COUNT) - mark = SPELL_WS_MARK_WINNER; - else - mark = SPELL_WS_MARK_LOSER; + mark = ITEM_WS_MARK_OF_HONOR; break; case BATTLEGROUND_AB: - IsSpell = true; - if(count == ITEM_WINNER_COUNT) - mark = SPELL_AB_MARK_WINNER; - else - mark = SPELL_AB_MARK_LOSER; + mark = ITEM_AB_MARK_OF_HONOR; break; - case BATTLEGROUND_EY: - IsSpell = false; + case BATTLEGROUND_EY: mark = ITEM_EY_MARK_OF_HONOR; break; default: return; } - if(IsSpell) - plr->CastSpell(plr, mark, true); - else if ( objmgr.GetItemPrototype( mark ) ) + if ( objmgr.GetItemPrototype( mark ) ) { ItemPosCountVec dest; uint32 no_space_count = 0; @@ -664,7 +651,7 @@ void BattleGround::RewardMark(Player *plr,uint32 count) if( msg != EQUIP_ERR_OK ) // convert to possible store amount count -= no_space_count; - if( count != 0 && !dest.empty()) // can add some + if(!dest.empty()) // can add some if(Item* item = plr->StoreNewItem( dest, mark, true, 0)) plr->SendNewItem(item,count,false,true); diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index b28ce709ada..a0e0d94e6e8 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -50,12 +50,9 @@ enum BattleGroundQuests enum BattleGroundMarks { - SPELL_WS_MARK_LOSER = 24950, - SPELL_WS_MARK_WINNER = 24951, - SPELL_AB_MARK_LOSER = 24952, - SPELL_AB_MARK_WINNER = 24953, - SPELL_AV_MARK_LOSER = 24954, - SPELL_AV_MARK_WINNER = 24955, + ITEM_AV_MARK_OF_HONOR = 20560, + ITEM_WS_MARK_OF_HONOR = 20558, + ITEM_AB_MARK_OF_HONOR = 20559, ITEM_EY_MARK_OF_HONOR = 29024 }; diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index 500b00feb46..3a8c5668a7a 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -441,7 +441,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target } //Alliance flag on ground(not in base) (returned or picked up again from ground!) - if(this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10)) + if(this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->id == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY) { if(Source->GetTeam() == ALLIANCE) { @@ -470,7 +470,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target } //Horde flag on ground(not in base) (returned or picked up again) - if(this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10)) + if(this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->id == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY) { if(Source->GetTeam() == HORDE) { diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h index 61898f92255..c804c250209 100644 --- a/src/game/BattleGroundWS.h +++ b/src/game/BattleGroundWS.h @@ -23,9 +23,14 @@ #include "BattleGround.h" -#define BG_WS_MAX_TEAM_SCORE 3 -#define BG_WS_FLAG_RESPAWN_TIME 23000 -#define BG_WS_FLAG_DROP_TIME 10000 +enum BG_WS_TimerOrScore +{ + BG_WS_MAX_TEAM_SCORE = 3, + BG_WS_FLAG_RESPAWN_TIME = 23000, + BG_WS_FLAG_DROP_TIME = 10000, + BG_WS_SPELL_FORCE_TIME = 600000, + BG_WS_SPELL_BRUTAL_TIME = 900000 +}; enum BG_WS_Sound { @@ -43,7 +48,9 @@ enum BG_WS_SpellId BG_WS_SPELL_WARSONG_FLAG = 23333, BG_WS_SPELL_WARSONG_FLAG_DROPPED = 23334, BG_WS_SPELL_SILVERWING_FLAG = 23335, - BG_WS_SPELL_SILVERWING_FLAG_DROPPED = 23336 + BG_WS_SPELL_SILVERWING_FLAG_DROPPED = 23336, + BG_WS_SPELL_FOCUSED_ASSAULT = 46392, + BG_WS_SPELL_BRUTAL_ASSAULT = 46393 }; enum BG_WS_WorldStates @@ -94,7 +101,9 @@ enum BG_WS_ObjectEntry BG_OBJECT_DOOR_H_3_WS_ENTRY = 180322, BG_OBJECT_DOOR_H_4_WS_ENTRY = 180322, BG_OBJECT_A_FLAG_WS_ENTRY = 179830, - BG_OBJECT_H_FLAG_WS_ENTRY = 179831 + BG_OBJECT_H_FLAG_WS_ENTRY = 179831, + BG_OBJECT_A_FLAG_GROUND_WS_ENTRY = 179785, + BG_OBJECT_H_FLAG_GROUND_WS_ENTRY = 179786 }; enum BG_WS_FlagState @@ -151,6 +160,10 @@ class BattleGroundWS : public BattleGround void RespawnFlag(uint32 Team, bool captured); void RespawnFlagAfterDrop(uint32 Team); uint8 GetFlagState(uint32 team) { return m_FlagState[GetTeamIndexByTeamId(team)]; } + void AddTimedAura(uint32 aura); + void RemoveTimedAura(uint32 aura); + bool IsBrutalTimerDone; + bool IsForceTimerDone; /* Battleground Events */ virtual void EventPlayerDroppedFlag(Player *Source); @@ -183,6 +196,9 @@ class BattleGroundWS : public BattleGround uint32 m_TeamScores[2]; int32 m_FlagsTimer[2]; int32 m_FlagsDropTimer[2]; + + int32 m_FlagSpellForceTimer; + int32 m_FlagSpellBrutalTimer; }; #endif diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index bcd85792b04..1f8cd447449 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -12,10 +12,11 @@ SET(game_STAT_SRCS ArenaTeam.cpp ArenaTeam.h ArenaTeamHandler.cpp - AuctionHouse.cpp AuctionHouseBot.cpp AuctionHouseBot.h - AuctionHouseObject.h + AuctionHouseHandler.cpp + AuctionHouseMgr.cpp + AuctionHouseMgr.h Bag.cpp Bag.h BattleGround.cpp diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index f64877095ed..ee8d78383aa 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -247,6 +247,7 @@ ChatCommand * ChatHandler::getCommandTable() { "areatrigger_tavern", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAreaTriggerTavernCommand, "", NULL }, { "areatrigger_teleport", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAreaTriggerTeleportCommand, "", NULL }, + { "access_requirement", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAccessRequirementCommand, "", NULL }, { "areatrigger_involvedrelation",SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, { "event_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventScriptsCommand, "", NULL }, { "command", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCommandCommand, "", NULL }, @@ -299,6 +300,7 @@ ChatCommand * ChatHandler::getCommandTable() { "locales_npc_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesNpcTextCommand, "", NULL }, { "locales_page_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesPageTextCommand, "", NULL }, { "locales_quest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesQuestCommand, "", NULL }, + { "auctions", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAuctionsCommand, "", NULL }, { "waypoint_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadWpScriptsCommand, "", NULL }, { "gm_tickets", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMTicketReloadCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index e6474968606..c66d5e4dee7 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -222,6 +222,7 @@ class ChatHandler bool HandleReloadWpScriptsCommand(const char* args); bool HandleReloadAreaTriggerTavernCommand(const char* args); bool HandleReloadAreaTriggerTeleportCommand(const char* args); + bool HandleReloadAccessRequirementCommand(const char* args); bool HandleReloadEventScriptsCommand(const char* args); bool HandleReloadCommandCommand(const char* args); bool HandleReloadCreatureQuestRelationsCommand(const char* args); @@ -274,6 +275,7 @@ class ChatHandler bool HandleReloadLocalesNpcTextCommand(const char* args); bool HandleReloadLocalesPageTextCommand(const char* args); bool HandleReloadLocalesQuestCommand(const char* args); + bool HandleReloadAuctionsCommand(const char* args); bool HandleInstanceListBindsCommand(const char* args); bool HandleInstanceUnbindCommand(const char* args); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 23ae8229251..00e826404e6 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -132,7 +132,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { assistant->SetNoCallAssistance(true); assistant->CombatStart(victim); - if(assistant->AI()) + if(assistant->IsAIEnabled) assistant->AI()->AttackStart(victim); } } @@ -141,7 +141,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) } Creature::Creature() : -Unit(), i_AI(NULL), i_AI_possessed(NULL), +Unit(), i_AI(NULL), lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), m_lootMoney(0), m_lootRecipient(0), m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), @@ -169,12 +169,6 @@ Creature::~Creature() delete i_AI; i_AI = NULL; - - if (i_AI_possessed) - { - delete i_AI_possessed; - i_AI_possessed = NULL; - } } void Creature::AddToWorld() @@ -490,7 +484,7 @@ void Creature::Update(uint32 diff) if(!isAlive()) break; - if(!IsInEvadeMode() && m_AI_enabled) + if(!IsInEvadeMode() && IsAIEnabled) { // do not allow the AI to be changed during update m_AI_locked = true; @@ -607,36 +601,10 @@ bool Creature::AIM_Initialize(CreatureAI* ai) i_AI = ai ? ai : FactorySelector::selectAI(this); if (oldAI) delete oldAI; - m_AI_enabled = true; + IsAIEnabled = true; return true; } -void Creature::InitPossessedAI() -{ - if (!isPossessed()) return; - - if (!i_AI_possessed) - i_AI_possessed = new PossessedAI(this); - - // Signal the old AI that it's been disabled - i_AI->OnPossess(true); - - if(!(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CHARM_AI)) - m_AI_enabled = false; -} - -void Creature::DisablePossessedAI() -{ - if (!i_AI_possessed) return; - - delete i_AI_possessed; - - // Signal the old AI that it's been re-enabled - i_AI->OnPossess(false); - - m_AI_enabled = true; -} - bool Creature::Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data) { SetMapId(map->GetId()); diff --git a/src/game/Creature.h b/src/game/Creature.h index ea81053aab3..fc5318c1cdb 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -132,7 +132,7 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature CREATURE_FLAG_EXTRA_WORLDEVENT = 0x00004000, // custom flag for world event creatures (left room for merging) - CREATURE_FLAG_EXTRA_CHARM_AI = 0x00008000, // use ai when charmed + //CREATURE_FLAG_EXTRA_CHARM_AI = 0x00008000, // use ai when charmed CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00010000, // cannot be taunted }; @@ -402,7 +402,6 @@ typedef std::map<uint32,time_t> CreatureSpellCooldowns; class TRINITY_DLL_SPEC Creature : public Unit { CreatureAI *i_AI; - CreatureAI *i_AI_possessed; public: @@ -467,11 +466,9 @@ class TRINITY_DLL_SPEC Creature : public Unit bool IsInEvadeMode() const; bool AIM_Initialize(CreatureAI* ai = NULL); - void InitPossessedAI(); - void DisablePossessedAI(); void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); - CreatureAI* AI() { return isPossessed() && i_AI_possessed ? i_AI_possessed : i_AI; } + CreatureAI* AI() { return i_AI; } uint32 GetShieldBlockValue() const //dunno mob block value { diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 409463b0052..fa512fce726 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -36,6 +36,12 @@ void UnitAI::AttackStart(Unit *victim) } } +//Enable PlayerAI when charmed +void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; } + +//Disable CreatureAI when charmed +void CreatureAI::OnCharmed(bool apply) { me->IsAIEnabled = !apply; } + void CreatureAI::MoveInLineOfSight(Unit *who) { if(!me->getVictim() && me->canStartAttack(who)) diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index a259475b543..fbfb8605866 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -78,6 +78,9 @@ class TRINITY_DLL_SPEC UnitAI UnitAI(Unit *u) : me(u) {} virtual void AttackStart(Unit *); virtual void UpdateAI(const uint32 diff) = 0; + + // Called when unit is charmed + virtual void OnCharmed(bool apply) = 0; }; class TRINITY_DLL_SPEC PlayerAI : public UnitAI @@ -86,6 +89,8 @@ class TRINITY_DLL_SPEC PlayerAI : public UnitAI Player *me; public: PlayerAI(Player *p) : UnitAI((Unit*)p), me(p) {} + + void OnCharmed(bool apply); }; class TRINITY_DLL_SPEC SimpleCharmedAI : public PlayerAI @@ -140,8 +145,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI // Called at waypoint reached or point movement finished virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {} - // Called when AI is temporarily replaced or put back when possess is applied or removed - virtual void OnPossess(bool apply) {} + void OnCharmed(bool apply); }; struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature> diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 0ae3656fc9d..fd3e16e79d7 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -113,12 +113,15 @@ void DynamicObject::Update(uint32 p_time) else deleteThis = true; - if(m_updateTimer < p_time) + if(m_effIndex < 4) { - Trinity::DynamicObjectUpdater notifier(*this,caster); - VisitNearbyObject(GetRadius(), notifier); - m_updateTimer = 500; // is this official-like? - }else m_updateTimer -= p_time; + if(m_updateTimer < p_time) + { + Trinity::DynamicObjectUpdater notifier(*this,caster); + VisitNearbyObject(GetRadius(), notifier); + m_updateTimer = 500; // is this official-like? + }else m_updateTimer -= p_time; + } if(deleteThis) { diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index f516035ea16..fcb4e376b26 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -30,23 +30,6 @@ using namespace Trinity; -/*void -Trinity::PlayerNotifier::Visit(PlayerMapType &m) -{ - for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - { - if( iter->getSource() == &i_player ) - continue; - - iter->getSource()->UpdateVisibilityOf(&i_player); - i_player.UpdateVisibilityOf(iter->getSource()); - - if (!i_player.GetSharedVisionList().empty()) - for (SharedVisionList::const_iterator it = i_player.GetSharedVisionList().begin(); it != i_player.GetSharedVisionList().end(); ++it) - (*it)->UpdateVisibilityOf(iter->getSource()); - } -}*/ - void VisibleChangesNotifier::Visit(PlayerMapType &m) { @@ -60,27 +43,7 @@ VisibleChangesNotifier::Visit(PlayerMapType &m) } void -VisibleNotifier::Visit(PlayerMapType &m) -{ - for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - { - if( iter->getSource() == &i_player ) - continue; - - iter->getSource()->UpdateVisibilityOf(&i_player); - //i_player.UpdateVisibilityOf(iter->getSource()); - - //if (!i_player.GetSharedVisionList().empty()) - // for (SharedVisionList::const_iterator it = i_player.GetSharedVisionList().begin(); it != i_player.GetSharedVisionList().end(); ++it) - // (*it)->UpdateVisibilityOf(iter->getSource()); - - i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); - i_clientGUIDs.erase(iter->getSource()->GetGUID()); - } -} - -void -VisibleNotifier::Notify() +PlayerVisibilityNotifier::Notify() { // at this moment i_clientGUIDs have guids that not iterate at grid level checks // but exist one case when this possible and object not out of range: transports @@ -146,7 +109,7 @@ VisibleNotifier::Notify() // send data at target visibility change (adding to client) for(std::set<WorldObject*>::const_iterator vItr = i_visibleNow.begin(); vItr != i_visibleNow.end(); ++vItr) if((*vItr)!=&i_player && (*vItr)->isType(TYPEMASK_UNIT)) - i_player.SendAuraDurationsForTarget((Unit*)(*vItr)); + i_player.SendInitialVisiblePackets((Unit*)(*vItr)); } void diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index b7b0a9d4292..8e427366f1a 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -38,16 +38,7 @@ class Player; namespace Trinity { - - /*struct TRINITY_DLL_DECL PlayerNotifier - { - explicit PlayerNotifier(Player &pl) : i_player(pl) {} - void Visit(PlayerMapType &); - template<class SKIP> void Visit(GridRefManager<SKIP> &) {} - Player &i_player; - };*/ - - struct TRINITY_DLL_DECL VisibleNotifier + struct TRINITY_DLL_DECL PlayerVisibilityNotifier { Player &i_player; UpdateData i_data; @@ -55,12 +46,38 @@ namespace Trinity Player::ClientGUIDs i_clientGUIDs; std::set<WorldObject*> i_visibleNow; - explicit VisibleNotifier(Player &player) : i_player(player),i_clientGUIDs(player.m_clientGUIDs) {} - template<class T> void Visit(GridRefManager<T> &m); - void Visit(PlayerMapType &); + PlayerVisibilityNotifier(Player &player) : i_player(player),i_clientGUIDs(player.m_clientGUIDs) {} + + template<class T> inline void Visit(GridRefManager<T> &); + /*#ifdef WIN32 + template<> inline void Visit(PlayerMapType &); + template<> inline void Visit(CreatureMapType &); + #endif*/ + void Notify(void); }; + struct TRINITY_DLL_DECL PlayerRelocationNotifier : public PlayerVisibilityNotifier + { + PlayerRelocationNotifier(Player &player) : PlayerVisibilityNotifier(player) {} + template<class T> inline void Visit(GridRefManager<T> &m) { PlayerVisibilityNotifier::Visit(m); } + #ifdef WIN32 + template<> inline void Visit(PlayerMapType &); + template<> inline void Visit(CreatureMapType &); + #endif + }; + + struct TRINITY_DLL_DECL CreatureRelocationNotifier + { + Creature &i_creature; + CreatureRelocationNotifier(Creature &c) : i_creature(c) {} + template<class T> void Visit(GridRefManager<T> &) {} + #ifdef WIN32 + template<> inline void Visit(PlayerMapType &); + template<> inline void Visit(CreatureMapType &); + #endif + }; + struct TRINITY_DLL_DECL VisibleChangesNotifier { WorldObject &i_object; @@ -168,25 +185,6 @@ namespace Trinity template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} }; - struct TRINITY_DLL_DECL PlayerRelocationNotifier - { - Player &i_player; - PlayerRelocationNotifier(Player &pl) : i_player(pl) {} - template<class T> void Visit(GridRefManager<T> &) {} - void Visit(PlayerMapType &); - void Visit(CreatureMapType &); - }; - - struct TRINITY_DLL_DECL CreatureRelocationNotifier - { - Creature &i_creature; - CreatureRelocationNotifier(Creature &c) : i_creature(c) {} - template<class T> void Visit(GridRefManager<T> &) {} - #ifdef WIN32 - template<> void Visit(PlayerMapType &); - #endif - }; - struct TRINITY_DLL_DECL DynamicObjectUpdater { DynamicObject &i_dynobject; @@ -968,10 +966,10 @@ namespace Trinity }; #ifndef WIN32 - template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &); - template<> void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &); - template<> void CreatureRelocationNotifier::Visit<Player>(PlayerMapType &); - template<> void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType &); + template<> inline void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &); + template<> inline void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &); + template<> inline void CreatureRelocationNotifier::Visit<Player>(PlayerMapType &); + template<> inline void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType &); template<> inline void DynamicObjectUpdater::Visit<Creature>(CreatureMapType &); template<> inline void DynamicObjectUpdater::Visit<Player>(PlayerMapType &); #endif diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 57fde9423d5..4fe61076b18 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -29,17 +29,6 @@ #include "CreatureAI.h" #include "SpellAuras.h" -template<class T> -inline void -Trinity::VisibleNotifier::Visit(GridRefManager<T> &m) -{ - for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) - { - i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); - i_clientGUIDs.erase(iter->getSource()->GetGUID()); - } -} - inline void Trinity::ObjectUpdater::Visit(CreatureMapType &m) { @@ -48,33 +37,15 @@ Trinity::ObjectUpdater::Visit(CreatureMapType &m) iter->getSource()->Update(i_timeDiff); } -inline void -Trinity::PlayerRelocationNotifier::Visit(PlayerMapType &m) -{ - for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - { - if(&i_player==iter->getSource()) - continue; - - // visibility for players updated by ObjectAccessor::UpdateVisibilityFor calls in appropriate places - - // Cancel Trade - if(i_player.GetTrader()==iter->getSource()) - // iteraction distance - if(!i_player.IsWithinDistInMap(iter->getSource(), 5)) - i_player.GetSession()->SendCancelTrade(); // will clode both side trade windows - } -} - inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c) { - // update creature visibility at player/creature move - pl->UpdateVisibilityOf(c); + if(!pl->isAlive() || !c->isAlive() || pl->isInFlight()) + return; // Creature AI reaction if(c->HasReactState(REACT_AGGRESSIVE) && !c->hasUnitState(UNIT_STAT_SIGHTLESS)) { - if( c->AI() && c->IsWithinSightDist(pl) && !c->IsInEvadeMode() ) + if( c->IsAIEnabled && c->IsWithinSightDist(pl) && !c->IsInEvadeMode() ) c->AI()->MoveInLineOfSight(pl); } } @@ -83,38 +54,83 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) { if(c1->HasReactState(REACT_AGGRESSIVE) && !c1->hasUnitState(UNIT_STAT_SIGHTLESS)) { - if( c1->AI() && c1->IsWithinSightDist(c2) && !c1->IsInEvadeMode() ) + if( c1->IsAIEnabled && c1->IsWithinSightDist(c2) && !c1->IsInEvadeMode() ) c1->AI()->MoveInLineOfSight(c2); } if(c2->HasReactState(REACT_AGGRESSIVE) && !c2->hasUnitState(UNIT_STAT_SIGHTLESS)) { - if( c2->AI() && c1->IsWithinSightDist(c2) && !c2->IsInEvadeMode() ) + if( c2->IsAIEnabled && c1->IsWithinSightDist(c2) && !c2->IsInEvadeMode() ) c2->AI()->MoveInLineOfSight(c1); } } +template<class T> +inline void +Trinity::PlayerVisibilityNotifier::Visit(GridRefManager<T> &m) +{ + for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) + { + i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); + i_clientGUIDs.erase(iter->getSource()->GetGUID()); + } +} + +template<> +inline void +Trinity::PlayerRelocationNotifier::Visit(PlayerMapType &m) +{ + for(PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + i_clientGUIDs.erase(iter->getSource()->GetGUID()); + + if(iter->getSource()->m_Notified) //self is also skipped in this check + continue; + + i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); + iter->getSource()->UpdateVisibilityOf(&i_player); + + //if (!i_player.GetSharedVisionList().empty()) + // for (SharedVisionList::const_iterator it = i_player.GetSharedVisionList().begin(); it != i_player.GetSharedVisionList().end(); ++it) + // (*it)->UpdateVisibilityOf(iter->getSource()); + + // Cancel Trade + if(i_player.GetTrader()==iter->getSource()) + if(!i_player.IsWithinDistInMap(iter->getSource(), 5)) // iteraction distance + i_player.GetSession()->SendCancelTrade(); // will clode both side trade windows + } +} + +template<> inline void Trinity::PlayerRelocationNotifier::Visit(CreatureMapType &m) { - if(!i_player.isAlive() || i_player.isInFlight()) - return; + for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + i_clientGUIDs.erase(iter->getSource()->GetGUID()); - for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - if( !iter->getSource()->m_Notified && iter->getSource()->isAlive()) - PlayerCreatureRelocationWorker(&i_player,iter->getSource()); + if(iter->getSource()->m_Notified) + continue; + + i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); + + PlayerCreatureRelocationWorker(&i_player, iter->getSource()); + } } template<> inline void Trinity::CreatureRelocationNotifier::Visit(PlayerMapType &m) { - if(!i_creature.isAlive()) - return; + for(PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + if(iter->getSource()->m_Notified) + continue; - for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - if( !iter->getSource()->m_Notified && iter->getSource()->isAlive() && !iter->getSource()->isInFlight()) - PlayerCreatureRelocationWorker(iter->getSource(), &i_creature); + iter->getSource()->UpdateVisibilityOf(&i_creature); + + PlayerCreatureRelocationWorker(iter->getSource(), &i_creature); + } } template<> @@ -124,11 +140,15 @@ Trinity::CreatureRelocationNotifier::Visit(CreatureMapType &m) if(!i_creature.isAlive()) return; - for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { - Creature* c = iter->getSource(); - if( !iter->getSource()->m_Notified && c != &i_creature && c->isAlive()) - CreatureCreatureRelocationWorker(c, &i_creature); + if(iter->getSource()->m_Notified) + continue; + + if(!iter->getSource()->isAlive()) + continue; + + CreatureCreatureRelocationWorker(iter->getSource(), &i_creature); } } diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index c4dd39b8be7..26a701fc507 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -2118,7 +2118,7 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args) return true; } - guidlow = target->GetGUIDLow(); + guidlow = target->GetDBTableGUIDLow(); QueryResult *result = WorldDatabase.PQuery( "SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow); if( result ) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 0dd5c7a176d..20c4396eee8 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1,7 +1,7 @@ /* -* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> +* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * -* Copyright (C) 2008 Trinity <http://www.trinitycore.org/> +* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ #include "WorldSession.h" #include "World.h" #include "ObjectMgr.h" +#include "AuctionHouseMgr.h" #include "AccountMgr.h" #include "PlayerDump.h" #include "SpellMgr.h" @@ -149,28 +150,42 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) char * param6 = strtok(NULL, " "); char * param7 = strtok(NULL, " "); char * param8 = strtok(NULL, " "); - if ((!ahMapIdStr) || (!param1) || (!param2) || (!param3) || (!param4) || (!param5) || (!param6) || (!param7) || (!param8)) - { - PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8"); - PSendSysMessage("1 WhiteTradeGoods 2 GreenTradeGoods 3 BlueTradeGoods 4 PurpleTradeGoods"); - PSendSysMessage("5 WhiteItems 6 GreenItems 7 BlueItems 8 PurpleItems"); + char * param9 = strtok(NULL, " "); + char * param10 = strtok(NULL, " "); + char * param11 = strtok(NULL, " "); + char * param12 = strtok(NULL, " "); + char * param13 = strtok(NULL, " "); + char * param14 = strtok(NULL, " "); + if ((!ahMapIdStr) || (!param14)) + { + PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14"); + PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods"); + PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems"); + PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems"); PSendSysMessage("The total must add up to 100%"); return false; } - uint32 wtg = (uint32) strtoul(param1, NULL, 0); - uint32 gtg = (uint32) strtoul(param2, NULL, 0); - uint32 btg = (uint32) strtoul(param3, NULL, 0); - uint32 ptg = (uint32) strtoul(param4, NULL, 0); - uint32 wi = (uint32) strtoul(param5, NULL, 0); - uint32 gi = (uint32) strtoul(param6, NULL, 0); - uint32 bi = (uint32) strtoul(param7, NULL, 0); - uint32 pi = (uint32) strtoul(param8, NULL, 0); - uint32 totalPercent = wtg + gtg + btg + ptg + wi + gi + bi + pi; + uint32 greytg = (uint32) strtoul(param1, NULL, 0); + uint32 whitetg = (uint32) strtoul(param2, NULL, 0); + uint32 greentg = (uint32) strtoul(param3, NULL, 0); + uint32 bluetg = (uint32) strtoul(param3, NULL, 0); + uint32 purpletg = (uint32) strtoul(param5, NULL, 0); + uint32 orangetg = (uint32) strtoul(param6, NULL, 0); + uint32 yellowtg = (uint32) strtoul(param7, NULL, 0); + uint32 greyi = (uint32) strtoul(param8, NULL, 0); + uint32 whitei = (uint32) strtoul(param9, NULL, 0); + uint32 greeni = (uint32) strtoul(param10, NULL, 0); + uint32 bluei = (uint32) strtoul(param11, NULL, 0); + uint32 purplei = (uint32) strtoul(param12, NULL, 0); + uint32 orangei = (uint32) strtoul(param13, NULL, 0); + uint32 yellowi = (uint32) strtoul(param14, NULL, 0); + uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi; if ((totalPercent == 0) || (totalPercent != 100)) { - PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8"); - PSendSysMessage("1 WhiteTradeGoods 2 GreenTradeGoods 3 BlueTradeGoods 4 PurpleTradeGoods"); - PSendSysMessage("5 WhiteItems 6 GreenItems 7 BlueItems 8 PurpleItems"); + PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14"); + PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods"); + PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems"); + PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems"); PSendSysMessage("The total must add up to 100%"); return false; } @@ -191,6 +206,18 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) strcat(param, param7); strcat(param, " "); strcat(param, param8); + strcat(param, " "); + strcat(param, param9); + strcat(param, " "); + strcat(param, param10); + strcat(param, " "); + strcat(param, param11); + strcat(param, " "); + strcat(param, param12); + strcat(param, " "); + strcat(param, param13); + strcat(param, " "); + strcat(param, param14); AuctionHouseBotCommands(5, ahMapID, NULL, param); } else if (strncmp(opt,"minprice",l) == 0) @@ -199,10 +226,14 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) char * param2 = strtok(NULL, " "); if ((!ahMapIdStr) || (!param1) || (!param2)) { - PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } - if (strncmp(param1,"white",l) == 0) + if (strncmp(param1,"grey",l) == 0) + { + AuctionHouseBotCommands(6, ahMapID, AHB_GREY, param2); + } + else if (strncmp(param1,"white",l) == 0) { AuctionHouseBotCommands(6, ahMapID, AHB_WHITE, param2); } @@ -214,13 +245,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) { AuctionHouseBotCommands(6, ahMapID, AHB_BLUE, param2); } - else if (strncmp(param1,"purple",l) == 0) + else if (strncmp(param1,"purple",l) == 0) { AuctionHouseBotCommands(6, ahMapID, AHB_PURPLE, param2); } + else if (strncmp(param1,"orange",l) == 0) + { + AuctionHouseBotCommands(6, ahMapID, AHB_ORANGE, param2); + } + else if (strncmp(param1,"yellow",l) == 0) + { + AuctionHouseBotCommands(6, ahMapID, AHB_YELLOW, param2); + } else { - PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } } @@ -230,10 +269,14 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) char * param2 = strtok(NULL, " "); if ((!ahMapIdStr) || (!param1) || (!param2)) { - PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } - if (strncmp(param1,"white",l) == 0) + if (strncmp(param1,"grey",l) == 0) + { + AuctionHouseBotCommands(7, ahMapID, AHB_GREY, param2); + } + else if (strncmp(param1,"white",l) == 0) { AuctionHouseBotCommands(7, ahMapID, AHB_WHITE, param2); } @@ -245,13 +288,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) { AuctionHouseBotCommands(7, ahMapID, AHB_BLUE, param2); } - else if (strncmp(param1,"purple",l) == 0) + else if (strncmp(param1,"purple",l) == 0) { AuctionHouseBotCommands(7, ahMapID, AHB_PURPLE, param2); } + else if (strncmp(param1,"orange",l) == 0) + { + AuctionHouseBotCommands(7, ahMapID, AHB_ORANGE, param2); + } + else if (strncmp(param1,"yellow",l) == 0) + { + AuctionHouseBotCommands(7, ahMapID, AHB_YELLOW, param2); + } else { - PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } } @@ -261,7 +312,7 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) char * param2 = strtok(NULL, " "); if ((!ahMapIdStr) || (!param1) || (!param2)) { - PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } uint32 minBidPrice = (uint32) strtoul(param2, NULL, 0); @@ -270,7 +321,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) PSendSysMessage("The min bid price multiplier must be between 1 and 100"); return false; } - if (strncmp(param1,"white",l) == 0) + if (strncmp(param1,"grey",l) == 0) + { + AuctionHouseBotCommands(8, ahMapID, AHB_GREY, param2); + } + else if (strncmp(param1,"white",l) == 0) { AuctionHouseBotCommands(8, ahMapID, AHB_WHITE, param2); } @@ -282,13 +337,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) { AuctionHouseBotCommands(8, ahMapID, AHB_BLUE, param2); } - else if (strncmp(param1,"purple",l) == 0) + else if (strncmp(param1,"purple",l) == 0) { AuctionHouseBotCommands(8, ahMapID, AHB_PURPLE, param2); } + else if (strncmp(param1,"orange",l) == 0) + { + AuctionHouseBotCommands(8, ahMapID, AHB_ORANGE, param2); + } + else if (strncmp(param1,"yellow",l) == 0) + { + AuctionHouseBotCommands(8, ahMapID, AHB_YELLOW, param2); + } else { - PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } } @@ -298,7 +361,7 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) char * param2 = strtok(NULL, " "); if ((!ahMapIdStr) || (!param1) || (!param2)) { - PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } uint32 maxBidPrice = (uint32) strtoul(param2, NULL, 0); @@ -307,7 +370,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) PSendSysMessage("The max bid price multiplier must be between 1 and 100"); return false; } - if (strncmp(param1,"white",l) == 0) + if (strncmp(param1,"grey",l) == 0) + { + AuctionHouseBotCommands(9, ahMapID, AHB_GREY, param2); + } + else if (strncmp(param1,"white",l) == 0) { AuctionHouseBotCommands(9, ahMapID, AHB_WHITE, param2); } @@ -319,13 +386,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) { AuctionHouseBotCommands(9, ahMapID, AHB_BLUE, param2); } - else if (strncmp(param1,"purple",l) == 0) + else if (strncmp(param1,"purple",l) == 0) { AuctionHouseBotCommands(9, ahMapID, AHB_PURPLE, param2); } + else if (strncmp(param1,"orange",l) == 0) + { + AuctionHouseBotCommands(9, ahMapID, AHB_ORANGE, param2); + } + else if (strncmp(param1,"yellow",l) == 0) + { + AuctionHouseBotCommands(9, ahMapID, AHB_YELLOW, param2); + } else { - PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price"); + PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price"); return false; } } @@ -335,7 +410,7 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) char * param2 = strtok(NULL, " "); if ((!ahMapIdStr) || (!param1) || (!param2)) { - PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $value"); + PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value"); return false; } uint32 maxStack = (uint32) strtoul(param2, NULL, 0); @@ -344,7 +419,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) PSendSysMessage("maxstack can't be a negative number."); return false; } - if (strncmp(param1,"white",l) == 0) + if (strncmp(param1,"grey",l) == 0) + { + AuctionHouseBotCommands(10, ahMapID, AHB_GREY, param2); + } + else if (strncmp(param1,"white",l) == 0) { AuctionHouseBotCommands(10, ahMapID, AHB_WHITE, param2); } @@ -356,13 +435,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) { AuctionHouseBotCommands(10, ahMapID, AHB_BLUE, param2); } - else if (strncmp(param1,"purple",l) == 0) + else if (strncmp(param1,"purple",l) == 0) { AuctionHouseBotCommands(10, ahMapID, AHB_PURPLE, param2); } + else if (strncmp(param1,"orange",l) == 0) + { + AuctionHouseBotCommands(10, ahMapID, AHB_ORANGE, param2); + } + else if (strncmp(param1,"yellow",l) == 0) + { + AuctionHouseBotCommands(10, ahMapID, AHB_YELLOW, param2); + } else { - PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $value"); + PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value"); return false; } } @@ -375,7 +462,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price"); return false; } - if (strncmp(param1,"white",l) == 0) + if (strncmp(param1,"grey",l) == 0) + { + AuctionHouseBotCommands(11, ahMapID, AHB_GREY, param2); + } + else if (strncmp(param1,"white",l) == 0) { AuctionHouseBotCommands(11, ahMapID, AHB_WHITE, param2); } @@ -387,10 +478,18 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) { AuctionHouseBotCommands(11, ahMapID, AHB_BLUE, param2); } - else if (strncmp(param1,"purple",l) == 0) + else if (strncmp(param1,"purple",l) == 0) { AuctionHouseBotCommands(11, ahMapID, AHB_PURPLE, param2); } + else if (strncmp(param1,"orange",l) == 0) + { + AuctionHouseBotCommands(11, ahMapID, AHB_ORANGE, param2); + } + else if (strncmp(param1,"yellow",l) == 0) + { + AuctionHouseBotCommands(11, ahMapID, AHB_YELLOW, param2); + } else { PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price"); @@ -572,6 +671,14 @@ bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*) return true; } +bool ChatHandler::HandleReloadAccessRequirementCommand(const char*) +{ + sLog.outString( "Re-Loading Access Requirement definitions..." ); + objmgr.LoadAccessRequirements(); + SendGlobalGMSysMessage("DB table `access_requirement` reloaded."); + return true; + } + bool ChatHandler::HandleReloadCommandCommand(const char*) { load_command_table = true; @@ -1093,6 +1200,16 @@ bool ChatHandler::HandleLoadScriptsCommand(const char* args) return true; } +bool ChatHandler::HandleReloadAuctionsCommand(const char* args) +{ + ///- Reload dynamic data tables from the database + sLog.outString( "Re-Loading Auctions..." ); + auctionmgr.LoadAuctionItems(); + auctionmgr.LoadAuctions(); + SendGlobalGMSysMessage("Auctions reloaded."); + return true; +} + bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) { if(!*args) @@ -7029,6 +7146,7 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args) // Set gender player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); + player->SetByteValue(PLAYER_BYTES_3, 0, gender); // Change display ID player->SetDisplayId(new_displayId); diff --git a/src/game/Makefile.am b/src/game/Makefile.am index ec9cbab40cb..a8a42d26a61 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -49,10 +49,11 @@ $(srcdir)/AnimalRandomMovementGenerator.h \ $(srcdir)/ArenaTeam.cpp \ $(srcdir)/ArenaTeam.h \ $(srcdir)/ArenaTeamHandler.cpp \ -$(srcdir)/AuctionHouse.cpp \ +$(srcdir)/AuctionHouseHandler.cpp \ $(srcdir)/AuctionHouseBot.cpp \ $(srcdir)/AuctionHouseBot.h \ -$(srcdir)/AuctionHouseObject.h \ +$(srcdir)/AuctionHouseMgr.cpp \ +$(srcdir)/AuctionHouseMgr.h \ $(srcdir)/Bag.cpp \ $(srcdir)/Bag.h \ $(srcdir)/BattleGround.cpp \ diff --git a/src/game/Map.cpp b/src/game/Map.cpp index c6b0739b6bd..fbe87986903 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -257,7 +257,7 @@ template<> void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) { // add to world object registry in grid - if(obj->isPet() || obj->HasSharedVision()) + if(obj->isPet() || obj->IsTempWorldObject) { (*grid)(cell.CellX(), cell.CellY()).AddWorldObject<Creature>(obj, obj->GetGUID()); } @@ -309,7 +309,7 @@ template<> void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell) { // remove from world object registry in grid - if(obj->isPet() || obj->HasSharedVision()) + if(obj->isPet() || obj->IsTempWorldObject) { (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject<Creature>(obj, obj->GetGUID()); } @@ -339,20 +339,25 @@ void Map::SwitchGridContainers(T* obj, bool on) if(on) { - if(!grid.RemoveGridObject<T>(obj, obj->GetGUID()) + grid.RemoveGridObject<T>(obj, obj->GetGUID()); + grid.AddWorldObject<T>(obj, obj->GetGUID()); + /*if(!grid.RemoveGridObject<T>(obj, obj->GetGUID()) || !grid.AddWorldObject<T>(obj, obj->GetGUID())) { assert(false); - } + }*/ } else { - if(!grid.RemoveWorldObject<T>(obj, obj->GetGUID()) + grid.RemoveWorldObject<T>(obj, obj->GetGUID()); + grid.AddGridObject<T>(obj, obj->GetGUID()); + /*if(!grid.RemoveWorldObject<T>(obj, obj->GetGUID()) || !grid.AddGridObject<T>(obj, obj->GetGUID())) { assert(false); - } + }*/ } + obj->IsTempWorldObject = on; } template void Map::SwitchGridContainers(Creature *, bool); @@ -619,34 +624,15 @@ void Map::RelocationNotify() if(unit->GetTypeId() == TYPEID_PLAYER) { - //UpdatePlayerVisibility((Player*)unit, cell, val); - //Trinity::PlayerNotifier pl_notifier(*player); - //VisitWorld(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), pl_notifier); - - //UpdateObjectsVisibilityFor((Player*)unit, cell, val); - Trinity::VisibleNotifier ob_notifier(*((Player*)unit)); - VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), ob_notifier); - ob_notifier.Notify(); - Trinity::PlayerRelocationNotifier notifier(*((Player*)unit)); VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), notifier); + notifier.Notify(); } else { Trinity::CreatureRelocationNotifier notifier(*((Creature*)unit)); VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), notifier); } - - // Update visibility back to player who is controlling the unit - if(unit->GetSharedVisionList().size()) - { - for(SharedVisionList::const_iterator it = unit->GetSharedVisionList().begin(); it != unit->GetSharedVisionList().end(); ++it) - { - Trinity::VisibleNotifier ob_notifier(**it); - VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), ob_notifier); - ob_notifier.Notify(); - } - } } //Clear list @@ -763,6 +749,28 @@ void Map::Update(const uint32 &t_diff) } } } + + // Update bindsight players + if(obj->isType(TYPEMASK_UNIT)) + { + if(!((Unit*)obj)->GetSharedVisionList().empty()) + for(SharedVisionList::const_iterator itr = ((Unit*)obj)->GetSharedVisionList().begin(); itr != ((Unit*)obj)->GetSharedVisionList().end(); ++itr) + { + Trinity::PlayerVisibilityNotifier notifier(**itr); + VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier); + notifier.Notify(); + } + } + else if(obj->GetTypeId() == TYPEID_DYNAMICOBJECT) + { + if(Unit *caster = ((DynamicObject*)obj)->GetCaster()) + if(caster->GetTypeId() == TYPEID_PLAYER && caster->GetUInt64Value(PLAYER_FARSIGHT) == obj->GetGUID()) + { + Trinity::PlayerVisibilityNotifier notifier(*((Player*)caster)); + VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier); + notifier.Notify(); + } + } } } @@ -1010,7 +1018,6 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell); AddToGrid(c,getNGrid(new_cell.GridX(), new_cell.GridY()),new_cell); - c->SetCurrentCell(new_cell); } else { @@ -1048,10 +1055,8 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) #endif RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell); - { - EnsureGridCreated(GridPair(new_cell.GridX(), new_cell.GridY())); - AddToGrid(c,getNGrid(new_cell.GridX(), new_cell.GridY()),new_cell); - } + EnsureGridCreated(GridPair(new_cell.GridX(), new_cell.GridY())); + AddToGrid(c,getNGrid(new_cell.GridX(), new_cell.GridY()),new_cell); return true; } @@ -1709,7 +1714,7 @@ void Map::AddToActive( Creature* c ) AddToActiveHelper(c); // also not allow unloading spawn grid to prevent creating creature clone at load - if(c->GetDBTableGUIDLow()) + if(!c->isPet() && c->GetDBTableGUIDLow()) { float x,y,z; c->GetRespawnCoord(x,y,z); @@ -1730,7 +1735,7 @@ void Map::RemoveFromActive( Creature* c ) RemoveFromActiveHelper(c); // also allow unloading spawn grid - if(c->GetDBTableGUIDLow()) + if(!c->isPet() && c->GetDBTableGUIDLow()) { float x,y,z; c->GetRespawnCoord(x,y,z); diff --git a/src/game/Map.h b/src/game/Map.h index 42e66996d3b..23ae08d1167 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -98,11 +98,10 @@ struct CreatureMover struct InstanceTemplate { uint32 map; - uint32 parent; - uint32 levelMin; - uint32 levelMax; + uint32 parent; uint32 maxPlayers; uint32 reset_delay; + uint32 access_id; float startLocX; float startLocY; float startLocZ; @@ -372,6 +371,8 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O if(m_activeNonPlayersIter != m_activeNonPlayers.end()) { ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj); + if(itr == m_activeNonPlayers.end()) + return; if(itr==m_activeNonPlayersIter) ++m_activeNonPlayersIter; m_activeNonPlayers.erase(itr); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 4b736f83b2e..6a8cd130691 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -209,14 +209,12 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) } } - // TODO: move this to a map dependent location - /*if(i_data && i_data->IsEncounterInProgress()) - { - sLog.outDebug("MAP: Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), GetMapName()); - player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); - return(false); - }*/ - return true; + // Requirements + InstanceTemplate const* instance = objmgr.GetInstanceTemplate(mapid); + if(!instance) + return false; + + return player->Satisfy(objmgr.GetAccessRequirement(instance->access_id), mapid, true); } else return true; diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 742cc69ff25..6d0c94fa0ef 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -485,42 +485,48 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote) { - if(!result) - return; - - uint64 friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); - uint32 team = Player::TeamForRace((*result)[1].GetUInt8()); - - delete result; - + uint64 friendGuid; + uint32 team; + FriendsResult friendResult; + WorldSession * session = sWorld.FindSession(accountId); + if(!session || !session->GetPlayer()) return; + + friendResult = FRIEND_NOT_FOUND; + friendGuid = 0; - FriendsResult friendResult = FRIEND_NOT_FOUND; - if(friendGuid) + if(result) { - if(friendGuid==session->GetPlayer()->GetGUID()) - friendResult = FRIEND_SELF; - else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) - friendResult = FRIEND_ENEMY; - else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) - friendResult = FRIEND_ALREADY; - else + friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); + team = Player::TeamForRace((*result)[1].GetUInt8()); + + delete result; + + if(friendGuid) { - Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); - if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) - friendResult = FRIEND_ADDED_ONLINE; + if(friendGuid==session->GetPlayer()->GetGUID()) + friendResult = FRIEND_SELF; + else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) + friendResult = FRIEND_ENEMY; + else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) + friendResult = FRIEND_ALREADY; else - friendResult = FRIEND_ADDED_OFFLINE; - - if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) { - friendResult = FRIEND_LIST_FULL; - sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); - } + Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); + if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) + friendResult = FRIEND_ADDED_ONLINE; + else + friendResult = FRIEND_ADDED_OFFLINE; + if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) + { + friendResult = FRIEND_LIST_FULL; + sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); + } - session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); + session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); + } } } @@ -569,31 +575,37 @@ void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data ) void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId) { - if(!result) - return; - - uint64 IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); - - delete result; - + uint64 IgnoreGuid; + FriendsResult ignoreResult; + WorldSession * session = sWorld.FindSession(accountId); + if(!session || !session->GetPlayer()) return; + + ignoreResult = FRIEND_IGNORE_NOT_FOUND; + IgnoreGuid = 0; - FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; - if(IgnoreGuid) + if(result) { - if(IgnoreGuid==session->GetPlayer()->GetGUID()) //not add yourself - ignoreResult = FRIEND_IGNORE_SELF; - else if( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) ) - ignoreResult = FRIEND_IGNORE_ALREADY; - else - { - ignoreResult = FRIEND_IGNORE_ADDED; + IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); + + delete result; - // ignore list full - if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true)) - ignoreResult = FRIEND_IGNORE_FULL; + if(IgnoreGuid) + { + if(IgnoreGuid==session->GetPlayer()->GetGUID()) //not add yourself + ignoreResult = FRIEND_IGNORE_SELF; + else if( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) ) + ignoreResult = FRIEND_IGNORE_ALREADY; + else + { + ignoreResult = FRIEND_IGNORE_ADDED; + + // ignore list full + if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true)) + ignoreResult = FRIEND_IGNORE_FULL; + } } } @@ -842,60 +854,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if(!at) return; - if(!GetPlayer()->isGameMaster()) - { - uint32 missingLevel = 0; - if(GetPlayer()->getLevel() < at->requiredLevel && !sWorld.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL)) - missingLevel = at->requiredLevel; - - // must have one or the other, report the first one that's missing - uint32 missingItem = 0; - if(at->requiredItem) - { - if(!GetPlayer()->HasItemCount(at->requiredItem, 1) && - (!at->requiredItem2 || !GetPlayer()->HasItemCount(at->requiredItem2, 1))) - missingItem = at->requiredItem; - } - else if(at->requiredItem2 && !GetPlayer()->HasItemCount(at->requiredItem2, 1)) - missingItem = at->requiredItem2; - - uint32 missingKey = 0; - uint32 missingHeroicQuest = 0; - if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC) - { - if(at->heroicKey) - { - if(!GetPlayer()->HasItemCount(at->heroicKey, 1) && - (!at->heroicKey2 || !GetPlayer()->HasItemCount(at->heroicKey2, 1))) - missingKey = at->heroicKey; - } - else if(at->heroicKey2 && !GetPlayer()->HasItemCount(at->heroicKey2, 1)) - missingKey = at->heroicKey2; - - if(at->heroicQuest && !GetPlayer()->GetQuestRewardStatus(at->heroicQuest)) - missingHeroicQuest = at->heroicQuest; - } - - uint32 missingQuest = 0; - if(at->requiredQuest && !GetPlayer()->GetQuestRewardStatus(at->requiredQuest)) - missingQuest = at->requiredQuest; - - if(missingLevel || missingItem || missingKey || missingQuest || missingHeroicQuest) - { - // TODO: all this is probably wrong - if(missingItem) - SendAreaTriggerMessage(GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), at->requiredLevel, objmgr.GetItemPrototype(missingItem)->Name1); - else if(missingKey) - GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY2); - else if(missingHeroicQuest) - SendAreaTriggerMessage(at->heroicQuestFailedText.c_str()); - else if(missingQuest) - SendAreaTriggerMessage(at->requiredFailedText.c_str()); - else if(missingLevel) - SendAreaTriggerMessage(GetTrinityString(LANG_LEVEL_MINREQUIRED), missingLevel); - return; - } - } + if(!GetPlayer()->Satisfy(objmgr.GetAccessRequirement(at->access_id), at->target_mapId, true)) + return; GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT); } diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index 7bfae33c079..b64c17b6342 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -55,10 +55,13 @@ MotionMaster::Initialize() { MovementGenerator* movement = FactorySelector::selectMovementGenerator((Creature*)i_owner); push( movement == NULL ? &si_idleMovement : movement ); - top()->Initialize(*i_owner); + InitTop(); } else + { push(&si_idleMovement); + needInit[MOTION_SLOT_IDLE] = false; + } } MotionMaster::~MotionMaster() @@ -98,35 +101,37 @@ MotionMaster::UpdateMotion(uint32 diff) delete m_expList; m_expList = NULL; - if (empty()) + if(empty()) Initialize(); - - if (m_cleanFlag & MMCF_RESET) - { + else if(needInitTop()) + InitTop(); + else if (m_cleanFlag & MMCF_RESET) top()->Reset(*i_owner); - m_cleanFlag &= ~MMCF_RESET; - } + + m_cleanFlag &= ~MMCF_RESET; } } void MotionMaster::DirectClean(bool reset) { - while( !empty() && size() > 1 ) + while(size() > 1) { MovementGenerator *curr = top(); pop(); if(curr) DirectDelete(curr); } - if(reset) + if(needInitTop()) + InitTop(); + else if(reset) top()->Reset(*i_owner); } void MotionMaster::DelayedClean() { - while( !empty() && size() > 1 ) + while(size() > 1) { MovementGenerator *curr = top(); pop(); @@ -137,31 +142,33 @@ MotionMaster::DelayedClean() void MotionMaster::DirectExpire(bool reset) { - if( empty() || size() == 1 ) - return; - - MovementGenerator *curr = top(); - pop(); - DirectDelete(curr); + if(size() > 1 ) + { + MovementGenerator *curr = top(); + pop(); + DirectDelete(curr); + } while(!top()) --i_top; if(empty()) Initialize(); - if(reset) + else if(needInitTop()) + InitTop(); + else if(reset) top()->Reset(*i_owner); } void MotionMaster::DelayedExpire() { - if( empty() || size() == 1 ) - return; - - MovementGenerator *curr = top(); - pop(); - DelayedDelete(curr); + if(size() > 1 ) + { + MovementGenerator *curr = top(); + pop(); + DelayedDelete(curr); + } while(!top()) --i_top; @@ -396,7 +403,14 @@ void MotionMaster::Mutate(MovementGenerator *m, MovementSlot slot) { i_top = slot; } - m->Initialize(*i_owner); + + if(i_top > slot) + needInit[slot] = true; + else + { + m->Initialize(*i_owner); + needInit[slot] = false; + } Impl[slot] = m; } @@ -446,6 +460,12 @@ MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const return top()->GetMovementGeneratorType(); } +void MotionMaster::InitTop() +{ + top()->Initialize(*i_owner); + needInit[i_top] = false; +} + void MotionMaster::DirectDelete(_Ty curr) { if(isStatic(curr)) diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index d362e6574f0..bf3560da321 100644 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -68,18 +68,25 @@ class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *> //typedef std::stack<MovementGenerator *> Impl; typedef MovementGenerator* _Ty; _Ty Impl[MAX_MOTION_SLOT]; + bool needInit[MAX_MOTION_SLOT]; typedef std::vector<_Ty> ExpireList; int i_top; bool empty() const { return i_top < 0; } void pop() { Impl[i_top] = NULL; --i_top; } void push(_Ty _Val) { ++i_top; Impl[i_top] = _Val; } + + bool needInitTop() const { return needInit[i_top]; } + void InitTop(); public: explicit MotionMaster(Unit *unit) : i_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE), i_top(-1) { for(int i = 0; i < MAX_MOTION_SLOT; ++i) + { Impl[i] = NULL; + needInit[i] = true; + } } ~MotionMaster(); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 62ad688e52e..10eafcba93d 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1068,6 +1068,7 @@ WorldObject::WorldObject() mSemaphoreTeleport = false; m_isActive = false; + IsTempWorldObject = false; } void WorldObject::SetWorldObject(bool on) @@ -1600,7 +1601,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa pCreature->SetHomePosition(x, y, z, ang); pCreature->Summon(spwtype, despwtime); - if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI()) + if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->JustSummoned(pCreature); if(pCreature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && pCreature->m_spells[0]) diff --git a/src/game/Object.h b/src/game/Object.h index c6d5f73f3ed..1a7a70163ca 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -490,6 +490,8 @@ class TRINITY_DLL_SPEC WorldObject : public Object template<class NOTIFIER> void VisitNearbyObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); } template<class NOTIFIER> void VisitNearbyGridObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); } template<class NOTIFIER> void VisitNearbyWorldObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); } + bool IsTempWorldObject; + protected: explicit WorldObject(); std::string m_name; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 55af142a094..7da8e89b26b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -22,6 +22,7 @@ #include "Database/DatabaseEnv.h" #include "Database/SQLStorage.h" #include "Database/SQLStorageImpl.h" +#include "Policies/SingletonImp.h" #include "Log.h" #include "MapManager.h" @@ -35,7 +36,6 @@ #include "ArenaTeam.h" #include "Transports.h" #include "ProgressBar.h" -#include "Policies/SingletonImp.h" #include "Language.h" #include "GameEvent.h" #include "Spell.h" @@ -123,9 +123,9 @@ ObjectMgr::ObjectMgr() m_hiPetNumber = 1; m_ItemTextId = 1; m_mailid = 1; - m_auctionid = 1; m_guildId = 1; m_arenaTeamId = 1; + m_auctionid = 1; mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); mGuildBankTabPrice[0] = 100; @@ -178,9 +178,6 @@ ObjectMgr::~ObjectMgr() for (CachePlayerInfoMap::iterator itr = m_mPlayerInfoMap.begin(); itr != m_mPlayerInfoMap.end(); ++itr) delete itr->second; - for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) - delete itr->second; - for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) itr->second.Clear(); @@ -325,254 +322,6 @@ void ObjectMgr::RemoveArenaTeam(ArenaTeam* arenaTeam) mArenaTeamMap.erase( arenaTeam->GetId() ); } -AuctionHouseObject * ObjectMgr::GetAuctionsMap( uint32 location ) -{ - switch ( location ) - { - case 6: //horde - return & mHordeAuctions; - break; - case 2: //alliance - return & mAllianceAuctions; - break; - default: //neutral - return & mNeutralAuctions; - } -} - -uint32 ObjectMgr::GetAuctionCut(uint32 location, uint32 highBid) -{ - if (location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - return (uint32) (0.15f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); - else - return (uint32) (0.05f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); -} - -uint32 ObjectMgr::GetAuctionDeposit(uint32 location, uint32 time, Item *pItem) -{ - float percentance; // in 0..1 - if ( location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - percentance = 0.75f; - else - percentance = 0.15f; - - percentance *= sWorld.getRate(RATE_AUCTION_DEPOSIT); - - return uint32( percentance * pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME ) ); -} - -/// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c -uint32 ObjectMgr::GetAuctionOutBid(uint32 currentBid) -{ - uint32 outbid = (currentBid / 100) * 5; - if (!outbid) - outbid = 1; - return outbid; -} - -//does not clear ram -void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction ) -{ - Item *pItem = GetAItem(auction->item_guidlow); - if(!pItem) - return; - - uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); - Player *bidder = GetPlayer(bidder_guid); - - uint32 bidder_accId = 0; - - // data for gm.log - if( sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) - { - uint32 bidder_security = 0; - std::string bidder_name; - if (bidder) - { - bidder_accId = bidder->GetSession()->GetAccountId(); - bidder_security = bidder->GetSession()->GetSecurity(); - bidder_name = bidder->GetName(); - } - else - { - bidder_accId = GetPlayerAccountIdByGUID(bidder_guid); - bidder_security = accmgr.GetSecurity(bidder_accId); - - if(bidder_security > SEC_PLAYER ) // not do redundant DB requests - { - if(!GetPlayerNameByGUID(bidder_guid,bidder_name)) - bidder_name = GetTrinityStringForDBCLocale(LANG_UNKNOWN); - } - } - - if( bidder_security > SEC_PLAYER ) - { - std::string owner_name; - if(!GetPlayerNameByGUID(auction->owner,owner_name)) - owner_name = GetTrinityStringForDBCLocale(LANG_UNKNOWN); - - uint32 owner_accid = GetPlayerAccountIdByGUID(auction->owner); - - sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", - 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 = GetPlayerAccountIdByGUID(bidder_guid); - - // receiver exist - if(bidder || bidder_accId) - { - std::ostringstream msgAuctionWonSubject; - msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON; - - std::ostringstream msgAuctionWonBody; - 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() ); - - //prepare mail data... : - uint32 itemTextId = 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 - CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow()); - CharacterDatabase.CommitTransaction(); - - MailItemsInfo mi; - mi.AddItem(auction->item_guidlow, auction->item_template, pItem); - - if (bidder) - bidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, bidder_guid, 0, 0, auction->item_template); - else - RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! - - // will delete item or place to receiver mail list - WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, 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 ObjectMgr::SendAuctionSalePendingMail( AuctionEntry * auction ) -{ - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player *owner = GetPlayer(owner_guid); - - // owner exist (online or offline) - if(owner || GetPlayerAccountIdByGUID(owner_guid)) - { - std::ostringstream msgAuctionSalePendingSubject; - msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING; - - std::ostringstream msgAuctionSalePendingBody; - uint32 auctionCut = GetAuctionCut(auction->location, auction->bid); - - time_t distrTime = time(NULL) + HOUR; - - msgAuctionSalePendingBody.width(16); - msgAuctionSalePendingBody << std::right << std::hex << auction->bidder; - msgAuctionSalePendingBody << std::dec << ":" << auction->bid << ":" << auction->buyout; - msgAuctionSalePendingBody << ":" << auction->deposit << ":" << auctionCut << ":0:"; - msgAuctionSalePendingBody << secsToTimeBitFields(distrTime); - - sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); - - uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() ); - - WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, 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 ObjectMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) -{ - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player *owner = GetPlayer(owner_guid); - - uint32 owner_accId = 0; - if(!owner) - owner_accId = GetPlayerAccountIdByGUID(owner_guid); - - // owner exist - if(owner || owner_accId) - { - std::ostringstream msgAuctionSuccessfulSubject; - msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL; - - std::ostringstream auctionSuccessfulBody; - uint32 auctionCut = GetAuctionCut(auction->location, auction->bid); - - auctionSuccessfulBody.width(16); - auctionSuccessfulBody << std::right << std::hex << auction->bidder; - auctionSuccessfulBody << std::dec << ":" << auction->bid << ":" << auction->buyout; - auctionSuccessfulBody << ":" << auction->deposit << ":" << auctionCut; - - sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); - - uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() ); - - uint32 profit = auction->bid + auction->deposit - auctionCut; - - if (owner) - { - //send auction owner notification, bidder must be current! - owner->GetSession()->SendAuctionOwnerNotification( auction ); - } - - WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSuccessfulSubject.str(), itemTextId, NULL, profit, 0, MAIL_CHECK_MASK_AUCTION, HOUR); - } -} - -//does not clear ram -void ObjectMgr::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); - return; - } - - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player *owner = GetPlayer(owner_guid); - - uint32 owner_accId = 0; - if(!owner) - owner_accId = GetPlayerAccountIdByGUID(owner_guid); - - // owner exist - 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 !! - - 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->location, 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; - } -} - CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id) { return sCreatureStorage.LookupEntry<CreatureInfo>(id); @@ -1498,65 +1247,6 @@ uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(const std::string& name) const return 0; } -void ObjectMgr::LoadAuctions() -{ - QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse"); - if( !result ) - return; - - Field *fields = result->Fetch(); - uint32 AuctionCount=fields[0].GetUInt32(); - delete result; - - if(!AuctionCount) - return; - - result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit,location FROM auctionhouse" ); - if( !result ) - return; - - barGoLink bar( AuctionCount ); - - AuctionEntry *aItem; - - do - { - fields = result->Fetch(); - - bar.step(); - - aItem = new AuctionEntry; - aItem->Id = fields[0].GetUInt32(); - aItem->auctioneer = fields[1].GetUInt32(); - aItem->item_guidlow = fields[2].GetUInt32(); - aItem->item_template = fields[3].GetUInt32(); - aItem->owner = fields[4].GetUInt32(); - aItem->buyout = fields[5].GetUInt32(); - aItem->time = fields[6].GetUInt32(); - aItem->bidder = fields[7].GetUInt32(); - aItem->bid = fields[8].GetUInt32(); - aItem->startbid = fields[9].GetUInt32(); - aItem->deposit = fields[10].GetUInt32(); - aItem->location = fields[11].GetUInt8(); - //check if sold item exists - if ( GetAItem( aItem->item_guidlow ) ) - { - GetAuctionsMap( aItem->location )->AddAuction(aItem); - } - else - { - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",aItem->Id); - sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow); - delete aItem; - } - } while (result->NextRow()); - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u auctions", AuctionCount ); - sLog.outString(); -} - void ObjectMgr::LoadItemLocales() { mItemLocaleMap.clear(); // need for reload case @@ -1932,53 +1622,6 @@ void ObjectMgr::LoadItemPrototypes() sItemStore.Clear(); } -void ObjectMgr::LoadAuctionItems() -{ - QueryResult *result = CharacterDatabase.Query( "SELECT itemguid,item_template FROM auctionhouse" ); - - if( !result ) - return; - - barGoLink bar( result->GetRowCount() ); - - uint32 count = 0; - - Field *fields; - do - { - bar.step(); - - fields = result->Fetch(); - uint32 item_guid = fields[0].GetUInt32(); - uint32 item_template = fields[1].GetUInt32(); - - ItemPrototype const *proto = GetItemPrototype(item_template); - - if(!proto) - { - 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)) - { - delete item; - continue; - } - AddAItem(item); - - ++count; - } - while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u auction items", count ); -} - void ObjectMgr::LoadPetLevelInfo() { // Loading levels data @@ -5112,8 +4755,8 @@ void ObjectMgr::LoadAreaTriggerTeleports() uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - QueryResult *result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, heroic_required_quest_done, heroic_required_failed_quest_text, required_quest_done, required_failed_text, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); + // 0 1 2 3 4 5 6 + QueryResult *result = WorldDatabase.Query("SELECT id, access_id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); if( !result ) { @@ -5140,20 +4783,12 @@ void ObjectMgr::LoadAreaTriggerTeleports() AreaTrigger at; - at.requiredLevel = fields[1].GetUInt8(); - at.requiredItem = fields[2].GetUInt32(); - at.requiredItem2 = fields[3].GetUInt32(); - at.heroicKey = fields[4].GetUInt32(); - at.heroicKey2 = fields[5].GetUInt32(); - at.heroicQuest = fields[6].GetUInt32(); - at.heroicQuestFailedText = fields[7].GetCppString(); - at.requiredQuest = fields[8].GetUInt32(); - at.requiredFailedText = fields[9].GetCppString(); - at.target_mapId = fields[10].GetUInt32(); - at.target_X = fields[11].GetFloat(); - at.target_Y = fields[12].GetFloat(); - at.target_Z = fields[13].GetFloat(); - at.target_Orientation = fields[14].GetFloat(); + at.access_id = fields[1].GetUInt32(); + at.target_mapId = fields[2].GetUInt32(); + at.target_X = fields[3].GetFloat(); + at.target_Y = fields[4].GetFloat(); + at.target_Z = fields[5].GetFloat(); + at.target_Orientation = fields[6].GetFloat(); AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); if(!atEntry) @@ -5161,85 +4796,141 @@ void ObjectMgr::LoadAreaTriggerTeleports() sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); continue; } + + MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); + if(!mapEntry) + { + sLog.outErrorDb("Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Trigger_ID,at.target_mapId); + continue; + } - if(at.requiredItem) + if(at.target_X==0 && at.target_Y==0 && at.target_Z==0) { - ItemPrototype const *pProto = GetItemPrototype(at.requiredItem); - if(!pProto) - { - sLog.outError("Key item %u does not exist for trigger %u, removing key requirement.", at.requiredItem, Trigger_ID); - at.requiredItem = 0; - } + sLog.outErrorDb("Area trigger (ID:%u) target coordinates not provided.",Trigger_ID); + continue; } - if(at.requiredItem2) + + mAreaTriggers[Trigger_ID] = at; + + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); +} + +void ObjectMgr::LoadAccessRequirements() +{ + mAccessRequirements.clear(); // need for reload case + + uint32 count = 0; + + // 0 1 2 3 4 5 6 7 8 9 10 + QueryResult *result = WorldDatabase.Query("SELECT id, level_min, level_max, item, item2, heroic_key, heroic_key2, quest_done, quest_failed_text, heroic_quest_done, heroic_quest_failed_text FROM access_requirement"); + if( !result ) + { + + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u access requirement definitions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field *fields = result->Fetch(); + + bar.step(); + + ++count; + + uint32 requiremt_ID = fields[0].GetUInt32(); + + AccessRequirement ar; + + ar.levelMin = fields[1].GetUInt8(); + ar.levelMax = fields[2].GetUInt32(); + ar.item = fields[3].GetUInt32(); + ar.item2 = fields[4].GetUInt32(); + ar.heroicKey = fields[5].GetUInt32(); + ar.heroicKey2 = fields[6].GetUInt32(); + ar.quest = fields[7].GetUInt32(); + ar.questFailedText = fields[8].GetCppString(); + ar.heroicQuest = fields[9].GetUInt32(); + ar.heroicQuestFailedText = fields[10].GetCppString(); + + if(ar.item) { - ItemPrototype const *pProto = GetItemPrototype(at.requiredItem2); + ItemPrototype const *pProto = GetItemPrototype(ar.item); if(!pProto) { - sLog.outError("Second item %u not exist for trigger %u, remove key requirement.", at.requiredItem2, Trigger_ID); - at.requiredItem2 = 0; + sLog.outError("Key item %u does not exist for requirement %u, removing key requirement.", ar.item, requiremt_ID); + ar.item = 0; } } - if(at.heroicKey) + if(ar.item2) { - ItemPrototype const *pProto = GetItemPrototype(at.heroicKey); + ItemPrototype const *pProto = GetItemPrototype(ar.item2); if(!pProto) { - sLog.outError("Heroic key item %u not exist for trigger %u, remove key requirement.", at.heroicKey, Trigger_ID); - at.heroicKey = 0; + sLog.outError("Second item %u does not exist for requirement %u, removing key requirement.", ar.item2, requiremt_ID); + ar.item2 = 0; } } - if(at.heroicKey2) + if(ar.heroicKey) { - ItemPrototype const *pProto = GetItemPrototype(at.heroicKey2); + ItemPrototype const *pProto = GetItemPrototype(ar.heroicKey); if(!pProto) { - sLog.outError("Heroic second key item %u not exist for trigger %u, remove key requirement.", at.heroicKey2, Trigger_ID); - at.heroicKey2 = 0; + sLog.outError("Heroic key %u not exist for trigger %u, remove key requirement.", ar.heroicKey, requiremt_ID); + ar.heroicKey = 0; } } - if(at.heroicQuest) + if(ar.heroicKey2) { - if(!mQuestTemplates[at.heroicQuest]) + ItemPrototype const *pProto = GetItemPrototype(ar.heroicKey2); + if(!pProto) { - sLog.outErrorDb("Required Heroic Quest %u not exist for trigger %u, remove heroic quest done requirement.",at.heroicQuest,Trigger_ID); - at.heroicQuest = 0; + sLog.outError("Second heroic key %u not exist for trigger %u, remove key requirement.", ar.heroicKey2, requiremt_ID); + ar.heroicKey2 = 0; } } - if(at.requiredQuest) + if(ar.heroicQuest) + { + if(!mQuestTemplates[ar.heroicQuest]) + { + sLog.outErrorDb("Required Heroic Quest %u not exist for trigger %u, remove heroic quest done requirement.",ar.heroicQuest,requiremt_ID); + ar.heroicQuest = 0; + } + } + + if(ar.quest) { - if(!mQuestTemplates[at.requiredQuest]) + if(!mQuestTemplates[ar.quest]) { - sLog.outErrorDb("Required Quest %u not exist for trigger %u, remove quest done requirement.",at.requiredQuest,Trigger_ID); - at.requiredQuest = 0; + sLog.outErrorDb("Required Quest %u not exist for trigger %u, remove quest done requirement.",ar.quest,requiremt_ID); + ar.quest = 0; } } - MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); - if(!mapEntry) - { - sLog.outErrorDb("Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Trigger_ID,at.target_mapId); - continue; - } - - if(at.target_X==0 && at.target_Y==0 && at.target_Z==0) - { - sLog.outErrorDb("Area trigger (ID:%u) target coordinates not provided.",Trigger_ID); - continue; - } - - mAreaTriggers[Trigger_ID] = at; + mAccessRequirements[requiremt_ID] = ar; } while( result->NextRow() ); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); + sLog.outString( ">> Loaded %u access requirement definitions", count ); } AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const @@ -6598,6 +6289,7 @@ void ObjectMgr::LoadSpellDisabledEntrys() { m_DisabledPlayerSpells.clear(); // need for reload case m_DisabledCreatureSpells.clear(); + m_DisabledPetSpells.clear(); QueryResult *result = WorldDatabase.Query("SELECT entry, disable_mask FROM spell_disabled"); uint32 total_count = 0; @@ -6630,6 +6322,8 @@ void ObjectMgr::LoadSpellDisabledEntrys() m_DisabledPlayerSpells.insert(spellid); if(disable_mask & SPELL_DISABLE_CREATURE) m_DisabledCreatureSpells.insert(spellid); + if(disable_mask & SPELL_DISABLE_PET) + m_DisabledPetSpells.insert(spellid); ++total_count; } while ( result->NextRow() ); diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 5dbea9c0ce4..5489bf7e42f 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -34,7 +34,6 @@ #include "ItemPrototype.h" #include "NPCHandler.h" #include "Database/DatabaseEnv.h" -#include "AuctionHouseObject.h" #include "Mail.h" #include "Map.h" #include "ObjectAccessor.h" @@ -102,15 +101,7 @@ extern ScriptMapMap sWaypointScripts; struct AreaTrigger { - uint8 requiredLevel; - uint32 requiredItem; - uint32 requiredItem2; - uint32 heroicKey; - uint32 heroicKey2; - uint32 heroicQuest; - std::string heroicQuestFailedText; - uint32 requiredQuest; - std::string requiredFailedText; + uint32 access_id; uint32 target_mapId; float target_X; float target_Y; @@ -315,6 +306,8 @@ class ObjectMgr typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap; + typedef UNORDERED_MAP<uint32, AccessRequirement> AccessRequirementMap; + typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap; typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap; @@ -374,42 +367,6 @@ class ObjectMgr return sInstanceTemplate.LookupEntry<InstanceTemplate>(map); } - Item* GetAItem(uint32 id) - { - ItemMap::const_iterator itr = mAitems.find(id); - if (itr != mAitems.end()) - { - return itr->second; - } - return NULL; - } - void AddAItem(Item* it) - { - ASSERT( it ); - ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end()); - mAitems[it->GetGUIDLow()] = it; - } - bool RemoveAItem(uint32 id) - { - ItemMap::iterator i = mAitems.find(id); - if (i == mAitems.end()) - { - return false; - } - mAitems.erase(i); - return true; - } - AuctionHouseObject * GetAuctionsMap( uint32 location ); - - //auction messages - void SendAuctionWonMail( AuctionEntry * auction ); - void SendAuctionSalePendingMail( AuctionEntry * auction ); - void SendAuctionSuccessfulMail( AuctionEntry * auction ); - void SendAuctionExpiredMail( AuctionEntry * auction ); - static uint32 GetAuctionCut( uint32 location, uint32 highBid ); - static uint32 GetAuctionDeposit(uint32 location, uint32 time, Item *pItem); - static uint32 GetAuctionOutBid(uint32 currentBid); - PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const; PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const @@ -490,6 +447,14 @@ class ObjectMgr return NULL; } + AccessRequirement const* GetAccessRequirement(uint32 requirement) const + { + AccessRequirementMap::const_iterator itr = mAccessRequirements.find( requirement ); + if( itr != mAccessRequirements.end( ) ) + return &itr->second; + return NULL; + } + AreaTrigger const* GetGoBackTrigger(uint32 Map) const; uint32 GetAreaTriggerScriptId(uint32 trigger_id); @@ -565,6 +530,7 @@ class ObjectMgr void LoadGossipText(); void LoadAreaTriggerTeleports(); + void LoadAccessRequirements(); void LoadQuestAreaTriggers(); void LoadAreaTriggerScripts(); void LoadTavernAreaTriggers(); @@ -574,9 +540,6 @@ class ObjectMgr void LoadItemTexts(); void LoadPageTexts(); - //load first auction items, because of check if item exists, when loading - void LoadAuctionItems(); - void LoadAuctions(); void LoadPlayerInfo(); void LoadPetLevelInfo(); void LoadExplorationBaseXP(); @@ -749,6 +712,7 @@ class ObjectMgr void LoadSpellDisabledEntrys(); bool IsPlayerSpellDisabled(uint32 spellid) { return (m_DisabledPlayerSpells.count(spellid) != 0); } bool IsCreatureSpellDisabled(uint32 spellid) { return (m_DisabledCreatureSpells.count(spellid) != 0); } + bool IsPetSpellDisabled(uint32 spellid) { return (m_DisabledPetSpells.count(spellid) != 0); } int GetIndexForLocale(LocaleConstant loc); LocaleConstant GetLocaleForIndex(int i); @@ -844,14 +808,9 @@ class ObjectMgr ArenaTeamMap mArenaTeamMap; ItemMap mItems; - ItemMap mAitems; ItemTextMap mItemTexts; - AuctionHouseObject mHordeAuctions; - AuctionHouseObject mAllianceAuctions; - AuctionHouseObject mNeutralAuctions; - QuestAreaTriggerMap mQuestAreaTriggerMap; BattleMastersMap mBattleMastersMap; TavernAreaTriggerSet mTavernAreaTriggerSet; @@ -859,6 +818,7 @@ class ObjectMgr GossipTextMap mGossipText; AreaTriggerMap mAreaTriggers; AreaTriggerScriptMap mAreaTriggerScripts; + AccessRequirementMap mAccessRequirements; RepOnKillMap mRepOnKill; @@ -872,6 +832,7 @@ class ObjectMgr std::set<uint32> m_DisabledPlayerSpells; std::set<uint32> m_DisabledCreatureSpells; + std::set<uint32> m_DisabledPetSpells; GraveYardMap mGraveYardMap; diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp index 57f072ebbef..99b1c9a55f0 100644 --- a/src/game/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP.cpp @@ -56,7 +56,7 @@ void OutdoorPvPObjective::HandlePlayerActivityChanged(Player * plr) { if(m_CapturePointCreature) if(Creature * c = HashMapHolder<Creature>::Find(m_CapturePointCreature)) - if(c->AI()) + if(c->IsAIEnabled) c->AI()->MoveInLineOfSight(plr); } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 00452fc0d95..a5d80266242 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -83,12 +83,12 @@ Pet::Pet(PetType type) : Creature() m_auraUpdateMask = 0; // pets always have a charminfo, even if they are not actually charmed - CharmInfo* charmInfo = InitCharmInfo(this); + CharmInfo* charmInfo = InitCharmInfo(); if(type == MINI_PET || type == POSSESSED_PET) // always passive - charmInfo->SetReactState(REACT_PASSIVE); + SetReactState(REACT_PASSIVE); else if(type == GUARDIAN_PET) // always aggressive - charmInfo->SetReactState(REACT_AGGRESSIVE); + SetReactState(REACT_AGGRESSIVE); m_spells.clear(); m_Auras.clear(); @@ -253,7 +253,7 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32()); SetUInt64Value(UNIT_FIELD_CREATEDBY, owner->GetGUID()); - m_charmInfo->SetReactState( ReactStates( fields[6].GetUInt8() )); + SetReactState( ReactStates( fields[6].GetUInt8() )); m_loyaltyPoints = fields[7].GetInt32(); uint32 savedhealth = fields[13].GetUInt32(); @@ -445,7 +445,7 @@ void Pet::SavePetToDB(PetSaveMode mode) << GetNativeDisplayId() << ", " << getLevel() << ", " << GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ", " - << uint32(m_charmInfo->GetReactState()) << ", " + << uint32(GetReactState()) << ", " << m_loyaltyPoints << ", " << GetLoyaltyLevel() << ", " << m_TrainingPoints << ", " diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index f841d83fdb0..cf639f84db5 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -47,7 +47,6 @@ PetAI::PetAI(Creature *c) : CreatureAI(c), i_pet(*c), i_tracker(TIME_INTERVAL_LO void PetAI::MoveInLineOfSight(Unit *u) { if( !i_pet.getVictim() && i_pet.GetCharmInfo() && - i_pet.GetCharmInfo()->HasReactState(REACT_AGGRESSIVE) && i_pet.IsHostileTo( u ) && i_pet.canAttack(u) && u->isInAccessiblePlaceFor(&i_pet)) { @@ -181,7 +180,7 @@ void PetAI::UpdateAI(const uint32 diff) } else if(owner && i_pet.GetCharmInfo()) { - if(owner->isInCombat() && !(i_pet.GetCharmInfo()->HasReactState(REACT_PASSIVE) || i_pet.GetCharmInfo()->HasCommandState(COMMAND_STAY))) + if(owner->isInCombat() && !(i_pet.HasReactState(REACT_PASSIVE) || i_pet.GetCharmInfo()->HasCommandState(COMMAND_STAY))) { AttackStart(owner->getAttackerForHelper()); } diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 05c889b8cf9..b87193b7e9f 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -118,10 +118,9 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) //if(!pet->IsWithinLOSInMap(TargetUnit)) // return; - if(pet->GetTypeId() != TYPEID_PLAYER) + if(pet->GetTypeId() != TYPEID_PLAYER && ((Creature*)pet)->IsAIEnabled) { - if (((Creature*)pet)->AI()) - ((Creature*)pet)->AI()->AttackStart(TargetUnit); + ((Creature*)pet)->AI()->AttackStart(TargetUnit); //10% chance to play special pet attack talk, else growl if(((Creature*)pet)->isPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10) @@ -165,7 +164,8 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) case REACT_PASSIVE: //passive case REACT_DEFENSIVE: //recovery case REACT_AGGRESSIVE: //activete - charmInfo->SetReactState( ReactStates(spellid) ); + if(pet->GetTypeId() == TYPEID_UNIT) + ((Creature*)pet)->SetReactState( ReactStates(spellid) ); break; } break; @@ -241,7 +241,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) if(pet->getVictim()) pet->AttackStop(); pet->GetMotionMaster()->Clear(); - if (((Creature*)pet)->AI()) + if (((Creature*)pet)->IsAIEnabled) ((Creature*)pet)->AI()->AttackStart(unit_target); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 4114f4da4ac..6345a8d2d1f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -15227,6 +15227,70 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, uint64 player if(!player || has_solo) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND permanent = 0", GUID_LOPART(player_guid)); } +bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report) +{ + if(!isGameMaster() && ar) + { + uint32 LevelMin = 0; + if(getLevel() < ar->levelMin && !sWorld.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL)) + LevelMin = ar->levelMin; + + uint32 LevelMax = 0; + if(ar->levelMax >= ar->levelMin && getLevel() > ar->levelMax && !sWorld.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL)) + LevelMax = ar->levelMax; + + uint32 missingItem = 0; + if(ar->item) + { + if(!HasItemCount(ar->item, 1) && + (!ar->item2 || !HasItemCount(ar->item2, 1))) + missingItem = ar->item; + } + else if(ar->item2 && !HasItemCount(ar->item2, 1)) + missingItem = ar->item2; + + uint32 missingKey = 0; + uint32 missingHeroicQuest = 0; + if(GetDifficulty() == DIFFICULTY_HEROIC) + { + if(ar->heroicKey) + { + if(!HasItemCount(ar->heroicKey, 1) && + (!ar->heroicKey2 || !HasItemCount(ar->heroicKey2, 1))) + missingKey = ar->heroicKey; + } + else if(ar->heroicKey2 && !HasItemCount(ar->heroicKey2, 1)) + missingKey = ar->heroicKey2; + + if(ar->heroicQuest && !GetQuestRewardStatus(ar->heroicQuest)) + missingHeroicQuest = ar->heroicQuest; + } + + uint32 missingQuest = 0; + if(ar->quest && !GetQuestRewardStatus(ar->quest)) + missingQuest = ar->quest; + + if(LevelMin || LevelMax || missingItem || missingKey || missingQuest || missingHeroicQuest) + { + if(report) + { + if(missingItem) + GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), ar->levelMin, objmgr.GetItemPrototype(missingItem)->Name1); + else if(missingKey) + SendTransferAborted(target_map, TRANSFER_ABORT_DIFFICULTY2); + else if(missingHeroicQuest) + GetSession()->SendAreaTriggerMessage(ar->heroicQuestFailedText.c_str()); + else if(missingQuest) + GetSession()->SendAreaTriggerMessage(ar->questFailedText.c_str()); + else if(LevelMin) + GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED), LevelMin); + } + return false; + } + } + return true; +} + bool Player::_LoadHomeBind(QueryResult *result) { bool ok = false; @@ -16365,7 +16429,7 @@ void Player::PetSpellInitialize() CharmInfo *charmInfo = pet->GetCharmInfo(); //16 - data << (uint64)pet->GetGUID() << uint32(0x00000000) << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); + data << (uint64)pet->GetGUID() << uint32(0x00000000) << uint8(pet->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); for(uint32 i = 0; i < 10; i++) //40 { @@ -16474,7 +16538,7 @@ void Player::CharmSpellInitialize() data << (uint64)charm->GetGUID() << uint32(0x00000000); if(charm->GetTypeId() != TYPEID_PLAYER) - data << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()); + data << uint8(((Creature*)charm)->GetReactState()) << uint8(charmInfo->GetCommandState()); else data << uint8(0) << uint8(0); @@ -16721,19 +16785,7 @@ void Player::HandleStealthedUnitsDetection() sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i)); #endif - // target aura duration for caster show only if target exist at caster client - // send data at target visibility change (adding to client) - if((*i)!=this && (*i)->isType(TYPEMASK_UNIT)) - { - SendAuraDurationsForTarget(*i); - //if(((Unit*)(*i))->isAlive()) //should be always alive - { - if((*i)->GetTypeId()==TYPEID_UNIT) - ((Creature*)(*i))->SendMonsterMoveWithSpeedToCurrentDestination(this); - if(((Unit*)(*i))->getVictim()) - ((Unit*)(*i))->SendAttackStart(((Unit*)(*i))->getVictim()); - } - } + SendInitialVisiblePackets(*i); } } } @@ -17717,21 +17769,24 @@ void Player::UpdateVisibilityOf(WorldObject* target) // target aura duration for caster show only if target exist at caster client // send data at target visibility change (adding to client) - if(target!=this && target->isType(TYPEMASK_UNIT)) - { - SendAuraDurationsForTarget((Unit*)target); - if(((Unit*)target)->isAlive()) - { - if(target->GetTypeId()==TYPEID_UNIT) - ((Creature*)target)->SendMonsterMoveWithSpeedToCurrentDestination(this); - if(((Unit*)target)->getVictim()) - ((Unit*)target)->SendAttackStart(((Unit*)target)->getVictim()); - } - } + if(target->isType(TYPEMASK_UNIT)) + SendInitialVisiblePackets((Unit*)target); } } } +void Player::SendInitialVisiblePackets(Unit* target) +{ + SendAuraDurationsForTarget(target); + if(target->isAlive()) + { + if(target->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE) + target->SendMonsterMoveWithSpeedToCurrentDestination(this); + if(target->hasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim()) + target->SendAttackStart(target->getVictim()); + } +} + template<class T> inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, T* target) { @@ -17778,7 +17833,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& } } -template<> +/*template<> void Player::UpdateVisibilityOf<Creature>(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow) { if(HaveAtClient(target)) @@ -17811,10 +17866,10 @@ void Player::UpdateVisibilityOf<Creature>(Creature* target, UpdateData& data, Up #endif } } -} +}*/ template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow); -//template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow); +template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow); template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow); template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow); template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow); diff --git a/src/game/Player.h b/src/game/Player.h index 79380fbbb2c..53dcf84d5b5 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -830,6 +830,20 @@ struct InstancePlayerBind InstancePlayerBind() : save(NULL), perm(false) {} }; +struct AccessRequirement +{ + uint8 levelMin; + uint8 levelMax; + uint32 item; + uint32 item2; + uint32 heroicKey; + uint32 heroicKey2; + uint32 quest; + std::string questFailedText; + uint32 heroicQuest; + std::string heroicQuestFailedText; + }; + class TRINITY_DLL_SPEC PlayerTaxi { public: @@ -2010,6 +2024,7 @@ class TRINITY_DLL_SPEC Player : public Unit bool IsVisibleGloballyFor(Player* pl) const; void UpdateVisibilityOf(WorldObject* target); + void SendInitialVisiblePackets(Unit* target); template<class T> void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow); @@ -2052,6 +2067,7 @@ class TRINITY_DLL_SPEC Player : public Unit void SendRaidInfo(); void SendSavedInstances(); static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0); + bool Satisfy(AccessRequirement const*, uint32 target_map, bool report = false); /*********************************************************/ /*** GROUP SYSTEM ***/ diff --git a/src/game/PlayerDump.h b/src/game/PlayerDump.h index 2fbdf513ce5..211a000103d 100644 --- a/src/game/PlayerDump.h +++ b/src/game/PlayerDump.h @@ -20,28 +20,6 @@ #ifndef _PLAYER_DUMP_H #define _PLAYER_DUMP_H -/* -#include "Log.h" -#include "Object.h" -#include "Bag.h" -#include "Creature.h" -#include "Player.h" -#include "DynamicObject.h" -#include "GameObject.h" -#include "Corpse.h" -#include "QuestDef.h" -#include "Path.h" -#include "ItemPrototype.h" -#include "NPCHandler.h" -#include "Database/DatabaseEnv.h" -#include "AuctionHouseObject.h" -#include "Mail.h" -#include "Map.h" -#include "ObjectAccessor.h" -#include "ObjectDefines.h" -#include "Policies/Singleton.h" -#include "Database/SQLStorage.h" -*/ #include <string> #include <map> #include <set> diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index d3923d99233..378bd06aa95 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1212,10 +1212,10 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) } } - if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->AI()) + if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->IsAIEnabled) ((Creature*)unit)->AI()->SpellHit(m_caster, m_spellInfo); - if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) + if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->IsAIEnabled) ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); for(ChanceTriggerSpells::const_iterator i = m_ChanceTriggerSpells.begin(); i != m_ChanceTriggerSpells.end(); ++i) @@ -2048,7 +2048,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) return; } - if(m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isPet())) + if(m_caster->GetTypeId() == TYPEID_PLAYER) { if(objmgr.IsPlayerSpellDisabled(m_spellInfo->Id)) { @@ -2057,6 +2057,15 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) return; } } + else if (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isPet()) + { + if(objmgr.IsPetSpellDisabled(m_spellInfo->Id)) + { + SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE); + finish(false); + return; + } + } else { if(objmgr.IsCreatureSpellDisabled(m_spellInfo->Id)) @@ -2116,8 +2125,11 @@ void Spell::cancel() if(m_spellState == SPELL_STATE_FINISHED) return; + uint32 oldState = m_spellState; + m_spellState = SPELL_STATE_FINISHED; + m_autoRepeat = false; - switch (m_spellState) + switch (oldState) { case SPELL_STATE_PREPARING: case SPELL_STATE_DELAYED: @@ -2149,10 +2161,13 @@ void Spell::cancel() } break; } - finish(false); - m_caster->RemoveDynObject(m_spellInfo->Id); m_caster->RemoveGameObject(m_spellInfo->Id,true); + + //set state back so finish will be processed + m_spellState = oldState; + + finish(false); } void Spell::cast(bool skipCheck) @@ -4027,10 +4042,8 @@ uint8 Spell::CanCast(bool strict) InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(m_caster->GetMapId()); if(!instance) return SPELL_FAILED_TARGET_NOT_IN_INSTANCE; - if ( instance->levelMin > target->getLevel() ) - return SPELL_FAILED_LOWLEVEL; - if ( instance->levelMax && instance->levelMax < target->getLevel() ) - return SPELL_FAILED_HIGHLEVEL; + if(!target->Satisfy(objmgr.GetAccessRequirement(instance->access_id), m_caster->GetMapId())) + return SPELL_FAILED_BAD_TARGETS; } break; } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 40edea80ce9..99adb488eb1 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -908,11 +908,6 @@ void Aura::_AddAura() void Aura::_RemoveAura() { - // Remove all triggered by aura spells vs unlimited duration - // except same aura replace case - if(m_removeMode!=AURA_REMOVE_BY_STACK) - CleanupTriggeredSpells(); - Unit* caster = GetCaster(); if(caster && IsPersistent()) @@ -2873,11 +2868,14 @@ void Aura::HandleModPossessPet(bool apply, bool Real) Unit* caster = GetCaster(); if(!caster || caster->GetTypeId() != TYPEID_PLAYER) return; - if(caster->GetPet() != m_target) - return; if(apply) + { + if(caster->GetPet() != m_target) + return; + m_target->SetCharmedOrPossessedBy(caster, true); + } else { m_target->RemoveCharmedOrPossessedBy(caster); diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 249eb4b6762..be95c5245b7 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -271,6 +271,7 @@ class TRINITY_DLL_SPEC Aura bool IsDeathPersistent() const { return m_isDeathPersist; } bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; } bool IsInUse() const { return m_in_use;} + void CleanupTriggeredSpells(); virtual void Update(uint32 diff); void ApplyModifier(bool apply, bool Real = false); @@ -339,7 +340,6 @@ class TRINITY_DLL_SPEC Aura int32 m_stackAmount; private: - void CleanupTriggeredSpells(); void SetAura(uint32 slot, bool remove) { m_target->SetUInt32Value(UNIT_FIELD_AURA + slot, remove ? 0 : GetId()); } void SetAuraFlag(uint32 slot, bool add); void SetAuraLevel(uint32 slot, uint32 level); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index c9e0d1e0647..a985e1c9fb1 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -339,14 +339,6 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) } break; } - case 43648: //Electrical Storm - { - if(unitTarget && unitTarget->HasAura(44007, 0)) // Immune Aura - { - damage = 0; - } - break; - } // percent from health with min case 25599: // Thundercrash { @@ -1154,7 +1146,7 @@ void Spell::EffectDummy(uint32 i) pCreature->SetHealth(health); - if(pCreature->AI()) + if(pCreature->IsAIEnabled) pCreature->AI()->AttackStart(m_caster); return; @@ -1186,7 +1178,7 @@ void Spell::EffectDummy(uint32 i) pCreature->SetHealth(health); ((Player*)m_caster)->KilledMonster(16992,pCreature->GetGUID()); - if (pCreature->AI()) + if (pCreature->IsAIEnabled) pCreature->AI()->AttackStart(m_caster); return; @@ -1234,7 +1226,7 @@ void Spell::EffectDummy(uint32 i) m_caster->CastSpell(m_caster, 30452, true, NULL); return; - } + } } //All IconID Check in there @@ -2428,13 +2420,6 @@ void Spell::SpellDamageHeal(uint32 /*i*/) sLog.outError("Target(GUID:" I64FMTD ") has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID()); return; } - int idx = 0; - while(idx < 3) - { - if(targetAura->GetSpellProto()->EffectApplyAuraName[idx] == SPELL_AURA_PERIODIC_HEAL) - break; - idx++; - } int32 tickheal = targetAura->GetModifierValuePerStack(); if(Unit* auraCaster = targetAura->GetCaster()) @@ -2442,7 +2427,15 @@ void Spell::SpellDamageHeal(uint32 /*i*/) //int32 tickheal = targetAura->GetSpellProto()->EffectBasePoints[idx] + 1; //It is said that talent bonus should not be included //int32 tickheal = targetAura->GetModifierValue(); - int32 tickcount = GetSpellDuration(targetAura->GetSpellProto()) / targetAura->GetSpellProto()->EffectAmplitude[idx]; + int32 tickcount = 0; + if(targetAura->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID) + { + switch(targetAura->GetSpellProto()->SpellFamilyFlags)//TODO: proper spellfamily for 3.0.x + { + case 0x10: tickcount = 4; break; // Rejuvenation + case 0x40: tickcount = 6; break; // Regrowth + } + } addhealth += tickheal * tickcount; unitTarget->RemoveAurasDueToCasterSpell(targetAura->GetId(), targetAura->GetCasterGUID()); @@ -2634,33 +2627,7 @@ void Spell::DoCreateItem(uint32 i, uint32 itemtype) // we succeeded in creating at least one item, so a levelup is possible player->UpdateCraftSkill(m_spellInfo->Id); - } - - // for battleground marks send by mail if not add all expected - if(no_space > 0 ) - { - BattleGroundTypeId bgType; - switch(m_spellInfo->Id) - { - case SPELL_AV_MARK_WINNER: - case SPELL_AV_MARK_LOSER: - bgType = BATTLEGROUND_AV; - break; - case SPELL_WS_MARK_WINNER: - case SPELL_WS_MARK_LOSER: - bgType = BATTLEGROUND_WS; - break; - case SPELL_AB_MARK_WINNER: - case SPELL_AB_MARK_LOSER: - bgType = BATTLEGROUND_AB; - break; - default: - return; - } - - if(BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(bgType)) - bg->SendRewardMarkByMail(player,newitemid,no_space); - } + } } void Spell::EffectCreateItem(uint32 i) @@ -2859,6 +2826,10 @@ void Spell::SendLoot(uint64 guid, LootType loottype) if(uint32 trapEntry = gameObjTarget->GetGOInfo()->goober.linkedTrapId) gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); + // activate GO scripts + Script->GOHello(player, gameObjTarget); + sWorld.ScriptsStart(sGameObjectScripts, gameObjTarget->GetDBTableGUIDLow(), player, gameObjTarget); + return; case GAMEOBJECT_TYPE_CHEST: @@ -3247,7 +3218,7 @@ void Spell::EffectSummon(uint32 i) name.append(petTypeSuffix[spawnCreature->getPetType()]); spawnCreature->SetName( name ); - spawnCreature->GetCharmInfo()->SetReactState( REACT_DEFENSIVE ); + spawnCreature->SetReactState( REACT_DEFENSIVE ); } void Spell::EffectLearnSpell(uint32 i) @@ -3474,7 +3445,7 @@ void Spell::EffectPickPocket(uint32 /*i*/) { // Reveal action + get attack m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK); - if (((Creature*)unitTarget)->AI()) + if (((Creature*)unitTarget)->IsAIEnabled) ((Creature*)unitTarget)->AI()->AttackStart(m_caster); } } @@ -3488,7 +3459,7 @@ void Spell::EffectAddFarsight(uint32 i) float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); int32 duration = GetSpellDuration(m_spellInfo); DynamicObject* dynObj = new DynamicObject; - if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, 4, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) { delete dynObj; return; @@ -4025,9 +3996,9 @@ void Spell::EffectSummonPet(uint32 i) if(m_caster->GetTypeId() == TYPEID_UNIT) { if ( ((Creature*)m_caster)->isTotem() ) - pet->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); + pet->SetReactState(REACT_AGGRESSIVE); else - pet->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); + pet->SetReactState(REACT_DEFENSIVE); } pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 43ee5d7d4a5..9320d26d88d 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -751,6 +751,7 @@ bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellI switch(spec1) { case SPELL_JUDGEMENT: + case SPELL_MAGE_POLYMORPH: if(GetSpellSpecific(spellInfo2->Id) == spec1) return true; break; @@ -1399,6 +1400,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool case SPELL_AURA_PERIODIC_ENERGIZE: case SPELL_AURA_PERIODIC_MANA_LEECH: case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_POWER_BURN_MANA: + case SPELL_AURA_OBS_MOD_MANA: + case SPELL_AURA_OBS_MOD_HEALTH: return false; default: break; @@ -2223,6 +2227,7 @@ void SpellMgr::LoadSpellCustomAttr() case 38296: //Spitfire Totem case 37676: //Insidious Whisper case 46009: //Negative Energy + case 45641: //Fire Bloom spellInfo->MaxAffectedTargets = 5; break; case 40827: //Sinful Beam diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 4ac0871e853..35d867dce2b 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -230,7 +230,8 @@ enum SpellFamilyNames enum SpellDisableTypes { SPELL_DISABLE_PLAYER = 1, - SPELL_DISABLE_CREATURE = 2 + SPELL_DISABLE_CREATURE = 2, + SPELL_DISABLE_PET = 4 }; enum SpellEffectTargetTypes diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index d30ad9ec56e..bbe8fa9c104 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -176,7 +176,7 @@ void TemporarySummon::UnSummon() AddObjectToRemoveList(); Unit* sum = m_summoner ? ObjectAccessor::GetUnit(*this, m_summoner) : NULL; - if (sum && sum->GetTypeId() == TYPEID_UNIT && ((Creature*)sum)->AI()) + if (sum && sum->GetTypeId() == TYPEID_UNIT && ((Creature*)sum)->IsAIEnabled) { ((Creature*)sum)->AI()->SummonedCreatureDespawn(this); } diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 86d21c9a724..df2ad178550 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -555,11 +555,10 @@ void Transport::Update(uint32 /*p_time*/) //MapManager::Instance().GetMap(m_curr->second.mapid)->Add((GameObject *)this); // -> // ->Add(t); if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0) - sLog.outDetail("%s moved to %f %f %f %d", this->m_name.c_str(), m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid); + sLog.outDetail("%s moved to %d %f %f %f %d", this->m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid); //Transport Event System CheckForEvent(this->GetEntry(), m_curr->second.id); - sLog.outDetail("%s is at wp id: %u", this->m_name.c_str(), m_curr->second.id); } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0fbeb5a9f7d..d7b3305c55d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -149,7 +149,7 @@ bool IsPassiveStackableSpell( uint32 spellId ) Unit::Unit() : WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) -, m_IsInNotifyList(false), m_Notified(false), m_AI_enabled(false) +, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false) { m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; @@ -627,7 +627,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } //Script Event damage taken - if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() ) + if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled ) { ((Creature *)pVictim)->AI()->DamageTaken(this, damage); @@ -778,7 +778,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if(!getVictim()) /*{ // if have target and damage pVictim just call AI reaction - if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI()) + if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled) ((Creature*)pVictim)->AI()->AttackedBy(this); } else*/ @@ -4154,59 +4154,49 @@ bool Unit::AddAura(Aura *Aur) SpellEntry const* aurSpellInfo = Aur->GetSpellProto(); spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex()); - AuraMap::iterator i = m_Auras.find( spair ); - // take out same spell - if (i != m_Auras.end()) + bool stackModified=false; + // passive and persistent auras can stack with themselves any number of times + if (!Aur->IsPassive() && !Aur->IsPersistent()) { - // passive and persistent auras can stack with themselves any number of times - if (!Aur->IsPassive() && !Aur->IsPersistent()) + for(AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair);) { - // replace aura if next will > spell StackAmount - if(aurSpellInfo->StackAmount) + if(i2->second->GetCasterGUID()==Aur->GetCasterGUID()) { - Aur->SetStackAmount(i->second->GetStackAmount()); - if(Aur->GetStackAmount() < aurSpellInfo->StackAmount) - Aur->SetStackAmount(Aur->GetStackAmount()+1); - RemoveAura(i,AURA_REMOVE_BY_STACK); - } - // if StackAmount==0 not allow auras from same caster - else - { - for(AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair); ++i2) + if (!stackModified) { - if(i2->second->GetCasterGUID()==Aur->GetCasterGUID()) - { - // can be only single (this check done at _each_ aura add - RemoveAura(i2,AURA_REMOVE_BY_STACK); - break; - } - - bool stop = false; - switch(aurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]) + // replace aura if next will > spell StackAmount + if(aurSpellInfo->StackAmount) { - // DoT/HoT/etc - case SPELL_AURA_PERIODIC_DAMAGE: // allow stack - case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: - case SPELL_AURA_PERIODIC_LEECH: - case SPELL_AURA_PERIODIC_HEAL: - case SPELL_AURA_OBS_MOD_HEALTH: - case SPELL_AURA_PERIODIC_MANA_LEECH: - case SPELL_AURA_PERIODIC_ENERGIZE: - case SPELL_AURA_OBS_MOD_MANA: - case SPELL_AURA_POWER_BURN_MANA: - break; - default: // not allow - // can be only single (this check done at _each_ aura add - RemoveAura(i2,AURA_REMOVE_BY_STACK); - stop = true; - break; + // prevent adding stack more than once + stackModified=true; + Aur->SetStackAmount(i2->second->GetStackAmount()); + if(Aur->GetStackAmount() < aurSpellInfo->StackAmount) + Aur->SetStackAmount(Aur->GetStackAmount()+1); } - - if(stop) - break; + RemoveAura(i2,AURA_REMOVE_BY_STACK); + i2=m_Auras.lower_bound(spair); + continue; } } + switch(aurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]) + { + // DOT or HOT from different casters will stack + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_PERIODIC_TRIGGER_SPELL: + case SPELL_AURA_PERIODIC_ENERGIZE: + case SPELL_AURA_PERIODIC_MANA_LEECH: + case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_POWER_BURN_MANA: + case SPELL_AURA_OBS_MOD_MANA: + case SPELL_AURA_OBS_MOD_HEALTH: + ++i2; + continue; + } + RemoveAura(i2,AURA_REMOVE_BY_STACK); + i2=m_Auras.lower_bound(spair); + continue; } } @@ -4347,6 +4337,9 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) uint32 i_spellId = i_spellProto->Id; + if (spellId==i_spellId) + continue; + if(IsPassiveSpell(i_spellId)) { if(IsPassiveStackableSpell(i_spellId)) @@ -4359,8 +4352,6 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) uint32 i_effIndex = (*i).second->GetEffIndex(); - if(i_spellId == spellId) continue; - bool is_triggered_by_spell = false; // prevent triggered aura of removing aura that triggered it for(int j = 0; j < 3; ++j) @@ -4417,7 +4408,23 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); continue; } - RemoveAurasDueToSpell(i_spellId); + + uint64 caster = (*i).second->GetCasterGUID(); + // Remove all auras by aura caster + for (uint8 a=0;a<3;++a) + { + spellEffectPair spair = spellEffectPair(i_spellId, a); + for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) + { + if(iter->second->GetCasterGUID()==caster) + { + RemoveAura(iter, AURA_REMOVE_BY_STACK); + iter = m_Auras.lower_bound(spair); + } + else + ++iter; + } + } if( m_Auras.empty() ) break; @@ -4706,13 +4713,10 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) if(!caster) // can be already located for IsSingleTargetSpell case caster = Aur->GetCaster(); - if(caster) + if(caster && caster->isAlive()) { - if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) - statue = ((Totem*)caster); - // stop caster chanelling state - else if(caster->m_currentSpells[CURRENT_CHANNELED_SPELL] + if(caster->m_currentSpells[CURRENT_CHANNELED_SPELL] //prevent recurential call && caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) { @@ -4727,6 +4731,9 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel(); } } + + if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) + statue = ((Totem*)caster); } // Unsummon summon as possessed creatures on spell cancel @@ -4755,8 +4762,21 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) Aur->_RemoveAura(); - if(mode != AURA_REMOVE_BY_STACK) + bool stack = false; + spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex()); + for(AuraMap::const_iterator itr = GetAuras().lower_bound(spair); itr != GetAuras().upper_bound(spair); ++itr) { + if (itr->second->GetCasterGUID()==GetGUID()) + { + stack = true; + } + } + if (!stack) + { + // Remove all triggered by aura spells vs unlimited duration + Aur->CleanupTriggeredSpells(); + + // Remove Linked Auras uint32 id = Aur->GetId(); if(spellmgr.GetSpellCustomAttr(id) & SPELL_ATTR_CU_LINK_REMOVE) { @@ -6465,6 +6485,30 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu } break; } + case SPELLFAMILY_POTION: + { + if (dummySpell->Id == 17619) + { + if (procSpell->SpellFamilyName == SPELLFAMILY_POTION) + { + for (uint8 i=0;i<3;i++) + { + if (procSpell->Effect[i]==SPELL_EFFECT_HEAL) + { + triggered_spell_id = 21399; + } + else if (procSpell->Effect[i]==SPELL_EFFECT_ENERGIZE) + { + triggered_spell_id = 21400; + } + else continue; + basepoints0 = CalculateSpellDamage(procSpell,i,procSpell->EffectBasePoints[i],this) * 0.4f; + CastCustomSpell(this,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + } + return true; + } + } + } default: break; } @@ -8259,7 +8303,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) m_attacking = victim; m_attacking->_addAttacker(this); - //if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI()) + //if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->IsAIEnabled) // ((Creature*)m_attacking)->AI()->AttackedBy(this); if(GetTypeId()==TYPEID_UNIT) @@ -8318,7 +8362,7 @@ bool Unit::AttackStop() void Unit::CombatStop(bool cast) { - if(cast& IsNonMeleeSpellCasted(false)) + if(cast && IsNonMeleeSpellCasted(false)) InterruptNonMeleeSpells(false); AttackStop(); @@ -8502,19 +8546,23 @@ void Unit::SetCharm(Unit* pet) void Unit::AddPlayerToVision(Player* plr) { - setActive(true); if(m_sharedVision.empty()) + { + setActive(true); SetWorldObject(true); + } m_sharedVision.push_back(plr); plr->SetFarsightTarget(this); } void Unit::RemovePlayerFromVision(Player* plr) { - setActive(false); m_sharedVision.remove(plr); if(m_sharedVision.empty()) + { + setActive(false); SetWorldObject(false); + } plr->ClearFarsight(); } @@ -8675,6 +8723,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 } } + bool hasmangle=false; // .. taken pct: dummy auras AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) @@ -8697,6 +8746,10 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 //Mangle case 2312: case 44955: + // don't apply mod twice + if (hasmangle) + break; + hasmangle=true; for(int j=0;j<3;j++) { if(GetEffectMechanic(spellProto, j)==MECHANIC_BLEED) @@ -9172,7 +9225,8 @@ uint32 Unit::SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, spellProto->Id == 33778 || spellProto->Id == 379 || spellProto->Id == 38395 || spellProto->Id == 40972 || spellProto->Id == 22845 || spellProto->Id == 33504 || - spellProto->Id == 34299) + spellProto->Id == 34299 || spellProto->Id == 27813 || + spellProto->Id == 27817 || spellProto->Id == 27818) return healamount; int32 AdvertisedBenefit = SpellBaseHealingBonus(GetSpellSchoolMask(spellProto)); @@ -9802,7 +9856,7 @@ void Unit::CombatStart(Unit* target) target->SetStandState(PLAYER_STATE_NONE); if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER - && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->AI()) + && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled) ((Creature*)target)->AI()->AttackStart(this); SetInCombatWith(target); @@ -10425,7 +10479,7 @@ void Unit::TauntApply(Unit* taunter) return; SetInFront(taunter); - if (((Creature*)this)->AI()) + if (((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->AttackStart(taunter); m_ThreatManager.tauntApply(taunter); @@ -10449,7 +10503,7 @@ void Unit::TauntFadeOut(Unit *taunter) if(m_ThreatManager.isThreatListEmpty()) { - if(((Creature*)this)->AI()) + if(((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->EnterEvadeMode(); return; } @@ -10460,7 +10514,7 @@ void Unit::TauntFadeOut(Unit *taunter) if (target && target != taunter) { SetInFront(target); - if (((Creature*)this)->AI()) + if (((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->AttackStart(target); } } @@ -10584,7 +10638,7 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde } } - if(spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel && + if(!basePointsPerLevel && (spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel) && spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE && spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK) //there are many more: slow speed, -healing pct @@ -11196,21 +11250,43 @@ void Unit::CleanupsBeforeDelete() RemoveFromWorld(); } -CharmInfo* Unit::InitCharmInfo(Unit *charm) +CharmInfo* Unit::InitCharmInfo() { if(!m_charmInfo) - m_charmInfo = new CharmInfo(charm); + m_charmInfo = new CharmInfo(this); return m_charmInfo; } +void Unit::DeleteCharmInfo() +{ + if(!m_charmInfo) + return; + + delete m_charmInfo; + m_charmInfo = NULL; +} + CharmInfo::CharmInfo(Unit* unit) -: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0), m_barInit(false) +: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_petnumber(0), m_barInit(false) { for(int i =0; i<4; ++i) { m_charmspells[i].spellId = 0; m_charmspells[i].active = ACT_DISABLED; } + if(m_unit->GetTypeId() == TYPEID_UNIT) + { + m_oldReactState = ((Creature*)m_unit)->GetReactState(); + ((Creature*)m_unit)->SetReactState(REACT_PASSIVE); + } +} + +CharmInfo::~CharmInfo() +{ + if(m_unit->GetTypeId() == TYPEID_UNIT) + { + ((Creature*)m_unit)->SetReactState(m_oldReactState); + } } void CharmInfo::InitPetActionBar() @@ -12055,7 +12131,7 @@ void Unit::SetFeared(bool apply, uint64 casterGUID, uint32 spellID) // attack caster if can Unit* caster = ObjectAccessor::GetObjectInWorld(casterGUID, (Unit*)NULL); - if(caster && caster != getVictim() && ((Creature*)this)->AI()) + if(caster && caster != getVictim() && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->AttackStart(caster); } } @@ -12739,7 +12815,7 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) ((Player*)pVictim)->GetSession()->SendPacket(&data); } // Call KilledUnit for creatures - if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->KilledUnit(pVictim); // last damage from non duel opponent or opponent controlled creature @@ -12762,11 +12838,11 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) } // Call KilledUnit for creatures, this needs to be called after the lootable flag is set - if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->KilledUnit(pVictim); // Call creature just died function - if (cVictim->AI()) + if (cVictim->IsAIEnabled) cVictim->AI()->JustDied(this); // Dungeon specific stuff, only applies to players killing creatures @@ -13030,7 +13106,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess) if(GetTypeId() == TYPEID_UNIT) { - ((Creature*)this)->InitPossessedAI(); + ((Creature*)this)->AI()->OnCharmed(true); StopMoving(); GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); @@ -13045,8 +13121,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess) // Pets already have a properly initialized CharmInfo, don't overwrite it. if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet()) { - CharmInfo *charmInfo = InitCharmInfo(this); - charmInfo->SetReactState(REACT_DEFENSIVE); + CharmInfo *charmInfo = InitCharmInfo(); if(possess) charmInfo->InitPossessCreateSpells(); else @@ -13116,8 +13191,8 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer) if(!((Creature*)this)->isPet()) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - ((Creature*)this)->DisablePossessedAI(); - if(isAlive() && ((Creature*)this)->AI()) + ((Creature*)this)->AI()->OnCharmed(false); + if(isAlive() && ((Creature*)this)->IsAIEnabled) { if(charmer && !IsFriendlyTo(charmer)) { @@ -13163,6 +13238,11 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer) } } + if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet()) + { + DeleteCharmInfo(); + } + if(possess || charmer->GetTypeId() == TYPEID_PLAYER) { // Remove pet spell action bar diff --git a/src/game/Unit.h b/src/game/Unit.h index c6648f00a30..d103525208c 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -709,15 +709,16 @@ struct TRINITY_DLL_SPEC CharmInfo { public: explicit CharmInfo(Unit* unit); + ~CharmInfo(); uint32 GetPetNumber() const { return m_petnumber; } void SetPetNumber(uint32 petnumber, bool statwindow); void SetCommandState(CommandStates st) { m_CommandState = st; } CommandStates GetCommandState() { return m_CommandState; } bool HasCommandState(CommandStates state) { return (m_CommandState == state); } - void SetReactState(ReactStates st) { m_reactState = st; } - ReactStates GetReactState() { return m_reactState; } - bool HasReactState(ReactStates state) { return (m_reactState == state); } + //void SetReactState(ReactStates st) { m_reactState = st; } + //ReactStates GetReactState() { return m_reactState; } + //bool HasReactState(ReactStates state) { return (m_reactState == state); } void InitPossessCreateSpells(); void InitCharmCreateSpells(); @@ -734,9 +735,12 @@ struct TRINITY_DLL_SPEC CharmInfo UnitActionBarEntry PetActionBar[10]; CharmSpellEntry m_charmspells[4]; CommandStates m_CommandState; - ReactStates m_reactState; + //ReactStates m_reactState; uint32 m_petnumber; bool m_barInit; + + //for restoration after charmed + ReactStates m_oldReactState; }; // for clearing special attacks @@ -1103,7 +1107,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject bool isPossessing(Unit* u) const { return u->isPossessed() && GetCharmGUID() == u->GetGUID(); } CharmInfo* GetCharmInfo() { return m_charmInfo; } - CharmInfo* InitCharmInfo(Unit* charm); + CharmInfo* InitCharmInfo(); + void DeleteCharmInfo(); SharedVisionList const& GetSharedVisionList() { return m_sharedVision; } void AddPlayerToVision(Player* plr); void RemovePlayerFromVision(Player* plr); @@ -1414,6 +1419,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject } uint32 GetReducedThreatPercent() { return m_reducedThreatPercent; } Unit *GetMisdirectionTarget() { return m_misdirectionTargetGUID ? GetUnit(*this, m_misdirectionTargetGUID) : NULL; } + + bool IsAIEnabled; protected: explicit Unit (); @@ -1466,7 +1473,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject ThreatManager m_ThreatManager; - bool m_AI_enabled; private: void SendAttackStop(Unit* victim); // only from AttackStop(Unit*) //void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*) diff --git a/src/game/World.cpp b/src/game/World.cpp index 7adb9f4d24f..1ef570fe0d7 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -37,6 +37,7 @@ #include "SkillDiscovery.h" #include "World.h" #include "AccountMgr.h" +#include "AuctionHouseMgr.h" #include "ObjectMgr.h" #include "SpellMgr.h" #include "Chat.h" @@ -278,7 +279,7 @@ bool World::HasRecentlyDisconnected(WorldSession* session) if(!session) return false; if(uint32 tolerance = getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) - { + { for(DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end(); ++i) { if(difftime(i->second, time(NULL)) < tolerance) @@ -624,7 +625,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Channel",false); m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Group",false); m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Guild",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",false); + m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",false); m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Mail",false); m_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = sConfig.GetBoolDefault("AllowTwoSide.WhoList", false); m_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = sConfig.GetBoolDefault("AllowTwoSide.AddFriend", false); @@ -1201,7 +1202,10 @@ void World::SetInitialWorldSettings() objmgr.LoadQuestRelations(); // must be after quest load sLog.outString( "Loading AreaTrigger definitions..." ); - objmgr.LoadAreaTriggerTeleports(); // must be after item template load + objmgr.LoadAreaTriggerTeleports(); + + sLog.outString( "Loading Access Requirements..." ); + objmgr.LoadAccessRequirements(); // must be after item template load sLog.outString( "Loading Quest Area Triggers..." ); objmgr.LoadQuestAreaTriggers(); // must be after LoadQuests @@ -1265,8 +1269,8 @@ void World::SetInitialWorldSettings() ///- Load dynamic data tables from the database sLog.outString( "Loading Auctions..." ); - objmgr.LoadAuctionItems(); - objmgr.LoadAuctions(); + auctionmgr.LoadAuctionItems(); + auctionmgr.LoadAuctions(); sLog.outString( "Loading Guilds..." ); objmgr.LoadGuilds(); @@ -1510,7 +1514,7 @@ void World::Update(time_t diff) if (m_timers[WUPDATE_AUCTIONS].Passed()) { AuctionHouseBot(); - m_timers[WUPDATE_AUCTIONS].Reset(); + m_timers[WUPDATE_AUCTIONS].Reset(); ///- Update mails (return old mails with item, or delete them) //(tested... works on win) @@ -1519,55 +1523,8 @@ void World::Update(time_t diff) mail_timer = 0; objmgr.ReturnOrDeleteOldMails(true); } - - AuctionHouseObject* AuctionMap; - for (int i = 0; i < 3; i++) - { - switch (i) - { - case 0: - AuctionMap = objmgr.GetAuctionsMap( 6 );//horde - break; - case 1: - AuctionMap = objmgr.GetAuctionsMap( 2 );//alliance - break; - case 2: - AuctionMap = objmgr.GetAuctionsMap( 7 );//neutral - break; - } - - ///- Handle expired auctions - AuctionHouseObject::AuctionEntryMap::iterator itr,next; - for (itr = AuctionMap->GetAuctionsBegin(); itr != AuctionMap->GetAuctionsEnd();itr = next) - { - next = itr; - ++next; - if (m_gameTime > (itr->second->time)) - { - ///- Either cancel the auction if there was no bidder - if (itr->second->bidder == 0) - { - objmgr.SendAuctionExpiredMail( itr->second ); - } - ///- Or perform the transaction - else - { - //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 - objmgr.SendAuctionSuccessfulMail( itr->second ); - objmgr.SendAuctionWonMail( itr->second ); - } - - ///- In any case clear the auction - //No SQL injection (Id is integer) - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",itr->second->Id); - objmgr.RemoveAItem(itr->second->item_guidlow); - delete itr->second; - AuctionMap->RemoveAuction(itr->first); - } - } - } + ///-Handle expired auctions + auctionmgr.Update(); } RecordTimeDiff(NULL); @@ -2426,6 +2383,21 @@ void World::ScriptsProcess() break; } + case SCRIPT_COMMAND_KILL: + { + if(!source || ((Creature*)source)->isDead()) + break; + + ((Creature*)source)->DealDamage(((Creature*)source), ((Creature*)source)->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + switch(step.script->dataint) + { + case 0: break; //return false not remove corpse + case 1: ((Creature*)source)->RemoveCorpse(); break; + } + break; + } + default: sLog.outError("Unknown script command %u called.",step.script->command); break; diff --git a/src/game/World.h b/src/game/World.h index 4848c87ca5f..8b6fe46b561 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -331,6 +331,7 @@ enum RealmZone #define SCRIPT_COMMAND_LOAD_PATH 16 // source = unit, path = datalong, repeatable datalong2 #define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 17 // datalong scriptid, lowguid datalong2, dataint table #define SCRIPT_COMMAND_PLAYSOUND 18 // datalong soundid, datalong2 play only self +#define SCRIPT_COMMAND_KILL 19 // datalong removecorpse /// Storage class for commands issued for delayed execution diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index d9fa35f3208..1461d47fd2b 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -164,7 +164,6 @@ class TRINITY_DLL_SPEC WorldSession void SendAuctionCommandResult( uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0); void SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template); void SendAuctionOwnerNotification( AuctionEntry * auction ); - bool SendAuctionInfo(WorldPacket & data, AuctionEntry* auction); void SendAuctionOutbiddedMail( AuctionEntry * auction, uint32 newPrice ); void SendAuctionCancelledToBidderMail( AuctionEntry* auction ); diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index 67b806cd632..2031457ceaf 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -36,6 +36,7 @@ static AreaFlagByAreaID sAreaFlagByAreaID; static AreaFlagByMapID sAreaFlagByMapID; // for instances without generated *.map files DBCStorage <AreaTriggerEntry> sAreaTriggerStore(AreaTriggerEntryfmt); +DBCStorage <AuctionHouseEntry> sAuctionHouseStore(AuctionHouseEntryfmt); DBCStorage <BankBagSlotPricesEntry> sBankBagSlotPricesStore(BankBagSlotPricesEntryfmt); DBCStorage <BattlemasterListEntry> sBattlemasterListStore(BattlemasterListEntryfmt); DBCStorage <CharStartOutfitEntry> sCharStartOutfitStore(CharStartOutfitEntryfmt); @@ -178,7 +179,7 @@ void LoadDBCStores(const std::string& dataPath) { std::string dbcPath = dataPath+"dbc/"; - const uint32 DBCFilesCount = 56; + const uint32 DBCFilesCount = 57; barGoLink bar( DBCFilesCount ); @@ -202,6 +203,7 @@ void LoadDBCStores(const std::string& dataPath) } LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaTriggerStore, dbcPath,"AreaTrigger.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAuctionHouseStore, dbcPath,"AuctionHouse.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBankBagSlotPricesStore, dbcPath,"BankBagSlotPrices.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBattlemasterListStore, dbcPath,"BattlemasterList.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharStartOutfitStore, dbcPath,"CharStartOutfit.dbc"); diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h index dd255894ded..4ad275653e7 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/shared/Database/DBCStores.h @@ -134,6 +134,7 @@ class DBCStorage extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions extern DBCStorage <AreaTriggerEntry> sAreaTriggerStore; +extern DBCStorage <AuctionHouseEntry> sAuctionHouseStore; extern DBCStorage <BankBagSlotPricesEntry> sBankBagSlotPricesStore; extern DBCStorage <BattlemasterListEntry> sBattlemasterListStore; //extern DBCStorage <ChatChannelsEntry> sChatChannelsStore; -- accessed using function, no usable index diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index 2f51f1d6579..95703f9b778 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -65,6 +65,16 @@ struct AreaTriggerEntry float box_orientation; // 9 extent rotation by about z axis }; +struct AuctionHouseEntry +{ + uint32 houseId; // 0 index + uint32 faction; // 1 id of faction.dbc for player factions associated with city + uint32 depositPercent; // 2 1/3 from real + uint32 cutPercent; // 3 + //char* name[16]; // 4-19 + // 20 string flag, unused +}; + struct BankBagSlotPricesEntry { uint32 ID; diff --git a/src/shared/Database/DBCfmt.cpp b/src/shared/Database/DBCfmt.cpp index cab781692f0..14cf6486933 100644 --- a/src/shared/Database/DBCfmt.cpp +++ b/src/shared/Database/DBCfmt.cpp @@ -19,6 +19,7 @@ */ const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxx"; +const char AuctionHouseEntryfmt[]="niiixxxxxxxxxxxxxxxxx"; const char AreaTriggerEntryfmt[]="niffffffff"; const char BankBagSlotPricesEntryfmt[]="ni"; const char BattlemasterListEntryfmt[]="niiixxxxxiiiixxssssssssssssssssxx"; diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index 1419d6a2ac6..0eeefbf10ca 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -39,8 +39,8 @@ const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiii"; const char PageTextfmt[]="isi"; const char SpellThreatfmt[]="ii"; -const char InstanceTemplatesrcfmt[]="iiiiiiffffs"; -const char InstanceTemplatedstfmt[]="iiiiiiffffi"; +const char InstanceTemplatesrcfmt[]="iiiiiffffs"; +const char InstanceTemplatedstfmt[]="iiiiiffffi"; SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template"); SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); |