mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
refactor: Dead-code sweep — TravelMgr.cpp 5x /* */ blocks (-823 lines) + NewRpgBaseAction 5 unused includes
This commit is contained in:
parent
d8c4425409
commit
783210c4d0
@ -9,12 +9,8 @@
|
||||
#include "Creature.h"
|
||||
#include "G3D/Vector2.h"
|
||||
#include "GameObject.h"
|
||||
#include "GossipDef.h"
|
||||
#include "GridTerrainData.h"
|
||||
#include "IVMapMgr.h"
|
||||
#include "Item.h"
|
||||
#include "ItemTemplate.h"
|
||||
#include "LootMgr.h"
|
||||
#include "Map.h"
|
||||
#include "ModelIgnoreFlags.h"
|
||||
#include "MotionMaster.h"
|
||||
@ -34,7 +30,6 @@
|
||||
#include "PlayerbotTextMgr.h"
|
||||
#include "Playerbots.h"
|
||||
#include "Position.h"
|
||||
#include "QuestDef.h"
|
||||
#include "Random.h"
|
||||
#include "RandomPlayerbotMgr.h"
|
||||
#include "SharedDefines.h"
|
||||
|
||||
@ -1943,93 +1943,6 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
units.push_back(t_unit);
|
||||
}
|
||||
|
||||
/*
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
std::string const query = "SELECT 0,guid,id,map,position_x,position_y,position_z,orientation, (SELECT COUNT(*) FROM
|
||||
creature k WHERE c.id1 = k.id1) FROM creature c UNION ALL SELECT
|
||||
1,guid,id,map,position_x,position_y,position_z,orientation, (SELECT COUNT(*) FROM gameobject h WHERE h.id = g.id)
|
||||
FROM gameobject g";
|
||||
|
||||
QueryResult result = WorldDatabase.Query(query.c_str());
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
t_unit.type = fields[0].Get<uint32>();
|
||||
t_unit.guid = fields[1].Get<uint32>();
|
||||
t_unit.entry = fields[2].Get<uint32>();
|
||||
t_unit.map = fields[3].Get<uint32>();
|
||||
t_unit.x = fields[4].Get<float>();
|
||||
t_unit.y = fields[5].Get<float>();
|
||||
t_unit.z = fields[6].Get<float>();
|
||||
t_unit.o = fields[7].Get<float>();
|
||||
t_unit.c = uint32(fields[8].Get<uint64>());
|
||||
|
||||
units.push_back(t_unit);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded {} units locations.", units.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("playerbots", ">> Error loading units locations.");
|
||||
}
|
||||
|
||||
query = "SELECT 0, 0, id, quest FROM creature_queststarter UNION ALL SELECT 0, 1, id, quest FROM creature_questender
|
||||
UNION ALL SELECT 1, 0, id, quest FROM gameobject_queststarter UNION ALL SELECT 1, 1, id, quest FROM
|
||||
gameobject_questender"; result = WorldDatabase.Query(query.c_str());
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
t_rel.type = fields[0].Get<uint32>();
|
||||
t_rel.role = fields[1].Get<uint32>();
|
||||
t_rel.entry = fields[2].Get<uint32>();
|
||||
t_rel.questId = fields[3].Get<uint32>();
|
||||
|
||||
relations.push_back(t_rel);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded {} relations.", relations.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("playerbots", ">> Error loading relations.");
|
||||
}
|
||||
|
||||
query = "SELECT 0, ct.entry, item FROM creature_template ct JOIN creature_loot_template clt ON (ct.lootid =
|
||||
clt.entry) UNION ALL SELECT 0, entry, item FROM npc_vendor UNION ALL SELECT 1, gt.entry, item FROM
|
||||
gameobject_template gt JOIN gameobject_loot_template glt ON (gt.TYPE = 3 AND gt.DATA1 = glt.entry)"; result =
|
||||
WorldDatabase.Query(query.c_str());
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
t_loot.type = fields[0].Get<uint32>();
|
||||
t_loot.entry = fields[1].Get<uint32>();
|
||||
t_loot.item = fields[2].Get<uint32>();
|
||||
|
||||
loots.push_back(t_loot);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded {} loot lists.", loots.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("playerbots", ">> Error loading loot lists.");
|
||||
}
|
||||
*/
|
||||
|
||||
LOG_INFO("playerbots", "Loading quest data.");
|
||||
|
||||
@ -2115,164 +2028,6 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (loadQuestData && false)
|
||||
{
|
||||
for (auto& questId : questIds)
|
||||
{
|
||||
Quest* quest = questMap.find(questId)->second;
|
||||
|
||||
QuestContainer* container = new QuestContainer;
|
||||
QuestTravelDestination* loc = nullptr;
|
||||
WorldPosition point;
|
||||
|
||||
bool hasError = false;
|
||||
|
||||
//Relations
|
||||
for (auto& r : relations)
|
||||
{
|
||||
if (questId != r.questId)
|
||||
continue;
|
||||
|
||||
int32 entry = r.type == 0 ? r.entry : r.entry * -1;
|
||||
|
||||
loc = new QuestRelationTravelDestination(r.questId, entry, r.role, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance); loc->setExpireDelay(5 * 60 * 1000); loc->setMaxVisitors(15, 0);
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
if (r.type != u.type || r.entry != u.entry)
|
||||
continue;
|
||||
|
||||
int32 guid = u.type == 0 ? u.guid : u.guid * -1;
|
||||
|
||||
point = WorldPosition(u.map, u.x, u.y, u.z, u.o);
|
||||
loc->addPoint(&point);
|
||||
}
|
||||
|
||||
if (loc->getPoints(0).empty())
|
||||
{
|
||||
logQuestError(1, quest, r.role, entry);
|
||||
delete loc;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r.role == 0)
|
||||
{
|
||||
container->questGivers.push_back(loc);
|
||||
}
|
||||
else
|
||||
container->questTakers.push_back(loc);
|
||||
|
||||
}
|
||||
|
||||
//Mobs
|
||||
for (uint32 i = 0; i < 4; i++)
|
||||
{
|
||||
if (quest->RequiredNpcOrGoCount[i] == 0)
|
||||
continue;
|
||||
|
||||
uint32 reqEntry = quest->RequiredNpcOrGo[i];
|
||||
|
||||
loc = new QuestObjectiveTravelDestination(questId, reqEntry, i, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1);
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
int32 entry = u.type == 0 ? u.entry : u.entry * -1;
|
||||
|
||||
if (entry != reqEntry)
|
||||
continue;
|
||||
|
||||
int32 guid = u.type == 0 ? u.guid : u.guid * -1;
|
||||
|
||||
point = WorldPosition(u.map, u.x, u.y, u.z, u.o);
|
||||
loc->addPoint(&point);
|
||||
}
|
||||
|
||||
if (loc->getPoints(0).empty())
|
||||
{
|
||||
logQuestError(2, quest, i, reqEntry);
|
||||
|
||||
delete loc;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
container->questObjectives.push_back(loc);
|
||||
}
|
||||
|
||||
//Loot
|
||||
for (uint32 i = 0; i < 4; i++)
|
||||
{
|
||||
if (quest->RequiredItemCount[i] == 0)
|
||||
continue;
|
||||
|
||||
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i]);
|
||||
if (!proto)
|
||||
{
|
||||
logQuestError(3, quest, i, 0, quest->RequiredItemId[i]);
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 foundLoot = 0;
|
||||
|
||||
for (auto& l : loots)
|
||||
{
|
||||
if (l.item != quest->RequiredItemId[i])
|
||||
continue;
|
||||
|
||||
int32 entry = l.type == 0 ? l.entry : l.entry * -1;
|
||||
|
||||
loc = new QuestObjectiveTravelDestination(questId, entry, i, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance, l.item); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1);
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
if (l.type != u.type || l.entry != u.entry)
|
||||
continue;
|
||||
|
||||
int32 guid = u.type == 0 ? u.guid : u.guid * -1;
|
||||
|
||||
point = WorldPosition(u.map, u.x, u.y, u.z, u.o);
|
||||
loc->addPoint(&point);
|
||||
}
|
||||
|
||||
if (loc->getPoints(0).empty())
|
||||
{
|
||||
logQuestError(4, quest, i, entry, quest->RequiredItemId[i]);
|
||||
delete loc;
|
||||
continue;
|
||||
}
|
||||
|
||||
container->questObjectives.push_back(loc);
|
||||
|
||||
foundLoot++;
|
||||
}
|
||||
|
||||
if (foundLoot == 0)
|
||||
{
|
||||
hasError = true;
|
||||
logQuestError(5, quest, i, 0, quest->RequiredItemId[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (container->questTakers.empty())
|
||||
logQuestError(7, quest);
|
||||
|
||||
if (!container->questGivers.empty() || !container->questTakers.empty() || hasError)
|
||||
{
|
||||
quests.insert(std::make_pair(questId, container));
|
||||
|
||||
for (auto loc : container->questGivers)
|
||||
questGivers.push_back(loc);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded {} quest details.", questIds.size());
|
||||
}
|
||||
*/
|
||||
|
||||
WorldPosition point;
|
||||
|
||||
@ -2407,531 +2162,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
// Node loading/generation is handled by TravelNodeMap::Init() called from TravelMgr::Init().
|
||||
|
||||
/*
|
||||
bool fullNavPointReload = false;
|
||||
bool storeNavPointReload = true;
|
||||
|
||||
if (!fullNavPointReload && true)
|
||||
TravelNodeStore::loadNodes();
|
||||
|
||||
//TravelNodeMap::instance().loadNodeStore();
|
||||
|
||||
for (auto node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
node->setLinked(true);
|
||||
}
|
||||
|
||||
bool reloadNavigationPoints = false || fullNavPointReload || storeNavPointReload;
|
||||
|
||||
if (reloadNavigationPoints)
|
||||
{
|
||||
LOG_INFO("playerbots", "Loading navigation points");
|
||||
|
||||
//Npc nodes
|
||||
|
||||
WorldPosition pos;
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
if (u.type != 0)
|
||||
continue;
|
||||
|
||||
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(u.entry);
|
||||
if (!cInfo)
|
||||
continue;
|
||||
|
||||
std::vector<uint32> allowedNpcFlags;
|
||||
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_INNKEEPER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_FLIGHTMASTER);
|
||||
//allowedNpcFlags.push_back(UNIT_NPC_FLAG_QUESTGIVER);
|
||||
|
||||
for (std::vector<uint32>::iterator i = allowedNpcFlags.begin(); i != allowedNpcFlags.end(); ++i)
|
||||
{
|
||||
if ((cInfo->npcflag & *i) != 0)
|
||||
{
|
||||
pos = WorldPosition(u.map, u.x, u.y, u.z, u.o);
|
||||
|
||||
std::string const nodeName = pos.getAreaName(false);
|
||||
if ((cInfo->npcflag & UNIT_NPC_FLAG_INNKEEPER) != 0)
|
||||
nodeName += " innkeeper";
|
||||
else
|
||||
nodeName += " flightMaster";
|
||||
|
||||
TravelNodeMap::instance().addNode(&pos, nodeName, true, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Build flight paths
|
||||
for (uint32 i = 0; i < sTaxiPathStore.GetNumRows(); ++i)
|
||||
{
|
||||
TaxiPathEntry const* taxiPath = sTaxiPathStore.LookupEntry(i);
|
||||
|
||||
if (!taxiPath)
|
||||
continue;
|
||||
|
||||
TaxiNodesEntry const* startTaxiNode = sTaxiNodesStore.LookupEntry(taxiPath->from);
|
||||
if (!startTaxiNode)
|
||||
continue;
|
||||
|
||||
TaxiNodesEntry const* endTaxiNode = sTaxiNodesStore.LookupEntry(taxiPath->to);
|
||||
if (!endTaxiNode)
|
||||
continue;
|
||||
|
||||
TaxiPathNodeList const& nodes = sTaxiPathNodesByPath[taxiPath->ID];
|
||||
if (nodes.empty())
|
||||
continue;
|
||||
|
||||
WorldPosition startPos(startTaxiNode->map_id, startTaxiNode->x, startTaxiNode->y, startTaxiNode->z);
|
||||
WorldPosition endPos(endTaxiNode->map_id, endTaxiNode->x, endTaxiNode->y, endTaxiNode->z);
|
||||
|
||||
TravelNode* startNode = TravelNodeMap::instance().getNode(&startPos, nullptr, 15.0f);
|
||||
TravelNode* endNode = TravelNodeMap::instance().getNode(&endPos, nullptr, 15.0f);
|
||||
|
||||
if (!startNode || !endNode)
|
||||
continue;
|
||||
|
||||
std::vector<WorldPosition> ppath;
|
||||
|
||||
for (auto& n : nodes)
|
||||
ppath.push_back(WorldPosition(n->mapid, n->x, n->y, n->z, 0.0));
|
||||
|
||||
float totalTime = startPos.getPathLength(ppath) / (450 * 8.0f);
|
||||
|
||||
TravelNodePath travelPath(0.1f, totalTime, (uint8) TravelNodePathType::flightPath, i, true);
|
||||
travelPath.setPath(ppath);
|
||||
|
||||
startNode->setPathTo(endNode, travelPath);
|
||||
}
|
||||
|
||||
//Unique bosses
|
||||
for (auto& u : units)
|
||||
{
|
||||
if (u.type != 0)
|
||||
continue;
|
||||
|
||||
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(u.entry);
|
||||
if (!cInfo)
|
||||
continue;
|
||||
|
||||
pos = WorldPosition(u.map, u.x, u.y, u.z, u.o);
|
||||
|
||||
if (cInfo->rank == 3 || (cInfo->rank == 1 && !pos.isOverworld() && u.c == 1))
|
||||
{
|
||||
std::string const nodeName = cInfo->Name;
|
||||
TravelNodeMap::instance().addNode(&pos, nodeName, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
std::map<uint8, std::string> startNames;
|
||||
startNames[RACE_HUMAN] = "Human";
|
||||
startNames[RACE_ORC] = "Orc and Troll";
|
||||
startNames[RACE_DWARF] = "Dwarf and Gnome";
|
||||
startNames[RACE_NIGHTELF] = "Night Elf";
|
||||
startNames[RACE_UNDEAD_PLAYER] = "Undead";
|
||||
startNames[RACE_TAUREN] = "Tauren";
|
||||
startNames[RACE_GNOME] = "Dwarf and Gnome";
|
||||
startNames[RACE_TROLL] = "Orc and Troll";
|
||||
startNames[RACE_DRAENEI] = "Draenei";
|
||||
startNames[RACE_BLOODELF] = "Blood Elf";
|
||||
|
||||
for (uint32 i = 0; i < MAX_RACES; i++)
|
||||
{
|
||||
for (uint32 j = 0; j < MAX_CLASSES; j++)
|
||||
{
|
||||
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(i, j);
|
||||
if (!info)
|
||||
continue;
|
||||
|
||||
pos = WorldPosition(info->mapId, info->positionX, info->positionY, info->positionZ, info->orientation);
|
||||
|
||||
std::string const nodeName = startNames[i] + " start";
|
||||
TravelNodeMap::instance().addNode(&pos, nodeName, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
//Transports
|
||||
GameObjectTemplateContainer const* goTemplates = sObjectMgr->GetGameObjectTemplates();
|
||||
for (auto const& iter : *goTemplates)
|
||||
{
|
||||
GameObjectTemplate const* data = &iter.second;
|
||||
if (data && (data->type == GAMEOBJECT_TYPE_TRANSPORT || data->type == GAMEOBJECT_TYPE_MO_TRANSPORT))
|
||||
{
|
||||
TransportAnimation const* animation = sTransportMgr->GetTransportAnimInfo(iter.first);
|
||||
|
||||
uint32 pathId = data->moTransport.taxiPathId;
|
||||
float moveSpeed = data->moTransport.moveSpeed;
|
||||
if (pathId >= sTaxiPathNodesByPath.size())
|
||||
continue;
|
||||
|
||||
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathId];
|
||||
|
||||
std::vector<WorldPosition> ppath;
|
||||
TravelNode* prevNode = nullptr;
|
||||
|
||||
//Elevators/Trams
|
||||
if (path.empty())
|
||||
{
|
||||
if (animation)
|
||||
{
|
||||
TransportPathContainer aPath = animation->Path;
|
||||
float timeStart;
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
if (u.type != 1)
|
||||
continue;
|
||||
|
||||
if (u.entry != iter.first)
|
||||
continue;
|
||||
|
||||
prevNode = nullptr;
|
||||
WorldPosition lPos = WorldPosition(u.map, 0, 0, 0, 0);
|
||||
|
||||
for (auto& p : aPath)
|
||||
{
|
||||
float dx = cos(u.o) * p.second->X - sin(u.o) * p.second->Y;
|
||||
float dy = sin(u.o) * p.second->X + cos(u.o) * p.second->Y;
|
||||
WorldPosition pos = WorldPosition(u.map, u.x + dx, u.y + dy, u.z + p.second->Z, u.o);
|
||||
|
||||
if (prevNode)
|
||||
{
|
||||
ppath.push_back(pos);
|
||||
}
|
||||
|
||||
if (pos.distance(&lPos) == 0)
|
||||
{
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, data->name, true, true, true,
|
||||
iter.first);
|
||||
|
||||
if (!prevNode)
|
||||
{
|
||||
ppath.push_back(pos);
|
||||
timeStart = p.second->TimeSeg;
|
||||
}
|
||||
else
|
||||
{
|
||||
float totalTime = (p.second->TimeSeg - timeStart) / 1000.0f;
|
||||
TravelNodePath travelPath(0.1f, totalTime, (uint8)
|
||||
TravelNodePathType::transport, entry, true); node->setPathTo(prevNode, travelPath); ppath.clear();
|
||||
ppath.push_back(pos);
|
||||
timeStart = p.second->TimeSeg;
|
||||
}
|
||||
|
||||
prevNode = node;
|
||||
}
|
||||
|
||||
lPos = pos;
|
||||
}
|
||||
|
||||
if (prevNode)
|
||||
{
|
||||
for (auto& p : aPath)
|
||||
{
|
||||
float dx = cos(u.o) * p.second->X - sin(u.o) * p.second->Y;
|
||||
float dy = sin(u.o) * p.second->X + cos(u.o) * p.second->Y;
|
||||
WorldPosition pos = WorldPosition(u.map, u.x + dx, u.y + dy, u.z + p.second->Z,
|
||||
u.o);
|
||||
|
||||
ppath.push_back(pos);
|
||||
|
||||
if (pos.distance(&lPos) == 0)
|
||||
{
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, data->name, true, true, true,
|
||||
iter.first); if (node != prevNode)
|
||||
{
|
||||
float totalTime = (p.second->TimeSeg - timeStart) / 1000.0f;
|
||||
TravelNodePath travelPath(0.1f, totalTime, (uint8)
|
||||
TravelNodePathType::transport, entry, true); travelPath.setPath(ppath); node->setPathTo(prevNode, travelPath);
|
||||
ppath.clear();
|
||||
ppath.push_back(pos);
|
||||
timeStart = p.second->TimeSeg;
|
||||
}
|
||||
}
|
||||
|
||||
lPos = pos;
|
||||
}
|
||||
}
|
||||
|
||||
ppath.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Boats/Zepelins
|
||||
{
|
||||
//Loop over the path and connect stop locations.
|
||||
for (auto& p : path)
|
||||
{
|
||||
WorldPosition pos = WorldPosition(p->mapid, p->x, p->y, p->z, 0);
|
||||
|
||||
//if (data->displayId == 3015)
|
||||
// pos.setZ(pos.getZ() + 6.0f);
|
||||
//else if (data->displayId == 3031)
|
||||
// pos.setZ(pos.getZ() - 17.0f);
|
||||
|
||||
if (prevNode)
|
||||
{
|
||||
ppath.push_back(pos);
|
||||
}
|
||||
|
||||
if (p->delay > 0)
|
||||
{
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, data->name, true, true, true, iter.first);
|
||||
|
||||
if (!prevNode)
|
||||
{
|
||||
ppath.push_back(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
TravelNodePath travelPath(0.1f, 0.0, (uint8) TravelNodePathType::transport, entry,
|
||||
true); travelPath.setPathAndCost(ppath, moveSpeed); node->setPathTo(prevNode, travelPath); ppath.clear();
|
||||
ppath.push_back(pos);
|
||||
}
|
||||
|
||||
prevNode = node;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevNode)
|
||||
{
|
||||
//Continue from start until first stop and connect to end.
|
||||
for (auto& p : path)
|
||||
{
|
||||
WorldPosition pos = WorldPosition(p->mapid, p->x, p->y, p->z, 0);
|
||||
|
||||
//if (data->displayId == 3015)
|
||||
// pos.setZ(pos.getZ() + 6.0f);
|
||||
//else if (data->displayId == 3031)
|
||||
// pos.setZ(pos.getZ() - 17.0f);
|
||||
|
||||
ppath.push_back(pos);
|
||||
|
||||
if (p->delay > 0)
|
||||
{
|
||||
TravelNode* node = TravelNodeMap::instance().getNode(&pos, nullptr, 5.0f);
|
||||
if (node != prevNode)
|
||||
{
|
||||
TravelNodePath travelPath(0.1f, 0.0, (uint8) TravelNodePathType::transport, entry,
|
||||
true); travelPath.setPathAndCost(ppath, moveSpeed); node->setPathTo(prevNode, travelPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ppath.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Zone means
|
||||
for (auto& loc : exploreLocs)
|
||||
{
|
||||
std::vector<WorldPosition*> points;
|
||||
|
||||
for (auto p : loc.second->getPoints(true))
|
||||
if (!p->isUnderWater())
|
||||
points.push_back(p);
|
||||
|
||||
if (points.empty())
|
||||
points = loc.second->getPoints(true);
|
||||
|
||||
WorldPosition pos = WorldPosition(points, WP_MEAN_CENTROID);
|
||||
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, pos.getAreaName(), true, true, false);
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded {} navigation points.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
TravelNodeMap::instance().calcMapOffset();
|
||||
loadMapTransfers();
|
||||
*/
|
||||
|
||||
/*
|
||||
bool preloadNodePaths = false || fullNavPointReload || storeNavPointReload; //Calculate paths using
|
||||
PathGenerator. bool preloadReLinkFullyLinked = false || fullNavPointReload || storeNavPointReload; //Retry
|
||||
nodes that are fully linked. bool preloadUnlinkedPaths = false || fullNavPointReload; //Try to connect points
|
||||
currently unlinked. bool preloadWorldPaths = true; //Try to load paths in overworld. bool
|
||||
preloadInstancePaths = true; //Try to load paths in instances. bool preloadSubPrint = false; //Print output
|
||||
every 2%.
|
||||
|
||||
if (preloadNodePaths)
|
||||
{
|
||||
std::unordered_map<uint32, Map*> instances;
|
||||
|
||||
//PathGenerator
|
||||
std::vector<WorldPosition> ppath;
|
||||
|
||||
uint32 cur = 0, max = TravelNodeMap::instance().getNodes().size();
|
||||
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (!preloadReLinkFullyLinked && startNode->isLinked())
|
||||
continue;
|
||||
|
||||
for (auto& endNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (startNode == endNode)
|
||||
continue;
|
||||
|
||||
if (startNode->getPosition()->isOverworld() && !preloadWorldPaths)
|
||||
continue;
|
||||
|
||||
if (!startNode->getPosition()->isOverworld() && !preloadInstancePaths)
|
||||
continue;
|
||||
|
||||
if (startNode->hasCompletePathTo(endNode))
|
||||
continue;
|
||||
|
||||
if (!preloadUnlinkedPaths && !startNode->hasLinkTo(endNode))
|
||||
continue;
|
||||
|
||||
if (startNode->getMapId() != endNode->getMapId())
|
||||
continue;
|
||||
|
||||
//if (preloadUnlinkedPaths && !startNode->hasLinkTo(endNode) && startNode->isUselessLink(endNode))
|
||||
// continue;
|
||||
|
||||
startNode->BuildPath(endNode, nullptr, false);
|
||||
|
||||
//if (startNode->hasLinkTo(endNode) && !startNode->getPathTo(endNode)->getComplete())
|
||||
//startNode->removeLinkTo(endNode);
|
||||
}
|
||||
|
||||
startNode->setLinked(true);
|
||||
|
||||
cur++;
|
||||
|
||||
if (preloadSubPrint && (cur * 50) / max > ((cur - 1) * 50) / max)
|
||||
{
|
||||
TravelNodeMap::instance().printMap();
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
}
|
||||
}
|
||||
|
||||
if (!preloadSubPrint)
|
||||
{
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
TravelNodeMap::instance().printMap();
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded paths for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool removeLowLinkNodes = false || fullNavPointReload || storeNavPointReload;
|
||||
|
||||
if (removeLowLinkNodes)
|
||||
{
|
||||
std::vector<TravelNode*> goodNodes;
|
||||
std::vector<TravelNode*> remNodes;
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (!node->getPosition()->isOverworld())
|
||||
continue;
|
||||
|
||||
if (std::find(goodNodes.begin(), goodNodes.end(), node) != goodNodes.end())
|
||||
continue;
|
||||
|
||||
if (std::find(remNodes.begin(), remNodes.end(), node) != remNodes.end())
|
||||
continue;
|
||||
|
||||
std::vector<TravelNode*> nodes = node->getNodeMap(true);
|
||||
|
||||
if (nodes.size() < 5)
|
||||
remNodes.insert(remNodes.end(), nodes.begin(), nodes.end());
|
||||
else
|
||||
goodNodes.insert(goodNodes.end(), nodes.begin(), nodes.end());
|
||||
}
|
||||
|
||||
for (auto& node : remNodes)
|
||||
TravelNodeMap::instance().removeNode(node);
|
||||
|
||||
LOG_INFO("playerbots", ">> Checked {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool cleanUpNodeLinks = false || fullNavPointReload || storeNavPointReload;
|
||||
bool cleanUpSubPrint = false; //Print output every 2%.
|
||||
|
||||
if (cleanUpNodeLinks)
|
||||
{
|
||||
//Routes
|
||||
uint32 cur = 0;
|
||||
uint32 max = TravelNodeMap::instance().getNodes().size();
|
||||
|
||||
//Clean up node links
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
startNode->cropUselessLinks();
|
||||
|
||||
cur++;
|
||||
if (cleanUpSubPrint && (cur * 10) / max > ((cur - 1) * 10) / max)
|
||||
{
|
||||
TravelNodeMap::instance().printMap();
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Cleaned paths for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool reCalculateCost = false || fullNavPointReload || storeNavPointReload;
|
||||
bool forceReCalculate = false;
|
||||
|
||||
if (reCalculateCost)
|
||||
{
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
for (auto& path : *startNode->getLinks())
|
||||
{
|
||||
TravelNodePath* nodePath = path.second;
|
||||
|
||||
if (path.second->getPathType() != TravelNodePathType::walk)
|
||||
continue;
|
||||
|
||||
if (nodePath->getCalculated() && !forceReCalculate)
|
||||
continue;
|
||||
|
||||
nodePath->calculateCost();
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Calculated pathcost for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool mirrorMissingPaths = true || fullNavPointReload || storeNavPointReload;
|
||||
|
||||
if (mirrorMissingPaths)
|
||||
{
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
for (auto& path : *startNode->getLinks())
|
||||
{
|
||||
TravelNode* endNode = path.first;
|
||||
|
||||
if (endNode->hasLinkTo(startNode))
|
||||
continue;
|
||||
|
||||
if (path.second->getPathType() != TravelNodePathType::walk)
|
||||
continue;
|
||||
|
||||
TravelNodePath nodePath = *path.second;
|
||||
|
||||
std::vector<WorldPosition> pPath = nodePath.GetPath();
|
||||
std::reverse(pPath.begin(), pPath.end());
|
||||
|
||||
nodePath.setPath(pPath);
|
||||
|
||||
endNode->setPathTo(startNode, nodePath, true);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Reversed missing paths for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
*/
|
||||
|
||||
TravelNodeMap::instance().printMap();
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
@ -3686,65 +2917,6 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
sPlayerbotAIConfig.openLog(7, "w");
|
||||
|
||||
//Zone area map REMOVE!
|
||||
uint32 k = 0;
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
WorldPosition* pos = node->getPosition();
|
||||
//map area
|
||||
for (uint32 x = 0; x < 2000; x++)
|
||||
{
|
||||
for (uint32 y = 0; y < 2000; y++)
|
||||
{
|
||||
if (!pos->getMap())
|
||||
continue;
|
||||
|
||||
float nx = pos->GetPositionX() + (x * 5) - 5000.0f;
|
||||
float ny = pos->GetPositionY() + (y * 5) - 5000.0f;
|
||||
float nz = pos->GetPositionZ() + 100.0f;
|
||||
|
||||
//pos->getMap()->GetHitPosition(nx, ny, nz + 200.0f, nx, ny, nz, -0.5f);
|
||||
|
||||
if (!pos->getMap()->GetHeightInRange(nx, ny, nz, 5000.0f)) // GetHeight can fail
|
||||
continue;
|
||||
|
||||
WorldPosition npos = WorldPosition(pos->GetMapId(), nx, ny, nz, 0.0);
|
||||
uint32 area = path.getArea(npos.GetMapId(), npos.GetPositionX(), npos.GetPositionY(),
|
||||
npos.GetPositionZ());
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << area << "," << npos.getDisplayX() << "," << npos.getDisplayY();
|
||||
sPlayerbotAIConfig.log(7, out.str().c_str());
|
||||
}
|
||||
}
|
||||
k++;
|
||||
|
||||
if (k > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
//Explore map output (REMOVE!)
|
||||
|
||||
sPlayerbotAIConfig.openLog(5, "w");
|
||||
for (auto i : exploreLocs)
|
||||
{
|
||||
for (auto j : i.second->getPoints())
|
||||
{
|
||||
std::ostringstream out;
|
||||
std::string const name = i.second->getTitle();
|
||||
name.erase(remove(name.begin(), name.end(), '\"'), name.end());
|
||||
out << std::fixed << std::setprecision(2) << name.c_str() << "," << i.first << "," << j->getDisplayX() <<
|
||||
"," << j->getDisplayY() << "," << j->GetPositionX() << "," << j->GetPositionY() << "," << j->GetPositionZ();
|
||||
sPlayerbotAIConfig.log(5,
|
||||
out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
uint32 TravelMgr::getDialogStatus(Player* pPlayer, int32 questgiver, Quest const* pQuest)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user