diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 71fa48710ce..41bd55fa916 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -22,6 +22,7 @@ if(SERVERS OR TOOLS) add_subdirectory(openssl) add_subdirectory(jemalloc) add_subdirectory(argon2) + add_subdirectory(short_alloc) endif() if(SERVERS) @@ -29,7 +30,6 @@ if(SERVERS) add_subdirectory(readline) add_subdirectory(gsoap) add_subdirectory(efsw) - add_subdirectory(short_alloc) endif() if(TOOLS) diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 9965641bc9e..a06c87d2eeb 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -27,6 +27,7 @@ #include "GameTime.h" #include "GridNotifiersImpl.h" #include "Group.h" +#include "GroupMgr.h" #include "MiscPackets.h" #include "Object.h" #include "ObjectAccessor.h" @@ -1042,6 +1043,7 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team) group = new Group; SetBgRaid(team, group); group->Create(player); + sGroupMgr->AddGroup(group); } else // raid already exist { diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index bd7c55a7023..0f3cc9425de 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -446,7 +446,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const joinData.result = LFG_JOIN_NOT_MEET_REQS; else if (grp) { - if (grp->GetMembersCount() > MAXGROUPSIZE) + if (grp->GetMembersCount() > MAX_GROUP_SIZE) joinData.result = LFG_JOIN_TOO_MUCH_MEMBERS; else { diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index 034f1586979..c9274a6d84b 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -370,7 +370,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check) LfgRolesMap proposalRoles; // Check for correct size - if (check.size() > MAXGROUPSIZE || check.empty()) + if (check.size() > MAX_GROUP_SIZE || check.empty()) { TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: ({}): Size wrong - Not compatibles", GetDetailedMatchRoles(check)); return LFG_INCOMPATIBLES_WRONG_GROUP_SIZE; @@ -396,7 +396,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check) // Check if more than one LFG group and number of players joining uint8 numPlayers = 0; uint8 numLfgGroups = 0; - for (GuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++it) + for (GuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAX_GROUP_SIZE; ++it) { ObjectGuid guid = *it; LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid); @@ -421,8 +421,8 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check) } } - // Group with less that MAXGROUPSIZE members always compatible - if (!sLFGMgr->IsSoloLFG() && numPlayers != MAXGROUPSIZE) //solo lfg + // Group with less that MAX_GROUP_SIZE members always compatible + if (!sLFGMgr->IsSoloLFG() && numPlayers != MAX_GROUP_SIZE) //solo lfg { TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: ({}) single group. Compatibles", GetDetailedMatchRoles(check)); LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front()); @@ -443,7 +443,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check) return LFG_INCOMPATIBLES_MULTIPLE_LFG_GROUPS; } - if (numPlayers > MAXGROUPSIZE) + if (numPlayers > MAX_GROUP_SIZE) { TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: ({}) Too many players ({})", GetDetailedMatchRoles(check), numPlayers); SetCompatibles(strGuids, LFG_INCOMPATIBLES_TOO_MUCH_PLAYERS); @@ -520,7 +520,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check) } // Enough players? - if (!sLFGMgr->IsSoloLFG() && numPlayers != MAXGROUPSIZE) //solo lfg + if (!sLFGMgr->IsSoloLFG() && numPlayers != MAX_GROUP_SIZE) //solo lfg { TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: ({}) Compatibles but not enough players({})", GetDetailedMatchRoles(check), numPlayers); LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 98ebb98f2bd..089a414f7a2 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2041,7 +2041,9 @@ void Creature::setDeathState(DeathState s) Motion_Initialize(); Unit::setDeathState(ALIVE); - LoadCreaturesAddon(); + + if (!IsPet()) + LoadCreaturesAddon(); } } diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index a265ec4c77c..3fa2ebf40c0 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1011,19 +1011,9 @@ void WorldObject::setActive(bool on) return; if (on) - { - if (GetTypeId() == TYPEID_UNIT) - map->AddToActive(ToCreature()); - else if (GetTypeId() == TYPEID_DYNAMICOBJECT) - map->AddToActive((DynamicObject*)this); - } + map->AddToActive(this); else - { - if (GetTypeId() == TYPEID_UNIT) - map->RemoveFromActive(ToCreature()); - else if (GetTypeId() == TYPEID_DYNAMICOBJECT) - map->RemoveFromActive((DynamicObject*)this); - } + map->RemoveFromActive(this); } void WorldObject::SetFarVisible(bool on) diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index d4b8d373fc8..1b26f6a4f82 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -1874,7 +1874,6 @@ bool Pet::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 SetPhaseMask(phaseMask, false); Object::_Create(guidlow, petId, HighGuid::Pet); - m_spawnId = guidlow; m_originalEntry = Entry; if (!InitEntry(Entry)) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e6a3b4fe127..5543652b36e 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -4512,8 +4512,7 @@ void Player::BuildPlayerRepop() // there must be SMSG.STOP_MIRROR_TIMER // the player cannot have a corpse already on current map, only bones which are not returned by GetCorpse - WorldLocation corpseLocation = GetCorpseLocation(); - if (corpseLocation.GetMapId() == GetMapId()) + if (GetCorpseLocation().GetMapId() == GetMapId()) { TC_LOG_ERROR("entities.player", "Player::BuildPlayerRepop: Player '{}' ({}) already has a corpse", GetName(), GetGUID().ToString()); return; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index d67225835a1..2b5b12c6413 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1700,7 +1700,7 @@ class TC_GAME_API Player : public Unit, public GridObject void KillPlayer(); static void OfflineResurrect(ObjectGuid const& guid, CharacterDatabaseTransaction trans); bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; } - WorldLocation GetCorpseLocation() const { return _corpseLocation; } + WorldLocation const& GetCorpseLocation() const { return _corpseLocation; } uint32 GetResurrectionSpellId(); void ResurrectPlayer(float restore_percent, bool applySickness = false); void BuildPlayerRepop(); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 1e515b48582..e0c3a42dedf 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3269,7 +3269,7 @@ void Unit::_AddAura(UnitAura* aura, Unit* caster) ASSERT(!m_cleanupDone); m_ownedAuras.emplace(aura->GetId(), aura); - _RemoveNoStackAurasDueToAura(aura); + _RemoveNoStackAurasDueToAura(aura, true); if (aura->IsRemoved()) return; @@ -3363,7 +3363,7 @@ void Unit::_ApplyAura(AuraApplication* aurApp, uint8 effMask) { Aura* aura = aurApp->GetBase(); - _RemoveNoStackAurasDueToAura(aura); + _RemoveNoStackAurasDueToAura(aura, false); if (aurApp->GetRemoveMode()) return; @@ -3517,7 +3517,7 @@ void Unit::_UnapplyAura(AuraApplication* aurApp, AuraRemoveMode removeMode) ABORT(); } -void Unit::_RemoveNoStackAurasDueToAura(Aura* aura) +void Unit::_RemoveNoStackAurasDueToAura(Aura* aura, bool owned) { SpellInfo const* spellProto = aura->GetSpellInfo(); @@ -3531,23 +3531,10 @@ void Unit::_RemoveNoStackAurasDueToAura(Aura* aura) return; } - bool remove = false; - for (AuraApplicationMap::iterator i = m_appliedAuras.begin(); i != m_appliedAuras.end(); ++i) - { - if (remove) - { - remove = false; - i = m_appliedAuras.begin(); - } - - if (aura->CanStackWith(i->second->GetBase())) - continue; - - RemoveAura(i, AURA_REMOVE_BY_DEFAULT); - if (i == m_appliedAuras.end()) - break; - remove = true; - } + if (owned) + RemoveOwnedAuras([aura](Aura const* ownedAura) { return !aura->CanStackWith(ownedAura); }, AURA_REMOVE_BY_DEFAULT); + else + RemoveAppliedAuras([aura](AuraApplication const* appliedAura) { return !aura->CanStackWith(appliedAura->GetBase()); }, AURA_REMOVE_BY_DEFAULT); } void Unit::_RegisterAuraEffect(AuraEffect* aurEff, bool apply) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 99fb781cef8..1e2753842f2 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1320,7 +1320,7 @@ class TC_GAME_API Unit : public WorldObject void _ApplyAura(AuraApplication* aurApp, uint8 effMask); void _UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveMode removeMode); void _UnapplyAura(AuraApplication* aurApp, AuraRemoveMode removeMode); - void _RemoveNoStackAurasDueToAura(Aura* aura); + void _RemoveNoStackAurasDueToAura(Aura* aura, bool owned); void _RegisterAuraEffect(AuraEffect* aurEff, bool apply); // m_ownedAuras container management diff --git a/src/server/game/Entities/Unit/UnitDefines.h b/src/server/game/Entities/Unit/UnitDefines.h index af72559baa8..a26da83b29e 100644 --- a/src/server/game/Entities/Unit/UnitDefines.h +++ b/src/server/game/Entities/Unit/UnitDefines.h @@ -171,9 +171,9 @@ enum UnitFlags : uint32 UNIT_FLAG_SILENCED | UNIT_FLAG_NON_ATTACKABLE_2 | UNIT_FLAG_PACIFIED | UNIT_FLAG_STUNNED | UNIT_FLAG_IN_COMBAT | UNIT_FLAG_ON_TAXI | UNIT_FLAG_DISARMED | UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | UNIT_FLAG_POSSESSED | UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_UNK_28 | - UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT | UNIT_FLAG_SHEATHE | UNIT_FLAG_IMMUNE), + UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT | UNIT_FLAG_SHEATHE | UNIT_FLAG_IMMUNE), // SKIP - UNIT_FLAG_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG_DISALLOWED) + UNIT_FLAG_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG_DISALLOWED) // SKIP }; DEFINE_ENUM_FLAG(UnitFlags); @@ -222,9 +222,9 @@ enum UnitFlags2 : uint32 /* UNIT_FLAG2_PLAY_DEATH_ANIM | */ UNIT_FLAG2_ALLOW_CHEAT_SPELLS | UNIT_FLAG2_UNUSED_1 | UNIT_FLAG2_UNUSED_2 | UNIT_FLAG2_UNUSED_3 | UNIT_FLAG2_UNUSED_4 | UNIT_FLAG2_UNUSED_5 | UNIT_FLAG2_UNUSED_6 | UNIT_FLAG2_UNUSED_7 | UNIT_FLAG2_UNUSED_8 | UNIT_FLAG2_UNUSED_9 | - UNIT_FLAG2_UNUSED_10 | UNIT_FLAG2_UNUSED_11 | UNIT_FLAG2_UNUSED_12 | UNIT_FLAG2_UNUSED_13), + UNIT_FLAG2_UNUSED_10 | UNIT_FLAG2_UNUSED_11 | UNIT_FLAG2_UNUSED_12 | UNIT_FLAG2_UNUSED_13), // SKIP - UNIT_FLAG2_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG2_DISALLOWED) + UNIT_FLAG2_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG2_DISALLOWED) // SKIP }; DEFINE_ENUM_FLAG(UnitFlags2); diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index e34c353edb0..bcb6e6b41af 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -79,31 +79,14 @@ class ObjectWorldLoader uint32& i_corpses; }; -template void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellCoord const& /*cellCoord*/) { } - -template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellCoord const& cellCoord) -{ - Cell cell(cellCoord); - obj->SetCurrentCell(cell); -} - -template<> void ObjectGridLoader::SetObjectCell(GameObject* obj, CellCoord const& cellCoord) +void ObjectGridLoader::SetObjectCell(MapObject* obj, CellCoord const& cellCoord) { Cell cell(cellCoord); obj->SetCurrentCell(cell); } template -void AddObjectHelper(CellCoord &cell, GridRefManager &m, uint32 &count, Map* /*map*/, T *obj) -{ - obj->AddToGrid(m); - ObjectGridLoader::SetObjectCell(obj, cell); - obj->AddToWorld(); - ++count; -} - -template <> -void AddObjectHelper(CellCoord &cell, CreatureMapType &m, uint32 &count, Map* map, Creature *obj) +void AddObjectHelper(CellCoord &cell, GridRefManager &m, uint32 &count, Map* map, T *obj) { obj->AddToGrid(m); ObjectGridLoader::SetObjectCell(obj, cell); diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index e07d8345783..4621420c529 100644 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -24,6 +24,7 @@ #include "GridDefines.h" #include "Cell.h" +class MapObject; class ObjectWorldLoader; class TC_GAME_API ObjectGridLoader @@ -42,7 +43,7 @@ class TC_GAME_API ObjectGridLoader void LoadN(void); - template static void SetObjectCell(T* obj, CellCoord const& cellCoord); + static void SetObjectCell(MapObject* obj, CellCoord const& cellCoord); private: Cell i_cell; diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 26e0117a701..693b4002252 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -64,7 +64,7 @@ m_dungeonDifficulty(DUNGEON_DIFFICULTY_NORMAL), m_raidDifficulty(RAID_DIFFICULTY m_bgGroup(nullptr), m_bfGroup(nullptr), m_lootMethod(FREE_FOR_ALL), m_lootThreshold(ITEM_QUALITY_UNCOMMON), m_looterGuid(), m_masterLooterGuid(), m_subGroupsCounts(nullptr), m_guid(), m_counter(0), m_maxEnchantingLevel(0), m_dbStoreId(0), m_isLeaderOffline(false) { - for (uint8 i = 0; i < TARGETICONCOUNT; ++i) + for (uint8 i = 0; i < TARGET_ICONS_COUNT; ++i) m_targetIcons[i].Clear(); } @@ -232,7 +232,7 @@ void Group::LoadGroupFromDB(Field* fields) m_looterGuid = ObjectGuid(HighGuid::Player, fields[2].GetUInt32()); m_lootThreshold = ItemQualities(fields[3].GetUInt8()); - for (uint8 i = 0; i < TARGETICONCOUNT; ++i) + for (uint8 i = 0; i < TARGET_ICONS_COUNT; ++i) m_targetIcons[i].Set(fields[4 + i].GetUInt64()); m_groupType = GroupType(fields[12].GetUInt8()); @@ -401,7 +401,7 @@ bool Group::AddMember(Player* player) bool groupFound = false; for (; subGroup < MAX_RAID_SUBGROUPS; ++subGroup) { - if (m_subGroupsCounts[subGroup] < MAXGROUPSIZE) + if (m_subGroupsCounts[subGroup] < MAX_GROUP_SIZE) { groupFound = true; break; @@ -438,7 +438,7 @@ bool Group::AddMember(Player* player) if (!isRaidGroup()) // reset targetIcons for non-raid-groups { - for (uint8 i = 0; i < TARGETICONCOUNT; ++i) + for (uint8 i = 0; i < TARGET_ICONS_COUNT; ++i) m_targetIcons[i].Clear(); } @@ -1627,12 +1627,12 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) void Group::SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid) { - if (id >= TARGETICONCOUNT) + if (id >= TARGET_ICONS_COUNT) return; // clean other icons if (targetGuid) - for (int i=0; i bgEntry->MaxGroupSize) // no MinPlayerCount for battlegrounds + if (memberscount > bgEntry->MAX_GROUP_SIZE) // no MinPlayerCount for battlegrounds return ERR_BATTLEGROUND_NONE; // ERR_GROUP_JOIN_BATTLEGROUND_TOO_MANY handled on client side // get a player as reference, to compare other players' stats to (arena team id, queue id based on level, etc.) @@ -2387,7 +2387,7 @@ void Group::SetLfgRoles(ObjectGuid guid, uint8 roles) bool Group::IsFull() const { - return isRaidGroup() ? (m_memberSlots.size() >= MAXRAIDSIZE) : (m_memberSlots.size() >= MAXGROUPSIZE); + return isRaidGroup() ? (m_memberSlots.size() >= MAX_RAID_SIZE) : (m_memberSlots.size() >= MAX_GROUP_SIZE); } bool Group::isLFGGroup() const @@ -2501,7 +2501,7 @@ bool Group::SameSubGroup(ObjectGuid guid1, MemberSlot const* slot2) const bool Group::HasFreeSlotSubGroup(uint8 subgroup) const { - return (m_subGroupsCounts && m_subGroupsCounts[subgroup] < MAXGROUPSIZE); + return (m_subGroupsCounts && m_subGroupsCounts[subgroup] < MAX_GROUP_SIZE); } uint8 Group::GetMemberGroup(ObjectGuid guid) const diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index 4bf4378686b..7793e092978 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -39,10 +39,11 @@ class WorldSession; struct MapEntry; -#define MAXGROUPSIZE 5 -#define MAXRAIDSIZE 40 -#define MAX_RAID_SUBGROUPS MAXRAIDSIZE/MAXGROUPSIZE -#define TARGETICONCOUNT 8 +#define MAX_GROUP_SIZE 5 +#define MAX_RAID_SIZE 40 +#define MAX_RAID_SUBGROUPS MAX_RAID_SIZE / MAX_GROUP_SIZE + +#define TARGET_ICONS_COUNT 8 enum RollVote { @@ -357,7 +358,7 @@ class TC_GAME_API Group Difficulty m_raidDifficulty; Battleground* m_bgGroup; Battlefield* m_bfGroup; - ObjectGuid m_targetIcons[TARGETICONCOUNT]; + ObjectGuid m_targetIcons[TARGET_ICONS_COUNT]; LootMethod m_lootMethod; ItemQualities m_lootThreshold; ObjectGuid m_looterGuid; diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index fd3fae44bdf..2ba9dff0b6e 100644 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -52,7 +52,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPackets::LFG::LFGJoin& packet) { if (!sLFGMgr->isOptionEnabled(lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER | lfg::LFG_OPTION_ENABLE_RAID_BROWSER) || (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID() && - (GetPlayer()->GetGroup()->GetMembersCount() == MAXGROUPSIZE || !GetPlayer()->GetGroup()->isLFGGroup()))) + (GetPlayer()->GetGroup()->GetMembersCount() == MAX_GROUP_SIZE || !GetPlayer()->GetGroup()->isLFGGroup()))) return; if (packet.Slots.empty()) diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 9d9e90b1f69..98f1e1ab29d 100644 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -218,9 +218,9 @@ void WorldSession::SendSpiritResurrect() // get corpse nearest graveyard WorldSafeLocsEntry const* corpseGrave = nullptr; - WorldLocation corpseLocation = _player->GetCorpseLocation(); if (_player->HasCorpse()) { + WorldLocation const& corpseLocation = _player->GetCorpseLocation(); corpseGrave = sObjectMgr->GetClosestGraveyard(corpseLocation.GetPositionX(), corpseLocation.GetPositionY(), corpseLocation.GetPositionZ(), corpseLocation.GetMapId(), _player->GetTeam()); } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 3f50c404f54..bd597e9ad88 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3719,71 +3719,84 @@ bool Map::ActiveObjectsNearGrid(NGridType const& ngrid) const return false; } -template -void Map::AddToActive(T* obj) +void Map::AddToActive(WorldObject* obj) { AddToActiveHelper(obj); -} -template <> -void Map::AddToActive(Creature* c) -{ - AddToActiveHelper(c); + Optional respawnLocation; + switch (obj->GetTypeId()) + { + case TYPEID_UNIT: + if (Creature* creature = obj->ToCreature(); !creature->IsPet() && creature->GetSpawnId()) + { + respawnLocation.emplace(); + creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ); + } + break; + case TYPEID_GAMEOBJECT: + if (GameObject* gameObject = obj->ToGameObject(); gameObject->GetSpawnId()) + { + respawnLocation.emplace(); + gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ); + } + break; + default: + break; + } - // also not allow unloading spawn grid to prevent creating creature clone at load - if (!c->IsPet() && c->GetSpawnId()) + if (respawnLocation) { - float x, y, z; - c->GetRespawnPosition(x, y, z); - GridCoord p = Trinity::ComputeGridCoord(x, y); + GridCoord p = Trinity::ComputeGridCoord(respawnLocation->GetPositionX(), respawnLocation->GetPositionY()); if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock(); else { - GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY()); - TC_LOG_ERROR("maps", "Active creature{} added to grid[{}, {}] but spawn grid[{}, {}] was not loaded.", - c->GetGUID().ToString(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); + GridCoord p2 = Trinity::ComputeGridCoord(obj->GetPositionX(), obj->GetPositionY()); + TC_LOG_ERROR("maps", "Active object {} added to grid[{}, {}] but spawn grid[{}, {}] was not loaded.", + obj->GetGUID().ToString(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); } } } -template<> -void Map::AddToActive(DynamicObject* d) +void Map::RemoveFromActive(WorldObject* obj) { - AddToActiveHelper(d); -} - -template -void Map::RemoveFromActive(T* /*obj*/) { } + RemoveFromActiveHelper(obj); -template <> -void Map::RemoveFromActive(Creature* c) -{ - RemoveFromActiveHelper(c); + Optional respawnLocation; + switch (obj->GetTypeId()) + { + case TYPEID_UNIT: + if (Creature* creature = obj->ToCreature(); !creature->IsPet() && creature->GetSpawnId()) + { + respawnLocation.emplace(); + creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ); + } + break; + case TYPEID_GAMEOBJECT: + if (GameObject* gameObject = obj->ToGameObject(); gameObject->GetSpawnId()) + { + respawnLocation.emplace(); + gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ); + } + break; + default: + break; + } - // also allow unloading spawn grid - if (!c->IsPet() && c->GetSpawnId()) + if (respawnLocation) { - float x, y, z; - c->GetRespawnPosition(x, y, z); - GridCoord p = Trinity::ComputeGridCoord(x, y); + GridCoord p = Trinity::ComputeGridCoord(respawnLocation->GetPositionX(), respawnLocation->GetPositionY()); if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock(); else { - GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY()); - TC_LOG_ERROR("maps", "Active creature {} removed from grid[{}, {}] but spawn grid[{}, {}] was not loaded.", - c->GetGUID().ToString(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); + GridCoord p2 = Trinity::ComputeGridCoord(obj->GetPositionX(), obj->GetPositionY()); + TC_LOG_ERROR("maps", "Active object {} removed from grid[{}, {}] but spawn grid[{}, {}] was not loaded.", + obj->GetGUID().ToString(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); } } } -template<> -void Map::RemoveFromActive(DynamicObject* obj) -{ - RemoveFromActiveHelper(obj); -} - template TC_GAME_API bool Map::AddToMap(Corpse*); template TC_GAME_API bool Map::AddToMap(Creature*); template TC_GAME_API bool Map::AddToMap(GameObject*); diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index f6814efbdcc..dadd8cc14de 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -489,12 +489,10 @@ class TC_GAME_API Map : public GridRefManager void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target); // must called with AddToWorld - template - void AddToActive(T* obj); + void AddToActive(WorldObject* obj); // must called with RemoveFromWorld - template - void RemoveFromActive(T* obj); + void RemoveFromActive(WorldObject* obj); template void SwitchGridContainers(T* obj, bool on); std::unordered_map CreatureGroupHolder; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 48b281c3647..1b12ecf3362 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -2597,6 +2597,9 @@ void UnitAura::Remove(AuraRemoveMode removeMode) void UnitAura::FillTargetMap(std::unordered_map& targets, Unit* caster) { + if (GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISABLE_AURA_WHILE_DEAD) && !GetUnitOwner()->IsAlive()) + return; + Unit* ref = caster; if (!ref) ref = GetUnitOwner(); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 4b31ea6fbff..f080cc537a7 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2247,27 +2247,30 @@ void World::DetectDBCLang() std::string availableLocalsStr; uint8 default_locale = TOTAL_LOCALES; - for (uint8 i = default_locale-1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8 + for (uint8 i = LOCALE_enUS; i < TOTAL_LOCALES; ++i) { if (race->Name[i][0] != '\0') // check by race names { - default_locale = i; + // Mark the first found locale as default locale + if (default_locale == TOTAL_LOCALES) + default_locale = i; + m_availableDbcLocaleMask |= (1 << i); availableLocalsStr += localeNames[i]; availableLocalsStr += " "; } } - if (default_locale != m_lang_confid && m_lang_confid < TOTAL_LOCALES && - (m_availableDbcLocaleMask & (1 << m_lang_confid))) + if (m_availableDbcLocaleMask == 0) { - default_locale = m_lang_confid; + TC_LOG_ERROR("server.loading", "Unable to determine your DBC Locale! (corrupt DBC?)"); + exit(1); } - if (default_locale >= TOTAL_LOCALES) + if (default_locale != m_lang_confid && m_lang_confid < TOTAL_LOCALES && + (m_availableDbcLocaleMask & (1 << m_lang_confid))) { - TC_LOG_ERROR("server.loading", "Unable to determine your DBC Locale! (corrupt DBC?)"); - exit(1); + default_locale = m_lang_confid; } m_defaultDbcLocale = LocaleConstant(default_locale); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 8119d1321c8..62caaefc129 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -86,7 +86,7 @@ enum WorldTimers }; /// Configuration elements -enum WorldBoolConfigs +enum WorldBoolConfigs : uint32 { CONFIG_DURABILITY_LOSS_IN_PVP = 0, CONFIG_ADDON_CHANNEL, @@ -181,7 +181,7 @@ enum WorldBoolConfigs BOOL_CONFIG_VALUE_COUNT }; -enum WorldFloatConfigs +enum WorldFloatConfigs : uint32 { CONFIG_GROUP_XP_DISTANCE = 0, CONFIG_MAX_RECRUIT_A_FRIEND_DISTANCE, @@ -206,7 +206,7 @@ enum WorldFloatConfigs FLOAT_CONFIG_VALUE_COUNT }; -enum WorldIntConfigs +enum WorldIntConfigs : uint32 { CONFIG_COMPRESSION = 0, CONFIG_INTERVAL_SAVE, diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp index aed2154129f..f8c7b97cb47 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp @@ -60,7 +60,7 @@ class boss_darkmaster_gandling : public CreatureScript struct boss_darkmaster_gandlingAI : public BossAI { - boss_darkmaster_gandlingAI(Creature* creature) : BossAI(creature, DATA_DARKMASTERGANDLING) { } + boss_darkmaster_gandlingAI(Creature* creature) : BossAI(creature, DATA_DARKMASTER_GANDLING) { } void Reset() override { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp index f058d2ac3d6..56c78aa4162 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp @@ -51,7 +51,7 @@ class boss_doctor_theolen_krastinov : public CreatureScript struct boss_theolenkrastinovAI : public BossAI { - boss_theolenkrastinovAI(Creature* creature) : BossAI(creature, DATA_DOCTORTHEOLENKRASTINOV) { } + boss_theolenkrastinovAI(Creature* creature) : BossAI(creature, DATA_DOCTOR_THEOLEN_KRASTINOV) { } void JustEngagedWith(Unit* who) override { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp index 1efb043fd00..28e7529fa54 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp @@ -49,7 +49,7 @@ class boss_illucia_barov : public CreatureScript struct boss_illuciabarovAI : public BossAI { - boss_illuciabarovAI(Creature* creature) : BossAI(creature, DATA_LADYILLUCIABAROV) { } + boss_illuciabarovAI(Creature* creature) : BossAI(creature, DATA_LADY_ILLUCIA_BAROV) { } void JustEngagedWith(Unit* who) override { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp index eef824e3d03..9a8002b070f 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp @@ -50,7 +50,7 @@ class boss_instructor_malicia : public CreatureScript struct boss_instructormaliciaAI : public BossAI { - boss_instructormaliciaAI(Creature* creature) : BossAI(creature, DATA_INSTRUCTORMALICIA) + boss_instructormaliciaAI(Creature* creature) : BossAI(creature, DATA_INSTRUCTOR_MALICIA) { Initialize(); } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp index 20be79069ed..22ed088934c 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp @@ -45,7 +45,7 @@ class boss_lord_alexei_barov : public CreatureScript struct boss_lordalexeibarovAI : public BossAI { - boss_lordalexeibarovAI(Creature* creature) : BossAI(creature, DATA_LORDALEXEIBAROV) { } + boss_lordalexeibarovAI(Creature* creature) : BossAI(creature, DATA_LORD_ALEXEI_BAROV) { } void Reset() override { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp index 8ae50697d9b..07615837321 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp @@ -48,7 +48,7 @@ class boss_lorekeeper_polkelt : public CreatureScript struct boss_lorekeeperpolkeltAI : public BossAI { - boss_lorekeeperpolkeltAI(Creature* creature) : BossAI(creature, DATA_LOREKEEPERPOLKELT) { } + boss_lorekeeperpolkeltAI(Creature* creature) : BossAI(creature, DATA_LOREKEEPER_POLKELT) { } void JustEngagedWith(Unit* who) override { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp index 63050b56ab5..3b6965f7582 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp @@ -48,7 +48,7 @@ class boss_the_ravenian : public CreatureScript struct boss_theravenianAI : public BossAI { - boss_theravenianAI(Creature* creature) : BossAI(creature, DATA_THERAVENIAN) { } + boss_theravenianAI(Creature* creature) : BossAI(creature, DATA_THE_RAVENIAN) { } void JustEngagedWith(Unit* who) override { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp index 4bbba1d1a85..504cdaf3ca1 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp @@ -85,12 +85,12 @@ class instance_scholomance : public InstanceMapScript switch (type) { - case DATA_LORDALEXEIBAROV: - case DATA_DOCTORTHEOLENKRASTINOV: - case DATA_THERAVENIAN: - case DATA_LOREKEEPERPOLKELT: - case DATA_INSTRUCTORMALICIA: - case DATA_LADYILLUCIABAROV: + case DATA_LORD_ALEXEI_BAROV: + case DATA_DOCTOR_THEOLEN_KRASTINOV: + case DATA_THE_RAVENIAN: + case DATA_LOREKEEPER_POLKELT: + case DATA_INSTRUCTOR_MALICIA: + case DATA_LADY_ILLUCIA_BAROV: CheckToSpawnGandling(); break; default: @@ -133,20 +133,20 @@ class instance_scholomance : public InstanceMapScript { switch (bossId) { - case DATA_DARKMASTERGANDLING: - if (GetBossState(DATA_LORDALEXEIBAROV) != DONE) + case DATA_DARKMASTER_GANDLING: + if (GetBossState(DATA_LORD_ALEXEI_BAROV) != DONE) return false; - if (GetBossState(DATA_DOCTORTHEOLENKRASTINOV) != DONE) + if (GetBossState(DATA_DOCTOR_THEOLEN_KRASTINOV) != DONE) return false; - if (GetBossState(DATA_THERAVENIAN) != DONE) + if (GetBossState(DATA_THE_RAVENIAN) != DONE) return false; - if (GetBossState(DATA_LOREKEEPERPOLKELT) != DONE) + if (GetBossState(DATA_LOREKEEPER_POLKELT) != DONE) return false; - if (GetBossState(DATA_INSTRUCTORMALICIA) != DONE) + if (GetBossState(DATA_INSTRUCTOR_MALICIA) != DONE) return false; - if (GetBossState(DATA_LADYILLUCIABAROV) != DONE) + if (GetBossState(DATA_LADY_ILLUCIA_BAROV) != DONE) return false; - if (GetBossState(DATA_DARKMASTERGANDLING) == DONE) + if (GetBossState(DATA_DARKMASTER_GANDLING) == DONE) return false; break; default: @@ -158,7 +158,7 @@ class instance_scholomance : public InstanceMapScript void CheckToSpawnGandling() { - if (CheckPreBosses(DATA_DARKMASTERGANDLING)) + if (CheckPreBosses(DATA_DARKMASTER_GANDLING)) instance->SummonCreature(NPC_DARKMASTER_GANDLING, GandlingLoc); } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/scholomance.h b/src/server/scripts/EasternKingdoms/Scholomance/scholomance.h index 651f1c26625..42b075eb4b5 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/scholomance.h +++ b/src/server/scripts/EasternKingdoms/Scholomance/scholomance.h @@ -27,13 +27,13 @@ uint32 const EncounterCount = 8; enum SCDataTypes { - DATA_DOCTORTHEOLENKRASTINOV = 0, - DATA_INSTRUCTORMALICIA = 1, - DATA_LADYILLUCIABAROV = 2, - DATA_LORDALEXEIBAROV = 3, - DATA_LOREKEEPERPOLKELT = 4, - DATA_THERAVENIAN = 5, - DATA_DARKMASTERGANDLING = 6, + DATA_DOCTOR_THEOLEN_KRASTINOV = 0, + DATA_INSTRUCTOR_MALICIA = 1, + DATA_LADY_ILLUCIA_BAROV = 2, + DATA_LORD_ALEXEI_BAROV = 3, + DATA_LOREKEEPER_POLKELT = 4, + DATA_THE_RAVENIAN = 5, + DATA_DARKMASTER_GANDLING = 6, DATA_KIRTONOS = 7 }; diff --git a/src/server/shared/SharedDefines.h b/src/server/shared/SharedDefines.h index 0bdd89004f7..f23b5ee486b 100644 --- a/src/server/shared/SharedDefines.h +++ b/src/server/shared/SharedDefines.h @@ -664,7 +664,7 @@ enum SpellAttr7 : uint32 { SPELL_ATTR7_UNK0 = 0x00000001, // TITLE Unknown attribute 0@Attr7 SPELL_ATTR7_IGNORE_DURATION_MODS = 0x00000002, // TITLE Ignore duration modifiers - SPELL_ATTR7_REACTIVATE_AT_RESURRECT = 0x00000004, // TITLE Reactivate at resurrect (client only) + SPELL_ATTR7_DISABLE_AURA_WHILE_DEAD = 0x00000004, // TITLE Disable Aura While Dead SPELL_ATTR7_IS_CHEAT_SPELL = 0x00000008, // TITLE Is cheat spell DESCRIPTION Cannot cast if caster doesn't have UnitFlag2 & UNIT_FLAG2_ALLOW_CHEAT_SPELLS SPELL_ATTR7_UNK4 = 0x00000010, // TITLE Unknown attribute 4@Attr7 DESCRIPTION Soulstone related? SPELL_ATTR7_SUMMON_PLAYER_TOTEM = 0x00000020, // TITLE Summons player-owned totem diff --git a/src/server/shared/enuminfo_SharedDefines.cpp b/src/server/shared/enuminfo_SharedDefines.cpp index bc6b4d77638..bfb9ed34875 100644 --- a/src/server/shared/enuminfo_SharedDefines.cpp +++ b/src/server/shared/enuminfo_SharedDefines.cpp @@ -1173,7 +1173,7 @@ TC_API_EXPORT EnumText EnumUtils::ToString(SpellAttr7 value) { case SPELL_ATTR7_UNK0: return { "SPELL_ATTR7_UNK0", "Unknown attribute 0@Attr7", "" }; case SPELL_ATTR7_IGNORE_DURATION_MODS: return { "SPELL_ATTR7_IGNORE_DURATION_MODS", "Ignore duration modifiers", "" }; - case SPELL_ATTR7_REACTIVATE_AT_RESURRECT: return { "SPELL_ATTR7_REACTIVATE_AT_RESURRECT", "Reactivate at resurrect (client only)", "" }; + case SPELL_ATTR7_DISABLE_AURA_WHILE_DEAD: return { "SPELL_ATTR7_DISABLE_AURA_WHILE_DEAD", "Disable Aura While Dead", "" }; case SPELL_ATTR7_IS_CHEAT_SPELL: return { "SPELL_ATTR7_IS_CHEAT_SPELL", "Is cheat spell", "Cannot cast if caster doesn't have UnitFlag2 & UNIT_FLAG2_ALLOW_CHEAT_SPELLS" }; case SPELL_ATTR7_UNK4: return { "SPELL_ATTR7_UNK4", "Unknown attribute 4@Attr7", "Soulstone related?" }; case SPELL_ATTR7_SUMMON_PLAYER_TOTEM: return { "SPELL_ATTR7_SUMMON_PLAYER_TOTEM", "Summons player-owned totem", "" }; @@ -1217,7 +1217,7 @@ TC_API_EXPORT SpellAttr7 EnumUtils::FromIndex(size_t index) { case 0: return SPELL_ATTR7_UNK0; case 1: return SPELL_ATTR7_IGNORE_DURATION_MODS; - case 2: return SPELL_ATTR7_REACTIVATE_AT_RESURRECT; + case 2: return SPELL_ATTR7_DISABLE_AURA_WHILE_DEAD; case 3: return SPELL_ATTR7_IS_CHEAT_SPELL; case 4: return SPELL_ATTR7_UNK4; case 5: return SPELL_ATTR7_SUMMON_PLAYER_TOTEM; @@ -1258,7 +1258,7 @@ TC_API_EXPORT size_t EnumUtils::ToIndex(SpellAttr7 value) { case SPELL_ATTR7_UNK0: return 0; case SPELL_ATTR7_IGNORE_DURATION_MODS: return 1; - case SPELL_ATTR7_REACTIVATE_AT_RESURRECT: return 2; + case SPELL_ATTR7_DISABLE_AURA_WHILE_DEAD: return 2; case SPELL_ATTR7_IS_CHEAT_SPELL: return 3; case SPELL_ATTR7_UNK4: return 4; case SPELL_ATTR7_SUMMON_PLAYER_TOTEM: return 5;