diff --git a/sql/mangos.sql b/sql/mangos.sql index 072f1d1d8..a5fdf2b3b 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_8498_01_mangos_spell_proc_event` bit(1) default NULL + `required_8499_01_mangos_spell_elixir` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -17044,14 +17044,29 @@ INSERT INTO `spell_elixir` VALUES (45373,0x1), (46837,0xB), (46839,0xB), +(53747,0x2), +(53748,0x1), +(53746,0x1), +(53749,0x1), +(53751,0x2), (53752,0x3), (53755,0x3), (53758,0x3), (53760,0x3), +(53763,0x2), +(53764,0x2), (54212,0x3), -(62380,0x3), -(67019,0x3); - +(54452,0x1), +(54494,0x1), +(54497,0x2), +(60340,0x1), +(60341,0x1), +(60343,0x2), +(60344,0x1), +(60345,0x1), +(60346,0x1), +(60347,0x2), +(62380,0x3); /*!40000 ALTER TABLE `spell_elixir` ENABLE KEYS */; diff --git a/sql/updates/8499_01_mangos_spell_elixir.sql b/sql/updates/8499_01_mangos_spell_elixir.sql new file mode 100644 index 000000000..bd625ea2e --- /dev/null +++ b/sql/updates/8499_01_mangos_spell_elixir.sql @@ -0,0 +1,24 @@ +ALTER TABLE db_version CHANGE COLUMN required_8498_01_mangos_spell_proc_event required_8499_01_mangos_spell_elixir bit; + +/* Elexirs added in 3.x */ +DELETE FROM `spell_elixir` WHERE `entry` IN +(53747,53748,53746,53749,53751,53763,53764,54452,54494,54497,60340,60341,60343,60344,60345,60346,60347); + +INSERT INTO `spell_elixir` (`entry`, `mask`) VALUES +(53747,0x2), +(53748,0x1), +(53746,0x1), +(53749,0x1), +(53751,0x2), +(53763,0x2), +(53764,0x2), +(54452,0x1), +(54494,0x1), +(54497,0x2), +(60340,0x1), +(60341,0x1), +(60343,0x2), +(60344,0x1), +(60345,0x1), +(60346,0x1), +(60347,0x2); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index f29308a99..8463f8149 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -106,6 +106,7 @@ pkgdata_DATA = \ 8488_01_mangos_spell_chain.sql \ 8488_02_mangos_spell_bonus_data.sql \ 8498_01_mangos_spell_proc_event.sql \ + 8499_01_mangos_spell_elixir.sql \ README ## Additional files to include when running 'make dist' @@ -192,4 +193,5 @@ EXTRA_DIST = \ 8488_01_mangos_spell_chain.sql \ 8488_02_mangos_spell_bonus_data.sql \ 8498_01_mangos_spell_proc_event.sql \ + 8499_01_mangos_spell_elixir.sql \ README diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index 868bc87e5..2ff2f92c1 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -421,7 +421,7 @@ uint32 GameEventMgr::Initialize() // return the next e m_ActiveEvents.clear(); uint32 delay = Update(); sLog.outBasic("Game Event system initialized." ); - isSystemInit = true; + m_IsGameEventsInit = true; return delay; } @@ -445,11 +445,14 @@ uint32 GameEventMgr::Update() // return the next e StopEvent(itr); else { - if (!isSystemInit) + if (!m_IsGameEventsInit) { int16 event_nid = (-1) * (itr); // spawn all negative ones for this event GameEventSpawn(event_nid); + + // disable any event specific quest (for cases where creature is spawned, but event not active). + UpdateEventQuests(itr, false); } } } @@ -740,7 +743,7 @@ void GameEventMgr::UpdateEventQuests(uint16 event_id, bool Activate) GameEventMgr::GameEventMgr() { - isSystemInit = false; + m_IsGameEventsInit = false; } MANGOS_DLL_SPEC bool IsHolidayActive( HolidayIds id ) diff --git a/src/game/GameEventMgr.h b/src/game/GameEventMgr.h index a05f07767..60a025ca5 100644 --- a/src/game/GameEventMgr.h +++ b/src/game/GameEventMgr.h @@ -94,7 +94,7 @@ class GameEventMgr GameEventIdMap mGameEventPoolIds; GameEventDataMap mGameEvent; ActiveEvents m_ActiveEvents; - bool isSystemInit; + bool m_IsGameEventsInit; }; #define gameeventmgr MaNGOS::Singleton::Instance() diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 1c60e474c..9f445d128 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1057,8 +1057,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce) GridMaps[gx][gy]->unloadData(); delete GridMaps[gx][gy]; } - // x and y are swapped - VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx); + VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gx, gy); } else ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridPair(gx, gy)); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 80b306c44..e25e606b2 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -11359,19 +11359,19 @@ void Player::SwapItem( uint16 src, uint16 dst ) RemoveItem(srcbag, srcslot, false); // add to dest - if( IsInventoryPos( dst ) ) + if (IsInventoryPos(dst)) StoreItem(sDest, pSrcItem, true); - else if( IsBankPos( dst ) ) + else if (IsBankPos(dst)) BankItem(sDest, pSrcItem, true); - else if( IsEquipmentPos( dst ) ) + else if (IsEquipmentPos(dst)) EquipItem(eDest, pSrcItem, true); // add to src - if( IsInventoryPos( src ) ) + if (IsInventoryPos(src)) StoreItem(sDest2, pDstItem, true); - else if( IsBankPos( src ) ) + else if (IsBankPos(src)) BankItem(sDest2, pDstItem, true); - else if( IsEquipmentPos( src ) ) + else if (IsEquipmentPos(src)) EquipItem(eDest2, pDstItem, true); AutoUnequipOffhandIfNeed(); @@ -11379,11 +11379,11 @@ void Player::SwapItem( uint16 src, uint16 dst ) void Player::AddItemToBuyBackSlot( Item *pItem ) { - if( pItem ) + if (pItem) { uint32 slot = m_currentBuybackSlot; // if current back slot non-empty search oldest or free - if(m_items[slot]) + if (m_items[slot]) { uint32 oldest_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 ); uint32 oldest_slot = BUYBACK_SLOT_START; @@ -11391,7 +11391,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) for(uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i ) { // found empty - if(!m_items[i]) + if (!m_items[i]) { slot = i; break; @@ -11399,7 +11399,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 i_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + i - BUYBACK_SLOT_START); - if(oldest_time > i_time) + if (oldest_time > i_time) { oldest_time = i_time; oldest_slot = i; @@ -11419,15 +11419,14 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 eslot = slot - BUYBACK_SLOT_START; SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID() ); - ItemPrototype const *pProto = pItem->GetProto(); - if( pProto ) + if (ItemPrototype const *pProto = pItem->GetProto()) SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); else SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime ); // move to next (for non filled list is move most optimized choice) - if(m_currentBuybackSlot < BUYBACK_SLOT_END - 1) + if (m_currentBuybackSlot < BUYBACK_SLOT_END - 1) ++m_currentBuybackSlot; } } @@ -11435,7 +11434,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) Item* Player::GetItemFromBuyBackSlot( uint32 slot ) { sLog.outDebug( "STORAGE: GetItemFromBuyBackSlot slot = %u", slot); - if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) + if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) return m_items[slot]; return NULL; } @@ -11443,10 +11442,10 @@ Item* Player::GetItemFromBuyBackSlot( uint32 slot ) void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) { sLog.outDebug( "STORAGE: RemoveItemFromBuyBackSlot slot = %u", slot); - if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) + if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) { Item *pItem = m_items[slot]; - if( pItem ) + if (pItem) { pItem->RemoveFromWorld(); if(del) pItem->SetState(ITEM_REMOVED, this); @@ -11460,7 +11459,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); // if current backslot is filled set to now free slot - if(m_items[m_currentBuybackSlot]) + if (m_items[m_currentBuybackSlot]) m_currentBuybackSlot = slot; } } @@ -11468,21 +11467,21 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ) { sLog.outDebug( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg); - WorldPacket data( SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : 18) ); + WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : (msg == EQUIP_ERR_OK ? 1 : 18))); data << uint8(msg); - if(msg) + if (msg != EQUIP_ERR_OK) { data << uint64(pItem ? pItem->GetGUID() : 0); data << uint64(pItem2 ? pItem2->GetGUID() : 0); data << uint8(0); // not 0 there... - if(msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) + if (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) { uint32 level = 0; - if(pItem) - if(ItemPrototype const* proto = pItem->GetProto()) + if (pItem) + if (ItemPrototype const* proto = pItem->GetProto()) level = proto->RequiredLevel; data << uint32(level); // new 2.4.0 @@ -11497,7 +11496,7 @@ void Player::SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 p WorldPacket data( SMSG_BUY_FAILED, (8+4+4+1) ); data << uint64(pCreature ? pCreature->GetGUID() : 0); data << uint32(item); - if( param > 0 ) + if (param > 0) data << uint32(param); data << uint8(msg); GetSession()->SendPacket(&data); @@ -11509,7 +11508,7 @@ void Player::SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 WorldPacket data( SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 data << uint64(pCreature ? pCreature->GetGUID() : 0); data << uint64(guid); - if( param > 0 ) + if (param > 0) data << uint32(param); data << uint8(msg); GetSession()->SendPacket(&data); @@ -11525,15 +11524,15 @@ void Player::ClearTrade() void Player::TradeCancel(bool sendback) { - if(pTrader) + if (pTrader) { // send yellow "Trade canceled" message to both traders WorldSession* ws; ws = GetSession(); - if(sendback) + if (sendback) ws->SendCancelTrade(); ws = pTrader->GetSession(); - if(!ws->PlayerLogout()) + if (!ws->PlayerLogout()) ws->SendCancelTrade(); // cleanup @@ -11547,7 +11546,7 @@ void Player::TradeCancel(bool sendback) void Player::UpdateItemDuration(uint32 time, bool realtimeonly) { - if(m_itemDuration.empty()) + if (m_itemDuration.empty()) return; sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time, realtimeonly); @@ -11568,17 +11567,17 @@ void Player::UpdateEnchantTime(uint32 time) { assert(itr->item); next = itr; - if(!itr->item->GetEnchantmentId(itr->slot)) + if (!itr->item->GetEnchantmentId(itr->slot)) { next = m_enchantDuration.erase(itr); } - else if(itr->leftduration <= time) + else if (itr->leftduration <= time) { ApplyEnchantment(itr->item, itr->slot, false, false); itr->item->ClearEnchantment(itr->slot); next = m_enchantDuration.erase(itr); } - else if(itr->leftduration > time) + else if (itr->leftduration > time) { itr->leftduration -= time; ++next; @@ -11590,11 +11589,11 @@ void Player::AddEnchantmentDurations(Item *item) { for(int x = 0; x < MAX_ENCHANTMENT_SLOT; ++x) { - if(!item->GetEnchantmentId(EnchantmentSlot(x))) + if (!item->GetEnchantmentId(EnchantmentSlot(x))) continue; uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x)); - if( duration > 0 ) + if (duration > 0) AddEnchantmentDuration(item, EnchantmentSlot(x), duration); } } @@ -11603,7 +11602,7 @@ void Player::RemoveEnchantmentDurations(Item *item) { for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end();) { - if(itr->item == item) + if (itr->item == item) { // save duration in item item->SetEnchantmentDuration(EnchantmentSlot(itr->slot), itr->leftduration); @@ -11620,9 +11619,9 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) for(EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr = next) { next = itr; - if(itr->slot == slot) + if (itr->slot == slot) { - if(itr->item && itr->item->GetEnchantmentId(slot)) + if (itr->item && itr->item->GetEnchantmentId(slot)) { // remove from stats ApplyEnchantment(itr->item, slot, false, false); @@ -11640,47 +11639,38 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) // NOTE: no need to remove these from stats, since these aren't equipped // in inventory for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEnchantmentId(slot) ) - pItem->ClearEnchantment(slot); - } + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (pItem->GetEnchantmentId(slot)) + pItem->ClearEnchantment(slot); // in inventory bags for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { + if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) for(uint32 j = 0; j < pBag->GetBagSize(); ++j) - { - Item* pItem = pBag->GetItemByPos(j); - if( pItem && pItem->GetEnchantmentId(slot) ) - pItem->ClearEnchantment(slot); - } - } - } + if (Item* pItem = pBag->GetItemByPos(j)) + if (pItem->GetEnchantmentId(slot)) + pItem->ClearEnchantment(slot); } // duration == 0 will remove item enchant void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration) { - if(!item) + if (!item) return; - if(slot >= MAX_ENCHANTMENT_SLOT) + if (slot >= MAX_ENCHANTMENT_SLOT) return; for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { - if(itr->item == item && itr->slot == slot) + if (itr->item == item && itr->slot == slot) { itr->item->SetEnchantmentDuration(itr->slot, itr->leftduration); m_enchantDuration.erase(itr); break; } } - if(item && duration > 0 ) + if (item && duration > 0 ) { GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000)); m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); @@ -11695,24 +11685,24 @@ void Player::ApplyEnchantment(Item *item,bool apply) void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) { - if(!item) + if (!item) return; - if(!item->IsEquipped()) + if (!item->IsEquipped()) return; - if(slot >= MAX_ENCHANTMENT_SLOT) + if (slot >= MAX_ENCHANTMENT_SLOT) return; uint32 enchant_id = item->GetEnchantmentId(slot); - if(!enchant_id) + if (!enchant_id) return; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) + if (!pEnchant) return; - if(!ignore_condition && pEnchant->EnchantmentCondition && !((Player*)this)->EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) + if (!ignore_condition && pEnchant->EnchantmentCondition && !((Player*)this)->EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) return; if (!item->IsBroken()) @@ -11739,9 +11729,9 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(enchant_amount), apply); break; case ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL: - if(enchant_spell_id) + if (enchant_spell_id) { - if(apply) + if (apply) { int32 basepoints = 0; // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 0c2ea07fc..8634ac873 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -40,7 +40,7 @@ void WorldSession::SendNameQueryOpcode(Player *p) // guess size WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10) ); data.append(p->GetPackGUID()); // player guid - data << uint8(0); // added in 3.1 + data << uint8(0); // added in 3.1; if > 1, then end of packet data << p->GetName(); // played name data << uint8(0); // realm name for cross realm BG usage data << uint8(p->getRace()); @@ -104,7 +104,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 // guess size WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10) ); data.appendPackGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); - data << uint8(0); // added in 3.1 + data << uint8(0); // added in 3.1; if > 1, then end of packet data << name; data << uint8(0); // realm name for cross realm BG usage data << uint8(pRace); // race diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d3a514ffb..6e4f79c60 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8498" + #define REVISION_NR "8502" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 6601f92f2..0bbec6660 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_8469_01_characters_character_spell" - #define REVISION_DB_MANGOS "required_8498_01_mangos_spell_proc_event" + #define REVISION_DB_MANGOS "required_8499_01_mangos_spell_elixir" #define REVISION_DB_REALMD "required_8332_01_realmd_realmcharacters" #endif // __REVISION_SQL_H__