mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* Improved connection performance on new release, no more empty cards on startup;
This commit is contained in:
parent
6846db75f4
commit
f788af1f6a
4 changed files with 20 additions and 10 deletions
|
@ -3,6 +3,7 @@ package mage.client;
|
|||
import mage.cards.action.ActionCallback;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.CardScanner;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.cards.repository.RepositoryUtil;
|
||||
import mage.client.cards.BigCard;
|
||||
|
@ -215,7 +216,15 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
LOGGER.fatal(null, ex);
|
||||
}
|
||||
|
||||
// DATA PREPARE
|
||||
RepositoryUtil.bootstrapLocalDb();
|
||||
// re-create database on empty (e.g. after new build cleaned db on startup)
|
||||
if (RepositoryUtil.CARD_DB_RECREATE_BY_CLIENT_SIDE && RepositoryUtil.isDatabaseEmpty()) {
|
||||
LOGGER.info("DB: creating cards database");
|
||||
CardScanner.scan();
|
||||
LOGGER.info("Done.");
|
||||
}
|
||||
|
||||
if (RateCard.PRELOAD_CARD_RATINGS_ON_STARTUP) {
|
||||
RateCard.bootstrapCardsAndRatings();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/*
|
||||
* ConnectDialog.java
|
||||
*
|
||||
* Created on 20-Jan-2010, 9:37:07 PM
|
||||
*/
|
||||
package mage.client.dialog;
|
||||
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.cards.repository.RepositoryUtil;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.client.MageFrame;
|
||||
|
@ -509,9 +503,7 @@ public class ConnectDialog extends MageDialog {
|
|||
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
|
||||
connection.setUsername(this.txtUserName.getText().trim());
|
||||
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
|
||||
// force to redownload db
|
||||
boolean redownloadDatabase = (ExpansionRepository.instance.getSetByCode("GRN") == null || CardRepository.instance.findCard("Island") == null);
|
||||
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected() || redownloadDatabase);
|
||||
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected() || RepositoryUtil.isDatabaseEmpty());
|
||||
String allMAC = "";
|
||||
try {
|
||||
allMAC = Connection.getMAC();
|
||||
|
|
|
@ -402,6 +402,9 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
private void updateDatabase(boolean forceDBComparison, ServerState serverState) {
|
||||
// download NEW cards/sets, but do not download data fixes (it's an old and rare feature from old clients, e.g. one client for different servers with different cards)
|
||||
// use case: server gets new minor version with new cards, old client can get that cards too without donwload new version
|
||||
|
||||
// sets
|
||||
long expansionDBVersion = ExpansionRepository.instance.getContentVersionFromDB();
|
||||
if (forceDBComparison || serverState.getExpansionsContentVersion() > expansionDBVersion) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.List;
|
|||
public final class RepositoryUtil {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(RepositoryUtil.class);
|
||||
public static final boolean CARD_DB_RECREATE_BY_CLIENT_SIDE = true; // re-creates db from client (best performance) or downloads from server on connects (can be slow)
|
||||
|
||||
public static void bootstrapLocalDb() {
|
||||
// call local db to init all sets and cards repository (need for correct updates cycle, not on random request)
|
||||
|
@ -103,4 +104,9 @@ public final class RepositoryUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isDatabaseEmpty() {
|
||||
return ExpansionRepository.instance.getSetByCode("GRN") == null
|
||||
|| CardRepository.instance.findCard("Island") == null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue