From 677ecd8dd51bc4c2f27ba787298c1d542a58c8f8 Mon Sep 17 00:00:00 2001 From: Mazo Date: Wed, 20 Jan 2021 18:59:29 +0000 Subject: [PATCH] Restore `/warp -list` functionality --- .../net/psforever/actors/session/ChatActor.scala | 16 +++++++++++----- .../net/psforever/util/PointOfInterest.scala | 13 +++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/scala/net/psforever/actors/session/ChatActor.scala b/src/main/scala/net/psforever/actors/session/ChatActor.scala index 8afe468e9..b57771264 100644 --- a/src/main/scala/net/psforever/actors/session/ChatActor.scala +++ b/src/main/scala/net/psforever/actors/session/ChatActor.scala @@ -673,11 +673,11 @@ class ChatActor( case (CMT_WARP, _, contents) if gmCommandAllowed => val buffer = contents.toLowerCase.split("\\s+") val (coordinates, waypoint) = (buffer.lift(0), buffer.lift(1), buffer.lift(2)) match { - case (Some(x), Some(y), Some(z)) => (Some(x, y, z), None) - case (Some("to"), Some(character), None) => (None, None) // TODO not implemented - case (Some("near"), Some(objectName), None) => (None, None) // TODO not implemented - case (Some(waypoint), None, None) => (None, Some(waypoint)) - case _ => (None, None) + case (Some(x), Some(y), Some(z)) => (Some(x, y, z), None) + case (Some("to"), Some(character), None) => (None, None) // TODO not implemented + case (Some("near"), Some(objectName), None) => (None, None) // TODO not implemented + case (Some(waypoint), None, None) if waypoint.nonEmpty => (None, Some(waypoint)) + case _ => (None, None) } (coordinates, waypoint) match { case (Some((x, y, z)), None) if List(x, y, z).forall { str => @@ -685,6 +685,12 @@ class ChatActor( coordinate.isDefined && coordinate.get >= 0 && coordinate.get <= 8191 } => sessionActor ! SessionActor.SetPosition(Vector3(x.toFloat, y.toFloat, z.toFloat)) + case (None, Some(waypoint)) if waypoint == "-list" => + val zone = PointOfInterest.get(session.player.Zone.id) + zone match { + case Some(zone: PointOfInterest) => sessionActor ! SessionActor.SendResponse(ChatMsg(UNK_229, true, "", PointOfInterest.listAll(zone), None)) + case _ => ChatMsg(UNK_229, true, "", s"unknown player zone '${session.player.Zone.id}'", None) + } case (None, Some(waypoint)) if waypoint != "-help" => PointOfInterest.getWarpLocation(session.zone.id, waypoint) match { case Some(location) => sessionActor ! SessionActor.SetPosition(location) diff --git a/src/main/scala/net/psforever/util/PointOfInterest.scala b/src/main/scala/net/psforever/util/PointOfInterest.scala index e6e708661..87467a3ce 100644 --- a/src/main/scala/net/psforever/util/PointOfInterest.scala +++ b/src/main/scala/net/psforever/util/PointOfInterest.scala @@ -187,7 +187,7 @@ object PointOfInterest { * @return all of the location keys */ def listLocations(zone: PointOfInterest): String = { - var out: String = "warps: " + var out: String = "Locations: " if (zone.locations.nonEmpty) { out += zone.locations.keys.toArray.sorted.mkString(", ") } else @@ -201,7 +201,7 @@ object PointOfInterest { * @return all of the warpgate keys */ def listWarpgates(zone: PointOfInterest): String = { - var out: String = "gatenames: " + var out: String = "Gates: " if (zone.gates.isEmpty) out += "none" else @@ -209,6 +209,15 @@ object PointOfInterest { out } + /** + * Get the name for all of the warpgates and locations that can be visited in this `CSRZone`. + * @param zone the `CSRZone` + * @return all of the warpgate and location keys + */ + def listAll(zone: PointOfInterest): String = { + s"${listWarpgates(zone)} ${listLocations(zone)}" + } + /** * Select, of all the `CSRZone` locations and warpgates, a pseudorandom destination to spawn the player in the zone if none has been specified. * @param zone the `CSRZone`