From f243293e8c046445fa62c0361925ede977c845f4 Mon Sep 17 00:00:00 2001 From: Skal Fate <13443576-SkalFate@users.noreply.gitlab.com> Date: Thu, 16 Feb 2023 22:16:46 +0000 Subject: [PATCH] Fixed construction issue relating to incorrect isloaded checks causing null scenery Fixed construction issue relating to houseregionid getting registered for dunegon id Fixed construction issue relating to teleports in houses --- .../skill/construction/HouseManager.java | 9 +- .../global/skill/construction/HouseZone.java | 2 +- Server/src/test/kotlin/HouseManagerTests.kt | 126 ------------------ 3 files changed, 7 insertions(+), 130 deletions(-) delete mode 100644 Server/src/test/kotlin/HouseManagerTests.kt diff --git a/Server/src/main/content/global/skill/construction/HouseManager.java b/Server/src/main/content/global/skill/construction/HouseManager.java index 4b1f7b632..081e3f0d0 100644 --- a/Server/src/main/content/global/skill/construction/HouseManager.java +++ b/Server/src/main/content/global/skill/construction/HouseManager.java @@ -225,7 +225,7 @@ public final class HouseManager { public boolean pulse() { spawnServant(); if (servant.isGreet()){ - player.getDialogueInterpreter().sendDialogues(servant.getType().getId(), servant.getType().getId() == 4243 ? FacialExpression.HALF_GUILTY : null, "Welcome."); + player.getDialogueInterpreter().sendDialogues(servant.getType().getId(), servant.getType().getId() == 4243 ? FacialExpression.HAPPY : null, "Welcome."); } return true; } @@ -252,7 +252,7 @@ public final class HouseManager { } if (house.isInHouse(player)) { player.animate(Animation.RESET); - player.setLocation(house.location.getExitLocation()); + player.getProperties().setTeleportLocation(house.location.getExitLocation()); } } @@ -743,8 +743,11 @@ public final class HouseManager { * Checks if the house region was constructed and active. * @return {@code True} if an active region for the house exists. */ + //public boolean isLoaded() { + // return (houseRegion != null) || (dungeonRegion != null); + //} public boolean isLoaded() { - return (houseRegion != null) || (dungeonRegion != null); + return (houseRegion != null && houseRegion.isActive()) || (dungeonRegion != null && dungeonRegion.isActive()); } /** diff --git a/Server/src/main/content/global/skill/construction/HouseZone.java b/Server/src/main/content/global/skill/construction/HouseZone.java index a095b7d7b..f3f894b8c 100644 --- a/Server/src/main/content/global/skill/construction/HouseZone.java +++ b/Server/src/main/content/global/skill/construction/HouseZone.java @@ -46,7 +46,7 @@ public final class HouseZone extends MapZone { } registerRegion(house.getHouseRegion().getId()); if (house.getDungeonRegion() != null) { - registerRegion(house.getHouseRegion().getId()); + registerRegion(house.getDungeonRegion().getId()); } } diff --git a/Server/src/test/kotlin/HouseManagerTests.kt b/Server/src/test/kotlin/HouseManagerTests.kt deleted file mode 100644 index ab6b24241..000000000 --- a/Server/src/test/kotlin/HouseManagerTests.kt +++ /dev/null @@ -1,126 +0,0 @@ -import core.game.node.entity.player.link.music.MusicEntry -import content.global.skill.construction.HouseLocation -import content.global.skill.construction.HouseManager -import content.global.skill.construction.Servant -import content.global.skill.construction.ServantType -import core.game.world.map.RegionManager -import core.game.world.map.path.Pathfinder -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -class HouseManagerTests { - companion object { - init {TestUtils.preTestSetup()} - } - - val manager = HouseManager() - val testPlayer = TestUtils.getMockPlayer("test") - - @Test fun constructShouldLoadTheConstructedRegion() { - val newManager = HouseManager() - newManager.createNewHouseAt(HouseLocation.RIMMINGTON) //add a room to it, already tested below - newManager.construct() - Assertions.assertNotEquals(0, newManager.houseRegion.planes[0].getRegionChunk(4, 3).objects.size) - } - - @Test fun constructShouldRegisterNewRegionToRegionManager() { - val newManager = HouseManager() - newManager.construct() - Assertions.assertEquals(true, RegionManager.forId(newManager.houseRegion.id) == newManager.houseRegion) - } - - @Test fun constructShouldSetTheRegionInTheHouseManager() { - val newManager = HouseManager() - newManager.construct() - Assertions.assertNotEquals(null, newManager.houseRegion) - } - - @Test fun constructShouldSetTheRegionBorders() { - val newManager = HouseManager() - newManager.construct() - Assertions.assertNotEquals(null, newManager.houseRegion.borders) - } - - @Test fun constructShouldSetUpdateAllPlanes() { - val newManager = HouseManager() - newManager.construct() - Assertions.assertEquals(true, newManager.houseRegion.isUpdateAllPlanes) - } - - @Test fun constructShouldReplacePlanes1And2UnusedChunksAndAllPlane3ChunksWithEmptyChunks() { - val newManager = HouseManager() - newManager.construct() - for(z in 1..3) - for (objs in newManager.houseRegion.planes[z].objects) - for (obj in objs) Assertions.assertEquals(null, obj) - } - - @Test fun leaveShouldPlaceThePlayerAtTheHouseLocationExitLocation() { - val newManager = HouseManager() - val newPlayer = TestUtils.getMockPlayer("test3") - newManager.construct() - newManager.enter(newPlayer, false) - TestUtils.advanceTicks(5) - HouseManager.leave(newPlayer) - Assertions.assertEquals(newManager.location.exitLocation, newPlayer.location) - } - - @Test fun toggleBuildingModeShouldChangeBuildingMode() { - val newManager = HouseManager() - val newPlayer = TestUtils.getMockPlayer("test4") - newManager.enter(newPlayer, false) - TestUtils.advanceTicks(5) - newManager.toggleBuildingMode(newPlayer, true) - Assertions.assertEquals(true, newManager.isBuildingMode) - } - - @Test fun createShouldPlaceGardenInRooms() { - manager.createNewHouseAt(HouseLocation.RIMMINGTON) - Assertions.assertEquals(true, manager.hasRoomAt(0, 4, 3)) - } - - @Test fun enterShouldConstructDynamicRegionIfItHasNotBeenConstructed() { - manager.enter(testPlayer, false) - Assertions.assertEquals(true, manager.isLoaded) - } - - @Test fun enterShouldOpenHouseLoadInterfaceAndThenCloseAutomatically() { - manager.enter(testPlayer, false) - Assertions.assertEquals(399, testPlayer.interfaceManager.opened.id) - TestUtils.advanceTicks(5) - Assertions.assertNotEquals(null, testPlayer.interfaceManager.opened) - } - - @Test fun enterShouldSendServantIfHasOne() { - manager.servant = Servant(ServantType.BUTLER) - manager.enter(testPlayer, false) - TestUtils.advanceTicks(5) - Assertions.assertEquals(true, manager.servant.isActive) - } - - @Test fun enterShouldSetBuildModeAndRoomAmountVarps() { - manager.enter(testPlayer, false) - Assertions.assertEquals(true, testPlayer.varpManager.get(261).varbits.isNotEmpty()) - Assertions.assertEquals(true, testPlayer.varpManager.get(262).varbits.isNotEmpty()) - } - - @Test fun enterShouldUnlockPOHMusicTrack() { - manager.enter(testPlayer, false) - Assertions.assertEquals(true, testPlayer.musicPlayer.unlocked.contains(MusicEntry.forId(454).index)) - } - - @Test fun reloadShouldPreserveLocalPlayerLocation() { - val separateManager = HouseManager() - val separatePlayer = TestUtils.getMockPlayer("test2") - separateManager.enter(separatePlayer, false) - TestUtils.advanceTicks(5) - Pathfinder.find(separatePlayer, separatePlayer.location.transform(10,10,0)).walk(separatePlayer) - TestUtils.advanceTicks(20) - val localX = separatePlayer.location.localX - val localY = separatePlayer.location.localY - separateManager.reload(separatePlayer, true) - TestUtils.advanceTicks(20) - Assertions.assertEquals(localX, separatePlayer.location.localX) - Assertions.assertEquals(localY, separatePlayer.location.localY) - } -} \ No newline at end of file