Browse Source

HotZone availability reset at 01am.

master
MagicBot 2 years ago
parent
commit
176fdb51da
  1. 3
      src/engine/devcmd/cmds/HotzoneCmd.java
  2. 28
      src/engine/gameManager/ZoneManager.java
  3. 1
      src/engine/objects/Zone.java
  4. 7
      src/engine/workthreads/HourlyJobThread.java

3
src/engine/devcmd/cmds/HotzoneCmd.java

@ -54,8 +54,7 @@ public class HotzoneCmd extends AbstractDevCmd { @@ -54,8 +54,7 @@ public class HotzoneCmd extends AbstractDevCmd {
}
if (input.equalsIgnoreCase("reset"))
for (Zone zone: ZoneManager.getAllZones())
zone.hasBeenHotzone = false;
ZoneManager.resetHotZones();
return;
}

28
src/engine/gameManager/ZoneManager.java

@ -44,9 +44,10 @@ public enum ZoneManager { @@ -44,9 +44,10 @@ public enum ZoneManager {
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
private static final ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
private static final ConcurrentHashMap<String, Zone> zonesByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
private static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
private static final Set<Zone> npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
private static final Set<Zone> playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
// Find all zones coordinates fit into, starting with Sea Floor
public static ArrayList<Zone> getAllZonesIn(final Vector3fImmutable loc) {
@ -108,6 +109,30 @@ public enum ZoneManager { @@ -108,6 +109,30 @@ public enum ZoneManager {
}
// Returns the number of available hotZones
// remaining in this cycle (1am)
public static int availableHotZones() {
int count = 0;
for (Zone zone : ZoneManager.macroZones)
if (zone.hasBeenHotzone)
count = count + 1;
return count;
}
// Resets the availability of hotZones
// for this cycle
public static void resetHotZones() {
for (Zone zone : ZoneManager.macroZones)
if (zone.hasBeenHotzone)
zone.hasBeenHotzone = false;
}
public static Zone getZoneByUUID(final int zoneUUID) {
return ZoneManager.zonesByUUID.get(zoneUUID);
}
@ -129,7 +154,6 @@ public enum ZoneManager { @@ -129,7 +154,6 @@ public enum ZoneManager {
ZoneManager.hotZone = zone;
ZoneManager.hotZoneCycle = 1; // Used with HOTZONE_DURATION from config.
zone.hasBeenHotzone = true;
zone.becameHotzone = LocalDateTime.now();
WorldServer.hotZoneLastUpdate = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant();
}

1
src/engine/objects/Zone.java

@ -61,7 +61,6 @@ public class Zone extends AbstractGameObject { @@ -61,7 +61,6 @@ public class Zone extends AbstractGameObject {
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public boolean hasBeenHotzone = false;
public LocalDateTime becameHotzone = null;
/**
* ResultSet Constructor
*/

7
src/engine/workthreads/HourlyJobThread.java

@ -191,6 +191,13 @@ public class HourlyJobThread implements Runnable { @@ -191,6 +191,13 @@ public class HourlyJobThread implements Runnable {
try {
// Reset zone availability at 1am
// or if we run out of hotZones
if (LocalDateTime.now().getHour() == 01 ||
ZoneManager.availableHotZones() == 0)
ZoneManager.resetHotZones();
// Use the same hotZone this hour up and until
// the HotZone_Duration from the ConfigManager

Loading…
Cancel
Save