Scripts/InstanceScript: Fix an issue where LoadAllGrids would load creatures before TeamInInstance was properly set (PR #25340)

# Conflicts:
#	src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp
This commit is contained in:
kvipka
2020-08-28 20:48:41 +03:00
committed by Ovahlord
parent bdb6705911
commit e6e20bd574
5 changed files with 14 additions and 22 deletions

View File

@@ -3819,10 +3819,10 @@ template TC_GAME_API void Map::RemoveFromMap(AreaTrigger*, bool);
/* ******* Dungeon Instance Maps ******* */
InstanceMap::InstanceMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _parent)
InstanceMap::InstanceMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _parent, TeamId InstanceTeam)
: Map(id, expiry, InstanceId, SpawnMode, _parent),
m_resetAfterUnload(false), m_unloadWhenEmpty(false),
i_data(nullptr), i_script_id(0)
i_data(nullptr), i_script_id(0), i_script_team(InstanceTeam)
{
//lets initialize visibility distance for dungeons
InstanceMap::InitVisibilityDistance();

View File

@@ -950,7 +950,7 @@ enum InstanceResetMethod
class TC_GAME_API InstanceMap : public Map
{
public:
InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent);
InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent, TeamId InstanceTeam);
~InstanceMap();
bool AddPlayerToMap(Player*) override;
void RemovePlayerFromMap(Player*, bool) override;
@@ -972,6 +972,8 @@ class TC_GAME_API InstanceMap : public Map
bool HasPermBoundPlayers() const;
uint32 GetMaxPlayers() const;
uint32 GetMaxResetDelay() const;
TeamId GetTeamIdInInstance() const { return i_script_team; }
Team GetTeamInInstance() const { return i_script_team == TEAM_ALLIANCE ? ALLIANCE : HORDE; }
virtual void InitVisibilityDistance() override;
private:
@@ -979,6 +981,7 @@ class TC_GAME_API InstanceMap : public Map
bool m_unloadWhenEmpty;
InstanceScript* i_data;
uint32 i_script_id;
TeamId i_script_team;
};
class TC_GAME_API BattlegroundMap : public Map

View File

@@ -153,7 +153,7 @@ Map* MapInstanced::CreateInstanceForPlayer(uint32 mapId, Player* player, uint32
{
map = FindInstanceMap(loginInstanceId);
if (!map && pSave && pSave->GetInstanceId() == loginInstanceId)
map = CreateInstance(loginInstanceId, pSave, pSave->GetDifficulty());
map = CreateInstance(loginInstanceId, pSave, pSave->GetDifficulty(), player->GetTeamId());
return map;
}
@@ -178,7 +178,7 @@ Map* MapInstanced::CreateInstanceForPlayer(uint32 mapId, Player* player, uint32
map = FindInstanceMap(newInstanceId);
// it is possible that the save exists but the map doesn't
if (!map)
map = CreateInstance(newInstanceId, pSave, pSave->GetDifficulty());
map = CreateInstance(newInstanceId, pSave, pSave->GetDifficulty(), player->GetTeamId());
}
else
{
@@ -191,14 +191,14 @@ Map* MapInstanced::CreateInstanceForPlayer(uint32 mapId, Player* player, uint32
//ASSERT(!FindInstanceMap(NewInstanceId));
map = FindInstanceMap(newInstanceId);
if (!map)
map = CreateInstance(newInstanceId, nullptr, diff);
map = CreateInstance(newInstanceId, nullptr, diff, player->GetTeamId());
}
}
return map;
}
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty, TeamId InstanceTeam)
{
// load/create a map
std::lock_guard<std::mutex> lock(_mapLock);
@@ -222,7 +222,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
TC_LOG_DEBUG("maps", "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");
InstanceMap* map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
InstanceMap* map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this, InstanceTeam);
ASSERT(map->IsDungeon());
map->LoadRespawnTimes();

View File

@@ -50,7 +50,7 @@ class TC_GAME_API MapInstanced : public Map
virtual void InitVisibilityDistance() override;
private:
InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty);
InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty, TeamId InstanceTeam);
BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg);
InstancedMaps m_InstancedMaps;

View File

@@ -114,7 +114,7 @@ class instance_icecrown_citadel : public InstanceMapScript
SetBossNumber(EncounterCount);
LoadBossBoundaries(boundaries);
LoadDoorData(doorData);
TeamInInstance = 0;
TeamInInstance = map->GetTeamInInstance();
IsBonedEligible = true;
IsOozeDanceEligible = true;
IsNauseaEligible = true;
@@ -143,9 +143,6 @@ class instance_icecrown_citadel : public InstanceMapScript
void OnPlayerEnter(Player* player) override
{
if (!TeamInInstance)
TeamInInstance = player->GetTeam();
if (GetBossState(DATA_LADY_DEATHWHISPER) == DONE && GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) != DONE)
SpawnGunship();
}
@@ -271,14 +268,6 @@ class instance_icecrown_citadel : public InstanceMapScript
// Weekly quest spawn prevention
uint32 GetCreatureEntry(ObjectGuid::LowType /*guidLow*/, CreatureData const* data) override
{
if (!TeamInInstance)
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
if (Player* player = players.begin()->GetSource())
TeamInInstance = player->GetTeam();
}
uint32 entry = data->id;
switch (entry)
{
@@ -1356,7 +1345,7 @@ class instance_icecrown_citadel : public InstanceMapScript
ObjectGuid FrozenBolvarGUID;
ObjectGuid PillarsChainedGUID;
ObjectGuid PillarsUnchainedGUID;
uint32 TeamInInstance;
Team TeamInInstance;
uint32 ColdflameJetsState;
uint32 UpperSpireTeleporterActiveState;
std::set<uint32> FrostwyrmGUIDs;