try
{
int rx = x - x_base;
int rz = z - z_base;
BiomeMap bm = biomemap[rx][rz];
if (sameneighborbiomecnt[rx][rz] >= (byte)8) /* All neighbors same? */
{
if (bm == BiomeMap.SWAMPLAND)
{
mult = swampmap[bm.biomeLookup()];
}
else
{
mult = colormap[bm.biomeLookup()];
}
}
else
{
int raccum = 0;
int gaccum = 0;
int baccum = 0;
for (int xoff = -1; xoff < 2; xoff++)
{
for (int zoff = -1; zoff < 2; zoff++)
{
bm = biomemap[rx + xoff][rz + zoff];
int rmult;
if (bm == BiomeMap.SWAMPLAND)
{
rmult = swampmap[bm.biomeLookup()];
}
else
{
rmult = colormap[bm.biomeLookup()];
}
raccum += (rmult >> 16) & 0xFF;
gaccum += (rmult >> 8) & 0xFF;
baccum += rmult & 0xFF;