From 8a9474d839907a65f0b2a29238ac985928acc873 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Tue, 15 Jul 2014 21:44:48 +0400 Subject: [PATCH] [Server] fastDbMode for starting without scanning for cards --- .../src/main/java/mage/server/Main.java | 36 ++++++++++++------- .../mage/cards/repository/CardScanner.java | 4 +-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/Main.java b/Mage.Server/src/main/java/mage/server/Main.java index d9ad4e4bf2..18f0dc35ab 100644 --- a/Mage.Server/src/main/java/mage/server/Main.java +++ b/Mage.Server/src/main/java/mage/server/Main.java @@ -75,6 +75,7 @@ public class Main { private static final MageVersion version = new MageVersion(1, 3, 0, MageVersion.MAGE_VERSION_INFO); private static final String testModeArg = "-testMode="; + private static final String fastDBModeArg = "-fastDbMode="; private static final String adminPasswordArg = "-adminPassword="; private static final String pluginFolder = "plugins"; @@ -82,6 +83,7 @@ public class Main { public static PluginClassLoader classLoader = new PluginClassLoader(); public static TransporterServer server; protected static boolean testMode; + protected static boolean fastDbMode; /** * @param args the command line arguments @@ -90,9 +92,29 @@ public class Main { logger.info("Starting MAGE server version " + version); logger.info("Logging level: " + logger.getEffectiveLevel()); + + String adminPassword = ""; + for (String arg: args) { + if (arg.startsWith(testModeArg)) { + testMode = Boolean.valueOf(arg.replace(testModeArg, "")); + } + else if (arg.startsWith(adminPasswordArg)) { + adminPassword = arg.replace(adminPasswordArg, ""); + adminPassword = SystemUtil.sanitize(adminPassword); + } + else if (arg.startsWith(fastDBModeArg)) { + fastDbMode = Boolean.valueOf(arg.replace(fastDBModeArg, "")); + } + } + logger.info("Loading cards..."); - CardScanner.scan(); + if (fastDbMode) { + CardScanner.scanned = true; + } else { + CardScanner.scan(); + } logger.info("Done."); + deleteSavedGames(); ConfigSettings config = ConfigSettings.getInstance(); for (GamePlugin plugin: config.getGameTypes()) { @@ -110,17 +132,7 @@ public class Main { for (Plugin plugin: config.getDeckTypes()) { DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin)); } - String adminPassword = ""; - for (String arg: args) { - if (arg.startsWith(testModeArg)) { - testMode = Boolean.valueOf(arg.replace(testModeArg, "")); - } - else if (arg.startsWith(adminPasswordArg)) { - adminPassword = arg.replace(adminPasswordArg, ""); - adminPassword = SystemUtil.sanitize(adminPassword); - } - } - + logger.info("Config - max seconds idle: " + config.getMaxSecondsIdle()); logger.info("Config - max game threads: " + config.getMaxGameThreads()); logger.info("Config - max AI opponents: " + config.getMaxAiOpponents()); diff --git a/Mage/src/mage/cards/repository/CardScanner.java b/Mage/src/mage/cards/repository/CardScanner.java index eebf0681ce..0cce67bf8a 100644 --- a/Mage/src/mage/cards/repository/CardScanner.java +++ b/Mage/src/mage/cards/repository/CardScanner.java @@ -40,11 +40,10 @@ import java.util.List; */ public class CardScanner { - private static boolean scanned = false; + public static boolean scanned = false; private static final Logger logger = Logger.getLogger(CardScanner.class); - public static void scan() { if (scanned) { return; @@ -76,5 +75,6 @@ public class CardScanner { logger.info("Cards need storing in DB: " + cardsToAdd.size()); CardRepository.instance.addCards(cardsToAdd); } + } }