[7292] Implement storage for points of interest data in DB.

It can be in current state used for simplify scripting code that set POI and more advansed way later..
    Call void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, char const * locName )
    will removed after some time delay, and only void PlayerMenu::SendPointOfInterest( uint32 poi_id ) will exist.

Author: GriffonHeart

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-17 17:40:03 -06:00
parent 68cfb7c5a4
commit a24928be67
13 changed files with 298 additions and 16 deletions

View File

@@ -460,6 +460,57 @@ void ObjectMgr::LoadNpcOptionLocales()
sLog.outString( ">> Loaded %u npc_option locale strings", mNpcOptionLocaleMap.size() );
}
void ObjectMgr::LoadPointOfInterestLocales()
{
mPointOfInterestLocaleMap.clear(); // need for reload case
QueryResult *result = WorldDatabase.Query("SELECT entry,icon_name_loc1,icon_name_loc2,icon_name_loc3,icon_name_loc4,icon_name_loc5,icon_name_loc6,icon_name_loc7,icon_name_loc8 FROM locales_points_of_interest");
if(!result)
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 points_of_interest locale strings. DB table `locales_points_of_interest` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 entry = fields[0].GetUInt32();
PointOfInterestLocale& data = mPointOfInterestLocaleMap[entry];
for(int i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
if(str.empty())
continue;
int idx = GetOrNewIndexForLocale(LocaleConstant(i));
if(idx >= 0)
{
if(data.IconName.size() <= idx)
data.IconName.resize(idx+1);
data.IconName[idx] = str;
}
}
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u points_of_interest locale strings", mPointOfInterestLocaleMap.size() );
}
struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader>
{
template<class D>
@@ -5889,6 +5940,58 @@ void ObjectMgr::LoadReputationOnKill()
sLog.outString(">> Loaded %u creature award reputation definitions", count);
}
void ObjectMgr::LoadPointsOfInterest()
{
uint32 count = 0;
// 0 1 2 3 4 5
QueryResult *result = WorldDatabase.Query("SELECT entry, x, y, icon, flags, data, icon_name FROM points_of_interest");
if(!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 point_id = fields[0].GetUInt32();
PointOfInterest POI;
POI.x = fields[1].GetFloat();
POI.y = fields[2].GetFloat();
POI.icon = fields[3].GetUInt32();
POI.flags = fields[4].GetUInt32();
POI.data = fields[5].GetUInt32();
POI.icon_name = fields[6].GetCppString();
if(!MaNGOS::IsValidMapCoord(POI.x,POI.y))
{
sLog.outErrorDb("Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.",point_id,POI.x,POI.y);
continue;
}
mPointsOfInterest[point_id] = POI;
++count;
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u Points of Interest definitions", count);
}
void ObjectMgr::LoadWeatherZoneChances()
{
uint32 count = 0;