ref: 5d7a20f136c8628e34c66815069c5d4a1b55235e
parent: 6041c007423da884fffb0ec75fafdc2da3b2266b
author: qwx <[email protected]>
date: Sun Dec 19 18:11:39 EST 2021
path: fix decreasing distance from start twice
--- a/path.c
+++ b/path.c
@@ -451,11 +451,11 @@
Δg = n->g - g;
if(!n->open){
n->from = x;
- n->g = g;
- n->h = octdist(n->Point, b->Point);
- n->len = x->len + n->Δlen;
n->open = 1;
n->step = x->step + 1;
+ n->h = octdist(n->Point, b->Point);
+ n->len = x->len + n->Δlen;
+ n->g = g;
pushqueue(n, &queue);
}else if(Δg > 0){
n->from = x;
--- a/pheap.c
+++ b/pheap.c
@@ -65,9 +65,8 @@
void
decreasekey(Pairheap *p, double Δ, Pairheap **queue)
{
+ dprint("decrease %#p %P g %f sum %f by %f\n", p->n, p->n->Point, p->n->g, p->sum, Δ);
p->sum -= Δ;
- p->n->g -= Δ;
- dprint("decrease %#p %P g %f sum %f\n", p->n, p->n->Point, p->n->g, p->sum);
if(p->parent != nil && p->sum < p->parent->sum){
p->parent->left = nil;
p->parent = nil;