F
Filip Strugar
...or where should I post it if this is not the right place?
Goes like this: I've got a following method in a class DataSource:
public IHeightmapSampler GetSampler(ushort maxSmpX, ushort maxSmpY)
{
if (maxSmpX == data.GetLength(0) && maxSmpY == data.GetLength(1))
return new DirectSampler(data);
throw new Exception("Map size is different than heightmap data size
but no other than DirectSampler avaliable.");
}
When I do DataSource.GetSampler() some other random method get's called
(both std debug/release build, with many variations).
I was surprised when, while debugging, I stepped into
DataSource.GetSampler() call but finished in some other property get_xx
method
Afther many variations I returned the 'return null; ' line (that I removed
to avoid unreachable code warning) and surprise - it works properly.
public IHeightmapSampler GetSampler(ushort maxSmpX, ushort maxSmpY)
{
if (maxSmpX == data.GetLength(0) && maxSmpY == data.GetLength(1))
return new DirectSampler(data);
throw new Exception("Map size is different than heightmap data size
but no other than DirectSampler avaliable.");
return null;
}
I'm using VS.NET 2003.
By the way, that's the second bug of that sort, I had a method that refused
to execute (access violation) unless some random code was added to it.
(VS.NET) Can't find it now
Goes like this: I've got a following method in a class DataSource:
public IHeightmapSampler GetSampler(ushort maxSmpX, ushort maxSmpY)
{
if (maxSmpX == data.GetLength(0) && maxSmpY == data.GetLength(1))
return new DirectSampler(data);
throw new Exception("Map size is different than heightmap data size
but no other than DirectSampler avaliable.");
}
When I do DataSource.GetSampler() some other random method get's called
(both std debug/release build, with many variations).
I was surprised when, while debugging, I stepped into
DataSource.GetSampler() call but finished in some other property get_xx
method

Afther many variations I returned the 'return null; ' line (that I removed
to avoid unreachable code warning) and surprise - it works properly.
public IHeightmapSampler GetSampler(ushort maxSmpX, ushort maxSmpY)
{
if (maxSmpX == data.GetLength(0) && maxSmpY == data.GetLength(1))
return new DirectSampler(data);
throw new Exception("Map size is different than heightmap data size
but no other than DirectSampler avaliable.");
return null;
}
I'm using VS.NET 2003.
By the way, that's the second bug of that sort, I had a method that refused
to execute (access violation) unless some random code was added to it.
(VS.NET) Can't find it now
