Core/Map: Save weather, light and music overrides in map to send them to players logging in
This commit is contained in:
1 parent
0758c47491
commit
529cabea68
10 files changed
+198
-94
No files matched your search
@@ -223,7 +223,7 @@ m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE),
|
||||
m_VisibilityNotifyPeriod(DEFAULT_VISIBILITY_NOTIFY_PERIOD),
|
||||
m_activeNonPlayersIter(m_activeNonPlayers.end()), _transportsUpdateIter(_transports.end()),
|
||||
i_gridExpiry(expiry),
|
||||
i_scriptLock(false)
|
||||
i_scriptLock(false), _defaultLight(GetDefaultMapLight(id))
|
||||
{
|
||||
m_parentMap = (_parent ? _parent : this);
|
||||
for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
|
||||
@@ -477,6 +477,7 @@ bool Map::AddPlayerToMap(Player* player)
|
||||
|
||||
SendInitSelf(player);
|
||||
SendInitTransports(player);
|
||||
SendZoneDynamicInfo(player);
|
||||
|
||||
player->m_clientGUIDs.clear();
|
||||
player->UpdateObjectVisibility(false);
|
||||
@@ -3433,3 +3434,103 @@ time_t Map::GetLinkedRespawnTime(uint64 guid) const
|
||||
return time_t(0);
|
||||
}
|
||||
|
||||
void Map::SendZoneDynamicInfo(Player* player)
|
||||
{
|
||||
uint32 zoneId = GetZoneId(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
|
||||
ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
|
||||
if (itr == _zoneDynamicInfo.end())
|
||||
return;
|
||||
|
||||
if (uint32 music = itr->second.MusicId)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||
data << uint32(music);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
if (uint32 weather = itr->second.WeatherId)
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
|
||||
data << uint32(weather);
|
||||
data << float(itr->second.WeatherGrade);
|
||||
data << uint8(0);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
if (uint32 overrideLight = itr->second.OverrideLightId)
|
||||
{
|
||||
WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 1);
|
||||
data << uint32(_defaultLight);
|
||||
data << uint32(overrideLight);
|
||||
data << uint32(itr->second.LightFadeInTime);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::SetZoneMusic(uint32 zoneId, uint32 musicId)
|
||||
{
|
||||
if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
|
||||
_zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
|
||||
|
||||
_zoneDynamicInfo[zoneId].MusicId = musicId;
|
||||
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||
data << uint32(musicId);
|
||||
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId)
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade)
|
||||
{
|
||||
if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
|
||||
_zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
|
||||
|
||||
ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
|
||||
info.WeatherId = weatherId;
|
||||
info.WeatherGrade = weatherGrade;
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
|
||||
data << uint32(weatherId);
|
||||
data << float(weatherGrade);
|
||||
data << uint8(0);
|
||||
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId)
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::SetZoneOverrideLight(uint32 zoneId, uint32 lightId, uint32 fadeInTime)
|
||||
{
|
||||
if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
|
||||
_zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
|
||||
|
||||
ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
|
||||
info.OverrideLightId = lightId;
|
||||
info.LightFadeInTime = fadeInTime;
|
||||
Map::PlayerList const& players = GetPlayers();
|
||||
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 1);
|
||||
data << uint32(_defaultLight);
|
||||
data << uint32(lightId);
|
||||
data << uint32(fadeInTime);
|
||||
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId)
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user