mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
fix(Core/Instances): Ensure team is acquired before spawning creatures (#21221)
This commit is contained in:
@@ -57,23 +57,7 @@ void InstanceScript::SaveToDB()
|
|||||||
|
|
||||||
void InstanceScript::OnPlayerEnter(Player* player)
|
void InstanceScript::OnPlayerEnter(Player* player)
|
||||||
{
|
{
|
||||||
if (!IsTwoFactionInstance())
|
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && IsTwoFactionInstance())
|
||||||
return;
|
|
||||||
|
|
||||||
if (GetTeamIdInInstance() == TEAM_NEUTRAL)
|
|
||||||
{
|
|
||||||
if (Group* group = player->GetGroup())
|
|
||||||
{
|
|
||||||
if (Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID()))
|
|
||||||
_teamIdInInstance = leader->GetTeamId();
|
|
||||||
else
|
|
||||||
_teamIdInInstance = player->GetTeamId();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_teamIdInInstance = player->GetTeamId();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
|
|
||||||
player->SetFaction((_teamIdInInstance == TEAM_HORDE) ? 1610 /*FACTION_HORDE*/ : 1 /*FACTION_ALLIANCE*/);
|
player->SetFaction((_teamIdInInstance == TEAM_HORDE) ? 1610 /*FACTION_HORDE*/ : 1 /*FACTION_ALLIANCE*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -285,6 +285,10 @@ public:
|
|||||||
[[nodiscard]] bool AllBossesDone() const;
|
[[nodiscard]] bool AllBossesDone() const;
|
||||||
[[nodiscard]] bool AllBossesDone(std::initializer_list<uint32> bossIds) const;
|
[[nodiscard]] bool AllBossesDone(std::initializer_list<uint32> bossIds) const;
|
||||||
|
|
||||||
|
TeamId GetTeamIdInInstance() const { return _teamIdInInstance; }
|
||||||
|
void SetTeamIdInInstance(TeamId teamId) { _teamIdInInstance = teamId; }
|
||||||
|
bool IsTwoFactionInstance() const;
|
||||||
|
|
||||||
TaskScheduler scheduler;
|
TaskScheduler scheduler;
|
||||||
protected:
|
protected:
|
||||||
void SetHeaders(std::string const& dataHeaders);
|
void SetHeaders(std::string const& dataHeaders);
|
||||||
@@ -325,9 +329,6 @@ protected:
|
|||||||
void WritePersistentData(std::ostringstream& data);
|
void WritePersistentData(std::ostringstream& data);
|
||||||
virtual void WriteSaveDataMore(std::ostringstream& /*data*/) { }
|
virtual void WriteSaveDataMore(std::ostringstream& /*data*/) { }
|
||||||
|
|
||||||
TeamId GetTeamIdInInstance() const { return _teamIdInInstance; }
|
|
||||||
bool IsTwoFactionInstance() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void LoadObjectData(ObjectData const* creatureData, ObjectInfoMap& objectInfo);
|
static void LoadObjectData(ObjectData const* creatureData, ObjectInfoMap& objectInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -3020,6 +3020,15 @@ bool InstanceMap::AddPlayerToMap(Player* player)
|
|||||||
m_resetAfterUnload = false;
|
m_resetAfterUnload = false;
|
||||||
m_unloadWhenEmpty = false;
|
m_unloadWhenEmpty = false;
|
||||||
|
|
||||||
|
if (instance_data && instance_data->IsTwoFactionInstance()
|
||||||
|
&& instance_data->GetTeamIdInInstance() == TEAM_NEUTRAL)
|
||||||
|
{
|
||||||
|
instance_data->SetTeamIdInInstance(player->GetTeamId());
|
||||||
|
if (Group* group = player->GetGroup())
|
||||||
|
if (Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID()))
|
||||||
|
instance_data->SetTeamIdInInstance(leader->GetTeamId());
|
||||||
|
}
|
||||||
|
|
||||||
// this will acquire the same mutex so it cannot be in the previous block
|
// this will acquire the same mutex so it cannot be in the previous block
|
||||||
Map::AddPlayerToMap(player);
|
Map::AddPlayerToMap(player);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user