for(int n = 0;n < 4;n++)
{
nextcoord[n] = mapdata.adjustToMapSize(nextcoord[n]);
if(nextcoord[n] != null)
{
Field nextfield = mapdata.getField(nextcoord[n]);
if((nextfield.getWaterFlow() < 0) && (nextfield.isLand()))
{
int probability = -1;
int from = config.UNDEFINED;
int to = config.UNDEFINED;
from = config.getHeightConstant(start);
to = config.getHeightConstant(nextfield);
if((from != config.UNDEFINED) && (to != config.UNDEFINED)
&& (randomgen.nextDouble() < config.probevprobs[from][to]))
{
if(config.probev_seastopprobsuse)
{
int nextdst = nextfield.getDistanceToSea();
double [] probs = config.probev_seastopprobs;
int [] mindepth = config.probev_seastopprobsmindepth;
if((nextdst <= probs.length)
&& (depth >= mindepth[nextdst - 1])
&& (randomgen.nextDouble() <= probs[nextdst - 1]))
continue;
}
int nstoppoints = stoppoints +
config.probev_callstoppoints[recnumber];
if(config.probev_spforturnarounduse)
{
Coordinate s = start.getPosition();
int dst = Math.abs(startpos.x - nextcoord[n].x) +
Math.abs(startpos.y - nextcoord[n].y);
int olddst = Math.abs(startpos.x - s.x) +
Math.abs(startpos.y - s.y);
if((dst < olddst)
&& (dst >= config.probev_turnaroundmindist))
nstoppoints += config.probev_spforturnaround;
}
if(config.probev_spfornearerseause)
{
int newseadist = nextfield.getDistanceToSea();
if((newseadist <= config.probev_nearerseamaxdist)
&& (newseadist < start.getDistanceToSea()))
nstoppoints += config.probev_spfornearersea;
}
start.addWaterFlowFrom(nextfield);
nextfield.setWaterFlowTo(start);
otherfieldsflow += evolveRiver(nextfield,nstoppoints,depth + 1);
recnumber++;
}
}
}