mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00:00
Replace PP with direct printing
This commit is contained in:
parent
de77fe8ade
commit
3b74cc4a41
18 changed files with 110 additions and 109 deletions
|
@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "pathfinder.h"
|
||||
#include "map.h"
|
||||
#include "nodedef.h"
|
||||
#include "irrlicht_changes/printing.h"
|
||||
|
||||
//#define PATHFINDER_DEBUG
|
||||
//#define PATHFINDER_CALC_TIME
|
||||
|
@ -524,25 +525,25 @@ void GridNodeContainer::initNode(v3s16 ipos, PathGridnode *p_node)
|
|||
|
||||
if ((current.param0 == CONTENT_IGNORE) ||
|
||||
(below.param0 == CONTENT_IGNORE)) {
|
||||
DEBUG_OUT("Pathfinder: " << PP(realpos) <<
|
||||
DEBUG_OUT("Pathfinder: " << realpos <<
|
||||
" current or below is invalid element" << std::endl);
|
||||
if (current.param0 == CONTENT_IGNORE) {
|
||||
elem.type = 'i';
|
||||
DEBUG_OUT(PP(ipos) << ": " << 'i' << std::endl);
|
||||
DEBUG_OUT(ipos << ": " << 'i' << std::endl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//don't add anything if it isn't an air node
|
||||
if (ndef->get(current).walkable || !ndef->get(below).walkable) {
|
||||
DEBUG_OUT("Pathfinder: " << PP(realpos)
|
||||
DEBUG_OUT("Pathfinder: " << realpos
|
||||
<< " not on surface" << std::endl);
|
||||
if (ndef->get(current).walkable) {
|
||||
elem.type = 's';
|
||||
DEBUG_OUT(PP(ipos) << ": " << 's' << std::endl);
|
||||
DEBUG_OUT(ipos << ": " << 's' << std::endl);
|
||||
} else {
|
||||
elem.type = '-';
|
||||
DEBUG_OUT(PP(ipos) << ": " << '-' << std::endl);
|
||||
DEBUG_OUT(ipos << ": " << '-' << std::endl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -550,7 +551,7 @@ void GridNodeContainer::initNode(v3s16 ipos, PathGridnode *p_node)
|
|||
elem.valid = true;
|
||||
elem.pos = realpos;
|
||||
elem.type = 'g';
|
||||
DEBUG_OUT(PP(ipos) << ": " << 'a' << std::endl);
|
||||
DEBUG_OUT(ipos << ": " << 'a' << std::endl);
|
||||
|
||||
if (m_pathf->m_prefetch) {
|
||||
elem.directions[DIR_XP] = m_pathf->calcCost(realpos, v3s16( 1, 0, 0));
|
||||
|
@ -667,13 +668,13 @@ std::vector<v3s16> Pathfinder::getPath(v3s16 source,
|
|||
MapNode node_at_pos = m_map->getNode(destination);
|
||||
if (m_ndef->get(node_at_pos).walkable) {
|
||||
VERBOSE_TARGET << "Destination is walkable. " <<
|
||||
"Pos: " << PP(destination) << std::endl;
|
||||
"Pos: " << destination << std::endl;
|
||||
return retval;
|
||||
}
|
||||
node_at_pos = m_map->getNode(source);
|
||||
if (m_ndef->get(node_at_pos).walkable) {
|
||||
VERBOSE_TARGET << "Source is walkable. " <<
|
||||
"Pos: " << PP(source) << std::endl;
|
||||
"Pos: " << source << std::endl;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -701,14 +702,14 @@ std::vector<v3s16> Pathfinder::getPath(v3s16 source,
|
|||
|
||||
if (!startpos.valid) {
|
||||
VERBOSE_TARGET << "Invalid startpos " <<
|
||||
"Index: " << PP(StartIndex) <<
|
||||
"Realpos: " << PP(getRealPos(StartIndex)) << std::endl;
|
||||
"Index: " << StartIndex <<
|
||||
"Realpos: " << getRealPos(StartIndex) << std::endl;
|
||||
return retval;
|
||||
}
|
||||
if (!endpos.valid) {
|
||||
VERBOSE_TARGET << "Invalid stoppos " <<
|
||||
"Index: " << PP(EndIndex) <<
|
||||
"Realpos: " << PP(getRealPos(EndIndex)) << std::endl;
|
||||
"Index: " << EndIndex <<
|
||||
"Realpos: " << getRealPos(EndIndex) << std::endl;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -833,7 +834,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir)
|
|||
|
||||
//check limits
|
||||
if (!m_limits.isPointInside(pos2)) {
|
||||
DEBUG_OUT("Pathfinder: " << PP(pos2) <<
|
||||
DEBUG_OUT("Pathfinder: " << pos2 <<
|
||||
" no cost -> out of limits" << std::endl);
|
||||
return retval;
|
||||
}
|
||||
|
@ -843,7 +844,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir)
|
|||
//did we get information about node?
|
||||
if (node_at_pos2.param0 == CONTENT_IGNORE ) {
|
||||
VERBOSE_TARGET << "Pathfinder: (1) area at pos: "
|
||||
<< PP(pos2) << " not loaded";
|
||||
<< pos2 << " not loaded";
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -854,7 +855,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir)
|
|||
//did we get information about node?
|
||||
if (node_below_pos2.param0 == CONTENT_IGNORE ) {
|
||||
VERBOSE_TARGET << "Pathfinder: (2) area at pos: "
|
||||
<< PP((pos2 + v3s16(0, -1, 0))) << " not loaded";
|
||||
<< (pos2 + v3s16(0, -1, 0)) << " not loaded";
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -864,7 +865,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir)
|
|||
retval.valid = true;
|
||||
retval.value = 1;
|
||||
retval.y_change = 0;
|
||||
DEBUG_OUT("Pathfinder: "<< PP(pos)
|
||||
DEBUG_OUT("Pathfinder: "<< pos
|
||||
<< " cost same height found" << std::endl);
|
||||
}
|
||||
else {
|
||||
|
@ -1040,8 +1041,8 @@ bool Pathfinder::updateAllCosts(v3s16 ipos,
|
|||
v3s16 ipos2 = ipos + direction;
|
||||
|
||||
if (!isValidIndex(ipos2)) {
|
||||
DEBUG_OUT(LVL " Pathfinder: " << PP(ipos2) <<
|
||||
" out of range, max=" << PP(m_limits.MaxEdge) << std::endl);
|
||||
DEBUG_OUT(LVL " Pathfinder: " << ipos2 <<
|
||||
" out of range, max=" << m_limits.MaxEdge << std::endl);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1050,7 @@ bool Pathfinder::updateAllCosts(v3s16 ipos,
|
|||
|
||||
if (!g_pos2.valid) {
|
||||
VERBOSE_TARGET << LVL "Pathfinder: no data for new position: "
|
||||
<< PP(ipos2) << std::endl;
|
||||
<< ipos2 << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1066,7 +1067,7 @@ bool Pathfinder::updateAllCosts(v3s16 ipos,
|
|||
if ((g_pos2.totalcost < 0) ||
|
||||
(g_pos2.totalcost > new_cost)) {
|
||||
DEBUG_OUT(LVL "Pathfinder: updating path at: "<<
|
||||
PP(ipos2) << " from: " << g_pos2.totalcost << " to "<<
|
||||
ipos2 << " from: " << g_pos2.totalcost << " to "<<
|
||||
new_cost << std::endl);
|
||||
if (updateAllCosts(ipos2, invert(direction),
|
||||
new_cost, level)) {
|
||||
|
@ -1076,13 +1077,13 @@ bool Pathfinder::updateAllCosts(v3s16 ipos,
|
|||
else {
|
||||
DEBUG_OUT(LVL "Pathfinder:"
|
||||
" already found shorter path to: "
|
||||
<< PP(ipos2) << std::endl);
|
||||
<< ipos2 << std::endl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG_OUT(LVL "Pathfinder:"
|
||||
" not moving to invalid direction: "
|
||||
<< PP(directions[i]) << std::endl);
|
||||
<< directions[i] << std::endl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1145,8 +1146,8 @@ bool Pathfinder::updateCostHeuristic(v3s16 isource, v3s16 idestination)
|
|||
|
||||
// check if node is inside searchdistance and valid
|
||||
if (!isValidIndex(ipos)) {
|
||||
DEBUG_OUT(LVL " Pathfinder: " << PP(current_pos) <<
|
||||
" out of search distance, max=" << PP(m_limits.MaxEdge) << std::endl);
|
||||
DEBUG_OUT(LVL " Pathfinder: " << current_pos <<
|
||||
" out of search distance, max=" << m_limits.MaxEdge << std::endl);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1258,8 +1259,8 @@ v3s16 Pathfinder::walkDownwards(v3s16 pos, unsigned int max_down) {
|
|||
}
|
||||
else {
|
||||
VERBOSE_TARGET << "Pos too far above ground: " <<
|
||||
"Index: " << PP(getIndexPos(pos)) <<
|
||||
"Realpos: " << PP(getRealPos(getIndexPos(pos))) << std::endl;
|
||||
"Index: " << getIndexPos(pos) <<
|
||||
"Realpos: " << getRealPos(getIndexPos(pos)) << std::endl;
|
||||
}
|
||||
} else {
|
||||
DEBUG_OUT("Pathfinder: no surface found below pos" << std::endl);
|
||||
|
@ -1433,7 +1434,7 @@ void Pathfinder::printPath(const std::vector<v3s16> &path)
|
|||
unsigned int current = 0;
|
||||
for (std::vector<v3s16>::iterator i = path.begin();
|
||||
i != path.end(); ++i) {
|
||||
std::cout << std::setw(3) << current << ":" << PP((*i)) << std::endl;
|
||||
std::cout << std::setw(3) << current << ":" << *i << std::endl;
|
||||
current++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue