mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +00:00
Server: fixed NPE error on wrong AI usage in new game dialogs (fixes #7556);
This commit is contained in:
parent
82f40f04ae
commit
42364f7e27
5 changed files with 34 additions and 24 deletions
|
@ -30,7 +30,7 @@ public interface ICardGrid {
|
||||||
// only for debug, return inner cards list
|
// only for debug, return inner cards list
|
||||||
Object getCardsStore();
|
Object getCardsStore();
|
||||||
|
|
||||||
// specil memory optimization to clean inner cards list before new cards load, so you don't need 2x memory
|
// special memory optimization to clean inner cards list before new cards load, so you don't need 2x memory
|
||||||
// WARNING, you must call it in same code as new cards list prepare
|
// WARNING, you must call it in the same code as new cards list prepare
|
||||||
void clearCardsStoreBeforeUpdate();
|
void clearCardsStoreBeforeUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,7 +471,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
||||||
|
|
||||||
private void debugObjectMemorySize(String name, Object object) {
|
private void debugObjectMemorySize(String name, Object object) {
|
||||||
// just debug code, don't use it in production
|
// just debug code, don't use it in production
|
||||||
// need 2x memory for find a size
|
// need 2x memory to find a size
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||||
|
|
|
@ -522,6 +522,19 @@ public class NewTableDialog extends MageDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
// join AI
|
||||||
|
for (TablePlayerPanel player : players) {
|
||||||
|
if (player.getPlayerType() != PlayerType.HUMAN) {
|
||||||
|
if (!player.joinTable(roomId, table.getTableId())) {
|
||||||
|
// error message must be send by the server
|
||||||
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
|
table = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// join itself
|
||||||
if (SessionHandler.joinTable(
|
if (SessionHandler.joinTable(
|
||||||
roomId,
|
roomId,
|
||||||
table.getTableId(),
|
table.getTableId(),
|
||||||
|
@ -529,16 +542,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
PlayerType.HUMAN, 1,
|
PlayerType.HUMAN, 1,
|
||||||
DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true),
|
DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true),
|
||||||
this.txtPassword.getText())) {
|
this.txtPassword.getText())) {
|
||||||
for (TablePlayerPanel player : players) {
|
// all fine, can close create dialog (join dialog will be opened after feedback from server)
|
||||||
if (player.getPlayerType() != PlayerType.HUMAN) {
|
|
||||||
if (!player.joinTable(roomId, table.getTableId())) {
|
|
||||||
// error message must be send by the server
|
|
||||||
SessionHandler.removeTable(roomId, table.getTableId());
|
|
||||||
table = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.hideDialog();
|
this.hideDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -692,6 +692,20 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
// message must be send by server!
|
// message must be send by server!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// join AI
|
||||||
|
for (TournamentPlayerPanel player : players) {
|
||||||
|
if (player.getPlayerType().getSelectedItem() != PlayerType.HUMAN) {
|
||||||
|
if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true))) {
|
||||||
|
// error message must be send by sever
|
||||||
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
|
table = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// join itself
|
||||||
if (SessionHandler.joinTournamentTable(
|
if (SessionHandler.joinTournamentTable(
|
||||||
roomId,
|
roomId,
|
||||||
table.getTableId(),
|
table.getTableId(),
|
||||||
|
@ -699,19 +713,11 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
PlayerType.HUMAN, 1,
|
PlayerType.HUMAN, 1,
|
||||||
DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true),
|
DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true),
|
||||||
tOptions.getPassword())) {
|
tOptions.getPassword())) {
|
||||||
for (TournamentPlayerPanel player : players) {
|
// all fine, can close create dialog (join dialog will be opened after feedback from server)
|
||||||
if (player.getPlayerType().getSelectedItem() != PlayerType.HUMAN) {
|
|
||||||
if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true))) {
|
|
||||||
// error message must be send by sever
|
|
||||||
SessionHandler.removeTable(roomId, table.getTableId());
|
|
||||||
table = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.hideDialog();
|
this.hideDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
SessionHandler.removeTable(roomId, table.getTableId());
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
table = null;
|
table = null;
|
||||||
|
|
|
@ -608,7 +608,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
logger.fatal("Client error\n", ex);
|
logger.fatal("Client error\n", ex);
|
||||||
String errorMessage = ex.getMessage();
|
String errorMessage = ex.getMessage();
|
||||||
if (errorMessage == null || errorMessage.isEmpty() || errorMessage.equals("Null")) {
|
if (errorMessage == null || errorMessage.isEmpty() || errorMessage.equals("Null")) {
|
||||||
errorMessage = ex.getClass().getSimpleName() + " - look server logs for more details";
|
errorMessage = ex.getClass().getSimpleName() + " - look server or client logs for more details";
|
||||||
}
|
}
|
||||||
frame.showError("Server's error: " + errorMessage);
|
frame.showError("Server's error: " + errorMessage);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue