From 0c9343f24dd33592204c2bea3d54c62f75dc50fb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 5 Sep 2024 20:09:27 -0500 Subject: [PATCH] additional 60 second logout timer for players who have enemies nearby and aren't in safezone --- src/engine/net/client/ClientMessagePump.java | 1 + src/engine/server/world/WorldServer.java | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 73541de4..4a0b96a4 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -15,6 +15,7 @@ import engine.exception.MsgSendException; import engine.gameManager.*; import engine.job.JobContainer; import engine.job.JobScheduler; +import engine.jobs.LogoutCharacterJob; import engine.jobs.RefreshGroupJob; import engine.jobs.StuckJob; import engine.math.Vector3fImmutable; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 29182e4c..33422137 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -57,6 +57,7 @@ import java.nio.file.Paths; import java.time.Duration; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Timer; @@ -671,6 +672,22 @@ public class WorldServer { delta = 60000; } + + //get additional logout timer for enemies nearby + if(!playerCharacter.isInSafeZone()){ + HashSet playersClose = WorldGrid.getObjectsInRangePartial(playerCharacter.loc,MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER); + boolean enemiesClose = false; + for(AbstractWorldObject awo : playersClose){ + PlayerCharacter pc = (PlayerCharacter)awo; + if(!pc.guild.getNation().equals(playerCharacter.guild.getNation())) + enemiesClose = true; + } + if(enemiesClose){ + delta += 60000; + } + } + + playerCharacter.stopMovement(playerCharacter.getLoc()); UpdateStateMsg updateStateMsg = new UpdateStateMsg(); updateStateMsg.setPlayer(playerCharacter); @@ -688,8 +705,7 @@ public class WorldServer { playerCharacter.getLoadedStaticObjects().clear(); LogoutCharacterJob logoutJob = new LogoutCharacterJob(playerCharacter, this); - JobContainer jc = JobScheduler.getInstance().scheduleJob(logoutJob, - System.currentTimeMillis() + delta); + JobContainer jc = JobScheduler.getInstance().scheduleJob(logoutJob, System.currentTimeMillis() + delta); playerCharacter.getTimers().put("Logout", jc); playerCharacter.getTimestamps().put("logout", System.currentTimeMillis());