AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
The World

Files

file  Weather.cpp
 
file  Weather.h
 
file  WeatherMgr.cpp
 
file  WeatherMgr.h
 
file  World.cpp
 
file  World.h
 

Namespaces

namespace  WeatherMgr
 

Classes

struct  WeatherSeasonChances
 
struct  WeatherData
 
class  Weather
 Weather for one zone. More...
 
struct  PetitionData
 
class  World
 The World. More...
 

Macros

#define WEATHER_SEASONS   4
 
#define sWorld   getWorldInstance()
 

Enumerations

enum  WeatherState : uint32 {
  WEATHER_STATE_FINE = 0 ,
  WEATHER_STATE_FOG = 1 ,
  WEATHER_STATE_LIGHT_RAIN = 3 ,
  WEATHER_STATE_MEDIUM_RAIN = 4 ,
  WEATHER_STATE_HEAVY_RAIN = 5 ,
  WEATHER_STATE_LIGHT_SNOW = 6 ,
  WEATHER_STATE_MEDIUM_SNOW = 7 ,
  WEATHER_STATE_HEAVY_SNOW = 8 ,
  WEATHER_STATE_LIGHT_SANDSTORM = 22 ,
  WEATHER_STATE_MEDIUM_SANDSTORM = 41 ,
  WEATHER_STATE_HEAVY_SANDSTORM = 42 ,
  WEATHER_STATE_THUNDERS = 86 ,
  WEATHER_STATE_BLACKRAIN = 90 ,
  WEATHER_STATE_BLACKSNOW = 106
}
 
enum  ShutdownMask : uint8 {
  SHUTDOWN_MASK_RESTART = 1 ,
  SHUTDOWN_MASK_IDLE = 2
}
 
enum  ShutdownExitCode : uint8 {
  SHUTDOWN_EXIT_CODE = 0 ,
  ERROR_EXIT_CODE = 1 ,
  RESTART_EXIT_CODE = 2
}
 
enum  WorldTimers {
  WUPDATE_AUCTIONS ,
  WUPDATE_WEATHERS ,
  WUPDATE_UPTIME ,
  WUPDATE_CORPSES ,
  WUPDATE_EVENTS ,
  WUPDATE_CLEANDB ,
  WUPDATE_AUTOBROADCAST ,
  WUPDATE_MAILBOXQUEUE ,
  WUPDATE_PINGDB ,
  WUPDATE_5_SECS ,
  WUPDATE_WHO_LIST ,
  WUPDATE_COUNT
}
 Timers for different object refresh rates. More...
 
enum  BillingPlanFlags {
  SESSION_NONE = 0x00 ,
  SESSION_UNUSED = 0x01 ,
  SESSION_RECURRING_BILL = 0x02 ,
  SESSION_FREE_TRIAL = 0x04 ,
  SESSION_IGR = 0x08 ,
  SESSION_USAGE = 0x10 ,
  SESSION_TIME_MIXTURE = 0x20 ,
  SESSION_RESTRICTED = 0x40 ,
  SESSION_ENABLE_CAIS = 0x80
}
 Can be used in SMSG_AUTH_RESPONSE packet. More...
 
enum  RealmZone {
  REALM_ZONE_UNKNOWN = 0 ,
  REALM_ZONE_DEVELOPMENT = 1 ,
  REALM_ZONE_UNITED_STATES = 2 ,
  REALM_ZONE_OCEANIC = 3 ,
  REALM_ZONE_LATIN_AMERICA = 4 ,
  REALM_ZONE_TOURNAMENT_5 = 5 ,
  REALM_ZONE_KOREA = 6 ,
  REALM_ZONE_TOURNAMENT_7 = 7 ,
  REALM_ZONE_ENGLISH = 8 ,
  REALM_ZONE_GERMAN = 9 ,
  REALM_ZONE_FRENCH = 10 ,
  REALM_ZONE_SPANISH = 11 ,
  REALM_ZONE_RUSSIAN = 12 ,
  REALM_ZONE_TOURNAMENT_13 = 13 ,
  REALM_ZONE_TAIWAN = 14 ,
  REALM_ZONE_TOURNAMENT_15 = 15 ,
  REALM_ZONE_CHINA = 16 ,
  REALM_ZONE_CN1 = 17 ,
  REALM_ZONE_CN2 = 18 ,
  REALM_ZONE_CN3 = 19 ,
  REALM_ZONE_CN4 = 20 ,
  REALM_ZONE_CN5 = 21 ,
  REALM_ZONE_CN6 = 22 ,
  REALM_ZONE_CN7 = 23 ,
  REALM_ZONE_CN8 = 24 ,
  REALM_ZONE_TOURNAMENT_25 = 25 ,
  REALM_ZONE_TEST_SERVER = 26 ,
  REALM_ZONE_TOURNAMENT_27 = 27 ,
  REALM_ZONE_QA_SERVER = 28 ,
  REALM_ZONE_CN9 = 29 ,
  REALM_ZONE_TEST_SERVER_2 = 30 ,
  REALM_ZONE_CN10 = 31 ,
  REALM_ZONE_CTC = 32 ,
  REALM_ZONE_CNC = 33 ,
  REALM_ZONE_CN1_4 = 34 ,
  REALM_ZONE_CN2_6_9 = 35 ,
  REALM_ZONE_CN3_7 = 36 ,
  REALM_ZONE_CN5_8 = 37
}
 
enum  WorldStates {
  WS_ARENA_DISTRIBUTION_TIME = 20001 ,
  WS_WEEKLY_QUEST_RESET_TIME = 20002 ,
  WS_BG_DAILY_RESET_TIME = 20003 ,
  WS_CLEANING_FLAGS = 20004 ,
  WS_DAILY_QUEST_RESET_TIME = 20005 ,
  WS_GUILD_DAILY_RESET_TIME = 20006 ,
  WS_MONTHLY_QUEST_RESET_TIME = 20007 ,
  WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME = 20008
}
 

Functions

 Weather::Weather (uint32 zone, WeatherData const *weatherChances)
 Create the Weather object.
 
 Weather::~Weather ()=default
 
bool Weather::Update (uint32 diff)
 Launch a weather update.
 
bool Weather::ReGenerate ()
 Calculate the new weather.
 
bool Weather::UpdateWeather ()
 Send the new weather to all players in the zone.
 
void Weather::SendWeatherUpdateToPlayer (Player *player)
 
void Weather::SetWeather (WeatherType type, float grade)
 Set the weather.
 
uint32 Weather::GetZone () const
 For which zone is this weather?
 
uint32 Weather::GetScriptId () const
 
WeatherState Weather::GetWeatherState () const
 Get the sound number associated with the current weather.
 
void WeatherMgr::LoadWeatherData ()
 
WeatherWeatherMgr::FindWeather (uint32 id)
 Find a Weather object by the given zoneid.
 
WeatherWeatherMgr::AddWeather (uint32 zone_id)
 Add a Weather object to the list.
 
void WeatherMgr::RemoveWeather (uint32 id)
 Remove a Weather object for the given zoneid.
 
void WeatherMgr::SendFineWeatherUpdateToPlayer (Player *player)
 
void WeatherMgr::Update (uint32 diff)
 
std::unique_ptr< IWorld > & getWorldInstance ()
 

Variables

uint32 WeatherSeasonChances::rainChance
 
uint32 WeatherSeasonChances::snowChance
 
uint32 WeatherSeasonChances::stormChance
 
WeatherSeasonChances WeatherData::data [WEATHER_SEASONS]
 
uint32 WeatherData::ScriptId
 
uint32 Weather::m_zone
 
WeatherType Weather::m_type
 
float Weather::m_grade
 
IntervalTimer Weather::m_timer
 
WeatherData const * Weather::m_weatherChances
 
AC_GAME_API Realm realm
 

Detailed Description

Macro Definition Documentation

◆ sWorld

◆ WEATHER_SEASONS

#define WEATHER_SEASONS   4

Enumeration Type Documentation

◆ BillingPlanFlags

#include <D:/azerothcore-wotlk/src/server/game/World/World.h>

Can be used in SMSG_AUTH_RESPONSE packet.

Enumerator
SESSION_NONE 
SESSION_UNUSED 
SESSION_RECURRING_BILL 
SESSION_FREE_TRIAL 
SESSION_IGR 
SESSION_USAGE 
SESSION_TIME_MIXTURE 
SESSION_RESTRICTED 
SESSION_ENABLE_CAIS 
78{
79 SESSION_NONE = 0x00,
80 SESSION_UNUSED = 0x01,
82 SESSION_FREE_TRIAL = 0x04,
83 SESSION_IGR = 0x08,
84 SESSION_USAGE = 0x10,
86 SESSION_RESTRICTED = 0x40,
88};
@ SESSION_NONE
Definition: World.h:79
@ SESSION_TIME_MIXTURE
Definition: World.h:85
@ SESSION_USAGE
Definition: World.h:84
@ SESSION_RECURRING_BILL
Definition: World.h:81
@ SESSION_ENABLE_CAIS
Definition: World.h:87
@ SESSION_RESTRICTED
Definition: World.h:86
@ SESSION_UNUSED
Definition: World.h:80
@ SESSION_FREE_TRIAL
Definition: World.h:82
@ SESSION_IGR
Definition: World.h:83

◆ RealmZone

enum RealmZone

#include <D:/azerothcore-wotlk/src/server/game/World/World.h>

Enumerator
REALM_ZONE_UNKNOWN 
REALM_ZONE_DEVELOPMENT 
REALM_ZONE_UNITED_STATES 
REALM_ZONE_OCEANIC 
REALM_ZONE_LATIN_AMERICA 
REALM_ZONE_TOURNAMENT_5 
REALM_ZONE_KOREA 
REALM_ZONE_TOURNAMENT_7 
REALM_ZONE_ENGLISH 
REALM_ZONE_GERMAN 
REALM_ZONE_FRENCH 
REALM_ZONE_SPANISH 
REALM_ZONE_RUSSIAN 
REALM_ZONE_TOURNAMENT_13 
REALM_ZONE_TAIWAN 
REALM_ZONE_TOURNAMENT_15 
REALM_ZONE_CHINA 
REALM_ZONE_CN1 
REALM_ZONE_CN2 
REALM_ZONE_CN3 
REALM_ZONE_CN4 
REALM_ZONE_CN5 
REALM_ZONE_CN6 
REALM_ZONE_CN7 
REALM_ZONE_CN8 
REALM_ZONE_TOURNAMENT_25 
REALM_ZONE_TEST_SERVER 
REALM_ZONE_TOURNAMENT_27 
REALM_ZONE_QA_SERVER 
REALM_ZONE_CN9 
REALM_ZONE_TEST_SERVER_2 
REALM_ZONE_CN10 
REALM_ZONE_CTC 
REALM_ZONE_CNC 
REALM_ZONE_CN1_4 
REALM_ZONE_CN2_6_9 
REALM_ZONE_CN3_7 
REALM_ZONE_CN5_8 
91{
92 REALM_ZONE_UNKNOWN = 0, // any language
93 REALM_ZONE_DEVELOPMENT = 1, // any language
94 REALM_ZONE_UNITED_STATES = 2, // extended-Latin
95 REALM_ZONE_OCEANIC = 3, // extended-Latin
96 REALM_ZONE_LATIN_AMERICA = 4, // extended-Latin
97 REALM_ZONE_TOURNAMENT_5 = 5, // basic-Latin at create, any at login
98 REALM_ZONE_KOREA = 6, // East-Asian
99 REALM_ZONE_TOURNAMENT_7 = 7, // basic-Latin at create, any at login
100 REALM_ZONE_ENGLISH = 8, // extended-Latin
101 REALM_ZONE_GERMAN = 9, // extended-Latin
102 REALM_ZONE_FRENCH = 10, // extended-Latin
103 REALM_ZONE_SPANISH = 11, // extended-Latin
104 REALM_ZONE_RUSSIAN = 12, // Cyrillic
105 REALM_ZONE_TOURNAMENT_13 = 13, // basic-Latin at create, any at login
106 REALM_ZONE_TAIWAN = 14, // East-Asian
107 REALM_ZONE_TOURNAMENT_15 = 15, // basic-Latin at create, any at login
108 REALM_ZONE_CHINA = 16, // East-Asian
109 REALM_ZONE_CN1 = 17, // basic-Latin at create, any at login
110 REALM_ZONE_CN2 = 18, // basic-Latin at create, any at login
111 REALM_ZONE_CN3 = 19, // basic-Latin at create, any at login
112 REALM_ZONE_CN4 = 20, // basic-Latin at create, any at login
113 REALM_ZONE_CN5 = 21, // basic-Latin at create, any at login
114 REALM_ZONE_CN6 = 22, // basic-Latin at create, any at login
115 REALM_ZONE_CN7 = 23, // basic-Latin at create, any at login
116 REALM_ZONE_CN8 = 24, // basic-Latin at create, any at login
117 REALM_ZONE_TOURNAMENT_25 = 25, // basic-Latin at create, any at login
118 REALM_ZONE_TEST_SERVER = 26, // any language
119 REALM_ZONE_TOURNAMENT_27 = 27, // basic-Latin at create, any at login
120 REALM_ZONE_QA_SERVER = 28, // any language
121 REALM_ZONE_CN9 = 29, // basic-Latin at create, any at login
122 REALM_ZONE_TEST_SERVER_2 = 30, // any language
123 REALM_ZONE_CN10 = 31, // basic-Latin at create, any at login
124 REALM_ZONE_CTC = 32,
125 REALM_ZONE_CNC = 33,
126 REALM_ZONE_CN1_4 = 34, // basic-Latin at create, any at login
127 REALM_ZONE_CN2_6_9 = 35, // basic-Latin at create, any at login
128 REALM_ZONE_CN3_7 = 36, // basic-Latin at create, any at login
129 REALM_ZONE_CN5_8 = 37 // basic-Latin at create, any at login
130};
@ REALM_ZONE_CN2
Definition: World.h:110
@ REALM_ZONE_TEST_SERVER
Definition: World.h:118
@ REALM_ZONE_TOURNAMENT_7
Definition: World.h:99
@ REALM_ZONE_TOURNAMENT_5
Definition: World.h:97
@ REALM_ZONE_LATIN_AMERICA
Definition: World.h:96
@ REALM_ZONE_CN4
Definition: World.h:112
@ REALM_ZONE_TOURNAMENT_25
Definition: World.h:117
@ REALM_ZONE_SPANISH
Definition: World.h:103
@ REALM_ZONE_OCEANIC
Definition: World.h:95
@ REALM_ZONE_KOREA
Definition: World.h:98
@ REALM_ZONE_UNKNOWN
Definition: World.h:92
@ REALM_ZONE_TOURNAMENT_15
Definition: World.h:107
@ REALM_ZONE_CNC
Definition: World.h:125
@ REALM_ZONE_UNITED_STATES
Definition: World.h:94
@ REALM_ZONE_CN5_8
Definition: World.h:129
@ REALM_ZONE_CN2_6_9
Definition: World.h:127
@ REALM_ZONE_CN1_4
Definition: World.h:126
@ REALM_ZONE_CN8
Definition: World.h:116
@ REALM_ZONE_ENGLISH
Definition: World.h:100
@ REALM_ZONE_TOURNAMENT_13
Definition: World.h:105
@ REALM_ZONE_FRENCH
Definition: World.h:102
@ REALM_ZONE_CN9
Definition: World.h:121
@ REALM_ZONE_QA_SERVER
Definition: World.h:120
@ REALM_ZONE_CN3
Definition: World.h:111
@ REALM_ZONE_CN10
Definition: World.h:123
@ REALM_ZONE_CN3_7
Definition: World.h:128
@ REALM_ZONE_TEST_SERVER_2
Definition: World.h:122
@ REALM_ZONE_CHINA
Definition: World.h:108
@ REALM_ZONE_CN5
Definition: World.h:113
@ REALM_ZONE_CN7
Definition: World.h:115
@ REALM_ZONE_TOURNAMENT_27
Definition: World.h:119
@ REALM_ZONE_CTC
Definition: World.h:124
@ REALM_ZONE_CN6
Definition: World.h:114
@ REALM_ZONE_RUSSIAN
Definition: World.h:104
@ REALM_ZONE_DEVELOPMENT
Definition: World.h:93
@ REALM_ZONE_CN1
Definition: World.h:109
@ REALM_ZONE_TAIWAN
Definition: World.h:106
@ REALM_ZONE_GERMAN
Definition: World.h:101

◆ ShutdownExitCode

#include <D:/azerothcore-wotlk/src/server/game/World/World.h>

Enumerator
SHUTDOWN_EXIT_CODE 
ERROR_EXIT_CODE 
RESTART_EXIT_CODE 
53{
57};
@ RESTART_EXIT_CODE
Definition: World.h:56
@ SHUTDOWN_EXIT_CODE
Definition: World.h:54
@ ERROR_EXIT_CODE
Definition: World.h:55

◆ ShutdownMask

#include <D:/azerothcore-wotlk/src/server/game/World/World.h>

Enumerator
SHUTDOWN_MASK_RESTART 
SHUTDOWN_MASK_IDLE 
47{
50};
@ SHUTDOWN_MASK_RESTART
Definition: World.h:48
@ SHUTDOWN_MASK_IDLE
Definition: World.h:49

◆ WeatherState

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

Enumerator
WEATHER_STATE_FINE 
WEATHER_STATE_FOG 
WEATHER_STATE_LIGHT_RAIN 
WEATHER_STATE_MEDIUM_RAIN 
WEATHER_STATE_HEAVY_RAIN 
WEATHER_STATE_LIGHT_SNOW 
WEATHER_STATE_MEDIUM_SNOW 
WEATHER_STATE_HEAVY_SNOW 
WEATHER_STATE_LIGHT_SANDSTORM 
WEATHER_STATE_MEDIUM_SANDSTORM 
WEATHER_STATE_HEAVY_SANDSTORM 
WEATHER_STATE_THUNDERS 
WEATHER_STATE_BLACKRAIN 
WEATHER_STATE_BLACKSNOW 
46{
61};
@ WEATHER_STATE_THUNDERS
Definition: Weather.h:58
@ WEATHER_STATE_HEAVY_RAIN
Definition: Weather.h:51
@ WEATHER_STATE_HEAVY_SANDSTORM
Definition: Weather.h:57
@ WEATHER_STATE_MEDIUM_SNOW
Definition: Weather.h:53
@ WEATHER_STATE_MEDIUM_RAIN
Definition: Weather.h:50
@ WEATHER_STATE_MEDIUM_SANDSTORM
Definition: Weather.h:56
@ WEATHER_STATE_BLACKSNOW
Definition: Weather.h:60
@ WEATHER_STATE_FINE
Definition: Weather.h:47
@ WEATHER_STATE_LIGHT_SNOW
Definition: Weather.h:52
@ WEATHER_STATE_BLACKRAIN
Definition: Weather.h:59
@ WEATHER_STATE_HEAVY_SNOW
Definition: Weather.h:54
@ WEATHER_STATE_LIGHT_SANDSTORM
Definition: Weather.h:55
@ WEATHER_STATE_FOG
Definition: Weather.h:48
@ WEATHER_STATE_LIGHT_RAIN
Definition: Weather.h:49

◆ WorldStates

#include <D:/azerothcore-wotlk/src/server/game/World/World.h>

Enumerator
WS_ARENA_DISTRIBUTION_TIME 
WS_WEEKLY_QUEST_RESET_TIME 
WS_BG_DAILY_RESET_TIME 
WS_CLEANING_FLAGS 
WS_DAILY_QUEST_RESET_TIME 
WS_GUILD_DAILY_RESET_TIME 
WS_MONTHLY_QUEST_RESET_TIME 
WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME 
133{
134 WS_ARENA_DISTRIBUTION_TIME = 20001, // Next arena distribution time
135 WS_WEEKLY_QUEST_RESET_TIME = 20002, // Next weekly reset time
136 WS_BG_DAILY_RESET_TIME = 20003, // Next daily BG reset time
137 WS_CLEANING_FLAGS = 20004, // Cleaning Flags
138 WS_DAILY_QUEST_RESET_TIME = 20005, // Next daily reset time
139 WS_GUILD_DAILY_RESET_TIME = 20006, // Next guild cap reset time
140 WS_MONTHLY_QUEST_RESET_TIME = 20007, // Next monthly reset time
141 WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME = 20008 // Next daily calendar deletions of old events time
142};
@ WS_CLEANING_FLAGS
Definition: World.h:137
@ WS_GUILD_DAILY_RESET_TIME
Definition: World.h:139
@ WS_WEEKLY_QUEST_RESET_TIME
Definition: World.h:135
@ WS_ARENA_DISTRIBUTION_TIME
Definition: World.h:134
@ WS_BG_DAILY_RESET_TIME
Definition: World.h:136
@ WS_MONTHLY_QUEST_RESET_TIME
Definition: World.h:140
@ WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME
Definition: World.h:141
@ WS_DAILY_QUEST_RESET_TIME
Definition: World.h:138

◆ WorldTimers

#include <D:/azerothcore-wotlk/src/server/game/World/World.h>

Timers for different object refresh rates.

Enumerator
WUPDATE_AUCTIONS 
WUPDATE_WEATHERS 
WUPDATE_UPTIME 
WUPDATE_CORPSES 
WUPDATE_EVENTS 
WUPDATE_CLEANDB 
WUPDATE_AUTOBROADCAST 
WUPDATE_MAILBOXQUEUE 
WUPDATE_PINGDB 
WUPDATE_5_SECS 
WUPDATE_WHO_LIST 
WUPDATE_COUNT 
61{
74};
@ WUPDATE_COUNT
Definition: World.h:73
@ WUPDATE_MAILBOXQUEUE
Definition: World.h:69
@ WUPDATE_CLEANDB
Definition: World.h:67
@ WUPDATE_CORPSES
Definition: World.h:65
@ WUPDATE_PINGDB
Definition: World.h:70
@ WUPDATE_5_SECS
Definition: World.h:71
@ WUPDATE_AUTOBROADCAST
Definition: World.h:68
@ WUPDATE_WHO_LIST
Definition: World.h:72
@ WUPDATE_UPTIME
Definition: World.h:64
@ WUPDATE_WEATHERS
Definition: World.h:63
@ WUPDATE_EVENTS
Definition: World.h:66
@ WUPDATE_AUCTIONS
Definition: World.h:62

Function Documentation

◆ AddWeather()

Weather * WeatherMgr::AddWeather ( uint32  zone_id)

#include <D:/azerothcore-wotlk/src/server/game/Weather/WeatherMgr.cpp>

Add a Weather object to the list.

68 {
69 WeatherData const* weatherChances = GetWeatherData(zone_id);
70
71 // zone does not have weather, ignore
72 if (!weatherChances)
73 return nullptr;
74
75 Weather* w = new Weather(zone_id, weatherChances);
76 m_weathers[w->GetZone()].reset(w);
77 w->ReGenerate();
78 w->UpdateWeather();
79
80 return w;
81 }
uint32 GetZone() const
For which zone is this weather?
Definition: Weather.h:78
bool UpdateWeather()
Send the new weather to all players in the zone.
Definition: Weather.cpp:193
bool ReGenerate()
Calculate the new weather.
Definition: Weather.cpp:66
WeatherData const * GetWeatherData(uint32 zone_id)
Definition: WeatherMgr.cpp:42
WeatherMap m_weathers
Definition: WeatherMgr.cpp:39
Definition: Weather.h:40
Weather for one zone.
Definition: Weather.h:65

References Weather::GetZone(), Weather::ReGenerate(), and Weather::UpdateWeather().

Referenced by misc_commandscript::HandleChangeWeather(), and Player::UpdateZone().

◆ FindWeather()

Weather * WeatherMgr::FindWeather ( uint32  id)

#include <D:/azerothcore-wotlk/src/server/game/Weather/WeatherMgr.cpp>

Find a Weather object by the given zoneid.

51 {
52 WeatherMap::const_iterator itr = m_weathers.find(id);
53 return (itr != m_weathers.end()) ? itr->second.get() : 0;
54 }

Referenced by misc_commandscript::HandleChangeWeather(), and Player::UpdateZone().

◆ GetScriptId()

uint32 Weather::GetScriptId ( ) const
inline

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

79{ return m_weatherChances->ScriptId; }
uint32 ScriptId
Definition: Weather.h:42
WeatherData const * m_weatherChances
Definition: Weather.h:87

References Weather::m_weatherChances, and WeatherData::ScriptId.

Referenced by ScriptMgr::OnWeatherChange(), and ScriptMgr::OnWeatherUpdate().

◆ GetWeatherState()

WeatherState Weather::GetWeatherState ( ) const
private

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

Get the sound number associated with the current weather.

273{
274 if (m_grade < 0.27f)
275 return WEATHER_STATE_FINE;
276
277 switch (m_type)
278 {
280 if (m_grade < 0.40f)
282 else if (m_grade < 0.70f)
284 else
287 if (m_grade < 0.40f)
289 else if (m_grade < 0.70f)
291 else
294 if (m_grade < 0.40f)
296 else if (m_grade < 0.70f)
298 else
305 default:
306 return WEATHER_STATE_FINE;
307 }
308}
@ WEATHER_TYPE_RAIN
Definition: SharedDefines.h:3139
@ WEATHER_TYPE_STORM
Definition: SharedDefines.h:3141
@ WEATHER_TYPE_FINE
Definition: SharedDefines.h:3138
@ WEATHER_TYPE_SNOW
Definition: SharedDefines.h:3140
@ WEATHER_TYPE_THUNDERS
Definition: SharedDefines.h:3142
@ WEATHER_TYPE_BLACKRAIN
Definition: SharedDefines.h:3143
WeatherType m_type
Definition: Weather.h:84
float m_grade
Definition: Weather.h:85

References Weather::m_grade, Weather::m_type, WEATHER_STATE_BLACKRAIN, WEATHER_STATE_FINE, WEATHER_STATE_HEAVY_RAIN, WEATHER_STATE_HEAVY_SANDSTORM, WEATHER_STATE_HEAVY_SNOW, WEATHER_STATE_LIGHT_RAIN, WEATHER_STATE_LIGHT_SANDSTORM, WEATHER_STATE_LIGHT_SNOW, WEATHER_STATE_MEDIUM_RAIN, WEATHER_STATE_MEDIUM_SANDSTORM, WEATHER_STATE_MEDIUM_SNOW, WEATHER_STATE_THUNDERS, WEATHER_TYPE_BLACKRAIN, WEATHER_TYPE_FINE, WEATHER_TYPE_RAIN, WEATHER_TYPE_SNOW, WEATHER_TYPE_STORM, and WEATHER_TYPE_THUNDERS.

Referenced by Weather::SendWeatherUpdateToPlayer(), and Weather::UpdateWeather().

◆ getWorldInstance()

std::unique_ptr< IWorld > & getWorldInstance ( )

#include <D:/azerothcore-wotlk/src/server/game/World/World.h>

171{
172 static std::unique_ptr<IWorld> instance = std::make_unique<World>();
173 return instance;
174}

◆ GetZone()

uint32 Weather::GetZone ( ) const
inline

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

For which zone is this weather?

78{ return m_zone; };
uint32 m_zone
Definition: Weather.h:83

References Weather::m_zone.

Referenced by WeatherMgr::AddWeather().

◆ LoadWeatherData()

void WeatherMgr::LoadWeatherData ( )

#include <D:/azerothcore-wotlk/src/server/game/Weather/WeatherMgr.cpp>

84 {
85 uint32 oldMSTime = getMSTime();
86
87 uint32 count = 0;
88
89 QueryResult result = WorldDatabase.Query("SELECT "
90 "zone, spring_rain_chance, spring_snow_chance, spring_storm_chance,"
91 "summer_rain_chance, summer_snow_chance, summer_storm_chance,"
92 "fall_rain_chance, fall_snow_chance, fall_storm_chance,"
93 "winter_rain_chance, winter_snow_chance, winter_storm_chance,"
94 "ScriptName FROM game_weather");
95
96 if (!result)
97 {
98 LOG_WARN("server.loading", ">> Loaded 0 weather definitions. DB table `game_weather` is empty.");
99 LOG_INFO("server.loading", " ");
100 return;
101 }
102
103 do
104 {
105 Field* fields = result->Fetch();
106
107 uint32 zone_id = fields[0].Get<uint32>();
108
109 WeatherData& wzc = mWeatherZoneMap[zone_id];
110
111 for (uint8 season = 0; season < WEATHER_SEASONS; ++season)
112 {
113 wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE - 1) + 1].Get<uint8>();
114 wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE - 1) + 2].Get<uint8>();
115 wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE - 1) + 3].Get<uint8>();
116
117 if (wzc.data[season].rainChance > 100)
118 {
119 wzc.data[season].rainChance = 25;
120 LOG_ERROR("sql.sql", "Weather for zone {} season {} has wrong rain chance > 100%", zone_id, season);
121 }
122
123 if (wzc.data[season].snowChance > 100)
124 {
125 wzc.data[season].snowChance = 25;
126 LOG_ERROR("sql.sql", "Weather for zone {} season {} has wrong snow chance > 100%", zone_id, season);
127 }
128
129 if (wzc.data[season].stormChance > 100)
130 {
131 wzc.data[season].stormChance = 25;
132 LOG_ERROR("sql.sql", "Weather for zone {} season {} has wrong storm chance > 100%", zone_id, season);
133 }
134 }
135
136 wzc.ScriptId = sObjectMgr->GetScriptId(fields[13].Get<std::string>());
137
138 ++count;
139 } while (result->NextRow());
140
141 LOG_INFO("server.loading", ">> Loaded {} Weather Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
142 LOG_INFO("server.loading", " ");
143 }
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
#define sObjectMgr
Definition: ObjectMgr.h:1640
#define MAX_WEATHER_TYPE
Definition: SharedDefines.h:3146
#define WEATHER_SEASONS
Definition: Weather.h:31
WeatherZoneMap mWeatherZoneMap
Definition: WeatherMgr.cpp:40
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113

References Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, LOG_WARN, MAX_WEATHER_TYPE, sObjectMgr, WEATHER_SEASONS, and WorldDatabase.

Referenced by World::SetInitialWorldSettings().

◆ ReGenerate()

bool Weather::ReGenerate ( )

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

Calculate the new weather.

Weather statistics:

  • 30% - no change
  • 30% - weather gets better (if not fine) or change weather type
  • 30% - weather worsens (if not fine)
  • 10% - radical change (if not fine)

Radical change:

  • if light -> heavy
  • if medium -> change weather type
  • if heavy -> 50% light, 50% change weather type

New weather statistics (if not fine):

  • 85% light
  • 7% medium
  • 7% heavy If fine 100% sun (no fog)
67{
69 {
71 m_grade = 0.0f;
72 return false;
73 }
74
80 uint32 u = urand(0, 99);
81
82 if (u < 30)
83 return false;
84
85 // remember old values
86 WeatherType old_type = m_type;
87 float old_grade = m_grade;
88
89 //78 days between January 1st and March 20nd; 365/4=91 days by season
90 // season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html
91 uint32 season = ((Acore::Time::GetDayInYear() - 78 + 365) / 91) % 4;
92
93 static char const* seasonName[WEATHER_SEASONS] = { "spring", "summer", "fall", "winter" };
94 LOG_DEBUG("weather", "Generating a change in {} weather for zone {}.", seasonName[season], m_zone);
95
96 if ((u < 60) && (m_grade < 0.33333334f)) // Get fair
97 {
99 m_grade = 0.0f;
100 }
101
102 if ((u < 60) && (m_type != WEATHER_TYPE_FINE)) // Get better
103 {
104 m_grade -= 0.33333334f;
105 return true;
106 }
107
108 if ((u < 90) && (m_type != WEATHER_TYPE_FINE)) // Get worse
109 {
110 m_grade += 0.33333334f;
111 return true;
112 }
113
115 {
120
121 if (m_grade < 0.33333334f)
122 {
123 m_grade = 0.9999f; // go nuts
124 return true;
125 }
126 else
127 {
128 if (m_grade > 0.6666667f)
129 {
130 // Severe change, but how severe?
131 uint32 rnd = urand(0, 99);
132 if (rnd < 50)
133 {
134 m_grade -= 0.6666667f;
135 return true;
136 }
137 }
138 m_type = WEATHER_TYPE_FINE; // clear up
139 m_grade = 0;
140 }
141 }
142
143 // At this point, only weather that isn't doing anything remains but that have weather data
144 uint32 chance1 = m_weatherChances->data[season].rainChance;
145 uint32 chance2 = chance1 + m_weatherChances->data[season].snowChance;
146 uint32 chance3 = chance2 + m_weatherChances->data[season].stormChance;
147
148 uint32 rnd = urand(1, 100);
149 if (rnd <= chance1)
151 else if (rnd <= chance2)
153 else if (rnd <= chance3)
155 else
157
163
165 {
166 m_grade = 0.0f;
167 }
168 else if (u < 90)
169 {
170 m_grade = (float)rand_norm() * 0.3333f;
171 }
172 else
173 {
174 // Severe change, but how severe?
175 rnd = urand(0, 99);
176 if (rnd < 50)
177 m_grade = (float)rand_norm() * 0.3333f + 0.3334f;
178 else
179 m_grade = (float)rand_norm() * 0.3333f + 0.6667f;
180 }
181
182 // return true only in case weather changes
183 return m_type != old_type || m_grade != old_grade;
184}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
double rand_norm()
Definition: Random.cpp:77
WeatherType
Definition: SharedDefines.h:3137
uint32 snowChance
Definition: Weather.h:35
WeatherSeasonChances data[WEATHER_SEASONS]
Definition: Weather.h:41
uint32 rainChance
Definition: Weather.h:34
uint32 stormChance
Definition: Weather.h:36
AC_COMMON_API uint32 GetDayInYear(Seconds time=0s)
Definition: Timer.cpp:414

References WeatherData::data, Acore::Time::GetDayInYear(), LOG_DEBUG, Weather::m_grade, Weather::m_type, Weather::m_weatherChances, Weather::m_zone, WeatherSeasonChances::rainChance, rand_norm(), WeatherSeasonChances::snowChance, WeatherSeasonChances::stormChance, urand(), WEATHER_SEASONS, WEATHER_TYPE_FINE, WEATHER_TYPE_RAIN, WEATHER_TYPE_SNOW, and WEATHER_TYPE_STORM.

Referenced by WeatherMgr::AddWeather(), and Weather::Update().

◆ RemoveWeather()

void WeatherMgr::RemoveWeather ( uint32  id)

#include <D:/azerothcore-wotlk/src/server/game/Weather/WeatherMgr.cpp>

Remove a Weather object for the given zoneid.

58 {
59 // not called at the moment. Kept for completeness
60 WeatherMap::iterator itr = m_weathers.find(id);
61
62 if (itr != m_weathers.end())
63 m_weathers.erase(itr);
64 }

◆ SendFineWeatherUpdateToPlayer()

void WeatherMgr::SendFineWeatherUpdateToPlayer ( Player player)

#include <D:/azerothcore-wotlk/src/server/game/Weather/WeatherMgr.cpp>

146 {
148 player->SendDirectMessage(weather.Write());
149 }
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5607
Definition: MiscPackets.h:32

References Player::SendDirectMessage(), WEATHER_STATE_FINE, and WorldPackets::Misc::Weather::Write().

Referenced by Player::UpdateZone().

◆ SendWeatherUpdateToPlayer()

void Weather::SendWeatherUpdateToPlayer ( Player player)

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

187{
189 player->SendDirectMessage(weather.Write());
190}
WeatherState GetWeatherState() const
Get the sound number associated with the current weather.
Definition: Weather.cpp:272

References Weather::GetWeatherState(), Weather::m_grade, Player::SendDirectMessage(), and WorldPackets::Misc::Weather::Write().

◆ SetWeather()

void Weather::SetWeather ( WeatherType  type,
float  grade 
)

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

Set the weather.

262{
263 if (m_type == type && m_grade == grade)
264 return;
265
266 m_type = type;
267 m_grade = grade;
269}

References Weather::m_grade, Weather::m_type, and Weather::UpdateWeather().

Referenced by misc_commandscript::HandleChangeWeather().

◆ Update() [1/2]

bool Weather::Update ( uint32  diff)

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

Launch a weather update.

  • If the timer has passed, ReGenerate the weather
  • Weather will be removed if not updated (no players in zone anymore)
42{
43 if (m_timer.GetCurrent() >= 0)
44 m_timer.Update(diff);
45 else
47
49 if (m_timer.Passed())
50 {
51 m_timer.Reset();
52 // update only if Regenerate has changed the weather
53 if (ReGenerate())
54 {
56 if (!UpdateWeather())
57 return false;
58 }
59 }
60
61 sScriptMgr->OnWeatherUpdate(this, diff);
62 return true;
63}
#define sScriptMgr
Definition: ScriptMgr.h:698
IntervalTimer m_timer
Definition: Weather.h:86
time_t GetCurrent() const
Definition: Timer.h:189
bool Passed()
Definition: Timer.h:161
void Update(time_t diff)
Definition: Timer.h:152
void SetCurrent(time_t current)
Definition: Timer.h:174
void Reset()
Definition: Timer.h:166

References IntervalTimer::GetCurrent(), Weather::m_timer, IntervalTimer::Passed(), Weather::ReGenerate(), IntervalTimer::Reset(), IntervalTimer::SetCurrent(), sScriptMgr, IntervalTimer::Update(), and Weather::UpdateWeather().

◆ Update() [2/2]

void WeatherMgr::Update ( uint32  diff)

#include <D:/azerothcore-wotlk/src/server/game/Weather/WeatherMgr.cpp>

  • Send an update signal to Weather objects
  • and remove Weather objects for zones with no player
152 {
154 WeatherMap::iterator itr, next;
155 for (itr = m_weathers.begin(); itr != m_weathers.end(); itr = next)
156 {
157 next = itr;
158 ++next;
159
161 // As interval > WorldTick
162 if (!itr->second->Update(diff))
163 m_weathers.erase(itr);
164 }
165 }

Referenced by World::Update().

◆ UpdateWeather()

bool Weather::UpdateWeather ( )

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

Send the new weather to all players in the zone.

  • Send the weather packet to all players in this zone
  • Log the event
194{
196 if (m_grade >= 1)
197 m_grade = 0.9999f;
198 else if (m_grade < 0)
199 m_grade = 0.0001f;
200
202
203 WorldPackets::Misc::Weather weather(state, m_grade);
204
205 //- Returns false if there were no players found to update
206 if (!sWorld->SendZoneMessage(m_zone, weather.Write()))
207 return false;
208
210 char const* wthstr;
211 switch (state)
212 {
214 wthstr = "fog";
215 break;
217 wthstr = "light rain";
218 break;
220 wthstr = "medium rain";
221 break;
223 wthstr = "heavy rain";
224 break;
226 wthstr = "light snow";
227 break;
229 wthstr = "medium snow";
230 break;
232 wthstr = "heavy snow";
233 break;
235 wthstr = "light sandstorm";
236 break;
238 wthstr = "medium sandstorm";
239 break;
241 wthstr = "heavy sandstorm";
242 break;
244 wthstr = "thunders";
245 break;
247 wthstr = "blackrain";
248 break;
250 default:
251 wthstr = "fine";
252 break;
253 }
254
255 LOG_DEBUG("weather", "Change the weather of zone {} to {}.", m_zone, wthstr);
256 sScriptMgr->OnWeatherChange(this, state, m_grade);
257 return true;
258}
#define sWorld
Definition: World.h:447
WeatherState
Definition: Weather.h:46

References Weather::GetWeatherState(), LOG_DEBUG, Weather::m_grade, Weather::m_zone, sScriptMgr, sWorld, WEATHER_STATE_BLACKRAIN, WEATHER_STATE_FINE, WEATHER_STATE_FOG, WEATHER_STATE_HEAVY_RAIN, WEATHER_STATE_HEAVY_SANDSTORM, WEATHER_STATE_HEAVY_SNOW, WEATHER_STATE_LIGHT_RAIN, WEATHER_STATE_LIGHT_SANDSTORM, WEATHER_STATE_LIGHT_SNOW, WEATHER_STATE_MEDIUM_RAIN, WEATHER_STATE_MEDIUM_SANDSTORM, WEATHER_STATE_MEDIUM_SNOW, WEATHER_STATE_THUNDERS, and WorldPackets::Misc::Weather::Write().

Referenced by WeatherMgr::AddWeather(), Weather::SetWeather(), and Weather::Update().

◆ Weather()

Weather::Weather ( uint32  zone,
WeatherData const *  weatherChances 
)

#include <D:/azerothcore-wotlk/src/server/game/Weather/Weather.h>

Create the Weather object.

31 : m_zone(zone), m_weatherChances(weatherChances)
32{
35 m_grade = 0;
36
37 LOG_DEBUG("weather", "WORLD: Starting weather system for zone {} (change every {} minutes).", m_zone, (uint32)(m_timer.GetInterval() / (MINUTE * IN_MILLISECONDS)));
38}
constexpr auto IN_MILLISECONDS
Definition: Common.h:55
constexpr auto MINUTE
Definition: Common.h:49
@ CONFIG_INTERVAL_CHANGEWEATHER
Definition: IWorld.h:212
void SetInterval(time_t interval)
Definition: Timer.h:179
time_t GetInterval() const
Definition: Timer.h:184

References CONFIG_INTERVAL_CHANGEWEATHER, IntervalTimer::GetInterval(), IN_MILLISECONDS, LOG_DEBUG, Weather::m_grade, Weather::m_timer, Weather::m_type, Weather::m_zone, MINUTE, IntervalTimer::SetInterval(), sWorld, and WEATHER_TYPE_FINE.

◆ ~Weather()

Weather::~Weather ( )
default

Variable Documentation

◆ data

Referenced by Weather::ReGenerate().

◆ m_grade

◆ m_timer

IntervalTimer Weather::m_timer
private

◆ m_type

◆ m_weatherChances

WeatherData const* Weather::m_weatherChances
private

◆ m_zone

◆ rainChance

uint32 WeatherSeasonChances::rainChance

Referenced by Weather::ReGenerate().

◆ realm

◆ ScriptId

uint32 WeatherData::ScriptId

Referenced by Weather::GetScriptId().

◆ snowChance

uint32 WeatherSeasonChances::snowChance

Referenced by Weather::ReGenerate().

◆ stormChance

uint32 WeatherSeasonChances::stormChance

Referenced by Weather::ReGenerate().