mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
Clean up node generation
This commit is contained in:
parent
95e0b161e0
commit
cfadcc8ec7
@ -196,18 +196,18 @@ bool DebugAction::Execute(Event event)
|
|||||||
{
|
{
|
||||||
WorldPosition pos(bot);
|
WorldPosition pos(bot);
|
||||||
|
|
||||||
std::string const name = "USER:" + text.substr(9);
|
std::string suffix = text.size() > 9 ? text.substr(9) : pos.getAreaName();
|
||||||
|
std::string const name = "USER:" + suffix;
|
||||||
|
|
||||||
/* TravelNode* startNode = */ TravelNodeMap::instance().addNode(pos, name, false, false); // startNode not used, but addNode as side effect, fragment marked for removal.
|
|
||||||
|
|
||||||
for (auto& endNode : TravelNodeMap::instance().getNodes(pos, 2000))
|
|
||||||
{
|
{
|
||||||
endNode->setLinked(false);
|
std::lock_guard<std::shared_timed_mutex> lock(TravelNodeMap::instance().m_nMapMtx);
|
||||||
|
TravelNodeMap::instance().addNode(pos, name, false, true);
|
||||||
|
|
||||||
|
for (auto& endNode : TravelNodeMap::instance().getNodes(pos, 2000))
|
||||||
|
endNode->setLinked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
botAI->TellMasterNoFacing("Node " + name + " created.");
|
botAI->TellMasterNoFacing("Node " + name + " created. Run 'gen path' when done adding nodes.");
|
||||||
|
|
||||||
TravelNodeMap::instance().setHasToGen();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -223,14 +223,15 @@ bool DebugAction::Execute(Event event)
|
|||||||
if (startNode->isImportant())
|
if (startNode->isImportant())
|
||||||
{
|
{
|
||||||
botAI->TellMasterNoFacing("Node can not be removed.");
|
botAI->TellMasterNoFacing("Node can not be removed.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TravelNodeMap::instance().m_nMapMtx.lock();
|
{
|
||||||
TravelNodeMap::instance().removeNode(startNode);
|
std::lock_guard<std::shared_timed_mutex> lock(TravelNodeMap::instance().m_nMapMtx);
|
||||||
botAI->TellMasterNoFacing("Node removed.");
|
TravelNodeMap::instance().removeNode(startNode);
|
||||||
TravelNodeMap::instance().m_nMapMtx.unlock();
|
}
|
||||||
|
|
||||||
TravelNodeMap::instance().setHasToGen();
|
botAI->TellMasterNoFacing("Node removed. Run 'gen path' when done editing nodes.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -249,13 +250,14 @@ bool DebugAction::Execute(Event event)
|
|||||||
}
|
}
|
||||||
else if (text.find("gen node") != std::string::npos)
|
else if (text.find("gen node") != std::string::npos)
|
||||||
{
|
{
|
||||||
// Pathfinder
|
botAI->TellMasterNoFacing("Regenerating travel nodes...");
|
||||||
TravelNodeMap::instance().generateNodes();
|
std::thread([]() { TravelNodeMap::instance().generateAll(); }).detach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (text.find("gen path") != std::string::npos)
|
else if (text.find("gen path") != std::string::npos)
|
||||||
{
|
{
|
||||||
TravelNodeMap::instance().generatePaths();
|
botAI->TellMasterNoFacing("Regenerating travel paths...");
|
||||||
|
std::thread([]() { TravelNodeMap::instance().generateAll(); }).detach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (text.find("crop path") != std::string::npos)
|
else if (text.find("crop path") != std::string::npos)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user