Core/Conditions: Implemented missing PlayerCondition columns - time and weather

This commit is contained in:
Shauren
2021-06-04 21:47:43 +02:00
parent 9542d221cb
commit 8aaf750be1
4 changed files with 33 additions and 4 deletions
+16 -2
View File
@@ -2855,7 +2855,19 @@ bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, PlayerConditio
return false;
}
// TODO: time condition
if (condition->Time[0])
{
ByteBuffer unpacker;
unpacker << condition->Time[0];
time_t from = unpacker.ReadPackedTime();
unpacker.rpos(0);
unpacker.wpos(0);
unpacker << condition->Time[1];
time_t to = unpacker.ReadPackedTime();
if (GameTime::GetGameTime() < from || GameTime::GetGameTime() > to)
return false;
}
if (condition->WorldStateExpressionID)
{
@@ -2867,7 +2879,9 @@ bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, PlayerConditio
return false;
}
// TODO: weather condition
if (condition->WeatherID)
if (player->GetMap()->GetZoneWeather(player->GetZoneId()) != WeatherState(condition->WeatherID))
return false;
if (condition->Achievement[0])
{
+15
View File
@@ -4847,6 +4847,21 @@ Weather* Map::GetOrGenerateZoneDefaultWeather(uint32 zoneId)
return info.DefaultWeather.get();
}
WeatherState Map::GetZoneWeather(uint32 zoneId) const
{
ZoneDynamicInfo const* zoneDynamicInfo = Trinity::Containers::MapGetValuePtr(_zoneDynamicInfo, zoneId);
if (zoneDynamicInfo)
{
if (WeatherState weatherId = zoneDynamicInfo->WeatherId)
return weatherId;
if (zoneDynamicInfo->DefaultWeather)
return zoneDynamicInfo->DefaultWeather->GetWeatherState();
}
return WEATHER_STATE_FINE;
}
void Map::SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade)
{
ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
+1
View File
@@ -552,6 +552,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
void SetZoneMusic(uint32 zoneId, uint32 musicId);
Weather* GetOrGenerateZoneDefaultWeather(uint32 zoneId);
WeatherState GetZoneWeather(uint32 zoneId) const;
void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade);
void SetZoneOverrideLight(uint32 zoneId, uint32 lightId, uint32 fadeInTime);
+1 -2
View File
@@ -76,13 +76,12 @@ class TC_GAME_API Weather
static void SendFineWeatherUpdateToPlayer(Player* player);
void SetWeather(WeatherType type, float grade);
WeatherState GetWeatherState() const;
/// For which zone is this weather?
uint32 GetZone() const { return m_zone; };
uint32 GetScriptId() const { return m_weatherChances->ScriptId; }
private:
WeatherState GetWeatherState() const;
uint32 m_zone;
WeatherType m_type;
float m_grade;