forked from mirrors/0ad
petra: fixes placement of dock when on the border of the map
fixes attack path computation when change of target during
preparation
fixes #3710
This was SVN commit r17557.
This commit is contained in:
@@ -767,7 +767,10 @@ m.AttackPlan.prototype.chooseTarget = function(gameState)
|
||||
}
|
||||
|
||||
if (rallySame)
|
||||
{
|
||||
this.rallyPoint = rallySame;
|
||||
this.overseas = 0;
|
||||
}
|
||||
else if (rallyDiff)
|
||||
{
|
||||
rallyIndex = gameState.ai.accessibility.getAccessValue(rallyDiff);
|
||||
@@ -779,9 +782,11 @@ m.AttackPlan.prototype.chooseTarget = function(gameState)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (this.overseas)
|
||||
this.overseas = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// sameLand true means that we look for a target for which we do not need to take a transport
|
||||
m.AttackPlan.prototype.getNearestTarget = function(gameState, position, sameLand)
|
||||
{
|
||||
|
||||
@@ -517,11 +517,14 @@ m.ConstructionPlan.prototype.getDockAngle = function(gameState, x, z, size)
|
||||
for (var dist = 0; dist < 4; ++dist)
|
||||
{
|
||||
var waterPoints = [];
|
||||
for (var i = 0; i < numPoints; ++i)
|
||||
for (let i = 0; i < numPoints; ++i)
|
||||
{
|
||||
let angle = (i/numPoints)*2*Math.PI;
|
||||
pos = [x - (1+dist)*size*Math.sin(angle), z + (1+dist)*size*Math.cos(angle)];
|
||||
pos = gameState.ai.accessibility.gamePosToMapPos(pos);
|
||||
if (pos[0] < 0 || pos[0] >= gameState.ai.accessibility.width ||
|
||||
pos[1] < 0 || pos[1] >= gameState.ai.accessibility.height)
|
||||
continue;
|
||||
let j = pos[0] + pos[1]*gameState.ai.accessibility.width;
|
||||
if (gameState.ai.accessibility.navalPassMap[j] == seaRef)
|
||||
waterPoints.push(i);
|
||||
@@ -595,14 +598,23 @@ m.ConstructionPlan.prototype.checkDockPlacement = function(gameState, x, z, half
|
||||
for (let i = 1; i < 5; ++i)
|
||||
{
|
||||
pos = gameState.ai.accessibility.gamePosToMapPos([x + sz + i*(sp+sw), z + cz + i*(cp-cw)]);
|
||||
if (pos[0] < 0 || pos[0] >= gameState.ai.accessibility.width ||
|
||||
pos[1] < 0 || pos[1] >= gameState.ai.accessibility.height)
|
||||
break;
|
||||
j = pos[0] + pos[1]*gameState.ai.accessibility.width;
|
||||
if (gameState.ai.accessibility.landPassMap[j] > 1 || gameState.ai.accessibility.navalPassMap[j] < 2)
|
||||
break;
|
||||
pos = gameState.ai.accessibility.gamePosToMapPos([x + sz + i*sp, z + cz + i*cp]);
|
||||
if (pos[0] < 0 || pos[0] >= gameState.ai.accessibility.width ||
|
||||
pos[1] < 0 || pos[1] >= gameState.ai.accessibility.height)
|
||||
break;
|
||||
j = pos[0] + pos[1]*gameState.ai.accessibility.width;
|
||||
if (gameState.ai.accessibility.landPassMap[j] > 1 || gameState.ai.accessibility.navalPassMap[j] < 2)
|
||||
break;
|
||||
pos = gameState.ai.accessibility.gamePosToMapPos([x + sz + i*(sp-sw), z + cz + i*(cp+cw)]);
|
||||
if (pos[0] < 0 || pos[0] >= gameState.ai.accessibility.width ||
|
||||
pos[1] < 0 || pos[1] >= gameState.ai.accessibility.height)
|
||||
break;
|
||||
j = pos[0] + pos[1]*gameState.ai.accessibility.width;
|
||||
if (gameState.ai.accessibility.landPassMap[j] > 1 || gameState.ai.accessibility.navalPassMap[j] < 2)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user