|
|
|
@ -7,7 +7,6 @@
@@ -7,7 +7,6 @@
|
|
|
|
|
// www.magicbane.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package engine.server.world; |
|
|
|
|
|
|
|
|
|
import engine.Enum; |
|
|
|
@ -69,6 +68,8 @@ import static java.lang.System.exit;
@@ -69,6 +68,8 @@ import static java.lang.System.exit;
|
|
|
|
|
public class WorldServer { |
|
|
|
|
|
|
|
|
|
public static int worldMapID = Integer.parseInt(ConfigManager.MB_WORLD_MAPID.getValue()); |
|
|
|
|
public static int worldRealmMap = Integer.parseInt(ConfigManager.MB_WORLD_REALMMAP.getValue()); |
|
|
|
|
|
|
|
|
|
public static int worldUUID = 1; // Root object in database
|
|
|
|
|
public static Enum.AccountStatus worldAccessLevel = Enum.AccountStatus.valueOf(ConfigManager.MB_WORLD_ACCESS_LVL.getValue()); |
|
|
|
|
private static LocalDateTime bootTime = LocalDateTime.now(); |
|
|
|
@ -152,11 +153,8 @@ public class WorldServer {
@@ -152,11 +153,8 @@ public class WorldServer {
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void shutdown() { |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String getUptimeString() { |
|
|
|
|
|
|
|
|
|
String outString = null; |
|
|
|
|
java.time.Duration uptimeDuration; |
|
|
|
|
String newLine = System.getProperty("line.separator"); |
|
|
|
@ -174,13 +172,35 @@ public class WorldServer {
@@ -174,13 +172,35 @@ public class WorldServer {
|
|
|
|
|
return outString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void writePopulationFile() { |
|
|
|
|
|
|
|
|
|
int population = SessionManager.getActivePlayerCharacterCount(); |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File populationFile = new File(MBServerStatics.DEFAULT_DATA_DIR + ConfigManager.MB_WORLD_NAME.getValue().replaceAll("'", "") + ".pop"); |
|
|
|
|
FileWriter fileWriter; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
fileWriter = new FileWriter(populationFile, false); |
|
|
|
|
fileWriter.write(Integer.toString(population)); |
|
|
|
|
fileWriter.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.error(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int exec() { |
|
|
|
|
|
|
|
|
|
LocalDateTime nextHeartbeatTime = LocalDateTime.now(); |
|
|
|
|
LocalDateTime nextPopulationFileTime = LocalDateTime.now(); |
|
|
|
|
LocalDateTime nextFlashTrashCheckTime = LocalDateTime.now(); |
|
|
|
|
LocalDateTime nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1); |
|
|
|
|
LocalDateTime nextWareHousePushTime = LocalDateTime.now();; |
|
|
|
|
LocalDateTime nextWareHousePushTime = LocalDateTime.now(); |
|
|
|
|
|
|
|
|
|
// Begin execution of main game loop
|
|
|
|
|
|
|
|
|
@ -263,7 +283,6 @@ public class WorldServer {
@@ -263,7 +283,6 @@ public class WorldServer {
|
|
|
|
|
Guild.getErrantGuild(); |
|
|
|
|
|
|
|
|
|
Logger.info("Initializing PowersManager."); |
|
|
|
|
// activate powers manager
|
|
|
|
|
PowersManager.initPowersManager(true); |
|
|
|
|
|
|
|
|
|
Logger.info("Initializing granted Skills for Runes"); |
|
|
|
@ -278,7 +297,6 @@ public class WorldServer {
@@ -278,7 +297,6 @@ public class WorldServer {
|
|
|
|
|
Logger.info("Initializing MeshBounds"); |
|
|
|
|
MeshBounds.InitializeBuildingBounds(); |
|
|
|
|
|
|
|
|
|
// Load ItemBases
|
|
|
|
|
Logger.info("Loading ItemBases"); |
|
|
|
|
ItemBase.loadAllItemBases(); |
|
|
|
|
|
|
|
|
@ -294,6 +312,7 @@ public class WorldServer {
@@ -294,6 +312,7 @@ public class WorldServer {
|
|
|
|
|
// Load new loot system
|
|
|
|
|
Logger.info("Loading New Loot Tables"); |
|
|
|
|
LootManager.loadLootData(); |
|
|
|
|
|
|
|
|
|
//load old loot system (still needed for rolling for now)
|
|
|
|
|
LootTable.populateLootTables(); |
|
|
|
|
RuneBaseAttribute.LoadAllAttributes(); |
|
|
|
@ -307,7 +326,6 @@ public class WorldServer {
@@ -307,7 +326,6 @@ public class WorldServer {
|
|
|
|
|
Logger.info("Loading Mob Powers for MobBases"); |
|
|
|
|
PowersManager.LoadAllMobPowers(); |
|
|
|
|
|
|
|
|
|
//load item enchantment values
|
|
|
|
|
Logger.info("Loading item enchants"); |
|
|
|
|
DbManager.LootQueries.LOAD_ENCHANT_VALUES(); |
|
|
|
|
|
|
|
|
@ -364,18 +382,14 @@ public class WorldServer {
@@ -364,18 +382,14 @@ public class WorldServer {
|
|
|
|
|
SupportMsgType.InitializeSupportMsgType(); |
|
|
|
|
|
|
|
|
|
//Load Buildings, Mobs and NPCs for server
|
|
|
|
|
|
|
|
|
|
getWorldBuildingsMobsNPCs(); |
|
|
|
|
|
|
|
|
|
// Configure realms for serialization
|
|
|
|
|
// Doing this after the world is loaded
|
|
|
|
|
|
|
|
|
|
Logger.info("Configuring realm serialization data"); |
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
Realm.configureAllRealms(); |
|
|
|
|
}catch(Exception e){ |
|
|
|
|
Logger.error( e.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Logger.info("Loading Mine data."); |
|
|
|
|
Mine.loadAllMines(); |
|
|
|
@ -400,6 +414,7 @@ public class WorldServer {
@@ -400,6 +414,7 @@ public class WorldServer {
|
|
|
|
|
|
|
|
|
|
Logger.info("Loading All Players from database to Server Cache"); |
|
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
DbManager.PlayerCharacterQueries.GET_ALL_CHARACTERS(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
@ -407,6 +422,7 @@ public class WorldServer {
@@ -407,6 +422,7 @@ public class WorldServer {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
Logger.info("Loading All Players took " + (end - start) + " ms."); |
|
|
|
|
|
|
|
|
|
ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize(); |
|
|
|
@ -444,17 +460,19 @@ public class WorldServer {
@@ -444,17 +460,19 @@ public class WorldServer {
|
|
|
|
|
DispatchMessage.startMessagePump(); |
|
|
|
|
|
|
|
|
|
// Run maintenance
|
|
|
|
|
|
|
|
|
|
MaintenanceManager.dailyMaintenance(); |
|
|
|
|
|
|
|
|
|
// Disabled but kept in case of emergency
|
|
|
|
|
Logger.info("Starting Orphan Item Purge"); |
|
|
|
|
PurgeOprhans.startPurgeThread(); |
|
|
|
|
|
|
|
|
|
// Open/Close mines for the current window
|
|
|
|
|
|
|
|
|
|
Logger.info("Processing mine window."); |
|
|
|
|
HourlyJobThread.processMineWindow(); |
|
|
|
|
|
|
|
|
|
// Calculate bootstrap time and rest boot time to current time.
|
|
|
|
|
|
|
|
|
|
java.time.Duration bootDuration = java.time.Duration.between(LocalDateTime.now(), bootTime); |
|
|
|
|
long bootSeconds = Math.abs(bootDuration.getSeconds()); |
|
|
|
|
String boottime = String.format("%d hours %02d minutes %02d seconds", bootSeconds / 3600, (bootSeconds % 3600) / 60, (bootSeconds % 60)); |
|
|
|
@ -467,6 +485,7 @@ public class WorldServer {
@@ -467,6 +485,7 @@ public class WorldServer {
|
|
|
|
|
System.gc(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected boolean initDatabaselayer() { |
|
|
|
|
|
|
|
|
|
// Try starting a GOM <-> DB connection.
|
|
|
|
@ -493,7 +512,6 @@ public class WorldServer {
@@ -493,7 +512,6 @@ public class WorldServer {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getWorldBuildingsMobsNPCs() { |
|
|
|
|
|
|
|
|
|
ArrayList<Zone> rootParent; |
|
|
|
@ -702,29 +720,6 @@ public class WorldServer {
@@ -702,29 +720,6 @@ public class WorldServer {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void writePopulationFile() { |
|
|
|
|
|
|
|
|
|
int population = SessionManager.getActivePlayerCharacterCount(); |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File populationFile = new File(MBServerStatics.DEFAULT_DATA_DIR + ConfigManager.MB_WORLD_NAME.getValue().replaceAll("'","") + ".pop"); |
|
|
|
|
FileWriter fileWriter; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
fileWriter = new FileWriter(populationFile, false); |
|
|
|
|
fileWriter.write(Integer.toString(population)); |
|
|
|
|
fileWriter.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}catch(Exception e){ |
|
|
|
|
Logger.error(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void processTrashFile() { |
|
|
|
|
|
|
|
|
|
ArrayList<String> machineList; |
|
|
|
|