Core/Maps: Replace some Instanceable() checks with IsDungeon()

This commit is contained in:
Shauren
2022-07-20 18:55:40 +02:00
parent 51d7ff6f0b
commit 8466894d81
7 changed files with 19 additions and 25 deletions
+5 -3
View File
@@ -3332,11 +3332,11 @@ bool DB2Manager::GetUiMapPosition(float x, float y, float z, int32 mapId, int32
return true;
}
void DB2Manager::Zone2MapCoordinates(uint32 areaId, float& x, float& y) const
bool DB2Manager::Zone2MapCoordinates(uint32 areaId, float& x, float& y) const
{
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
if (!areaEntry)
return;
return false;
for (auto assignment : Trinity::Containers::MapEqualRange(_uiMapAssignmentByArea[UI_MAP_SYSTEM_WORLD], areaId))
{
@@ -3348,8 +3348,10 @@ void DB2Manager::Zone2MapCoordinates(uint32 areaId, float& x, float& y) const
x = assignment.second->Region[0].X + tmpY * (assignment.second->Region[1].X - assignment.second->Region[0].X);
y = assignment.second->Region[0].Y + tmpX * (assignment.second->Region[1].Y - assignment.second->Region[0].Y);
break;
return true;
}
return false;
}
void DB2Manager::Map2ZoneCoordinates(uint32 areaId, float& x, float& y) const
+1 -1
View File
@@ -465,7 +465,7 @@ public:
std::vector<TransmogSetItemEntry const*> const* GetTransmogSetItems(uint32 transmogSetId) const;
static bool GetUiMapPosition(float x, float y, float z, int32 mapId, int32 areaId, int32 wmoDoodadPlacementId, int32 wmoGroupId, UiMapSystem system, bool local,
int32* uiMapId = nullptr, DBCPosition2D* newPos = nullptr);
void Zone2MapCoordinates(uint32 areaId, float& x, float& y) const;
bool Zone2MapCoordinates(uint32 areaId, float& x, float& y) const;
void Map2ZoneCoordinates(uint32 areaId, float& x, float& y) const;
bool IsUiMapPhase(uint32 phaseId) const;
WMOAreaTableEntry const* GetWMOAreaTable(int32 rootId, int32 adtId, int32 groupId) const;
@@ -608,7 +608,7 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
{
TC_LOG_DEBUG("maps", "InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId);
Map const* map = sMapMgr->CreateBaseMap(mapid);
if (!map->Instanceable())
if (!map->IsDungeon())
return;
InstanceSaveHashMap::iterator itr = m_instanceSaveById.find(instanceId);
@@ -618,12 +618,9 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
DeleteInstanceFromDB(instanceId); // even if save not loaded
Map* iMap = ((MapInstanced*)map)->FindInstanceMap(instanceId);
if (iMap && iMap->IsDungeon())
((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
if (iMap)
{
((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
iMap->DeleteRespawnTimes();
iMap->DeleteCorpseData();
}
+2 -2
View File
@@ -141,7 +141,7 @@ Map* MapInstanced::CreateInstanceForPlayer(uint32 mapId, Player* player, uint32
}
}
}
else if (!IsGarrison())
else if (IsDungeon())
{
InstancePlayerBind* pBind = player->GetBoundInstance(GetId(), player->GetDifficultyID(GetEntry()));
InstanceSave* pSave = pBind ? pBind->save : nullptr;
@@ -198,7 +198,7 @@ Map* MapInstanced::CreateInstanceForPlayer(uint32 mapId, Player* player, uint32
map = CreateInstance(newInstanceId, nullptr, diff, player->GetTeamId());
}
}
else
else if (IsGarrison())
{
newInstanceId = player->GetGUID().GetCounter();
map = FindInstanceMap(newInstanceId);
+4 -6
View File
@@ -293,11 +293,10 @@ uint32 MapManager::GetNumInstances()
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
{
Map* map = itr->second;
if (!map->Instanceable())
if (!map->IsDungeon())
continue;
MapInstanced::InstancedMaps &maps = ((MapInstanced*)map)->GetInstancedMaps();
for (MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
if (mitr->second->IsDungeon()) ret++;
ret += maps.size();
}
return ret;
}
@@ -310,12 +309,11 @@ uint32 MapManager::GetNumPlayersInInstances()
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
{
Map* map = itr->second;
if (!map->Instanceable())
if (!map->IsDungeon())
continue;
MapInstanced::InstancedMaps &maps = ((MapInstanced*)map)->GetInstancedMaps();
for (MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
if (mitr->second->IsDungeon())
ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize();
ret += mitr->second->GetPlayers().getSize();
}
return ret;
}
+4 -7
View File
@@ -340,20 +340,17 @@ public:
AreaTableEntry const* zoneEntry = areaEntry->ParentAreaID ? sAreaTableStore.LookupEntry(areaEntry->ParentAreaID) : areaEntry;
ASSERT(zoneEntry);
Map* map = sMapMgr->CreateBaseMap(zoneEntry->ContinentID);
x /= 100.0f;
y /= 100.0f;
if (map->Instanceable())
Map* map = sMapMgr->CreateBaseMap(zoneEntry->ContinentID);
if (!sDB2Manager.Zone2MapCoordinates(areaEntry->ParentAreaID ? uint32(areaEntry->ParentAreaID) : areaId, x, y))
{
handler->PSendSysMessage(LANG_INVALID_ZONE_MAP, areaId, areaEntry->AreaName[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName());
handler->SetSentErrorMessage(true);
return false;
}
x /= 100.0f;
y /= 100.0f;
sDB2Manager.Zone2MapCoordinates(areaEntry->ParentAreaID ? uint32(areaEntry->ParentAreaID) : areaId, x, y);
if (!MapManager::IsValidMapCoord(zoneEntry->ContinentID, x, y))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, uint32(zoneEntry->ContinentID));
+1 -1
View File
@@ -540,7 +540,7 @@ public:
if (!target->GetMap()->IsBattlegroundOrArena())
target->SetBattlegroundEntryPoint();
}
else if (map->Instanceable())
else if (map->IsDungeon())
{
Map* targetMap = target->GetMap();
Player* targetGroupLeader = nullptr;