Commit e2e156c5 authored by Kenix Whisperwind's avatar Kenix Whisperwind

WorldLoader now stores a context to the World so it doesn't need to pass...

WorldLoader now stores a context to the World so it doesn't need to pass around a world reference to all methods.
parent 54cc5ebd
......@@ -254,7 +254,7 @@ public final class SuperModerator implements CommandListener {
}
player.message(messagePrefix + "Drop tables reloaded");
} else if (cmd.equalsIgnoreCase("reloadworld") || cmd.equalsIgnoreCase("reloadland")) {
World.getWorld().getWorldLoader().loadWorld(World.getWorld());
World.getWorld().getWorldLoader().loadWorld();
player.message(messagePrefix + "World Reloaded");
} else if (cmd.equalsIgnoreCase("summonall")) {
if (args.length == 1) {
......
......@@ -21,6 +21,11 @@ public class WorldLoader {
*/
private static final Logger LOGGER = LogManager.getLogger();
private ZipFile tileArchive;
private final World world;
public WorldLoader(World world) {
this.world = world;
}
private static boolean projectileClipAllowed(int wallID) {
for (int allowedWallIdType : ALLOWED_WALL_ID_TYPES) {
......@@ -31,8 +36,7 @@ public class WorldLoader {
return false;
}
private boolean loadSection(int sectionX, int sectionY, int height,
World world, int bigX, int bigY) {
private boolean loadSection(int sectionX, int sectionY, int height, int bigX, int bigY) {
Sector s = null;
try {
String filename = "h" + height + "x" + sectionX + "y" + sectionY;
......@@ -137,7 +141,7 @@ public class WorldLoader {
}
public void loadWorld(World world) {
public void loadWorld() {
final long start = System.currentTimeMillis();
try {
if (Server.getServer().getConfig().MEMBER_WORLD) {
......@@ -159,8 +163,8 @@ public class WorldLoader {
for (int sy = 0; sy < 944; sy += 48) {
int x = (sx + wildX) / 48;
int y = (sy + (lvl * 944) + wildY) / 48;
if (loadSection(x, y, lvl, world, sx, sy + (944 * lvl))) {
loadSection(x, y, lvl, world, sx, sy + (944 * lvl));
if (loadSection(x, y, lvl, sx, sy + (944 * lvl))) {
loadSection(x, y, lvl, sx, sy + (944 * lvl));
sectors++;
}
}
......
......@@ -43,19 +43,22 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
public static final int MAX_HEIGHT = 4032; // 3776
public static final int MAX_WIDTH = 1008; // 944
/**
* The asynchronous logger.
*/
private static final Logger LOGGER = LogManager.getLogger();
/**
* IP filtering for wilderness entry
*/
private final static IPTracker<String> wildernessIPTracker = new ThreadSafeIPTracker<String>();
/**
* Avatar generator upon logout save to PNG.
*/
private final static AvatarGenerator avatarGenerator = new AvatarGenerator();
/**
* IP filtering for wilderness entry
*/
private final static IPTracker<String> wildernessIPTracker = new ThreadSafeIPTracker<String>();
private static final String[] objectsProjectileClipAllowed = {"gravestone", "sign", "broken pillar", "bone",
"animalskull", "skull", "egg", "eggs", "ladder", "torch", "rock", "treestump", "railing",
"railings", "gate", "fence", "table", "smashed chair", "smashed table", "longtable", "fence", "chair"};
......@@ -69,14 +72,18 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
public static int EVENT_COMBAT_MIN, EVENT_COMBAT_MAX;
public static boolean WORLD_TELEGRAB_TOGGLE = false;
private static World worldInstance;
private final EntityList<Npc> npcs = new EntityList<Npc>(4000);
private final EntityList<Player> players = new EntityList<Player>(2000);
private final List<QuestInterface> quests = new LinkedList<QuestInterface>();
private final List<MiniGameInterface> minigames = new LinkedList<MiniGameInterface>();
private final List<Shop> shopData = new ArrayList<Shop>();
private final List<Shop> shops = new ArrayList<Shop>();
private final TileValue[][] tiles = new TileValue[MAX_WIDTH][MAX_HEIGHT];
private WorldLoader worldLoader;
//private final RegionManager regionManager;
private final EntityList<Npc> npcs;
private final EntityList<Player> players;
private final List<QuestInterface> quests;
private final List<MiniGameInterface> minigames;
private final List<Shop> shopData;
private final List<Shop> shops;
private final Map<TrawlerBoat, FishingTrawler> fishingTrawler;
private final TileValue[][] tiles;
private final WorldLoader worldLoader;
private Map<Player, Boolean> playerUnderAttackMap = new HashMap<Player, Boolean>();
private Map<Npc, Boolean> npcUnderAttackMap = new HashMap<Npc, Boolean>();
......@@ -88,20 +95,22 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
/**
* Double ended queue to store snapshots into
*/
private Deque<Snapshot> snapshots = new LinkedList<Snapshot>();
private Map<TrawlerBoat, FishingTrawler> fishingTrawler = new HashMap<TrawlerBoat, FishingTrawler>();
public static IPTracker<String> getWildernessIPTracker() {
return wildernessIPTracker;
}
private Deque<Snapshot> snapshots;
private final Server server;
public final Server getServer() {
return server;
}
public World(Server server) {
this.server = server;
npcs = new EntityList<Npc>(4000);
players = new EntityList<Player>(2000);
quests = new LinkedList<QuestInterface>();
minigames = new LinkedList<MiniGameInterface>();
shopData = new ArrayList<Shop>();
shops = new ArrayList<Shop>();
fishingTrawler = new HashMap<TrawlerBoat, FishingTrawler>();
tiles = new TileValue[MAX_WIDTH][MAX_HEIGHT];
snapshots = new LinkedList<Snapshot>();
worldLoader = new WorldLoader(this);
}
public static synchronized World getWorld() {
......@@ -390,8 +399,7 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
try {
ClanManager.init();
PartyManager.init();
worldInstance.worldLoader = new WorldLoader();
worldInstance.getWorldLoader().loadWorld(worldInstance);
worldInstance.getWorldLoader().loadWorld();
WorldPopulation.populateWorld(worldInstance);
shutdownCheck();
if (Server.getServer().getConfig().WANT_NEW_RARE_DROP_TABLES)
......@@ -919,8 +927,15 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
}
public WorldLoader getWorldLoader() {
return worldLoader;
}
public final Server getServer() {
return server;
}
public static IPTracker<String> getWildernessIPTracker() {
return wildernessIPTracker;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment