* Move weather management to new WeatherMgr (yes, I care that much about the weather - I really do).

--HG--
branch : trunk
This commit is contained in:
XTZGZoReX
2010-08-08 05:06:13 +02:00
parent 18dce8897f
commit e03c873bcf
8 changed files with 238 additions and 152 deletions
-63
View File
@@ -7227,69 +7227,6 @@ void ObjectMgr::LoadNPCSpellClickSpells()
sLog.outString(">> Loaded %u spellclick definitions", count);
}
void ObjectMgr::LoadWeatherData()
{
uint32 count = 0;
// 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)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 weather definitions. DB table `game_weather` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 zone_id = fields[0].GetUInt32();
WeatherData& wzc = mWeatherZoneMap[zone_id];
for (uint8 season = 0; season < WEATHER_SEASONS; ++season)
{
wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE-1) + 1].GetUInt32();
wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE-1) + 2].GetUInt32();
wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE-1) + 3].GetUInt32();
if (wzc.data[season].rainChance > 100)
{
wzc.data[season].rainChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%%",zone_id,season);
}
if (wzc.data[season].snowChance > 100)
{
wzc.data[season].snowChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%%",zone_id,season);
}
if (wzc.data[season].stormChance > 100)
{
wzc.data[season].stormChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%%",zone_id,season);
}
}
wzc.ScriptId = objmgr.GetScriptId(fields[13].GetString());
++count;
} while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u weather definitions", count);
}
void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t)
{
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
-15
View File
@@ -40,7 +40,6 @@
#include "ace/Singleton.h"
#include "SQLStorage.h"
#include "Vehicle.h"
#include "Weather.h"
#include "ObjectMgr.h"
#include <string>
#include <map>
@@ -385,8 +384,6 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap;
typedef UNORDERED_MAP<uint32, WeatherData> WeatherZoneMap;
typedef std::vector<std::string> ScriptNameMap;
Player* GetPlayer(const char* name) const { return sObjectAccessor.FindPlayerByName(name);}
@@ -675,7 +672,6 @@ class ObjectMgr
void LoadNPCSpellClickSpells();
void LoadWeatherData();
void LoadGameTele();
void LoadNpcTextId();
@@ -728,15 +724,6 @@ class ObjectMgr
return NULL;
}
WeatherData const* GetWeatherChances(uint32 zone_id) const
{
WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id);
if (itr != mWeatherZoneMap.end())
return &itr->second;
else
return NULL;
}
CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id)
{
return mMapObjectGuids[MAKE_PAIR32(mapid,spawnMode)][cell_id];
@@ -1022,8 +1009,6 @@ class ObjectMgr
QuestPOIMap mQuestPOIMap;
WeatherZoneMap mWeatherZoneMap;
//character reserved names
typedef std::set<std::wstring> ReservedNamesMap;
ReservedNamesMap m_ReservedNames;