Browse Source

revert boxing enforcement

lakebane-new
FatBoy-DOTC 5 months ago
parent
commit
f51c28e708
  1. 68
      src/engine/gameManager/MultiboxManager.java
  2. 3
      src/engine/net/client/handlers/RequestEnterWorldHandler.java
  3. 3
      src/engine/server/world/WorldServer.java

68
src/engine/gameManager/MultiboxManager.java

@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
package engine.gameManager;
import engine.objects.PlayerCharacter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class MultiboxManager {
public static HashMap<String, ArrayList<PlayerCharacter>> activeCharacters = new HashMap<>();
public static ReentrantReadWriteLock updateLock = new ReentrantReadWriteLock();
public static void addPlayer(PlayerCharacter player){
updateLock.writeLock().lock();
try {
//get the machine ID for the key of the map
String machineID = player.getClientConnection().machineID;
//cleanup and remove inactive players from the list
ArrayList<PlayerCharacter> purgeList = new ArrayList<>();
for(PlayerCharacter pc : activeCharacters.get(machineID))
if(!pc.isEnteredWorld() || !pc.isActive())
purgeList.add(pc);
activeCharacters.get(machineID).removeAll(purgeList);
//remove empty key
if(activeCharacters.get(machineID).size() < 1)
activeCharacters.remove(machineID);
if(activeCharacters.containsKey(machineID)){
//already has an entry for this machine ID
player.isBoxed = true;
activeCharacters.get(machineID).add(player);
}else{
//does not have an entry for this machine ID
player.isBoxed = false;
ArrayList<PlayerCharacter> newList = new ArrayList<>();
newList.add(player);
activeCharacters.put(machineID,newList);
}
} finally {
updateLock.writeLock().unlock();
}
}
public static void removePlayer(PlayerCharacter player){
//get the machine ID for the key of the map
String machineID = player.getClientConnection().machineID;
if(activeCharacters.containsKey(machineID)){
//remove player from existing list
activeCharacters.get(machineID).remove(player);
//check if there are still players in the machine ID key list
if(activeCharacters.get(machineID).size() > 1){
//list still has characters, make one of them active
activeCharacters.get(machineID).get(0).isBoxed = false;
}else{
//list is now empty, remove it from the map
activeCharacters.remove(machineID);
}
}
}
}

3
src/engine/net/client/handlers/RequestEnterWorldHandler.java

@ -8,7 +8,6 @@ import engine.db.archive.CharacterRecord; @@ -8,7 +8,6 @@ import engine.db.archive.CharacterRecord;
import engine.db.archive.DataWarehouse;
import engine.db.archive.PvpRecord;
import engine.exception.MsgSendException;
import engine.gameManager.MultiboxManager;
import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.net.Dispatch;
@ -158,8 +157,6 @@ public class RequestEnterWorldHandler extends AbstractClientMsgHandler { @@ -158,8 +157,6 @@ public class RequestEnterWorldHandler extends AbstractClientMsgHandler {
dispatch = Dispatch.borrow(player, sopm);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
MultiboxManager.addPlayer(player);
return true;
}

3
src/engine/server/world/WorldServer.java

@ -656,7 +656,6 @@ public class WorldServer { @@ -656,7 +656,6 @@ public class WorldServer {
// TODO log this
return;
MultiboxManager.removePlayer(playerCharacter);
//cancel any trade
if (playerCharacter.getCharItemManager() != null)
playerCharacter.getCharItemManager().endTrade(true);
@ -706,8 +705,6 @@ public class WorldServer { @@ -706,8 +705,6 @@ public class WorldServer {
Logger.error("Unable to find PlayerCharacter to logout");
return;
}
MultiboxManager.removePlayer(player);
//remove player from loaded mobs agro maps
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) {
Mob loadedMob = (Mob) awo;

Loading…
Cancel
Save