Browse Source

hot fix for powers failure

lakebane
FatBoy-DOTC 6 days ago
parent
commit
1132f88b85
  1. 38
      src/engine/objects/PlayerCharacter.java
  2. 31
      src/engine/workthreads/UpdateThread.java

38
src/engine/objects/PlayerCharacter.java

@ -5122,24 +5122,6 @@ public class PlayerCharacter extends AbstractCharacter {
if (this.updateLock.writeLock().tryLock()) { if (this.updateLock.writeLock().tryLock()) {
try { try {
//if (!this.timestamps.contains("STAMHEALTICK")) {
// this.timestamps.put("STAMHEALTICK", System.currentTimeMillis());
//}
//if (this.containsEffect(441156455)) {
// long length = System.currentTimeMillis() - this.timestamps.get("STAMHEALTICK").longValue();
// if (length > 10000 ) {
// float stamIncrease = 6.5f;
// if (this.stamina.get() + stamIncrease > this.staminaMax)
// this.stamina.compareAndSet(this.stamina.get(), this.staminaMax);
// else
// this.stamina.compareAndSet(this.stamina.get(), this.stamina.get() + stamIncrease);
// this.timestamps.put("STAMHEALTICK", System.currentTimeMillis());
// ChatManager.chatSystemInfo(this, "Healed 7 Stamina");
// }
//} else {
// this.timestamps.put("STAMHEALTICK", System.currentTimeMillis());
//}
if (!this.isAlive() && this.isEnteredWorld()) { if (!this.isAlive() && this.isEnteredWorld()) {
if (!this.timestamps.containsKey("DeathTime")) { if (!this.timestamps.containsKey("DeathTime")) {
this.timestamps.put("DeathTime", System.currentTimeMillis()); this.timestamps.put("DeathTime", System.currentTimeMillis());
@ -5147,26 +5129,6 @@ public class PlayerCharacter extends AbstractCharacter {
forceRespawn(this); forceRespawn(this);
return; return;
} }
//if(!this.timestamps.containsKey("stamTick")){
// this.timestamps.put("stamTick", System.currentTimeMillis());
//}else{
// if(this.containsEffect(441156479) || this.containsEffect(441156455)) {
// if(System.currentTimeMillis() - this.timestamps.get("stamTick") > 5000){
// boolean worked = false;
// while(!worked) {
// float old = this.stamina.get();
// float mod = old + 4;
// if (mod > this.staminaMax)
// mod = this.staminaMax;
//
// worked = this.stamina.compareAndSet(old, mod);
// }
// this.timestamps.put("stamTick", System.currentTimeMillis());
// }
// }else{
// this.timestamps.put("stamTick", System.currentTimeMillis());
// }
//}
if (this.isAlive() && this.isActive && this.enteredWorld) { if (this.isAlive() && this.isActive && this.enteredWorld) {

31
src/engine/workthreads/UpdateThread.java

@ -32,7 +32,11 @@ public class UpdateThread implements Runnable {
try { try {
for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){ for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){
if (player != null) { if (player != null) {
try {
player.update(true); player.update(true);
}catch(Exception e){
Logger.error("UPDATE ERROR FOR PLAYER: " + player.getFirstName(),e);
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -43,21 +47,32 @@ public class UpdateThread implements Runnable {
} }
public void run() { public void run() {
lastRun = System.currentTimeMillis(); //lastRun = System.currentTimeMillis();
//while (true) {
// if (System.currentTimeMillis() >= lastRun + instancedelay) { // Correct condition
// this.processPlayerUpdate();
// lastRun = System.currentTimeMillis(); // Update lastRun after processing
// }else {
// try {
// Thread.sleep(100); // Pause for 100ms to reduce CPU usage
// } catch (InterruptedException e) {
// Logger.error("Thread interrupted", e);
// Thread.currentThread().interrupt();
// }
// }
// Thread.yield();
//}
while (true) { while (true) {
if (System.currentTimeMillis() >= lastRun + instancedelay) { // Correct condition
this.processPlayerUpdate();
lastRun = System.currentTimeMillis(); // Update lastRun after processing
}else {
try { try {
Thread.sleep(100); // Pause for 100ms to reduce CPU usage this.processPlayerUpdate(); // Execute update logic
Thread.sleep(250); // Always sleep for 250ms
} catch (InterruptedException e) { } catch (InterruptedException e) {
Logger.error("Thread interrupted", e); Logger.error("Thread interrupted", e);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
break; // Exit loop if interrupted
} }
} }
Thread.yield();
}
} }

Loading…
Cancel
Save