|
|
|
@ -11,10 +11,7 @@ package engine.objects;
@@ -11,10 +11,7 @@ package engine.objects;
|
|
|
|
|
|
|
|
|
|
import engine.Enum; |
|
|
|
|
import engine.InterestManagement.WorldGrid; |
|
|
|
|
import engine.gameManager.BuildingManager; |
|
|
|
|
import engine.gameManager.ChatManager; |
|
|
|
|
import engine.gameManager.DbManager; |
|
|
|
|
import engine.gameManager.ZoneManager; |
|
|
|
|
import engine.gameManager.*; |
|
|
|
|
import engine.net.ByteBufferWriter; |
|
|
|
|
import engine.net.client.msg.ErrorPopupMsg; |
|
|
|
|
import engine.server.MBServerStatics; |
|
|
|
@ -25,6 +22,8 @@ import java.sql.ResultSet;
@@ -25,6 +22,8 @@ import java.sql.ResultSet;
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
import static engine.gameManager.DbManager.MineQueries; |
|
|
|
@ -33,6 +32,7 @@ import static engine.math.FastMath.sqr;
@@ -33,6 +32,7 @@ import static engine.math.FastMath.sqr;
|
|
|
|
|
|
|
|
|
|
public class Mine extends AbstractGameObject { |
|
|
|
|
|
|
|
|
|
public final HashSet<Integer> _playerMemory = new HashSet<>(); |
|
|
|
|
public static ConcurrentHashMap<Mine, Integer> mineMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); |
|
|
|
|
public static ConcurrentHashMap<Integer, Mine> towerMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); |
|
|
|
|
private final String zoneName; |
|
|
|
@ -574,5 +574,67 @@ public class Mine extends AbstractGameObject {
@@ -574,5 +574,67 @@ public class Mine extends AbstractGameObject {
|
|
|
|
|
} |
|
|
|
|
return (int) totalModded; |
|
|
|
|
} |
|
|
|
|
public void onEnter() { |
|
|
|
|
|
|
|
|
|
HashSet<AbstractWorldObject> currentPlayers; |
|
|
|
|
HashSet<Integer> currentMemory; |
|
|
|
|
PlayerCharacter player; |
|
|
|
|
|
|
|
|
|
// Gather current list of players within the zone bounds
|
|
|
|
|
|
|
|
|
|
currentPlayers = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); |
|
|
|
|
currentMemory = new HashSet<>(); |
|
|
|
|
|
|
|
|
|
for (AbstractWorldObject playerObject : currentPlayers) { |
|
|
|
|
|
|
|
|
|
if (playerObject == null) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
player = (PlayerCharacter) playerObject; |
|
|
|
|
currentMemory.add(player.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
// Player is already in our memory
|
|
|
|
|
|
|
|
|
|
if (_playerMemory.contains(player.getObjectUUID())) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
// Add player to our city's memory
|
|
|
|
|
|
|
|
|
|
_playerMemory.add(player.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
// ***For debugging
|
|
|
|
|
// Logger.info("PlayerMemory for ", this.getCityName() + ": " + _playerMemory.size());
|
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
onExit(currentMemory); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.error(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
PowersManager.applyZergBuff(this); |
|
|
|
|
} |
|
|
|
|
private void onExit(HashSet<Integer> currentMemory) { |
|
|
|
|
|
|
|
|
|
PlayerCharacter player; |
|
|
|
|
int playerUUID = 0; |
|
|
|
|
HashSet<Integer> toRemove = new HashSet<>(); |
|
|
|
|
Iterator<Integer> iter = _playerMemory.iterator(); |
|
|
|
|
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc,Enum.CityBoundsType.ZONE.extents * 0.5f,MBServerStatics.MASK_PLAYER); |
|
|
|
|
while (iter.hasNext()) { |
|
|
|
|
|
|
|
|
|
playerUUID = iter.next(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player = PlayerCharacter.getFromCache(playerUUID); |
|
|
|
|
|
|
|
|
|
if (inRange.contains(player)) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
toRemove.add(playerUUID); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Remove players from mine memory
|
|
|
|
|
|
|
|
|
|
_playerMemory.removeAll(toRemove); |
|
|
|
|
PowersManager.removeZergBuff(toRemove); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|