Greatly improved server performance by limiting the max wander radius return-to-spawn behavior applies to, and ensuring only one return-to-spawn movement pulse triggers at a time

This commit is contained in:
Ceikry 2023-08-06 12:30:13 +00:00 committed by Ryan
parent 6cf0e03177
commit 16a7640e56
2 changed files with 12 additions and 2 deletions

View file

@ -447,10 +447,14 @@ public class NPC extends Entity {
if ( if (
!pathBoundMovement !pathBoundMovement
&& walkRadius > 0 && walkRadius > 0
&& walkRadius <= 20
&& !getLocation().withinDistance(getProperties().getSpawnLocation(), (int)(walkRadius * 1.5)) && !getLocation().withinDistance(getProperties().getSpawnLocation(), (int)(walkRadius * 1.5))
&& !getAttribute("no-spawn-return", false) && !getAttribute("no-spawn-return", false)
) )
{ {
MovementPulse current = getAttribute("return-to-spawn-pulse");
if (current != null && current.isRunning()) return;
if(!isNeverWalks()){ if(!isNeverWalks()){
if(walkRadius == 0) if(walkRadius == 0)
walkRadius = 3; walkRadius = 3;

View file

@ -9,8 +9,14 @@ import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class APITests { class APITests {
val testPlayer = TestUtils.getMockPlayer("test") var testPlayer: MockPlayer
val testPlayer2 = TestUtils.getMockPlayer("test2") var testPlayer2: MockPlayer
init {
TestUtils.preTestSetup()
testPlayer = TestUtils.getMockPlayer("test")
testPlayer2 = TestUtils.getMockPlayer("test2")
}
@Test fun testIfaceSettings(){ @Test fun testIfaceSettings(){
var builder = IfaceSettingsBuilder() var builder = IfaceSettingsBuilder()