[Server] fastDbMode for starting without scanning for cards

This commit is contained in:
magenoxx 2014-07-15 21:44:48 +04:00
parent ede16deca1
commit 8a9474d839
2 changed files with 26 additions and 14 deletions

View file

@ -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...");
if (fastDbMode) {
CardScanner.scanned = true;
} else {
CardScanner.scan();
}
logger.info("Done.");
deleteSavedGames();
ConfigSettings config = ConfigSettings.getInstance();
for (GamePlugin plugin: config.getGameTypes()) {
@ -110,16 +132,6 @@ 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());

View file

@ -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);
}
}
}