forked from MagicBane/Server
Color map built after realms loaded.
This commit is contained in:
@@ -52,8 +52,7 @@ public enum RealmMap {
|
||||
|
||||
if (yBuckets < 0 || yBuckets >= MBServerStatics.SPATIAL_HASH_BUCKETSY
|
||||
|| xBuckets < 0 || xBuckets >= MBServerStatics.SPATIAL_HASH_BUCKETSX) {
|
||||
Logger.error("WorldServerRealm.getRealmFromPosition",
|
||||
"Invalid range; Z: " + yBuckets + ", X: " + xBuckets);
|
||||
Logger.error("Invalid range; Z: " + yBuckets + ", X: " + xBuckets);
|
||||
return 255;
|
||||
}
|
||||
|
||||
@@ -110,6 +109,12 @@ public enum RealmMap {
|
||||
|
||||
public static void loadRealmImageMap() {
|
||||
|
||||
// Build color lookup map for realms from database
|
||||
|
||||
for (Realm realm : Realm._realms.values()) {
|
||||
RealmMap.addToColorMap(realm.mapColor, realm.realmID);
|
||||
}
|
||||
|
||||
RealmMap._realmImageMap = MapLoader.loadMap();
|
||||
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Realm {
|
||||
private final int stretchY;
|
||||
private final int locX;
|
||||
private final int locY;
|
||||
private final int realmID;
|
||||
public final int realmID;
|
||||
private final HashSet<Integer> cities = new HashSet<>();
|
||||
private String hash;
|
||||
|
||||
@@ -204,7 +204,6 @@ public class Realm {
|
||||
public static void configureAllRealms() {
|
||||
|
||||
for (Realm realm : Realm._realms.values()) {
|
||||
RealmMap.addToColorMap(realm.mapColor, realm.realmID);
|
||||
realm.configure();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,6 +326,9 @@ public class WorldServer {
|
||||
Logger.info("Loading Realms");
|
||||
Realm.loadAllRealms();
|
||||
|
||||
Logger.info("Loading RealmMap");
|
||||
RealmMap.loadRealmImageMap();
|
||||
|
||||
Logger.info("Loading Kits");
|
||||
DbManager.KitQueries.GET_ALL_KITS();
|
||||
|
||||
@@ -334,10 +337,6 @@ public class WorldServer {
|
||||
|
||||
Logger.info("Starting InterestManager.");
|
||||
WorldGrid.startLoadJob();
|
||||
|
||||
|
||||
Logger.info("Loading Spaital Hash");
|
||||
RealmMap.loadRealmImageMap();
|
||||
|
||||
DbManager.MobBaseQueries.SET_AI_DEFAULTS();
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ public enum MapLoader {
|
||||
long timeToLoad = System.currentTimeMillis();
|
||||
long bytesRead = 0;
|
||||
long realmsWritten = 0;
|
||||
|
||||
Integer realmUUID = null;
|
||||
int realmUUID;
|
||||
|
||||
// Load image from disk
|
||||
|
||||
@@ -54,20 +53,14 @@ public enum MapLoader {
|
||||
try {
|
||||
int rgb = image.getRGB(j, i);
|
||||
realmUUID = RealmMap.getRealmIDByRGB(rgb);
|
||||
|
||||
if (realmUUID == null) {
|
||||
Logger.error("Corrupted png: unknown color " + rgb);
|
||||
WorldServer.shutdown();
|
||||
}
|
||||
|
||||
realmMap[j][i] = realmUUID.intValue();
|
||||
realmMap[j][i] = realmUUID;
|
||||
bytesRead++;
|
||||
|
||||
if (realmUUID.intValue() != 0)
|
||||
if (realmUUID != 0)
|
||||
realmsWritten++;
|
||||
|
||||
}catch (Exception e){
|
||||
// Logger.error("REALMEDIT ERROR", e.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -76,9 +69,7 @@ public enum MapLoader {
|
||||
}
|
||||
timeToLoad = System.currentTimeMillis() - timeToLoad;
|
||||
|
||||
Logger.info( bytesRead + " pixels processed in " + timeToLoad / 1000 + " seconds");
|
||||
Logger.info("Realm pixels written : " + realmsWritten);
|
||||
image = null;
|
||||
Logger.info( bytesRead + "Realm imageMNap pixels processed in " + timeToLoad / 1000 + " seconds");
|
||||
return realmMap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user