@@ -310,27 +310,16 @@ std::vector<v3s16> pathfinder::get_Path(ServerEnvironment* env,
310
310
print_path (path);
311
311
#endif
312
312
313
- // optimize path
314
- std::vector<v3s16> optimized_path;
315
-
316
- std::vector<v3s16>::iterator startpos = path.begin ();
317
- optimized_path.push_back (source);
318
-
313
+ // finalize path
314
+ std::vector<v3s16> full_path;
319
315
for (std::vector<v3s16>::iterator i = path.begin ();
320
316
i != path.end (); i++) {
321
- if (!m_env->line_of_sight (
322
- tov3f (getIndexElement (*startpos).pos ),
323
- tov3f (getIndexElement (*i).pos ))) {
324
- optimized_path.push_back (getIndexElement (*(i-1 )).pos );
325
- startpos = (i-1 );
326
- }
317
+ full_path.push_back (getIndexElement (*i).pos );
327
318
}
328
319
329
- optimized_path.push_back (destination);
330
-
331
320
#ifdef PATHFINDER_DEBUG
332
- std::cout << " Optimized path:" << std::endl;
333
- print_path (optimized_path );
321
+ std::cout << " full path:" << std::endl;
322
+ print_path (full_path );
334
323
#endif
335
324
#ifdef PATHFINDER_CALC_TIME
336
325
timespec ts2;
@@ -344,7 +333,7 @@ std::vector<v3s16> pathfinder::get_Path(ServerEnvironment* env,
344
333
std::cout << " Calculating path took: " << (ts2.tv_sec - ts.tv_sec ) <<
345
334
" s " << ms << " ms " << us << " us " << ns << " ns " << std::endl;
346
335
#endif
347
- return optimized_path ;
336
+ return full_path ;
348
337
}
349
338
else {
350
339
#ifdef PATHFINDER_DEBUG
@@ -532,7 +521,7 @@ path_cost pathfinder::calc_cost(v3s16 pos,v3s16 dir) {
532
521
if ((testpos.Y >= m_limits.Y .min ) &&
533
522
(node_at_pos.param0 != CONTENT_IGNORE) &&
534
523
(node_at_pos.param0 != CONTENT_AIR)) {
535
- if ((( pos2.Y - testpos.Y )*- 1 ) <= m_maxdrop) {
524
+ if ((pos2.Y - testpos.Y - 1 ) <= m_maxdrop) {
536
525
retval.valid = true ;
537
526
retval.value = 2 ;
538
527
// difference of y-pos +1 (target node is ABOVE solid node)
0 commit comments