Browse Source

Merge branch 'update-config' into release-1.3

master
MagicBot 2 years ago
parent
commit
14d1c7ccbb
  1. 1
      src/engine/Enum.java
  2. 2
      src/engine/db/archive/DataWarehouse.java
  3. 10
      src/engine/gameManager/ConfigManager.java
  4. 2
      src/engine/gameManager/MaintenanceManager.java
  5. 10
      src/engine/server/MBServerStatics.java
  6. 4
      src/engine/server/login/LoginServer.java
  7. 2
      src/engine/server/login/LoginServerMsgHandler.java
  8. 58
      src/engine/util/MiscUtils.java

1
src/engine/Enum.java

@ -24,6 +24,7 @@ import java.util.Collections; @@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern;
/*
* MagicBane engine enumeration class.

2
src/engine/db/archive/DataWarehouse.java

@ -39,7 +39,7 @@ public class DataWarehouse implements Runnable { @@ -39,7 +39,7 @@ public class DataWarehouse implements Runnable {
// If WarehousePush is disabled
// then early exit
if ( ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equals("false")) {
if ( ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equalsIgnoreCase("false")) {
Logger.info("Warehouse Remote Connection disabled along with push");
return;
}

10
src/engine/gameManager/ConfigManager.java

@ -16,10 +16,12 @@ import engine.Enum; @@ -16,10 +16,12 @@ import engine.Enum;
import engine.net.NetMsgHandler;
import engine.server.login.LoginServer;
import engine.server.world.WorldServer;
import jdk.nashorn.internal.runtime.regexp.joni.ast.StringNode;
import org.pmw.tinylog.Logger;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public enum ConfigManager {
@ -47,6 +49,8 @@ public enum ConfigManager { @@ -47,6 +49,8 @@ public enum ConfigManager {
MB_LOGIN_PORT,
MB_LOGIN_AUTOREG,
MB_LOGIN_FNAME_REGEX,
MB_MAJOR_VER,
MB_MINOR_VER,
@ -87,6 +91,7 @@ public enum ConfigManager { @@ -87,6 +91,7 @@ public enum ConfigManager {
public static NetMsgHandler handler;
public static WorldServer worldServer;
public static LoginServer loginServer;
public static Map<ConfigManager, Pattern> regex = new HashMap<>();
// Called at bootstrap: ensures that all config values are loaded.
@ -99,9 +104,14 @@ public enum ConfigManager { @@ -99,9 +104,14 @@ public enum ConfigManager {
Logger.info(configSetting.name() + ":" + configSetting.getValue());
else {
Logger.error("Missing Config: " + configSetting.name());
Logger.error("Update your MagicBox: docker pull magicbane/magicbox:latest");
return false;
}
// compile regex here
regex.put(MB_LOGIN_FNAME_REGEX, Pattern.compile(MB_LOGIN_FNAME_REGEX.getValue()));
return true;
}

2
src/engine/gameManager/MaintenanceManager.java

@ -349,7 +349,7 @@ public enum MaintenanceManager { @@ -349,7 +349,7 @@ public enum MaintenanceManager {
// Run maintenance on player buildings
if ((boolean) ConfigManager.MB_WORLD_MAINTENANCE.getValue().equals("true"))
if ((boolean) ConfigManager.MB_WORLD_MAINTENANCE.getValue().equalsIgnoreCase("true"))
processBuildingMaintenance();
else
Logger.info("Maintenance Costings: DISABLED");

10
src/engine/server/MBServerStatics.java

@ -124,16 +124,6 @@ public class MBServerStatics { @@ -124,16 +124,6 @@ public class MBServerStatics {
public static final int CHM_THREAD_MED = 2;
public static final int CHM_THREAD_LOW = 1;
/*
* LoginServer related
*/
public static final String PCMajorVer = "1.2.25.5";
public static final String PCMinorVer = "5.25.5";
public static final String MACMajorVer = "1.2.24.3";
public static final String MACMinorVer = "5.24.3";
/*
* LoginErrorMsg related
*/

4
src/engine/server/login/LoginServer.java

@ -169,8 +169,8 @@ public class LoginServer { @@ -169,8 +169,8 @@ public class LoginServer {
// Configure the VersionInfoMsgs:
this.versionInfoMessage = new VersionInfoMsg(MBServerStatics.PCMajorVer,
MBServerStatics.PCMinorVer);
this.versionInfoMessage = new VersionInfoMsg(ConfigManager.MB_MAJOR_VER.getValue(),
ConfigManager.MB_MINOR_VER.getValue());
Logger.info("Initializing Database Pool");
initDatabasePool();

2
src/engine/server/login/LoginServerMsgHandler.java

@ -180,7 +180,7 @@ public class LoginServerMsgHandler implements NetMsgHandler { @@ -180,7 +180,7 @@ public class LoginServerMsgHandler implements NetMsgHandler {
if (account == null) {
if (ConfigManager.MB_LOGIN_AUTOREG.getValue().equals("FALSE")) {
if (ConfigManager.MB_LOGIN_AUTOREG.getValue().equalsIgnoreCase("false")) {
this.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', clientConnection);
Logger.info("Could not find account (" + uname + ')');
return;

58
src/engine/util/MiscUtils.java

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
package engine.util;
import engine.gameManager.ConfigManager;
import engine.server.MBServerStatics;
import java.util.regex.Pattern;
@ -16,20 +17,13 @@ import java.util.regex.Pattern; @@ -16,20 +17,13 @@ import java.util.regex.Pattern;
public class MiscUtils {
// no need to recompile these each call, put them in object scope and
// compile just once.
private static final Pattern lastNameRegex = Pattern
.compile("^[A-Za-z][-'A-Za-z\\x20]*$");
private static final Pattern firstNameRegex = Pattern
.compile("^[A-Za-z]+$");
public static boolean checkIfFirstNameInvalid(String firstName) {
if ((firstName == null) || (firstName.length() == 0)
|| (firstName.length() > MBServerStatics.MAX_NAME_LENGTH)
|| (firstName.length() < MBServerStatics.MIN_NAME_LENGTH)) {
return true;
}
return (!firstNameRegex.matcher(firstName).matches());
return (!ConfigManager.regex.get(ConfigManager.MB_LOGIN_FNAME_REGEX).matcher(firstName).matches());
}
public static boolean checkIfLastNameInvalid(String lastName) {
@ -43,52 +37,4 @@ public class MiscUtils { @@ -43,52 +37,4 @@ public class MiscUtils {
// empty last names are fine, return false
return false;
}
public static String getCallingMethodName() {
StackTraceElement e[] = Thread.currentThread().getStackTrace();
int numElements = e.length;
if (numElements < 1) {
return "NoStack";
}
if (numElements == 1) {
return e[0].getMethodName();
} else if (numElements == 2) {
return e[1].getMethodName();
} else if (numElements == 3) {
return e[2].getMethodName();
} else {
return e[3].getMethodName();
}
}
public static String getCallStackAsString() {
String out = "";
StackTraceElement e[] = Thread.currentThread().getStackTrace();
int numElements = e.length;
for (int i = (numElements - 1); i > 1; --i) {
String[] classStack = e[i].getClassName().split("\\.");
String methName = e[i].getMethodName();
String className = classStack[classStack.length - 1];
if (methName.equals("<init>")) {
methName = className;
}
out += className + '.' + methName + "()";
if (i > 2) {
out += " -> ";
}
}
return out;
}
}

Loading…
Cancel
Save