Skip to content

Commit 2ad9c6f

Browse files
authored
bugfix: sending alliance to afk crashes game (#2202)
## Description: Afk players are marked as not friendly, the canSendAllianceRequest was returning true even if already allied because isFriendly was false. This was allowing alliance requests to people we were already allied with. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
1 parent 349e7ac commit 2ad9c6f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/core/game/PlayerImpl.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ export class PlayerImpl implements Player {
390390
if (other === this) {
391391
return false;
392392
}
393+
if (this.isDisconnected() || other.isDisconnected()) {
394+
// Disconnected players are marked as not-friendly even if they are allies,
395+
// so we need to return early if either player is disconnected.
396+
// Otherise we could end up sending an alliance request to someone
397+
// we are already allied with.
398+
return false;
399+
}
393400
if (this.isFriendly(other) || !this.isAlive()) {
394401
return false;
395402
}

0 commit comments

Comments
 (0)