inline a few getObjects for greg

This commit is contained in:
Player Name 2026-07-27 16:35:54 +02:00
parent 8316d934e9
commit e85d81157f
6 changed files with 14 additions and 39 deletions

View file

@ -367,7 +367,7 @@ class TearsOfGuthixGlobalTick : TickListener {
*/
wallStates.forEachIndexed { index, state ->
val wallLocation = allWalls[index + 1]
val currentWaterfall = RegionManager.getObject(wallLocation, 4)!!
val currentWaterfall = RegionManager.getObject(wallLocation.z, wallLocation.x, wallLocation.y, -1, 4)!!
val newWaterfallId = when (state) {
2 -> {
if (index + 1 <= 5) Scenery.GREEN_TEARS_6662 else Scenery.GREEN_TEARS_6666

View file

@ -1081,7 +1081,7 @@ fun findNPC(id: Int): NPC? {
* @param type the scenery type, -1 if any
*/
fun getScenery(x: Int, y: Int, z: Int, type: Int = -1): Scenery? {
return RegionManager.getObject(z, x, y, type)
return RegionManager.getObject(z, x, y, type, -1)
}
/**

View file

@ -1,6 +1,5 @@
package core.game.global.action;
import content.data.Quests;
import core.game.node.entity.Entity;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.diary.DiaryType;
@ -491,6 +490,10 @@ public final class DoorActionHandler {
return null;
}
private static Scenery getAdjacentDoor(Location location, int type) {
return RegionManager.getObject(location.getZ(), location.getX(), location.getY(), -1, type);
}
/**
* Gets the door next to this door.
*
@ -500,16 +503,16 @@ public final class DoorActionHandler {
public static Scenery getSecondDoor(Scenery object, Entity entity) {
Location l = object.getLocation();
Scenery o = null;
if ((o = RegionManager.getObject(l.transform(-1, 0, 0), object.getType())) != null && o.getName().equals(object.getName())) {
if ((o = getAdjacentDoor(l.transform(-1, 0, 0), object.getType())) != null && o.getName().equals(object.getName())) {
return o;
}
if ((o = RegionManager.getObject(l.transform(1, 0, 0), object.getType())) != null && o.getName().equals(object.getName())) {
if ((o = getAdjacentDoor(l.transform(1, 0, 0), object.getType())) != null && o.getName().equals(object.getName())) {
return o;
}
if ((o = RegionManager.getObject(l.transform(0, -1, 0), object.getType())) != null && o.getName().equals(object.getName())) {
if ((o = getAdjacentDoor(l.transform(0, -1, 0), object.getType())) != null && o.getName().equals(object.getName())) {
return o;
}
if ((o = RegionManager.getObject(l.transform(0, 1, 0), object.getType())) != null && o.getName().equals(object.getName())) {
if ((o = getAdjacentDoor(l.transform(0, 1, 0), object.getType())) != null && o.getName().equals(object.getName())) {
return o;
}
return null;

View file

@ -303,17 +303,6 @@ object RegionManager {
return getObject(l.z, l.x, l.y)
}
/**
* Gets the scenery on the current location of the same type as a different piece of scenery.
* @param l The location.
* @param type The scenery type.
* @return The scenery, or `null` if no object was found.
*/
@JvmStatic
fun getObject(l: Location, type: Int): Scenery? {
return getObject(l.z, l.x, l.y, -1, type)
}
/**
* Gets the scenery on the current absolute coordinates.
* @param z The height.
@ -323,20 +312,7 @@ object RegionManager {
*/
@JvmStatic
fun getObject(z: Int, x: Int, y: Int): Scenery? {
return getObject(z, x, y, -1)
}
/**
* Gets the object on the given absolute coordinates.
* @param z The height.
* @param x The x-coordinate.
* @param y The y-coordinate.
* @param objectId The object id.
* @return The scenery, or `null` if no object was found.
*/
@JvmStatic
fun getObject(z: Int, x: Int, y: Int, objectId: Int): Scenery? {
return getObject(z, x, y, objectId, -1)
return getObject(z, x, y, -1, -1)
}
/**

View file

@ -579,7 +579,7 @@ object PacketProcessor {
}
else if (pkt is Packet.UseWithScenery) {
item = pkt.player.inventory[pkt.slot] ?: return sendClearMinimap(pkt.player)
node = RegionManager.getObject(pkt.player.location.z, pkt.x, pkt.y, pkt.sceneryId) ?: return sendClearMinimap(pkt.player)
node = RegionManager.getObject(pkt.player.location.z, pkt.x, pkt.y, pkt.sceneryId, -1) ?: return sendClearMinimap(pkt.player)
childNode = node.asScenery().getChild(pkt.player)
itemId = pkt.itemId
nodeId = node.id
@ -680,7 +680,7 @@ object PacketProcessor {
private fun processSceneryAction(pkt: Packet.SceneryAction) {
val player = pkt.player
var scenery = RegionManager.getObject(player.location.z, pkt.x, pkt.y, pkt.id)
var scenery = RegionManager.getObject(player.location.z, pkt.x, pkt.y, pkt.id, -1)
var objId = pkt.id
//what follows is a series of hardcoded crimes against humanity

View file

@ -16,12 +16,8 @@ import core.game.node.entity.impl.PulseType
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.world.GameWorld
import core.game.world.map.Region
import core.net.packet.PacketProcessor
import core.plugin.ClassScanner
import core.plugin.Plugin
import core.tools.Log
import org.rs09.consts.NPCs
class PathfinderTests {
companion object {init {TestUtils.preTestSetup(); GatheringSkillOptionListeners().defineListeners(); WoodcuttingListener().defineListeners() }; val NPC_TEST_LOC = ServerConstants.HOME_LOCATION!!.transform(2, 10, 0)}
@ -49,7 +45,7 @@ class PathfinderTests {
@Test fun movementPulseShouldStopEarlyIfNextToATileOccupiedByTargetObject() {
val start = Location.create(2731, 3481)
val dest = RegionManager.getObject(0, 2720, 3475, 1307)
val dest = RegionManager.getObject(0, 2720, 3475, 1307, -1)
val p = TestUtils.getMockPlayer("treefindtest")
p.location = start
p.init()