mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
*Zum'Rah Area Trigger Script, Zum'Rah should become hostile when approached. By totoro. *Judgement of Light PPM based, not 100%. By Drevi. *Fix Deflection Exploit. By manuel, thanks to TheNecromancer and Gyullo. *Correct Wintergrasp Tenacity formulas, by Gyullo. *A Spirit Guide Escort Quest, code from SD2, patch by manuel. *TrullyOne/MeanMachine Waypoint System Restored. Patch by XTElite1. --HG-- branch : trunk
150 lines
4.0 KiB
C++
150 lines
4.0 KiB
C++
/*
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
*
|
|
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include "Database/DatabaseEnv.h"
|
|
#include "GridDefines.h"
|
|
#include "WaypointManager.h"
|
|
#include "ProgressBar.h"
|
|
#include "MapManager.h"
|
|
|
|
UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
|
|
WaypointStore WaypointMgr;
|
|
|
|
void WaypointStore::Free()
|
|
{
|
|
waypoint_map.clear();
|
|
}
|
|
|
|
void WaypointStore::Load()
|
|
{
|
|
QueryResult *result = WorldDatabase.PQuery("SELECT COUNT(id) FROM waypoint_data");
|
|
if(!result)
|
|
{
|
|
sLog.outError("an error occured while loading the table `waypoint_data` (maybe it doesn't exist ?)");
|
|
exit(1); // Stop server at loading non exited table or not accessable table
|
|
}
|
|
|
|
records = (*result)[0].GetUInt32();
|
|
delete result;
|
|
|
|
result = WorldDatabase.PQuery("SELECT id,point,position_x,position_y,position_z,move_flag,delay,action,action_chance FROM waypoint_data ORDER BY id, point");
|
|
if(!result)
|
|
{
|
|
sLog.outErrorDb("The table `waypoint_data` is empty or corrupted");
|
|
return;
|
|
}
|
|
|
|
WaypointPath* path_data;
|
|
uint32 total_records = result->GetRowCount();
|
|
|
|
barGoLink bar( total_records);
|
|
Field *fields;
|
|
uint32 last_id = 0;
|
|
|
|
do
|
|
{
|
|
fields = result->Fetch();
|
|
uint32 id = fields[0].GetUInt32();
|
|
bar.step();
|
|
WaypointData *wp = new WaypointData;
|
|
|
|
if(last_id != id)
|
|
path_data = new WaypointPath;
|
|
|
|
float x,y,z;
|
|
x = fields[2].GetFloat();
|
|
y = fields[3].GetFloat();
|
|
z = fields[4].GetFloat();
|
|
|
|
Trinity::NormalizeMapCoord(x);
|
|
Trinity::NormalizeMapCoord(y);
|
|
|
|
wp->id = fields[1].GetUInt32();
|
|
wp->x = x;
|
|
wp->y = y;
|
|
wp->z = z;
|
|
wp->run = fields[5].GetBool();
|
|
wp->delay = fields[6].GetUInt32();
|
|
wp->event_id = fields[7].GetUInt32();
|
|
wp->event_chance = fields[8].GetUInt8();
|
|
|
|
path_data->push_back(wp);
|
|
|
|
if(id != last_id)
|
|
waypoint_map[id] = path_data;
|
|
|
|
last_id = id;
|
|
|
|
} while(result->NextRow()) ;
|
|
|
|
delete result;
|
|
}
|
|
|
|
void WaypointStore::UpdatePath(uint32 id)
|
|
{
|
|
if(waypoint_map.find(id)!= waypoint_map.end())
|
|
waypoint_map[id]->clear();
|
|
|
|
QueryResult *result;
|
|
|
|
result = WorldDatabase.PQuery("SELECT id,point,position_x,position_y,position_z,move_flag,delay,action,action_chance FROM waypoint_data WHERE id = %u ORDER BY point", id);
|
|
|
|
if(!result)
|
|
return;
|
|
|
|
WaypointPath* path_data;
|
|
path_data = new WaypointPath;
|
|
Field *fields;
|
|
|
|
do
|
|
{
|
|
fields = result->Fetch();
|
|
uint32 id = fields[0].GetUInt32();
|
|
|
|
WaypointData *wp = new WaypointData;
|
|
|
|
float x,y,z;
|
|
x = fields[2].GetFloat();
|
|
y = fields[3].GetFloat();
|
|
z = fields[4].GetFloat();
|
|
|
|
Trinity::NormalizeMapCoord(x);
|
|
Trinity::NormalizeMapCoord(y);
|
|
|
|
wp->id = fields[1].GetUInt32();
|
|
wp->x = x;
|
|
wp->y = y;
|
|
wp->z = z;
|
|
wp->run = fields[5].GetBool();
|
|
wp->delay = fields[6].GetUInt32();
|
|
wp->event_id = fields[7].GetUInt32();
|
|
wp->event_chance = fields[8].GetUInt8();
|
|
|
|
path_data->push_back(wp);
|
|
|
|
}
|
|
while (result->NextRow());
|
|
|
|
waypoint_map[id] = path_data;
|
|
|
|
delete result;
|
|
}
|
|
|