165 |
|
initambfile(0); /* file exists */ |
166 |
|
lastpos = ftell(ambfp); |
167 |
|
while (readambval(&amb, ambfp)) |
168 |
< |
avinsert(avstore(&amb)); |
168 |
> |
avstore(&amb); |
169 |
|
nambshare = nambvals; /* share loaded values */ |
170 |
|
if (readonly) { |
171 |
|
sprintf(errmsg, |
443 |
|
/* |
444 |
|
* Ambient level test |
445 |
|
*/ |
446 |
< |
if (av->lvl > al) /* list sorted, so this works */ |
446 |
> |
if (av->lvl > al || /* list sorted, so this works */ |
447 |
> |
(av->lvl == al) & (av->weight < 0.9*r->rweight)) |
448 |
|
break; |
448 |
– |
if (av->weight < 0.9*r->rweight) |
449 |
– |
continue; |
449 |
|
/* |
450 |
|
* Direction test using unperturbed normal |
451 |
|
*/ |
607 |
|
} |
608 |
|
avh.next = at->alist; /* order by increasing level */ |
609 |
|
for (ap = &avh; ap->next != NULL; ap = ap->next) |
610 |
< |
if (ap->next->lvl >= av->lvl) |
610 |
> |
if ( ap->next->lvl > av->lvl || |
611 |
> |
(ap->next->lvl == av->lvl) & |
612 |
> |
(ap->next->weight <= av->weight) ) |
613 |
|
break; |
614 |
|
av->next = ap->next; |
615 |
|
ap->next = (AMBVAL*)av; |
722 |
|
/* |
723 |
|
* Ambient level test. |
724 |
|
*/ |
725 |
< |
if (av->lvl > al) /* list sorted, so this works */ |
725 |
> |
if (av->lvl > al || /* list sorted, so this works */ |
726 |
> |
(av->lvl == al) & (av->weight < 0.9*r->rweight)) |
727 |
|
break; |
726 |
– |
if (av->weight < 0.9*r->rweight) |
727 |
– |
continue; |
728 |
|
/* |
729 |
|
* Ambient radius test. |
730 |
|
*/ |
906 |
|
} |
907 |
|
avh.next = at->alist; /* order by increasing level */ |
908 |
|
for (ap = &avh; ap->next != NULL; ap = ap->next) |
909 |
< |
if (ap->next->lvl >= av->lvl) |
909 |
> |
if ( ap->next->lvl > av->lvl || |
910 |
> |
(ap->next->lvl == av->lvl) & |
911 |
> |
(ap->next->weight <= av->weight) ) |
912 |
|
break; |
913 |
|
av->next = ap->next; |
914 |
|
ap->next = (AMBVAL*)av; |
960 |
|
AMBVAL *av |
961 |
|
) |
962 |
|
{ |
963 |
< |
avinsert(avstore(av)); |
963 |
> |
avstore(av); |
964 |
|
if (ambfp == NULL) |
965 |
|
return; |
966 |
|
if (writambval(av, ambfp) < 0) |
975 |
|
|
976 |
|
|
977 |
|
static AMBVAL * |
978 |
< |
avstore( /* allocate memory and store aval */ |
978 |
> |
avstore( /* allocate memory and save aval */ |
979 |
|
AMBVAL *aval |
980 |
|
) |
981 |
|
{ |
993 |
|
avsum += log(d); |
994 |
|
navsum++; |
995 |
|
} |
996 |
+ |
avinsert(av); /* insert in our cache tree */ |
997 |
|
return(av); |
998 |
|
} |
999 |
|
|
1276 |
|
error(WARNING, errmsg); |
1277 |
|
break; |
1278 |
|
} |
1279 |
< |
avinsert(avstore(&avs)); |
1279 |
> |
avstore(&avs); |
1280 |
|
n -= AMBVALSIZ; |
1281 |
|
} |
1282 |
|
lastpos = flen - n; |