mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Fix rare corner case crashes when an attempt is made to insert a card to the zone at a specific index position but that zone ends up being empty at that point (for instance, this can happen when clicking "Concede" during a mana payment for a spell). Currently this is set to issue a console warning for testing purposes to see if this happens in any other cases.
This commit is contained in:
@@ -80,6 +80,13 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
}
|
||||
|
||||
public void add(final Card c, final Integer index, final Card latestState) {
|
||||
if (index != null && cardList.isEmpty() && index.intValue() > 0) {
|
||||
// something went wrong, most likely the method fired when the game was in an unexpected state
|
||||
// (e.g. conceding during the mana payment prompt)
|
||||
System.out.println("Warning: tried to add a card to zone with a specific non-zero index, but the zone was empty! Canceling Zone#add to avoid a crash.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Immutable cards are usually emblems and effects
|
||||
if (!c.isImmutable()) {
|
||||
final Zone oldZone = game.getZoneOf(c);
|
||||
|
||||
Reference in New Issue
Block a user