From 669502916a7ba7414fd4693b8edefba3d6da6fa9 Mon Sep 17 00:00:00 2001 From: Charles A Edwards Date: Sun, 31 Jan 2016 18:58:38 +0000 Subject: [PATCH] More build errors fixed 13 errors left at this stage. --- src/game/BattleGround/BattleGround.cpp | 1 + src/game/BattleGround/BattleGroundHandler.cpp | 4 +- src/game/Object/Creature.cpp | 20 ++++++ src/game/Object/Creature.h | 8 ++- src/game/Object/GameObject.h | 3 +- src/game/Object/Guild.cpp | 13 +++- src/game/Object/Guild.h | 3 + src/game/Object/Item.cpp | 29 +++++--- src/game/Object/Item.h | 10 ++- src/game/Object/ItemPrototype.h | 38 +++++----- src/game/Object/Player.h | 11 ++- src/game/Object/Unit.cpp | 17 ++++- src/game/Object/Unit.h | 6 +- src/game/Server/SharedDefines.h | 3 +- src/game/WorldHandlers/Channel.cpp | 1 + src/game/WorldHandlers/Chat.cpp | 72 +++++++++++++++++++ src/game/WorldHandlers/Chat.h | 39 +++++++++- src/game/WorldHandlers/GuildHandler.cpp | 4 +- src/game/WorldHandlers/Map.h | 3 +- src/game/WorldHandlers/PetitionsHandler.cpp | 12 ++-- src/modules/Eluna/PlayerMethods.h | 4 +- src/shared/Database/Field.h | 34 ++++++++- 22 files changed, 279 insertions(+), 56 deletions(-) diff --git a/src/game/BattleGround/BattleGround.cpp b/src/game/BattleGround/BattleGround.cpp index bfec280d6..e62483318 100644 --- a/src/game/BattleGround/BattleGround.cpp +++ b/src/game/BattleGround/BattleGround.cpp @@ -40,6 +40,7 @@ #include "Util.h" #include "Formulas.h" #include "GridNotifiersImpl.h" +#include "Chat.h" namespace MaNGOS { diff --git a/src/game/BattleGround/BattleGroundHandler.cpp b/src/game/BattleGround/BattleGroundHandler.cpp index a67b88513..e96b18f2a 100644 --- a/src/game/BattleGround/BattleGroundHandler.cpp +++ b/src/game/BattleGround/BattleGroundHandler.cpp @@ -579,7 +579,7 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data) if (!unit) return; - if (!unit->isSpiritService()) // it's not spirit service + if (!unit->IsSpiritService()) // it's not spirit service return; unit->SendAreaSpiritHealerQueryOpcode(GetPlayer()); @@ -600,7 +600,7 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data) if (!unit) return; - if (!unit->isSpiritService()) // it's not spirit service + if (!unit->IsSpiritService()) // it's not spirit service return; sScriptMgr.OnGossipHello(GetPlayer(), unit); diff --git a/src/game/Object/Creature.cpp b/src/game/Object/Creature.cpp index 497551ce0..e76322f95 100644 --- a/src/game/Object/Creature.cpp +++ b/src/game/Object/Creature.cpp @@ -1616,6 +1616,19 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd return Unit::IsImmuneToSpellEffect(spellInfo, index, castOnSelf); } +// return true if this creature is tapped by the player or by a member of his group. +bool Creature::IsTappedBy(Player const* player) const +{ + if (player == GetOriginalLootRecipient()) + return true; + + Group const* playerGroup = player->GetGroup(); + if (!playerGroup || playerGroup != GetGroupLootRecipient()) // if we dont have a group we arent the recipient + return false; // if creature doesnt have group bound it means it was solo killed by someone else + + return true; +} + SpellEntry const* Creature::ReachWithSpellAttack(Unit* pVictim) { if (!pVictim) @@ -2147,6 +2160,13 @@ bool Creature::HasCategoryCooldown(uint32 spell_id) const return (itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->GetCategoryRecoveryTime() / IN_MILLISECONDS)) > time(NULL)); } +uint32 Creature::GetCreatureSpellCooldownDelay(uint32 spellId) const +{ + CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId); + time_t t = time(NULL); + return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0); +} + bool Creature::HasSpellCooldown(uint32 spell_id) const { CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id); diff --git a/src/game/Object/Creature.h b/src/game/Object/Creature.h index f363c0d08..342e2d57b 100644 --- a/src/game/Object/Creature.h +++ b/src/game/Object/Creature.h @@ -511,7 +511,8 @@ class Creature : public Unit bool IsCorpse() const { return getDeathState() == CORPSE; } bool IsDespawned() const { return getDeathState() == DEAD; } - void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } + void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } + uint32 GetCorpseDelay() const { return m_corpseDelay; } bool IsRacialLeader() const { return GetCreatureInfo()->RacialLeader; } bool IsCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } bool IsGuard() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; } @@ -529,6 +530,7 @@ class Creature : public Unit bool IsImmuneToSpell(SpellEntry const* spellInfo, bool castOnSelf) override; bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index, bool castOnSelf) const override; + bool IsTappedBy(Player const* player) const; bool IsElite() const { @@ -572,6 +574,7 @@ class Creature : public Unit void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time); void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time); + uint32 Creature::GetCreatureSpellCooldownDelay(uint32 spellId) const; void AddCreatureSpellCooldown(uint32 spellid); bool HasSpellCooldown(uint32 spell_id) const; bool HasCategoryCooldown(uint32 spell_id) const; @@ -726,8 +729,9 @@ class Creature : public Unit void SendAreaSpiritHealerQueryOpcode(Player* pl); - void SetVirtualItem(VirtualItemSlot slot, uint32 item_id) { SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, item_id); } + void SetVirtualItem(VirtualItemSlot slot, uint32 item_id) { SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, item_id); } + void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; } bool IsReputationGainDisabled() { return DisableReputationGain; } protected: diff --git a/src/game/Object/GameObject.h b/src/game/Object/GameObject.h index 971f97254..0e72d1303 100644 --- a/src/game/Object/GameObject.h +++ b/src/game/Object/GameObject.h @@ -707,7 +707,8 @@ class GameObject : public WorldObject (m_respawnTime > 0 && !m_spawnedByDefault) || (m_respawnTime == 0 && m_spawnedByDefault); } - bool isSpawnedByDefault() const { return m_spawnedByDefault; } + bool isSpawnedByDefault() const { return m_spawnedByDefault; } + void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; } uint32 GetRespawnDelay() const { return m_respawnDelayTime; } void Refresh(); void Delete(); diff --git a/src/game/Object/Guild.cpp b/src/game/Object/Guild.cpp index 56fcf76d3..eedee02b0 100644 --- a/src/game/Object/Guild.cpp +++ b/src/game/Object/Guild.cpp @@ -244,7 +244,7 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank) pl->SetInGuild(m_Id); pl->SetGuildLevel(GetLevel()); pl->SetRank(newmember.RankId); - pl->SetGuildInvited(0); + pl->SetGuildIdInvited(0); } UpdateAccountsNumber(); @@ -567,6 +567,17 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding) return members.empty(); } +bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank) +{ + if (newRank <= GetLowestRank()) // Validate rank (allow only existing ranks) + if (MemberSlot* member = GetMemberSlot(guid)) + { + member->ChangeRank(newRank); + return true; + } + return false; +} + void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language) { if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_GCHATSPEAK)) diff --git a/src/game/Object/Guild.h b/src/game/Object/Guild.h index 651d91abe..98ad958e0 100644 --- a/src/game/Object/Guild.h +++ b/src/game/Object/Guild.h @@ -35,6 +35,8 @@ class Item; +#define GUILD_RANK_NONE 0xFF + enum GuildDefaultRanks { // these ranks can be modified, but they cannot be deleted @@ -362,6 +364,7 @@ class Guild void SetLeader(ObjectGuid guid); bool AddMember(ObjectGuid plGuid, uint32 plRank); bool DelMember(ObjectGuid guid, bool isDisbanding = false); + bool ChangeMemberRank(ObjectGuid guid, uint8 newRank); // lowest rank is the count of ranks - 1 (the highest rank_id in table) uint32 GetLowestRank() const { return m_Ranks.size() - 1; } diff --git a/src/game/Object/Item.cpp b/src/game/Object/Item.cpp index ffdea054d..2a519e5d2 100644 --- a/src/game/Object/Item.cpp +++ b/src/game/Object/Item.cpp @@ -184,39 +184,39 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt case ITEM_SUBCLASS_CONTAINER: return true; case ITEM_SUBCLASS_SOUL_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS)) + if (!(pProto->BagFamily & BAG_FAMILY_SOUL_SHARDS)) return false; return true; case ITEM_SUBCLASS_HERB_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_HERBS)) + if (!(pProto->BagFamily & BAG_FAMILY_HERBS)) return false; return true; case ITEM_SUBCLASS_ENCHANTING_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_ENCHANTING_SUPP)) + if (!(pProto->BagFamily & BAG_FAMILY_ENCHANTING_SUPP)) return false; return true; case ITEM_SUBCLASS_MINING_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_MINING_SUPP)) + if (!(pProto->BagFamily & BAG_FAMILY_MINING_SUPP)) return false; return true; case ITEM_SUBCLASS_ENGINEERING_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_ENGINEERING_SUPP)) + if (!(pProto->BagFamily & BAG_FAMILY_ENGINEERING_SUPP)) return false; return true; case ITEM_SUBCLASS_GEM_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_GEMS)) + if (!(pProto->BagFamily & BAG_FAMILY_GEMS)) return false; return true; case ITEM_SUBCLASS_LEATHERWORKING_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_LEATHERWORKING_SUPP)) + if (!(pProto->BagFamily & BAG_FAMILY_LEATHERWORKING_SUPP)) return false; return true; case ITEM_SUBCLASS_INSCRIPTION_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_INSCRIPTION_SUPP)) + if (!(pProto->BagFamily & BAG_FAMILY_INSCRIPTION_SUPP)) return false; return true; case ITEM_SUBCLASS_FISHING_CONTAINER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_FISHING_SUPP)) + if (!(pProto->BagFamily & BAG_FAMILY_FISHING_SUPP)) return false; return true; default: @@ -226,11 +226,11 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt switch (pBagProto->SubClass) { case ITEM_SUBCLASS_QUIVER: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_ARROWS)) + if (!(pProto->BagFamily & BAG_FAMILY_ARROWS)) return false; return true; case ITEM_SUBCLASS_AMMO_POUCH: - if (!(pProto->BagFamily & BAG_FAMILY_MASK_BULLETS)) + if (!(pProto->BagFamily & BAG_FAMILY_BULLETS)) return false; return true; default: @@ -409,6 +409,13 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) return true; } +bool Item::IsNotEmptyBag() const +{ + if (Bag const* bag = ToBag()) + return !bag->IsEmpty(); + return false; +} + void Item::UpdateDuration(Player* owner, uint32 diff) { if (!GetUInt32Value(ITEM_FIELD_DURATION)) diff --git a/src/game/Object/Item.h b/src/game/Object/Item.h index c9abe1b2a..01b3a6a27 100644 --- a/src/game/Object/Item.h +++ b/src/game/Object/Item.h @@ -308,9 +308,15 @@ class Item : public Object virtual bool LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid = ObjectGuid()); virtual void DeleteFromDB(); void DeleteFromInventoryDB(); - void LoadLootFromDB(Field* fields); + void LoadLootFromDB(Field* fields); - bool IsBag() const { return GetProto()->InventoryType == INVTYPE_BAG; } + Bag* ToBag() { if (IsBag()) return reinterpret_cast(this); else return NULL; } + const Bag* ToBag() const { if (IsBag()) return reinterpret_cast(this); else return NULL; } + + bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_UNLOCKED); } + bool IsBag() const { return GetProto()->InventoryType == INVTYPE_BAG; } + bool IsCurrencyToken() const { return GetProto()->IsCurrencyToken(); } + bool IsNotEmptyBag() const; bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; } bool CanBeTraded(bool mail = false) const; void SetInTrade(bool b = true) { mb_in_trade = b; } diff --git a/src/game/Object/ItemPrototype.h b/src/game/Object/ItemPrototype.h index 6ef020841..615830bda 100644 --- a/src/game/Object/ItemPrototype.h +++ b/src/game/Object/ItemPrototype.h @@ -169,23 +169,23 @@ enum ItemPrototypeFlags2 enum BagFamilyMask { - BAG_FAMILY_MASK_NONE = 0x00000000, - BAG_FAMILY_MASK_ARROWS = 0x00000001, - BAG_FAMILY_MASK_BULLETS = 0x00000002, - BAG_FAMILY_MASK_SOUL_SHARDS = 0x00000004, - BAG_FAMILY_MASK_LEATHERWORKING_SUPP = 0x00000008, - BAG_FAMILY_MASK_INSCRIPTION_SUPP = 0x00000010, - BAG_FAMILY_MASK_HERBS = 0x00000020, - BAG_FAMILY_MASK_ENCHANTING_SUPP = 0x00000040, - BAG_FAMILY_MASK_ENGINEERING_SUPP = 0x00000080, - BAG_FAMILY_MASK_KEYS = 0x00000100, - BAG_FAMILY_MASK_GEMS = 0x00000200, - BAG_FAMILY_MASK_MINING_SUPP = 0x00000400, - BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT = 0x00000800, - BAG_FAMILY_MASK_VANITY_PETS = 0x00001000, - BAG_FAMILY_MASK_CURRENCY_TOKENS = 0x00002000, - BAG_FAMILY_MASK_QUEST_ITEMS = 0x00004000, - BAG_FAMILY_MASK_FISHING_SUPP = 0x00008000, + BAG_FAMILY_NONE = 0x00000000, + BAG_FAMILY_ARROWS = 0x00000001, + BAG_FAMILY_BULLETS = 0x00000002, + BAG_FAMILY_SOUL_SHARDS = 0x00000004, + BAG_FAMILY_LEATHERWORKING_SUPP = 0x00000008, + BAG_FAMILY_INSCRIPTION_SUPP = 0x00000010, + BAG_FAMILY_HERBS = 0x00000020, + BAG_FAMILY_ENCHANTING_SUPP = 0x00000040, + BAG_FAMILY_ENGINEERING_SUPP = 0x00000080, + BAG_FAMILY_KEYS = 0x00000100, + BAG_FAMILY_GEMS = 0x00000200, + BAG_FAMILY_MINING_SUPP = 0x00000400, + BAG_FAMILY_SOULBOUND_EQUIPMENT = 0x00000800, + BAG_FAMILY_VANITY_PETS = 0x00001000, + BAG_FAMILY_CURRENCY_TOKENS = 0x00002000, + BAG_FAMILY_QUEST_ITEMS = 0x00004000, + BAG_FAMILY_FISHING_SUPP = 0x00008000, }; enum SocketColor @@ -652,7 +652,9 @@ struct ItemPrototype } return false; - } + } + + bool IsCurrencyToken() const { return BagFamily & BAG_FAMILY_CURRENCY_TOKENS; } uint32 GetMaxStackSize() const { return Stackable > 0 ? uint32(Stackable) : uint32(0x7FFFFFFF - 1); } float getDPS() const; diff --git a/src/game/Object/Player.h b/src/game/Object/Player.h index f376c5c13..41226233a 100644 --- a/src/game/Object/Player.h +++ b/src/game/Object/Player.h @@ -788,6 +788,9 @@ enum EnviromentalDamage DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss }; +/* + * This is defined in Chat.h (just like Zero, One, and Two) + * DELETE THIS IF ALL IS OK enum PlayerChatTag { CHAT_TAG_NONE = 0x00, @@ -798,6 +801,8 @@ enum PlayerChatTag CHAT_TAG_DEV = 0x10, // Developer }; +*/ + enum PlayedTimeIndex { PLAYED_TIME_TOTAL = 0, @@ -1747,7 +1752,11 @@ class Player : public Unit void SetInGuild(uint32 GuildId); void SetGuildLevel(uint32 level) { SetUInt32Value(PLAYER_GUILDLEVEL, level); } void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); } - void SetGuildInvited(uint32 GuildId, ObjectGuid inviter = ObjectGuid()) { m_GuildIdInvited = GuildId; m_GuildInviterGuid = inviter; } +// void SetGuildInvited(uint32 GuildId, ObjectGuid inviter = ObjectGuid()) { m_GuildIdInvited = GuildId; m_GuildInviterGuid = inviter; } .. PRE Dev21 version (DELETE IT?) + void SetGuildIdInvited(uint32 GuildId) + { + m_GuildIdInvited = GuildId; + } uint32 GetGuildId() const { return GetGuildGuid().GetCounter(); } ObjectGuid GetGuildGuid() const { return GetGuidValue(OBJECT_FIELD_DATA); } std::string GetGuildName() const; diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 8ea00f8f2..b4d58edb7 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -5699,6 +5699,21 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType SendAttackStateUpdate(&dmgInfo); } +void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) +{ + CalcDamageInfo dmgInfo; + dmgInfo.HitInfo = HitInfo; + dmgInfo.attacker = this; + dmgInfo.target = target; + dmgInfo.damage = Damage - AbsorbDamage - Resist - BlockedAmount; + dmgInfo.damageSchoolMask = damageSchoolMask; + dmgInfo.absorb = AbsorbDamage; + dmgInfo.resist = Resist; + dmgInfo.TargetState = TargetState; + dmgInfo.blocked_amount = BlockedAmount; + SendAttackStateUpdate(&dmgInfo); +} + void Unit::setPowerType(Powers new_powertype) { SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype); @@ -9782,7 +9797,7 @@ bool Unit::isInvisibleForAlive() const if (m_AuraFlags & UNIT_AURAFLAG_ALIVE_INVISIBLE) return true; // TODO: maybe spiritservices also have just an aura - return isSpiritService(); + return IsSpiritService(); } uint32 Unit::GetCreatureType() const diff --git a/src/game/Object/Unit.h b/src/game/Object/Unit.h index ded0546b0..a225d67f4 100644 --- a/src/game/Object/Unit.h +++ b/src/game/Object/Unit.h @@ -2422,7 +2422,8 @@ class Unit : public WorldObject * \todo What's the swingtype for? */ void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); - /** + void SendAttackStateUpdate(uint32 HitInfo, Unit* target, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); + /** * Used to send a update to the combat log for all \ref Player/\ref Unit s in the vicinity. * @param log Info about who/what did damage to who and how etc, data needed for the packet * \see OpcodesList::SMSG_SPELLNONMELEEDAMAGELOG @@ -3034,7 +3035,8 @@ class Unit : public WorldObject // delayed+channeled spells are always interrupted void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0); - Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; } + Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; } + Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; } Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; bool CheckAndIncreaseCastCounter(); diff --git a/src/game/Server/SharedDefines.h b/src/game/Server/SharedDefines.h index d26748fb4..31bcedbcc 100644 --- a/src/game/Server/SharedDefines.h +++ b/src/game/Server/SharedDefines.h @@ -3062,7 +3062,8 @@ enum SkillType SKILL_BALANCE = 574, SKILL_DESTRUCTION = 593, SKILL_HOLY2 = 594, - SKILL_DISCIPLINE = 613, + SKILL_DISCIPLINE = 613, + SKILL_LOCKPICKING = 633, SKILL_PET_BAT = 653, SKILL_PET_HYENA = 654, SKILL_PET_BIRD_OF_PREY = 655, diff --git a/src/game/WorldHandlers/Channel.cpp b/src/game/WorldHandlers/Channel.cpp index 3c23f2cd8..4a2960d69 100644 --- a/src/game/WorldHandlers/Channel.cpp +++ b/src/game/WorldHandlers/Channel.cpp @@ -26,6 +26,7 @@ #include "ObjectMgr.h" #include "World.h" #include "SocialMgr.h" +#include "Chat.h" Channel::Channel(const std::string& name, uint32 channel_id) : m_announce(true), m_moderate(false), m_name(name), m_flags(0), m_channelId(channel_id) diff --git a/src/game/WorldHandlers/Chat.cpp b/src/game/WorldHandlers/Chat.cpp index dd5059b7b..5a2816434 100644 --- a/src/game/WorldHandlers/Chat.cpp +++ b/src/game/WorldHandlers/Chat.cpp @@ -3716,6 +3716,78 @@ void ChatHandler::LogCommand(char const* fullcmd) } } +void ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg msgtype, char const* message, Language language /*= LANG_UNIVERSAL*/, ChatTagFlags chatTag /*= CHAT_TAG_NONE*/, + ObjectGuid const& senderGuid /*= ObjectGuid()*/, char const* senderName /*= NULL*/, + ObjectGuid const& targetGuid /*= ObjectGuid()*/, char const* targetName /*= NULL*/, + char const* channelName /*= NULL*/) +{ + bool isGM = chatTag & CHAT_TAG_GM; + + data.Initialize(isGM ? SMSG_GM_MESSAGECHAT : SMSG_MESSAGECHAT); + data << uint8(msgtype); + data << uint32(language); + data << ObjectGuid(senderGuid); + data << uint32(0); // 2.1.0 + + switch (msgtype) + { + case CHAT_MSG_MONSTER_SAY: + case CHAT_MSG_MONSTER_PARTY: + case CHAT_MSG_MONSTER_YELL: + case CHAT_MSG_MONSTER_WHISPER: + case CHAT_MSG_RAID_BOSS_WHISPER: + case CHAT_MSG_RAID_BOSS_EMOTE: + case CHAT_MSG_MONSTER_EMOTE: + MANGOS_ASSERT(senderName); + data << uint32(strlen(senderName) + 1); + data << senderName; + data << ObjectGuid(targetGuid); // Unit Target + if (targetGuid && !targetGuid.IsPlayer() && !targetGuid.IsPet()) + { + data << uint32(strlen(targetName) + 1); // target name length + data << targetName; // target name + } + MANGOS_ASSERT(message); + data << uint32(strlen(message) + 1); + data << message; + data << uint8(chatTag); + break; + case CHAT_MSG_BG_SYSTEM_NEUTRAL: + case CHAT_MSG_BG_SYSTEM_ALLIANCE: + case CHAT_MSG_BG_SYSTEM_HORDE: + data << ObjectGuid(targetGuid); // Unit Target + if (targetGuid && !targetGuid.IsPlayer()) + { + MANGOS_ASSERT(targetName); + data << uint32(strlen(targetName) + 1); // target name length + data << targetName; // target name + } + MANGOS_ASSERT(message); + data << uint32(strlen(message) + 1); + data << message; + data << uint8(chatTag); + break; + default: + if (msgtype == CHAT_MSG_CHANNEL) + { + MANGOS_ASSERT(channelName); + data << channelName; + } + data << ObjectGuid(targetGuid); + MANGOS_ASSERT(message); + data << uint32(strlen(message) + 1); + data << message; + data << uint8(chatTag); + if (isGM) + { + MANGOS_ASSERT(senderName); + data << uint32(strlen(senderName) + 1); + data << senderName; + } + break; + } +} + // Instantiate template for helper function template void ChatHandler::ShowNpcOrGoSpawnInformation(uint32 guid); template void ChatHandler::ShowNpcOrGoSpawnInformation(uint32 guid); diff --git a/src/game/WorldHandlers/Chat.h b/src/game/WorldHandlers/Chat.h index 2988ff739..c316a9d8f 100644 --- a/src/game/WorldHandlers/Chat.h +++ b/src/game/WorldHandlers/Chat.h @@ -69,6 +69,17 @@ enum ChatCommandSearchResult CHAT_COMMAND_UNKNOWN_SUBCOMMAND, // command found but some level subcommand not find in subcommand list }; +enum PlayerChatTag +{ + CHAT_TAG_NONE = 0, + CHAT_TAG_AFK = 1, + CHAT_TAG_DND = 2, + CHAT_TAG_GM = 3, + CHAT_TAG_COM = 4, // Commentator + CHAT_TAG_DEV = 5, // Developer +}; +typedef uint32 ChatTagFlags; + class ChatHandler { public: @@ -109,7 +120,33 @@ class ChatHandler ChatCommand const* FindCommand(char const* text); bool isValidChatMessage(const char* msg); - bool HasSentErrorMessage() { return sentErrorMessage;} + bool HasSentErrorMessage() { return sentErrorMessage; } + + /** + * \brief Prepare SMSG_GM_MESSAGECHAT/SMSG_MESSAGECHAT + * + * Method: BuildChatPacket build message chat packet generic way + * FullName: ChatHandler::BuildChatPacket + * Access: public static + * Returns: void + * + * \param WorldPacket& data : Provided packet will be filled with requested info + * \param ChatMsg msgtype : Message type from ChatMsg enum from SharedDefines.h + * \param ChatTagFlags chatTag : Chat tag from PlayerChatTag in Chat.h + * \param char const* message : Message to send + * \param Language language : Language from Language enum in SharedDefines.h + * \param ObjectGuid const& senderGuid : May be null in some case but often required for ignore list + * \param char const* senderName : Required for type *MONSTER* or *BATTLENET, but also if GM is true + * \param ObjectGuid const& targetGuid : Often null, but needed for type *MONSTER* or *BATTLENET or *BATTLEGROUND* or *ACHIEVEMENT + * \param char const* targetName : Often null, but needed for type *MONSTER* or *BATTLENET or *BATTLEGROUND* + * \param char const* channelName : Required only for CHAT_MSG_CHANNEL + **/ + static void BuildChatPacket( + WorldPacket& data, ChatMsg msgtype, char const* message, Language language = LANG_UNIVERSAL, ChatTagFlags chatTag = CHAT_TAG_NONE, + ObjectGuid const& senderGuid = ObjectGuid(), char const* senderName = NULL, + ObjectGuid const& targetGuid = ObjectGuid(), char const* targetName = NULL, + char const* channelName = NULL); + protected: explicit ChatHandler() : m_session(NULL) {} // for CLI subclass diff --git a/src/game/WorldHandlers/GuildHandler.cpp b/src/game/WorldHandlers/GuildHandler.cpp index d9a5c0ca3..89b2a499b 100644 --- a/src/game/WorldHandlers/GuildHandler.cpp +++ b/src/game/WorldHandlers/GuildHandler.cpp @@ -143,7 +143,7 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) DEBUG_LOG("Player %s Invited %s to Join his Guild", GetPlayer()->GetName(), Invitedname.c_str()); - player->SetGuildInvited(GetPlayer()->GetGuildId(), GetPlayer()->GetObjectGuid()); + player->SetGuildIdInvited(GetPlayer()->GetGuildId()); // Put record into guildlog guild->LogGuildEvent(GUILD_EVENT_LOG_INVITE_PLAYER, GetPlayer()->GetObjectGuid(), player->GetObjectGuid()); @@ -292,7 +292,7 @@ void WorldSession::HandleGuildDeclineOpcode(WorldPacket& recvPacket) if (Player* inviter = sObjectMgr.GetPlayer(GetPlayer()->GetGuildInviterGuid())) inviter->SendGuildDeclined(GetPlayer()->GetName(), recvPacket.GetOpcode() == CMSG_GUILD_AUTO_DECLINE); - GetPlayer()->SetGuildInvited(0); + GetPlayer()->SetGuildIdInvited(0); GetPlayer()->SetInGuild(0); GetPlayer()->SetGuildLevel(0); } diff --git a/src/game/WorldHandlers/Map.h b/src/game/WorldHandlers/Map.h index 44b96d32c..d216326d6 100644 --- a/src/game/WorldHandlers/Map.h +++ b/src/game/WorldHandlers/Map.h @@ -198,7 +198,8 @@ class Map : public GridRefManager bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); } bool IsRaid() const { return i_mapEntry && i_mapEntry->IsRaid(); } bool IsNonRaidDungeon() const { return i_mapEntry && i_mapEntry->IsNonRaidDungeon(); } - bool IsRaidOrHeroicDungeon() const { return IsRaid() || GetDifficulty() > DUNGEON_DIFFICULTY_NORMAL; } + bool IsRaidOrHeroicDungeon() const { return IsRaid() || GetDifficulty() > DUNGEON_DIFFICULTY_NORMAL; } + bool IsHeroic() const { return IsRaid() || i_spawnMode >= DUNGEON_DIFFICULTY_HEROIC; } bool IsBattleGround() const { return i_mapEntry && i_mapEntry->IsBattleGround(); } bool IsBattleArena() const { return i_mapEntry && i_mapEntry->IsBattleArena(); } bool IsBattleGroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattleGroundOrArena(); } diff --git a/src/game/WorldHandlers/PetitionsHandler.cpp b/src/game/WorldHandlers/PetitionsHandler.cpp index 8590fb5b6..5d6c79878 100644 --- a/src/game/WorldHandlers/PetitionsHandler.cpp +++ b/src/game/WorldHandlers/PetitionsHandler.cpp @@ -92,11 +92,11 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - if (!pCreature->isTabardDesigner()) - { - sLog.outError("WORLD: HandlePetitionBuyOpcode - unsupported npc type, npc: %s", guidNPC.GetString().c_str()); - return; - } + if (!pCreature->IsTabardDesigner()) + { + sLog.outError("WORLD: HandlePetitionBuyOpcode - unsupported npc type, npc: %s", guidNPC.GetString().c_str()); + return; + } if (sGuildMgr.GetGuildByName(name)) { @@ -678,7 +678,7 @@ void WorldSession::SendPetitionShowList(ObjectGuid guid) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); // only guild petitions currently used - if (!pCreature->isTabardDesigner()) + if (!pCreature->IsTabardDesigner()) { DEBUG_LOG("WORLD: HandlePetitionShowListOpcode - %s is not supported npc type.", guid.GetString().c_str()); return; diff --git a/src/modules/Eluna/PlayerMethods.h b/src/modules/Eluna/PlayerMethods.h index b7c38c2a2..b2540f742 100644 --- a/src/modules/Eluna/PlayerMethods.h +++ b/src/modules/Eluna/PlayerMethods.h @@ -2440,10 +2440,10 @@ namespace LuaPlayer bool no_cost = Eluna::CHECKVAL(L, 2, true); #ifdef CATA - player->ResetTalents(no_cost); + player->resetTalents(no_cost); #else #ifdef TRINITY - player->ResetTalents(no_cost); + player->resetTalents(no_cost); #else player->resetTalents(no_cost); #endif diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index 38dfd018a..d31f19a2f 100644 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -102,7 +102,19 @@ class Field * * @return bool */ - bool GetBool() const { return mValue ? atoi(mValue) > 0 : false; } + bool GetBool() const { return mValue ? atoi(mValue) > 0 : false; } + /** + * @brief + * + * @return double + */ + double GetDouble() const { return mValue ? static_cast(atof(mValue)) : 0.0f; } + /** + * @brief + * + * @return int8 + */ + int8 GetInt8() const { return mValue ? static_cast(atol(mValue)) : int8(0); } /** * @brief * @@ -145,8 +157,26 @@ class Field return 0; return value; - } + } + /** + * @brief + * + * @return int64 + */ + uint64 GetInt64() const + { + int64 value = 0; + if (!mValue || sscanf(mValue, SI64FMTD, &value) == -1) + return 0; + return value; + } + + /** + * @brief + * + * @param type + */ void SetType(enum DataTypes type) { mType = type; } /**