Clone targetPos in attackPlan

On a rejoined client the data isn't the same anymore. But it's equal.
Likely this is because the data isn't aquired at the same turn.

This could also be solved more generally by copying all data which is
pushed to the AI. Or by using the same serializer for AI as for the rest
of the simulation.
This commit is contained in:
phosit committed 2026-05-10 14:18:51 +02:00
1 parent 3ddf101a06
commit 55f2d356ff
1 file changed
+2 -2
@@ -1239,7 +1239,7 @@ AttackPlan.prototype.getPathToTarget = function(gameState, fixedRallyPoint = fal
const endPos = { "x": this.targetPos[0], "y": this.targetPos[1] }; const endPos = { "x": this.targetPos[0], "y": this.targetPos[1] };
const path = Engine.ComputePath(startPos, endPos, gameState.getPassabilityClassMask("large")); const path = Engine.ComputePath(startPos, endPos, gameState.getPassabilityClassMask("large"));
this.path = []; this.path = [];
this.path.push(this.targetPos); this.path.push(clone(this.targetPos));
for (const p in path) for (const p in path)
this.path.push([path[p].x, path[p].y]); this.path.push([path[p].x, path[p].y]);
this.path.push(this.rallyPoint); this.path.push(this.rallyPoint);
@@ -2271,7 +2271,7 @@ AttackPlan.prototype.Serialize = function()
"isBlocked": this.isBlocked, "isBlocked": this.isBlocked,
"targetPlayer": this.targetPlayer, "targetPlayer": this.targetPlayer,
"target": this.target !== undefined ? this.target.id() : undefined, "target": this.target !== undefined ? this.target.id() : undefined,
"targetPos": this.targetPos, "targetPos": clone(this.targetPos),
"uniqueTargetId": this.uniqueTargetId, "uniqueTargetId": this.uniqueTargetId,
"path": this.path, "path": this.path,
"unitCollUpdateArray": this.unitCollUpdateArray "unitCollUpdateArray": this.unitCollUpdateArray