fix: prevent loading graphs with less than 8 nodes (brokes pathfinder)
fix: prevent running A* with less than 8 nodes (in case converted one) fix: trying to play with graph author/modified stuff per #374
This commit is contained in:
parent
18ee4ce38b
commit
a3288cc353
3 changed files with 20 additions and 15 deletions
|
|
@ -1739,7 +1739,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef ext, StringRef name,
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the count
|
// check the count
|
||||||
if (hdr.length == 0 || hdr.length > kMaxNodes) {
|
if (hdr.length == 0 || hdr.length > kMaxNodes || hdr.length < kMaxNodeLinks) {
|
||||||
if (tryReload ()) {
|
if (tryReload ()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1831,7 +1831,7 @@ bool BotGraph::loadGraphData () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((outOptions & StorageOption::Official) || strncmp (exten.author, "official", 8) == 0 || strlen (exten.author) < 2) {
|
if ((outOptions & StorageOption::Official) || strncmp (exten.author, "official", 8) == 0 || strlen (exten.author) < 2) {
|
||||||
m_graphAuthor.assign (product.folder);
|
m_graphAuthor.assign (product.name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_graphAuthor.assign (exten.author);
|
m_graphAuthor.assign (exten.author);
|
||||||
|
|
@ -1867,40 +1867,39 @@ bool BotGraph::canDownload () {
|
||||||
|
|
||||||
bool BotGraph::saveGraphData () {
|
bool BotGraph::saveGraphData () {
|
||||||
auto options = StorageOption::Graph | StorageOption::Exten;
|
auto options = StorageOption::Graph | StorageOption::Exten;
|
||||||
String author;
|
String editorName;
|
||||||
|
|
||||||
if (game.isNullEntity (m_editor) && !m_graphAuthor.empty ()) {
|
if (game.isNullEntity (m_editor) && !m_graphAuthor.empty ()) {
|
||||||
author = m_graphAuthor;
|
editorName = m_graphAuthor;
|
||||||
|
|
||||||
if (!game.isDedicated ()) {
|
if (!game.isDedicated ()) {
|
||||||
options |= StorageOption::Recovered;
|
options |= StorageOption::Recovered;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!game.isNullEntity (m_editor)) {
|
else if (!game.isNullEntity (m_editor)) {
|
||||||
author = m_editor->v.netname.chars ();
|
editorName = m_editor->v.netname.chars ();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
author = product.name;
|
editorName = product.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark as official
|
// mark as official
|
||||||
if (author.startsWith (product.name)) {
|
if (editorName.startsWith (product.name)) {
|
||||||
options |= StorageOption::Official;
|
options |= StorageOption::Official;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtenHeader exten {};
|
ExtenHeader exten {};
|
||||||
|
|
||||||
// only modify the author if no author currenlty assigned to graph file
|
// only modify the author if no author currenlty assigned to graph file
|
||||||
if (m_graphAuthor.empty ()) {
|
if (m_graphAuthor.empty () || strings.isEmpty (m_extenHeader.author)) {
|
||||||
strings.copy (exten.author, author.chars (), cr::bufsize (exten.author));
|
strings.copy (exten.author, editorName.chars (), cr::bufsize (exten.author));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strings.copy (exten.author, m_extenHeader.author, cr::bufsize (exten.author));
|
strings.copy (exten.author, m_extenHeader.author, cr::bufsize (exten.author));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only update modified by, if name differs
|
// only update modified by, if name differs
|
||||||
if (m_graphAuthor != author && strncmp (m_extenHeader.author, m_extenHeader.modified, cr::bufsize (m_extenHeader.author)) != 0) {
|
if (m_graphAuthor != editorName && !strings.isEmpty (m_extenHeader.author)) {
|
||||||
strings.copy (exten.modified, author.chars (), cr::bufsize (exten.author));
|
strings.copy (exten.modified, editorName.chars (), cr::bufsize (exten.author));
|
||||||
}
|
}
|
||||||
exten.mapSize = getBspSize ();
|
exten.mapSize = getBspSize ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1404,6 +1404,12 @@ void Bot::findPath (int srcIndex, int destIndex, FindPath pathType /*= FindPath:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// astar needs some nodes to work with
|
||||||
|
if (graph.length () < kMaxNodeLinks) {
|
||||||
|
logger.error ("A* Search for bot \"%s\" has failed due to too small number of nodes (%d). Seems to be graph is broken.", pev->netname.chars (), graph.length ());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// holders for heuristic functions
|
// holders for heuristic functions
|
||||||
static Lambda <float (int, int, int)> gcalc, hcalc;
|
static Lambda <float (int, int, int)> gcalc, hcalc;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@
|
||||||
<Filter Include="inc\ext\crlib">
|
<Filter Include="inc\ext\crlib">
|
||||||
<UniqueIdentifier>{bec0fb46-08b4-4bfa-900c-d279a933ff77}</UniqueIdentifier>
|
<UniqueIdentifier>{bec0fb46-08b4-4bfa-900c-d279a933ff77}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="res">
|
|
||||||
<UniqueIdentifier>{5e73b918-f42b-4df9-bbe9-918289e44ad2}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="inc\ext\hlsdk">
|
<Filter Include="inc\ext\hlsdk">
|
||||||
<UniqueIdentifier>{f6a0fc04-bdf5-479b-8e5a-85eae698541e}</UniqueIdentifier>
|
<UniqueIdentifier>{f6a0fc04-bdf5-479b-8e5a-85eae698541e}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="res">
|
||||||
|
<UniqueIdentifier>{5e73b918-f42b-4df9-bbe9-918289e44ad2}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\inc\config.h">
|
<ClInclude Include="..\inc\config.h">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue