Attempt to combat game memory leaks after game finishes.

- Make PLAY_LAND_SURROGATE a game field rather than static
- Remove games from cache more aggressively
- Remove targeting overlay from global view after game ends
This commit is contained in:
elcnesh
2015-04-02 14:35:42 +00:00
parent b7a47736bf
commit dc4559c577
10 changed files with 67 additions and 35 deletions

View File

@@ -1097,9 +1097,9 @@ public class AiController {
if (landsWannaPlay != null && !landsWannaPlay.isEmpty() && player.canPlayLand(null)) {
Card land = chooseBestLandToPlay(landsWannaPlay);
if (ComputerUtil.damageFromETB(player, land) < player.getLife() || !player.canLoseLife()) {
Ability.PLAY_LAND_SURROGATE.setHostCard(land);
game.PLAY_LAND_SURROGATE.setHostCard(land);
final List<SpellAbility> abilities = new ArrayList<SpellAbility>();
abilities.add(Ability.PLAY_LAND_SURROGATE);
abilities.add(game.PLAY_LAND_SURROGATE);
return abilities;
}
}

View File

@@ -397,10 +397,9 @@ public class PlayerControllerAi extends PlayerController {
@Override
public void playChosenSpellAbility(SpellAbility sa) {
// System.out.println("Playing sa: " + sa);
if (sa == Ability.PLAY_LAND_SURROGATE) {
if (sa == sa.getHostCard().getGame().PLAY_LAND_SURROGATE) {
player.playLand(sa.getHostCard(), false);
}
else {
} else {
ComputerUtil.handlePlayingSpellAbility(player, sa, game);
}
}

View File

@@ -15,7 +15,6 @@ import forge.game.GameObject;
import forge.game.card.Card;
import forge.game.card.CardCollection;
import forge.game.player.Player;
import forge.game.spellability.Ability;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetChoices;
import forge.game.spellability.TargetRestrictions;
@@ -152,7 +151,7 @@ public class GameSimulator {
}
}
if (sa == Ability.PLAY_LAND_SURROGATE) {
if (sa == origSa.getHostCard().getGame().PLAY_LAND_SURROGATE) {
aiPlayer.playLand(sa.getHostCard(), false);
} else {
if (debugPrint && !sa.getAllTargetChoices().isEmpty()) {