@@ -33,17 +33,13 @@ export class TransportShipExecution implements Execution {
3333
3434 private pathFinder : PathFinder ;
3535
36- private originalOwner : Player ;
37-
3836 constructor (
3937 private attacker : Player ,
4038 private targetID : PlayerID | null ,
4139 private ref : TileRef ,
4240 private startTroops : number ,
4341 private src : TileRef | null ,
44- ) {
45- this . originalOwner = this . attacker ;
46- }
42+ ) { }
4743
4844 activeDuringSpawnPhase ( ) : boolean {
4945 return false ;
@@ -177,43 +173,11 @@ export class TransportShipExecution implements Execution {
177173 }
178174 this . lastMove = ticks ;
179175
180- // Team mate can conquer disconnected player and get their ships
181- // captureUnit has changed the owner of the unit, now update attacker
182- if (
183- this . originalOwner . isDisconnected ( ) &&
184- this . boat . owner ( ) !== this . originalOwner &&
185- this . boat . owner ( ) . isOnSameTeam ( this . originalOwner )
186- ) {
187- this . attacker = this . boat . owner ( ) ;
188- this . originalOwner = this . boat . owner ( ) ; // for when this owner disconnects too
189- }
190-
191176 if ( this . boat . retreating ( ) ) {
192- // Ensure retreat source is valid for the new owner
193- if ( this . mg . owner ( this . src ! ) !== this . attacker ) {
194- // Use bestTransportShipSpawn, not canBuild because of its max boats check etc
195- const newSrc = this . attacker . bestTransportShipSpawn ( this . dst ) ;
196- if ( newSrc === false ) {
197- this . src = null ;
198- } else {
199- this . src = newSrc ;
200- }
201- }
177+ this . dst = this . src ! ; // src is guaranteed to be set at this point
202178
203- if ( this . src === null ) {
204- console . warn (
205- `TransportShipExecution: retreating but no src found for new attacker` ,
206- ) ;
207- this . attacker . addTroops ( this . boat . troops ( ) ) ;
208- this . boat . delete ( false ) ;
209- this . active = false ;
210- return ;
211- } else {
212- this . dst = this . src ;
213-
214- if ( this . boat . targetTile ( ) !== this . dst ) {
215- this . boat . setTargetTile ( this . dst ) ;
216- }
179+ if ( this . boat . targetTile ( ) !== this . dst ) {
180+ this . boat . setTargetTile ( this . dst ) ;
217181 }
218182 }
219183
0 commit comments