Hi again.

I applied valgrind to glob2, to locate the source of some double-free errors.
Before I got that far, however, I found a bug leading to nondeterminism:
Map::buildingAvailable() reads the building's localGradient if it is not dirty. But updateLocalGradient does not ensure that not-dirty means updated - at least not with the optimized version. If ULG determines that the building should be locked, then the gradient is not updated. I'll fix this by updating with a non-propagated gradient; I think this was the original behaviour, but I don't know if it is the right thing to do.
(A related bugfix is to not be lazy in ULG when the gradient is dirty.)

Sanity-check on my assumptions: A building is locked if it is not reachable, have I understood this correctly? What are/should be the exact conditions? It looks like currently it is deemed locked if it is not 'easily' accessible from (-1,-1) relative to it... I can't say I grok it.

And one more question about the intentions of the code (the comments are not plenty, the considering the complexity): Map::isInLocalGradient() - I suppose this should tell whether the local gradient map for a building can be used for a given unit coordinate. This area is a 32x32 square around the building, right? Apparently not, judging from the function; for instance, it disallows in some cases the point +(15,15) from the building.

I'd have expected something like...
bool Map::isInLocalGradient(int ux, int uy, int bx, int by) {
   int dx = (ux-bx+15)&wMask;
   int dy = (uy-by+15)&hMask;
   return (dx<32 && dy<32);
}

/Erik [seeking enlightenment :-]


_______________________________________________
glob2-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/glob2-devel

Reply via email to