[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[glob2-devel] Intended behaviour for locking and isInLocalGradient()?
From: |
Erik Søe Sørensen |
Subject: |
[glob2-devel] Intended behaviour for locking and isInLocalGradient()? |
Date: |
Fri, 07 Sep 2007 23:18:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; da; rv:1.7.13) Gecko/20060717 Debian/1.7.12-1.1ubuntu2 StumbleUpon/1.9995 |
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] Intended behaviour for locking and isInLocalGradient()?,
Erik Søe Sørensen <=