diff options
-rw-r--r-- | sql/base/world_database.sql | 1 | ||||
-rw-r--r-- | sql/updates/9195_world_game_weather.sql | 1 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 9 | ||||
-rw-r--r-- | src/server/game/Weather/Weather.cpp | 3 | ||||
-rw-r--r-- | src/server/game/Weather/Weather.h | 15 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 4 |
7 files changed, 30 insertions, 15 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql index 2f2fb86997e..100a578f60b 100644 --- a/sql/base/world_database.sql +++ b/sql/base/world_database.sql @@ -2372,6 +2372,7 @@ CREATE TABLE `game_weather` ( `winter_rain_chance` tinyint(3) unsigned NOT NULL DEFAULT '25', `winter_snow_chance` tinyint(3) unsigned NOT NULL DEFAULT '25', `winter_storm_chance` tinyint(3) unsigned NOT NULL DEFAULT '25', + `ScriptName` char(64) NOT NULL DEFAULT '', PRIMARY KEY (`zone`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Weather System'; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/sql/updates/9195_world_game_weather.sql b/sql/updates/9195_world_game_weather.sql new file mode 100644 index 00000000000..355c49e7640 --- /dev/null +++ b/sql/updates/9195_world_game_weather.sql @@ -0,0 +1 @@ +ALTER TABLE `game_weather` ADD `ScriptName` char(64) NOT NULL DEFAULT '' AFTER `winter_storm_chance`; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index d687afbc089..5ab7c515601 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -7227,12 +7227,12 @@ void ObjectMgr::LoadNPCSpellClickSpells() sLog.outString(">> Loaded %u spellclick definitions", count); } -void ObjectMgr::LoadWeatherZoneChances() +void ObjectMgr::LoadWeatherData() { uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult_AutoPtr result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance FROM game_weather"); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + QueryResult_AutoPtr result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance, ScriptName FROM game_weather"); if (!result) { @@ -7254,7 +7254,7 @@ void ObjectMgr::LoadWeatherZoneChances() uint32 zone_id = fields[0].GetUInt32(); - WeatherZoneChances& wzc = mWeatherZoneMap[zone_id]; + WeatherData& wzc = mWeatherZoneMap[zone_id]; for (uint8 season = 0; season < WEATHER_SEASONS; ++season) { @@ -7281,6 +7281,8 @@ void ObjectMgr::LoadWeatherZoneChances() } } + wzc.ScriptId = objmgr.GetScriptId(fields[13].GetString()); + ++count; } while (result->NextRow()); @@ -8744,6 +8746,8 @@ void ObjectMgr::LoadScriptNames() "UNION " "SELECT DISTINCT(ScriptName) FROM transports WHERE ScriptName <> '' " "UNION " + "SELECT DISTINCT(ScriptName) FROM game_weather WHERE ScriptName <> '' " + "UNION " "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''"); if (!result) diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 114dc483cb4..1b8c2613ebe 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -302,9 +302,10 @@ struct WeatherSeasonChances uint32 stormChance; }; -struct WeatherZoneChances +struct WeatherData { WeatherSeasonChances data[WEATHER_SEASONS]; + uint32 ScriptId; }; struct GraveYardData @@ -397,7 +398,7 @@ class ObjectMgr typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap; - typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap; + typedef UNORDERED_MAP<uint32, WeatherData> WeatherZoneMap; typedef std::vector<std::string> ScriptNameMap; @@ -687,7 +688,7 @@ class ObjectMgr void LoadNPCSpellClickSpells(); - void LoadWeatherZoneChances(); + void LoadWeatherData(); void LoadGameTele(); void LoadNpcTextId(); @@ -740,7 +741,7 @@ class ObjectMgr return NULL; } - WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const + WeatherData const* GetWeatherChances(uint32 zone_id) const { WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id); if (itr != mWeatherZoneMap.end()) diff --git a/src/server/game/Weather/Weather.cpp b/src/server/game/Weather/Weather.cpp index 0bfb7f19345..5c5779a6506 100644 --- a/src/server/game/Weather/Weather.cpp +++ b/src/server/game/Weather/Weather.cpp @@ -31,7 +31,8 @@ #include "Util.h" /// Create the Weather object -Weather::Weather(uint32 zone, WeatherZoneChances const* weatherChances) : m_zone(zone), m_weatherChances(weatherChances) +Weather::Weather(uint32 zone, WeatherData const* weatherChances) + : m_zone(zone), m_weatherChances(weatherChances) { m_timer.SetInterval(sWorld.getConfig(CONFIG_INTERVAL_CHANGEWEATHER)); m_type = WEATHER_TYPE_FINE; diff --git a/src/server/game/Weather/Weather.h b/src/server/game/Weather/Weather.h index 874eccba64f..bfe901fc527 100644 --- a/src/server/game/Weather/Weather.h +++ b/src/server/game/Weather/Weather.h @@ -53,23 +53,30 @@ struct WeatherZoneChances; class Weather { public: - Weather(uint32 zone, WeatherZoneChances const* weatherChances); + + Weather(uint32 zone, WeatherData const* weatherChances); ~Weather() { }; + + bool Update(uint32 diff); bool ReGenerate(); bool UpdateWeather(); + void SendWeatherUpdateToPlayer(Player *player); static void SendFineWeatherUpdateToPlayer(Player *player); void SetWeather(WeatherType type, float grade); + /// For which zone is this weather? - uint32 GetZone() { return m_zone; }; - bool Update(uint32 diff); + 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; IntervalTimer m_timer; - WeatherZoneChances const* m_weatherChances; + WeatherData const* m_weatherChances; }; #endif diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 5c982faf205..5a54f9f85da 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -417,7 +417,7 @@ void World::RemoveWeather(uint32 id) /// Add a Weather object to the list Weather* World::AddWeather(uint32 zone_id) { - WeatherZoneChances const* weatherChances = objmgr.GetWeatherChances(zone_id); + WeatherData const* weatherChances = objmgr.GetWeatherChances(zone_id); // zone not have weather, ignore if (!weatherChances) @@ -1429,7 +1429,7 @@ void World::SetInitialWorldSettings() gameeventmgr.LoadFromDB(); sLog.outString("Loading Weather Data..."); - objmgr.LoadWeatherZoneChances(); + objmgr.LoadWeatherData(); sLog.outString("Loading Quests..."); objmgr.LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables |