* Cleanup of server memory handling - removed memory leaks for Chat, Player, Match, Game etc.

This commit is contained in:
LevelX2 2014-02-21 01:13:27 +01:00
parent c7289a3810
commit 8491b5b90b
27 changed files with 255 additions and 129 deletions

View file

@ -133,16 +133,18 @@ public class GameEndDialog extends MageDialog {
// get game log
try {
GamePanel gamePanel = MageFrame.getGame(gameEndView.getMatchView().getGames().get(gameEndView.getMatchView().getGames().size()-1));
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern( "yyyyMMdd_HHmmss" );
String fileName = new StringBuilder(dir).append(File.separator)
.append(sdf.format(gameEndView.getStartTime()))
.append("_").append(gameEndView.getMatchView().getGameType())
.append("_").append(gameEndView.getMatchView().getGames().size())
.append(".txt").toString();
PrintWriter out = new PrintWriter(fileName);
out.print(gamePanel.getGameLog());
out.close();
if (gamePanel != null) {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern( "yyyyMMdd_HHmmss" );
String fileName = new StringBuilder(dir).append(File.separator)
.append(sdf.format(gameEndView.getStartTime()))
.append("_").append(gameEndView.getMatchView().getGameType())
.append("_").append(gameEndView.getMatchView().getGames().size())
.append(".txt").toString();
PrintWriter out = new PrintWriter(fileName);
out.print(gamePanel.getGameLog());
out.close();
}
} catch (FileNotFoundException ex) {
JOptionPane.showMessageDialog(this, "Error while writing game log to file\n\n" + ex, "Error writing gamelog", JOptionPane.ERROR_MESSAGE);
}

View file

@ -245,7 +245,7 @@ public class TableWaitingDialog extends MageDialog {
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
if (!isTournament) {
session.startGame(roomId, tableId);
session.startMatch(roomId, tableId);
}
else {
session.startTournament(roomId, tableId);

View file

@ -617,7 +617,7 @@ public class TablesPanel extends javax.swing.JPanel {
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"));
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"));
session.startGame(roomId, table.getTableId());
session.startMatch(roomId, table.getTableId());
} catch (HeadlessException ex) {
handleError(ex);
}