diff options
| author | kvipka <qvipka@gmail.com> | 2020-08-28 20:48:41 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-28 19:48:41 +0200 |
| commit | 5d2780c43c36b0ae1cc4ac2694bf6ec464d079c7 (patch) | |
| tree | aa5e5e3c597099145bbf6a01f89e583217cb297f /src/server/game/Maps | |
| parent | b63f5b0d83174abfb1b74111514ec424f5efe748 (diff) | |
Scripts/InstanceScript: Fix an issue where LoadAllGrids would load creatures before TeamInInstance was properly set (PR #25340)
Diffstat (limited to 'src/server/game/Maps')
| -rw-r--r-- | src/server/game/Maps/Map.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/Maps/Map.h | 5 | ||||
| -rw-r--r-- | src/server/game/Maps/MapInstanced.cpp | 10 | ||||
| -rw-r--r-- | src/server/game/Maps/MapInstanced.h | 2 |
4 files changed, 12 insertions, 9 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 17be3a915d3..64a1a5fb2dd 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3743,10 +3743,10 @@ template TC_GAME_API void Map::RemoveFromMap(DynamicObject*, 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(); diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index a6a4e53bc50..06c148cae00 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -916,7 +916,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; @@ -938,6 +938,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; @@ -947,6 +949,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 diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index ae023f153bb..2d7feeda28d 100644 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -155,7 +155,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; } @@ -180,7 +180,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 { @@ -193,14 +193,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); @@ -224,7 +224,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(); diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h index 58be263a767..d60abbc25d1 100644 --- a/src/server/game/Maps/MapInstanced.h +++ b/src/server/game/Maps/MapInstanced.h @@ -63,7 +63,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; |
