player update handled in new thread
This commit is contained in:
@@ -68,7 +68,7 @@ public enum MovementManager {
|
||||
|
||||
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
if (((PlayerCharacter) toMove).isCasting())
|
||||
((PlayerCharacter) toMove).update();
|
||||
((PlayerCharacter) toMove).update(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public enum MovementManager {
|
||||
if (!toMove.isMoving())
|
||||
toMove.resetLastSetLocUpdate();
|
||||
else
|
||||
toMove.update();
|
||||
toMove.update(false);
|
||||
|
||||
// Update movement for the player
|
||||
|
||||
@@ -351,7 +351,7 @@ public enum MovementManager {
|
||||
ChatManager.chatSystemInfo((PlayerCharacter) ac, "Finished Alt change, setting the end location to " + ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ() + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
|
||||
|
||||
//Send run/walk/sit/stand to tell the client we are flying / landing etc
|
||||
ac.update();
|
||||
ac.update(false);
|
||||
ac.stopMovement(ac.getLoc());
|
||||
if (ac.isAlive())
|
||||
MovementManager.sendRWSSMsg(ac);
|
||||
@@ -408,7 +408,7 @@ public enum MovementManager {
|
||||
if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None))
|
||||
continue;
|
||||
|
||||
member.update();
|
||||
member.update(false);
|
||||
|
||||
|
||||
// All checks passed, let's move the player
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
package engine.gameManager;
|
||||
|
||||
import com.sun.corba.se.spi.orbutil.fsm.ActionBase;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
@@ -28,7 +27,6 @@ import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.objects.*;
|
||||
import engine.powers.*;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
import engine.powers.poweractions.TrackPowerAction;
|
||||
import engine.server.MBServerStatics;
|
||||
@@ -179,7 +177,7 @@ public enum PowersManager {
|
||||
if (pc != null) {
|
||||
sendPowerMsg(pc, 2, msg);
|
||||
if (pc.isCasting()) {
|
||||
pc.update();
|
||||
pc.update(false);
|
||||
}
|
||||
|
||||
pc.setIsCasting(false);
|
||||
@@ -591,7 +589,7 @@ public enum PowersManager {
|
||||
|
||||
// make person casting stand up if spell (unless they're casting a chant which does not make them stand up)
|
||||
if (pb.isSpell() && !pb.isChant() && playerCharacter.isSit()) {
|
||||
playerCharacter.update();
|
||||
playerCharacter.update(false);
|
||||
playerCharacter.setSit(false);
|
||||
UpdateStateMsg updateStateMsg = new UpdateStateMsg(playerCharacter);
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
@@ -614,7 +612,7 @@ public enum PowersManager {
|
||||
|
||||
|
||||
if (time > 100) {
|
||||
playerCharacter.update();
|
||||
playerCharacter.update(false);
|
||||
playerCharacter.setIsCasting(true);
|
||||
}
|
||||
|
||||
@@ -792,7 +790,7 @@ public enum PowersManager {
|
||||
playerCharacter.removeEffectBySource(EffectSourceType.Root,40,true);
|
||||
}
|
||||
if (playerCharacter.isCasting()) {
|
||||
playerCharacter.update();
|
||||
playerCharacter.update(false);
|
||||
playerCharacter.updateStamRegen(-100);
|
||||
}
|
||||
|
||||
@@ -2318,7 +2316,7 @@ public enum PowersManager {
|
||||
|
||||
// set player is not casting for regens
|
||||
if (pc.isCasting()) {
|
||||
pc.update();
|
||||
pc.update(false);
|
||||
}
|
||||
pc.setIsCasting(false);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ public enum SimulationManager {
|
||||
|
||||
if (player == null)
|
||||
continue;
|
||||
player.update();
|
||||
player.update(false);
|
||||
}
|
||||
|
||||
_updatePulseTime = System.currentTimeMillis() + 500;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
pc.update();
|
||||
pc.update(false);
|
||||
if (msg.getSpeed() == 2)
|
||||
pc.setWalkMode(false);
|
||||
else
|
||||
@@ -114,7 +114,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
pc.update();
|
||||
pc.update(false);
|
||||
|
||||
pc.setSit(msg.toggleSitStand());
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
if (pc.getAltitude() == 0 && !msg.up())
|
||||
return true;
|
||||
|
||||
pc.update();
|
||||
pc.update(false);
|
||||
pc.stopMovement(pc.getLoc());
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
if (msg.up()) {
|
||||
@@ -135,7 +135,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
if (msg.up()) {
|
||||
pc.update();
|
||||
pc.update(false);
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
} else {
|
||||
@@ -161,7 +161,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
} else
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
|
||||
pc.update();
|
||||
pc.update(false);
|
||||
|
||||
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
|
||||
@@ -31,7 +31,6 @@ import engine.net.ByteBufferWriter;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.UpdateStateMsg;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -1841,7 +1840,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
//updates
|
||||
public void update() {
|
||||
public void update(Boolean newSystem) {
|
||||
}
|
||||
|
||||
public void updateRegen() {
|
||||
@@ -1861,16 +1860,16 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
try {
|
||||
switch (updateType) {
|
||||
case ALL:
|
||||
update();
|
||||
update(false);
|
||||
break;
|
||||
case REGEN:
|
||||
updateRegen();
|
||||
break;
|
||||
case LOCATION:
|
||||
update();
|
||||
update(false);
|
||||
break;
|
||||
case MOVEMENTSTATE:
|
||||
update();
|
||||
update(false);
|
||||
break;
|
||||
case FLIGHT:
|
||||
updateFlight();
|
||||
|
||||
@@ -270,7 +270,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
this.effects.remove(name);
|
||||
if (this.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
if (name.equals("Flight")) {
|
||||
((PlayerCharacter) this).update();
|
||||
((PlayerCharacter) this).update(false);
|
||||
PlayerCharacter.GroundPlayer((PlayerCharacter) this);
|
||||
}
|
||||
}
|
||||
@@ -385,7 +385,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
if (source.equals("Flight")) {
|
||||
//ground player
|
||||
if (this.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
((PlayerCharacter) this).update();
|
||||
((PlayerCharacter) this).update(false);
|
||||
PlayerCharacter.GroundPlayer((PlayerCharacter) this);
|
||||
}
|
||||
}
|
||||
@@ -414,7 +414,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
if (source.equals("Flight")) {
|
||||
//ground player
|
||||
if (this.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
((PlayerCharacter) this).update();
|
||||
((PlayerCharacter) this).update(false);
|
||||
PlayerCharacter.GroundPlayer((PlayerCharacter) this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import engine.job.JobScheduler;
|
||||
import engine.jobs.DeferredPowerJob;
|
||||
import engine.jobs.FinishSpireEffectJob;
|
||||
import engine.jobs.NoTimeJob;
|
||||
import engine.jobs.RefreshGroupJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.FastMath;
|
||||
import engine.math.Vector3fImmutable;
|
||||
@@ -2102,7 +2101,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
this.lastUpdateTime = System.currentTimeMillis();
|
||||
this.lastStamUpdateTime = System.currentTimeMillis();
|
||||
|
||||
this.update();
|
||||
this.update(false);
|
||||
|
||||
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, -1661758934, 40, false);
|
||||
|
||||
@@ -2923,7 +2922,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
public synchronized void grantXP(int xp) {
|
||||
if(this.promotionClass == null && this.level == 10){
|
||||
this.setOverFlowEXP(0);
|
||||
this.update();
|
||||
this.update(false);
|
||||
this.incVer();
|
||||
this.recalculate();
|
||||
this.calculateMaxHealthManaStamina();
|
||||
@@ -3084,7 +3083,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
}
|
||||
|
||||
if (charReloadRequired) {
|
||||
this.update();
|
||||
this.update(false);
|
||||
this.incVer();
|
||||
this.recalculate();
|
||||
this.calculateMaxHealthManaStamina();
|
||||
@@ -3157,7 +3156,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
bonus += this.bonuses.getFloatPercentNullZero(ModType.Speed, SourceType.None);
|
||||
|
||||
// TODO get equip bonus
|
||||
this.update();
|
||||
this.update(false);
|
||||
this.speedMod = bonus;
|
||||
}
|
||||
|
||||
@@ -4839,7 +4838,10 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update(Boolean newSystem) {
|
||||
|
||||
if(!newSystem)
|
||||
return;
|
||||
|
||||
if (this.updateLock.writeLock().tryLock()) {
|
||||
try {
|
||||
@@ -5547,7 +5549,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
@Override
|
||||
public final void setIsCasting(final boolean isCasting) {
|
||||
if (this.isCasting != isCasting)
|
||||
this.update();
|
||||
this.update(false);
|
||||
this.isCasting = isCasting;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AttributeEffectModifier extends AbstractEffectModifier {
|
||||
@Override
|
||||
public void applyBonus(AbstractCharacter ac, int trains) {
|
||||
|
||||
ac.update();
|
||||
ac.update(false);
|
||||
Float amount = 0f;
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
if (this.percentMod != 0f) { //Stat Percent Modifiers
|
||||
|
||||
@@ -29,7 +29,7 @@ public class HealthRecoverRateEffectModifier extends AbstractEffectModifier {
|
||||
@Override
|
||||
public void applyBonus(AbstractCharacter ac, int trains) {
|
||||
|
||||
ac.update();
|
||||
ac.update(false);
|
||||
Float amount = 0f;
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
if (this.useRampAdd)
|
||||
|
||||
@@ -39,7 +39,7 @@ public class NoModEffectModifier extends AbstractEffectModifier {
|
||||
PlayerCharacter flyer = (PlayerCharacter) ac;
|
||||
|
||||
if (flyer.getAltitude() > 0)
|
||||
flyer.update();
|
||||
flyer.update(false);
|
||||
PlayerCharacter.GroundPlayer(flyer);
|
||||
break;
|
||||
|
||||
|
||||
@@ -517,6 +517,9 @@ public class WorldServer {
|
||||
Logger.info("Starting Bane Thread");
|
||||
BaneThread.startBaneThread();
|
||||
|
||||
Logger.info("Starting Player Update Thread");
|
||||
UpdateThread.startUpdateThread();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.workthreads;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.gameManager.SimulationManager;
|
||||
import engine.objects.Bane;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public class UpdateThread implements Runnable {
|
||||
|
||||
public Long lastRun;
|
||||
public static int instancedelay = 1000;
|
||||
public UpdateThread() {
|
||||
Logger.info(" UpdateThread thread has started!");
|
||||
}
|
||||
|
||||
|
||||
public void processPlayerUpdate() {
|
||||
|
||||
try {
|
||||
for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){
|
||||
player.update(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error("UPDATE ERROR");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
lastRun = System.currentTimeMillis();
|
||||
while (true) {
|
||||
if (System.currentTimeMillis() >= lastRun + instancedelay) { // Correct condition
|
||||
this.processPlayerUpdate();
|
||||
lastRun = System.currentTimeMillis(); // Update lastRun after processing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void startUpdateThread() {
|
||||
Thread updateThread;
|
||||
updateThread = new Thread(new UpdateThread());
|
||||
updateThread.setName("updateThread");
|
||||
updateThread.start();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user