diff --git a/.codecov.yml b/.codecov.yml
index 0f310ab54..2ce4e5825 100644
--- a/.codecov.yml
+++ b/.codecov.yml
@@ -2,60 +2,60 @@
comment: off
ignore:
- - "common/src/main/scala/net/psforever/objects/ObjectType.scala"
- - "common/src/main/scala/net/psforever/objects/avatar/Avatars.scala"
- - "common/src/main/scala/net/psforever/objects/ballistics/ProjectileResolution.scala"
- - "common/src/main/scala/net/psforever/objects/ballistics/Projectiles.scala"
- - "common/src/main/scala/net/psforever/objects/equipment/Ammo.scala"
- - "common/src/main/scala/net/psforever/objects/equipment/CItem.scala"
- - "common/src/main/scala/net/psforever/objects/equipment/EquipmentSize.scala"
- - "common/src/main/scala/net/psforever/objects/equipment/Kits.scala"
- - "common/src/main/scala/net/psforever/objects/equipment/SItem.scala"
- - "common/src/main/scala/net/psforever/objects/guid/AvailabilityPolicy.scala"
- - "common/src/main/scala/net/psforever/objects/serverobject/pad/AutoDriveControls.scala"
- - "common/src/main/scala/net/psforever/objects/serverobject/structures/StructureType.scala"
- - "common/src/main/scala/net/psforever/objects/serverobject/turret/TurretUpgrade.scala"
- - "common/src/main/scala/net/psforever/objects/serverobject/CommonMessages.scala"
- - "common/src/main/scala/net/psforever/objects/vehicles/AccessPermissionGroup.scala"
- - "common/src/main/scala/net/psforever/objects/vehicles/CargoVehicleRestiction.scala"
- - "common/src/main/scala/net/psforever/objects/vehicles/DestroyedVehicle.scala"
- - "common/src/main/scala/net/psforever/objects/vehicles/SeatArmoRestriction.scala"
- - "common/src/main/scala/net/psforever/objects/vehicles/Turrets.scala"
- - "common/src/main/scala/net/psforever/objects/vehicles/VehicleLockState.scala"
- - "common/src/main/scala/net/psforever/objects/vital/damage/DamageProfile.scala"
- - "common/src/main/scala/net/psforever/objects/vital/projectile/ProjectileCalculations.scala"
- - "common/src/main/scala/net/psforever/objects/vital/resistance/ResistanceProfile.scala"
- - "common/src/main/scala/net/psforever/objects/vital/DamageResistanceModel.scala"
- - "common/src/main/scala/net/psforever/objects/vital/DamageType.scala"
- - "common/src/main/scala/net/psforever/objects/vital/StandardDamages.scala"
- - "common/src/main/scala/net/psforever/objects/vital/StandardResistanceProfile.scala"
- - "common/src/main/scala/net/psforever/objects/vital/StandardResistances.scala"
- - "common/src/main/scala/net/psforever/objects/vital/StandardResolutions.scala"
- - "common/src/main/scala/net/psforever/packet/crypto"
- - "common/src/main/scala/net/psforever/packet/game/objectcreate/DrawnSlot.scala"
- - "common/src/main/scala/net/psforever/packet/game/objectcreate/DriveState.scala"
- - "common/src/main/scala/net/psforever/packet/game/objectcreate/MountItem.scala"
- - "common/src/main/scala/net/psforever/packet/game/objectcreate/ObjectClass.scala"
- - "common/src/main/scala/net/psforever/packet/game/objectcreate/Prefab.scala"
- - "common/src/main/scala/net/psforever/packet/ControlPacketOpcode.scala"
- - "common/src/main/scala/net/psforever/packet/CryptoPacketOpcode.scala"
- - "common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala"
- - "common/src/main/scala/net/psforever/types/Angular.scala"
- - "common/src/main/scala/net/psforever/types/CertificationType.scala"
- - "common/src/main/scala/net/psforever/types/ChatMessageType.scala"
- - "common/src/main/scala/net/psforever/types/DriveState.scala"
- - "common/src/main/scala/net/psforever/types/EmoteType.scala"
- - "common/src/main/scala/net/psforever/types/ExoSuitType.scala"
- - "common/src/main/scala/net/psforever/types/GrenadeState.scala"
- - "common/src/main/scala/net/psforever/types/ImplantType.scala"
- - "common/src/main/scala/net/psforever/types/MeritCommendation.scala"
- - "common/src/main/scala/net/psforever/types/PlanetSideEmpire.scala"
- - "common/src/main/scala/net/psforever/types/TransactionType.scala"
- - "common/src/main/scala/net.psforever.services/avatar/AvatarAction.scala"
- - "common/src/main/scala/net.psforever.services/avatar/AvatarResponse.scala"
- - "common/src/main/scala/net.psforever.services/galaxy/GalaxyAction.scala"
- - "common/src/main/scala/net.psforever.services/galaxy/GalaxyResponse.scala"
- - "common/src/main/scala/net.psforever.services/local/LocalAction.scala"
- - "common/src/main/scala/net.psforever.services/local/LocalResponse.scala"
- - "common/src/main/scala/net.psforever.services/vehicle/VehicleAction.scala"
- - "common/src/main/scala/net.psforever.services/vehicle/VehicleResponse.scala"
\ No newline at end of file
+ - "src/main/scala/net/psforever/objects/ObjectType.scala"
+ - "src/main/scala/net/psforever/objects/avatar/Avatars.scala"
+ - "src/main/scala/net/psforever/objects/ballistics/ProjectileResolution.scala"
+ - "src/main/scala/net/psforever/objects/ballistics/Projectiles.scala"
+ - "src/main/scala/net/psforever/objects/equipment/Ammo.scala"
+ - "src/main/scala/net/psforever/objects/equipment/CItem.scala"
+ - "src/main/scala/net/psforever/objects/equipment/EquipmentSize.scala"
+ - "src/main/scala/net/psforever/objects/equipment/Kits.scala"
+ - "src/main/scala/net/psforever/objects/equipment/SItem.scala"
+ - "src/main/scala/net/psforever/objects/guid/AvailabilityPolicy.scala"
+ - "src/main/scala/net/psforever/objects/serverobject/pad/AutoDriveControls.scala"
+ - "src/main/scala/net/psforever/objects/serverobject/structures/StructureType.scala"
+ - "src/main/scala/net/psforever/objects/serverobject/turret/TurretUpgrade.scala"
+ - "src/main/scala/net/psforever/objects/serverobject/CommonMessages.scala"
+ - "src/main/scala/net/psforever/objects/vehicles/AccessPermissionGroup.scala"
+ - "src/main/scala/net/psforever/objects/vehicles/CargoVehicleRestiction.scala"
+ - "src/main/scala/net/psforever/objects/vehicles/DestroyedVehicle.scala"
+ - "src/main/scala/net/psforever/objects/vehicles/SeatArmoRestriction.scala"
+ - "src/main/scala/net/psforever/objects/vehicles/Turrets.scala"
+ - "src/main/scala/net/psforever/objects/vehicles/VehicleLockState.scala"
+ - "src/main/scala/net/psforever/objects/vital/damage/DamageProfile.scala"
+ - "src/main/scala/net/psforever/objects/vital/projectile/ProjectileCalculations.scala"
+ - "src/main/scala/net/psforever/objects/vital/resistance/ResistanceProfile.scala"
+ - "src/main/scala/net/psforever/objects/vital/DamageResistanceModel.scala"
+ - "src/main/scala/net/psforever/objects/vital/DamageType.scala"
+ - "src/main/scala/net/psforever/objects/vital/StandardDamages.scala"
+ - "src/main/scala/net/psforever/objects/vital/StandardResistanceProfile.scala"
+ - "src/main/scala/net/psforever/objects/vital/StandardResistances.scala"
+ - "src/main/scala/net/psforever/objects/vital/StandardResolutions.scala"
+ - "src/main/scala/net/psforever/packet/crypto"
+ - "src/main/scala/net/psforever/packet/game/objectcreate/DrawnSlot.scala"
+ - "src/main/scala/net/psforever/packet/game/objectcreate/DriveState.scala"
+ - "src/main/scala/net/psforever/packet/game/objectcreate/MountItem.scala"
+ - "src/main/scala/net/psforever/packet/game/objectcreate/ObjectClass.scala"
+ - "src/main/scala/net/psforever/packet/game/objectcreate/Prefab.scala"
+ - "src/main/scala/net/psforever/packet/ControlPacketOpcode.scala"
+ - "src/main/scala/net/psforever/packet/CryptoPacketOpcode.scala"
+ - "src/main/scala/net/psforever/packet/GamePacketOpcode.scala"
+ - "src/main/scala/net/psforever/types/Angular.scala"
+ - "src/main/scala/net/psforever/types/CertificationType.scala"
+ - "src/main/scala/net/psforever/types/ChatMessageType.scala"
+ - "src/main/scala/net/psforever/types/DriveState.scala"
+ - "src/main/scala/net/psforever/types/EmoteType.scala"
+ - "src/main/scala/net/psforever/types/ExoSuitType.scala"
+ - "src/main/scala/net/psforever/types/GrenadeState.scala"
+ - "src/main/scala/net/psforever/types/ImplantType.scala"
+ - "src/main/scala/net/psforever/types/MeritCommendation.scala"
+ - "src/main/scala/net/psforever/types/PlanetSideEmpire.scala"
+ - "src/main/scala/net/psforever/types/TransactionType.scala"
+ - "src/main/scala/net/psforever/services/avatar/AvatarAction.scala"
+ - "src/main/scala/net/psforever/services/avatar/AvatarResponse.scala"
+ - "src/main/scala/net/psforever/services/galaxy/GalaxyAction.scala"
+ - "src/main/scala/net/psforever/services/galaxy/GalaxyResponse.scala"
+ - "src/main/scala/net/psforever/services/local/LocalAction.scala"
+ - "src/main/scala/net/psforever/services/local/LocalResponse.scala"
+ - "src/main/scala/net/psforever/services/vehicle/VehicleAction.scala"
+ - "src/main/scala/net/psforever/services/vehicle/VehicleResponse.scala"
\ No newline at end of file
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 9cad05cbb..ed8870f06 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -29,8 +29,6 @@ jobs:
uses: actions/checkout@v2
- name: Setup Scala
uses: olafurpg/setup-scala@v5
- - name: Install pscrypto
- run: curl -L https://github.com/psforever/PSCrypto/releases/download/v1.1/pscrypto-lib-1.1.zip | jar vx
- name: Run migrations
run: sbt "server/run migrate"
- name: Run build
diff --git a/.gitignore b/.gitignore
index bef6a5da0..4c334d583 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ out/
.metals
project/metals.sbt
/docs
+.vscode
# User configs
config/psforever.conf
diff --git a/Dockerfile b/Dockerfile
index ee08dfd34..3cfbec1b4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,9 +4,7 @@ COPY . /PSF-LoginServer
WORKDIR /PSF-LoginServer
-RUN wget https://github.com/psforever/PSCrypto/releases/download/v1.1/pscrypto-lib-1.1.zip && \
- unzip pscrypto-lib-1.1.zip && rm pscrypto-lib-1.1.zip && \
- sbt server/pack
+RUN sbt server/pack
FROM openjdk:8-slim
@@ -16,4 +14,4 @@ EXPOSE 51000
EXPOSE 51001
EXPOSE 51002
-CMD ["psf-server"]
+CMD ["psforever-server"]
diff --git a/README.md b/README.md
index 207863599..b77f67d7e 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,6 @@ instructions on downloading the game and using the PSForever launcher to start t
- sbt (Scala build tool)
- Java Development Kit (JDK) 8.0
-- PSCrypto v1.1 - binary DLL (Windows) or Shared Library (Linux) placed in the root directory of the project. See [Downloading PSCrypto](#downloading-pscrypto) to get it set up.
- PostgreSQL
## Setting up a Build Environment
@@ -80,19 +79,6 @@ DB](#setting-up-the-database)). Note: sbt is quite slow at starting up (JVM/JIT
open sbt console (just run `sbt` without any arguments) in order to avoid this startup time. With a sbt console you can
run tests (and you should) using `sbt test`.
-### Downloading PSCrypto
-**The server requires binary builds of PSCrypto in order to run.** [Download the latest
-*release](https://github.com/psforever/PSCrypto/releases/download/v1.1/pscrypto-lib-1.1.zip) and extract the the
-*approprate dll for your operating system. If you are not comfortable with compiled binaries, you can [build the
-*libraries yourself](https://github.com/psforever/PSCrypto).
-
-sbt, IDEA, and Java will automatically find the required libraries when running the server. The build expects to find
-the library in a subdirectory of the root directory called /pscrypto-lib/. Historically, we have recommended placing it
-directly into the root directory and that has worked as well. If you still have issues with PSCrypto being detected, try
-adding `-Djava.library.path=` (no path necessary) to your preferred IDE's build configuration with the library in the
-root directory. For example, with IDEA: Run -> Edit Configuration -> (select the configuration) -> Uncheck "Use sbt
-shell" -> VM Parameters
-
## Setting up the Database
The Login and World servers require PostgreSQL for persistence.
@@ -194,7 +180,7 @@ some helper scripts. Run the correct file for your platform (.BAT for Windows an
Using sbt, you can generate documentation all projects using `sbt docs/unidoc`.
-Current documentation is available at [https://jgillich.github.io/PSF-LoginServer/net/psforever/index.html](https://jgillich.github.io/PSF-LoginServer/net/psforever/index.html)
+Current documentation is available at [https://psforever.github.io/PSF-LoginServer/net/psforever/index.html](https://psforever.github.io/PSF-LoginServer/net/psforever/index.html)
## Tools
@@ -225,22 +211,6 @@ psf-decode-packets -o ./output-directory foo.gcap bar.gcap
By default, decodePackets takes in `.gcap` files, but it can also take gcapy ascii files with the
`-p` option. Run `psf-decode-packets --help` to get usage info.
-## Troubleshooting
-
-#### Unable to initialize pscrypto
-
-If you get an error like below
-
-```
-12:17:28.037 [main] ERROR PsLogin - Unable to initialize pscrypto
-java.lang.UnsatisfiedLinkError: Unable to load library 'pscrypto': Native library (win32-x86-64/pscrypto.dll) not found in resource path
-```
-
-Then you are missing the native library required to provide cryptographic functions to the login server. To fix this,
-you need a binary build of [PSCrypto](#downloading-pscrypto).
-
-If you are still having trouble on Linux, try putting the library in `root directory/pscrypto-lib/libpscrypto.so`.
-
## Contributing
Please fork the project and provide a pull request to contribute code. Coding guidelines and contribution checklists
diff --git a/build.sbt b/build.sbt
index ca250a0c8..a5d11a7ed 100644
--- a/build.sbt
+++ b/build.sbt
@@ -49,12 +49,11 @@ lazy val psforeverSettings = Seq(
"com.typesafe.akka" %% "akka-cluster-typed" % "2.6.9",
"com.typesafe.akka" %% "akka-coordination" % "2.6.9",
"com.typesafe.akka" %% "akka-cluster-tools" % "2.6.9",
+ "com.typesafe.akka" %% "akka-slf4j" % "2.6.9",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
"org.specs2" %% "specs2-core" % "4.10.3" % "test",
"org.scalatest" %% "scalatest" % "3.2.2" % "test",
"org.scodec" %% "scodec-core" % "1.11.7",
- "net.java.dev.jna" % "jna" % "5.6.0",
- "com.typesafe.akka" %% "akka-slf4j" % "2.6.9",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.log4s" %% "log4s" % "1.8.2",
"org.fusesource.jansi" % "jansi" % "1.18",
@@ -78,18 +77,13 @@ lazy val psforeverSettings = Seq(
"io.circe" %% "circe-core" % "0.13.0",
"io.circe" %% "circe-generic" % "0.13.0",
"io.circe" %% "circe-parser" % "0.13.0",
- "org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0"
+ "org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0",
+ "org.bouncycastle" % "bcprov-jdk15on" % "1.66"
),
// TODO(chord): remove exclusion when SessionActor is refactored: https://github.com/psforever/PSF-LoginServer/issues/279
coverageExcludedPackages := "net\\.psforever\\.actors\\.session\\.SessionActor.*"
)
-lazy val pscryptoSettings = Seq(
- unmanagedClasspath in Test += (baseDirectory in ThisBuild).value / "pscrypto-lib",
- unmanagedClasspath in Runtime += (baseDirectory in ThisBuild).value / "pscrypto-lib",
- unmanagedClasspath in Compile += (baseDirectory in ThisBuild).value / "pscrypto-lib"
-)
-
lazy val psforever = (project in file("."))
.configs(QuietTest)
.settings(psforeverSettings: _*)
@@ -98,7 +92,6 @@ lazy val psforever = (project in file("."))
// Copy all tests from Test -> QuietTest (we're only changing the run options)
inConfig(QuietTest)(Defaults.testTasks)
)
- .settings(pscryptoSettings: _*)
lazy val server = (project in file("server"))
.configs(QuietTest)
@@ -113,24 +106,24 @@ lazy val server = (project in file("server"))
packMain := Map("psforever-server" -> "net.psforever.server.Server"),
packArchivePrefix := "psforever-server",
packJvmOpts := Map("psforever-server" -> Seq("-Dstacktrace.app.packages=net.psforever")),
- packExtraClasspath := Map("psforever-server" -> Seq("${PROG_HOME}/pscrypto-lib", "${PROG_HOME}/config")),
- packResourceDir += (baseDirectory.in(psforever).value / "pscrypto-lib" -> "pscrypto-lib"),
- packResourceDir += (baseDirectory.in(psforever).value / "config" -> "config")
+ packExtraClasspath := Map("psforever-server" -> Seq("${PROG_HOME}/config")),
+ packResourceDir += (baseDirectory.in(psforever).value / "config" -> "config")
)
- .settings(pscryptoSettings: _*)
.dependsOn(psforever)
lazy val decodePackets = (project in file("tools/decode-packets"))
.enablePlugins(PackPlugin)
.settings(psforeverSettings: _*)
.settings(
- libraryDependencies ++= Seq(
- "org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0"
- ),
packMain := Map("psforever-decode-packets" -> "net.psforever.tools.decodePackets.DecodePackets")
)
.dependsOn(psforever)
+lazy val client = (project in file("tools/client"))
+ .enablePlugins(PackPlugin)
+ .settings(psforeverSettings: _*)
+ .dependsOn(psforever)
+
// Special test configuration for really quiet tests (used in CI)
lazy val QuietTest = config("quiet") extend Test
diff --git a/docker-compose.yml b/docker-compose.yml
index 8ae721242..e94117e46 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -10,15 +10,7 @@ services:
ports:
- 51000-51001:51000-51001/udp
- 51002:51002/tcp
- command: >
- sh -c '
- if [ ! -d "pscrypto-lib" ]; then
- wget https://github.com/psforever/PSCrypto/releases/download/v1.1/pscrypto-lib-1.1.zip
- unzip pscrypto-lib-1.1.zip
- rm pscrypto-lib-1.1.zip
- fi
- sbt server/run
- '
+ command: sbt server/run
adminer:
image: adminer
ports:
diff --git a/project/build.properties b/project/build.properties
index dcfaffb4d..cb6a5a8a9 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1 +1 @@
-sbt.version = 1.3.8
+sbt.version = 1.3.13
diff --git a/server/src/main/resources/sentry.properties b/server/src/main/resources/sentry.properties
new file mode 100644
index 000000000..b7c88db7c
--- /dev/null
+++ b/server/src/main/resources/sentry.properties
@@ -0,0 +1 @@
+stacktrace.app.packages=net.psforever
\ No newline at end of file
diff --git a/server/src/main/scala/net/psforever/server/Server.scala b/server/src/main/scala/net/psforever/server/Server.scala
index c1fdeae25..98c7d74e7 100644
--- a/server/src/main/scala/net/psforever/server/Server.scala
+++ b/server/src/main/scala/net/psforever/server/Server.scala
@@ -1,19 +1,21 @@
package net.psforever.server
-import java.net.InetAddress
+import java.net.{InetAddress, InetSocketAddress}
import java.nio.file.Paths
import java.util.Locale
+import java.util.UUID.randomUUID
import akka.actor.ActorSystem
-import akka.actor.typed.scaladsl.adapter._
+import akka.actor.typed.ActorRef
+import akka.actor.typed.scaladsl.Behaviors
import akka.routing.RandomPool
import akka.{actor => classic}
import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.classic.joran.JoranConfigurator
import io.sentry.Sentry
import kamon.Kamon
+import net.psforever.actors.net.{LoginActor, MiddlewareActor, SocketActor}
import net.psforever.actors.session.SessionActor
-import net.psforever.crypto.CryptoInterface
import net.psforever.login.psadmin.PsAdminActor
import net.psforever.login._
import net.psforever.objects.Default
@@ -33,6 +35,8 @@ import org.fusesource.jansi.Ansi.Color._
import org.fusesource.jansi.Ansi._
import org.slf4j
import scopt.OParser
+import akka.actor.typed.scaladsl.adapter._
+import net.psforever.packet.PlanetSidePacket
object Server {
private val logger = org.log4s.getLogger
@@ -90,38 +94,25 @@ object Server {
implicit val system: ActorSystem = classic.ActorSystem("PsLogin")
Default(system)
- /** Create pipelines for the login and world servers
- *
- * The first node in the pipe is an Actor that handles the crypto for protecting packets.
- * After any crypto operations have been applied or unapplied, the packets are passed on to the next
- * actor in the chain. For an incoming packet, this is a player session handler. For an outgoing packet
- * this is the session router, which returns the packet to the sending host.
- *
- * See SessionRouter.scala for a diagram
- */
- val loginTemplate = List(
- SessionPipeline("crypto-session-", classic.Props[CryptoSessionActor]()),
- SessionPipeline("packet-session-", classic.Props[PacketCodingActor]()),
- SessionPipeline("login-session-", classic.Props[LoginSessionActor]())
- )
- val worldTemplate = List(
- SessionPipeline("crypto-session-", classic.Props[CryptoSessionActor]()),
- SessionPipeline("packet-session-", classic.Props[PacketCodingActor]()),
- SessionPipeline("world-session-", classic.Props[SessionActor]())
- )
-
- val netSim: Option[NetworkSimulatorParameters] = if (Config.app.development.netSim.enable) {
- val params = NetworkSimulatorParameters(
- Config.app.development.netSim.loss,
- Config.app.development.netSim.delay.toMillis,
- Config.app.development.netSim.reorderChance,
- Config.app.development.netSim.reorderTime.toMillis
- )
- logger.warn("NetSim is active")
- logger.warn(params.toString)
- Some(params)
- } else {
- None
+ // typed to classic wrappers for login and session actors
+ val login = (ref: ActorRef[MiddlewareActor.Command], connectionId: String) => {
+ Behaviors.setup[PlanetSidePacket](context => {
+ val actor = context.actorOf(classic.Props(new LoginActor(ref, connectionId)), "login")
+ Behaviors.receiveMessage(message => {
+ actor ! message
+ Behaviors.same
+ })
+ })
+ }
+ val session = (ref: ActorRef[MiddlewareActor.Command], connectionId: String) => {
+ Behaviors.setup[PlanetSidePacket](context => {
+ val uuid = randomUUID().toString
+ val actor = context.actorOf(classic.Props(new SessionActor(ref, connectionId)), s"session-${uuid}")
+ Behaviors.receiveMessage(message => {
+ actor ! message
+ Behaviors.same
+ })
+ })
}
val zones = Zones.zones ++ Seq(Zone.Nowhere)
@@ -137,27 +128,19 @@ object Server {
serviceManager ! ServiceManager.Register(classic.Props[AccountPersistenceService](), "accountPersistence")
serviceManager ! ServiceManager.Register(classic.Props[PropertyOverrideManager](), "propertyOverrideManager")
- val loginRouter = classic.Props(new SessionRouter("Login", loginTemplate))
- val worldRouter = classic.Props(new SessionRouter("World", worldTemplate))
- val loginListener = system.actorOf(
- classic.Props(new UdpListener(loginRouter, "login-session-router", bindAddress, Config.app.login.port, netSim)),
- "login-udp-endpoint"
- )
- val worldListener = system.actorOf(
- classic.Props(new UdpListener(worldRouter, "world-session-router", bindAddress, Config.app.world.port, netSim)),
- "world-udp-endpoint"
- )
+ system.spawn(SocketActor(new InetSocketAddress(bindAddress, Config.app.login.port), login), "login-socket")
+ system.spawn(SocketActor(new InetSocketAddress(bindAddress, Config.app.world.port), session), "world-socket")
val adminListener = system.actorOf(
classic.Props(
new TcpListener(
classOf[PsAdminActor],
- "net.psforever.login.psadmin-client-",
+ "psadmin-client-",
InetAddress.getByName(Config.app.admin.bind),
Config.app.admin.port
)
),
- "net.psforever.login.psadmin-tcp-endpoint"
+ "psadmin-tcp-endpoint"
)
logger.info(
@@ -206,31 +189,6 @@ object Server {
case Right(_) =>
}
- /** Initialize the PSCrypto native library
- *
- * PSCrypto provides PlanetSide specific crypto that is required to communicate with it.
- * It has to be distributed as a native library because there is no Scala version of the required
- * cryptographic primitives (MD5MAC). See https://github.com/psforever/PSCrypto for more information.
- */
- try {
- CryptoInterface.initialize()
- } catch {
- case e: UnsatisfiedLinkError =>
- logger.error("Unable to initialize " + CryptoInterface.libName)
- logger.error(e)(
- "This means that your PSCrypto version is out of date. Get the latest version from the README" +
- " https://github.com/psforever/PSF-LoginServer#downloading-pscrypto"
- )
- sys.exit(1)
- case e: IllegalArgumentException =>
- logger.error("Unable to initialize " + CryptoInterface.libName)
- logger.error(e)(
- "This means that your PSCrypto version is out of date. Get the latest version from the README" +
- " https://github.com/psforever/PSF-LoginServer#downloading-pscrypto"
- )
- sys.exit(1)
- }
-
val builder = OParser.builder[CliConfig]
val parser = {
diff --git a/server/src/test/scala/MDCTestProbe.scala b/server/src/test/scala/MDCTestProbe.scala
deleted file mode 100644
index b69edea69..000000000
--- a/server/src/test/scala/MDCTestProbe.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-package net.psforever.pslogin
-
-import akka.actor.{ActorRef, MDCContextAware}
-import akka.testkit.TestProbe
-import net.psforever.login.HelloFriend
-import net.psforever.packet.{ControlPacket, GamePacket}
-
-final case class MDCGamePacket(packet: GamePacket)
-
-final case class MDCControlPacket(packet: ControlPacket)
-
-class MDCTestProbe(probe: TestProbe) extends MDCContextAware {
- /*
- The way this test mediator works needs to be explained.
-
- MDCContextAware objects initialize themselves in a chain of ActorRefs defined in the HelloFriend message.
- As the iterator is consumed, it produces a right-neighbor (r-neighbor) that is much further along the chain.
- The HelloFriend is passed to that r-neighbor and that is how subsequent neighbors are initialized and chained.
-
- MDCContextAware objects consume and produce internal messages called MdcMsg that wrap around the payload.
- Normally inaccessible from the outside, the payload is unwrapped within the standard receive PartialFunction.
- By interacting with a TestProbe constructor param, information that would be concealed by MdcMsg can be polled.
-
- The l-neighbor of the MDCContextAware is the system of the base.actor.base.ActorTest TestKit.
- The r-neighbor of the MDCContextAware is this MDCTestProbe and, indirectly, the TestProbe that was interjected.
- Pass l-input into the MDCContextAware itself.
- The r-output is a normal message that can be polled on that TestProbe.
- Pass r-input into this MDCTestProbe directly.
- The l-output is an MdcMsg that can be treated just as r-output, sending it to this Actor and polling the TestProbe.
- */
- private var left: ActorRef = ActorRef.noSender
-
- def receive: Receive = {
- case msg @ HelloFriend(_, _) =>
- left = sender()
- probe.ref ! msg
-
- case MDCGamePacket(msg) =>
- left ! msg
-
- case MDCControlPacket(msg) =>
- left ! msg
-
- case msg =>
- left ! msg
- probe.ref ! msg
- }
-}
diff --git a/server/src/test/scala/PacketCodingActorTest.scala b/server/src/test/scala/PacketCodingActorTest.scala
index c4f583e13..724b14636 100644
--- a/server/src/test/scala/PacketCodingActorTest.scala
+++ b/server/src/test/scala/PacketCodingActorTest.scala
@@ -1,57 +1,28 @@
package net.psforever.pslogin
+/*
import actor.base.ActorTest
import akka.actor.{ActorRef, Props}
import akka.testkit.TestProbe
-import net.psforever.login.{HelloFriend, PacketCodingActor, RawPacket}
+import net.psforever.actors.net.MiddlewareActor
import net.psforever.objects.avatar.Certification
-import net.psforever.packet.control.{ControlSync, MultiPacketBundle, SlottedMetaPacket}
-import net.psforever.packet.{ControlPacket, GamePacket, GamePacketOpcode, PacketCoding}
+import net.psforever.packet.control.{ControlSync, SlottedMetaPacket}
+import net.psforever.packet.{GamePacketOpcode, PacketCoding}
import net.psforever.packet.game._
import net.psforever.packet.game.objectcreate.ObjectClass
import net.psforever.types._
import scodec.bits._
import scala.concurrent.duration._
-
class PacketCodingActor1Test extends ActorTest {
"PacketCodingActor" should {
"construct" in {
- system.actorOf(Props[PacketCodingActor](), "pca")
+ system.actorOf(Props[MiddlewareActor](), "pca")
//just construct without failing
}
}
}
-class PacketCodingActor2Test extends ActorTest {
- "PacketCodingActor" should {
- "initialize (no r-neighbor)" in {
- val pca: ActorRef = system.actorOf(Props[PacketCodingActor](), "pca")
- within(200 millis) {
- pca ! HelloFriend(135, List.empty[ActorRef].iterator)
- expectNoMessage()
- }
- }
- }
-}
-
-class PacketCodingActor3Test extends ActorTest {
- "PacketCodingActor" should {
- "initialize (an r-neighbor)" in {
- val probe1 = TestProbe()
- val probe2 = system.actorOf(Props(classOf[MDCTestProbe], probe1), "mdc-probe")
- val pca: ActorRef = system.actorOf(Props[PacketCodingActor](), "pca")
- val iter = List(probe2).iterator
- val msg = HelloFriend(135, iter)
-
- assert(iter.hasNext)
- pca ! msg
- probe1.expectMsg(msg) //pca will pass message directly; a new HelloFriend would be an unequal different object
- assert(!iter.hasNext)
- }
- }
-}
-
class PacketCodingActor4Test extends ActorTest {
val string_hex = RawPacket(hex"2A 9F05 D405 86")
val string_obj = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 6)
@@ -577,7 +548,7 @@ class PacketCodingActorITest extends ActorTest {
probe1.receiveOne(300 milli) match {
case RawPacket(data) =>
assert(data == string_hex)
- PacketCoding.DecodePacket(data).require match {
+ PacketCoding.decodePacket(data).require match {
case _: SlottedMetaPacket =>
assert(true)
case _ =>
@@ -916,3 +887,5 @@ class PacketCodingActorLTest extends ActorTest {
object PacketCodingActorTest {
//decoy
}
+
+ */
diff --git a/src/main/scala/net/psforever/login/LoginSessionActor.scala b/src/main/scala/net/psforever/actors/net/LoginActor.scala
similarity index 57%
rename from src/main/scala/net/psforever/login/LoginSessionActor.scala
rename to src/main/scala/net/psforever/actors/net/LoginActor.scala
index 0043b0434..994e5d03c 100644
--- a/src/main/scala/net/psforever/login/LoginSessionActor.scala
+++ b/src/main/scala/net/psforever/actors/net/LoginActor.scala
@@ -1,30 +1,50 @@
-package net.psforever.login
+package net.psforever.actors.net
import java.net.{InetAddress, InetSocketAddress}
-
-import akka.actor.MDCContextAware.Implicits._
-import akka.actor.{Actor, ActorRef, Cancellable, MDCContextAware}
+import akka.actor.{Actor, ActorRef, Cancellable, MDCContextAware, typed}
import com.github.t3hnar.bcrypt._
import net.psforever.objects.{Account, Default}
-import net.psforever.packet.control._
+import net.psforever.packet.PlanetSideGamePacket
import net.psforever.packet.game.LoginRespMessage.{LoginError, StationError, StationSubscriptionStatus}
import net.psforever.packet.game._
-import net.psforever.packet.{PlanetSideGamePacket, _}
import net.psforever.persistence
-import net.psforever.types.PlanetSideEmpire
-import net.psforever.util.Config
-import net.psforever.util.Database._
-import org.log4s.MDC
-import scodec.bits._
import net.psforever.services.ServiceManager
import net.psforever.services.ServiceManager.Lookup
import net.psforever.services.account.{ReceiveIPAddress, RetrieveIPAddress, StoreAccountData}
+import net.psforever.types.PlanetSideEmpire
+import net.psforever.util.Config
+import net.psforever.util.Database._
import scala.concurrent.Future
import scala.concurrent.duration._
import scala.util.{Failure, Success}
+/*
+object LoginActor {
+ def apply(
+ middlewareActor: typed.ActorRef[MiddlewareActor.Command],
+ uuid: String
+ ): Behavior[Command] =
+ Behaviors.setup(context => new LoginActor(context, middlewareActor, uuid).start())
-class LoginSessionActor extends Actor with MDCContextAware {
+ sealed trait Command
+
+}
+
+class LoginActor(
+ middlewareActor: typed.ActorRef[MiddlewareActor.Command],
+ uuid: String
+) {
+
+ def start(): Unit = {
+ Behaviors.receiveMessagePartial {}
+ }
+}
+
+ */
+
+class LoginActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], connectionId: String)
+ extends Actor
+ with MDCContextAware {
private[this] val log = org.log4s.getLogger
import scala.concurrent.ExecutionContext.Implicits.global
@@ -51,32 +71,14 @@ class LoginSessionActor extends Actor with MDCContextAware {
// Reference: https://stackoverflow.com/a/50470009
private val numBcryptPasses = 10
+ ServiceManager.serviceManager ! Lookup("accountIntermediary")
+
override def postStop() = {
if (updateServerListTask != null)
updateServerListTask.cancel()
}
- def receive = Initializing
-
- def Initializing: Receive = {
- case HelloFriend(aSessionId, pipe) =>
- this.sessionId = aSessionId
- leftRef = sender()
- if (pipe.hasNext) {
- rightRef = pipe.next()
- rightRef !> HelloFriend(aSessionId, pipe)
- } else {
- rightRef = sender()
- }
- context.become(Started)
- ServiceManager.serviceManager ! Lookup("accountIntermediary")
-
- case _ =>
- log.error("Unknown message")
- context.stop(self)
- }
-
- def Started: Receive = {
+ def receive: Receive = {
case ServiceManager.LookupResult("accountIntermediary", endpoint) =>
accountIntermediary = endpoint
case ReceiveIPAddress(address) =>
@@ -86,30 +88,11 @@ class LoginSessionActor extends Actor with MDCContextAware {
port = address.Port
case UpdateServerList() =>
updateServerList()
- case ControlPacket(_, ctrl) =>
- handleControlPkt(ctrl)
- case GamePacket(_, _, game) =>
- handleGamePkt(game)
+ case packet: PlanetSideGamePacket =>
+ handleGamePkt(packet)
case default => failWithError(s"Invalid packet class received: $default")
}
- def handleControlPkt(pkt: PlanetSideControlPacket) = {
- pkt match {
- /// TODO: figure out what this is what what it does for the PS client
- /// I believe it has something to do with reliable packet transmission and resending
- case sync @ ControlSync(diff, _, _, _, _, _, fa, fb) =>
- log.trace(s"SYNC: $sync")
- val serverTick = Math.abs(System.nanoTime().toInt) // limit the size to prevent encoding error
- sendResponse(PacketCoding.CreateControlPacket(ControlSyncResp(diff, serverTick, fa, fb, fb, fa)))
-
- case TeardownConnection(_) =>
- sendResponse(DropSession(sessionId, "client requested session termination"))
-
- case default =>
- log.error(s"Unhandled ControlPacket $default")
- }
- }
-
def handleGamePkt(pkt: PlanetSideGamePacket) =
pkt match {
case LoginMessage(majorVersion, minorVersion, buildDate, username, password, token, revision) =>
@@ -131,8 +114,8 @@ class LoginSessionActor extends Actor with MDCContextAware {
case ConnectToWorldRequestMessage(name, _, _, _, _, _, _) =>
log.info(s"Connect to world request for '$name'")
val response = ConnectToWorldMessage(serverName, publicAddress.getAddress.getHostAddress, publicAddress.getPort)
- sendResponse(PacketCoding.CreateGamePacket(0, response))
- sendResponse(DropSession(sessionId, "user transferring to world"))
+ middlewareActor ! MiddlewareActor.Send(response)
+ middlewareActor ! MiddlewareActor.Close()
case _ =>
log.debug(s"Unhandled GamePacket $pkt")
@@ -141,7 +124,6 @@ class LoginSessionActor extends Actor with MDCContextAware {
def accountLogin(username: String, password: String): Unit = {
import ctx._
val newToken = this.generateToken()
- log.info("accountLogin")
val result = for {
// backwards compatibility: prefer exact match first, then try lowercase
accountsExact <- ctx.run(query[persistence.Account].filter(_.username == lift(username)))
@@ -153,26 +135,23 @@ class LoginSessionActor extends Actor with MDCContextAware {
}
accountOption <- accountsExact.headOption orElse accountsLower.headOption match {
case Some(account) => Future.successful(Some(account))
- case None => {
- Config.app.login.createMissingAccounts match {
- case true =>
- val passhash: String = password.bcrypt(numBcryptPasses)
- ctx.run(
- query[persistence.Account]
- .insert(_.passhash -> lift(passhash), _.username -> lift(username))
- .returningGenerated(_.id)
- ) flatMap { id => ctx.run(query[persistence.Account].filter(_.id == lift(id))) } map { accounts =>
- Some(accounts.head)
- }
- case false =>
- loginFailureResponse(username, newToken)
- Future.successful(None)
+ case None =>
+ if (Config.app.login.createMissingAccounts) {
+ val passhash: String = password.bcrypt(numBcryptPasses)
+ ctx.run(
+ query[persistence.Account]
+ .insert(_.passhash -> lift(passhash), _.username -> lift(username))
+ .returningGenerated(_.id)
+ ) flatMap { id => ctx.run(query[persistence.Account].filter(_.id == lift(id))) } map { accounts =>
+ Some(accounts.head)
+ }
+ } else {
+ loginFailureResponse(username, newToken)
+ Future.successful(None)
}
- }
}
login <- accountOption match {
case Some(account) =>
- log.info(s"$account")
(account.inactive, password.isBcrypted(account.passhash)) match {
case (false, true) =>
accountIntermediary ! StoreAccountData(newToken, Account(account.id, account.username, account.gm))
@@ -187,7 +166,7 @@ class LoginSessionActor extends Actor with MDCContextAware {
)
loginSuccessfulResponse(username, newToken)
updateServerListTask =
- context.system.scheduler.scheduleWithFixedDelay(0 seconds, 2 seconds, self, UpdateServerList())
+ context.system.scheduler.scheduleWithFixedDelay(0 seconds, 5 seconds, self, UpdateServerList())
future
case (_, false) =>
loginPwdFailureResponse(username, newToken)
@@ -202,77 +181,65 @@ class LoginSessionActor extends Actor with MDCContextAware {
result.onComplete {
case Success(_) =>
- case Failure(e) => log.error(e.getMessage())
+ case Failure(e) => log.error(e.getMessage)
}
}
def loginSuccessfulResponse(username: String, newToken: String) = {
- sendResponse(
- PacketCoding.CreateGamePacket(
+ middlewareActor ! MiddlewareActor.Send(
+ LoginRespMessage(
+ newToken,
+ LoginError.Success,
+ StationError.AccountActive,
+ StationSubscriptionStatus.Active,
0,
- LoginRespMessage(
- newToken,
- LoginError.Success,
- StationError.AccountActive,
- StationSubscriptionStatus.Active,
- 0,
- username,
- 10001
- )
+ username,
+ 10001
)
)
}
def loginPwdFailureResponse(username: String, newToken: String) = {
log.info(s"Failed login to account $username")
- sendResponse(
- PacketCoding.CreateGamePacket(
- 0,
- LoginRespMessage(
- newToken,
- LoginError.BadUsernameOrPassword,
- StationError.AccountActive,
- StationSubscriptionStatus.Active,
- 685276011,
- username,
- 10001
- )
+ middlewareActor ! MiddlewareActor.Send(
+ LoginRespMessage(
+ newToken,
+ LoginError.BadUsernameOrPassword,
+ StationError.AccountActive,
+ StationSubscriptionStatus.Active,
+ 685276011,
+ username,
+ 10001
)
)
}
def loginFailureResponse(username: String, newToken: String) = {
log.info("DB problem")
- sendResponse(
- PacketCoding.CreateGamePacket(
- 0,
- LoginRespMessage(
- newToken,
- LoginError.unk1,
- StationError.AccountActive,
- StationSubscriptionStatus.Active,
- 685276011,
- username,
- 10001
- )
+ middlewareActor ! MiddlewareActor.Send(
+ LoginRespMessage(
+ newToken,
+ LoginError.unk1,
+ StationError.AccountActive,
+ StationSubscriptionStatus.Active,
+ 685276011,
+ username,
+ 10001
)
)
}
def loginAccountFailureResponse(username: String, newToken: String) = {
log.info(s"Account $username inactive")
- sendResponse(
- PacketCoding.CreateGamePacket(
- 0,
- LoginRespMessage(
- newToken,
- LoginError.BadUsernameOrPassword,
- StationError.AccountClosed,
- StationSubscriptionStatus.Active,
- 685276011,
- username,
- 10001
- )
+ middlewareActor ! MiddlewareActor.Send(
+ LoginRespMessage(
+ newToken,
+ LoginError.BadUsernameOrPassword,
+ StationError.AccountClosed,
+ StationSubscriptionStatus.Active,
+ 685276011,
+ username,
+ 10001
)
)
}
@@ -287,35 +254,25 @@ class LoginSessionActor extends Actor with MDCContextAware {
}
def updateServerList() = {
- val msg = VNLWorldStatusMessage(
- "Welcome to PlanetSide! ",
- Vector(
- WorldInformation(
- serverName,
- WorldStatus.Up,
- Config.app.world.serverType,
- Vector(WorldConnectionInfo(publicAddress)),
- PlanetSideEmpire.VS
+ middlewareActor ! MiddlewareActor.Send(
+ VNLWorldStatusMessage(
+ "Welcome to PlanetSide! ",
+ Vector(
+ WorldInformation(
+ serverName,
+ WorldStatus.Up,
+ Config.app.world.serverType,
+ Vector(WorldConnectionInfo(publicAddress)),
+ PlanetSideEmpire.VS
+ )
)
)
)
- sendResponse(PacketCoding.CreateGamePacket(0, msg))
}
- def failWithError(error: String) = {
+ def failWithError(error: String): Unit = {
log.error(error)
- //sendResponse(PacketCoding.CreateControlPacket(ConnectionClose()))
+ middlewareActor ! MiddlewareActor.Close()
}
- def sendResponse(cont: Any) = {
- log.trace("LOGIN SEND: " + cont)
- MDC("sessionId") = sessionId.toString
- rightRef !> cont
- }
-
- def sendRawResponse(pkt: ByteVector) = {
- log.trace("LOGIN SEND RAW: " + pkt)
- MDC("sessionId") = sessionId.toString
- rightRef !> RawPacket(pkt)
- }
}
diff --git a/src/main/scala/net/psforever/actors/net/MiddlewareActor.scala b/src/main/scala/net/psforever/actors/net/MiddlewareActor.scala
new file mode 100644
index 000000000..0ed8e3768
--- /dev/null
+++ b/src/main/scala/net/psforever/actors/net/MiddlewareActor.scala
@@ -0,0 +1,593 @@
+package net.psforever.actors.net
+
+import java.net.InetSocketAddress
+import java.security.{SecureRandom, Security}
+
+import akka.actor.Cancellable
+import akka.actor.typed.{ActorRef, ActorTags, Behavior, PostStop, Signal}
+import akka.actor.typed.scaladsl.{ActorContext, Behaviors}
+import akka.io.Udp
+import net.psforever.packet.{
+ CryptoPacketOpcode,
+ PacketCoding,
+ PlanetSideControlPacket,
+ PlanetSideCryptoPacket,
+ PlanetSideGamePacket,
+ PlanetSidePacket
+}
+import net.psforever.packet.control.{
+ ClientStart,
+ ConnectionClose,
+ ControlSync,
+ ControlSyncResp,
+ HandleGamePacket,
+ MultiPacket,
+ MultiPacketEx,
+ RelatedA,
+ RelatedB,
+ ServerStart,
+ SlottedMetaPacket,
+ TeardownConnection
+}
+import net.psforever.packet.crypto.{ClientChallengeXchg, ClientFinished, ServerChallengeXchg, ServerFinished}
+import net.psforever.packet.game.{
+ ChangeFireModeMessage,
+ CharacterInfoMessage,
+ KeepAliveMessage,
+ ObjectCreateDetailedMessage,
+ PingMsg
+}
+import scodec.Attempt.{Failure, Successful}
+import scodec.bits.{BitVector, ByteVector, HexStringSyntax}
+import scodec.interop.akka.EnrichedByteVector
+import javax.crypto.spec.SecretKeySpec
+import net.psforever.packet.PacketCoding.CryptoCoding
+import net.psforever.util.{DiffieHellman, Md5Mac}
+import org.bouncycastle.jce.provider.BouncyCastleProvider
+import scodec.Attempt
+
+import scala.collection.mutable
+import scala.collection.mutable.ListBuffer
+import scala.concurrent.ExecutionContextExecutor
+import scala.concurrent.duration._
+
+/** MiddlewareActor sits between the raw UDP socket and the "main" actors (either login or session) and handles
+ * crypto and control packets. This means it sets up cryptography, it decodes incoming packets,
+ * it encodes, bundles and splits outgoing packets, it handles things like requesting/resending lost packets and more.
+ */
+object MiddlewareActor {
+ Security.addProvider(new BouncyCastleProvider)
+
+ /** Maximum packet size in bytes */
+ //final val MTU: Int = 467
+ final val MTU: Int = 440
+
+ def apply(
+ socket: ActorRef[Udp.Command],
+ sender: InetSocketAddress,
+ next: (ActorRef[Command], String) => Behavior[PlanetSidePacket],
+ connectionId: String
+ ): Behavior[Command] =
+ Behaviors.setup(context => new MiddlewareActor(context, socket, sender, next, connectionId).start())
+
+ sealed trait Command
+
+ /** Receive incoming packet */
+ final case class Receive(msg: ByteVector) extends Command
+
+ /** Send outgoing packet */
+ final case class Send(msg: PlanetSidePacket) extends Command
+
+ /** Close connection */
+ final case class Close() extends Command
+}
+
+class MiddlewareActor(
+ context: ActorContext[MiddlewareActor.Command],
+ socket: ActorRef[Udp.Command],
+ sender: InetSocketAddress,
+ next: (ActorRef[MiddlewareActor.Command], String) => Behavior[PlanetSidePacket],
+ connectionId: String
+) {
+
+ import MiddlewareActor._
+
+ implicit val ec: ExecutionContextExecutor = context.executionContext
+
+ private[this] val log = org.log4s.getLogger
+
+ var clientNonce: Long = 0
+
+ var serverMACBuffer: ByteVector = ByteVector.empty
+
+ val random = new SecureRandom()
+
+ var crypto: Option[CryptoCoding] = None
+
+ val nextActor: ActorRef[PlanetSidePacket] =
+ context.spawnAnonymous(next(context.self, connectionId), ActorTags(s"id=${connectionId}"))
+
+ /** Queue of incoming packets (plus sequence numbers and timestamps) that arrived in the wrong order */
+ val inReorderQueue: ListBuffer[(PlanetSidePacket, Int, Long)] = ListBuffer()
+
+ /** Latest incoming sequence number */
+ var inSequence = 0
+
+ /** Latest incoming subslot number */
+ var inSubslot = 0
+
+ /** List of missing subslot numbers and attempts counter */
+ var inSubslotsMissing: mutable.Map[Int, Int] = mutable.Map()
+
+ /** Queue of outgoing packets used for bundling and splitting */
+ val outQueue: mutable.Queue[(PlanetSidePacket, BitVector)] = mutable.Queue()
+
+ /** Queue of outgoing packets ready for sending */
+ val outQueueBundled: mutable.Queue[PlanetSidePacket] = mutable.Queue()
+
+ /** Latest outgoing sequence number */
+ var outSequence = 0
+
+ def nextSequence: Int = {
+ val r = outSequence
+ if (outSequence == 0xffff) {
+ outSequence = 0
+ } else {
+ outSequence += 1
+ }
+ r
+ }
+
+ /** Latest outgoing subslot number */
+ var outSubslot = 0
+
+ def nextSubslot: Int = {
+ val r = outSubslot
+ if (outSubslot == 0xffff) {
+ outSubslot = 0
+ } else {
+ outSubslot += 1
+ }
+ r
+ }
+
+ /** Create a new SlottedMetaPacket with the sequence number filled in and the packet added to the history */
+ def smp(slot: Int, data: ByteVector): SlottedMetaPacket = {
+ if (outSlottedMetaPackets.length > 100) {
+ outSlottedMetaPackets = outSlottedMetaPackets.takeRight(100)
+ }
+ val packet = SlottedMetaPacket(slot, nextSubslot, data)
+ outSlottedMetaPackets += packet
+ packet
+ }
+
+ /** History of sent SlottedMetaPackets in case the client requests missing SMP packets via a RelatedA packet. */
+ var outSlottedMetaPackets: ListBuffer[SlottedMetaPacket] = ListBuffer()
+
+ /** Timer that handles the bundling and throttling of outgoing packets and the reordering of incoming packets */
+ val queueProcessor: Cancellable = {
+ context.system.scheduler.scheduleWithFixedDelay(10.milliseconds, 10.milliseconds)(() => {
+ try {
+ if (outQueue.nonEmpty && outQueueBundled.isEmpty) {
+ var length = 0L
+ val bundle = outQueue
+ .dequeueWhile {
+ case (packet, payload) =>
+ // packet length + MultiPacketEx prefix length
+ val packetLength = payload.length + (if (payload.length < 256 * 8) { 1L * 8 }
+ else if (payload.length < 65536 * 8) { 2L * 8 }
+ else { 4L * 8 })
+ length += packetLength
+
+ packet match {
+ // Super awkward special case: Bundling CharacterInfoMessage with OCDM causes the character selection
+ // to show blank lines and be broken. So we only dequeue either if they are the first packet.
+ case _: CharacterInfoMessage | _: ObjectCreateDetailedMessage =>
+ length == packetLength
+ case _ =>
+ // Some packets may be larger than the MTU limit, in that case we dequeue anyway and split later
+ // We deduct some bytes to leave room for SlottedMetaPacket (4 bytes) and MultiPacketEx (2 bytes + prefix per packet)
+ length == packetLength || length <= (MTU - 6) * 8
+ }
+ }
+ .map(_._2)
+
+ if (bundle.length == 1) {
+ outQueueBundled.enqueueAll(splitPacket(bundle.head))
+ } else {
+ PacketCoding.encodePacket(MultiPacketEx(bundle.toVector.map(_.bytes))) match {
+ case Successful(data) => outQueueBundled.enqueue(smp(0, data.bytes))
+ case Failure(cause) => log.error(cause.message)
+ }
+ }
+ }
+
+ outQueueBundled.dequeueFirst(_ => true) match {
+ case Some(packet) => send(packet, Some(nextSequence), crypto)
+ case None => ()
+ }
+
+ if (inReorderQueue.nonEmpty) {
+ var currentSequence = inSequence
+ val currentTime = System.currentTimeMillis()
+ inReorderQueue
+ .sortBy(_._2)
+ .dropWhile {
+ case (_, sequence, time) =>
+ // Forward packet if next in sequence order or older than 20ms
+ if (sequence == currentSequence + 1 || currentTime - time > 20) {
+ currentSequence += 1
+ true
+ } else {
+ false
+ }
+ }
+ .foreach {
+ case (packet, sequence, _) =>
+ if (sequence > inSequence) {
+ inSequence = sequence
+ }
+ in(packet)
+ }
+ }
+
+ if (inSubslotsMissing.nonEmpty) {
+ inSubslotsMissing.foreach {
+ case (subslot, attempts) =>
+ if (attempts <= 50) {
+ // Slight hack to send RelatedA less frequently, might want to put this on a separate timer
+ if (attempts % 10 == 0) send(RelatedA(0, subslot))
+ inSubslotsMissing(subslot) += 1
+ } else {
+ log.warn(s"Requesting subslot '$subslot' from client failed")
+ inSubslotsMissing.remove(subslot)
+ }
+ }
+ }
+ } catch {
+ case e: Throwable => log.error(e)("Queue processing error")
+ }
+ })
+ }
+
+ def start(): Behavior[Command] = {
+ Behaviors.receiveMessagePartial {
+ case Receive(msg) =>
+ PacketCoding.unmarshalPacket(msg) match {
+ case Successful(packet) =>
+ packet match {
+ case (ClientStart(nonce), _) =>
+ clientNonce = nonce
+ val serverNonce = Math.abs(random.nextInt())
+ send(ServerStart(nonce, serverNonce), None, None)
+ cryptoSetup()
+
+ // TODO ResetSequence
+ case _ =>
+ log.error(s"Unexpected packet type $packet in init")
+ Behaviors.same
+ }
+ case Failure(_) =>
+ // There is a special case where no crypto is being used.
+ // The only packet coming through looks like PingMsg. This is a hardcoded
+ // feature of the client @ 0x005FD618
+ PacketCoding.decodePacket(msg) match {
+ case Successful(packet) =>
+ packet match {
+ case ping: PingMsg =>
+ // reflect the packet back to the sender
+ send(ping)
+ Behaviors.same
+ case _: ChangeFireModeMessage =>
+ // ignore
+ Behaviors.same
+ case _ =>
+ log.error(s"Unexpected non-crypto packet type $packet in start")
+ Behaviors.same
+ }
+ case Failure(e) =>
+ log.error(s"Could not decode packet in start: $e")
+ Behaviors.same
+ }
+ }
+
+ case other =>
+ log.error(s"Invalid message '$other' received in start")
+ Behaviors.same
+ }
+
+ }
+
+ def cryptoSetup(): Behavior[Command] = {
+ Behaviors
+ .receiveMessagePartial[Command] {
+ case Receive(msg) =>
+ PacketCoding.unmarshalPacket(msg, None, CryptoPacketOpcode.ClientChallengeXchg) match {
+ case Successful(packet) =>
+ packet match {
+ case (ClientChallengeXchg(time, challenge, p, g), Some(_)) =>
+ serverMACBuffer ++= msg.drop(3)
+
+ val dh = DiffieHellman(p.toArray, g.toArray)
+
+ val clientChallenge = ServerChallengeXchg.getCompleteChallenge(time, challenge)
+ val serverTime = System.currentTimeMillis() / 1000L
+ val randomChallenge = randomBytes(0xc)
+ val serverChallenge = ServerChallengeXchg.getCompleteChallenge(serverTime, randomChallenge)
+
+ serverMACBuffer ++= send(
+ ServerChallengeXchg(serverTime, randomChallenge, ByteVector.view(dh.publicKey))
+ ).drop(3)
+
+ cryptoFinish(dh, clientChallenge, serverChallenge)
+
+ case _ =>
+ log.error(s"Unexpected packet type $packet in cryptoSetup")
+ stop()
+ }
+ case Failure(e) =>
+ log.error(s"Could not decode packet in cryptoSetup: ${e}")
+ stop()
+ }
+ case other =>
+ log.error(s"Invalid message '$other' received in cryptoSetup")
+ stop()
+ }
+ .receiveSignal(onSignal)
+ }
+
+ def cryptoFinish(dh: DiffieHellman, clientChallenge: ByteVector, serverChallenge: ByteVector): Behavior[Command] = {
+ Behaviors
+ .receiveMessagePartial[Command] {
+ case Receive(msg) =>
+ PacketCoding.unmarshalPacket(msg, None, CryptoPacketOpcode.ClientFinished) match {
+ case Successful(packet) =>
+ packet match {
+ case (ClientFinished(clientPubKey, _), Some(_)) =>
+ serverMACBuffer ++= msg.drop(3)
+
+ val agreedKey = dh.agree(clientPubKey.toArray)
+ val agreedMessage = ByteVector("master secret".getBytes) ++ clientChallenge ++
+ hex"00000000" ++ serverChallenge ++ hex"00000000"
+
+ val masterSecret = new Md5Mac(ByteVector.view(agreedKey)).updateFinal(agreedMessage)
+ val mac = new Md5Mac(masterSecret)
+
+ // To do? verify client challenge. The code below has always been commented out, so it probably never
+ // worked and it surely doesn't work now. The whole cryptography is flawed because
+ // of the 128bit p values for DH, so implementing security features is probably not worth it.
+ /*
+ val clientChallengeExpanded = mac.updateFinal(
+ ByteVector(
+ "client finished".getBytes
+ ) ++ serverMACBuffer ++ hex"01" ++ clientChallengeResult ++ hex"01",
+ 0xc
+ )
+ */
+
+ val serverChallengeResult = mac
+ .updateFinal(ByteVector("server finished".getBytes) ++ serverMACBuffer ++ hex"01", 0xc)
+
+ val encExpansion = ByteVector.view("server expansion".getBytes) ++ hex"0000" ++ serverChallenge ++
+ hex"00000000" ++ clientChallenge ++ hex"00000000"
+ val decExpansion = ByteVector.view("client expansion".getBytes) ++ hex"0000" ++ serverChallenge ++
+ hex"00000000" ++ clientChallenge ++ hex"00000000"
+
+ val expandedEncKey = mac.updateFinal(encExpansion, 64)
+ val expandedDecKey = mac.updateFinal(decExpansion, 64)
+
+ crypto = Some(
+ CryptoCoding(
+ new SecretKeySpec(expandedEncKey.take(20).toArray, "RC5"),
+ new SecretKeySpec(expandedDecKey.take(20).toArray, "RC5"),
+ expandedEncKey.slice(20, 36),
+ expandedDecKey.slice(20, 36)
+ )
+ )
+
+ send(ServerFinished(serverChallengeResult))
+
+ active()
+
+ case other =>
+ log.error(s"Unexpected packet '$other' in cryptoFinish")
+ stop()
+ }
+ case Failure(e) =>
+ log.error(s"Could not decode packet in cryptoFinish: $e")
+ stop()
+ }
+ case other =>
+ log.error(s"Invalid message '$other' received in cryptoFinish")
+ stop()
+ }
+ .receiveSignal(onSignal)
+ }
+
+ def active(): Behavior[Command] = {
+ Behaviors
+ .receiveMessage[Command] {
+ case Receive(msg) =>
+ PacketCoding.unmarshalPacket(msg, crypto) match {
+ case Successful((packet, Some(sequence))) =>
+ if (sequence == inSequence + 1) {
+ inSequence = sequence
+ in(packet)
+ } else {
+ inReorderQueue.addOne((packet, sequence, System.currentTimeMillis()))
+ }
+ case Successful((packet, None)) => in(packet)
+ case Failure(e) => log.error(s"Could not decode packet: ${e}")
+ }
+ Behaviors.same
+
+ case Send(packet) =>
+ out(packet)
+ Behaviors.same
+
+ case Close() =>
+ outQueue
+ .dequeueAll(_ => true)
+ .foreach(p => send(smp(0, p._2.bytes), Some(nextSequence), crypto))
+ stop()
+ }
+ .receiveSignal(onSignal)
+ }
+
+ val onSignal: PartialFunction[(ActorContext[Command], Signal), Behavior[Command]] = {
+ case (_, PostStop) =>
+ context.stop(nextActor)
+ queueProcessor.cancel()
+ Behaviors.same
+ }
+
+ /** Handle incoming packet */
+ def in(packet: PlanetSidePacket): Behavior[Command] = {
+ packet match {
+ case packet: PlanetSideGamePacket =>
+ nextActor ! packet
+ Behaviors.same
+
+ case packet: PlanetSideControlPacket =>
+ packet match {
+ case SlottedMetaPacket(slot, subslot, inner) =>
+ if (subslot > inSubslot + 1) {
+ ((inSubslot + 1) until subslot).foreach(s => inSubslotsMissing.addOne((s, 0)))
+ } else if (inSubslotsMissing.contains(subslot)) {
+ inSubslotsMissing.remove(subslot)
+ } else if (inSubslotsMissing.isEmpty) {
+ send(RelatedB(slot, subslot))
+ }
+ if (subslot > inSubslot) {
+ inSubslot = subslot
+ }
+ in(PacketCoding.decodePacket(inner))
+ Behaviors.same
+
+ case MultiPacket(packets) =>
+ packets.foreach(p => in(PacketCoding.decodePacket(p)))
+ Behaviors.same
+
+ case MultiPacketEx(packets) =>
+ packets.foreach(p => in(PacketCoding.decodePacket(p)))
+ Behaviors.same
+
+ case RelatedA(slot, subslot) =>
+ log.info(s"Client indicated a packet is missing prior to slot '$slot' and subslot '$subslot'")
+ outSlottedMetaPackets.find(_.subslot == subslot - 1) match {
+ case Some(packet) => outQueueBundled.enqueue(packet)
+ case None => log.warn(s"Client requested unknown subslot '$subslot'")
+ }
+ Behaviors.same
+
+ case RelatedB(_, subslot) =>
+ outSlottedMetaPackets = outSlottedMetaPackets.filter(_.subslot > subslot)
+ Behaviors.same
+
+ case ControlSync(diff, _, _, _, _, _, fa, fb) =>
+ // TODO: figure out what this is what what it does for the PS client
+ // I believe it has something to do with reliable packet transmission and resending
+
+ // Work around the 2038 problem
+ // TODO can we just start at 0 again? what is this for?
+ val serverTick = math.min(System.currentTimeMillis(), 4294967295L)
+ val nextDiff = if (diff == 65535) 0 else diff + 1
+ send(ControlSyncResp(nextDiff, serverTick, fa, fb, fb, fa))
+ Behaviors.same
+
+ case ConnectionClose() =>
+ Behaviors.stopped
+
+ case TeardownConnection(_) =>
+ stop()
+
+ case ClientStart(_) =>
+ start()
+
+ case other =>
+ log.warn(s"Unhandled control packet '$other'")
+ Behaviors.same
+ }
+
+ case packet: PlanetSideCryptoPacket =>
+ log.error(s"Unexpected crypto packet '$packet'")
+ Behaviors.same
+ }
+
+ }
+
+ def in(packet: Attempt[PlanetSidePacket]): Unit = {
+ packet match {
+ case Successful(packet) => in(packet)
+ case Failure(cause) => log.error(cause.message)
+ }
+ }
+
+ /** Handle outgoing packet */
+ def out(packet: PlanetSidePacket): Unit = {
+ packet match {
+ case packet: KeepAliveMessage =>
+ send(packet)
+
+ case _ =>
+ PacketCoding.encodePacket(packet) match {
+ case Successful(payload) => outQueue.enqueue((packet, payload))
+ case Failure(cause) => log.error(cause.message)
+ }
+ }
+ }
+
+ def send(packet: PlanetSideControlPacket): ByteVector = {
+ send(packet, if (crypto.isDefined) Some(nextSequence) else None, crypto)
+ }
+
+ def send(packet: PlanetSideCryptoPacket): ByteVector = {
+ send(packet, Some(nextSequence), crypto)
+ }
+
+ def send(packet: PlanetSideGamePacket): ByteVector = {
+ send(packet, Some(nextSequence), crypto)
+ }
+
+ def send(packet: PlanetSidePacket, sequence: Option[Int], crypto: Option[CryptoCoding]): ByteVector = {
+ PacketCoding.marshalPacket(packet, sequence, crypto) match {
+ case Successful(bits) =>
+ val bytes = bits.toByteVector
+ socket ! Udp.Send(bytes.toByteString, sender)
+ bytes
+ case Failure(e) =>
+ log.error(s"Failed to encode packet ${packet.getClass.getName}: $e")
+ ByteVector.empty
+ }
+ }
+
+ def randomBytes(amount: Int): ByteVector = {
+ val array = Array.ofDim[Byte](amount)
+ random.nextBytes(array)
+ ByteVector.view(array)
+ }
+
+ def stop(): Behavior[Command] = {
+ send(ConnectionClose())
+ Behaviors.stopped
+ }
+
+ /** Split packet into multiple chunks (if necessary)
+ * Split packets are wrapped in a HandleGamePacket and sent as SlottedMetaPacket4
+ * The purpose of SlottedMetaPacket4 may or may not be to indicate a split packet
+ */
+ def splitPacket(packet: BitVector): Seq[PlanetSideControlPacket] = {
+ if (packet.length > (MTU - 4) * 8) {
+ PacketCoding.encodePacket(HandleGamePacket(packet.bytes)) match {
+ case Successful(data) =>
+ data.grouped((MTU - 8) * 8).map(vec => smp(4, vec.bytes)).toSeq
+ case Failure(cause) =>
+ log.error(cause.message)
+ Seq()
+ }
+ } else {
+ Seq(smp(0, packet.bytes))
+ }
+ }
+
+}
diff --git a/src/main/scala/net/psforever/actors/net/SocketActor.scala b/src/main/scala/net/psforever/actors/net/SocketActor.scala
new file mode 100644
index 000000000..b4fb976a3
--- /dev/null
+++ b/src/main/scala/net/psforever/actors/net/SocketActor.scala
@@ -0,0 +1,226 @@
+package net.psforever.actors.net
+
+import java.net.InetSocketAddress
+import java.security.SecureRandom
+import java.util.UUID.randomUUID
+import java.util.concurrent.ThreadLocalRandom
+
+import akka.actor.Cancellable
+import akka.{actor => classic}
+import akka.actor.typed.{ActorRef, ActorTags, Behavior, PostStop, Terminated}
+import akka.actor.typed.scaladsl.{AbstractBehavior, ActorContext, Behaviors}
+import akka.io.{IO, Udp}
+import akka.actor.typed.scaladsl.adapter._
+import net.psforever.packet.PlanetSidePacket
+import net.psforever.util.Config
+import scodec.interop.akka.EnrichedByteString
+
+import scala.collection.mutable
+import scala.concurrent.ExecutionContextExecutor
+import scala.concurrent.duration.{DurationDouble, DurationInt}
+import scala.util.Random
+
+/** SocketActor creates a UDP socket, receives packets and forwards them to MiddlewareActor
+ * There is only one SocketActor, but each connected client gets its own MiddlewareActor
+ */
+object SocketActor {
+ def apply(
+ address: InetSocketAddress,
+ next: (ActorRef[MiddlewareActor.Command], String) => Behavior[PlanetSidePacket]
+ ): Behavior[Command] =
+ Behaviors.setup(context => new SocketActor(context, address, next).start())
+
+ sealed trait Command
+
+ private final case class UdpCommandMessage(message: Udp.Command) extends Command
+ private final case class UdpEventMessage(message: Udp.Event) extends Command
+ private final case class UdpUnboundMessage(message: Udp.Unbound) extends Command
+ private final case class Bound(socket: classic.ActorRef) extends Command
+ private final case class StopChild(ref: ActorRef[MiddlewareActor.Command]) extends Command
+
+ // Typed actors cannot access sender but you can only get the socket that way
+ private class SenderHack(ref: ActorRef[SocketActor.Command]) extends classic.Actor {
+ def receive: Receive = {
+ case Udp.Bound(_) =>
+ ref ! Bound(sender())
+ }
+ }
+
+ // TODO? This doesn't quite support all parameters of the old network simulator
+ // Need to decide wheter they are necessary or not
+ // https://github.com/psforever/PSF-LoginServer/blob/07f447c2344ab55d581317316c41571772ac2242/src/main/scala/net/psforever/login/UdpNetworkSimulator.scala
+ private object NetworkSimulator {
+ def apply(socketActor: ActorRef[SocketActor.Command]): Behavior[Udp.Message] =
+ Behaviors.setup(context => new NetworkSimulator(context, socketActor))
+ }
+
+ private class NetworkSimulator(context: ActorContext[Udp.Message], socketActor: ActorRef[SocketActor.Command])
+ extends AbstractBehavior[Udp.Message](context) {
+
+ private[this] val log = org.log4s.getLogger
+
+ override def onMessage(message: Udp.Message): Behavior[Udp.Message] = {
+ message match {
+ case _: Udp.Received | _: Udp.Send =>
+ simulate(message)
+ Behaviors.same
+ case other =>
+ socketActor ! toSocket(message)
+ Behaviors.same
+ }
+ }
+
+ def simulate(message: Udp.Message): Unit = {
+ if (Random.nextDouble() > Config.app.development.netSim.loss) {
+ if (Random.nextDouble() <= Config.app.development.netSim.reorderChance) {
+ context.scheduleOnce(
+ ThreadLocalRandom.current().nextDouble(0.01, 0.2).seconds,
+ socketActor,
+ toSocket(message)
+ )
+ } else {
+ socketActor ! toSocket(message)
+ }
+ } else {
+ log.info("Network simulator dropped packet")
+ }
+ }
+
+ def toSocket(message: Udp.Message): Command =
+ message match {
+ case message: Udp.Command => UdpCommandMessage(message)
+ case message: Udp.Event => UdpEventMessage(message)
+ }
+ }
+}
+
+class SocketActor(
+ context: ActorContext[SocketActor.Command],
+ address: InetSocketAddress,
+ next: (ActorRef[MiddlewareActor.Command], String) => Behavior[PlanetSidePacket]
+) {
+ import SocketActor._
+ import SocketActor.Command
+
+ implicit val ec: ExecutionContextExecutor = context.executionContext
+
+ private[this] val log = org.log4s.getLogger
+
+ val udpCommandAdapter: ActorRef[Udp.Command] =
+ if (!Config.app.development.netSim.enable) {
+ context.messageAdapter[Udp.Command](UdpCommandMessage)
+ } else {
+ context.spawnAnonymous(NetworkSimulator(context.self))
+ }
+
+ val updEventAdapter: ActorRef[Udp.Event] =
+ if (!Config.app.development.netSim.enable) {
+ context.messageAdapter[Udp.Event](UdpEventMessage)
+ } else {
+ context.spawnAnonymous(NetworkSimulator(context.self))
+ }
+
+ val updUnboundAdapter: ActorRef[Udp.Unbound] = context.messageAdapter[Udp.Unbound](UdpUnboundMessage)
+ val senderHack: classic.ActorRef = context.actorOf(classic.Props(new SenderHack(context.self)))
+
+ IO(Udp)(context.system.classicSystem).tell(Udp.Bind(updEventAdapter.toClassic, address), senderHack)
+
+ val random = new SecureRandom()
+
+ val packetActors: mutable.Map[InetSocketAddress, ActorRef[MiddlewareActor.Command]] = mutable.Map()
+
+ val incomingTimes: mutable.Map[InetSocketAddress, Long] = mutable.Map()
+ val outgoingTimes: mutable.Map[InetSocketAddress, Long] = mutable.Map()
+
+ val sessionReaper: Cancellable = context.system.scheduler.scheduleWithFixedDelay(0.seconds, 5.seconds)(() => {
+ val now = System.currentTimeMillis()
+ packetActors.keys.foreach(addr => {
+ incomingTimes.get(addr) match {
+ case Some(time) =>
+ if (now - time > Config.app.network.session.inboundGraceTime.toMillis) {
+ context.self ! StopChild(packetActors(addr))
+ }
+ case _ => ()
+ }
+ outgoingTimes.get(addr) match {
+ case Some(time) =>
+ if (now - time > Config.app.network.session.outboundGraceTime.toMillis) {
+ context.self ! StopChild(packetActors(addr))
+ }
+ case _ => ()
+ }
+ })
+ })
+
+ def start(): Behavior[Command] = {
+ Behaviors
+ .receiveMessagePartial[Command] {
+ case Bound(socket) =>
+ active(socket)
+ }
+ .receiveSignal {
+ case (_, PostStop) =>
+ sessionReaper.cancel()
+ Behaviors.same
+ }
+ }
+
+ def active(socket: classic.ActorRef): Behavior[Command] = {
+ Behaviors
+ .receiveMessagePartial[Command] {
+ case UdpEventMessage(message) =>
+ message match {
+ case Udp.Bound(_) => Behaviors.same
+ case Udp.Received(data, remote) =>
+ incomingTimes(remote) = System.currentTimeMillis()
+ val ref = packetActors.get(remote) match {
+ case Some(ref) => ref
+ case None =>
+ val connectionId = randomUUID.toString
+ val ref = context.spawn(
+ MiddlewareActor(udpCommandAdapter, remote, next, connectionId),
+ s"middleware-${connectionId}",
+ ActorTags(s"uuid=${connectionId}")
+ )
+ context.watch(ref)
+ packetActors(remote) = ref
+ ref
+ }
+ ref ! MiddlewareActor.Receive(data.toByteVector)
+ Behaviors.same
+
+ case _ =>
+ Behaviors.same
+ }
+ Behaviors.same
+
+ case UdpCommandMessage(message) =>
+ message match {
+ case Udp.Send(_, remote, _) =>
+ outgoingTimes(remote) = System.currentTimeMillis()
+ case _ => ()
+ }
+ socket ! message
+ Behaviors.same
+
+ case UdpUnboundMessage(_) =>
+ Behaviors.stopped
+
+ case StopChild(ref) =>
+ context.stop(ref)
+ Behaviors.same
+
+ }
+ .receiveSignal {
+ case (_, PostStop) =>
+ sessionReaper.cancel()
+ Behaviors.same
+ case (_, Terminated(ref)) =>
+ packetActors.find(_._2 == ref) match {
+ case Some((remote, _)) => packetActors.remove(remote)
+ case None => log.warn(s"Received Terminated for unknown actor ${ref}")
+ }
+ Behaviors.same
+ }
+ }
+}
diff --git a/src/main/scala/net/psforever/actors/session/AvatarActor.scala b/src/main/scala/net/psforever/actors/session/AvatarActor.scala
index c1d309d8e..ea40d09c4 100644
--- a/src/main/scala/net/psforever/actors/session/AvatarActor.scala
+++ b/src/main/scala/net/psforever/actors/session/AvatarActor.scala
@@ -866,7 +866,7 @@ class AvatarActor(
Behaviors.same
case ConsumeStamina(stamina) =>
- assert(stamina > 0)
+ assert(stamina > 0, s"consumed stamina must be larger than 0, but is: ${stamina}")
consumeStamina(stamina)
Behaviors.same
@@ -1121,8 +1121,8 @@ class AvatarActor(
val result = ctx.run(query[persistence.Avatar].filter(_.accountId == lift(account.id)))
result.onComplete {
case Success(avatars) =>
- val gen: AtomicInteger = new AtomicInteger(1)
- val converter: CharacterSelectConverter = new CharacterSelectConverter
+ val gen = new AtomicInteger(1)
+ val converter = new CharacterSelectConverter
avatars.filter(!_.deleted) foreach { a =>
val secondsSinceLastLogin = Seconds.secondsBetween(a.lastLogin, LocalDateTime.now()).getSeconds
@@ -1200,7 +1200,7 @@ class AvatarActor(
}
sessionActor ! SessionActor.SendResponse(
- CharacterInfoMessage(0, PlanetSideZoneID(1), 0, PlanetSideGUID(0), finished = true, 0)
+ CharacterInfoMessage(15, PlanetSideZoneID(0), 0, PlanetSideGUID(0), finished = true, 0)
)
case Failure(e) => log.error(e)("db failure")
diff --git a/src/main/scala/net/psforever/actors/session/ChatActor.scala b/src/main/scala/net/psforever/actors/session/ChatActor.scala
index 73d1f7fe5..6574ddf55 100644
--- a/src/main/scala/net/psforever/actors/session/ChatActor.scala
+++ b/src/main/scala/net/psforever/actors/session/ChatActor.scala
@@ -11,16 +11,15 @@ import net.psforever.objects.{Default, GlobalDefinitions, Player, Session}
import net.psforever.objects.serverobject.resourcesilo.ResourceSilo
import net.psforever.objects.serverobject.turret.{FacilityTurret, TurretUpgrade, WeaponTurrets}
import net.psforever.objects.zones.Zoning
-import net.psforever.packet.PacketCoding
import net.psforever.packet.game.{ChatMsg, DeadState, RequestDestroyMessage, ZonePopulationUpdateMessage}
import net.psforever.types.{ChatMessageType, PlanetSideEmpire, PlanetSideGUID, Vector3}
import net.psforever.util.{Config, PointOfInterest}
import net.psforever.zones.Zones
import net.psforever.services.chat.ChatService
import net.psforever.services.chat.ChatService.ChatChannel
-
import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.duration._
+import akka.actor.typed.scaladsl.adapter._
object ChatActor {
def apply(
@@ -272,9 +271,8 @@ class ChatActor(
case Some(turret: FacilityTurret) if turret.isUpgrading =>
WeaponTurrets.FinishUpgradingMannedTurret(turret, TurretUpgrade.None)
case _ =>
- sessionActor ! SessionActor.SendResponse(
- PacketCoding.CreateGamePacket(0, RequestDestroyMessage(PlanetSideGUID(guid))).packet
- )
+ // FIXME we shouldn't do it like that
+ sessionActor.toClassic ! RequestDestroyMessage(PlanetSideGUID(guid))
}
sessionActor ! SessionActor.SendResponse(message)
@@ -353,7 +351,7 @@ class ChatActor(
val ntu: Int = 900 + r.nextInt(100) - silo.NtuCapacitor
silo.Actor ! ResourceSilo.UpdateChargeLevel(ntu)
- case _ => ;
+ case _ => ()
}
)
)
@@ -474,7 +472,7 @@ class ChatActor(
)
case _ =>
sessionActor ! SessionActor.SendResponse(
- message.copy(messageType = UNK_229, contents = "@@CMT_CAPTUREBASE_usage")
+ message.copy(messageType = UNK_229, contents = "@CMT_CAPTUREBASE_usage")
)
}
diff --git a/src/main/scala/net/psforever/actors/session/SessionActor.scala b/src/main/scala/net/psforever/actors/session/SessionActor.scala
index c160bfdcc..b6373fcd5 100644
--- a/src/main/scala/net/psforever/actors/session/SessionActor.scala
+++ b/src/main/scala/net/psforever/actors/session/SessionActor.scala
@@ -1,6 +1,5 @@
package net.psforever.actors.session
-//language imports
import akka.actor.typed
import akka.actor.typed.receptionist.Receptionist
import akka.actor.typed.scaladsl.adapter._
@@ -8,19 +7,16 @@ import akka.actor.{Actor, ActorRef, Cancellable, MDCContextAware}
import akka.pattern.ask
import akka.util.Timeout
import java.util.concurrent.TimeUnit
-
import MDCContextAware.Implicits._
+import net.psforever.actors.net.MiddlewareActor
+import net.psforever.services.ServiceManager.Lookup
import net.psforever.objects.locker.LockerContainer
import org.log4s.MDC
-
import scala.collection.mutable
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Success
-import scodec.bits.ByteVector
-//project imports
-import net.psforever.login.{DropCryptoSession, DropSession, HelloFriend, RawPacket}
import net.psforever.login.WorldSession._
import net.psforever.objects._
import net.psforever.objects.avatar.{Avatar, Certification, Cosmetic, DeployableToolbox}
@@ -58,7 +54,6 @@ import net.psforever.objects.vehicles.Utility.InternalTelepad
import net.psforever.objects.vital._
import net.psforever.objects.zones.{Zone, ZoneHotSpotProjector, Zoning}
import net.psforever.packet._
-import net.psforever.packet.control._
import net.psforever.packet.game.{HotSpotInfo => PacketHotSpotInfo, _}
import net.psforever.packet.game.objectcreate._
import net.psforever.services.ServiceManager.LookupResult
@@ -133,7 +128,12 @@ object SessionActor {
* @param tickTime how long between each `tickAction` (ms);
* defaults to 250 milliseconds
*/
- final case class ProgressEvent(delta: Float, completionAction: () => Unit, tickAction: Float => Boolean, tickTime: Long = 250)
+ final case class ProgressEvent(
+ delta: Float,
+ completionAction: () => Unit,
+ tickAction: Float => Boolean,
+ tickTime: Long = 250
+ )
private final val zoningCountdownMessages: Seq[Int] = Seq(5, 10, 20)
@@ -159,14 +159,16 @@ object SessionActor {
private final case class LoadedRemoteProjectile(projectile_guid: PlanetSideGUID, projectile: Option[Projectile])
}
-class SessionActor extends Actor with MDCContextAware {
+class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], connectionId: String)
+ extends Actor
+ with MDCContextAware {
import SessionActor._
+ MDC("connectionId") = connectionId
+
private[this] val log = org.log4s.getLogger
private[this] val damageLog = org.log4s.getLogger(Damageable.LogChannel)
- var leftRef: ActorRef = ActorRef.noSender
- var rightRef: ActorRef = ActorRef.noSender
var avatarActor: typed.ActorRef[AvatarActor.Command] = context.spawnAnonymous(AvatarActor(context.self))
var chatActor: typed.ActorRef[ChatActor.Command] = context.spawnAnonymous(ChatActor(context.self, avatarActor))
var accountIntermediary: ActorRef = ActorRef.noSender
@@ -291,6 +293,19 @@ class SessionActor extends Actor with MDCContextAware {
def avatar: Avatar = _session.avatar
+ val serviceManager = ServiceManager.serviceManager
+ serviceManager ! Lookup("accountIntermediary")
+ serviceManager ! Lookup("accountPersistence")
+ serviceManager ! Lookup("taskResolver")
+ serviceManager ! Lookup("galaxy")
+ serviceManager ! Lookup("squad")
+ serviceManager ! Lookup("propertyOverrideManager")
+
+ ServiceManager.receptionist ! Receptionist.Find(
+ InterstellarClusterService.InterstellarClusterServiceKey,
+ context.self
+ )
+
override def postStop(): Unit = {
//normally, the player avatar persists a minute or so after disconnect; we are subject to the SessionReaper
clientKeepAlive.cancel()
@@ -322,40 +337,6 @@ class SessionActor extends Actor with MDCContextAware {
}
}
- def receive = Initializing
-
- def Initializing: Receive = {
- case HelloFriend(inSessionId, pipe) =>
- session = session.copy(id = inSessionId)
- leftRef = sender()
- if (pipe.hasNext) {
- rightRef = pipe.next()
- rightRef !> HelloFriend(session.id, pipe)
- } else {
- rightRef = sender()
- }
- context.become(Started)
- import net.psforever.services.ServiceManager.Lookup
- val serviceManager = ServiceManager.serviceManager
- serviceManager ! Lookup("accountIntermediary")
- serviceManager ! Lookup("accountPersistence")
- serviceManager ! Lookup("taskResolver")
- serviceManager ! Lookup("galaxy")
- serviceManager ! Lookup("squad")
- serviceManager ! Lookup("propertyOverrideManager")
-
- ServiceManager.receptionist ! Receptionist.Find(
- InterstellarClusterService.InterstellarClusterServiceKey,
- context.self
- )
-
- // avatarActor ! AvatarActor.Subscribe(context.self)
-
- case _ =>
- log.error("Unknown message")
- context.stop(self)
- }
-
def ValidObject(id: Int): Option[PlanetSideGameObject] = ValidObject(Some(PlanetSideGUID(id)))
def ValidObject(id: PlanetSideGUID): Option[PlanetSideGameObject] = ValidObject(Some(id))
@@ -389,7 +370,7 @@ class SessionActor extends Actor with MDCContextAware {
None
}
- def Started: Receive = {
+ def receive: Receive = {
case LookupResult("accountIntermediary", endpoint) =>
accountIntermediary = endpoint
log.info("ID: " + session.id + " Got account intermediary service " + endpoint)
@@ -434,10 +415,8 @@ class SessionActor extends Actor with MDCContextAware {
Deployables.InitializeDeployableQuantities(avatar)
cluster ! InterstellarClusterService.FilterZones(_ => true, context.self)
- case ControlPacket(_, ctrl) =>
- handleControlPkt(ctrl)
- case GamePacket(_, _, pkt) =>
- handleGamePkt(pkt)
+ case packet: PlanetSideGamePacket =>
+ handleGamePkt(packet)
case PokeClient() =>
sendResponse(KeepAliveMessage())
@@ -713,7 +692,6 @@ class SessionActor extends Actor with MDCContextAware {
case SquadResponse.Join(squad, positionsToUpdate, toChannel) =>
val leader = squad.Leader
val membershipPositions = positionsToUpdate map squad.Membership.zipWithIndex
- StartBundlingPackets()
membershipPositions.find({ case (member, _) => member.CharId == avatar.id }) match {
case Some((ourMember, ourIndex)) =>
//we are joining the squad
@@ -745,7 +723,7 @@ class SessionActor extends Actor with MDCContextAware {
unk7 = 0
)
) //repeat of our entry
- val playerGuid = player.GUID
+ val playerGuid = player.GUID
//turn lfs off
val factionChannel = s"${player.Faction}"
if (avatar.lookingForSquad) {
@@ -779,7 +757,6 @@ class SessionActor extends Actor with MDCContextAware {
}
)
}
- StopBundlingPackets()
//send an initial dummy update for map icon(s)
sendResponse(
SquadState(
@@ -806,7 +783,6 @@ class SessionActor extends Actor with MDCContextAware {
)
case SquadResponse.Leave(squad, positionsToUpdate) =>
- StartBundlingPackets()
positionsToUpdate.find({ case (member, _) => member == avatar.id }) match {
case Some((ourMember, ourIndex)) =>
//we are leaving the squad
@@ -847,7 +823,6 @@ class SessionActor extends Actor with MDCContextAware {
value = 0
)
}
- StopBundlingPackets()
case SquadResponse.AssignMember(squad, from_index, to_index) =>
//we've already swapped position internally; now we swap the cards
@@ -898,7 +873,7 @@ class SessionActor extends Actor with MDCContextAware {
SquadUIElement(element.name, element.index, entry.zone_number, entry.health, entry.armor, entry.pos)
entry
case (entry, element)
- if entry.health != element.health || entry.armor != element.armor || entry.pos != element.position =>
+ if entry.health != element.health || entry.armor != element.armor || entry.pos != element.position =>
//other elements that need to be updated
squadUI(entry.char_id) =
SquadUIElement(element.name, element.index, entry.zone_number, entry.health, entry.armor, entry.pos)
@@ -921,7 +896,6 @@ class SessionActor extends Actor with MDCContextAware {
sendResponse(SquadDefinitionActionMessage(PlanetSideGUID(0), 0, SquadAction.NoSquadSearchResults()))
case SquadResponse.InitWaypoints(char_id, waypoints) =>
- StartBundlingPackets()
waypoints.foreach {
case (waypoint_type, info, unk) =>
sendResponse(
@@ -933,7 +907,6 @@ class SessionActor extends Actor with MDCContextAware {
)
)
}
- StopBundlingPackets()
case SquadResponse.WaypointEvent(WaypointEventAction.Add, char_id, waypoint_type, _, Some(info), unk) =>
sendResponse(
@@ -1074,7 +1047,6 @@ class SessionActor extends Actor with MDCContextAware {
case SessionActor.FinalizeDeployable(obj: SensorDeployable, tool, index) =>
//motion alarm sensor and sensor disruptor
- StartBundlingPackets()
DeployableBuildActivity(obj)
continent.LocalEvents ! LocalServiceMessage(
continent.id,
@@ -1082,11 +1054,9 @@ class SessionActor extends Actor with MDCContextAware {
)
CommonDestroyConstructionItem(tool, index)
FindReplacementConstructionItem(tool, index)
- StopBundlingPackets()
case SessionActor.FinalizeDeployable(obj: BoomerDeployable, tool, index) =>
//boomers
- StartBundlingPackets()
DeployableBuildActivity(obj)
//TODO sufficiently delete the tool
sendResponse(ObjectDeleteMessage(tool.GUID, 0))
@@ -1103,26 +1073,20 @@ class SessionActor extends Actor with MDCContextAware {
//don't know where boomer trigger should go; drop it on the ground
taskResolver ! NewItemDrop(player, continent)(trigger)
}
- StopBundlingPackets()
case SessionActor.FinalizeDeployable(obj: ExplosiveDeployable, tool, index) =>
//mines
- StartBundlingPackets()
DeployableBuildActivity(obj)
CommonDestroyConstructionItem(tool, index)
FindReplacementConstructionItem(tool, index)
- StopBundlingPackets()
case SessionActor.FinalizeDeployable(obj: ComplexDeployable, tool, index) =>
//tank_traps, spitfires, deployable field turrets and the deployable_shield_generator
- StartBundlingPackets()
DeployableBuildActivity(obj)
CommonDestroyConstructionItem(tool, index)
FindReplacementConstructionItem(tool, index)
- StopBundlingPackets()
case SessionActor.FinalizeDeployable(obj: TelepadDeployable, tool, index) =>
- StartBundlingPackets()
if (obj.Health > 0) {
val guid = obj.GUID
//router telepad deployable
@@ -1142,7 +1106,6 @@ class SessionActor extends Actor with MDCContextAware {
obj.Router = routerGUID //necessary; forwards link to the router
DeployableBuildActivity(obj)
RemoveOldEquipmentFromInventory(player, taskResolver)(tool)
- StopBundlingPackets()
//it takes 60s for the telepad to become properly active
continent.LocalEvents ! LocalServiceMessage.Telepads(RouterTelepadActivation.AddTask(obj, continent))
}
@@ -1155,12 +1118,10 @@ class SessionActor extends Actor with MDCContextAware {
)
}
}
- StopBundlingPackets()
case SessionActor.FinalizeDeployable(obj: PlanetSideGameObject with Deployable, tool, index) =>
val guid = obj.GUID
val definition = obj.Definition
- StartBundlingPackets()
sendResponse(GenericObjectActionMessage(guid, 21)) //reset build cooldown
sendResponse(ObjectDeployedMessage.Failure(definition.Name))
log.warn(
@@ -1170,7 +1131,6 @@ class SessionActor extends Actor with MDCContextAware {
TryDropFDU(tool, index, obj.Position)
obj.Position = Vector3.Zero
continent.Deployables ! Zone.Deployable.Dismiss(obj)
- StopBundlingPackets()
//!!only dispatch Zone.Deployable.Dismiss from WorldSessionActor as cleanup if the target deployable was never fully introduced
case Zone.Deployable.DeployableIsDismissed(obj: TurretDeployable) =>
@@ -1182,7 +1142,6 @@ class SessionActor extends Actor with MDCContextAware {
case InterstellarClusterService.ZonesResponse(zones) =>
zones.foreach { zone =>
- Thread.sleep(connectionState)
val continentNumber = zone.Number
val popBO = 0
//TODO black ops test (partition)
@@ -1190,7 +1149,6 @@ class SessionActor extends Actor with MDCContextAware {
val popNC = zone.Players.count(_.faction == PlanetSideEmpire.NC)
val popVS = zone.Players.count(_.faction == PlanetSideEmpire.VS)
- StartBundlingPackets()
zone.Buildings.foreach({ case (id, building) => initBuilding(continentNumber, building.MapId, building) })
sendResponse(ZonePopulationUpdateMessage(continentNumber, 414, 138, popTR, 138, popNC, 138, popVS, 138, popBO))
if (continentNumber == 11)
@@ -1221,11 +1179,8 @@ class SessionActor extends Actor with MDCContextAware {
.map { spot => PacketHotSpotInfo(spot.DisplayLocation.x, spot.DisplayLocation.y, 40) }
)
) //normally set for all zones in bulk; should be fine manually updating per zone like this
-
- StopBundlingPackets()
}
LivePlayerList.Add(avatar.id, avatar)
- StartBundlingPackets()
//PropertyOverrideMessage
implicit val timeout = Timeout(1 seconds)
@@ -1270,7 +1225,6 @@ class SessionActor extends Actor with MDCContextAware {
)
}
}
- StopBundlingPackets()
case InterstellarClusterService.ZoneResponse(zone) =>
log.info(s"Zone ${zone.get.id} will now load")
@@ -1403,7 +1357,7 @@ class SessionActor extends Actor with MDCContextAware {
} else if (tplayer.isAlive) {
if (
zoneLoaded.contains(true) &&
- tplayer.HasGUID && tplayer.Actor != Default.Actor && (continent.GUID(tplayer.VehicleSeated) match {
+ tplayer.HasGUID && tplayer.Actor != Default.Actor && (continent.GUID(tplayer.VehicleSeated) match {
case Some(o: Vehicle) => o.HasGUID && o.Actor != Default.Actor && !o.Destroyed
case _ => true
})
@@ -1567,11 +1521,11 @@ class SessionActor extends Actor with MDCContextAware {
}
case msg @ Containable.ItemPutInSlot(
- _: PlanetSideServerObject with Container,
- _: Equipment,
- _: Int,
- _: Option[Equipment]
- ) =>
+ _: PlanetSideServerObject with Container,
+ _: Equipment,
+ _: Int,
+ _: Option[Equipment]
+ ) =>
log.info(s"$msg")
case msg @ Containable.CanNotPutItemInSlot(_: PlanetSideServerObject with Container, _: Equipment, _: Int) =>
@@ -1973,19 +1927,19 @@ class SessionActor extends Actor with MDCContextAware {
}
case AvatarResponse.PlayerState(
- pos,
- vel,
- yaw,
- pitch,
- yaw_upper,
- seq_time,
- is_crouching,
- is_jumping,
- jump_thrust,
- is_cloaking,
- spectating,
- weaponInHand
- ) =>
+ pos,
+ vel,
+ yaw,
+ pitch,
+ yaw_upper,
+ seq_time,
+ is_crouching,
+ is_jumping,
+ jump_thrust,
+ is_cloaking,
+ spectating,
+ weaponInHand
+ ) =>
if (tplayer_guid != guid) {
val now = System.currentTimeMillis()
val (location, time, distanceSq): (Vector3, Long, Float) = if (spectating) {
@@ -2105,7 +2059,6 @@ class SessionActor extends Actor with MDCContextAware {
drop,
delete
) =>
- StartBundlingPackets()
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, 4, armor))
if (tplayer_guid == target) {
@@ -2171,7 +2124,6 @@ class SessionActor extends Actor with MDCContextAware {
)
}
}
- StopBundlingPackets()
case AvatarResponse.ChangeLoadout(
target,
@@ -2186,7 +2138,6 @@ class SessionActor extends Actor with MDCContextAware {
inventory,
drops
) =>
- StartBundlingPackets()
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, 4, armor))
if (tplayer_guid == target) {
@@ -2214,7 +2165,6 @@ class SessionActor extends Actor with MDCContextAware {
old_holsters.foreach { case (_, guid) => sendResponse(ObjectDeleteMessage(guid, 0)) }
//redraw handled by callback
}
- StopBundlingPackets()
case _ => ;
}
@@ -2414,9 +2364,7 @@ class SessionActor extends Actor with MDCContextAware {
sendResponse(ChatMsg(ChatMessageType.UNK_229, false, "", msg, None))
case LocalResponse.RouterTelepadTransport(passenger_guid, src_guid, dest_guid) =>
- StartBundlingPackets()
UseRouterTelepadEffect(passenger_guid, src_guid, dest_guid)
- StopBundlingPackets()
case LocalResponse.SetEmpire(object_guid, empire) =>
sendResponse(SetEmpireMessage(object_guid, empire))
@@ -2816,18 +2764,18 @@ class SessionActor extends Actor with MDCContextAware {
}
case VehicleResponse.VehicleState(
- vehicle_guid,
- unk1,
- pos,
- ang,
- vel,
- unk2,
- unk3,
- unk4,
- wheel_direction,
- unk5,
- unk6
- ) =>
+ vehicle_guid,
+ unk1,
+ pos,
+ ang,
+ vel,
+ unk2,
+ unk3,
+ unk4,
+ wheel_direction,
+ unk5,
+ unk6
+ ) =>
if (tplayer_guid != guid) {
sendResponse(
VehicleStateMessage(vehicle_guid, unk1, pos, ang, vel, unk2, unk3, unk4, wheel_direction, unk5, unk6)
@@ -2921,7 +2869,6 @@ class SessionActor extends Actor with MDCContextAware {
//TODO when vehicle weapons can be changed without visual glitches, rewrite this
continent.GUID(target) match {
case Some(vehicle: Vehicle) =>
- StartBundlingPackets()
if (player.avatar.vehicle.contains(target)) {
//owner: must unregister old equipment, and register and install new equipment
(old_weapons ++ old_inventory).foreach {
@@ -2943,7 +2890,6 @@ class SessionActor extends Actor with MDCContextAware {
//observer: observe changes to external equipment
old_weapons.foreach { case (_, guid) => sendResponse(ObjectDeleteMessage(guid, 0)) }
}
- StopBundlingPackets()
case _ => ;
}
@@ -2961,10 +2907,10 @@ class SessionActor extends Actor with MDCContextAware {
* @return a tuple composed of an `ObjectAttachMessage` packet and a `CargoMountPointStatusMessage` packet
*/
def CargoMountBehaviorForUs(
- carrier: Vehicle,
- cargo: Vehicle,
- mountPoint: Int
- ): (ObjectAttachMessage, CargoMountPointStatusMessage) = {
+ carrier: Vehicle,
+ cargo: Vehicle,
+ mountPoint: Int
+ ): (ObjectAttachMessage, CargoMountPointStatusMessage) = {
val msgs @ (attachMessage, mountPointStatusMessage) = CargoBehavior.CargoMountMessages(carrier, cargo, mountPoint)
CargoMountMessagesForUs(attachMessage, mountPointStatusMessage)
msgs
@@ -2978,9 +2924,9 @@ class SessionActor extends Actor with MDCContextAware {
* @param mountPointStatusMessage a `CargoMountPointStatusMessage` packet suitable for initializing cargo operations
*/
def CargoMountMessagesForUs(
- attachMessage: ObjectAttachMessage,
- mountPointStatusMessage: CargoMountPointStatusMessage
- ): Unit = {
+ attachMessage: ObjectAttachMessage,
+ mountPointStatusMessage: CargoMountPointStatusMessage
+ ): Unit = {
sendResponse(attachMessage)
sendResponse(mountPointStatusMessage)
}
@@ -3009,7 +2955,12 @@ class SessionActor extends Actor with MDCContextAware {
* @param tickAction an optional action is is performed for each tick of progress;
* also performs a continuity check to determine if the process has been disrupted
*/
- def HandleProgressChange(delta: Float, completionAction: () => Unit, tickAction: Float => Boolean, tick: Long): Unit = {
+ def HandleProgressChange(
+ delta: Float,
+ completionAction: () => Unit,
+ tickAction: Float => Boolean,
+ tick: Long
+ ): Unit = {
progressBarUpdate.cancel()
progressBarValue match {
case Some(value) =>
@@ -3059,7 +3010,6 @@ class SessionActor extends Actor with MDCContextAware {
log.info(s"HandleSetCurrentAvatar - ${tplayer.Name}")
session = session.copy(player = tplayer)
val guid = tplayer.GUID
- StartBundlingPackets()
UpdateDeployableUIElements(Deployables.InitializeDeployableUIElements(avatar))
sendResponse(PlanetsideAttributeMessage(PlanetSideGUID(0), 75, 0))
sendResponse(SetCurrentAvatarMessage(guid, 0, 0))
@@ -3122,7 +3072,6 @@ class SessionActor extends Actor with MDCContextAware {
obj.Owner = guid
drawDeloyableIcon(obj)
})
- StopBundlingPackets()
drawDeloyableIcon = DontRedrawIcons
//assert or transfer vehicle ownership
@@ -3296,56 +3245,22 @@ class SessionActor extends Actor with MDCContextAware {
} yield player.get
}
- def handleControlPkt(pkt: PlanetSideControlPacket) = {
- pkt match {
- case sync @ ControlSync(diff, _, _, _, _, _, fa, fb) =>
- log.trace(s"SYNC: $sync")
- val nextDiff = if (diff == 65535) {
- 0
- } else {
- diff + 1
- }
- val serverTick = ServerTick
- sendResponse(ControlSyncResp(nextDiff, serverTick, fa, fb, fb, fa))
-
- case TeardownConnection(_) =>
- log.info("Good bye")
-
- case default =>
- log.warn(s"Unhandled ControlPacket $default")
- }
- }
-
- /**
- * Return a measure of server time as an unsigned 32-bit integer.
- * The server time started at 0 back at the beginning (POSIX time).
- * The server time will loop around to 0 again to maintain datatype integrity.
- * @see `Int.MaxValue`
- * @see `System.nanoTime`
- * @return a number that indicates server tick time
- */
- def ServerTick: Long = {
- serverTime = System.currentTimeMillis() & unsignedIntMaxValue
- serverTime
- }
-
def handleGamePkt(pkt: PlanetSideGamePacket) =
pkt match {
case ConnectToWorldRequestMessage(server, token, majorVersion, minorVersion, revision, buildDate, unk) =>
val clientVersion = s"Client Version: $majorVersion.$minorVersion.$revision, $buildDate"
log.info(s"New world login to $server with Token:$token. $clientVersion")
sendResponse(ChatMsg(ChatMessageType.CMT_CULLWATERMARK, false, "", "", None))
- Thread.sleep(40)
import scala.concurrent.ExecutionContext.Implicits.global
clientKeepAlive.cancel()
clientKeepAlive =
context.system.scheduler.scheduleWithFixedDelay(0 seconds, 500 milliseconds, self, PokeClient())
accountIntermediary ! RetrieveAccountData(token)
- case msg@MountVehicleCargoMsg(player_guid, cargo_guid, carrier_guid, unk4) =>
+ case msg @ MountVehicleCargoMsg(player_guid, cargo_guid, carrier_guid, unk4) =>
log.info(msg.toString)
(continent.GUID(cargo_guid), continent.GUID(carrier_guid)) match {
- case (Some(cargo : Vehicle), Some(carrier : Vehicle)) =>
+ case (Some(cargo: Vehicle), Some(carrier: Vehicle)) =>
carrier.CargoHolds.find({ case (_, hold) => !hold.isOccupied }) match {
case Some((mountPoint, _)) => //try begin the mount process
cargo.Actor ! CargoBehavior.CheckCargoMounting(carrier_guid, mountPoint, 0)
@@ -3361,24 +3276,24 @@ class SessionActor extends Actor with MDCContextAware {
case _ => ;
}
- case msg@DismountVehicleCargoMsg(player_guid, cargo_guid, bailed, requestedByPassenger, kicked) =>
+ case msg @ DismountVehicleCargoMsg(player_guid, cargo_guid, bailed, requestedByPassenger, kicked) =>
log.info(msg.toString)
//when kicked by carrier driver, player_guid will be PlanetSideGUID(0)
//when exiting of the cargo vehicle driver's own accord, player_guid will be the cargo vehicle driver
continent.GUID(cargo_guid) match {
- case Some(cargo : Vehicle) if !requestedByPassenger =>
+ case Some(cargo: Vehicle) if !requestedByPassenger =>
continent.GUID(cargo.MountedIn) match {
- case Some(carrier : Vehicle) =>
+ case Some(carrier: Vehicle) =>
CargoBehavior.HandleVehicleCargoDismount(continent, cargo_guid, bailed, requestedByPassenger, kicked)
case _ => ;
}
case _ => ;
}
- case msg@CharacterCreateRequestMessage(name, head, voice, gender, empire) =>
+ case msg @ CharacterCreateRequestMessage(name, head, voice, gender, empire) =>
avatarActor ! AvatarActor.CreateAvatar(name, head, voice, gender, empire)
- case msg@CharacterRequestMessage(charId, action) =>
+ case msg @ CharacterRequestMessage(charId, action) =>
action match {
case CharacterRequestAction.Delete =>
avatarActor ! AvatarActor.DeleteAvatar(charId.toInt)
@@ -3389,11 +3304,11 @@ class SessionActor extends Actor with MDCContextAware {
case KeepAliveMessage(_) =>
keepAliveFunc()
- case msg@BeginZoningMessage() =>
+ case msg @ BeginZoningMessage() =>
log.info("Reticulating splines ...")
zoneLoaded = None
- val continentId = continent.id
- val faction = player.Faction
+ val continentId = continent.id
+ val faction = player.Faction
val factionChannel = s"$faction"
continent.AvatarEvents ! Service.Join(continentId)
continent.AvatarEvents ! Service.Join(factionChannel)
@@ -3406,7 +3321,7 @@ class SessionActor extends Actor with MDCContextAware {
if (connectionState != 100) configZone(continent)
sendResponse(TimeOfDayMessage(1191182336))
//custom
- sendResponse(ReplicationStreamMessage(5, Some(6), Vector.empty)) //clear squad list
+ sendResponse(ReplicationStreamMessage(5, Some(6), Vector.empty)) //clear squad list
sendResponse(PlanetsideAttributeMessage(PlanetSideGUID(0), 112, 0)) // disable festive backpacks
//find and reclaim own deployables, if any
@@ -3435,7 +3350,7 @@ class SessionActor extends Actor with MDCContextAware {
)
})
turrets.foreach(obj => {
- val objGUID = obj.GUID
+ val objGUID = obj.GUID
val definition = obj.Definition
sendResponse(
ObjectCreateMessage(
@@ -3469,11 +3384,11 @@ class SessionActor extends Actor with MDCContextAware {
normal
.filter(obj =>
obj.Definition.DeployCategory == DeployableCategory.Sensors &&
- !obj.Destroyed &&
- (obj match {
- case jObj : JammableUnit => !jObj.Jammed;
- case _ => true
- })
+ !obj.Destroyed &&
+ (obj match {
+ case jObj: JammableUnit => !jObj.Jammed;
+ case _ => true
+ })
)
.foreach(obj => {
sendResponse(TriggerEffectMessage(obj.GUID, "on", true, 1000))
@@ -3540,7 +3455,7 @@ class SessionActor extends Actor with MDCContextAware {
(
a,
continent.GUID(player.VehicleSeated) match {
- case Some(vehicle : Vehicle) if vehicle.PassengerInSeat(player).isDefined =>
+ case Some(vehicle: Vehicle) if vehicle.PassengerInSeat(player).isDefined =>
b.partition {
_.GUID != vehicle.GUID
}
@@ -3558,7 +3473,7 @@ class SessionActor extends Actor with MDCContextAware {
val allActiveVehicles = vehicles ++ usedVehicle
//active vehicles (and some wreckage)
vehicles.foreach(vehicle => {
- val vguid = vehicle.GUID
+ val vguid = vehicle.GUID
val vdefinition = vehicle.Definition
sendResponse(
ObjectCreateMessage(vdefinition.ObjectId, vguid, vdefinition.Packet.ConstructorData(vehicle).get)
@@ -3568,7 +3483,7 @@ class SessionActor extends Actor with MDCContextAware {
.filter({ case (index, seat) => seat.isOccupied && live.contains(seat.Occupant.get) && index > 0 })
.foreach({
case (index, seat) =>
- val targetPlayer = seat.Occupant.get
+ val targetPlayer = seat.Occupant.get
val targetDefiniton = targetPlayer.avatar.definition
sendResponse(
ObjectCreateMessage(
@@ -3596,7 +3511,7 @@ class SessionActor extends Actor with MDCContextAware {
})
.foreach({
case (index, seat) =>
- val targetPlayer = seat.Occupant.get
+ val targetPlayer = seat.Occupant.get
val targetDefinition = targetPlayer.avatar.definition
sendResponse(
ObjectCreateMessage(
@@ -3650,9 +3565,9 @@ class SessionActor extends Actor with MDCContextAware {
//special effects
sendResponse(PlanetsideAttributeMessage(obj.GUID, 52, 1)) // ant panel glow
Vehicles.FindANTChargingSource(obj, None).orElse(Vehicles.FindANTDischargingTarget(obj, None)) match {
- case Some(silo : ResourceSilo) =>
+ case Some(silo: ResourceSilo) =>
sendResponse(PlanetsideAttributeMessage(silo.GUID, 49, 1)) // silo orb particle effect
- case Some(_ : WarpGate) =>
+ case Some(_: WarpGate) =>
sendResponse(PlanetsideAttributeMessage(obj.GUID, 49, 1)) // ant orb particle effect
case _ => ;
}
@@ -3669,7 +3584,7 @@ class SessionActor extends Actor with MDCContextAware {
case ((terminal_guid, interface_guid)) =>
val parent_guid = PlanetSideGUID(terminal_guid)
continent.GUID(interface_guid) match {
- case Some(obj : Terminal) =>
+ case Some(obj: Terminal) =>
val objDef = obj.Definition
sendResponse(
ObjectCreateMessage(
@@ -3683,7 +3598,7 @@ class SessionActor extends Actor with MDCContextAware {
}
//seat terminal occupants
continent.GUID(terminal_guid) match {
- case Some(obj : Mountable) =>
+ case Some(obj: Mountable) =>
obj.Seats(0).Occupant match {
case Some(targetPlayer) =>
val targetDefinition = targetPlayer.avatar.definition
@@ -3705,12 +3620,12 @@ class SessionActor extends Actor with MDCContextAware {
continent.map.turretToWeapon
.map { case ((turret_guid, _)) => continent.GUID(turret_guid) }
.collect {
- case Some(turret : FacilityTurret) =>
+ case Some(turret: FacilityTurret) =>
val pguid = turret.GUID
//attached weapon
if (!turret.isUpgrading) {
turret.ControlledWeapon(wepNumber = 1) match {
- case Some(obj : Tool) =>
+ case Some(obj: Tool) =>
val objDef = obj.Definition
sendResponse(
ObjectCreateMessage(
@@ -3766,7 +3681,7 @@ class SessionActor extends Actor with MDCContextAware {
//log.info(s"$msg")
persist()
turnCounterFunc(avatar_guid)
- val isMoving = WorldEntity.isMoving(vel)
+ val isMoving = WorldEntity.isMoving(vel)
val isMovingPlus = isMoving || is_jumping || jump_thrust
if (isMovingPlus) {
CancelZoningProcessWithDescriptiveReason("cancel_motion")
@@ -3791,10 +3706,12 @@ class SessionActor extends Actor with MDCContextAware {
}
accessedContainer match {
case Some(veh: Vehicle) =>
- if (isMoving || veh.isMoving(1) || Vector3.DistanceSquared(
- player.Position,
- veh.TrunkLocation
- ) > 9) {
+ if (
+ isMoving || veh.isMoving(1) || Vector3.DistanceSquared(
+ player.Position,
+ veh.TrunkLocation
+ ) > 9
+ ) {
val guid = player.GUID
sendResponse(UnuseItemMessage(guid, veh.GUID))
sendResponse(UnuseItemMessage(guid, guid))
@@ -3878,18 +3795,18 @@ class SessionActor extends Actor with MDCContextAware {
}
case msg @ VehicleStateMessage(
- vehicle_guid,
- unk1,
- pos,
- ang,
- vel,
- flying,
- unk6,
- unk7,
- wheels,
- is_decelerating,
- is_cloaked
- ) =>
+ vehicle_guid,
+ unk1,
+ pos,
+ ang,
+ vel,
+ flying,
+ unk6,
+ unk7,
+ wheels,
+ is_decelerating,
+ is_cloaked
+ ) =>
//log.info(s"$msg")
GetVehicleAndSeat() match {
case (Some(obj), Some(0)) =>
@@ -4127,7 +4044,7 @@ class SessionActor extends Actor with MDCContextAware {
//the decimator does not send a ChangeFireState_Start on the last shot
if (
tool.Definition == GlobalDefinitions.phoenix &&
- tool.Projectile != GlobalDefinitions.phoenix_missile_guided_projectile
+ tool.Projectile != GlobalDefinitions.phoenix_missile_guided_projectile
) {
//suppress the decimator's alternate fire mode, however
continent.AvatarEvents ! AvatarServiceMessage(
@@ -4155,7 +4072,7 @@ class SessionActor extends Actor with MDCContextAware {
weapon match {
case Some(tool: Tool) =>
tool.FireMode match {
- case mode : ChargeFireModeDefinition =>
+ case mode: ChargeFireModeDefinition =>
sendResponse(QuantityUpdateMessage(tool.AmmoSlot.Box.GUID, tool.Magazine))
case _ => ;
}
@@ -4258,12 +4175,12 @@ class SessionActor extends Actor with MDCContextAware {
}
val sumReloadValue: Int = box.Capacity + tailReloadValue
val actualReloadValue = (if (sumReloadValue <= reloadValue) {
- deleteFunc(box)
- sumReloadValue
- } else {
- modifyFunc(box, reloadValue - tailReloadValue)
- reloadValue
- }) + currentMagazine
+ deleteFunc(box)
+ sumReloadValue
+ } else {
+ modifyFunc(box, reloadValue - tailReloadValue)
+ reloadValue
+ }) + currentMagazine
log.info(s"ReloadMessage: success, $tool <- $actualReloadValue ${tool.AmmoType}")
tool.Magazine = actualReloadValue
sendResponse(ReloadMessage(item_guid, actualReloadValue, unk1))
@@ -4471,10 +4388,10 @@ class SessionActor extends Actor with MDCContextAware {
log.info(s"MoveItem: $msg")
(continent.GUID(source_guid), continent.GUID(destination_guid), ValidObject(item_guid)) match {
case (
- Some(source: PlanetSideServerObject with Container),
- Some(destination: PlanetSideServerObject with Container),
- Some(item: Equipment)
- ) =>
+ Some(source: PlanetSideServerObject with Container),
+ Some(destination: PlanetSideServerObject with Container),
+ Some(item: Equipment)
+ ) =>
ContainableMoveItem(taskResolver, player.Name, source, destination, item, dest)
case (None, _, _) =>
log.error(s"MoveItem: wanted to move $item_guid from $source_guid, but could not find source object")
@@ -4546,18 +4463,18 @@ class SessionActor extends Actor with MDCContextAware {
}
case msg @ UseItemMessage(
- avatar_guid,
- item_used_guid,
- object_guid,
- unk2,
- unk3,
- unk4,
- unk5,
- unk6,
- unk7,
- unk8,
- itemType
- ) =>
+ avatar_guid,
+ item_used_guid,
+ object_guid,
+ unk2,
+ unk3,
+ unk4,
+ unk5,
+ unk6,
+ unk7,
+ unk8,
+ itemType
+ ) =>
//log.info("UseItem: " + msg)
// TODO: Not all fields in the response are identical to source in real packet logs (but seems to be ok)
// TODO: Not all incoming UseItemMessage's respond with another UseItemMessage (i.e. doors only send out GenericObjectStateMsg)
@@ -4834,8 +4751,8 @@ class SessionActor extends Actor with MDCContextAware {
//access to trunk
if (
obj.AccessingTrunk.isEmpty &&
- (!obj.PermissionGroup(AccessPermissionGroup.Trunk.id).contains(VehicleLockState.Locked) || obj.Owner
- .contains(player.GUID))
+ (!obj.PermissionGroup(AccessPermissionGroup.Trunk.id).contains(VehicleLockState.Locked) || obj.Owner
+ .contains(player.GUID))
) {
CancelZoningProcessWithDescriptiveReason("cancel_use")
obj.AccessingTrunk = player.GUID
@@ -4867,7 +4784,7 @@ class SessionActor extends Actor with MDCContextAware {
terminal.Actor ! CommonMessages.Use(player, Some(item))
case None
- if terminal.Owner == Building.NoBuilding || terminal.Faction == player.Faction || terminal.HackedBy.nonEmpty =>
+ if terminal.Owner == Building.NoBuilding || terminal.Faction == player.Faction || terminal.HackedBy.nonEmpty =>
val tdef = terminal.Definition
if (tdef.isInstanceOf[MatrixTerminalDefinition]) {
//TODO matrix spawn point; for now, just blindly bind to show work (and hope nothing breaks)
@@ -4877,7 +4794,7 @@ class SessionActor extends Actor with MDCContextAware {
)
} else if (
tdef == GlobalDefinitions.multivehicle_rearm_terminal || tdef == GlobalDefinitions.bfr_rearm_terminal ||
- tdef == GlobalDefinitions.air_rearm_terminal || tdef == GlobalDefinitions.ground_rearm_terminal
+ tdef == GlobalDefinitions.air_rearm_terminal || tdef == GlobalDefinitions.ground_rearm_terminal
) {
FindLocalVehicle match {
case Some(vehicle) =>
@@ -5264,19 +5181,19 @@ class SessionActor extends Actor with MDCContextAware {
}
case msg @ WeaponFireMessage(
- seq_time,
- weapon_guid,
- projectile_guid,
- shot_origin,
- unk1,
- unk2,
- unk3,
- unk4,
- unk5,
- unk6,
- unk7
- ) =>
- log.info(s"WeaponFire: $msg")
+ seq_time,
+ weapon_guid,
+ projectile_guid,
+ shot_origin,
+ unk1,
+ unk2,
+ unk3,
+ unk4,
+ unk5,
+ unk6,
+ unk7
+ ) =>
+ log.debug(s"WeaponFire: $msg")
HandleWeaponFire(weapon_guid, projectile_guid, shot_origin)
case msg @ WeaponLazeTargetPositionMessage(weapon, pos1, pos2) =>
@@ -5298,14 +5215,14 @@ class SessionActor extends Actor with MDCContextAware {
}
case msg @ HitMessage(
- seq_time,
- projectile_guid,
- unk1,
- hit_info,
- unk2,
- unk3,
- unk4
- ) =>
+ seq_time,
+ projectile_guid,
+ unk1,
+ hit_info,
+ unk2,
+ unk3,
+ unk4
+ ) =>
log.info(s"Hit: $msg")
//find defined projectile
FindProjectileEntry(projectile_guid) match {
@@ -5372,15 +5289,15 @@ class SessionActor extends Actor with MDCContextAware {
}
case msg @ SplashHitMessage(
- seq_time,
- projectile_guid,
- explosion_pos,
- direct_victim_uid,
- unk3,
- projectile_vel,
- unk4,
- targets
- ) =>
+ seq_time,
+ projectile_guid,
+ explosion_pos,
+ direct_victim_uid,
+ unk3,
+ projectile_vel,
+ unk4,
+ targets
+ ) =>
log.info(s"Splash: $msg")
FindProjectileEntry(projectile_guid) match {
case Some(projectile) =>
@@ -5388,8 +5305,7 @@ class SessionActor extends Actor with MDCContextAware {
projectile.Position = explosion_pos
projectile.Velocity = projectile_vel
val (resolution1, resolution2) = profile.Aggravated match {
- case Some(_)
- if profile.ProjectileDamageTypes.contains(DamageType.Aggravated) =>
+ case Some(_) if profile.ProjectileDamageTypes.contains(DamageType.Aggravated) =>
(ProjectileResolution.AggravatedDirect, ProjectileResolution.AggravatedSplash)
case _ =>
(ProjectileResolution.Splash, ProjectileResolution.Splash)
@@ -5459,11 +5375,11 @@ class SessionActor extends Actor with MDCContextAware {
if (deadState != DeadState.RespawnTime) {
continent.Buildings.values.find(building => building.GUID == building_guid) match {
case Some(wg: WarpGate) if (wg.Active && (GetKnownVehicleAndSeat() match {
- case (Some(vehicle), _) =>
- wg.Definition.VehicleAllowance && !wg.Definition.NoWarp.contains(vehicle.Definition)
- case _ =>
- true
- })) =>
+ case (Some(vehicle), _) =>
+ wg.Definition.VehicleAllowance && !wg.Definition.NoWarp.contains(vehicle.Definition)
+ case _ =>
+ true
+ })) =>
deadState = DeadState.RespawnTime
cluster ! InterstellarClusterService.GetSpawnPoint(
destinationZoneGuid.guid,
@@ -5621,17 +5537,17 @@ class SessionActor extends Actor with MDCContextAware {
log.debug("Ouch! " + msg)
case msg @ BugReportMessage(
- version_major,
- version_minor,
- version_date,
- bug_type,
- repeatable,
- location,
- zone,
- pos,
- summary,
- desc
- ) =>
+ version_major,
+ version_minor,
+ version_date,
+ bug_type,
+ repeatable,
+ location,
+ zone,
+ pos,
+ summary,
+ desc
+ ) =>
log.info("BugReportMessage: " + msg)
case msg @ BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
@@ -6159,24 +6075,24 @@ class SessionActor extends Actor with MDCContextAware {
}
def DisplayContainerContents(containerId: PlanetSideGUID, container: Container): Unit = {
- container.Inventory.Items.foreach(entry => {
- val obj = entry.obj
- val objDef = obj.Definition
- sendResponse(
- ObjectCreateDetailedMessage(
- objDef.ObjectId,
- obj.GUID,
- ObjectCreateMessageParent(containerId, entry.start),
- objDef.Packet.DetailedConstructorData(obj).get
- )
- )
- })
+ container.Inventory.Items.foreach(entry => {
+ val obj = entry.obj
+ val objDef = obj.Definition
+ sendResponse(
+ ObjectCreateDetailedMessage(
+ objDef.ObjectId,
+ obj.GUID,
+ ObjectCreateMessageParent(containerId, entry.start),
+ objDef.Packet.DetailedConstructorData(obj).get
+ )
+ )
+ })
}
def UnaccessContainer(): Unit = {
accessedContainer match {
case Some(container) => UnaccessContainer(container)
- case _ => ;
+ case _ => ;
}
}
@@ -6205,7 +6121,7 @@ class SessionActor extends Actor with MDCContextAware {
*/
def UnaccessVehicleContainer(vehicle: Vehicle): Unit = {
accessedContainer = None
- if(vehicle.AccessingTrunk.contains(player.GUID)) {
+ if (vehicle.AccessingTrunk.contains(player.GUID)) {
vehicle.AccessingTrunk = None
}
UnaccessVehicleContainerChannel(vehicle)
@@ -6393,7 +6309,7 @@ class SessionActor extends Actor with MDCContextAware {
sendResponse(ObjectDetachMessage(tool.GUID, previousBox.GUID, Vector3.Zero, 0f))
sendResponse(ObjectDetachMessage(player.GUID, box.GUID, Vector3.Zero, 0f))
obj.Inventory -= x.start //remove replacement ammo from inventory
- val ammoSlotIndex = tool.FireMode.AmmoSlotIndex
+ val ammoSlotIndex = tool.FireMode.AmmoSlotIndex
tool.AmmoSlots(ammoSlotIndex).Box = box //put replacement ammo in tool
sendResponse(ObjectAttachMessage(tool.GUID, box.GUID, ammoSlotIndex))
@@ -6418,16 +6334,16 @@ class SessionActor extends Actor with MDCContextAware {
//handle inventory contents
box.Capacity = (if (sumReloadValue <= fullMagazine) {
- sumReloadValue
- } else {
- val splitReloadAmmo: Int = sumReloadValue - fullMagazine
- log.info(
- s"ChangeAmmo: taking ${originalBoxCapacity - splitReloadAmmo} from a box of ${originalBoxCapacity} $requestedAmmoType"
- )
- val boxForInventory = AmmoBox(box.Definition, splitReloadAmmo)
- taskResolver ! stowNewFunc(boxForInventory)
- fullMagazine
- })
+ sumReloadValue
+ } else {
+ val splitReloadAmmo: Int = sumReloadValue - fullMagazine
+ log.info(
+ s"ChangeAmmo: taking ${originalBoxCapacity - splitReloadAmmo} from a box of ${originalBoxCapacity} $requestedAmmoType"
+ )
+ val boxForInventory = AmmoBox(box.Definition, splitReloadAmmo)
+ taskResolver ! stowNewFunc(boxForInventory)
+ fullMagazine
+ })
sendResponse(
InventoryStateMessage(box.GUID, tool.GUID, box.Capacity)
) //should work for both players and vehicles
@@ -6541,12 +6457,12 @@ class SessionActor extends Actor with MDCContextAware {
else { xs.map(_.obj.asInstanceOf[Tool].Magazine).reduce(_ + _) }
val sumReloadValue: Int = box.Magazine + tailReloadValue
val actualReloadValue = (if (sumReloadValue <= 3) {
- RemoveOldEquipmentFromInventory(player, taskResolver)(x.obj)
- sumReloadValue
- } else {
- ModifyAmmunition(player)(box.AmmoSlot.Box, 3 - tailReloadValue)
- 3
- })
+ RemoveOldEquipmentFromInventory(player, taskResolver)(x.obj)
+ sumReloadValue
+ } else {
+ ModifyAmmunition(player)(box.AmmoSlot.Box, 3 - tailReloadValue)
+ 3
+ })
log.info(s"found $actualReloadValue more $ammoType grenades to throw")
ModifyAmmunition(player)(
tool.AmmoSlot.Box,
@@ -6568,8 +6484,8 @@ class SessionActor extends Actor with MDCContextAware {
* the second value is the slot position of the object
*/
def FindInLocalContainer(
- object_guid: PlanetSideGUID
- )(parent: PlanetSideServerObject with Container): Option[(PlanetSideServerObject with Container, Option[Int])] = {
+ object_guid: PlanetSideGUID
+ )(parent: PlanetSideServerObject with Container): Option[(PlanetSideServerObject with Container, Option[Int])] = {
val slot: Option[Int] = parent.Find(object_guid)
slot match {
case place @ Some(_) =>
@@ -6586,10 +6502,10 @@ class SessionActor extends Actor with MDCContextAware {
* @param reason a string explaining why the state can not or will not change
*/
def CanNotChangeDeployment(
- obj: PlanetSideServerObject with Deployment,
- state: DriveState.Value,
- reason: String
- ): Unit = {
+ obj: PlanetSideServerObject with Deployment,
+ state: DriveState.Value,
+ reason: String
+ ): Unit = {
val mobileShift: String = if (obj.DeploymentState != DriveState.Mobile) {
obj.DeploymentState = DriveState.Mobile
sendResponse(DeployRequestMessage(player.GUID, obj.GUID, DriveState.Mobile, 0, false, Vector3.Zero))
@@ -6711,7 +6627,6 @@ class SessionActor extends Actor with MDCContextAware {
case obj if obj.Destroyed => configAmenityAsDestroyed(obj)
case obj => configAmenityAsWorking(obj)
}
- Thread.sleep(connectionState)
})
}
@@ -6879,10 +6794,10 @@ class SessionActor extends Actor with MDCContextAware {
accessedContainer match {
case Some(v: Vehicle) =>
val vguid = v.GUID
- if(v.AccessingTrunk.contains(player.GUID)) {
- if(player.VehicleSeated.contains(vguid)) {
+ if (v.AccessingTrunk.contains(player.GUID)) {
+ if (player.VehicleSeated.contains(vguid)) {
v.AccessingTrunk = None //player is seated; just stop accessing trunk
- if(player.isAlive) {
+ if (player.isAlive) {
sendResponse(UnuseItemMessage(player.GUID, vguid))
}
} else {
@@ -6892,7 +6807,7 @@ class SessionActor extends Actor with MDCContextAware {
case Some(o) =>
UnaccessContainer(o)
- if(player.isAlive) {
+ if (player.isAlive) {
sendResponse(UnuseItemMessage(player.GUID, o.GUID))
}
@@ -7041,10 +6956,10 @@ class SessionActor extends Actor with MDCContextAware {
* `(None, None)`, otherwise (even if the vehicle can be determined)
*/
def GetMountableAndSeat(
- direct: Option[PlanetSideGameObject with Mountable],
- occupant: Player,
- zone: Zone
- ): (Option[PlanetSideGameObject with Mountable], Option[Int]) =
+ direct: Option[PlanetSideGameObject with Mountable],
+ occupant: Player,
+ zone: Zone
+ ): (Option[PlanetSideGameObject with Mountable], Option[Int]) =
direct.orElse(zone.GUID(occupant.VehicleSeated)) match {
case Some(obj: PlanetSideGameObject with Mountable) =>
obj.PassengerInSeat(occupant) match {
@@ -7721,11 +7636,11 @@ class SessionActor extends Actor with MDCContextAware {
* @return the projectile
*/
def ResolveProjectileEntry(
- projectile_guid: PlanetSideGUID,
- resolution: ProjectileResolution.Value,
- target: PlanetSideGameObject with FactionAffinity with Vitality,
- pos: Vector3
- ): Option[ResolvedProjectile] = {
+ projectile_guid: PlanetSideGUID,
+ resolution: ProjectileResolution.Value,
+ target: PlanetSideGameObject with FactionAffinity with Vitality,
+ pos: Vector3
+ ): Option[ResolvedProjectile] = {
FindProjectileEntry(projectile_guid) match {
case Some(projectile) =>
ResolveProjectileEntry(projectile, resolution, target, pos)
@@ -7743,12 +7658,12 @@ class SessionActor extends Actor with MDCContextAware {
* @return a copy of the projectile
*/
def ResolveProjectileEntry(
- projectile: Projectile,
- index: Int,
- resolution: ProjectileResolution.Value,
- target: PlanetSideGameObject with FactionAffinity with Vitality,
- pos: Vector3
- ): Option[ResolvedProjectile] = {
+ projectile: Projectile,
+ index: Int,
+ resolution: ProjectileResolution.Value,
+ target: PlanetSideGameObject with FactionAffinity with Vitality,
+ pos: Vector3
+ ): Option[ResolvedProjectile] = {
if (!projectiles(index).contains(projectile)) {
log.error(s"expected projectile could not be found at $index; can not resolve")
None
@@ -7764,28 +7679,27 @@ class SessionActor extends Actor with MDCContextAware {
* @return a copy of the projectile
*/
def ResolveProjectileEntry(
- projectile: Projectile,
- resolution: ProjectileResolution.Value,
- target: PlanetSideGameObject with FactionAffinity with Vitality,
- pos: Vector3
- ): Option[ResolvedProjectile] = {
+ projectile: Projectile,
+ resolution: ProjectileResolution.Value,
+ target: PlanetSideGameObject with FactionAffinity with Vitality,
+ pos: Vector3
+ ): Option[ResolvedProjectile] = {
if (projectile.isMiss) {
log.error("expected projectile was already counted as a missed shot; can not resolve any further")
None
} else {
projectile.Resolve()
- val outProjectile = if(projectile.profile.ProjectileDamageTypes.contains(DamageType.Aggravated)) {
+ val outProjectile = if (projectile.profile.ProjectileDamageTypes.contains(DamageType.Aggravated)) {
val quality = projectile.profile.Aggravated match {
case Some(aggravation)
- if aggravation.targets.exists(validation => validation.test(target)) &&
- aggravation.info.exists(_.damage_type == AggravatedDamage.basicDamageType(resolution)) =>
+ if aggravation.targets.exists(validation => validation.test(target)) &&
+ aggravation.info.exists(_.damage_type == AggravatedDamage.basicDamageType(resolution)) =>
ProjectileQuality.AggravatesTarget
case _ =>
ProjectileQuality.Normal
}
projectile.quality(quality)
- }
- else {
+ } else {
projectile
}
Some(ResolvedProjectile(resolution, outProjectile, SourceEntry(target), target.DamageModel, pos))
@@ -7874,11 +7788,11 @@ class SessionActor extends Actor with MDCContextAware {
* @return a `DestroyDisplayMessage` packet that is properly formatted
*/
def DestroyDisplayMessage(
- killer: SourceEntry,
- victim: SourceEntry,
- method: Int,
- unk: Int = 121
- ): DestroyDisplayMessage = {
+ killer: SourceEntry,
+ victim: SourceEntry,
+ method: Int,
+ unk: Int = 121
+ ): DestroyDisplayMessage = {
val killer_seated = killer match {
case obj: PlayerSource => obj.Seated
case _ => false
@@ -8038,9 +7952,9 @@ class SessionActor extends Actor with MDCContextAware {
* @return `true`, if the desired certification requirements are met; `false`, otherwise
*/
def ConstructionItemPermissionComparison(
- sample: Set[Certification],
- test: Set[Certification]
- ): Boolean = {
+ sample: Set[Certification],
+ test: Set[Certification]
+ ): Boolean = {
import Certification._
val engineeringCerts: Set[Certification] = Set(AssaultEngineering, FortificationEngineering)
val testDiff: Set[Certification] = test diff (engineeringCerts ++ Set(AdvancedEngineering))
@@ -8185,10 +8099,10 @@ class SessionActor extends Actor with MDCContextAware {
* `false`, otherwise
*/
def SafelyRemoveConstructionItemFromSlot(
- tool: ConstructionItem,
- index: Int,
- logDecorator: String = "SafelyRemoveConstructionItemFromSlot"
- ): Boolean = {
+ tool: ConstructionItem,
+ index: Int,
+ logDecorator: String = "SafelyRemoveConstructionItemFromSlot"
+ ): Boolean = {
if ({
val holster = player.Slot(index)
if (holster.Equipment.contains(tool)) {
@@ -8288,7 +8202,7 @@ class SessionActor extends Actor with MDCContextAware {
*/
def FindEquipmentToDelete(object_guid: PlanetSideGUID, obj: Equipment): Boolean = {
val findFunc
- : PlanetSideServerObject with Container => Option[(PlanetSideServerObject with Container, Option[Int])] =
+ : PlanetSideServerObject with Container => Option[(PlanetSideServerObject with Container, Option[Int])] =
FindInLocalContainer(object_guid)
findFunc(player)
@@ -8335,7 +8249,6 @@ class SessionActor extends Actor with MDCContextAware {
* @param pos the previous position of the deployable
*/
def DeconstructDeployable(obj: PlanetSideGameObject with Deployable, guid: PlanetSideGUID, pos: Vector3): Unit = {
- StartBundlingPackets()
sendResponse(SetEmpireMessage(guid, PlanetSideEmpire.NEUTRAL)) //for some, removes the green marker circle
sendResponse(ObjectDeleteMessage(guid, 0))
if (player.Faction == obj.Faction) {
@@ -8346,7 +8259,6 @@ class SessionActor extends Actor with MDCContextAware {
)
)
}
- StopBundlingPackets()
}
/**
@@ -8358,13 +8270,12 @@ class SessionActor extends Actor with MDCContextAware {
* @param deletionType the value passed to `ObjectDeleteMessage` concerning the deconstruction animation
*/
def DeconstructDeployable(
- obj: PlanetSideGameObject with Deployable,
- guid: PlanetSideGUID,
- pos: Vector3,
- orient: Vector3,
- deletionType: Int
- ): Unit = {
- StartBundlingPackets()
+ obj: PlanetSideGameObject with Deployable,
+ guid: PlanetSideGUID,
+ pos: Vector3,
+ orient: Vector3,
+ deletionType: Int
+ ): Unit = {
sendResponse(SetEmpireMessage(guid, PlanetSideEmpire.NEUTRAL)) //for some, removes the green marker circle
sendResponse(TriggerEffectMessage("spawn_object_failed_effect", pos, orient))
sendResponse(PlanetsideAttributeMessage(guid, 29, 1)) //make deployable vanish
@@ -8377,7 +8288,6 @@ class SessionActor extends Actor with MDCContextAware {
)
)
}
- StopBundlingPackets()
}
/**
@@ -8779,7 +8689,6 @@ class SessionActor extends Actor with MDCContextAware {
* if absent, the knowable endpoint is deleted from the client reflexively
*/
def ToggleTeleportSystem(router: Vehicle, systemPlan: Option[(Utility.InternalTelepad, TelepadDeployable)]): Unit = {
- StartBundlingPackets()
systemPlan match {
case Some((internalTelepad, remoteTelepad)) =>
LinkRouterToRemoteTelepad(router, internalTelepad, remoteTelepad)
@@ -8790,7 +8699,6 @@ class SessionActor extends Actor with MDCContextAware {
case _ => ;
}
}
- StopBundlingPackets()
}
/**
@@ -8801,10 +8709,10 @@ class SessionActor extends Actor with MDCContextAware {
* @param remoteTelepad the endpoint of the teleportation system that exists in the environment
*/
def LinkRouterToRemoteTelepad(
- router: Vehicle,
- internalTelepad: Utility.InternalTelepad,
- remoteTelepad: TelepadDeployable
- ): Unit = {
+ router: Vehicle,
+ internalTelepad: Utility.InternalTelepad,
+ remoteTelepad: TelepadDeployable
+ ): Unit = {
internalTelepad.Telepad = remoteTelepad.GUID //necessary; backwards link to the (new) telepad
CreateRouterInternalTelepad(router, internalTelepad)
LinkRemoteTelepad(remoteTelepad.GUID)
@@ -8865,12 +8773,12 @@ class SessionActor extends Actor with MDCContextAware {
* @param dest the destination of the teleportation (where the player is going)
*/
def UseRouterTelepadSystem(
- router: Vehicle,
- internalTelepad: InternalTelepad,
- remoteTelepad: TelepadDeployable,
- src: PlanetSideGameObject with TelepadLike,
- dest: PlanetSideGameObject with TelepadLike
- ) = {
+ router: Vehicle,
+ internalTelepad: InternalTelepad,
+ remoteTelepad: TelepadDeployable,
+ src: PlanetSideGameObject with TelepadLike,
+ dest: PlanetSideGameObject with TelepadLike
+ ) = {
val time = System.nanoTime
if (
time - recentTeleportAttempt > (2 seconds).toNanos && router.DeploymentState == DriveState.Deployed && internalTelepad.Active && remoteTelepad.Active
@@ -8878,10 +8786,8 @@ class SessionActor extends Actor with MDCContextAware {
val pguid = player.GUID
val sguid = src.GUID
val dguid = dest.GUID
- StartBundlingPackets()
sendResponse(PlayerStateShiftMessage(ShiftState(0, dest.Position, player.Orientation.z)))
UseRouterTelepadEffect(pguid, sguid, dguid)
- StopBundlingPackets()
continent.LocalEvents ! LocalServiceMessage(
continent.id,
LocalAction.RouterTelepadTransport(pguid, pguid, sguid, dguid)
@@ -9119,7 +9025,7 @@ class SessionActor extends Actor with MDCContextAware {
// Charge
else if (
player.Capacitor < player.ExoSuitDef.MaxCapacitor
- && (player.CapacitorState == CapacitorStateType.Idle || player.CapacitorState == CapacitorStateType.Charging || (player.CapacitorState == CapacitorStateType.ChargeDelay && System
+ && (player.CapacitorState == CapacitorStateType.Idle || player.CapacitorState == CapacitorStateType.Charging || (player.CapacitorState == CapacitorStateType.ChargeDelay && System
.currentTimeMillis() - player.CapacitorLastUsedMillis > player.ExoSuitDef.CapacitorRechargeDelayMillis))
) {
if (player.CapacitorState == CapacitorStateType.Charging) {
@@ -9253,10 +9159,10 @@ class SessionActor extends Actor with MDCContextAware {
}
def CheckForHitPositionDiscrepancy(
- projectile_guid: PlanetSideGUID,
- hitPos: Vector3,
- target: PlanetSideGameObject with FactionAffinity with Vitality
- ): Unit = {
+ projectile_guid: PlanetSideGUID,
+ hitPos: Vector3,
+ target: PlanetSideGameObject with FactionAffinity with Vitality
+ ): Unit = {
val hitPositionDiscrepancy = Vector3.DistanceSquared(hitPos, target.Position)
if (hitPositionDiscrepancy > Config.app.antiCheat.hitPositionDiscrepancyThreshold) {
// If the target position on the server does not match the position where the projectile landed within reason there may be foul play
@@ -9400,15 +9306,17 @@ class SessionActor extends Actor with MDCContextAware {
def KickedByAdministration(): Unit = {
sendResponse(DisconnectMessage("@kick_w"))
Thread.sleep(300)
- sendResponse(DropSession(session.id, "kick by GM"))
+ // sendResponse(DropSession(session.id, "kick by GM"))
+ middlewareActor ! MiddlewareActor.Close()
}
def ImmediateDisconnect(): Unit = {
if (avatar != null) {
accountPersistence ! AccountPersistenceService.Logout(avatar.name)
}
- sendResponse(DropCryptoSession())
- sendResponse(DropSession(session.id, "user quit"))
+ // sendResponse(DropCryptoSession())
+ // sendResponse(DropSession(session.id, "user quit"))
+ middlewareActor ! MiddlewareActor.Close()
}
def HandleWeaponFire(weaponGUID: PlanetSideGUID, projectileGUID: PlanetSideGUID, shotOrigin: Vector3): Unit = {
@@ -9457,7 +9365,7 @@ class SessionActor extends Actor with MDCContextAware {
player,
attribution,
shotOrigin,
- angle,
+ angle
)
val initialQuality = tool.FireMode match {
case mode: ChargeFireModeDefinition =>
@@ -9471,18 +9379,18 @@ class SessionActor extends Actor with MDCContextAware {
s"WeaponFireMessage: ${projectile_info.Name} is a remote projectile"
)
taskResolver ! (if (projectile.HasGUID) {
- continent.AvatarEvents ! AvatarServiceMessage(
- continent.id,
- AvatarAction.ProjectileExplodes(
- player.GUID,
- projectile.GUID,
- projectile
- )
- )
- ReregisterProjectile(projectile)
- } else {
- RegisterProjectile(projectile)
- })
+ continent.AvatarEvents ! AvatarServiceMessage(
+ continent.id,
+ AvatarAction.ProjectileExplodes(
+ player.GUID,
+ projectile.GUID,
+ projectile
+ )
+ )
+ ReregisterProjectile(projectile)
+ } else {
+ RegisterProjectile(projectile)
+ })
}
projectilesToCleanUp(projectileIndex) = false
@@ -9522,7 +9430,11 @@ class SessionActor extends Actor with MDCContextAware {
shotsWhileDead += 1
} else { //shooting
if (
- tool.FireModeIndex == 1 && (tool.Definition.Name == "anniversary_guna" || tool.Definition.Name == "anniversary_gun" || tool.Definition.Name == "anniversary_gunb")
+ avatar.stamina > 0 &&
+ tool.FireModeIndex == 1 &&
+ (tool.Definition.Name == "anniversary_guna"
+ || tool.Definition.Name == "anniversary_gun"
+ || tool.Definition.Name == "anniversary_gunb")
) {
avatarActor ! AvatarActor.ConsumeStamina(avatar.stamina)
}
@@ -9538,117 +9450,10 @@ class SessionActor extends Actor with MDCContextAware {
def failWithError(error: String) = {
log.error(error)
- sendResponse(ConnectionClose())
+ middlewareActor ! MiddlewareActor.Close()
}
- /**
- * Persistent collector that intercepts `GamePacket` and `ControlPacket` messages that are being sent towards the network.
- */
- private val packetBundlingCollector: MultiPacketCollector = new MultiPacketCollector()
-
- /**
- * Re-assigned function used to direct/intercept packets being sent towards the network.
- * Defaults to directing the packets.
- */
- private var packetBundlingFunc: (PlanetSidePacket) => Option[PlanetSidePacket] = NoBundlingAction
-
- /**
- * Start packet bundling by assigning the appropriate function.
- * @see `sendResponse(PlanetSidePacket) : Unit`
- */
- def StartBundlingPackets(): Unit = {
- log.trace("WORLD SEND: STARTED BUNDLING PACKETS")
- packetBundlingFunc = PerformBundlingAction
- }
-
- /**
- * Stop packet bundling by assigning the appropriate function.
- * If any bundles are in the collector's buffer, push that bundle out towards the network.
- * @see `sendResponse(PlanetSidePacket) : Unit`
- */
- def StopBundlingPackets(): Unit = {
- log.trace("WORLD SEND: PACKET BUNDLING SUSPENDED")
- packetBundlingFunc = NoBundlingAction
- packetBundlingCollector.Bundle match {
- case Some(bundle) =>
- sendResponse(bundle)
- case None => ;
- }
- }
-
- /**
- * Transform the packet into either a `PlanetSideGamePacket` or a `PlanetSideControlPacket` and push it towards the network.
- * @param cont the packet
- * @return the same packet, to indicate it was sent
- */
- private def NoBundlingAction(cont: PlanetSidePacket): Option[PlanetSidePacket] = {
- cont match {
- case game: PlanetSideGamePacket =>
- sendResponse(PacketCoding.CreateGamePacket(0, game))
- case control: PlanetSideControlPacket =>
- sendResponse(PacketCoding.CreateControlPacket(control))
- case _ => ;
- }
- Some(cont)
- }
-
- /**
- * Intercept the packet being sent towards the network and
- * add it to a bundle that will eventually be sent to the network itself.
- * @param cont the packet
- * @return always `None`, to indicate the packet was not sent
- */
- private def PerformBundlingAction(cont: PlanetSidePacket): Option[PlanetSidePacket] = {
- log.trace("WORLD SEND, BUNDLED: " + cont)
- packetBundlingCollector.Add(cont)
- None
- }
-
- /**
- * Common entry point for transmitting packets to the network.
- * Alternately, catch those packets and retain them to send out a bundled message.
- * @param cont the packet
- */
- def sendResponse(cont: PlanetSidePacket): Unit = packetBundlingFunc(cont)
-
- /**
- * `KeepAliveMessage` is a special `PlanetSideGamePacket` that is excluded from being bundled when it is sent to the network.
- *
- * The risk of the server getting caught in a state where the packets dispatched to the client are always bundled is posible.
- * Starting the bundling functionality but forgetting to transition into a state where it is deactivated can lead to this problem.
- * No packets except for `KeepAliveMessage` will ever be sent until the ever-accumulating packets overflow.
- * To avoid this state, whenever a `KeepAliveMessage` is sent, the packet collector empties its current contents to the network.
- * @see `StartBundlingPackets`
- * @see `StopBundlingPackets`
- * @see `clientKeepAlive`
- * @param cont a `KeepAliveMessage` packet
- */
- def sendResponse(cont: KeepAliveMessage): Unit = {
- sendResponse(PacketCoding.CreateGamePacket(0, cont))
- packetBundlingCollector.Bundle match {
- case Some(bundle) =>
- log.trace("WORLD SEND: INTERMITTENT PACKET BUNDLE")
- sendResponse(bundle)
- case None => ;
- }
- }
-
- def sendResponse(cont: PlanetSidePacketContainer): Unit = {
- log.trace("WORLD SEND: " + cont)
- sendResponse(cont.asInstanceOf[Any])
- }
-
- def sendResponse(cont: MultiPacketBundle): Unit = {
- sendResponse(cont.asInstanceOf[Any])
- }
-
- def sendResponse(msg: Any): Unit = {
- MDC("sessionId") = session.id.toString
- rightRef !> msg
- }
-
- def sendRawResponse(pkt: ByteVector) = {
- log.trace("WORLD SEND RAW: " + pkt)
- sendResponse(RawPacket(pkt))
+ def sendResponse(packet: PlanetSidePacket): Unit = {
+ middlewareActor ! MiddlewareActor.Send(packet)
}
}
diff --git a/src/main/scala/net/psforever/crypto/CryptoInterface.scala b/src/main/scala/net/psforever/crypto/CryptoInterface.scala
deleted file mode 100644
index d337b18cf..000000000
--- a/src/main/scala/net/psforever/crypto/CryptoInterface.scala
+++ /dev/null
@@ -1,310 +0,0 @@
-// Copyright (c) 2017 PSForever
-package net.psforever.crypto
-
-import com.sun.jna.ptr.IntByReference
-import net.psforever.IFinalizable
-import sna.Library
-import com.sun.jna.Pointer
-import scodec.bits.ByteVector
-
-object CryptoInterface {
- final val libName = "pscrypto"
- final val fullLibName = libName
- final val PSCRYPTO_VERSION_MAJOR = 1
- final val PSCRYPTO_VERSION_MINOR = 1
-
- /**
- * NOTE: this is a single, global shared library for the entire server's crypto needs
- *
- * Unfortunately, access to this object didn't used to be synchronized. I noticed that
- * tests for this module were hanging ("arrive at a shared secret" & "must fail to agree on
- * a secret..."). This heisenbug was responsible for failed Travis test runs and developer
- * issues as well. Using Windows minidumps, I tracked the issue to a single thread deep in
- * pscrypto.dll. It appeared to be executing an EB FE instruction (on Intel x86 this is
- * `jmp $-2` or jump to self), which is an infinite loop. The stack trace made little to no
- * sense and after banging my head on the wall for many hours, I assumed that something deep
- * in CryptoPP, the libgcc libraries, or MSVC++ was the cause (or myself). Now all access to
- * pscrypto functions that allocate and deallocate memory (DH_Start, RC5_Init) are synchronized.
- * This *appears* to have fixed the problem.
- */
- final val psLib = new Library(libName)
-
- final val RC5_BLOCK_SIZE = 8
- final val MD5_MAC_SIZE = 16
-
- val functionsList = List(
- "PSCrypto_Init",
- "PSCrypto_Get_Version",
- "PSCrypto_Version_String",
- "RC5_Init",
- "RC5_Encrypt",
- "RC5_Decrypt",
- "DH_Start",
- "DH_Start_Generate",
- "DH_Agree",
- "MD5_MAC",
- "Free_DH",
- "Free_RC5"
- )
-
- /**
- * Used to initialize the crypto library at runtime. The version is checked and
- * all functions are mapped.
- */
- def initialize(): Unit = {
- // preload all library functions for speed
- functionsList foreach psLib.prefetch
-
- val libraryMajor = new IntByReference
- val libraryMinor = new IntByReference
-
- psLib.PSCrypto_Get_Version(libraryMajor, libraryMinor)[Unit]
-
- if (!psLib.PSCrypto_Init(PSCRYPTO_VERSION_MAJOR, PSCRYPTO_VERSION_MINOR)[Boolean]) {
- throw new IllegalArgumentException(
- s"Invalid PSCrypto library version ${libraryMajor.getValue}.${libraryMinor.getValue}. Expected " +
- s"$PSCRYPTO_VERSION_MAJOR.$PSCRYPTO_VERSION_MINOR"
- )
- }
- }
-
- /**
- * Used for debugging object loading
- */
- def printEnvironment(): Unit = {
- import java.io.File
-
- val classpath = System.getProperty("java.class.path")
- val classpathEntries = classpath.split(File.pathSeparator)
-
- val myLibraryPath = System.getProperty("user.dir")
- val jnaLibrary = System.getProperty("jna.library.path")
- val javaLibrary = System.getProperty("java.library.path")
- println("User dir: " + myLibraryPath)
- println("JNA Lib: " + jnaLibrary)
- println("Java Lib: " + javaLibrary)
- print("Classpath: ")
- classpathEntries.foreach(println)
-
- println("Required data model: " + System.getProperty("sun.arch.data.model"))
- }
-
- def MD5MAC(key: ByteVector, message: ByteVector, bytesWanted: Int): ByteVector = {
- val out = Array.ofDim[Byte](bytesWanted)
-
- // WARNING BUG: the function must be cast to something (even if void) otherwise it doesnt work
- val ret = psLib.MD5_MAC(key.toArray, key.length, message.toArray, message.length, out, out.length)[Boolean]
-
- if (!ret)
- throw new Exception("MD5MAC failed to process")
-
- ByteVector(out)
- }
-
- /**
- * Checks if two Message Authentication Codes are the same in constant time,
- * preventing a timing attack for MAC forgery
- *
- * @param mac1 A MAC value
- * @param mac2 Another MAC value
- */
- def verifyMAC(mac1: ByteVector, mac2: ByteVector): Boolean = {
- var okay = true
-
- // prevent byte by byte guessing
- if (mac1.length != mac2.length)
- return false
-
- for (i <- 0 until mac1.length.toInt) {
- okay = okay && mac1 { i } == mac2 { i }
- }
-
- okay
- }
-
- class CryptoDHState extends IFinalizable {
- var started = false
- // these types MUST be Arrays of bytes for JNA to work
- val privateKey = Array.ofDim[Byte](16)
- val publicKey = Array.ofDim[Byte](16)
- val p = Array.ofDim[Byte](16)
- val g = Array.ofDim[Byte](16)
- var dhHandle = Pointer.NULL
-
- def start(modulus: ByteVector, generator: ByteVector): Unit = {
- assertNotClosed
-
- if (started)
- throw new IllegalStateException("DH state has already been started")
-
- psLib.synchronized {
- dhHandle = psLib.DH_Start(modulus.toArray, generator.toArray, privateKey, publicKey)[Pointer]
- }
-
- if (dhHandle == Pointer.NULL)
- throw new Exception("DH initialization failed!")
-
- modulus.copyToArray(p, 0)
- generator.copyToArray(g, 0)
-
- started = true
- }
-
- def start(): Unit = {
- assertNotClosed
-
- if (started)
- throw new IllegalStateException("DH state has already been started")
-
- psLib.synchronized {
- dhHandle = psLib.DH_Start_Generate(privateKey, publicKey, p, g)[Pointer]
- }
-
- if (dhHandle == Pointer.NULL)
- throw new Exception("DH initialization failed!")
-
- started = true
- }
-
- def agree(otherPublicKey: ByteVector) = {
- if (!started)
- throw new IllegalStateException("DH state has not been started")
-
- val agreedValue = Array.ofDim[Byte](16)
- val agreed = psLib.DH_Agree(dhHandle, agreedValue, privateKey, otherPublicKey.toArray)[Boolean]
-
- if (!agreed)
- throw new Exception("Failed to DH agree")
-
- ByteVector.view(agreedValue)
- }
-
- private def checkAndReturnView(array: Array[Byte]) = {
- if (!started)
- throw new IllegalStateException("DH state has not been started")
-
- ByteVector.view(array)
- }
-
- def getPrivateKey = {
- checkAndReturnView(privateKey)
- }
-
- def getPublicKey = {
- checkAndReturnView(publicKey)
- }
-
- def getModulus = {
- checkAndReturnView(p)
- }
-
- def getGenerator = {
- checkAndReturnView(g)
- }
-
- override def close = {
- if (started) {
- // TODO: zero private key material
- psLib.synchronized {
- psLib.Free_DH(dhHandle)[Unit]
- }
- started = false
- }
-
- super.close
- }
- }
-
- class CryptoState(val decryptionKey: ByteVector, val encryptionKey: ByteVector) extends IFinalizable {
- // Note that the keys must be returned as primitive Arrays for JNA to work
- var encCryptoHandle: Pointer = Pointer.NULL
- var decCryptoHandle: Pointer = Pointer.NULL
-
- psLib.synchronized {
- encCryptoHandle = psLib.RC5_Init(encryptionKey.toArray, encryptionKey.length, true)[Pointer]
- decCryptoHandle = psLib.RC5_Init(decryptionKey.toArray, decryptionKey.length, false)[Pointer]
- }
-
- if (encCryptoHandle == Pointer.NULL)
- throw new Exception("Encryption initialization failed!")
-
- if (decCryptoHandle == Pointer.NULL)
- throw new Exception("Decryption initialization failed!")
-
- def encrypt(plaintext: ByteVector): ByteVector = {
- if (plaintext.length % RC5_BLOCK_SIZE != 0)
- throw new IllegalArgumentException(s"input must be padded to the nearest $RC5_BLOCK_SIZE byte boundary")
-
- val ciphertext = Array.ofDim[Byte](plaintext.length.toInt)
-
- val ret = psLib.RC5_Encrypt(encCryptoHandle, plaintext.toArray, plaintext.length, ciphertext)[Boolean]
-
- if (!ret)
- throw new Exception("Failed to encrypt plaintext")
-
- ByteVector.view(ciphertext)
- }
-
- def decrypt(ciphertext: ByteVector): ByteVector = {
- if (ciphertext.length % RC5_BLOCK_SIZE != 0)
- throw new IllegalArgumentException(s"input must be padded to the nearest $RC5_BLOCK_SIZE byte boundary")
-
- val plaintext = Array.ofDim[Byte](ciphertext.length.toInt)
-
- val ret = psLib.RC5_Decrypt(decCryptoHandle, ciphertext.toArray, ciphertext.length, plaintext)[Boolean]
-
- if (!ret)
- throw new Exception("Failed to decrypt ciphertext")
-
- ByteVector.view(plaintext)
- }
-
- override def close = {
- psLib.synchronized {
- psLib.Free_RC5(encCryptoHandle)[Unit]
- psLib.Free_RC5(decCryptoHandle)[Unit]
- }
- super.close
- }
- }
-
- class CryptoStateWithMAC(
- decryptionKey: ByteVector,
- encryptionKey: ByteVector,
- val decryptionMACKey: ByteVector,
- val encryptionMACKey: ByteVector
- ) extends CryptoState(decryptionKey, encryptionKey) {
-
- /**
- * Performs a MAC operation over the message. Used when encrypting packets
- *
- * @param message the input message
- * @return ByteVector
- */
- def macForEncrypt(message: ByteVector): ByteVector = {
- MD5MAC(encryptionMACKey, message, MD5_MAC_SIZE)
- }
-
- /**
- * Performs a MAC operation over the message. Used when verifying decrypted packets
- *
- * @param message the input message
- * @return ByteVector
- */
- def macForDecrypt(message: ByteVector): ByteVector = {
- MD5MAC(decryptionMACKey, message, MD5_MAC_SIZE)
- }
-
- /**
- * MACs the plaintext message, encrypts it, and then returns the encrypted message with the
- * MAC appended to the end.
- *
- * @param message Arbitrary set of bytes
- * @return ByteVector
- */
- def macAndEncrypt(message: ByteVector): ByteVector = {
- encrypt(message) ++ MD5MAC(encryptionMACKey, message, MD5_MAC_SIZE)
- }
- }
-
-}
diff --git a/src/main/scala/net/psforever/login/CryptoSessionActor.scala b/src/main/scala/net/psforever/login/CryptoSessionActor.scala
deleted file mode 100644
index 7aedcdc88..000000000
--- a/src/main/scala/net/psforever/login/CryptoSessionActor.scala
+++ /dev/null
@@ -1,358 +0,0 @@
-package net.psforever.login
-
-import java.security.SecureRandom
-
-import akka.actor.MDCContextAware.Implicits._
-import akka.actor.{Actor, ActorRef, MDCContextAware}
-import net.psforever.crypto.CryptoInterface
-import net.psforever.crypto.CryptoInterface.CryptoStateWithMAC
-import net.psforever.packet._
-import net.psforever.packet.control._
-import net.psforever.packet.crypto._
-import net.psforever.packet.game.PingMsg
-import org.log4s.MDC
-import scodec.Attempt.{Failure, Successful}
-import scodec.bits._
-
-sealed trait CryptoSessionAPI
-final case class DropCryptoSession() extends CryptoSessionAPI
-
-/**
- * Actor that stores crypto state for a connection, appropriately encrypts and decrypts packets,
- * and passes packets along to the next hop once processed.
- */
-class CryptoSessionActor extends Actor with MDCContextAware {
- private[this] val log = org.log4s.getLogger
-
- var sessionId: Long = 0
- var leftRef: ActorRef = ActorRef.noSender
- var rightRef: ActorRef = ActorRef.noSender
-
- var cryptoDHState: Option[CryptoInterface.CryptoDHState] = None
- var cryptoState: Option[CryptoInterface.CryptoStateWithMAC] = None
- val random = new SecureRandom()
-
- // crypto handshake state
- var serverChallenge = ByteVector.empty
- var serverChallengeResult = ByteVector.empty
- var serverMACBuffer = ByteVector.empty
-
- var clientPublicKey = ByteVector.empty
- var clientChallenge = ByteVector.empty
- var clientChallengeResult = ByteVector.empty
-
- var clientNonce: Long = 0
- var serverNonce: Long = 0
-
- // Don't leak crypto object memory even on an exception
- override def postStop() = {
- cleanupCrypto()
- }
-
- def receive = Initializing
-
- def Initializing: Receive = {
- case HelloFriend(sharedSessionId, pipe) =>
- import MDCContextAware.Implicits._
- this.sessionId = sharedSessionId
- leftRef = sender()
- if (pipe.hasNext) {
- rightRef = pipe.next() // who ever we send to has to send something back to us
- rightRef !> HelloFriend(sessionId, pipe)
- } else {
- rightRef = sender()
- }
- log.trace(s"Left sender ${leftRef.path.name}")
- context.become(NewClient)
-
- case default =>
- log.error("Unknown message " + default)
- context.stop(self)
- }
-
- def NewClient: Receive = {
- case RawPacket(msg) =>
- PacketCoding.UnmarshalPacket(msg) match {
- case Successful(p) =>
- log.trace("Initializing -> NewClient")
-
- p match {
- case ControlPacket(_, ClientStart(nonce)) =>
- clientNonce = nonce
- serverNonce = Math.abs(random.nextInt())
- sendResponse(PacketCoding.CreateControlPacket(ServerStart(nonce, serverNonce)))
- log.trace(s"ClientStart($nonce), $serverNonce")
-
- context.become(CryptoExchange)
- case _ =>
- log.error(s"Unexpected packet type $p in state NewClient")
- }
- case Failure(_) =>
- // There is a special case where no crypto is being used.
- // The only packet coming through looks like PingMsg. This is a hardcoded
- // feature of the client @ 0x005FD618
- PacketCoding.DecodePacket(msg) match {
- case Successful(packet) =>
- packet match {
- case ping @ PingMsg(_, _) =>
- // reflect the packet back to the sender
- sendResponse(ping)
- case _ =>
- log.error(s"Unexpected non-crypto packet type $packet in state NewClient")
- }
- case Failure(e) =>
- log.error("Could not decode packet: " + e + s" in state NewClient")
- }
- }
- case default =>
- log.error(s"Invalid message '$default' received in state NewClient")
- }
-
- def CryptoExchange: Receive = {
- case RawPacket(msg) =>
- PacketCoding.UnmarshalPacket(msg, CryptoPacketOpcode.ClientChallengeXchg) match {
- case Failure(e) =>
- log.error("Could not decode packet in state CryptoExchange: " + e)
-
- case Successful(pkt) =>
- log.trace("NewClient -> CryptoExchange")
- pkt match {
- case CryptoPacket(seq, ClientChallengeXchg(time, challenge, p, g)) =>
- cryptoDHState = Some(new CryptoInterface.CryptoDHState())
- val dh = cryptoDHState.get
- // initialize our crypto state from the client's P and G
- dh.start(p, g)
- // save the client challenge
- clientChallenge = ServerChallengeXchg.getCompleteChallenge(time, challenge)
- // save the packet we got for a MAC check later. drop the first 3 bytes
- serverMACBuffer ++= msg.drop(3)
- val serverTime = System.currentTimeMillis() / 1000L
- val randomChallenge = getRandBytes(0xc)
- // store the complete server challenge for later
- serverChallenge = ServerChallengeXchg.getCompleteChallenge(serverTime, randomChallenge)
- val packet =
- PacketCoding.CreateCryptoPacket(seq, ServerChallengeXchg(serverTime, randomChallenge, dh.getPublicKey))
- val sentPacket = sendResponse(packet)
- // save the sent packet a MAC check
- serverMACBuffer ++= sentPacket.drop(3)
- context.become(CryptoSetupFinishing)
-
- case _ =>
- log.error(s"Unexpected packet type $pkt in state CryptoExchange")
- }
- }
- case default =>
- log.error(s"Invalid message '$default' received in state CryptoExchange")
- }
-
- def CryptoSetupFinishing: Receive = {
- case RawPacket(msg) =>
- PacketCoding.UnmarshalPacket(msg, CryptoPacketOpcode.ClientFinished) match {
- case Failure(e) => log.error("Could not decode packet in state CryptoSetupFinishing: " + e)
- case Successful(p) =>
- log.trace("CryptoExchange -> CryptoSetupFinishing")
-
- p match {
- case CryptoPacket(seq, ClientFinished(clientPubKey, clientChalResult)) =>
- clientPublicKey = clientPubKey
- clientChallengeResult = clientChalResult
-
- // save the packet we got for a MAC check later
- serverMACBuffer ++= msg.drop(3)
-
- val dh = cryptoDHState.get
- val agreedValue = dh.agree(clientPublicKey)
-
- // we are now done with the DH crypto object
- dh.close
-
- /*println("Agreed: " + agreedValue)
- println(s"Client challenge: $clientChallenge")*/
- val agreedMessage = ByteVector("master secret".getBytes) ++ clientChallenge ++
- hex"00000000" ++ serverChallenge ++ hex"00000000"
-
- //println("In message: " + agreedMessage)
-
- val masterSecret = CryptoInterface.MD5MAC(agreedValue, agreedMessage, 20)
-
- //println("Master secret: " + masterSecret)
-
- serverChallengeResult = CryptoInterface.MD5MAC(
- masterSecret,
- ByteVector("server finished".getBytes) ++ serverMACBuffer ++ hex"01",
- 0xc
- )
-
-// val clientChallengeResultCheck = CryptoInterface.MD5MAC(masterSecret,
-// ByteVector("client finished".getBytes) ++ serverMACBuffer ++ hex"01" ++ clientChallengeResult ++ hex"01",
-// 0xc)
-// println("Check result: " + CryptoInterface.verifyMAC(clientChallenge, clientChallengeResult))
-
- val decExpansion = ByteVector("client expansion".getBytes) ++ hex"0000" ++ serverChallenge ++
- hex"00000000" ++ clientChallenge ++ hex"00000000"
-
- val encExpansion = ByteVector("server expansion".getBytes) ++ hex"0000" ++ serverChallenge ++
- hex"00000000" ++ clientChallenge ++ hex"00000000"
-
- /*println("DecExpansion: " + decExpansion)
- println("EncExpansion: " + encExpansion)*/
-
- // expand the encryption and decryption keys
- // The first 20 bytes are for RC5, and the next 16 are for the MAC'ing keys
- val expandedDecKey =
- CryptoInterface.MD5MAC(masterSecret, decExpansion, 0x40) // this is what is visible in IDA
-
- val expandedEncKey = CryptoInterface.MD5MAC(masterSecret, encExpansion, 0x40)
-
- val decKey = expandedDecKey.take(20)
- val encKey = expandedEncKey.take(20)
- val decMACKey = expandedDecKey.drop(20).take(16)
- val encMACKey = expandedEncKey.drop(20).take(16)
-
- /*println("**** DecKey: " + decKey)
- println("**** EncKey: " + encKey)
- println("**** DecMacKey: " + decMACKey)
- println("**** EncMacKey: " + encMACKey)*/
-
- // spin up our encryption program
- cryptoState = Some(new CryptoStateWithMAC(decKey, encKey, decMACKey, encMACKey))
-
- val packet = PacketCoding.CreateCryptoPacket(seq, ServerFinished(serverChallengeResult))
-
- sendResponse(packet)
-
- context.become(Established)
- case default => failWithError(s"Unexpected packet type $default in state CryptoSetupFinished")
- }
- }
- case default => failWithError(s"Invalid message '$default' received in state CryptoSetupFinished")
- }
-
- def Established: Receive = {
- //same as having received ad hoc hexadecimal
- case RawPacket(msg) =>
- if (sender() == rightRef) {
- val packet = PacketCoding.encryptPacket(cryptoState.get, 0, msg).require
- sendResponse(packet)
- } else { //from network-side
- PacketCoding.UnmarshalPacket(msg) match {
- case Successful(p) =>
- p match {
- case encPacket @ EncryptedPacket(_ /*seq*/, _) =>
- PacketCoding.decryptPacketData(cryptoState.get, encPacket) match {
- case Successful(packet) =>
- MDC("sessionId") = sessionId.toString
- rightRef !> RawPacket(packet)
- case Failure(e) =>
- log.error("Failed to decode encrypted packet: " + e)
- }
- case default =>
- failWithError(s"Unexpected packet type $default in state Established")
-
- }
- case Failure(e) =>
- log.error("Could not decode raw packet: " + e)
- }
- }
- //message to self?
- case api: CryptoSessionAPI =>
- api match {
- case DropCryptoSession() =>
- handleEstablishedPacket(
- sender(),
- PacketCoding.CreateControlPacket(TeardownConnection(clientNonce))
- )
- }
- //echo the session router? isn't that normally the leftRef?
- case sessionAPI: SessionRouterAPI =>
- leftRef !> sessionAPI
- //error
- case default =>
- failWithError(s"Invalid message '$default' received in state Established")
- }
-
- def failWithError(error: String) = {
- log.error(error)
- }
-
- def cleanupCrypto() = {
- if (cryptoDHState.isDefined) {
- cryptoDHState.get.close
- cryptoDHState = None
- }
-
- if (cryptoState.isDefined) {
- cryptoState.get.close
- cryptoState = None
- }
- }
-
- def resetState(): Unit = {
- context.become(receive)
-
- // reset the crypto primitives
- cleanupCrypto()
-
- serverChallenge = ByteVector.empty
- serverChallengeResult = ByteVector.empty
- serverMACBuffer = ByteVector.empty
- clientPublicKey = ByteVector.empty
- clientChallenge = ByteVector.empty
- clientChallengeResult = ByteVector.empty
- }
-
- def handleEstablishedPacket(from: ActorRef, cont: PlanetSidePacketContainer): Unit = {
- //we are processing a packet that we decrypted
- if (from == self) { //to WSA, LSA, etc.
- rightRef !> cont
- } else if (from == rightRef) { //processing a completed packet from the right; to network-side
- PacketCoding.getPacketDataForEncryption(cont) match {
- case Successful((seq, data)) =>
- val packet = PacketCoding.encryptPacket(cryptoState.get, seq, data).require
- sendResponse(packet)
- case Failure(ex) =>
- log.error(s"$ex")
- }
- } else {
- log.error(s"Invalid sender when handling a message in Established $from")
- }
- }
-
- def sendResponse(cont: PlanetSidePacketContainer): ByteVector = {
- log.trace("CRYPTO SEND: " + cont)
- val pkt = PacketCoding.MarshalPacket(cont)
- pkt match {
- case Failure(_) =>
- log.error(s"Failed to marshal packet ${cont.getClass.getName} when sending response")
- ByteVector.empty
-
- case Successful(v) =>
- val bytes = v.toByteVector
- MDC("sessionId") = sessionId.toString
- leftRef !> ResponsePacket(bytes)
- bytes
- }
- }
-
- def sendResponse(pkt: PlanetSideGamePacket): ByteVector = {
- log.trace("CRYPTO SEND GAME: " + pkt)
- val pktEncoded = PacketCoding.EncodePacket(pkt)
- pktEncoded match {
- case Failure(_) =>
- log.error(s"Failed to encode packet ${pkt.getClass.getName} when sending response")
- ByteVector.empty
-
- case Successful(v) =>
- val bytes = v.toByteVector
- MDC("sessionId") = sessionId.toString
- leftRef !> ResponsePacket(bytes)
- bytes
- }
- }
-
- def getRandBytes(amount: Int): ByteVector = {
- val array = Array.ofDim[Byte](amount)
- random.nextBytes(array)
- ByteVector.view(array)
- }
-}
diff --git a/src/main/scala/net/psforever/login/PacketCodingActor.scala b/src/main/scala/net/psforever/login/PacketCodingActor.scala
deleted file mode 100644
index b8f932c36..000000000
--- a/src/main/scala/net/psforever/login/PacketCodingActor.scala
+++ /dev/null
@@ -1,484 +0,0 @@
-package net.psforever.login
-
-import akka.actor.MDCContextAware.Implicits._
-import akka.actor.{Actor, ActorRef, Cancellable, MDCContextAware}
-import net.psforever.objects.Default
-import net.psforever.packet._
-import net.psforever.packet.control.{HandleGamePacket, _}
-import org.log4s.MDC
-import scodec.Attempt.{Failure, Successful}
-import scodec.bits._
-
-import scala.annotation.tailrec
-import scala.collection.mutable
-import scala.collection.mutable.ArrayBuffer
-import scala.concurrent.duration._
-
-/**
- * In between the network side and the higher functioning side of the simulation:
- * accept packets and transform them into a sequence of data (encoding), and
- * accept a sequence of data and transform it into s packet (decoding).
- *
- * Following the standardization of the `SessionRouter` pipeline, the throughput of this `Actor` has directionality.
- * The "network," where the encoded data comes and goes, is assumed to be `leftRef`.
- * The "simulation", where the decoded packets come and go, is assumed to be `rightRef`.
- * `rightRef` can accept a sequence that looks like encoded data but it will merely pass out the same sequence.
- * Likewise, `leftRef` accepts decoded packets but merely ejects the same packets without doing any work on them.
- * The former functionality is anticipated.
- * The latter functionality is deprecated.
- *
- * Encoded data leaving the `Actor` (`leftRef`) is limited by an upper bound capacity.
- * Sequences can not be larger than that bound or else they will be dropped.
- * This maximum transmission unit (MTU) is used to divide the encoded sequence into chunks of encoded data,
- * re-packaged into nested `ControlPacket` units, and each unit encoded.
- * The outer packaging is numerically consistent with a `subslot` that starts counting once the simulation starts.
- * The client is very specific about the `subslot` number and will reject out-of-order packets.
- * It resets to 0 each time this `Actor` starts up and the client reflects this functionality.
- */
-class PacketCodingActor extends Actor with MDCContextAware {
- private var sessionId: Long = 0
- private var subslotOutbound: Int = 0
- private var subslotInbound: Int = 0
- private var leftRef: ActorRef = ActorRef.noSender
- private var rightRef: ActorRef = ActorRef.noSender
- private[this] val log = org.log4s.getLogger
-
- /*
- Since the client can indicate missing packets when sending SlottedMetaPackets we should keep a history of them to resend to the client when requested with a RelatedA packet
- Since the subslot counter can wrap around, we need to use a LinkedHashMap to maintain the order packets are inserted, then we can drop older entries as required
- For example when a RelatedB packet arrives we can remove any entries to the left of the received ones without risking removing newer entries if the subslot counter wraps around back to 0
- */
- private var slottedPacketLog: mutable.LinkedHashMap[Int, ByteVector] = mutable.LinkedHashMap()
-
- // Due to the fact the client can send `RelatedA` packets out of order, we need to keep a buffer of which subslots arrived correctly, order them
- // and then act accordingly to send the missing subslot packet after a specified timeout
- private var relatedALog: ArrayBuffer[Int] = ArrayBuffer()
- private var relatedABufferTimeout: Cancellable = Default.Cancellable
-
- def AddSlottedPacketToLog(subslot: Int, packet: ByteVector): Unit = {
- val log_limit = 500 // Number of SlottedMetaPackets to keep in history
- if (slottedPacketLog.size > log_limit) {
- slottedPacketLog = slottedPacketLog.drop(slottedPacketLog.size - log_limit)
- }
-
- slottedPacketLog { subslot } = packet
- }
-
- override def postStop() = {
- subslotOutbound = 0 //in case this `Actor` restarts
- super.postStop()
- }
-
- def receive = Initializing
-
- def Initializing: Receive = {
- case HelloFriend(sharedSessionId, pipe) =>
- import MDCContextAware.Implicits._
- this.sessionId = sharedSessionId
- leftRef = sender()
- if (pipe.hasNext) {
- rightRef = pipe.next()
- rightRef !> HelloFriend(sessionId, pipe)
- } else {
- rightRef = sender()
- }
- log.trace(s"Left sender ${leftRef.path.name}")
- context.become(Established)
-
- case default =>
- log.error("Unknown message " + default)
- context.stop(self)
- }
-
- def Established: Receive = {
- case PacketCodingActor.SubslotResend() => {
- log.trace(s"Subslot resend timeout reached, session: ${sessionId}")
- relatedABufferTimeout.cancel()
- log.trace(s"Client indicated successful subslots ${relatedALog.sortBy(x => x).mkString(" ")}")
-
- // If a non-contiguous range of RelatedA packets were received we may need to send multiple missing packets, thus split the array into contiguous ranges
- val sorted_log = relatedALog.sortBy(x => x)
-
- val split_logs: ArrayBuffer[ArrayBuffer[Int]] = new ArrayBuffer[ArrayBuffer[Int]]()
- var curr: ArrayBuffer[Int] = ArrayBuffer()
- for (i <- 0 to sorted_log.size - 1) {
- if (i == 0 || (sorted_log(i) != sorted_log(i - 1) + 1)) {
- curr = new ArrayBuffer()
- split_logs.append(curr)
- }
- curr.append(sorted_log(i))
- }
-
- if (split_logs.size > 1) log.trace(s"Split successful subslots into ${split_logs.size} contiguous chunks")
-
- for (range <- split_logs) {
- log.trace(s"Processing chunk ${range.mkString(" ")}")
- val first_accepted_subslot = range.min
- val missing_subslot = first_accepted_subslot - 1
- slottedPacketLog.get(missing_subslot) match {
- case Some(packet: ByteVector) =>
- log.info(s"Resending packet with subslot: $missing_subslot to session: ${sessionId}")
- sendResponseLeft(packet)
- case None =>
- log.error(s"Couldn't find packet with subslot: ${missing_subslot} to resend to session ${sessionId}.")
- }
- }
-
- relatedALog.clear()
- }
- case RawPacket(msg) =>
- if (sender() == rightRef) { //from LSA, WSA, etc., to network - encode
- mtuLimit(msg)
- } else { //from network, to LSA, WSA, etc. - decode
- UnmarshalInnerPacket(msg, "a packet")
- }
- //known elevated packet type
- case ctrl @ ControlPacket(_, packet) =>
- if (sender() == rightRef) { //from LSA, WSA, to network - encode
- PacketCoding.EncodePacket(packet) match {
- case Successful(data) =>
- mtuLimit(data.toByteVector)
- case Failure(ex) =>
- log.error(s"Failed to encode a ControlPacket: $ex")
- }
- } else { //deprecated; ControlPackets should not be coming from this direction
- log.warn(s"DEPRECATED CONTROL PACKET SEND: $ctrl")
- MDC("sessionId") = sessionId.toString
- handlePacketContainer(ctrl) //sendResponseRight
- }
- //known elevated packet type
- case game @ GamePacket(_, _, packet) =>
- if (sender() == rightRef) { //from LSA, WSA, etc., to network - encode
- PacketCoding.EncodePacket(packet) match {
- case Successful(data) =>
- mtuLimit(data.toByteVector)
- case Failure(ex) =>
- log.error(s"Failed to encode a GamePacket: $ex")
- }
- } else { //deprecated; GamePackets should not be coming from this direction
- log.warn(s"DEPRECATED GAME PACKET SEND: $game")
- MDC("sessionId") = sessionId.toString
- sendResponseRight(game)
- }
- //bundling packets into a SlottedMetaPacket0/MultiPacketEx
- case msg @ MultiPacketBundle(list) =>
- log.trace(s"BUNDLE PACKET REQUEST SEND, LEFT (always): $msg")
- handleBundlePacket(list)
- //etc
- case msg =>
- if (sender() == rightRef) {
- log.trace(s"BASE CASE PACKET SEND, LEFT: $msg")
- MDC("sessionId") = sessionId.toString
- leftRef !> msg
- } else {
- log.trace(s"BASE CASE PACKET SEND, RIGHT: $msg")
- MDC("sessionId") = sessionId.toString
- rightRef !> msg
- }
- }
-
- /**
- * Retrieve the current subslot number.
- * Increment the `subslot` for the next time it is needed.
- * @return a `16u` number starting at 0
- */
- def Subslot: Int = {
- if (subslotOutbound == 65536) { //TODO what is the actual wrap number?
- subslotOutbound = 0
- subslotOutbound
- } else {
- val curr = subslotOutbound
- subslotOutbound += 1
- curr
- }
- }
-
- /**
- * Check that an outbound packet is not too big to get stuck by the MTU.
- * If it is larger than the MTU, divide it up and re-package the sections.
- * Otherwise, send the data out like normal.
- * @param msg the encoded packet data
- */
- def mtuLimit(msg: ByteVector): Unit = {
- if (msg.length > PacketCodingActor.MTU_LIMIT_BYTES) {
- handleSplitPacket(PacketCoding.CreateControlPacket(HandleGamePacket(msg)))
- } else {
- sendResponseLeft(msg)
- }
- }
-
- /**
- * Transform a `ControlPacket` into `ByteVector` data for splitting.
- * @param cont the original `ControlPacket`
- */
- def handleSplitPacket(cont: ControlPacket): Unit = {
- PacketCoding.getPacketDataForEncryption(cont) match {
- case Successful((_, data)) =>
- handleSplitPacket(data)
- case Failure(ex) =>
- log.error(s"$ex")
- }
- }
-
- /**
- * Accept `ByteVector` data, representing a `ControlPacket`, and split it into chunks.
- * The chunks should not be blocked by the MTU.
- * Send each chunk (towards the network) as it is converted.
- * @param data `ByteVector` data to be split
- */
- def handleSplitPacket(data: ByteVector): Unit = {
- val lim = PacketCodingActor.MTU_LIMIT_BYTES - 4 //4 bytes is the base size of SlottedMetaPacket
- data
- .grouped(lim)
- .foreach(bvec => {
- val subslot = Subslot
- PacketCoding.EncodePacket(SlottedMetaPacket(4, subslot, bvec)) match {
- case Successful(bdata) =>
- AddSlottedPacketToLog(subslot, bdata.toByteVector)
- sendResponseLeft(bdata.toByteVector)
- case f: Failure =>
- log.error(s"$f")
- }
- })
- }
-
- /**
- * Accept a `List` of packets and sequentially re-package the elements from the list into multiple container packets.
- *
- * The original packets are encoded then paired with their encoding lengths plus extra space to prefix the length.
- * Encodings from these pairs are drawn from the list until into buckets that fit a maximum byte stream length.
- * The size limitation on any bucket is the MTU limit.
- * less by the base sizes of `MultiPacketEx` (2) and of `SlottedMetaPacket` (4).
- * @param bundle the packets to be bundled
- */
- def handleBundlePacket(bundle: List[PlanetSidePacket]): Unit = {
- val packets: List[ByteVector] = recursiveEncode(bundle.iterator)
- recursiveFillPacketBuckets(packets.iterator, PacketCodingActor.MTU_LIMIT_BYTES - 6)
- .foreach(list => {
- handleBundlePacket(list.toVector)
- })
- }
-
- /**
- * Accept a `Vector` of encoded packets and re-package them.
- * The normal order is to package the elements of the vector into a `MultiPacketEx`.
- * If the vector only has one element, it will get packaged by itself in a `SlottedMetaPacket`.
- * If that one element risks being too big for the MTU, however, it will be handled off to be split.
- * Splitting should preserve `Subslot` ordering with the rest of the bundling.
- * @param vec a specific number of byte streams
- */
- def handleBundlePacket(vec: Vector[ByteVector]): Unit = {
- if (vec.size == 1) {
- val elem = vec.head
- if (elem.length > PacketCodingActor.MTU_LIMIT_BYTES - 4) {
- handleSplitPacket(PacketCoding.CreateControlPacket(HandleGamePacket(elem)))
- } else {
- handleBundlePacket(elem)
- }
- } else {
- PacketCoding.EncodePacket(MultiPacketEx(vec)) match {
- case Successful(bdata) =>
- handleBundlePacket(bdata.toByteVector)
- case Failure(e) =>
- log.warn(s"bundling failed on MultiPacketEx creation: - $e")
- }
- }
- }
-
- /**
- * Accept `ByteVector` data and package it into a `SlottedMetaPacket`.
- * Send it (towards the network) upon successful encoding.
- * @param data an encoded packet
- */
- def handleBundlePacket(data: ByteVector): Unit = {
- val subslot = Subslot
- PacketCoding.EncodePacket(SlottedMetaPacket(0, subslot, data)) match {
- case Successful(bdata) =>
- AddSlottedPacketToLog(subslot, bdata.toByteVector)
- sendResponseLeft(bdata.toByteVector)
- case Failure(e) =>
- log.warn(s"bundling failed on SlottedMetaPacket creation: - $e")
- }
- }
-
- /**
- * Encoded sequence of data going towards the network.
- * @param cont the data
- */
- def sendResponseLeft(cont: ByteVector): Unit = {
- log.trace("PACKET SEND, LEFT: " + cont)
- MDC("sessionId") = sessionId.toString
- leftRef !> RawPacket(cont)
- }
-
- /**
- * Transform data into a container packet and re-submit that container to the process that handles the packet.
- * @param data the packet data
- * @param description an explanation of the input `data`
- */
- def UnmarshalInnerPacket(data: ByteVector, description: String): Unit = {
- PacketCoding.unmarshalPayload(0, data) match { //TODO is it safe for this to always be 0?
- case Successful(packet) =>
- handlePacketContainer(packet)
- case Failure(ex) =>
- log.info(s"Failed to unmarshal $description: $ex. Data : $data")
- }
- }
-
- /**
- * Sort and redirect a container packet bound for the server by type of contents.
- * `GamePacket` objects can just onwards without issue.
- * `ControlPacket` objects may need to be dequeued.
- * All other container types are invalid.
- * @param container the container packet
- */
- def handlePacketContainer(container: PlanetSidePacketContainer): Unit = {
- container match {
- case _: GamePacket =>
- sendResponseRight(container)
- case ControlPacket(_, ctrlPkt) =>
- handleControlPacket(container, ctrlPkt)
- case default =>
- log.warn(s"Invalid packet container class received: ${default.getClass.getName}") //do not spill contents in log
- }
- }
-
- /**
- * Process a control packet or determine that it does not need to be processed at this level.
- * Primarily, if the packet is of a type that contains another packet that needs be be unmarshalled,
- * that/those packet must be unwound.
- *
- * The subslot information is used to identify these nested packets after arriving at their destination,
- * to establish order for sequential packets and relation between divided packets.
- * @param container the original container packet
- * @param packet the packet that was extracted from the container
- */
- def handleControlPacket(container: PlanetSidePacketContainer, packet: PlanetSideControlPacket) = {
- packet match {
- case SlottedMetaPacket(slot, subslot, innerPacket) =>
- subslotInbound = subslot
- self.tell(PacketCoding.CreateControlPacket(RelatedB(slot, subslot)), rightRef) //will go to the network
- UnmarshalInnerPacket(innerPacket, "the inner packet of a SlottedMetaPacket")
-
- case MultiPacket(packets) =>
- packets.foreach { UnmarshalInnerPacket(_, "the inner packet of a MultiPacket") }
-
- case MultiPacketEx(packets) =>
- packets.foreach { UnmarshalInnerPacket(_, "the inner packet of a MultiPacketEx") }
-
- case RelatedA(slot, subslot) =>
- log.trace(s"Client indicated a packet is missing prior to slot: $slot subslot: $subslot, session: ${sessionId}")
-
- relatedALog += subslot
-
- // (re)start the timeout period, if no more RelatedA packets are sent before the timeout period elapses the missing packet(s) will be resent
- import scala.concurrent.ExecutionContext.Implicits.global
- relatedABufferTimeout.cancel()
- relatedABufferTimeout =
- context.system.scheduler.scheduleOnce(100 milliseconds, self, PacketCodingActor.SubslotResend())
-
- case RelatedB(slot, subslot) =>
- log.trace(s"result $slot: subslot $subslot accepted, session: ${sessionId}")
-
- // The client has indicated it's received up to a certain subslot, that means we can purge the log of any subslots prior to and including the confirmed subslot
- // Find where this subslot is stored in the packet log (if at all) and drop anything to the left of it, including itself
- if (relatedABufferTimeout.isCancelled || relatedABufferTimeout == Default.Cancellable) {
- val pos = slottedPacketLog.keySet.toArray.indexOf(subslot)
- if (pos != -1) {
- slottedPacketLog = slottedPacketLog.drop(pos + 1)
- log.trace(s"Subslots left in log: ${slottedPacketLog.keySet.toString()}")
- }
- }
- case _ =>
- sendResponseRight(container)
- }
- }
-
- /**
- * Decoded packet going towards the simulation.
- * @param cont the packet
- */
- def sendResponseRight(cont: PlanetSidePacketContainer): Unit = {
- log.trace("PACKET SEND, RIGHT: " + cont)
- MDC("sessionId") = sessionId.toString
- rightRef !> cont
- }
-
- /**
- * Accept a series of packets and transform it into a series of packet encodings.
- * Packets that do not encode properly are simply excluded from the product.
- * This is not treated as an error or exception; a warning will merely be logged.
- * @param iter the `Iterator` for a series of packets
- * @param out updated series of byte stream data produced through successful packet encoding;
- * defaults to an empty list
- * @return a series of byte stream data produced through successful packet encoding
- */
- @tailrec private def recursiveEncode(
- iter: Iterator[PlanetSidePacket],
- out: List[ByteVector] = List()
- ): List[ByteVector] = {
- if (!iter.hasNext) {
- out
- } else {
- import net.psforever.packet.{PlanetSideControlPacket, PlanetSideGamePacket}
- iter.next() match {
- case msg: PlanetSideGamePacket =>
- PacketCoding.EncodePacket(msg) match {
- case Successful(bytecode) =>
- recursiveEncode(iter, out :+ bytecode.toByteVector)
- case Failure(e) =>
- log.warn(s"game packet $msg, part of a bundle, did not encode - $e")
- recursiveEncode(iter, out)
- }
- case msg: PlanetSideControlPacket =>
- PacketCoding.EncodePacket(msg) match {
- case Successful(bytecode) =>
- recursiveEncode(iter, out :+ bytecode.toByteVector)
- case Failure(e) =>
- log.warn(s"control packet $msg, part of a bundle, did not encode - $e")
- recursiveEncode(iter, out)
- }
- case _ =>
- recursiveEncode(iter, out)
- }
- }
- }
-
- /**
- * Accept a series of byte stream data and sort into sequential size-limited buckets of the same byte streams.
- * Note that elements that exceed `lim` by themselves are always sorted into their own buckets.
- * @param iter an `Iterator` of a series of byte stream data
- * @param lim the maximum stream length permitted
- * @param curr the stream length of the current bucket
- * @param out updated series of byte stream data stored in buckets
- * @return a series of byte stream data stored in buckets
- */
- @tailrec private def recursiveFillPacketBuckets(
- iter: Iterator[ByteVector],
- lim: Int,
- curr: Int = 0,
- out: List[mutable.ListBuffer[ByteVector]] = List(mutable.ListBuffer())
- ): List[mutable.ListBuffer[ByteVector]] = {
- if (!iter.hasNext) {
- out
- } else {
- val data = iter.next()
- var len = data.length.toInt
- len = len + (if (len < 256) { 1 }
- else if (len < 65536) { 2 }
- else { 4 }) //space for the prefixed length byte(s)
- if (curr + len > lim && out.last.nonEmpty) { //bucket must have something in it before swapping
- recursiveFillPacketBuckets(iter, lim, len, out :+ mutable.ListBuffer(data))
- } else {
- out.last += data
- recursiveFillPacketBuckets(iter, lim, curr + len, out)
- }
- }
- }
-}
-
-object PacketCodingActor {
- final val MTU_LIMIT_BYTES: Int = 467
-
- private final case class SubslotResend()
-}
diff --git a/src/main/scala/net/psforever/login/Session.scala b/src/main/scala/net/psforever/login/Session.scala
deleted file mode 100644
index 2095b7355..000000000
--- a/src/main/scala/net/psforever/login/Session.scala
+++ /dev/null
@@ -1,103 +0,0 @@
-package net.psforever.login
-
-import java.net.InetSocketAddress
-
-import akka.actor.MDCContextAware.Implicits._
-import akka.actor.{ActorContext, ActorRef, PoisonPill, _}
-import com.github.nscala_time.time.Imports._
-import scodec.bits._
-
-sealed trait SessionState
-final case class New() extends SessionState
-final case class Related() extends SessionState
-final case class Handshaking() extends SessionState
-final case class Established() extends SessionState
-final case class Closing() extends SessionState
-final case class Closed() extends SessionState
-
-class Session(
- val sessionId: Long,
- val socketAddress: InetSocketAddress,
- returnActor: ActorRef,
- sessionPipeline: List[SessionPipeline]
-)(
- implicit val context: ActorContext,
- implicit val self: ActorRef
-) {
-
- var state: SessionState = New()
- val sessionCreatedTime: DateTime = DateTime.now()
- var sessionEndedTime: DateTime = DateTime.now()
-
- val pipeline = sessionPipeline.map { actor =>
- val a = context.actorOf(actor.props, actor.nameTemplate + sessionId.toString)
- context.watch(a)
- a
- }
-
- val pipelineIter = pipeline.iterator
- if (pipelineIter.hasNext) {
- pipelineIter.next() ! HelloFriend(sessionId, pipelineIter)
- }
-
- // statistics
- var bytesSent: Long = 0
- var bytesReceived: Long = 0
- var inboundPackets: Long = 0
- var outboundPackets: Long = 0
-
- var lastInboundEvent: Long = System.nanoTime()
- var lastOutboundEvent: Long = System.nanoTime()
-
- var inboundPacketRate: Double = 0.0
- var outboundPacketRate: Double = 0.0
- var inboundBytesPerSecond: Double = 0.0
- var outboundBytesPerSecond: Double = 0.0
-
- def receive(packet: RawPacket): Unit = {
- bytesReceived += packet.data.size
- inboundPackets += 1
- lastInboundEvent = System.nanoTime()
-
- pipeline.head !> packet
- }
-
- def send(packet: ByteVector): Unit = {
- bytesSent += packet.size
- outboundPackets += 1
- lastOutboundEvent = System.nanoTime()
-
- returnActor ! SendPacket(packet, socketAddress)
- }
-
- def dropSession(graceful: Boolean) = {
- pipeline.foreach(context.unwatch)
- pipeline.foreach(_ ! PoisonPill)
-
- sessionEndedTime = DateTime.now()
- setState(Closed())
- }
-
- def getState = state
-
- def setState(newState: SessionState): Unit = {
- state = newState
- }
- def getPipeline: List[ActorRef] = pipeline
-
- def getTotalBytes = {
- bytesSent + bytesReceived
- }
-
- def timeSinceLastInboundEvent = {
- (System.nanoTime() - lastInboundEvent) / 1000000
- }
-
- def timeSinceLastOutboundEvent = {
- (System.nanoTime() - lastOutboundEvent) / 1000000
- }
-
- override def toString: String = {
- s"Session($sessionId, $getTotalBytes)"
- }
-}
diff --git a/src/main/scala/net/psforever/login/SessionRouter.scala b/src/main/scala/net/psforever/login/SessionRouter.scala
deleted file mode 100644
index a7a2e547d..000000000
--- a/src/main/scala/net/psforever/login/SessionRouter.scala
+++ /dev/null
@@ -1,198 +0,0 @@
-package net.psforever.login
-
-import java.net.InetSocketAddress
-
-import akka.actor.SupervisorStrategy.Stop
-import akka.actor._
-import net.psforever.packet.PacketCoding
-import net.psforever.packet.control.ConnectionClose
-import net.psforever.util.Config
-import org.log4s.MDC
-import scodec.bits._
-import net.psforever.services.ServiceManager
-import net.psforever.services.ServiceManager.Lookup
-import net.psforever.services.account.{IPAddress, StoreIPAddress}
-import scala.collection.mutable
-import scala.concurrent.duration._
-
-sealed trait SessionRouterAPI
-
-final case class RawPacket(data: ByteVector) extends SessionRouterAPI
-
-final case class ResponsePacket(data: ByteVector) extends SessionRouterAPI
-
-final case class DropSession(id: Long, reason: String) extends SessionRouterAPI
-
-final case class SessionReaper() extends SessionRouterAPI
-
-case class SessionPipeline(nameTemplate: String, props: Props)
-
-/**
- * Login sessions are divided between two actors. The crypto session actor transparently handles all of the cryptographic
- * setup of the connection. Once a correct crypto session has been established, all packets, after being decrypted
- * will be passed on to the login session actor. This actor has important state that is used to maintain the login
- * session.
- *
- * > PlanetSide Session Pipeline <
- *
- * read() route decrypt
- * UDP Socket -----> [Session Router] -----> [Crypto Actor] -----> [Session Actor]
- * /|\ | /|\ | /|\ |
- * | write() | | encrypt | | response |
- * +--------------+ +-----------+ +-----------------+
- */
-class SessionRouter(role: String, pipeline: List[SessionPipeline]) extends Actor with MDCContextAware {
- private[this] val log = org.log4s.getLogger(self.path.name)
-
- import scala.concurrent.ExecutionContext.Implicits.global
- val sessionReaper = context.system.scheduler.scheduleWithFixedDelay(10 seconds, 5 seconds, self, SessionReaper())
-
- val idBySocket = mutable.Map[InetSocketAddress, Long]()
- val sessionById = mutable.Map[Long, Session]()
- val sessionByActor = mutable.Map[ActorRef, Session]()
- val closePacket = PacketCoding.EncodePacket(ConnectionClose()).require.bytes
- var accountIntermediary: ActorRef = ActorRef.noSender
-
- var sessionId = 0L // this is a connection session, not an actual logged in session ID
- var inputRef: ActorRef = ActorRef.noSender
-
- override def supervisorStrategy = OneForOneStrategy() { case _ => Stop }
-
- override def preStart() = {
- log.info(s"SessionRouter (for ${role}s) initializing ...")
- }
-
- def receive = initializing
-
- def initializing: Receive = {
- case Hello() =>
- inputRef = sender()
- ServiceManager.serviceManager ! Lookup("accountIntermediary")
- case ServiceManager.LookupResult("accountIntermediary", endpoint) =>
- accountIntermediary = endpoint
- log.info(s"SessionRouter starting; ready for $role sessions")
- context.become(started)
- case default =>
- log.error(s"Unknown or unexpected message $default before being properly started. Stopping completely...")
- context.stop(self)
- }
-
- override def postStop() = {
- sessionReaper.cancel()
- }
-
- def started: Receive = {
- case _ @ReceivedPacket(msg, from) =>
- var session: Session = null
-
- if (!idBySocket.contains(from)) {
- session = createNewSession(from)
- } else {
- val id = idBySocket { from }
- session = sessionById { id }
- }
-
- if (session.state != Closed()) {
- MDC("sessionId") = session.sessionId.toString
- log.trace(s"RECV: $msg -> ${session.getPipeline.head.path.name}")
- session.receive(RawPacket(msg))
- MDC.clear()
- }
- case ResponsePacket(msg) =>
- val session = sessionByActor.get(sender())
-
- if (session.isDefined) {
- if (session.get.state != Closed()) {
- MDC("sessionId") = session.get.sessionId.toString
- log.trace(s"SEND: $msg -> ${inputRef.path.name}")
- session.get.send(msg)
- MDC.clear()
- }
- } else {
- log.error("Dropped old response packet from actor " + sender().path.name)
- }
- case DropSession(id, reason) =>
- val session = sessionById.get(id)
-
- if (session.isDefined) {
- removeSessionById(id, reason, graceful = true)
- } else {
- log.error(s"Requested to drop non-existent session ID=$id from ${sender()}")
- }
- case SessionReaper() =>
- val inboundGrace = Config.app.network.session.inboundGraceTime.toMillis
- val outboundGrace = Config.app.network.session.outboundGraceTime.toMillis
-
- sessionById.foreach {
- case (id, session) =>
- log.trace(session.toString)
- if (session.getState == Closed()) {
- // clear mappings
- session.getPipeline.foreach(sessionByActor remove)
- sessionById.remove(id)
- idBySocket.remove(session.socketAddress)
- log.debug(s"Reaped session ID=$id")
- } else if (session.timeSinceLastInboundEvent > inboundGrace) {
- removeSessionById(id, "session timed out (inbound)", graceful = false)
- } else if (session.timeSinceLastOutboundEvent > outboundGrace) {
- removeSessionById(id, "session timed out (outbound)", graceful = true) // tell client to STFU
- }
- }
- case Terminated(actor) =>
- val terminatedSession = sessionByActor.get(actor)
-
- if (terminatedSession.isDefined) {
- removeSessionById(terminatedSession.get.sessionId, s"${actor.path.name} died", graceful = true)
- } else {
- log.error("Received an invalid actor Termination from " + actor.path.name)
- }
- case default =>
- log.error(s"Unknown message $default from " + sender().path)
- }
-
- def createNewSession(address: InetSocketAddress) = {
- val id = newSessionId
- val session = new Session(id, address, inputRef, pipeline)
-
- // establish mappings for easy lookup
- idBySocket { address } = id
- sessionById { id } = session
-
- session.getPipeline.foreach { actor =>
- sessionByActor { actor } = session
- }
-
- log.info(s"New session ID=$id from " + address.toString)
-
- if (role == "Login") {
- accountIntermediary ! StoreIPAddress(id, new IPAddress(address))
- }
-
- session
- }
-
- def removeSessionById(id: Long, reason: String, graceful: Boolean): Unit = {
- val sessionOption = sessionById.get(id)
-
- if (sessionOption.isEmpty)
- return
-
- val session: Session = sessionOption.get
-
- if (graceful) {
- for (_ <- 0 to 5) {
- session.send(closePacket)
- }
- }
-
- // kill all session specific actors
- session.dropSession(graceful)
- log.info(s"Dropping session ID=$id (reason: $reason)")
- }
-
- def newSessionId = {
- val oldId = sessionId
- sessionId += 1
- oldId
- }
-}
diff --git a/src/main/scala/net/psforever/login/UdpListener.scala b/src/main/scala/net/psforever/login/UdpListener.scala
deleted file mode 100644
index e48b0d92d..000000000
--- a/src/main/scala/net/psforever/login/UdpListener.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-package net.psforever.login
-
-import java.net.{InetAddress, InetSocketAddress}
-
-import akka.actor.SupervisorStrategy.Stop
-import akka.actor.{Actor, ActorRef, OneForOneStrategy, Props, Terminated}
-import akka.io._
-import scodec.bits._
-import scodec.interop.akka._
-
-final case class ReceivedPacket(msg: ByteVector, from: InetSocketAddress)
-final case class SendPacket(msg: ByteVector, to: InetSocketAddress)
-final case class Hello()
-final case class HelloFriend(sessionId: Long, next: Iterator[ActorRef])
-
-class UdpListener(
- nextActorProps: Props,
- nextActorName: String,
- listenAddress: InetAddress,
- port: Int,
- netParams: Option[NetworkSimulatorParameters]
-) extends Actor {
- private val log = org.log4s.getLogger(self.path.name)
-
- override def supervisorStrategy =
- OneForOneStrategy() {
- case _ => Stop
- }
-
- import context.system
-
- // If we have network parameters, start the network simulator
- if (netParams.isDefined) {
- // See http://www.cakesolutions.net/teamblogs/understanding-akkas-recommended-practice-for-actor-creation-in-scala
- // For why we cant do Props(new Actor) here
- val sim = context.actorOf(Props(classOf[UdpNetworkSimulator], self, netParams.get))
- IO(Udp).tell(Udp.Bind(sim, new InetSocketAddress(listenAddress, port)), sim)
- } else {
- IO(Udp) ! Udp.Bind(self, new InetSocketAddress(listenAddress, port))
- }
-
- var bytesRecevied = 0L
- var bytesSent = 0L
- var nextActor: ActorRef = ActorRef.noSender
-
- def receive = {
- case Udp.Bound(local) =>
- log.info(s"Now listening on UDP:$local")
-
- createNextActor()
- context.become(ready(sender()))
- case Udp.CommandFailed(Udp.Bind(_, address, _)) =>
- log.error("Failed to bind to the network interface: " + address)
- context.system.terminate()
- case default =>
- log.error(s"Unexpected message $default")
- }
-
- def ready(socket: ActorRef): Receive = {
- case SendPacket(msg, to) =>
- bytesSent += msg.size
- socket ! Udp.Send(msg.toByteString, to)
- case Udp.Received(data, remote) =>
- bytesRecevied += data.size
- nextActor ! ReceivedPacket(data.toByteVector, remote)
- case Udp.Unbind => socket ! Udp.Unbind
- case Udp.Unbound => context.stop(self)
- case Terminated(actor) =>
- log.error(s"Next actor ${actor.path.name} has died...restarting")
- createNextActor()
- case default => log.error(s"Unhandled message: $default")
- }
-
- def createNextActor() = {
- nextActor = context.actorOf(nextActorProps, nextActorName)
- context.watch(nextActor)
- nextActor ! Hello()
- }
-}
diff --git a/src/main/scala/net/psforever/login/UdpNetworkSimulator.scala b/src/main/scala/net/psforever/login/UdpNetworkSimulator.scala
deleted file mode 100644
index 2e466c744..000000000
--- a/src/main/scala/net/psforever/login/UdpNetworkSimulator.scala
+++ /dev/null
@@ -1,146 +0,0 @@
-package net.psforever.login
-
-import akka.actor.{Actor, ActorRef}
-import akka.io._
-
-import scala.collection.mutable
-import scala.concurrent.duration._
-import scala.util.Random
-
-/** Parameters for the Network simulator
- *
- * @param packetLoss The percentage from [0.0, 1.0] that a packet will be lost
- * @param packetDelay The end-to-end delay (ping) of all packets
- * @param packetReorderingChance The percentage from [0.0, 1.0] that a packet will be reordered
- * @param packetReorderingTime The absolute adjustment in milliseconds that a packet can have (either
- * forward or backwards in time)
- */
-case class NetworkSimulatorParameters(
- packetLoss: Double,
- packetDelay: Long,
- packetReorderingChance: Double,
- packetReorderingTime: Long
-) {
- assert(packetLoss >= 0.0 && packetLoss <= 1.0)
- assert(packetDelay >= 0)
- assert(packetReorderingChance >= 0.0 && packetReorderingChance <= 1.0)
- assert(packetReorderingTime >= 0)
-
- override def toString =
- "NetSimParams: loss %.2f%% / delay %dms / reorder %.2f%% / reorder +/- %dms".format(
- packetLoss * 100,
- packetDelay,
- packetReorderingChance * 100,
- packetReorderingTime
- )
-}
-
-class UdpNetworkSimulator(server: ActorRef, params: NetworkSimulatorParameters) extends Actor {
- private val log = org.log4s.getLogger
-
- import scala.concurrent.ExecutionContext.Implicits.global
-
- //******* Variables
- val packetDelayDuration = (params.packetDelay / 2).milliseconds
-
- type QueueItem = (Udp.Message, Long)
-
- // sort in ascending order (older things get dequeued first)
- implicit val QueueItem = Ordering.by[QueueItem, Long](_._2).reverse
-
- val inPacketQueue = mutable.PriorityQueue[QueueItem]()
- val outPacketQueue = mutable.PriorityQueue[QueueItem]()
-
- val chaos = new Random()
- var interface = ActorRef.noSender
-
- def receive = {
- case UdpNetworkSimulator.ProcessInputQueue() =>
- val time = System.nanoTime()
- var exit = false
-
- while (inPacketQueue.nonEmpty && !exit) {
- val lastTime = time - inPacketQueue.head._2
-
- // this packet needs to be sent within 20 milliseconds or more
- if (lastTime >= 20000000) {
- server.tell(inPacketQueue.dequeue()._1, interface)
- } else {
- schedule(lastTime.nanoseconds, outbound = false)
- exit = true
- }
- }
- case UdpNetworkSimulator.ProcessOutputQueue() =>
- val time = System.nanoTime()
- var exit = false
-
- while (outPacketQueue.nonEmpty && !exit) {
- val lastTime = time - outPacketQueue.head._2
-
- // this packet needs to be sent within 20 milliseconds or more
- if (lastTime >= 20000000) {
- interface.tell(outPacketQueue.dequeue()._1, server)
- } else {
- schedule(lastTime.nanoseconds, outbound = true)
- exit = true
- }
- }
- // outbound messages
- case msg @ Udp.Send(payload, target, _) =>
- handlePacket(msg, outPacketQueue, outbound = true)
- // inbound messages
- case msg @ Udp.Received(payload, sender) =>
- handlePacket(msg, inPacketQueue, outbound = false)
- case msg @ Udp.Bound(address) =>
- interface = sender()
- log.info(s"Hooked ${server.path} for network simulation")
- server.tell(msg, self) // make sure the server sends *us* the packets
- case default =>
- val from = sender()
-
- if (from == server)
- interface.tell(default, server)
- else if (from == interface)
- server.tell(default, interface)
- else
- log.error("Unexpected sending Actor " + from.path)
- }
-
- def handlePacket(message: Udp.Message, queue: mutable.PriorityQueue[QueueItem], outbound: Boolean) = {
- val name: String = if (outbound) "OUT" else "IN"
- val queue: mutable.PriorityQueue[QueueItem] = if (outbound) outPacketQueue else inPacketQueue
-
- if (chaos.nextDouble() > params.packetLoss) {
- // if the message queue is empty, then we need to reschedule our task
- if (queue.isEmpty)
- schedule(packetDelayDuration, outbound)
-
- // perform a reordering
- if (chaos.nextDouble() <= params.packetReorderingChance) {
- // creates the range (-1.0, 1.0)
- // time adjustment to move the packet (forward or backwards in time)
- val adj = (2 * (chaos.nextDouble() - 0.5) * params.packetReorderingTime).toLong
- queue += ((message, System.nanoTime() + adj * 1000000))
-
- log.debug(s"Reordered $name by ${adj}ms - $message")
- } else { // normal message
- queue += ((message, System.nanoTime()))
- }
- } else {
- log.debug(s"Dropped $name - $message")
- }
- }
-
- def schedule(duration: FiniteDuration, outbound: Boolean) =
- context.system.scheduler.scheduleOnce(
- packetDelayDuration,
- self,
- if (outbound) UdpNetworkSimulator.ProcessOutputQueue() else UdpNetworkSimulator.ProcessInputQueue()
- )
-}
-
-object UdpNetworkSimulator {
- //******* Internal messages
- private final case class ProcessInputQueue()
- private final case class ProcessOutputQueue()
-}
diff --git a/src/main/scala/net/psforever/login/psadmin/PsAdminActor.scala b/src/main/scala/net/psforever/login/psadmin/PsAdminActor.scala
index fc8dea961..0028cc442 100644
--- a/src/main/scala/net/psforever/login/psadmin/PsAdminActor.scala
+++ b/src/main/scala/net/psforever/login/psadmin/PsAdminActor.scala
@@ -93,6 +93,9 @@ class PsAdminActor(peerAddress: InetSocketAddress, connection: ActorRef) extends
case Tcp.PeerClosed =>
context.stop(self)
+ case Tcp.ErrorClosed(_) =>
+ context.stop(self)
+
case default =>
log.error(s"Unexpected message $default")
}
diff --git a/src/main/scala/net/psforever/objects/serverobject/containable/ContainableBehavior.scala b/src/main/scala/net/psforever/objects/serverobject/containable/ContainableBehavior.scala
index 4c9bd9411..5e8bbbfc9 100644
--- a/src/main/scala/net/psforever/objects/serverobject/containable/ContainableBehavior.scala
+++ b/src/main/scala/net/psforever/objects/serverobject/containable/ContainableBehavior.scala
@@ -23,10 +23,10 @@ sealed trait DeferrableMsg extends ContainableMsg
/**
* A mixin for handling synchronized movement of `Equipment` items into or out from `Container` entities.
- * The most important feature of this synchronization is the movmement of equipment
+ * The most important feature of this synchronization is the movemement of equipment
* out from one container into another container
* without causing representation overlap, overwriting, or unintended stacking of other equipment
- * including equipment that has nort yet been inserted.
+ * including equipment that has not yet been inserted.
*/
trait ContainableBehavior {
_: Actor =>
diff --git a/src/main/scala/net/psforever/packet/CryptoPacketOpcode.scala b/src/main/scala/net/psforever/packet/CryptoPacketOpcode.scala
index 3a3260e70..4a345f0b6 100644
--- a/src/main/scala/net/psforever/packet/CryptoPacketOpcode.scala
+++ b/src/main/scala/net/psforever/packet/CryptoPacketOpcode.scala
@@ -1,10 +1,9 @@
-// Copyright (c) 2017 PSForever
package net.psforever.packet
import scodec.bits.BitVector
import scodec.{Attempt, DecodeResult, Err}
-// this isnt actually used as an opcode (i.e not serialized)
+// This isn't actually used as an opcode (i.e not serialized)
object CryptoPacketOpcode extends Enumeration {
type Type = Value
val Ignore, ClientChallengeXchg, ServerChallengeXchg, ClientFinished, ServerFinished = Value
diff --git a/src/main/scala/net/psforever/packet/PacketCoding.scala b/src/main/scala/net/psforever/packet/PacketCoding.scala
index ce0dc9549..09831325d 100644
--- a/src/main/scala/net/psforever/packet/PacketCoding.scala
+++ b/src/main/scala/net/psforever/packet/PacketCoding.scala
@@ -1,246 +1,156 @@
// Copyright (c) 2017 PSForever
package net.psforever.packet
-import net.psforever.crypto.CryptoInterface
+import java.security.{Key, SecureRandom, Security}
+
+import javax.crypto.Cipher
+import javax.crypto.spec.RC5ParameterSpec
import scodec.Attempt.{Failure, Successful}
import scodec.bits._
-import scodec.{Attempt, Codec, Err}
+import scodec.{Attempt, Codec, DecodeResult, Err}
import scodec.codecs.{bytes, uint16L, uint8L}
-
-/**
- * Base trait of the packet container `case class`.
- */
-sealed trait PlanetSidePacketContainer
-
-/**
- * An encrypted packet contains the following:
- * a sequence;
- * an encrypted opcode;
- * an encrypted payload;
- * and an implicit MD5MAC plus padding.
- * @param sequenceNumber na
- * @param payload the packet data
- */
-final case class EncryptedPacket(sequenceNumber: Int, payload: ByteVector) extends PlanetSidePacketContainer
-
-/**
- * A crypto packet contains the following:
- * a sequence;
- * and, a payload.
- * These packets have no opcodes and they rely on implicit state to decode properly.
- * @param sequenceNumber na
- * @param packet the packet data
- */
-final case class CryptoPacket(sequenceNumber: Int, packet: PlanetSideCryptoPacket) extends PlanetSidePacketContainer
-
-/**
- * A game packet is prefaced by a byte that determines the type of packet and how to interpret the data.
- * This is important for decoding and encoding.
- * @param opcode a byte that identifies the packet
- * @param sequenceNumber na
- * @param packet the packet data
- */
-final case class GamePacket(opcode: GamePacketOpcode.Value, sequenceNumber: Int, packet: PlanetSideGamePacket)
- extends PlanetSidePacketContainer
-
-/**
- * A control packet is prefaced with a zero'd byte (`00`) followed by a special byte opcode for the type of control packet.
- * @param opcode a byte that identifies the packet
- * @param packet the packet data
- */
-final case class ControlPacket(opcode: ControlPacketOpcode.Value, packet: PlanetSideControlPacket)
- extends PlanetSidePacketContainer
+import org.bouncycastle.jce.provider.BouncyCastleProvider
+import scodec.bits.ByteVector
+import net.psforever.util.Md5Mac
object PacketCoding {
+ Security.addProvider(new BouncyCastleProvider)
- /**
- * Access to the `ControlPacket` constructor.
- * @param packet a `PlanetSideControlPacket`
- * @return a `ControlPacket`
- */
- def CreateControlPacket(packet: PlanetSideControlPacket) = ControlPacket(packet.opcode, packet)
+ private val random = new SecureRandom()
- /**
- * Access to the `CryptoPacket` constructor.
- * @param sequence na
- * @param packet a `PlanetSideCryptoPacket`
- * @return a `CryptoPacket`
- */
- def CreateCryptoPacket(sequence: Int, packet: PlanetSideCryptoPacket) = CryptoPacket(sequence, packet)
+ val RC5_BLOCK_SIZE = 8
- /**
- * Access to the `GamePacket` constructor.
- * @param sequence na
- * @param packet a `PlanetSideGamePacket`
- * @return a `GamePacket`
- */
- def CreateGamePacket(sequence: Int, packet: PlanetSideGamePacket) = GamePacket(packet.opcode, sequence, packet)
-
- /* Marshalling and Encoding. */
+ /** A lower bound on the packet size */
+ final val PLANETSIDE_MIN_PACKET_SIZE = 1
/**
* Transform a kind of packet into the sequence of data that represents it.
* Wraps around the encoding process for all valid packet container types.
* @param packet the packet to encode
+ * @param sequence the packet's sequence number. Must be set for all non ControlPacket packets (but always for encrypted packets).
+ * @param crypto if set, encrypt final payload
* @return a `BitVector` translated from the packet's data
*/
- def MarshalPacket(packet: PlanetSidePacketContainer): Attempt[BitVector] = {
- var flagsEncoded: BitVector = BitVector.empty //flags before everything in packet
- var seqEncoded: BitVector = BitVector.empty //control packets have a sequence number
- var paddingEncoded: BitVector = BitVector.empty //encrypted packets need to be aligned in a certain way
- var payloadEncoded: BitVector = BitVector.empty //the packet itself as bits and bytes
- var controlPacket = false
- var sequenceNum = 0
- //packet flags
- var secured = false
- var packetType = PacketType.Crypto
-
- packet match {
- case GamePacket(_, seq, payload) =>
- packetType = PacketType.Normal
- sequenceNum = seq
- EncodePacket(payload) match {
- case f @ Failure(_) => return f
- case Successful(p) => payloadEncoded = p
+ def marshalPacket(
+ packet: PlanetSidePacket,
+ sequence: Option[Int] = None,
+ crypto: Option[CryptoCoding] = None
+ ): Attempt[BitVector] = {
+ val seq = packet match {
+ case _: PlanetSideControlPacket if crypto.isEmpty => BitVector.empty
+ case _ =>
+ sequence match {
+ case Some(sequence) =>
+ uint16L.encode(sequence) match {
+ case Successful(seq) => seq
+ case f @ Failure(_) => return f
+ }
+ case None =>
+ return Failure(Err(s"Missing sequence"))
}
+ }
- case ControlPacket(_, payload) =>
- controlPacket = true
- EncodePacket(payload) match {
+ val (flags, payload) = packet match {
+ case _: PlanetSideGamePacket | _: PlanetSideControlPacket if crypto.isDefined =>
+ encodePacket(packet) match {
+ case Successful(payload) =>
+ val encryptedPayload = crypto.get.encrypt(payload.bytes) match {
+ case Successful(p) => p
+ case f: Failure => return f
+ }
+ (
+ PlanetSidePacketFlags.codec.encode(PlanetSidePacketFlags(PacketType.Normal, secured = true)).require,
+ // encrypted packets need to be aligned to 4 bytes before encryption/decryption
+ // first byte are flags, second is the sequence, and third is the pad
+ hex"00".bits ++ encryptedPayload.bits
+ )
case f @ Failure(_) => return f
- case Successful(p) => payloadEncoded = p
}
-
- case CryptoPacket(seq, payload) =>
- packetType = PacketType.Crypto
- sequenceNum = seq
- EncodePacket(payload) match {
+ case packet: PlanetSideGamePacket =>
+ encodePacket(packet) match {
+ case Successful(payload) =>
+ (
+ PlanetSidePacketFlags.codec.encode(PlanetSidePacketFlags(PacketType.Normal, secured = false)).require,
+ payload
+ )
+ case f @ Failure(_) => return f
+ }
+ case packet: PlanetSideControlPacket =>
+ encodePacket(packet) match {
+ case Successful(payload) =>
+ (
+ // control packets don't have flags
+ BitVector.empty,
+ payload
+ )
+ case f @ Failure(_) => return f
+ }
+ case packet: PlanetSideCryptoPacket =>
+ encodePacket(packet) match {
+ case Successful(payload) =>
+ (
+ PlanetSidePacketFlags.codec.encode(PlanetSidePacketFlags(PacketType.Crypto, secured = false)).require,
+ payload
+ )
case f @ Failure(_) => return f
- case Successful(p) => payloadEncoded = p
}
-
- case EncryptedPacket(seq, payload) =>
- secured = true
- packetType = PacketType.Normal
- sequenceNum = seq
- //encrypted packets need to be aligned to 4 bytes before encryption/decryption
- //first byte are flags, second is the sequence, and third is the pad
- paddingEncoded = hex"00".bits
- payloadEncoded = payload.bits
}
- //crypto packets DON'T have flags
- if (!controlPacket) {
- val flags = PlanetSidePacketFlags(packetType, secured = secured)
- flagsEncoded = PlanetSidePacketFlags.codec.encode(flags).require
- uint16L.encode(sequenceNum) match {
- case Failure(e) =>
- return Attempt.failure(Err(s"Failed to marshal sequence in packet $packet: " + e.messageWithContext))
- case Successful(p) => seqEncoded = p
- }
- }
- Attempt.successful(flagsEncoded ++ seqEncoded ++ paddingEncoded ++ payloadEncoded)
+ Successful(flags ++ seq ++ payload)
}
/**
- * Overloaded method for transforming a `ControlPacket` into its `BitVector` representation.
- * @param packet the control packet to encode
- * @return a `BitVector` translated from the packet's data
- */
- def EncodePacket(packet: PlanetSideControlPacket): Attempt[BitVector] = {
- val opcode = packet.opcode
- var opcodeEncoded = BitVector.empty
- ControlPacketOpcode.codec.encode(opcode) match {
- case Failure(e) =>
- return Attempt.failure(Err(s"Failed to marshal opcode in control packet $opcode: " + e.messageWithContext))
- case Successful(p) => opcodeEncoded = p
- }
- var payloadEncoded = BitVector.empty
- encodePacket(packet) match {
- case Failure(e) =>
- return Attempt.failure(Err(s"Failed to marshal control packet $packet: " + e.messageWithContext))
- case Successful(p) => payloadEncoded = p
- }
- Attempt.Successful(hex"00".bits ++ opcodeEncoded ++ payloadEncoded)
- }
-
- /**
- * Overloaded method for transforming a `CryptoPacket` into its `BitVector` representation.
- * @param packet the crypto packet to encode
- * @return a `BitVector` translated from the packet's data
- */
- def EncodePacket(packet: PlanetSideCryptoPacket): Attempt[BitVector] = {
- encodePacket(packet) match {
- case Failure(e) => Attempt.failure(Err(s"Failed to marshal crypto packet $packet: " + e.messageWithContext))
- case s @ Successful(_) => s
- }
- }
-
- /**
- * Overloaded method for transforming a `GamePacket` into its `BitVector` representation.
- * @param packet the game packet to encode
- * @return a `BitVector` translated from the packet's data
- */
- def EncodePacket(packet: PlanetSideGamePacket): Attempt[BitVector] = {
- val opcode = packet.opcode
- var opcodeEncoded = BitVector.empty
- GamePacketOpcode.codec.encode(opcode) match {
- case Failure(e) =>
- return Attempt.failure(Err(s"Failed to marshal opcode in game packet $opcode: " + e.messageWithContext))
- case Successful(p) => opcodeEncoded = p
- }
- var payloadEncoded = BitVector.empty
- encodePacket(packet) match {
- case Failure(e) => return Attempt.failure(Err(s"Failed to marshal game packet $packet: " + e.messageWithContext))
- case Successful(p) => payloadEncoded = p
- }
- Attempt.Successful(opcodeEncoded ++ payloadEncoded)
- }
-
- /**
- * Calls the packet's own `encode` function.
- * Lowest encode call before the packet-specific implementations.
+ * Transform a `PlanetSidePacket` into its `BitVector` representation.
* @param packet the packet to encode
* @return a `BitVector` translated from the packet's data
*/
- private def encodePacket(packet: PlanetSidePacket): Attempt[BitVector] = packet.encode
-
- /* Unmarshalling and Decoding. */
-
- /**
- * A lower bound on the packet size
- */
- final val PLANETSIDE_MIN_PACKET_SIZE = 1
+ def encodePacket(packet: PlanetSidePacket): Attempt[BitVector] = {
+ packet.encode match {
+ case Successful(payload) =>
+ packet match {
+ case _: PlanetSideCryptoPacket => Successful(payload)
+ case packet: PlanetSideControlPacket =>
+ ControlPacketOpcode.codec.encode(packet.opcode) match {
+ case Successful(opcode) => Successful(hex"00".bits ++ opcode ++ payload)
+ case f @ Failure(_) => f
+ }
+ case packet: PlanetSideGamePacket =>
+ GamePacketOpcode.codec.encode(packet.opcode) match {
+ case Successful(opcode) => Successful(opcode ++ payload)
+ case f @ Failure(_) => f
+ }
+ }
+ case f @ Failure(_) => f
+ }
+ }
/**
* Transforms `ByteVector` data into a PlanetSide packet.
* Attempt to decode with an optional header and required payload.
* Does not decode into a `GamePacket`.
* @param msg the raw packet
+ * @param crypto CryptoCoding instance for packet decryption, if this is a encrypted packet
* @param cryptoState the current state of the connection's crypto. This is only used when decoding
* crypto packets as they do not have opcodes
* @return `PlanetSidePacketContainer`
*/
- def UnmarshalPacket(msg: ByteVector, cryptoState: CryptoPacketOpcode.Type): Attempt[PlanetSidePacketContainer] = {
- if (msg.length < PLANETSIDE_MIN_PACKET_SIZE)
- return Attempt.failure(Err(s"Packet does not meet the minimum length of $PLANETSIDE_MIN_PACKET_SIZE bytes"))
-
- val firstByte = msg { 0 }
- firstByte match {
- case 0x00 => unmarshalControlPacket(msg.drop(1)) //control packets dont need the first byte
- case _ => unmarshalFlaggedPacket(msg, cryptoState) //either EncryptedPacket or CryptoPacket
+ def unmarshalPacket(
+ msg: ByteVector,
+ crypto: Option[CryptoCoding] = None,
+ cryptoState: CryptoPacketOpcode.Type = CryptoPacketOpcode.Ignore
+ ): Attempt[(PlanetSidePacket, Option[Int])] = {
+ if (msg.length < PLANETSIDE_MIN_PACKET_SIZE) {
+ Failure(Err(s"Packet does not meet the minimum length of $PLANETSIDE_MIN_PACKET_SIZE bytes"))
+ } else {
+ msg(0) match {
+ // ControlPacket
+ case 0x00 => decodePacket(msg).map(p => (p, None))
+ // either encrypted payload or CryptoPacket
+ case _ => unmarshalFlaggedPacket(msg, cryptoState, crypto).map { case (p, s) => (p, Some(s)) }
+ }
}
}
- /**
- * Helper function to decode a packet without specifying a crypto state.
- * Used when there is no crypto state available such as in tests.
- * @param msg packet data bytes
- * @return `PlanetSidePacketContainer`
- */
- def UnmarshalPacket(msg: ByteVector): Attempt[PlanetSidePacketContainer] =
- UnmarshalPacket(msg, CryptoPacketOpcode.Ignore)
-
/**
* Handle decoding for a packet that has been identified as not a `ControlPacket`.
* It may just be encrypted (`EncryptedPacket`) or it may be involved in the encryption process itself (`CryptoPacket`).
@@ -250,106 +160,50 @@ object PacketCoding {
*/
private def unmarshalFlaggedPacket(
msg: ByteVector,
- cryptoState: CryptoPacketOpcode.Type
- ): Attempt[PlanetSidePacketContainer] = {
- val decodedFlags = Codec.decode[PlanetSidePacketFlags](BitVector(msg)) //get the flags
- decodedFlags match {
- case Failure(e) =>
- return Attempt.failure(Err("Failed to parse packet flags: " + e.message))
- case _ =>
+ cryptoState: CryptoPacketOpcode.Type,
+ crypto: Option[CryptoCoding] = None
+ ): Attempt[(PlanetSidePacket, Int)] = {
+ val (flags, remainder) = Codec.decode[PlanetSidePacketFlags](BitVector(msg)) match {
+ case Successful(DecodeResult(value, remainder)) => (value, remainder)
+ case Failure(e) => return Failure(Err(s"Failed to parse packet flags: ${e.message}"))
}
- val flags = decodedFlags.require.value
- val packetType = flags.packetType
- packetType match {
+
+ flags.packetType match {
case PacketType.Normal =>
- if (!flags.secured) { //support normal packets only if they are encrypted
- return Attempt.failure(Err("Unsupported packet type: normal packets must be encryped"))
+ // support normal packets only if they are encrypted
+ if (!flags.secured) {
+ return Failure(Err("Unsupported packet type: normal packets must be encryped"))
}
-
case PacketType.Crypto =>
- if (flags.secured) { //support crypto packets only if they are not encrypted
- return Attempt.failure(Err("Unsupported packet type: crypto packets must be unencrypted"))
+ if (flags.secured && crypto.isEmpty) {
+ return Failure(Err("Unsupported packet type: crypto packets must be unencrypted"))
}
-
case _ =>
- return Attempt.failure(Err("Unsupported packet type: " + flags.packetType.toString))
+ return Failure(Err(s"Unsupported packet type: ${flags.packetType.toString}"))
}
- //all packets have a two byte sequence ID
- val decodedSeq = uint16L.decode(decodedFlags.require.remainder) //TODO: make this a codec for reuse
- decodedSeq match {
+
+ // all packets have a two byte sequence ID
+ val (sequence, payload) = uint16L.decode(remainder) match {
+ case Successful(DecodeResult(value, remainder)) =>
+ (value, remainder.toByteVector)
case Failure(e) =>
- return Attempt.failure(Err("Failed to parse packet sequence number: " + e.message))
- case _ =>
+ return Failure(Err(s"Failed to parse packet sequence number: ${e.message}"))
}
- val sequence = decodedSeq.require.value
- val payload = decodedSeq.require.remainder.toByteVector
- packetType match {
- case PacketType.Crypto =>
- unmarshalCryptoPacket(cryptoState, sequence, payload)
- case PacketType.Normal =>
- unmarshalEncryptedPacket(sequence, payload.drop(1)) //payload is 4-byte aligned
- }
- }
- /**
- * Handle decoding for a `ControlPacket`.
- * @param msg the packet
- * @return a `ControlPacket`
- */
- private def unmarshalControlPacket(msg: ByteVector): Attempt[ControlPacket] = {
- DecodeControlPacket(msg) match {
- case f @ Failure(_) =>
- f
- case Successful(p) =>
- Attempt.successful(CreateControlPacket(p))
+ (flags.packetType, crypto) match {
+ case (PacketType.Crypto, _) =>
+ CryptoPacketOpcode
+ .getPacketDecoder(cryptoState)(payload.bits)
+ .map(p => (p.value.asInstanceOf[PlanetSidePacket], sequence))
+ case (PacketType.Normal, Some(crypto)) if flags.secured =>
+ // encrypted payload is 4-byte aligned: 1b flags, 2b sequence, 1b padding
+ crypto.decrypt(payload.drop(1)).map(p => decodePacket(p)).flatten.map(p => (p, sequence))
+ case (PacketType.Normal, None) if !flags.secured =>
+ decodePacket(payload).map(p => (p, sequence))
+ case (PacketType.Normal, None) =>
+ Failure(Err(s"Cannot unmarshal encrypted packet without CryptoCoding"))
}
- }
- /**
- * Handle decoding for a `GamePacket`.
- * @param sequence na
- * @param msg the packet data
- * @return a `GamePacket`
- */
- private def unmarshalGamePacket(sequence: Int, msg: ByteVector): Attempt[GamePacket] = {
- DecodeGamePacket(msg) match {
- case f @ Failure(_) =>
- f
- case Successful(p) =>
- Attempt.successful(CreateGamePacket(sequence, p))
- }
- }
-
- /**
- * Handle decoding for a `CryptoPacket`.
- * @param state the current cryptographic state
- * @param sequence na
- * @param payload the packet data
- * @return a `CryptoPacket`
- */
- private def unmarshalCryptoPacket(
- state: CryptoPacketOpcode.Type,
- sequence: Int,
- payload: ByteVector
- ): Attempt[CryptoPacket] = {
- CryptoPacketOpcode.getPacketDecoder(state)(payload.bits) match {
- case Successful(a) =>
- Attempt.successful(CryptoPacket(sequence, a.value))
- case Failure(e) =>
- Attempt.failure(e.pushContext("unmarshal_crypto_packet"))
- }
- }
-
- /**
- * Handle decoding for an `EncryptedPacket`.
- * The payload is already encrypted.
- * Just repackage the data.
- * @param sequence na
- * @param payload the packet data
- * @return an `EncryptedPacket`
- */
- private def unmarshalEncryptedPacket(sequence: Int, payload: ByteVector): Attempt[EncryptedPacket] = {
- Attempt.successful(EncryptedPacket(sequence, payload))
}
/**
@@ -361,233 +215,110 @@ object PacketCoding {
* @return `PlanetSidePacket`
* @see `UnMarshalPacket`
*/
- def DecodePacket(msg: ByteVector): Attempt[PlanetSidePacket] = {
+ def decodePacket(msg: ByteVector): Attempt[PlanetSidePacket] = {
if (msg.length < PLANETSIDE_MIN_PACKET_SIZE)
- return Attempt.failure(Err(s"Packet does not meet the minimum length of $PLANETSIDE_MIN_PACKET_SIZE bytes"))
+ return Failure(Err(s"Packet does not meet the minimum length of $PLANETSIDE_MIN_PACKET_SIZE bytes"))
val firstByte = msg { 0 }
firstByte match {
- case 0x00 => DecodeControlPacket(msg.drop(1)) //control packets dont need the first byte
- case _ => DecodeGamePacket(msg)
- }
- }
-
- /**
- * Transform a `ByteVector` into a `ControlPacket`.
- * @param msg the the raw data to decode
- * @return a `PlanetSideControlPacket`
- */
- def DecodeControlPacket(msg: ByteVector): Attempt[PlanetSideControlPacket] = {
- ControlPacketOpcode.codec.decode(msg.bits) match {
- case Failure(e) =>
- Attempt.failure(Err("Failed to decode control packet's opcode: " + e.message))
-
- case Successful(op) =>
- ControlPacketOpcode.getPacketDecoder(op.value)(op.remainder) match {
- case Failure(e) =>
- Attempt.failure(Err(f"Failed to parse control packet ${op.value}: " + e.messageWithContext))
-
- case Successful(p) =>
- Attempt.successful(p.value)
- }
- }
- }
-
- /**
- * Transform a `ByteVector` into a `GamePacket`.
- * @param msg the the raw data to decode
- * @return a `PlanetSideGamePacket`
- */
- def DecodeGamePacket(msg: ByteVector): Attempt[PlanetSideGamePacket] = {
- GamePacketOpcode.codec.decode(msg.bits) match {
- case Failure(e) =>
- Attempt.failure(Err("Failed to decode game packet's opcode: " + e.message))
-
- case Successful(opcode) =>
- GamePacketOpcode.getPacketDecoder(opcode.value)(opcode.remainder) match {
- case Failure(e) =>
- Attempt.failure(Err(f"Failed to parse game packet 0x${opcode.value.id}%02x: " + e.messageWithContext))
-
- case Successful(p) =>
- Attempt.successful(p.value)
- }
- }
- }
-
- /* Encrypting and Decrypting. */
-
- /**
- * Transform the privileged `packet` into a `RawPacket` representation to get:
- * the sequence number,
- * and the raw `ByteVector` data.
- * @param packet the unencrypted packet
- * @return paired data based on the packet
- */
- def getPacketDataForEncryption(packet: PlanetSidePacketContainer): Attempt[(Int, ByteVector)] = {
- makeRawPacket(packet) match {
- case Successful(rawPacket) =>
- val sequenceNumber = packet match { //the sequence is variable if this is a GamePacket
- case GamePacket(_, seq, _) => seq
- case _ => 0
- }
- Successful((sequenceNumber, rawPacket.toByteVector))
-
- case f @ Failure(_) =>
- f
- }
- }
-
- /**
- * Encrypt the provided packet using the provided cryptographic state.
- * Translate the packet into data to send on to the actual encryption process.
- * @param crypto the current cryptographic state
- * @param packet the unencrypted packet
- * @return an `EncryptedPacket`
- */
- def encryptPacket(
- crypto: CryptoInterface.CryptoStateWithMAC,
- packet: PlanetSidePacketContainer
- ): Attempt[EncryptedPacket] = {
- getPacketDataForEncryption(packet) match {
- case Successful((seq, data)) =>
- encryptPacket(crypto, seq, data)
- case f @ Failure(_) =>
- f
- }
- }
-
- /**
- * Transform either a `GamePacket` or a `ControlPacket` into a `BitVector`.
- * This is not as thorough as the process of unmarshalling though the results are very similar.
- * @param packet a packet
- * @return a `BitVector` that represents the packet
- */
- def makeRawPacket(packet: PlanetSidePacketContainer): Attempt[BitVector] =
- packet match {
- case GamePacket(opcode, _, payload) =>
- val opcodeEncoded = GamePacketOpcode.codec.encode(opcode)
- opcodeEncoded match {
- case Failure(e) =>
- Attempt.failure(Err(s"Failed to marshal opcode in packet $opcode: " + e.message))
- case _ =>
- encodePacket(payload) match {
- case Failure(e) => Attempt.failure(Err(s"Failed to marshal packet $opcode: " + e.messageWithContext))
- case Successful(p) => Attempt.successful(opcodeEncoded.require ++ p)
+ case 0x00 =>
+ // control packets don't need the first byte
+ ControlPacketOpcode.codec.decode(msg.drop(1).bits) match {
+ case Successful(op) =>
+ ControlPacketOpcode.getPacketDecoder(op.value)(op.remainder) match {
+ case Successful(p) => Successful(p.value)
+ case Failure(e) => Failure(Err(e.messageWithContext))
}
+ case Failure(e) => Failure(Err(e.message))
}
-
- case ControlPacket(opcode, payload) =>
- val opcodeEncoded = ControlPacketOpcode.codec.encode(opcode)
- opcodeEncoded match {
- case Failure(e) =>
- Attempt.failure(Err(s"Failed to marshal opcode in packet $opcode: " + e.messageWithContext))
- case _ =>
- encodePacket(payload) match {
- case Failure(e) => Attempt.failure(Err(s"Failed to marshal packet $opcode: " + e.messageWithContext))
- case Successful(p) => Attempt.successful(hex"00".bits ++ opcodeEncoded.require ++ p)
- }
- }
-
case _ =>
- throw new IllegalArgumentException("Unsupported packet container type")
- }
-
- /**
- * Perform encryption on the packet's raw data.
- * @param crypto the current cryptographic state
- * @param sequenceNumber na
- * @param rawPacket a `ByteVector` that represents the packet data
- * @return an `EncryptedPacket`
- */
- def encryptPacket(
- crypto: CryptoInterface.CryptoStateWithMAC,
- sequenceNumber: Int,
- rawPacket: ByteVector
- ): Attempt[EncryptedPacket] = {
- val packetMac = crypto.macForEncrypt(rawPacket)
- val packetNoPadding = rawPacket ++ packetMac //opcode, payload, and MAC
- val remainder = packetNoPadding.length % CryptoInterface.RC5_BLOCK_SIZE
- val paddingNeeded = CryptoInterface.RC5_BLOCK_SIZE - remainder - 1 //minus 1 because of a mandatory padding bit
- val paddingEncoded = uint8L.encode(paddingNeeded.toInt).require
- val packetWithPadding = packetNoPadding ++ ByteVector.fill(paddingNeeded)(0x00) ++ paddingEncoded.toByteVector
- val encryptedPayload =
- crypto.encrypt(packetWithPadding) //raw packets plus MAC, padded to the nearest 16 byte boundary
- Attempt.successful(EncryptedPacket(sequenceNumber, encryptedPayload))
- }
-
- /**
- * Perform decryption on an `EncryptedPacket`.
- * @param crypto the current state of the connection's crypto
- * @param packet an encrypted packet
- * @return a general packet container type
- */
- def decryptPacket(
- crypto: CryptoInterface.CryptoStateWithMAC,
- packet: EncryptedPacket
- ): Attempt[PlanetSidePacketContainer] = {
- decryptPacketData(crypto, packet) match {
- case Successful(payload) => unmarshalPayload(packet.sequenceNumber, payload)
- case f @ Failure(_) => f
+ GamePacketOpcode.codec.decode(msg.bits) match {
+ case Successful(opcode) =>
+ GamePacketOpcode.getPacketDecoder(opcode.value)(opcode.remainder) match {
+ case Failure(e) =>
+ Failure(Err(f"Failed to parse game packet 0x${opcode.value.id}%02x: " + e.messageWithContext))
+ case Successful(p) => Successful(p.value)
+ }
+ case Failure(e) => Failure(Err("Failed to decode game packet's opcode: " + e.message))
+ }
}
}
- /**
- * Transform decrypted packet data into the type of packet that it represents.
- * Will not compose data into an `EncryptedPacket` or into a `CryptoPacket`.
- * @param sequenceNumber na
- * @param payload the decrypted packet data
- * @return a general packet container type
- */
- def unmarshalPayload(sequenceNumber: Int, payload: ByteVector): Attempt[PlanetSidePacketContainer] = {
- payload { 0 } match {
- case 0x00 => unmarshalControlPacket(payload.drop(1))
- case _ => unmarshalGamePacket(sequenceNumber, payload)
- }
- }
+ case class CryptoCoding(
+ rc5EncryptionKey: Key,
+ rc5DecryptionKey: Key,
+ macEncryptionKey: ByteVector,
+ macDecryptionKey: ByteVector
+ ) {
+ private val iv = BigInt(64, random)
+ private val rc5Spec = new RC5ParameterSpec(0, 16, 32)
+ private val rc5Encrypt = Cipher.getInstance("RC5/ECB/NoPadding")
+ private val rc5Decrypt = Cipher.getInstance("RC5/ECB/NoPadding")
+ rc5Encrypt.init(Cipher.ENCRYPT_MODE, rc5EncryptionKey, rc5Spec)
+ rc5Decrypt.init(Cipher.DECRYPT_MODE, rc5DecryptionKey, rc5Spec)
- /**
- * Compose the decrypted payload data from a formerly encrypted packet.
- * @param crypto the current state of the connection's crypto
- * @param packet an encrypted packet
- * @return a sequence of decrypted data
- */
- def decryptPacketData(crypto: CryptoInterface.CryptoStateWithMAC, packet: EncryptedPacket): Attempt[ByteVector] = {
- val payloadDecrypted = crypto.decrypt(packet.payload)
- val payloadJustLen = payloadDecrypted.takeRight(1) //get the last byte which is the padding length
- val padding = uint8L.decode(payloadJustLen.bits)
- padding match {
- case Failure(e) => return Attempt.failure(Err("Failed to decode the encrypted padding length: " + e.message))
- case _ =>
+ def encrypt(packet: PlanetSidePacket): Attempt[ByteVector] = {
+ encodePacket(packet) match {
+ case Successful(data) =>
+ encrypt(data.toByteVector)
+ case f @ Failure(_) =>
+ f
+ }
}
- val macSize = CryptoInterface.MD5_MAC_SIZE
- val macDecoder = bytes(macSize)
- val payloadNoPadding = payloadDecrypted.dropRight(1 + padding.require.value)
- val payloadMac = payloadNoPadding.takeRight(macSize)
- /*
- println("Payload: " + packet.payload)
- println("DecPayload: " + payloadDecrypted)
- println("DecPayloadNoLen: " + payloadJustLen)
- println("Padding: " + padding.require.value)
- println("NoPadding: " + payloadNoPadding)
- println("Mac: " + payloadMac)
- println("NoMac: " + payloadNoMac)
- */
- val mac = macDecoder.decode(payloadMac.bits)
- mac match {
- case Failure(e) => return Attempt.failure(Err("Failed to extract the encrypted MAC: " + e.message))
- case _ =>
+ def encrypt(
+ data: ByteVector
+ ): Attempt[ByteVector] = {
+ // This is basically X9.23 padding, except that the length byte is -1 because it doesn't count itself
+ val packetNoPadding = data ++ new Md5Mac(macEncryptionKey).updateFinal(data) // opcode, payload, and MAC
+ val remainder = packetNoPadding.length % RC5_BLOCK_SIZE
+ val paddingNeeded = RC5_BLOCK_SIZE - remainder - 1 // minus 1 because of a mandatory padding byte
+ val paddingEncoded = uint8L.encode(paddingNeeded.toInt).require
+ val packetWithPadding = packetNoPadding ++ ByteVector.fill(paddingNeeded)(0x00) ++ paddingEncoded.toByteVector
+ // raw packets plus MAC, padded to the nearest 8 byte boundary
+ try {
+ Successful(ByteVector.view(rc5Encrypt.doFinal(packetWithPadding.toArray)))
+ } catch {
+ case e: Throwable => Failure(Err(s"encrypt error: '${e.getMessage}' data: ${packetWithPadding.toHex}"))
+ }
}
- val payloadNoMac = payloadNoPadding.dropRight(macSize)
- val computedMac = crypto.macForDecrypt(payloadNoMac)
- if (!CryptoInterface.verifyMAC(computedMac, mac.require.value)) { //verify that the MAC matches
- throw new SecurityException("Invalid packet MAC")
+ def decrypt(data: ByteVector): Attempt[ByteVector] = {
+ val payloadDecrypted =
+ try {
+ ByteVector.view(rc5Decrypt.doFinal(data.toArray))
+ } catch {
+ case e: Throwable => return Failure(Err(e.getMessage))
+ }
+
+ // last byte is the padding length
+ val padding = uint8L.decode(payloadDecrypted.takeRight(1).bits) match {
+ case Successful(padding) => padding.value
+ case Failure(e) => return Failure(Err(s"Failed to decode the encrypted padding length: ${e.message}"))
+ }
+
+ val payloadNoPadding = payloadDecrypted.dropRight(1 + padding)
+ val payloadMac = payloadNoPadding.takeRight(Md5Mac.MACLENGTH)
+
+ val mac = bytes(Md5Mac.MACLENGTH).decode(payloadMac.bits) match {
+ case Failure(e) => return Failure(Err("Failed to extract the encrypted MAC: " + e.message))
+ case Successful(mac) => mac.value
+ }
+
+ val payloadNoMac = payloadNoPadding.dropRight(Md5Mac.MACLENGTH)
+ val computedMac = new Md5Mac(macDecryptionKey).updateFinal(payloadNoMac)
+
+ if (!Md5Mac.verifyMac(computedMac, mac)) {
+ return Failure(Err("Invalid packet MAC"))
+ }
+
+ if (payloadNoMac.length < PLANETSIDE_MIN_PACKET_SIZE) {
+ return Failure(
+ Err(s"Decrypted packet does not meet the minimum length of $PLANETSIDE_MIN_PACKET_SIZE bytes")
+ )
+ }
+
+ Successful(payloadNoMac)
}
- if (payloadNoMac.length < PLANETSIDE_MIN_PACKET_SIZE) {
- return Attempt.failure(
- Err(s"Decrypted packet does not meet the minimum length of $PLANETSIDE_MIN_PACKET_SIZE bytes")
- )
- }
- Successful(payloadNoMac)
+
}
}
diff --git a/src/main/scala/net/psforever/packet/control/HandleGamePacket.scala b/src/main/scala/net/psforever/packet/control/HandleGamePacket.scala
index 99d9c155b..ae15e37ff 100644
--- a/src/main/scala/net/psforever/packet/control/HandleGamePacket.scala
+++ b/src/main/scala/net/psforever/packet/control/HandleGamePacket.scala
@@ -1,15 +1,16 @@
// Copyright (c) 2017 PSForever
package net.psforever.packet.control
+import net.psforever.packet.ControlPacketOpcode.Type
import net.psforever.packet.{ControlPacketOpcode, Marshallable, PlanetSideControlPacket}
-import scodec.Codec
+import scodec.{Attempt, Codec}
import scodec.bits.{BitVector, ByteVector}
import scodec.codecs._
final case class HandleGamePacket(len: Int, stream: ByteVector, rest: BitVector = BitVector.empty)
extends PlanetSideControlPacket {
- def opcode = ControlPacketOpcode.HandleGamePacket
- def encode = HandleGamePacket.encode(this)
+ def opcode: Type = ControlPacketOpcode.HandleGamePacket
+ def encode: Attempt[BitVector] = HandleGamePacket.encode(this)
}
object HandleGamePacket extends Marshallable[HandleGamePacket] {
diff --git a/src/main/scala/net/psforever/packet/control/MultiPacketCollector.scala b/src/main/scala/net/psforever/packet/control/MultiPacketCollector.scala
deleted file mode 100644
index bc02e1fa2..000000000
--- a/src/main/scala/net/psforever/packet/control/MultiPacketCollector.scala
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (c) 2017 PSForever
-package net.psforever.packet.control
-
-import net.psforever.packet.PlanetSidePacket
-
-/**
- * Message for holding a series of packets being moved through the system (server),
- * eventually be bundled into a `MultiPacketEx` and dispatched to the client.
- * Invalid packets are eliminated at the time of creation.
- * At least one packet is necessary.
- * @param packets a series of packets to be bundled together;
- * this list is effectively immutable;
- * the only way to access these packets is through pattern matching
- */
-final case class MultiPacketBundle(private var packets: List[PlanetSidePacket]) {
- MultiPacketBundle.collectValidPackets(packets) match {
- case Nil =>
- throw new IllegalArgumentException("can not create with zero packets")
- case list =>
- packets = list
- }
-
- def +(t: MultiPacketBundle): MultiPacketBundle =
- t match {
- case MultiPacketBundle(list) =>
- MultiPacketBundle(packets ++ list)
- case _ =>
- MultiPacketBundle(packets)
- }
-}
-
-object MultiPacketBundle {
-
- /**
- * Accept a series of packets of a specific supertype (`PlanetSidePacket`)
- * and filter out subtypes that should be excluded.
- * Show a generic disclaimer if any packets were filtered.
- * Two of the four subclasses of `PlanetSidePacket` are accepted - `PlanetSideGamePacket` and `PlanetSideControlPacket`.
- * @param packets a series of packets
- * @return the accepted packets from the original group
- */
- def collectValidPackets(packets: List[PlanetSidePacket]): List[PlanetSidePacket] = {
- import net.psforever.packet.{PlanetSideGamePacket, PlanetSideControlPacket}
- val (good, bad) = packets.partition({
- case _: PlanetSideGamePacket => true
- case _: PlanetSideControlPacket => true
- case _ => false
- })
- if (bad.nonEmpty) {
- org.log4s
- .getLogger("MultiPacketBundle")
- .warn(s"attempted to include packet types that are not in the whitelist; ${bad.size} items have been excluded")
- }
- good
- }
-}
-
-/**
- * Accumulator for packets that will eventually be bundled and submitted for composing a `MultiPacketEx` packet.
- */
-class MultiPacketCollector() {
- private var bundle: List[PlanetSidePacket] = List.empty
-
- def Add(t: PlanetSidePacket): Unit = Add(List(t))
-
- def Add(t: MultiPacketBundle): Unit =
- t match {
- case MultiPacketBundle(list) =>
- Add(list)
- }
-
- def Add(t: List[PlanetSidePacket]): Unit = {
- if (t.nonEmpty) {
- bundle = bundle ++ t
- }
- }
-
- /**
- * Retrieve the internal collection of packets.
- * Reset the internal list of packets by clearing it.
- * @return a loaded `MultiPacketBundle` object, or `None`
- */
- def Bundle: Option[MultiPacketBundle] = {
- bundle match {
- case Nil =>
- None
- case list =>
- val out = MultiPacketBundle(list)
- bundle = List.empty
- Some(out)
- }
- }
-}
-
-object MultiPacketCollector {
-
- /**
- * Overload constructor that accepts initial packets.
- * @param bundle previously bundled packets
- * @return a `MultiPacketCollector` object
- */
- def apply(bundle: MultiPacketBundle): MultiPacketCollector = {
- val obj = new MultiPacketCollector()
- obj.Add(bundle)
- obj
- }
-
- /**
- * Overload constructor that accepts initial packets.
- * @param packets a series of packets
- * @return a `MultiPacketCollector` object
- */
- def apply(packets: List[PlanetSidePacket]): MultiPacketCollector = {
- val obj = new MultiPacketCollector()
- obj.Add(packets)
- obj
- }
-}
diff --git a/src/main/scala/net/psforever/packet/crypto/ClientChallengeXchg.scala b/src/main/scala/net/psforever/packet/crypto/ClientChallengeXchg.scala
index bd39e77b5..b6328107f 100644
--- a/src/main/scala/net/psforever/packet/crypto/ClientChallengeXchg.scala
+++ b/src/main/scala/net/psforever/packet/crypto/ClientChallengeXchg.scala
@@ -1,15 +1,16 @@
// Copyright (c) 2017 PSForever
package net.psforever.packet.crypto
+import net.psforever.packet.CryptoPacketOpcode.Type
import net.psforever.packet.{CryptoPacketOpcode, Marshallable, PlanetSideCryptoPacket}
-import scodec.Codec
+import scodec.{Attempt, Codec}
import scodec.bits.{ByteVector, _}
import scodec.codecs._
final case class ClientChallengeXchg(time: Long, challenge: ByteVector, p: ByteVector, g: ByteVector)
extends PlanetSideCryptoPacket {
- def opcode = CryptoPacketOpcode.ClientChallengeXchg
- def encode = ClientChallengeXchg.encode(this)
+ def opcode: Type = CryptoPacketOpcode.ClientChallengeXchg
+ def encode: Attempt[BitVector] = ClientChallengeXchg.encode(this)
}
object ClientChallengeXchg extends Marshallable[ClientChallengeXchg] {
diff --git a/src/main/scala/net/psforever/packet/game/CharacterInfoMessage.scala b/src/main/scala/net/psforever/packet/game/CharacterInfoMessage.scala
index ba439e6e2..e6cef33de 100644
--- a/src/main/scala/net/psforever/packet/game/CharacterInfoMessage.scala
+++ b/src/main/scala/net/psforever/packet/game/CharacterInfoMessage.scala
@@ -15,8 +15,9 @@ object PlanetSideZoneID {
/**
* Is sent by the PlanetSide world server when sending character selection screen state. Provides metadata
* about a certain character for rendering purposes (zone background, etc). Acts as an array insert for the
- * client character list. A blank displayed character is most likely caused by a mismatch between an
- * ObjectCreateMessage GUID and the GUID from this message.
+ * client character list. A blank displayed character is most likely caused by either:
+ * - a mismatch between an ObjectCreateMessage GUID and the GUID from this message.
+ * - bundling CharacterInfoMessage with OCDM, they should appear one after another
*
* @param finished True when there are no more characters to give info on
*/
diff --git a/src/main/scala/net/psforever/services/local/LocalService.scala b/src/main/scala/net/psforever/services/local/LocalService.scala
index bcbfb5656..7c3138afd 100644
--- a/src/main/scala/net/psforever/services/local/LocalService.scala
+++ b/src/main/scala/net/psforever/services/local/LocalService.scala
@@ -215,7 +215,7 @@ class LocalService(zone: Zone) extends Actor {
//response from HackClearActor
case HackClearActor.ClearTheHack(target_guid, _, unk1, unk2) =>
- log.warn(s"Clearing hack for $target_guid")
+ log.info(s"Clearing hack for $target_guid")
LocalEvents.publish(
LocalServiceResponse(
s"/${zone.id}/Local",
diff --git a/src/main/scala/net/psforever/util/Config.scala b/src/main/scala/net/psforever/util/Config.scala
index 29e3068dc..0305b83ae 100644
--- a/src/main/scala/net/psforever/util/Config.scala
+++ b/src/main/scala/net/psforever/util/Config.scala
@@ -10,7 +10,6 @@ import net.psforever.types.ChatMessageType
import pureconfig.ConfigConvert.viaNonEmptyStringOpt
import pureconfig.ConfigReader.Result
import pureconfig.{ConfigConvert, ConfigSource}
-
import scala.concurrent.duration._
import scala.reflect.ClassTag
import pureconfig.generic.auto._ // intellij: this is not unused
@@ -116,8 +115,8 @@ case class NetworkConfig(
)
case class SessionConfig(
- inboundGraceTime: Duration,
- outboundGraceTime: Duration
+ inboundGraceTime: FiniteDuration,
+ outboundGraceTime: FiniteDuration
)
case class GameConfig(
diff --git a/src/main/scala/net/psforever/util/DefinitionUtil.scala b/src/main/scala/net/psforever/util/DefinitionUtil.scala
index 04c058d4e..7d1cade70 100644
--- a/src/main/scala/net/psforever/util/DefinitionUtil.scala
+++ b/src/main/scala/net/psforever/util/DefinitionUtil.scala
@@ -235,9 +235,7 @@ object DefinitionUtil {
player.Slot(33).Equipment = AmmoBox(GlobalDefinitions.bullet_9mm_AP)
player.Slot(36).Equipment = AmmoBox(GlobalDefinitions.StandardPistolAmmo(faction))
player.Slot(39).Equipment = SimpleItem(GlobalDefinitions.remote_electronics_kit)
- player.Inventory.Items.foreach {
- _.obj.Faction = faction
- }
+ player.Inventory.Items.foreach(_.obj.Faction = faction)
}
/*
@@ -266,9 +264,6 @@ object DefinitionUtil {
// But macros cannot be called from the project they're defined in, and moving this to another project is not easy
// Making GlobalDefinitions iterable (map etc) should be the preferred solution
def fromString(name: String): BasicDefinition = {
- //println(
- // s"${universe.typeOf[GlobalDefinitions.type].member(universe.TermName(name))} ${universe.typeOf[GlobalDefinitions.type].decl(universe.TermName(name))}"
- //)
universe.typeOf[GlobalDefinitions.type].decl(universe.TermName(name))
val method = universe.typeOf[GlobalDefinitions.type].member(universe.TermName(name)).asMethod
instanceMirror.reflectMethod(method).apply().asInstanceOf[BasicDefinition]
diff --git a/src/main/scala/net/psforever/util/DiffieHellman.scala b/src/main/scala/net/psforever/util/DiffieHellman.scala
new file mode 100644
index 000000000..d9a963c44
--- /dev/null
+++ b/src/main/scala/net/psforever/util/DiffieHellman.scala
@@ -0,0 +1,31 @@
+package net.psforever.util
+
+import java.security.SecureRandom
+
+/** Simple DH implementation
+ * We can not use Java's built-in DH because it requires much larger p values than the ones that are used
+ * for key exchange by the client (which are 128 bits).
+ */
+case class DiffieHellman(p: Array[Byte], g: Array[Byte]) {
+ import DiffieHellman._
+
+ private val _p = BigInt(1, p)
+ private val _g = BigInt(1, g)
+ private val privateKey: BigInt = BigInt(128, random)
+
+ val publicKey: Array[Byte] = bytes(_g.modPow(privateKey, _p))
+
+ /** Agree on shared key */
+ def agree(otherKey: Array[Byte]): Array[Byte] = {
+ bytes(BigInt(1, otherKey).modPow(privateKey, _p))
+ }
+
+ /** Return BigInt as 16 byte array (same size as private key) */
+ private def bytes(b: BigInt): Array[Byte] = {
+ b.toByteArray.takeRight(16).reverse.padTo(16, 0x0.toByte).reverse
+ }
+}
+
+object DiffieHellman {
+ private val random = new SecureRandom()
+}
diff --git a/src/main/scala/net/psforever/util/Md5Mac.scala b/src/main/scala/net/psforever/util/Md5Mac.scala
new file mode 100644
index 000000000..1f1141a21
--- /dev/null
+++ b/src/main/scala/net/psforever/util/Md5Mac.scala
@@ -0,0 +1,261 @@
+package net.psforever.util
+
+import scodec.bits.ByteVector
+import scala.collection.mutable.ListBuffer
+
+object Md5Mac {
+ val BLOCKSIZE = 64
+ val DIGESTSIZE = 16
+ val MACLENGTH = 16
+ val KEYLENGTH = 16
+
+ /** Checks if two Message Authentication Codes are the same in constant time,
+ * preventing a timing attack for MAC forgery
+ * @param mac1 A MAC value
+ * @param mac2 Another MAC value
+ */
+ def verifyMac(mac1: ByteVector, mac2: ByteVector): Boolean = {
+ var okay = true
+
+ // prevent byte by byte guessing
+ if (mac1.length != mac2.length)
+ return false
+
+ for (i <- 0 until mac1.length.toInt) {
+ okay = okay && mac1 { i } == mac2 { i }
+ }
+
+ okay
+ }
+}
+
+/** MD5-MAC is a ancient MAC algorithm from the 90s that nobody uses anymore. Not to be confused with HMAC-MD5.
+ * A description of the algorithm can be found at http://cacr.uwaterloo.ca/hac/about/chap9.pdf, 9.69 Algorithm MD5-MAC
+ * There appear to be two implementations: In older versions of CryptoPP (2007) and OpenCL (2001) (nowadays called
+ * Botan and not to be confused with the OpenCL standard from Khronos).
+ * Both libraries have since removed this code. This file is a Scala port of the OpenCL implementation.
+ * Source: https://github.com/sghiassy/Code-Reading-Book/blob/master/OpenCL/src/md5mac.cpp
+ */
+class Md5Mac(val key: ByteVector) {
+ import Md5Mac._
+
+ private val buffer: ListBuffer[Byte] = ListBuffer.fill(BLOCKSIZE)(0)
+ private val digest: ListBuffer[Byte] = ListBuffer.fill(DIGESTSIZE)(0)
+ private val m: ListBuffer[Byte] = ListBuffer.fill(32)(0)
+ private val k1: ListBuffer[Byte] = ListBuffer.fill(16)(0)
+ private val k2: ListBuffer[Byte] = ListBuffer.fill(16)(0)
+ private val k3: ListBuffer[Byte] = ListBuffer.fill(BLOCKSIZE)(0)
+ private var count: Long = 0
+ private var position: Int = 0
+
+ private val t: Seq[Seq[Byte]] = Seq(
+ Seq(0x97, 0xef, 0x45, 0xac, 0x29, 0x0f, 0x43, 0xcd, 0x45, 0x7e, 0x1b, 0x55, 0x1c, 0x80, 0x11, 0x34),
+ Seq(0xb1, 0x77, 0xce, 0x96, 0x2e, 0x72, 0x8e, 0x7c, 0x5f, 0x5a, 0xab, 0x0a, 0x36, 0x43, 0xbe, 0x18),
+ Seq(0x9d, 0x21, 0xb4, 0x21, 0xbc, 0x87, 0xb9, 0x4d, 0xa2, 0x9d, 0x27, 0xbd, 0xc7, 0x5b, 0xd7, 0xc3)
+ ).map(_.map(_.toByte))
+
+ assert(key.length == KEYLENGTH, s"key length must be ${KEYLENGTH}, not ${key.length}")
+ doKey()
+
+ private def doKey() = {
+ val ek: ListBuffer[Byte] = ListBuffer.fill(48)(0)
+ val data: ListBuffer[Byte] = ListBuffer.fill(128)(0)
+ (0 until 16).foreach(j => {
+ data(j) = key(j % key.length)
+ data(j + 112) = key(j % key.length)
+ })
+
+ (0 until 3).foreach(j => {
+ digest.patchInPlace(0, ByteVector.fromInt(0x67452301).toArray, 4)
+ digest.patchInPlace(4, ByteVector.fromInt(0xefcdab89).toArray, 4)
+ digest.patchInPlace(8, ByteVector.fromInt(0x98badcfe).toArray, 4)
+ digest.patchInPlace(12, ByteVector.fromInt(0x10325476).toArray, 4)
+
+ (16 until 112).foreach(k => data(k) = t((j + (k - 16) / 16) % 3)(k % 16))
+
+ hash(data.toSeq)
+ hash(data.drop(64).toSeq)
+
+ ek.patchInPlace(4 * 4 * j, digest.slice(0, 4), 4)
+ ek.patchInPlace((4 * 4 * j) + 4, digest.slice(4, 8), 4)
+ ek.patchInPlace((4 * 4 * j) + 8, digest.slice(8, 12), 4)
+ ek.patchInPlace((4 * 4 * j) + 12, digest.slice(12, 16), 4)
+ })
+
+ k1.patchInPlace(0, ek.take(16), 16)
+ digest.patchInPlace(0, ek.take(16), 16)
+ k2.patchInPlace(0, ek.slice(16, 32), 16)
+
+ (0 until 16).foreach(j => k3(j) = ek(((8 + j / 4) * 4) + (3 - j % 4)))
+ (16 until 64).foreach(j => k3(j) = (k3(j % 16) ^ t((j - 16) / 16)(j % 16)).toByte)
+ }
+
+ private def hash(input: Seq[Byte]) = {
+ (0 until 16).foreach(j => {
+ m.patchInPlace(j * 4, Array[Byte](input(4 * j + 3), input(4 * j + 2), input(4 * j + 1), input(4 * j + 0)), 4)
+ })
+
+ var a = mkInt(digest.drop(0))
+ var c = mkInt(digest.drop(2 * 4))
+ var b = mkInt(digest.drop(1 * 4))
+ var d = mkInt(digest.drop(3 * 4))
+
+ a = ff(a, b, c, d, mkInt(m, 0 * 4), 7, 0xd76aa478)
+ d = ff(d, a, b, c, mkInt(m, 1 * 4), 12, 0xe8c7b756)
+ c = ff(c, d, a, b, mkInt(m, 2 * 4), 17, 0x242070db)
+ b = ff(b, c, d, a, mkInt(m, 3 * 4), 22, 0xc1bdceee)
+ a = ff(a, b, c, d, mkInt(m, 4 * 4), 7, 0xf57c0faf)
+ d = ff(d, a, b, c, mkInt(m, 5 * 4), 12, 0x4787c62a)
+ c = ff(c, d, a, b, mkInt(m, 6 * 4), 17, 0xa8304613)
+ b = ff(b, c, d, a, mkInt(m, 7 * 4), 22, 0xfd469501)
+ a = ff(a, b, c, d, mkInt(m, 8 * 4), 7, 0x698098d8)
+ d = ff(d, a, b, c, mkInt(m, 9 * 4), 12, 0x8b44f7af)
+ c = ff(c, d, a, b, mkInt(m, 10 * 4), 17, 0xffff5bb1)
+ b = ff(b, c, d, a, mkInt(m, 11 * 4), 22, 0x895cd7be)
+ a = ff(a, b, c, d, mkInt(m, 12 * 4), 7, 0x6b901122)
+ d = ff(d, a, b, c, mkInt(m, 13 * 4), 12, 0xfd987193)
+ c = ff(c, d, a, b, mkInt(m, 14 * 4), 17, 0xa679438e)
+ b = ff(b, c, d, a, mkInt(m, 15 * 4), 22, 0x49b40821)
+
+ a = gg(a, b, c, d, mkInt(m, 1 * 4), 5, 0xf61e2562)
+ d = gg(d, a, b, c, mkInt(m, 6 * 4), 9, 0xc040b340)
+ c = gg(c, d, a, b, mkInt(m, 11 * 4), 14, 0x265e5a51)
+ b = gg(b, c, d, a, mkInt(m, 0 * 4), 20, 0xe9b6c7aa)
+ a = gg(a, b, c, d, mkInt(m, 5 * 4), 5, 0xd62f105d)
+ d = gg(d, a, b, c, mkInt(m, 10 * 4), 9, 0x02441453)
+ c = gg(c, d, a, b, mkInt(m, 15 * 4), 14, 0xd8a1e681)
+ b = gg(b, c, d, a, mkInt(m, 4 * 4), 20, 0xe7d3fbc8)
+ a = gg(a, b, c, d, mkInt(m, 9 * 4), 5, 0x21e1cde6)
+ d = gg(d, a, b, c, mkInt(m, 14 * 4), 9, 0xc33707d6)
+ c = gg(c, d, a, b, mkInt(m, 3 * 4), 14, 0xf4d50d87)
+ b = gg(b, c, d, a, mkInt(m, 8 * 4), 20, 0x455a14ed)
+ a = gg(a, b, c, d, mkInt(m, 13 * 4), 5, 0xa9e3e905)
+ d = gg(d, a, b, c, mkInt(m, 2 * 4), 9, 0xfcefa3f8)
+ c = gg(c, d, a, b, mkInt(m, 7 * 4), 14, 0x676f02d9)
+ b = gg(b, c, d, a, mkInt(m, 12 * 4), 20, 0x8d2a4c8a)
+
+ a = hh(a, b, c, d, mkInt(m, 5 * 4), 4, 0xfffa3942)
+ d = hh(d, a, b, c, mkInt(m, 8 * 4), 11, 0x8771f681)
+ c = hh(c, d, a, b, mkInt(m, 11 * 4), 16, 0x6d9d6122)
+ b = hh(b, c, d, a, mkInt(m, 14 * 4), 23, 0xfde5380c)
+ a = hh(a, b, c, d, mkInt(m, 1 * 4), 4, 0xa4beea44)
+ d = hh(d, a, b, c, mkInt(m, 4 * 4), 11, 0x4bdecfa9)
+ c = hh(c, d, a, b, mkInt(m, 7 * 4), 16, 0xf6bb4b60)
+ b = hh(b, c, d, a, mkInt(m, 10 * 4), 23, 0xbebfbc70)
+ a = hh(a, b, c, d, mkInt(m, 13 * 4), 4, 0x289b7ec6)
+ d = hh(d, a, b, c, mkInt(m, 0 * 4), 11, 0xeaa127fa)
+ c = hh(c, d, a, b, mkInt(m, 3 * 4), 16, 0xd4ef3085)
+ b = hh(b, c, d, a, mkInt(m, 6 * 4), 23, 0x04881d05)
+ a = hh(a, b, c, d, mkInt(m, 9 * 4), 4, 0xd9d4d039)
+ d = hh(d, a, b, c, mkInt(m, 12 * 4), 11, 0xe6db99e5)
+ c = hh(c, d, a, b, mkInt(m, 15 * 4), 16, 0x1fa27cf8)
+ b = hh(b, c, d, a, mkInt(m, 2 * 4), 23, 0xc4ac5665)
+
+ a = ii(a, b, c, d, mkInt(m, 0 * 4), 6, 0xf4292244)
+ d = ii(d, a, b, c, mkInt(m, 7 * 4), 10, 0x432aff97)
+ c = ii(c, d, a, b, mkInt(m, 14 * 4), 15, 0xab9423a7)
+ b = ii(b, c, d, a, mkInt(m, 5 * 4), 21, 0xfc93a039)
+ a = ii(a, b, c, d, mkInt(m, 12 * 4), 6, 0x655b59c3)
+ d = ii(d, a, b, c, mkInt(m, 3 * 4), 10, 0x8f0ccc92)
+ c = ii(c, d, a, b, mkInt(m, 10 * 4), 15, 0xffeff47d)
+ b = ii(b, c, d, a, mkInt(m, 1 * 4), 21, 0x85845dd1)
+ a = ii(a, b, c, d, mkInt(m, 8 * 4), 6, 0x6fa87e4f)
+ d = ii(d, a, b, c, mkInt(m, 15 * 4), 10, 0xfe2ce6e0)
+ c = ii(c, d, a, b, mkInt(m, 6 * 4), 15, 0xa3014314)
+ b = ii(b, c, d, a, mkInt(m, 13 * 4), 21, 0x4e0811a1)
+ a = ii(a, b, c, d, mkInt(m, 4 * 4), 6, 0xf7537e82)
+ d = ii(d, a, b, c, mkInt(m, 11 * 4), 10, 0xbd3af235)
+ c = ii(c, d, a, b, mkInt(m, 2 * 4), 15, 0x2ad7d2bb)
+ b = ii(b, c, d, a, mkInt(m, 9 * 4), 21, 0xeb86d391)
+
+ digest.patchInPlace(0, ByteVector.fromInt(mkInt(digest, 0) + a).toArray, 4)
+ digest.patchInPlace(4, ByteVector.fromInt(mkInt(digest, 4) + b).toArray, 4)
+ digest.patchInPlace(8, ByteVector.fromInt(mkInt(digest, 8) + c).toArray, 4)
+ digest.patchInPlace(12, ByteVector.fromInt(mkInt(digest, 12) + d).toArray, 4)
+ }
+
+ private def mkInt(lb: Iterable[Byte], pos: Int = 0): Int = {
+ ByteVector.view(lb.slice(pos, pos + 4).toArray).toInt()
+ }
+
+ private def ff(a: Int, b: Int, c: Int, d: Int, msg: Int, shift: Int, magic: Int): Int = {
+ val r = a + ((d ^ (b & (c ^ d))) + msg + magic + mkInt(k2, 0))
+ Integer.rotateLeft(r, shift) + b
+ }
+
+ private def gg(a: Int, b: Int, c: Int, d: Int, msg: Int, shift: Int, magic: Int): Int = {
+ val r = a + ((c ^ ((b ^ c) & d)) + msg + magic + mkInt(k2, 4))
+ Integer.rotateLeft(r, shift) + b
+ }
+
+ private def hh(a: Int, b: Int, c: Int, d: Int, msg: Int, shift: Int, magic: Int): Int = {
+ val r = a + ((b ^ c ^ d) + msg + magic + mkInt(k2, 8))
+ Integer.rotateLeft(r, shift) + b
+ }
+
+ private def ii(a: Int, b: Int, c: Int, d: Int, msg: Int, shift: Int, magic: Int): Int = {
+ val r = a + ((c ^ (b | ~d)) + msg + magic + mkInt(k2, 12))
+ Integer.rotateLeft(r, shift) + b
+ }
+
+ def update(bytes: ByteVector) = {
+ count += bytes.length
+ var length = bytes.length
+ buffer.patchInPlace(
+ position,
+ bytes.take(math.min(BLOCKSIZE, bytes.length)).toIterable,
+ math.min(BLOCKSIZE, bytes.length).toInt
+ )
+
+ if (position + bytes.length >= BLOCKSIZE) {
+ hash(buffer.toSeq)
+ var input = bytes.drop(BLOCKSIZE - position)
+ length = bytes.length - (BLOCKSIZE - position)
+ while (length >= BLOCKSIZE) {
+ hash(input.toSeq)
+ input = input.drop(BLOCKSIZE)
+ length -= BLOCKSIZE
+ }
+ buffer.patchInPlace(0, input.toIterable, input.length.toInt)
+ position = 0
+ }
+ position += length.toInt
+ }
+
+ /** Perform final hash calculations and reset the state
+ * @return the hash
+ */
+ def doFinal(length: Int = MACLENGTH): ByteVector = {
+ val output: ListBuffer[Byte] = ListBuffer.fill(MACLENGTH)(0)
+ buffer(position) = 0x80.toByte
+ (position + 1 until BLOCKSIZE).foreach(i => buffer(i) = 0)
+ if (position >= BLOCKSIZE - 8) {
+ hash(buffer.toSeq)
+ buffer.mapInPlace(_ => 0)
+ }
+
+ (BLOCKSIZE - 8 until BLOCKSIZE).foreach(i => buffer(i) = ByteVector.fromLong(8 * count)(7 - (i % 8)))
+
+ hash(buffer.toSeq)
+ hash(k3.toSeq)
+
+ (0 until MACLENGTH).foreach(i => output(i) = digest((i / 4) * 4 + (3 - (i % 4))))
+
+ count = 0
+ position = 0
+ digest.patchInPlace(0, k1, digest.length)
+
+ if (length == MACLENGTH) {
+ ByteVector.view(output.toArray)
+ } else {
+ ByteVector.view((0 until length).map(i => output(i % Md5Mac.DIGESTSIZE)).toArray)
+ }
+ }
+
+ /** Shorthand for `update` and `doFinal` */
+ def updateFinal(bytes: ByteVector, length: Int = MACLENGTH): ByteVector = {
+ update(bytes)
+ doFinal(length)
+ }
+
+}
diff --git a/src/main/scala/net/psforever/zones/Zones.scala b/src/main/scala/net/psforever/zones/Zones.scala
index b2b2350e7..b896f180e 100644
--- a/src/main/scala/net/psforever/zones/Zones.scala
+++ b/src/main/scala/net/psforever/zones/Zones.scala
@@ -319,7 +319,7 @@ object Zones {
.addLocalObject(obj.guid, Locker.Constructor(obj.position), owningBuildingGuid = ownerGuid)
case "lock_external" | "lock_garage" | "lock_small" =>
- val closestDoor = doors.minBy(d => Vector3.DistanceSquared(d.position, obj.position))
+ val closestDoor = doors.minBy(d => Vector3.Distance(d.position, obj.position))
// Since tech plant garage locks are the only type where the lock does not face the same direction as the door we need to apply an offset for those, otherwise the door won't operate properly when checking inside/outside angles.
val yawOffset = if (obj.objectType == "lock_garage") 90 else 0
@@ -481,7 +481,7 @@ object Zones {
),
owningBuildingGuid = ownerGuid
)
- case _ => ;
+ case _ => ()
}
}
diff --git a/src/main/scala/sna/Library.scala b/src/main/scala/sna/Library.scala
deleted file mode 100644
index 91fc02243..000000000
--- a/src/main/scala/sna/Library.scala
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (c) 2014 Sanjay Dasgupta, All Rights Reserved
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- */
-
-package sna
-
-import com.sun.jna.{Function => JNAFunction}
-
-import scala.collection.mutable
-import scala.language.dynamics
-
-class Library(val libName: String) extends Dynamic {
-
- class Invocation(val jnaFunction: JNAFunction, val args: Array[Object]) {
-
- // TODO: this does not call without a passed type parameter
- def apply[R](implicit m: Manifest[R]): R = {
- //println("invoking " + jnaFunction.getName + ". class " + m.runtimeClass.toString)
- if (m.runtimeClass == classOf[Unit]) {
- jnaFunction.invoke(args).asInstanceOf[R]
- } else {
- jnaFunction.invoke(m.runtimeClass, args).asInstanceOf[R]
- }
- }
-
- def as[R](implicit m: Manifest[R]) = apply[R](m)
- def asInstanceOf[R](implicit m: Manifest[R]) = apply[R](m)
- }
-
- def applyDynamic(functionName: String)(args: Any*) = {
- new Invocation(loadFunction(functionName), args.map(_.asInstanceOf[Object]).toArray[Object])
- }
-
- private def loadFunction(functionName: String): JNAFunction = {
- var jnaFunction: JNAFunction = null
- if (functionCache.contains(functionName)) {
- jnaFunction = functionCache(functionName)
- } else {
- jnaFunction = JNAFunction.getFunction(libName, functionName)
- functionCache(functionName) = jnaFunction
- }
-
- jnaFunction
- }
-
- def prefetch(functionName: String): Unit = {
- loadFunction(functionName)
- }
-
- private val functionCache = mutable.Map.empty[String, JNAFunction]
-}
diff --git a/src/test/scala/CryptoInterfaceTest.scala b/src/test/scala/CryptoInterfaceTest.scala
deleted file mode 100644
index 3c0051550..000000000
--- a/src/test/scala/CryptoInterfaceTest.scala
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2017 PSForever
-
-import org.specs2.mutable._
-import net.psforever.crypto.CryptoInterface
-import net.psforever.crypto.CryptoInterface.CryptoDHState
-import scodec.bits._
-
-class CryptoInterfaceTest extends Specification {
- args(stopOnFail = true)
- "Crypto interface" should {
- "correctly initialize" in {
- CryptoInterface.initialize()
- ok
- }
-
- "encrypt and decrypt" in {
- val key = hex"41414141"
- val plaintext = ByteVector.fill(16)(0x42)
-
- val crypto = new CryptoInterface.CryptoState(key, key)
-
- val ciphertext = crypto.encrypt(plaintext)
- val decrypted = crypto.decrypt(ciphertext)
-
- crypto.close
- decrypted mustEqual plaintext
- ciphertext mustNotEqual plaintext
- }
-
- "encrypt and decrypt must handle no bytes" in {
- val key = hex"41414141"
- val empty = ByteVector.empty
-
- val crypto = new CryptoInterface.CryptoState(key, key)
-
- val ciphertext = crypto.encrypt(empty)
- val decrypted = crypto.decrypt(ciphertext)
-
- crypto.close
-
- ciphertext mustEqual empty
- decrypted mustEqual empty
- }
-
- "encrypt and decrypt must only accept block aligned inputs" in {
- val key = hex"41414141"
- val badPad = ByteVector.fill(CryptoInterface.RC5_BLOCK_SIZE - 1)('a')
-
- val crypto = new CryptoInterface.CryptoState(key, key)
-
- crypto.encrypt(badPad) must throwA[IllegalArgumentException]
- crypto.decrypt(badPad) must throwA[IllegalArgumentException]
-
- crypto.close
- ok
- }
-
- "arrive at a shared secret" in {
- val server = new CryptoInterface.CryptoDHState()
- val client = new CryptoInterface.CryptoDHState()
-
- // 1. Client generates p, g, and its key pair
- client.start()
-
- // 2. Client sends p and g to server who then generates a key pair as well
- server.start(client.getModulus, client.getGenerator)
-
- // 3. Both parties come to a shared secret
- val clientAgreed = client.agree(server.getPublicKey)
- val serverAgreed = server.agree(client.getPublicKey)
-
- // Free resources
- server.close
- client.close
-
- clientAgreed mustEqual serverAgreed
- }
-
- "must fail to agree on a secret with a bad public key" in {
- val server = new CryptoInterface.CryptoDHState()
- val client = new CryptoInterface.CryptoDHState()
-
- // 1. Client generates p, g, and its key pair
- client.start()
-
- // 2. Client sends p and g to server who then generates a key pair as well
- server.start(client.getModulus, client.getGenerator)
-
- // 3. Client agrees with a bad public key, so it must fail
- val clientAgreed = client.agree(client.getPublicKey)
- val serverAgreed = server.agree(client.getPublicKey)
-
- // Free resources
- server.close
- client.close
-
- clientAgreed mustNotEqual serverAgreed
- }
-
- "MD5MAC correctly" in {
- val key = hex"377b60f8790f91b35a9da82945743da9"
- val message = ByteVector(Array[Byte]('m', 'a', 's', 't', 'e', 'r', ' ', 's', 'e', 'c', 'r', 'e', 't')) ++
- hex"b4aea1559444a20b6112a2892de40eac00000000c8aea155b53d187076b79abab59001b600000000"
- val expected = hex"5aa15de41f5220cf5cca489155e1438c5aa15de4"
-
- val output = CryptoInterface.MD5MAC(key, message, expected.length.toInt)
-
- output mustEqual expected
- }
-
- "safely handle multiple starts" in {
- val dontCare = ByteVector.fill(16)(0x42)
- val dh = new CryptoDHState()
-
- dh.start()
- dh.start() must throwA[IllegalStateException]
- dh.close
-
- ok
- }
-
- "prevent function calls before initialization" in {
- val dontCare = ByteVector.fill(16)(0x42)
- val dh = new CryptoDHState()
-
- dh.getGenerator must throwA[IllegalStateException]
- dh.getModulus must throwA[IllegalStateException]
- dh.getPrivateKey must throwA[IllegalStateException]
- dh.getPublicKey must throwA[IllegalStateException]
- dh.agree(dontCare) must throwA[IllegalStateException]
- dh.close
-
- ok
- }
- }
-}
diff --git a/src/test/scala/CryptoTest.scala b/src/test/scala/CryptoTest.scala
new file mode 100644
index 000000000..c268011ca
--- /dev/null
+++ b/src/test/scala/CryptoTest.scala
@@ -0,0 +1,106 @@
+// Copyright (c) 2017 PSForever
+
+import java.security.{SecureRandom, Security}
+
+import javax.crypto.spec.SecretKeySpec
+import org.specs2.mutable._
+import net.psforever.packet.PacketCoding
+import net.psforever.packet.PacketCoding.CryptoCoding
+import net.psforever.packet.control.{HandleGamePacket, SlottedMetaPacket}
+import net.psforever.packet.game.PlanetsideAttributeMessage
+import net.psforever.types.PlanetSideGUID
+import net.psforever.util.{DiffieHellman, Md5Mac}
+import org.bouncycastle.jce.provider.BouncyCastleProvider
+import scodec.Attempt.Failure
+import scodec.Err
+import scodec.bits._
+
+class CryptoTest extends Specification {
+ Security.addProvider(new BouncyCastleProvider)
+
+ args(stopOnFail = true)
+ "Crypto" should {
+ "encrypt and decrypt" in {
+ val key = hex"41414141414141414141414141414141"
+ val keySpec = new SecretKeySpec(key.take(20).toArray, "RC5")
+ val plaintext = ByteVector.fill(32)(0x42)
+
+ val crypto = CryptoCoding(keySpec, keySpec, key, key)
+
+ val ciphertext = crypto.encrypt(plaintext).require
+ val decrypted = crypto.decrypt(ciphertext).require
+
+ decrypted mustEqual plaintext
+ ciphertext mustNotEqual plaintext
+
+ }
+
+ "encrypt and decrypt must only accept block aligned inputs" in {
+ val key = hex"41414141414141414141414141414141"
+ val keySpec = new SecretKeySpec(key.take(20).toArray, "RC5")
+ val badPad = ByteVector.fill(PacketCoding.RC5_BLOCK_SIZE - 1)('a')
+
+ val crypto = CryptoCoding(keySpec, keySpec, key, key)
+
+ //crypto.encrypt(badPad) must throwA[javax.crypto.IllegalBlockSizeException]
+ crypto.decrypt(badPad) mustEqual Failure(Err("data not block size aligned"))
+ }
+
+ "encrypt and decrypt packet" in {
+ val key = hex"41414141414141414141414141414141"
+ val keySpec = new SecretKeySpec(key.take(20).toArray, "RC5")
+ val crypto = CryptoCoding(keySpec, keySpec, key, key)
+
+ val packet =
+ SlottedMetaPacket(
+ 0,
+ 5,
+ PacketCoding
+ .encodePacket(
+ HandleGamePacket(
+ PacketCoding.encodePacket(PlanetsideAttributeMessage(PlanetSideGUID(0), 0, 0L)).require.toByteVector
+ )
+ )
+ .require
+ .bytes
+ )
+
+ val encrypted = PacketCoding.marshalPacket(packet, Some(10), Some(crypto)).require
+ println(s"encrypted ${encrypted}")
+ val (decryptedPacket, sequence) = PacketCoding.unmarshalPacket(encrypted.bytes, Some(crypto)).require
+
+ decryptedPacket mustEqual packet
+ sequence must beSome(10)
+ }
+
+ "MD5MAC" in {
+ val key = hex"377b60f8790f91b35a9da82945743da9"
+ val message = ByteVector(Array[Byte]('m', 'a', 's', 't', 'e', 'r', ' ', 's', 'e', 'c', 'r', 'e', 't')) ++
+ hex"b4aea1559444a20b6112a2892de40eac00000000c8aea155b53d187076b79abab59001b600000000"
+ val message2 = ByteVector.view((0 until 64).map(_.toByte).toArray)
+ val expected = hex"5aa15de41f5220cf5cca489155e1438c5aa15de4"
+
+ val mac = new Md5Mac(key)
+ mac.update(message)
+ mac.doFinal(20) mustEqual expected
+
+ val mac2 = new Md5Mac(key)
+ mac2.update(message2)
+ mac.update(message2)
+ mac.doFinal() mustEqual mac2.doFinal()
+
+ (0 to 20).map(_ => mac.updateFinal(message, 20) mustEqual expected)
+ }
+
+ "DH" in {
+ val p = BigInt(128, new SecureRandom()).toByteArray
+ val g = Array(1.toByte)
+
+ val bob = new DiffieHellman(p, g)
+ val alice = new DiffieHellman(p, g)
+
+ bob.agree(alice.publicKey) mustEqual alice.agree(bob.publicKey)
+ }
+
+ }
+}
diff --git a/src/test/scala/PacketCodingTest.scala b/src/test/scala/PacketCodingTest.scala
index dadbb59c0..7cc1ff21e 100644
--- a/src/test/scala/PacketCodingTest.scala
+++ b/src/test/scala/PacketCodingTest.scala
@@ -1,6 +1,6 @@
// Copyright (c) 2017 PSForever
import org.specs2.mutable._
-import net.psforever.packet._
+import net.psforever.packet.{PlanetSideControlPacket, _}
import net.psforever.packet.control.{ClientStart, ServerStart}
import scodec.bits._
@@ -18,13 +18,13 @@ class PacketCodingTest extends Specification {
"Packet coding" should {
"correctly decode control packets" in {
- val packet = PacketCoding.UnmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
+ val (packet, _) = PacketCoding.unmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
- packet.isInstanceOf[ControlPacket] mustEqual true
+ packet.isInstanceOf[PlanetSideControlPacket] mustEqual true
- val controlPacket = packet.asInstanceOf[ControlPacket]
+ val controlPacket = packet.asInstanceOf[PlanetSideControlPacket]
controlPacket.opcode mustEqual ControlPacketOpcode.ClientStart
- controlPacket.packet mustEqual ClientStart(656287232)
+ controlPacket mustEqual ClientStart(656287232)
}
"encode and decode to identical packets" in {
@@ -32,37 +32,37 @@ class PacketCodingTest extends Specification {
val serverNonce = 848483
val packetUnderTest = ServerStart(clientNonce, serverNonce)
- val pkt = PacketCoding.MarshalPacket(ControlPacket(packetUnderTest.opcode, packetUnderTest)).require
+ val pkt = PacketCoding.marshalPacket(packetUnderTest).require
- val decoded = PacketCoding.UnmarshalPacket(pkt.toByteVector).require.asInstanceOf[ControlPacket]
- val recvPkt = decoded.packet.asInstanceOf[ServerStart]
+ val decoded = PacketCoding.unmarshalPacket(pkt.toByteVector).require._1.asInstanceOf[PlanetSideControlPacket]
+ val recvPkt = decoded.asInstanceOf[ServerStart]
packetUnderTest mustEqual recvPkt
}
"reject corrupted control packets" in {
- val packet = PacketCoding.UnmarshalPacket(hex"0001 00001002 00261e27 004101f0")
+ val packet = PacketCoding.unmarshalPacket(hex"0001 00001002 00261e27 004101f0")
packet.isSuccessful mustEqual false
}
"correctly decode crypto packets" in {
- val packet = PacketCoding.UnmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
+ val (packet, _) = PacketCoding.unmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
- packet.isInstanceOf[ControlPacket] mustEqual true
+ packet.isInstanceOf[PlanetSideControlPacket] mustEqual true
- val controlPacket = packet.asInstanceOf[ControlPacket]
+ val controlPacket = packet.asInstanceOf[PlanetSideControlPacket]
controlPacket.opcode mustEqual ControlPacketOpcode.ClientStart
- controlPacket.packet mustEqual ClientStart(656287232)
+ controlPacket mustEqual ClientStart(656287232)
}
"reject bad packet types" in {
- PacketCoding.UnmarshalPacket(hex"ff414141").isFailure mustEqual true
+ PacketCoding.unmarshalPacket(hex"ff414141").isFailure mustEqual true
}
"reject small packets" in {
- PacketCoding.UnmarshalPacket(hex"00").isFailure mustEqual true
- PacketCoding.UnmarshalPacket(hex"").isFailure mustEqual true
+ PacketCoding.unmarshalPacket(hex"00").isFailure mustEqual true
+ PacketCoding.unmarshalPacket(hex"").isFailure mustEqual true
}
}
diff --git a/src/test/scala/control/ClientStartTest.scala b/src/test/scala/control/ClientStartTest.scala
index aecf0822e..2e4a1c8c2 100644
--- a/src/test/scala/control/ClientStartTest.scala
+++ b/src/test/scala/control/ClientStartTest.scala
@@ -10,7 +10,7 @@ class ClientStartTest extends Specification {
val string = hex"0001 00000002 00261e27 000001f0"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ClientStart(nonce) =>
nonce mustEqual 656287232
case _ =>
@@ -20,7 +20,7 @@ class ClientStartTest extends Specification {
"encode" in {
val msg = ClientStart(656287232)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/control/ConnectionCloseTest.scala b/src/test/scala/control/ConnectionCloseTest.scala
index 46231304f..c9a34717e 100644
--- a/src/test/scala/control/ConnectionCloseTest.scala
+++ b/src/test/scala/control/ConnectionCloseTest.scala
@@ -10,7 +10,7 @@ class ConnectionCloseTest extends Specification {
val string = hex"001D"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ConnectionClose() =>
ok
case _ =>
@@ -20,7 +20,7 @@ class ConnectionCloseTest extends Specification {
"encode" in {
val msg = ConnectionClose()
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/control/ControlSyncRespTest.scala b/src/test/scala/control/ControlSyncRespTest.scala
index 43be40279..5a3ba4e55 100644
--- a/src/test/scala/control/ControlSyncRespTest.scala
+++ b/src/test/scala/control/ControlSyncRespTest.scala
@@ -10,7 +10,7 @@ class ControlSyncRespTest extends Specification {
val string = hex"0008 5268 21392D92 0000000000000276 0000000000000275 0000000000000275 0000000000000276"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ControlSyncResp(a, b, c, d, e, f) =>
a mustEqual 21096
@@ -25,7 +25,7 @@ class ControlSyncRespTest extends Specification {
}
"encode" in {
- val encoded = PacketCoding.EncodePacket(ControlSyncResp(21096, 0x21392d92, 0x276, 0x275, 0x275, 0x276)).require
+ val encoded = PacketCoding.encodePacket(ControlSyncResp(21096, 0x21392d92, 0x276, 0x275, 0x275, 0x276)).require
encoded.toByteVector mustEqual string
}
diff --git a/src/test/scala/control/ControlSyncTest.scala b/src/test/scala/control/ControlSyncTest.scala
index 208e3a782..3b6ed7820 100644
--- a/src/test/scala/control/ControlSyncTest.scala
+++ b/src/test/scala/control/ControlSyncTest.scala
@@ -10,7 +10,7 @@ class ControlSyncTest extends Specification {
val string = hex"0007 5268 0000004D 00000052 0000004D 0000007C 0000004D 0000000000000276 0000000000000275"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ControlSync(a, b, c, d, e, f, g, h) =>
a mustEqual 21096
b mustEqual 0x4d
@@ -26,7 +26,7 @@ class ControlSyncTest extends Specification {
}
"encode" in {
- val encoded = PacketCoding.EncodePacket(ControlSync(21096, 0x4d, 0x52, 0x4d, 0x7c, 0x4d, 0x276, 0x275)).require
+ val encoded = PacketCoding.encodePacket(ControlSync(21096, 0x4d, 0x52, 0x4d, 0x7c, 0x4d, 0x276, 0x275)).require
encoded.toByteVector mustEqual string
}
}
diff --git a/src/test/scala/control/HandleGamePacketTest.scala b/src/test/scala/control/HandleGamePacketTest.scala
index c3f858784..fceef4f25 100644
--- a/src/test/scala/control/HandleGamePacketTest.scala
+++ b/src/test/scala/control/HandleGamePacketTest.scala
@@ -13,7 +13,7 @@ class HandleGamePacketTest extends Specification {
val string = hex"00 00 01 CB" ++ base
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case HandleGamePacket(len, data, extra) =>
len mustEqual 459
data mustEqual base
@@ -25,7 +25,7 @@ class HandleGamePacketTest extends Specification {
"encode" in {
val pkt = HandleGamePacket(base)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string
}
}
diff --git a/src/test/scala/control/MultiPacketCollectorTest.scala b/src/test/scala/control/MultiPacketCollectorTest.scala
deleted file mode 100644
index c626ece8b..000000000
--- a/src/test/scala/control/MultiPacketCollectorTest.scala
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright (c) 2017 PSForever
-package control
-
-import org.specs2.mutable._
-import net.psforever.packet.control.{ControlSync, MultiPacketBundle, MultiPacketCollector}
-import net.psforever.packet.crypto.{ClientFinished, ServerFinished}
-import net.psforever.packet.game.ObjectDeleteMessage
-import net.psforever.types.PlanetSideGUID
-
-class MultiPacketCollectorTest extends Specification {
- val packet1 = ObjectDeleteMessage(PlanetSideGUID(1103), 2)
-
- "MultiPacketBundle" should {
- import scodec.bits._
- val packet2 = ControlSync(21096, 0x4d, 0x52, 0x4d, 0x7c, 0x4d, 0x276, 0x275)
-
- "construct" in {
- MultiPacketBundle(List(packet1))
- ok
- }
-
- "fail to construct if not initialized with PlanetSidePackets" in {
- MultiPacketBundle(Nil) must throwA[IllegalArgumentException]
- }
-
- "concatenate bundles into a new bundle" in {
- val obj1 = MultiPacketBundle(List(packet1))
- val obj2 = MultiPacketBundle(List(packet2))
- val obj3 = obj1 + obj2
- obj3 match {
- case MultiPacketBundle(list) =>
- list.size mustEqual 2
- list.head mustEqual packet1
- list(1) mustEqual packet2
- case _ =>
- ko
- }
- }
-
- "accept PlanetSideGamePackets and PlanetSideControlPackets" in {
- MultiPacketBundle(List(packet2, packet1)) match {
- case MultiPacketBundle(list) =>
- list.size mustEqual 2
- list.head mustEqual packet2
- list(1) mustEqual packet1
- case _ =>
- ko
- }
- }
-
- "ignore other types of PlanetSideContainerPackets" in {
- val param = List(packet2, ClientFinished(hex"", hex""), packet1, ServerFinished(hex""))
- MultiPacketBundle(param) match { //warning message will display in log
- case MultiPacketBundle(list) =>
- list.size mustEqual 2
- list.head mustEqual param.head
- list(1) mustEqual param(2)
- case _ =>
- ko
- }
- }
- }
-
- "MultiPacketCollector" should {
- val packet2 = ObjectDeleteMessage(PlanetSideGUID(1105), 2)
- val packet3 = ObjectDeleteMessage(PlanetSideGUID(1107), 2)
-
- "construct" in {
- new MultiPacketCollector()
- ok
- }
-
- "construct with initial packets" in {
- MultiPacketCollector(List(packet1, packet2))
- ok
- }
-
- "can retrieve a bundle packets" in {
- val obj = MultiPacketCollector(List(packet1, packet2))
- obj.Bundle match {
- case Some(MultiPacketBundle(list)) =>
- list.size mustEqual 2
- list.head mustEqual packet1
- list(1) mustEqual packet2
- case _ =>
- ko
- }
- }
-
- "can retrieve a bundle of potential packets" in {
- val obj1 = new MultiPacketCollector()
- obj1.Bundle match {
- case Some(_) =>
- ko
- case _ => ;
- }
-
- val obj2 = MultiPacketCollector(List(packet1, packet2))
- obj2.Bundle match {
- case None =>
- ko
- case Some(MultiPacketBundle(list)) =>
- list.size mustEqual 2
- list.head mustEqual packet1
- list(1) mustEqual packet2
- }
- }
-
- "clear packets after being asked to bundle" in {
- val list = List(packet1, packet2)
- val obj = MultiPacketCollector(list)
-
- obj.Bundle match {
- case Some(MultiPacketBundle(bundle)) =>
- bundle mustEqual list
- case _ =>
- ko
- }
-
- obj.Bundle match {
- case Some(MultiPacketBundle(_)) =>
- ko
- case _ =>
- ok
- }
- }
-
- "add a packet" in {
- val obj = new MultiPacketCollector()
- obj.Add(packet1)
- obj.Bundle match {
- case Some(MultiPacketBundle(list)) =>
- list.size mustEqual 1
- list.head mustEqual packet1
- case _ =>
- ko
- }
- }
-
- "add packets" in {
- val obj = new MultiPacketCollector()
- obj.Add(List(packet1, packet2))
- obj.Bundle match {
- case Some(MultiPacketBundle(list)) =>
- list.size mustEqual 2
- list.head mustEqual packet1
- list(1) mustEqual packet2
- case _ =>
- ko
- }
- }
-
- "concatenate bundles (1)" in {
-
- val obj1 = new MultiPacketCollector()
- obj1.Add(List(packet1, packet2))
- obj1.Bundle match {
- case Some(MultiPacketBundle(bundle1)) =>
- val obj2 = MultiPacketCollector(bundle1)
- obj2.Add(packet3)
- obj2.Bundle match {
- case Some(MultiPacketBundle(list)) =>
- list.size mustEqual 3
- list.head mustEqual packet1
- list(1) mustEqual packet2
- list(2) mustEqual packet3
- case _ =>
- ko
- }
- case _ =>
- ko
- }
-
- }
-
- "concatenate bundles (2)" in {
- val obj1 = new MultiPacketCollector()
- obj1.Add(List(packet1, packet2))
- obj1.Bundle match {
- case Some(MultiPacketBundle(bundle1)) =>
- val obj2 = new MultiPacketCollector()
- obj2.Add(packet3)
- obj2.Add(bundle1)
- obj2.Bundle match {
- case Some(MultiPacketBundle(list)) =>
- list.size mustEqual 3
- list.head mustEqual packet3
- list(1) mustEqual packet1
- list(2) mustEqual packet2
- case _ =>
- ko
- }
- case _ =>
- ko
- }
-
- }
- }
-}
diff --git a/src/test/scala/control/MultiPacketTest.scala b/src/test/scala/control/MultiPacketTest.scala
index 6ca39a49e..bf4029f2a 100644
--- a/src/test/scala/control/MultiPacketTest.scala
+++ b/src/test/scala/control/MultiPacketTest.scala
@@ -11,7 +11,7 @@ class MultiPacketTest extends Specification {
hex"00 03 04 00 15 13 23 3A 00 09 03 E3 00 19 16 6D 56 05 68 05 40 A0 EF 45 00 15 0E 44 00 A0 A2 41 00 00 0F 88 00 06 E4 C0 60 00 00 00 15 E4 32 40 74 72 61 69 6E 69 6E 67 5F 77 65 61 70 6F 6E 73 30 31 13 BD 68 05 53 F6 EF 90 D1 6E 03 14 FE 78 8C 20 1C C0 00 00 1F 00 09 03 E4 6D 56 05 68 05 40 A0 EF 45 00 15 0E 44 30 89 A1 41 00 00 0F 8A 01 00 04 18 EF 80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case MultiPacket(data) =>
data.size mustEqual 4
data(0) mustEqual hex"00151323"
@@ -34,7 +34,7 @@ class MultiPacketTest extends Specification {
hex"000903e46d5605680540a0ef4500150e443089a14100000f8a01000418ef80"
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/control/RelatedATest.scala b/src/test/scala/control/RelatedATest.scala
index b62b2210d..765428494 100644
--- a/src/test/scala/control/RelatedATest.scala
+++ b/src/test/scala/control/RelatedATest.scala
@@ -13,7 +13,7 @@ class RelatedATest extends Specification {
val string3 = hex"00 14 01 04"
"decode (0)" in {
- PacketCoding.DecodePacket(string0).require match {
+ PacketCoding.decodePacket(string0).require match {
case RelatedA(slot, subslot) =>
slot mustEqual 0
subslot mustEqual 260
@@ -23,7 +23,7 @@ class RelatedATest extends Specification {
}
"decode (1)" in {
- PacketCoding.DecodePacket(string1).require match {
+ PacketCoding.decodePacket(string1).require match {
case RelatedA(slot, subslot) =>
slot mustEqual 1
subslot mustEqual 260
@@ -33,7 +33,7 @@ class RelatedATest extends Specification {
}
"decode (2)" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case RelatedA(slot, subslot) =>
slot mustEqual 2
subslot mustEqual 260
@@ -43,7 +43,7 @@ class RelatedATest extends Specification {
}
"decode (3)" in {
- PacketCoding.DecodePacket(string3).require match {
+ PacketCoding.decodePacket(string3).require match {
case RelatedA(slot, subslot) =>
slot mustEqual 3
subslot mustEqual 260
@@ -54,25 +54,25 @@ class RelatedATest extends Specification {
"encode (0)" in {
val pkt = RelatedA(0, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string0
}
"encode (1)" in {
val pkt = RelatedA(1, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string1
}
"encode (2)" in {
val pkt = RelatedA(2, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string2
}
"encode (3)" in {
val pkt = RelatedA(3, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string3
}
diff --git a/src/test/scala/control/RelatedBTest.scala b/src/test/scala/control/RelatedBTest.scala
index 3b29cf91d..069e17773 100644
--- a/src/test/scala/control/RelatedBTest.scala
+++ b/src/test/scala/control/RelatedBTest.scala
@@ -13,7 +13,7 @@ class RelatedBTest extends Specification {
val string3 = hex"00 18 01 04"
"decode (0)" in {
- PacketCoding.DecodePacket(string0).require match {
+ PacketCoding.decodePacket(string0).require match {
case RelatedB(slot, subslot) =>
slot mustEqual 0
subslot mustEqual 260
@@ -23,7 +23,7 @@ class RelatedBTest extends Specification {
}
"decode (1)" in {
- PacketCoding.DecodePacket(string1).require match {
+ PacketCoding.decodePacket(string1).require match {
case RelatedB(slot, subslot) =>
slot mustEqual 1
subslot mustEqual 260
@@ -33,7 +33,7 @@ class RelatedBTest extends Specification {
}
"decode (2)" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case RelatedB(slot, subslot) =>
slot mustEqual 2
subslot mustEqual 260
@@ -43,7 +43,7 @@ class RelatedBTest extends Specification {
}
"decode (3)" in {
- PacketCoding.DecodePacket(string3).require match {
+ PacketCoding.decodePacket(string3).require match {
case RelatedB(slot, subslot) =>
slot mustEqual 3
subslot mustEqual 260
@@ -54,25 +54,25 @@ class RelatedBTest extends Specification {
"encode (0)" in {
val pkt = RelatedB(0, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string0
}
"encode (1)" in {
val pkt = RelatedB(1, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string1
}
"encode (2)" in {
val pkt = RelatedB(2, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string2
}
"encode (3)" in {
val pkt = RelatedB(3, 260)
- val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
+ val msg = PacketCoding.encodePacket(pkt).require.toByteVector
msg mustEqual string3
}
diff --git a/src/test/scala/control/SlottedMetaPacketTest.scala b/src/test/scala/control/SlottedMetaPacketTest.scala
index 4b5f88f66..664589b31 100644
--- a/src/test/scala/control/SlottedMetaPacketTest.scala
+++ b/src/test/scala/control/SlottedMetaPacketTest.scala
@@ -29,7 +29,7 @@ class SlottedMetaPacketTest extends Specification {
.toByteVector ++ uint16.encode(subslot).require.toByteVector ++ rest
"decode as the base slot and subslot" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SlottedMetaPacket(slot, subslot, rest) =>
slot mustEqual 0
subslot mustEqual 0
@@ -48,7 +48,7 @@ class SlottedMetaPacketTest extends Specification {
val subslot = 12323
val pkt = createMetaPacket(i, subslot, ByteVector.empty)
- PacketCoding.DecodePacket(pkt).require match {
+ PacketCoding.decodePacket(pkt).require match {
case SlottedMetaPacket(slot, subslotDecoded, rest) =>
// XXX: there isn't a simple solution to Slot0 and Slot4 be aliases of each other structurally
// This is probably best left to higher layers
@@ -64,16 +64,16 @@ class SlottedMetaPacketTest extends Specification {
}
"encode" in {
- val encoded = PacketCoding.EncodePacket(SlottedMetaPacket(0, 0x1000, ByteVector.empty)).require
- val encoded2 = PacketCoding.EncodePacket(SlottedMetaPacket(3, 0xffff, hex"414243")).require
- val encoded3 = PacketCoding.EncodePacket(SlottedMetaPacket(7, 0, hex"00")).require
+ val encoded = PacketCoding.encodePacket(SlottedMetaPacket(0, 0x1000, ByteVector.empty)).require
+ val encoded2 = PacketCoding.encodePacket(SlottedMetaPacket(3, 0xffff, hex"414243")).require
+ val encoded3 = PacketCoding.encodePacket(SlottedMetaPacket(7, 0, hex"00")).require
encoded.toByteVector mustEqual createMetaPacket(0, 0x1000, ByteVector.empty)
encoded2.toByteVector mustEqual createMetaPacket(3, 0xffff, hex"414243")
encoded3.toByteVector mustEqual createMetaPacket(7, 0, hex"00")
- PacketCoding.EncodePacket(SlottedMetaPacket(8, 0, hex"00")).require must throwA[AssertionError]
- PacketCoding.EncodePacket(SlottedMetaPacket(-1, 0, hex"00")).require must throwA[AssertionError]
- PacketCoding.EncodePacket(SlottedMetaPacket(0, 0x10000, hex"00")).require must throwA[IllegalArgumentException]
+ PacketCoding.encodePacket(SlottedMetaPacket(8, 0, hex"00")).require must throwA[AssertionError]
+ PacketCoding.encodePacket(SlottedMetaPacket(-1, 0, hex"00")).require must throwA[AssertionError]
+ PacketCoding.encodePacket(SlottedMetaPacket(0, 0x10000, hex"00")).require must throwA[IllegalArgumentException]
}
}
diff --git a/src/test/scala/control/TeardownConnectionTest.scala b/src/test/scala/control/TeardownConnectionTest.scala
index dc62f354a..e606c41e5 100644
--- a/src/test/scala/control/TeardownConnectionTest.scala
+++ b/src/test/scala/control/TeardownConnectionTest.scala
@@ -10,7 +10,7 @@ class TeardownConnectionTest extends Specification {
val string = hex"00 05 02 4F 57 17 00 06"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case TeardownConnection(nonce) =>
nonce mustEqual 391597826
case _ =>
@@ -19,7 +19,7 @@ class TeardownConnectionTest extends Specification {
}
"encode" in {
- val encoded = PacketCoding.EncodePacket(TeardownConnection(391597826)).require
+ val encoded = PacketCoding.encodePacket(TeardownConnection(391597826)).require
encoded.toByteVector mustEqual string
}
diff --git a/src/test/scala/game/ActionCancelMessageTest.scala b/src/test/scala/game/ActionCancelMessageTest.scala
index 1909148f9..41af48866 100644
--- a/src/test/scala/game/ActionCancelMessageTest.scala
+++ b/src/test/scala/game/ActionCancelMessageTest.scala
@@ -11,7 +11,7 @@ class ActionCancelMessageTest extends Specification {
val string = hex"22 201ee01a10"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ActionCancelMessage(player_guid, object_guid, unk) =>
player_guid mustEqual PlanetSideGUID(7712)
object_guid mustEqual PlanetSideGUID(6880)
@@ -23,7 +23,7 @@ class ActionCancelMessageTest extends Specification {
"encode" in {
val msg = ActionCancelMessage(PlanetSideGUID(7712), PlanetSideGUID(6880), 1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ActionProgressMessageTest.scala b/src/test/scala/game/ActionProgressMessageTest.scala
index 30d05b2bf..1f31e26ee 100644
--- a/src/test/scala/game/ActionProgressMessageTest.scala
+++ b/src/test/scala/game/ActionProgressMessageTest.scala
@@ -10,7 +10,7 @@ class ActionProgressMessageTest extends Specification {
val string = hex"216000000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ActionProgressMessage(unk1, unk2) =>
unk1 mustEqual 6
unk2 mustEqual 0
@@ -21,7 +21,7 @@ class ActionProgressMessageTest extends Specification {
"encode" in {
val msg = ActionProgressMessage(6, 0L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ActionResultMessageTest.scala b/src/test/scala/game/ActionResultMessageTest.scala
index 29c9d950f..4ce697af8 100644
--- a/src/test/scala/game/ActionResultMessageTest.scala
+++ b/src/test/scala/game/ActionResultMessageTest.scala
@@ -11,7 +11,7 @@ class ActionResultMessageTest extends Specification {
val string_fail = hex"1f 0080000000"
"decode (pass)" in {
- PacketCoding.DecodePacket(string_pass).require match {
+ PacketCoding.decodePacket(string_pass).require match {
case ActionResultMessage(okay, code) =>
okay mustEqual true
code mustEqual None
@@ -21,7 +21,7 @@ class ActionResultMessageTest extends Specification {
}
"decode (fail)" in {
- PacketCoding.DecodePacket(string_fail).require match {
+ PacketCoding.decodePacket(string_fail).require match {
case ActionResultMessage(okay, code) =>
okay mustEqual false
code mustEqual Some(1)
@@ -32,28 +32,28 @@ class ActionResultMessageTest extends Specification {
"encode (pass, full)" in {
val msg = ActionResultMessage(true, None)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_pass
}
"encode (pass, minimal)" in {
val msg = ActionResultMessage.Pass
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_pass
}
"encode (fail, full)" in {
val msg = ActionResultMessage(false, Some(1))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_fail
}
"encode (fail, minimal)" in {
val msg = ActionResultMessage.Fail(1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_fail
}
diff --git a/src/test/scala/game/AggravatedDamageMessageTest.scala b/src/test/scala/game/AggravatedDamageMessageTest.scala
index 7cc9783a9..01a54e545 100644
--- a/src/test/scala/game/AggravatedDamageMessageTest.scala
+++ b/src/test/scala/game/AggravatedDamageMessageTest.scala
@@ -11,8 +11,8 @@ class AggravatedDamageMessageTest extends Specification {
val string = hex"6a350a0e000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
- case AggravatedDamageMessage(guid,unk) =>
+ PacketCoding.decodePacket(string).require match {
+ case AggravatedDamageMessage(guid, unk) =>
guid mustEqual PlanetSideGUID(2613)
unk mustEqual 14
case _ =>
@@ -22,7 +22,7 @@ class AggravatedDamageMessageTest extends Specification {
"encode" in {
val msg = AggravatedDamageMessage(PlanetSideGUID(2613), 14)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ArmorChangedMessageTest.scala b/src/test/scala/game/ArmorChangedMessageTest.scala
index ce2e57ce2..4a3f89439 100644
--- a/src/test/scala/game/ArmorChangedMessageTest.scala
+++ b/src/test/scala/game/ArmorChangedMessageTest.scala
@@ -11,7 +11,7 @@ class ArmorChangedMessageTest extends Specification {
val string = hex"3E 11 01 4C"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ArmorChangedMessage(player_guid, armor, subtype) =>
player_guid mustEqual PlanetSideGUID(273)
armor mustEqual ExoSuitType.MAX
@@ -23,7 +23,7 @@ class ArmorChangedMessageTest extends Specification {
"encode" in {
val msg = ArmorChangedMessage(PlanetSideGUID(273), ExoSuitType.MAX, 3)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/AvatarDeadStateMessageTest.scala b/src/test/scala/game/AvatarDeadStateMessageTest.scala
index 68e404af6..d32ac8175 100644
--- a/src/test/scala/game/AvatarDeadStateMessageTest.scala
+++ b/src/test/scala/game/AvatarDeadStateMessageTest.scala
@@ -12,7 +12,7 @@ class AvatarDeadStateMessageTest extends Specification {
val string_invalid = hex"ad3c1260801c12608009f99861fb0741e0400000F0"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case AvatarDeadStateMessage(unk1, unk2, unk3, pos, unk4, unk5) =>
unk1 mustEqual DeadState.Dead
unk2 mustEqual 300000
@@ -26,7 +26,7 @@ class AvatarDeadStateMessageTest extends Specification {
}
"decode (failure)" in {
- PacketCoding.DecodePacket(string_invalid).isFailure mustEqual true
+ PacketCoding.decodePacket(string_invalid).isFailure mustEqual true
}
"encode" in {
@@ -38,7 +38,7 @@ class AvatarDeadStateMessageTest extends Specification {
PlanetSideEmpire.VS,
true
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/AvatarFirstTimeEventMessageTest.scala b/src/test/scala/game/AvatarFirstTimeEventMessageTest.scala
index 735a9ff1a..efecc8502 100644
--- a/src/test/scala/game/AvatarFirstTimeEventMessageTest.scala
+++ b/src/test/scala/game/AvatarFirstTimeEventMessageTest.scala
@@ -11,7 +11,7 @@ class AvatarFirstTimeEventMessageTest extends Specification {
val string = hex"69 4b00 c000 01000000 9e 766973697465645f63657274696669636174696f6e5f7465726d696e616c"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case AvatarFirstTimeEventMessage(avatar_guid, object_guid, unk1, event_name) =>
avatar_guid mustEqual PlanetSideGUID(75)
object_guid mustEqual PlanetSideGUID(192)
@@ -24,7 +24,7 @@ class AvatarFirstTimeEventMessageTest extends Specification {
"encode" in {
val msg = AvatarFirstTimeEventMessage(PlanetSideGUID(75), PlanetSideGUID(192), 1, "visited_certification_terminal")
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/AvatarGrenadeStateMessageTest.scala b/src/test/scala/game/AvatarGrenadeStateMessageTest.scala
index 67bbc1f57..e325c9a35 100644
--- a/src/test/scala/game/AvatarGrenadeStateMessageTest.scala
+++ b/src/test/scala/game/AvatarGrenadeStateMessageTest.scala
@@ -11,7 +11,7 @@ class AvatarGrenadeStateMessageTest extends Specification {
val string = hex"A9 DA11 01"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case AvatarGrenadeStateMessage(player_guid, state) =>
player_guid mustEqual PlanetSideGUID(4570)
state mustEqual GrenadeState.Primed
@@ -22,7 +22,7 @@ class AvatarGrenadeStateMessageTest extends Specification {
"encode" in {
val msg = AvatarGrenadeStateMessage(PlanetSideGUID(4570), GrenadeState.Primed)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/AvatarImplantMessageTest.scala b/src/test/scala/game/AvatarImplantMessageTest.scala
index 3591f6fd0..32f687869 100644
--- a/src/test/scala/game/AvatarImplantMessageTest.scala
+++ b/src/test/scala/game/AvatarImplantMessageTest.scala
@@ -11,7 +11,7 @@ class AvatarImplantMessageTest extends Specification {
val string = hex"58 630C 68 80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case AvatarImplantMessage(player_guid, unk1, unk2, implant) =>
player_guid mustEqual PlanetSideGUID(3171)
unk1 mustEqual ImplantAction.Activation
@@ -24,7 +24,7 @@ class AvatarImplantMessageTest extends Specification {
"encode" in {
val msg = AvatarImplantMessage(PlanetSideGUID(3171), ImplantAction.Activation, 1, 1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/AvatarJumpMessageTest.scala b/src/test/scala/game/AvatarJumpMessageTest.scala
index 667addeeb..2e6c14f58 100644
--- a/src/test/scala/game/AvatarJumpMessageTest.scala
+++ b/src/test/scala/game/AvatarJumpMessageTest.scala
@@ -10,7 +10,7 @@ class AvatarJumpMessageTest extends Specification {
val string = hex"35 80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case AvatarJumpMessage(state) =>
state mustEqual true
case _ =>
@@ -20,7 +20,7 @@ class AvatarJumpMessageTest extends Specification {
"encode" in {
val msg = AvatarJumpMessage(true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/AvatarSearchCriteriaMessageTest.scala b/src/test/scala/game/AvatarSearchCriteriaMessageTest.scala
index 5efbf7005..50e8fc1a3 100644
--- a/src/test/scala/game/AvatarSearchCriteriaMessageTest.scala
+++ b/src/test/scala/game/AvatarSearchCriteriaMessageTest.scala
@@ -11,7 +11,7 @@ class AvatarSearchCriteriaMessageTest extends Specification {
val string = hex"64 C604 00 00 00 00 00 00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case AvatarSearchCriteriaMessage(unk1, unk2) =>
unk1 mustEqual PlanetSideGUID(1222)
unk2.length mustEqual 6
@@ -28,23 +28,23 @@ class AvatarSearchCriteriaMessageTest extends Specification {
"encode" in {
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0, 0, 0, 0, 0, 0))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (failure; wrong number of list entries)" in {
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0))
- PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
+ PacketCoding.encodePacket(msg).isSuccessful mustEqual false
}
"encode (failure; list number too big)" in {
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0, 0, 0, 0, 0, 256))
- PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
+ PacketCoding.encodePacket(msg).isSuccessful mustEqual false
}
"encode (failure; list number too small)" in {
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0, 0, 0, -1, 0, 0))
- PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
+ PacketCoding.encodePacket(msg).isSuccessful mustEqual false
}
}
diff --git a/src/test/scala/game/AvatarStatisticsMessageTest.scala b/src/test/scala/game/AvatarStatisticsMessageTest.scala
index ddbc966d3..4856932d6 100644
--- a/src/test/scala/game/AvatarStatisticsMessageTest.scala
+++ b/src/test/scala/game/AvatarStatisticsMessageTest.scala
@@ -12,7 +12,7 @@ class AvatarStatisticsMessageTest extends Specification {
hex"7F 01 3C 40 20 00 00 00 C0 00 00 00 00 00 00 00 20 00 00 00 20 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00"
"decode (long)" in {
- PacketCoding.DecodePacket(string_long).require match {
+ PacketCoding.decodePacket(string_long).require match {
case AvatarStatisticsMessage(unk, stats) =>
unk mustEqual 2
stats.unk1 mustEqual None
@@ -25,7 +25,7 @@ class AvatarStatisticsMessageTest extends Specification {
}
"decode (complex)" in {
- PacketCoding.DecodePacket(string_complex).require match {
+ PacketCoding.decodePacket(string_complex).require match {
case AvatarStatisticsMessage(unk, stats) =>
unk mustEqual 0
stats.unk1 mustEqual Some(1)
@@ -46,35 +46,35 @@ class AvatarStatisticsMessageTest extends Specification {
"encode (long)" in {
val msg = AvatarStatisticsMessage(2, Statistics(0L))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_long
}
"encode (complex)" in {
val msg = AvatarStatisticsMessage(0, Statistics(1, 572, List[Long](1, 6, 0, 1, 1, 2, 0, 0)))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_complex
}
"encode (failure; long; missing value)" in {
val msg = AvatarStatisticsMessage(0, Statistics(None, None, List(0L)))
- PacketCoding.EncodePacket(msg).isFailure mustEqual true
+ PacketCoding.encodePacket(msg).isFailure mustEqual true
}
"encode (failure; complex; missing value (5-bit))" in {
val msg = AvatarStatisticsMessage(0, Statistics(None, Some(572), List[Long](1, 6, 0, 1, 1, 2, 0, 0)))
- PacketCoding.EncodePacket(msg).isFailure mustEqual true
+ PacketCoding.encodePacket(msg).isFailure mustEqual true
}
"encode (failure; complex; missing value (11-bit))" in {
val msg = AvatarStatisticsMessage(0, Statistics(Some(1), None, List[Long](1, 6, 0, 1, 1, 2, 0, 0)))
- PacketCoding.EncodePacket(msg).isFailure mustEqual true
+ PacketCoding.encodePacket(msg).isFailure mustEqual true
}
"encode (failure; complex; wrong number of list entries)" in {
val msg = AvatarStatisticsMessage(0, Statistics(Some(1), None, List[Long](1, 6, 0, 1)))
- PacketCoding.EncodePacket(msg).isFailure mustEqual true
+ PacketCoding.encodePacket(msg).isFailure mustEqual true
}
}
diff --git a/src/test/scala/game/AvatarVehicleTimerMessageTest.scala b/src/test/scala/game/AvatarVehicleTimerMessageTest.scala
index 897e98b98..eeb3074ea 100644
--- a/src/test/scala/game/AvatarVehicleTimerMessageTest.scala
+++ b/src/test/scala/game/AvatarVehicleTimerMessageTest.scala
@@ -12,7 +12,7 @@ class AvatarVehicleTimerMessageTest extends Specification {
val string2 = hex"57971b84667572794800000080"
"decode medkit" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case AvatarVehicleTimerMessage(player_guid, text, time, u1) =>
player_guid mustEqual PlanetSideGUID(5821)
text mustEqual "medkit"
@@ -23,7 +23,7 @@ class AvatarVehicleTimerMessageTest extends Specification {
}
}
"decode fury" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case AvatarVehicleTimerMessage(player_guid, text, time, u1) =>
player_guid mustEqual PlanetSideGUID(7063)
text mustEqual "fury"
@@ -36,13 +36,13 @@ class AvatarVehicleTimerMessageTest extends Specification {
"encode medkit" in {
val msg = AvatarVehicleTimerMessage(PlanetSideGUID(5821), "medkit", 5, false)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode fury" in {
val msg = AvatarVehicleTimerMessage(PlanetSideGUID(7063), "fury", 72, true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string2
}
diff --git a/src/test/scala/game/BattleExperienceMessageTest.scala b/src/test/scala/game/BattleExperienceMessageTest.scala
index 3df06013b..25eeeb101 100644
--- a/src/test/scala/game/BattleExperienceMessageTest.scala
+++ b/src/test/scala/game/BattleExperienceMessageTest.scala
@@ -11,7 +11,7 @@ class BattleExperienceMessageTest extends Specification {
val string = hex"B4 8A0A E7030000 00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case BattleExperienceMessage(player_guid, experience, unk) =>
player_guid mustEqual PlanetSideGUID(2698)
experience mustEqual 999
@@ -23,7 +23,7 @@ class BattleExperienceMessageTest extends Specification {
"encode" in {
val msg = BattleExperienceMessage(PlanetSideGUID(2698), 999, 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/BattleplanMessageTest.scala b/src/test/scala/game/BattleplanMessageTest.scala
index ed3804c17..57616043f 100644
--- a/src/test/scala/game/BattleplanMessageTest.scala
+++ b/src/test/scala/game/BattleplanMessageTest.scala
@@ -19,7 +19,7 @@ class BattleplanMessageTest extends Specification {
//0xb3856477028c4f0075007400730074006100620075006c006f00750073000a000130
"decode (start)" in {
- PacketCoding.DecodePacket(string_start).require match {
+ PacketCoding.decodePacket(string_start).require match {
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
char_id mustEqual 41490746
player_name mustEqual "YetAnotherFailureAlt"
@@ -34,7 +34,7 @@ class BattleplanMessageTest extends Specification {
}
"decode (end)" in {
- PacketCoding.DecodePacket(string_stop).require match {
+ PacketCoding.decodePacket(string_stop).require match {
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
char_id mustEqual 41490746
player_name mustEqual "YetAnotherFailureAlt"
@@ -49,7 +49,7 @@ class BattleplanMessageTest extends Specification {
}
"decode (stop)" in {
- PacketCoding.DecodePacket(string_line).require match {
+ PacketCoding.decodePacket(string_line).require match {
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
char_id mustEqual 41378949
player_name mustEqual "Outstabulous"
@@ -191,7 +191,7 @@ class BattleplanMessageTest extends Specification {
}
"decode (style)" in {
- PacketCoding.DecodePacket(string_style).require match {
+ PacketCoding.decodePacket(string_style).require match {
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
char_id mustEqual 41378949
player_name mustEqual "Outstabulous"
@@ -217,7 +217,7 @@ class BattleplanMessageTest extends Specification {
}
"decode (message)" in {
- PacketCoding.DecodePacket(string_message).require match {
+ PacketCoding.decodePacket(string_message).require match {
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
char_id mustEqual 41378949
player_name mustEqual "Outstabulous"
@@ -245,7 +245,7 @@ class BattleplanMessageTest extends Specification {
BattleDiagramAction(DiagramActionCode.StartDrawing) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_start
}
@@ -258,7 +258,7 @@ class BattleplanMessageTest extends Specification {
BattleDiagramAction(DiagramActionCode.StopDrawing) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_stop
}
@@ -302,7 +302,7 @@ class BattleplanMessageTest extends Specification {
BattleDiagramAction.vertex(7536.0f, 6632.0f) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_line
}
@@ -317,7 +317,7 @@ class BattleplanMessageTest extends Specification {
BattleDiagramAction.vertex(7512.0f, 6344.0f) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_style
}
@@ -329,7 +329,7 @@ class BattleplanMessageTest extends Specification {
10,
BattleDiagramAction.drawString(7512.0f, 6312.0f, 2, 0, "Hello Auraxis!") :: Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_message
}
diff --git a/src/test/scala/game/BeginZoningMessageTest.scala b/src/test/scala/game/BeginZoningMessageTest.scala
index eaacc6f63..78823b42b 100644
--- a/src/test/scala/game/BeginZoningMessageTest.scala
+++ b/src/test/scala/game/BeginZoningMessageTest.scala
@@ -10,7 +10,7 @@ class BeginZoningMessageTest extends Specification {
val string = hex"43" //yes, just the opcode
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case BeginZoningMessage() =>
ok
case _ =>
@@ -20,7 +20,7 @@ class BeginZoningMessageTest extends Specification {
"encode" in {
val msg = BeginZoningMessage()
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/BindPlayerMessageTest.scala b/src/test/scala/game/BindPlayerMessageTest.scala
index d4f0fc40e..99ccde55b 100644
--- a/src/test/scala/game/BindPlayerMessageTest.scala
+++ b/src/test/scala/game/BindPlayerMessageTest.scala
@@ -14,7 +14,7 @@ class BindPlayerMessageTest extends Specification {
val string_akkan = hex"16048440616d7388100000001400000214e171a8e33024"
"decode (standard)" in {
- PacketCoding.DecodePacket(string_standard).require match {
+ PacketCoding.decodePacket(string_standard).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
action mustEqual BindStatus.Unbind
bindDesc mustEqual ""
@@ -30,7 +30,7 @@ class BindPlayerMessageTest extends Specification {
}
"decode (ams)" in {
- PacketCoding.DecodePacket(string_ams).require match {
+ PacketCoding.decodePacket(string_ams).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
action mustEqual BindStatus.Unavailable
bindDesc mustEqual "@ams"
@@ -46,7 +46,7 @@ class BindPlayerMessageTest extends Specification {
}
"decode (tech)" in {
- PacketCoding.DecodePacket(string_tech).require match {
+ PacketCoding.decodePacket(string_tech).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
action mustEqual BindStatus.Bind
bindDesc mustEqual "@tech_plant"
@@ -62,7 +62,7 @@ class BindPlayerMessageTest extends Specification {
}
"decode (akkan)" in {
- PacketCoding.DecodePacket(string_akkan).require match {
+ PacketCoding.decodePacket(string_akkan).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
action mustEqual BindStatus.Available
bindDesc mustEqual "@ams"
@@ -79,14 +79,14 @@ class BindPlayerMessageTest extends Specification {
"encode (standard)" in {
val msg = BindPlayerMessage.Standard
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_standard
}
"encode (ams)" in {
val msg = BindPlayerMessage(BindStatus.Unavailable, "@ams", false, false, SpawnGroup.AMS, 10, 0, Vector3.Zero)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ams
}
@@ -102,7 +102,7 @@ class BindPlayerMessageTest extends Specification {
14,
Vector3(4610.0f, 6292, 69.625f)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_tech
}
@@ -118,7 +118,7 @@ class BindPlayerMessageTest extends Specification {
5,
Vector3(2673.039f, 4423.547f, 39.1875f)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_akkan
}
diff --git a/src/test/scala/game/BroadcastWarpgateUpdateMessageTest.scala b/src/test/scala/game/BroadcastWarpgateUpdateMessageTest.scala
index eaeed5e8b..81e15be50 100644
--- a/src/test/scala/game/BroadcastWarpgateUpdateMessageTest.scala
+++ b/src/test/scala/game/BroadcastWarpgateUpdateMessageTest.scala
@@ -10,7 +10,7 @@ class BroadcastWarpgateUpdateMessageTest extends Specification {
val string = hex"D9 0D 00 01 00 20"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case BroadcastWarpgateUpdateMessage(continent_guid, building_guid, state1, state2, state3) =>
continent_guid mustEqual 13
building_guid mustEqual 1
@@ -24,7 +24,7 @@ class BroadcastWarpgateUpdateMessageTest extends Specification {
"encode" in {
val msg = BroadcastWarpgateUpdateMessage(13, 1, false, false, true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/BugReportMessageTest.scala b/src/test/scala/game/BugReportMessageTest.scala
index 511db98dd..76b766f3e 100644
--- a/src/test/scala/game/BugReportMessageTest.scala
+++ b/src/test/scala/game/BugReportMessageTest.scala
@@ -12,7 +12,7 @@ class BugReportMessageTest extends Specification {
hex"89 03000000 0F000000 8B4465632020322032303039 1 1 0 19 6C511 656B1 7A11 830610062006300 843100320033003400"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case BugReportMessage(major, minor, date, btype, repeat, unk, zone, loc, summary, desc) =>
major mustEqual 3
minor mustEqual 15
@@ -43,7 +43,7 @@ class BugReportMessageTest extends Specification {
"abc",
"1234"
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/BuildingInfoUpdateMessageTest.scala b/src/test/scala/game/BuildingInfoUpdateMessageTest.scala
index 1c3b1f7cc..bccdc43b7 100644
--- a/src/test/scala/game/BuildingInfoUpdateMessageTest.scala
+++ b/src/test/scala/game/BuildingInfoUpdateMessageTest.scala
@@ -11,7 +11,7 @@ class BuildingInfoUpdateMessageTest extends Specification {
val string = hex"a0 04 00 09 00 16 00 00 00 00 80 00 00 00 17 00 00 00 00 00 00 40"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case BuildingInfoUpdateMessage(
continent_guid,
building_guid,
@@ -86,7 +86,7 @@ class BuildingInfoUpdateMessageTest extends Specification {
false,
false
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ChainLashMessageTest.scala b/src/test/scala/game/ChainLashMessageTest.scala
index af7b48efe..87075dcd3 100644
--- a/src/test/scala/game/ChainLashMessageTest.scala
+++ b/src/test/scala/game/ChainLashMessageTest.scala
@@ -12,7 +12,7 @@ class ChainLashMessageTest extends Specification {
val string2 = hex"c5 5282e910100000093050"
"decode (1)" in {
- PacketCoding.DecodePacket(string1).require match {
+ PacketCoding.decodePacket(string1).require match {
case ChainLashMessage(u1a, u1b, u2, u3) =>
u1a.isEmpty mustEqual true
u1b.contains(Vector3(7673.164f, 544.1328f, 14.984375f)) mustEqual true
@@ -24,7 +24,7 @@ class ChainLashMessageTest extends Specification {
}
"decode (2)" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case ChainLashMessage(u1a, u1b, u2, u3) =>
u1a.contains(PlanetSideGUID(1445)) mustEqual true
u1b.isEmpty mustEqual true
@@ -37,14 +37,14 @@ class ChainLashMessageTest extends Specification {
"encode (1)" in {
val msg = ChainLashMessage(Vector3(7673.164f, 544.1328f, 14.984375f), 466, List(PlanetSideGUID(1603)))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string1
}
"encode (2)" in {
val msg = ChainLashMessage(PlanetSideGUID(1445), 466, List(PlanetSideGUID(1427)))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string2
}
diff --git a/src/test/scala/game/ChangeAmmoMessageTest.scala b/src/test/scala/game/ChangeAmmoMessageTest.scala
index f0a1a326b..977371800 100644
--- a/src/test/scala/game/ChangeAmmoMessageTest.scala
+++ b/src/test/scala/game/ChangeAmmoMessageTest.scala
@@ -11,7 +11,7 @@ class ChangeAmmoMessageTest extends Specification {
val string = hex"47 4E00 00000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ChangeAmmoMessage(item_guid, unk1) =>
item_guid mustEqual PlanetSideGUID(78)
unk1 mustEqual 0
@@ -22,7 +22,7 @@ class ChangeAmmoMessageTest extends Specification {
"encode" in {
val msg = ChangeAmmoMessage(PlanetSideGUID(78), 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ChangeFireModeMessageTest.scala b/src/test/scala/game/ChangeFireModeMessageTest.scala
index 3e6ad42ca..869135687 100644
--- a/src/test/scala/game/ChangeFireModeMessageTest.scala
+++ b/src/test/scala/game/ChangeFireModeMessageTest.scala
@@ -11,7 +11,7 @@ class ChangeFireModeMessageTest extends Specification {
val string = hex"46 4C0020"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ChangeFireModeMessage(item_guid, fire_mode) =>
item_guid mustEqual PlanetSideGUID(76)
fire_mode mustEqual 1
@@ -22,7 +22,7 @@ class ChangeFireModeMessageTest extends Specification {
"encode" in {
val msg = ChangeFireModeMessage(PlanetSideGUID(76), 1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ChangeFireStateMessage_StartTest.scala b/src/test/scala/game/ChangeFireStateMessage_StartTest.scala
index 7e48724ad..e8313c859 100644
--- a/src/test/scala/game/ChangeFireStateMessage_StartTest.scala
+++ b/src/test/scala/game/ChangeFireStateMessage_StartTest.scala
@@ -11,7 +11,7 @@ class ChangeFireStateMessage_StartTest extends Specification {
val string = hex"39 4C00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ChangeFireStateMessage_Start(item_guid) =>
item_guid mustEqual PlanetSideGUID(76)
case _ =>
@@ -21,7 +21,7 @@ class ChangeFireStateMessage_StartTest extends Specification {
"encode" in {
val msg = ChangeFireStateMessage_Start(PlanetSideGUID(76))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ChangeFireStateMessage_StopTest.scala b/src/test/scala/game/ChangeFireStateMessage_StopTest.scala
index 608556785..2a5376561 100644
--- a/src/test/scala/game/ChangeFireStateMessage_StopTest.scala
+++ b/src/test/scala/game/ChangeFireStateMessage_StopTest.scala
@@ -11,7 +11,7 @@ class ChangeFireStateMessage_StopTest extends Specification {
val string = hex"3A 4C00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ChangeFireStateMessage_Stop(item_guid) =>
item_guid mustEqual PlanetSideGUID(76)
case _ =>
@@ -21,7 +21,7 @@ class ChangeFireStateMessage_StopTest extends Specification {
"encode" in {
val msg = ChangeFireStateMessage_Stop(PlanetSideGUID(76))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ChangeShortcutBankMessageTest.scala b/src/test/scala/game/ChangeShortcutBankMessageTest.scala
index 1cd4fbed4..56b51d0cb 100644
--- a/src/test/scala/game/ChangeShortcutBankMessageTest.scala
+++ b/src/test/scala/game/ChangeShortcutBankMessageTest.scala
@@ -11,7 +11,7 @@ class ChangeShortcutBankMessageTest extends Specification {
val string = hex"29 4B00 20"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ChangeShortcutBankMessage(player_guid, bank) =>
player_guid mustEqual PlanetSideGUID(75)
bank mustEqual 2
@@ -22,7 +22,7 @@ class ChangeShortcutBankMessageTest extends Specification {
"encode" in {
val msg = ChangeShortcutBankMessage(PlanetSideGUID(75), 2)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/CharacterCreateRequestMessageTest.scala b/src/test/scala/game/CharacterCreateRequestMessageTest.scala
index 266d17555..a0134a8fa 100644
--- a/src/test/scala/game/CharacterCreateRequestMessageTest.scala
+++ b/src/test/scala/game/CharacterCreateRequestMessageTest.scala
@@ -11,7 +11,7 @@ class CharacterCreateRequestMessageTest extends Specification {
val string = hex"2f 88 54006500730074004300680061007200 320590"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case CharacterCreateRequestMessage(name, head, voice, gender, faction) =>
name mustEqual "TestChar"
head mustEqual 50
@@ -26,7 +26,7 @@ class CharacterCreateRequestMessageTest extends Specification {
"encode" in {
val msg =
CharacterCreateRequestMessage("TestChar", 50, CharacterVoice.Voice5, CharacterGender.Female, PlanetSideEmpire.NC)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/CharacterInfoMessageTest.scala b/src/test/scala/game/CharacterInfoMessageTest.scala
index 44a8a7a4e..66be332bc 100644
--- a/src/test/scala/game/CharacterInfoMessageTest.scala
+++ b/src/test/scala/game/CharacterInfoMessageTest.scala
@@ -11,7 +11,7 @@ class CharacterInfoMessageTest extends Specification {
val string = hex"14 0F000000 10270000C1D87A024B00265CB08000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case CharacterInfoMessage(unk, zone, charId, guid, finished, last) =>
unk mustEqual 15L
zone mustEqual PlanetSideZoneID(10000)
@@ -26,7 +26,7 @@ class CharacterInfoMessageTest extends Specification {
"encode" in {
val msg = CharacterInfoMessage(15L, PlanetSideZoneID(10000), 41605313L, PlanetSideGUID(75), false, 6404428L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/CharacterKnowledgeMessageTest.scala b/src/test/scala/game/CharacterKnowledgeMessageTest.scala
index b5be8db06..7675446bb 100644
--- a/src/test/scala/game/CharacterKnowledgeMessageTest.scala
+++ b/src/test/scala/game/CharacterKnowledgeMessageTest.scala
@@ -12,7 +12,7 @@ class CharacterKnowledgeMessageTest extends Specification {
val string = hex"ec cc637a02 45804600720061006e006b0065006e00740061006e006b0003c022dc0008f01800"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case CharacterKnowledgeMessage(char_id, Some(info)) =>
char_id mustEqual 41575372L
info mustEqual CharacterKnowledgeInfo(
@@ -64,7 +64,7 @@ class CharacterKnowledgeMessageTest extends Specification {
PlanetSideGUID(12)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/CharacterNoRecordMessageTest.scala b/src/test/scala/game/CharacterNoRecordMessageTest.scala
index 9a8244b0b..528aee729 100644
--- a/src/test/scala/game/CharacterNoRecordMessageTest.scala
+++ b/src/test/scala/game/CharacterNoRecordMessageTest.scala
@@ -10,7 +10,7 @@ class CharacterNoRecordMessageTest extends Specification {
val string = hex"13 00400000" //we have no record of this packet, so here's something fake that works
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case CharacterNoRecordMessage(unk) =>
unk mustEqual 16384
case _ =>
@@ -20,7 +20,7 @@ class CharacterNoRecordMessageTest extends Specification {
"encode" in {
val msg = CharacterNoRecordMessage(16384)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/CharacterRequestMessageTest.scala b/src/test/scala/game/CharacterRequestMessageTest.scala
index c6ba3fbd5..d71ab0d9d 100644
--- a/src/test/scala/game/CharacterRequestMessageTest.scala
+++ b/src/test/scala/game/CharacterRequestMessageTest.scala
@@ -10,7 +10,7 @@ class CharacterRequestMessageTest extends Specification {
val string = hex"30 c1d87a02 00000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case CharacterRequestMessage(charId, action) =>
charId mustEqual 41605313L
action mustEqual CharacterRequestAction.Select
@@ -21,7 +21,7 @@ class CharacterRequestMessageTest extends Specification {
"encode" in {
val msg = CharacterRequestMessage(41605313L, CharacterRequestAction.Select)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ChatMsgTest.scala b/src/test/scala/game/ChatMsgTest.scala
index ffe4c034d..27e835b28 100644
--- a/src/test/scala/game/ChatMsgTest.scala
+++ b/src/test/scala/game/ChatMsgTest.scala
@@ -12,7 +12,7 @@ class ChatMsgTest extends Specification {
val string_tell = hex"12 20 C180640065006600 83610062006300"
"decode" in {
- PacketCoding.DecodePacket(string_local).require match {
+ PacketCoding.decodePacket(string_local).require match {
case ChatMsg(messagetype, has_wide_contents, recipient, contents, note_contents) =>
messagetype mustEqual ChatMessageType.CMT_OPEN
has_wide_contents mustEqual true
@@ -23,7 +23,7 @@ class ChatMsgTest extends Specification {
ko
}
- PacketCoding.DecodePacket(string_tell).require match {
+ PacketCoding.decodePacket(string_tell).require match {
case ChatMsg(messagetype, has_wide_contents, recipient, contents, note_contents) =>
messagetype mustEqual ChatMessageType.CMT_TELL
has_wide_contents mustEqual true
@@ -37,12 +37,12 @@ class ChatMsgTest extends Specification {
"encode" in {
val msg_local = ChatMsg(ChatMessageType.CMT_OPEN, true, "", "abc", None)
- val pkt_local = PacketCoding.EncodePacket(msg_local).require.toByteVector
+ val pkt_local = PacketCoding.encodePacket(msg_local).require.toByteVector
pkt_local mustEqual string_local
val msg_tell = ChatMsg(ChatMessageType.CMT_TELL, true, "def", "abc", None)
- val pkt_tell = PacketCoding.EncodePacket(msg_tell).require.toByteVector
+ val pkt_tell = PacketCoding.encodePacket(msg_tell).require.toByteVector
pkt_tell mustEqual string_tell
}
diff --git a/src/test/scala/game/ChildObjectStateMessageTest.scala b/src/test/scala/game/ChildObjectStateMessageTest.scala
index ccd930134..c1f4bdc3d 100644
--- a/src/test/scala/game/ChildObjectStateMessageTest.scala
+++ b/src/test/scala/game/ChildObjectStateMessageTest.scala
@@ -11,7 +11,7 @@ class ChildObjectStateMessageTest extends Specification {
val string = hex"1E 640B 06 47"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ChildObjectStateMessage(object_guid, pitch, yaw) =>
object_guid mustEqual PlanetSideGUID(2916)
pitch mustEqual 343.125f
@@ -23,7 +23,7 @@ class ChildObjectStateMessageTest extends Specification {
"encode" in {
val msg = ChildObjectStateMessage(PlanetSideGUID(2916), 343.125f, 160.3125f)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ConnectToWorldMessageTest.scala b/src/test/scala/game/ConnectToWorldMessageTest.scala
index 3d0797cab..449dc3606 100644
--- a/src/test/scala/game/ConnectToWorldMessageTest.scala
+++ b/src/test/scala/game/ConnectToWorldMessageTest.scala
@@ -10,7 +10,7 @@ class ConnectToWorldMessageTest extends Specification {
val string = hex"04 8667656D696E69 8C36342E33372E3135382E36393C75"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ConnectToWorldMessage(serverName, serverIp, serverPort) =>
serverName mustEqual "gemini"
serverIp mustEqual "64.37.158.69"
@@ -22,7 +22,7 @@ class ConnectToWorldMessageTest extends Specification {
"encode" in {
val msg = ConnectToWorldMessage("gemini", "64.37.158.69", 30012)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/ConnectToWorldRequestMessageTest.scala b/src/test/scala/game/ConnectToWorldRequestMessageTest.scala
index 0f729b172..770bb3aca 100644
--- a/src/test/scala/game/ConnectToWorldRequestMessageTest.scala
+++ b/src/test/scala/game/ConnectToWorldRequestMessageTest.scala
@@ -11,7 +11,7 @@ class ConnectToWorldRequestMessageTest extends Specification {
hex"03 8667656D696E69 0000000000000000 00000000 00000000 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 "
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ConnectToWorldRequestMessage(serverName, token, majorVersion, minorVersion, revision, buildDate, unk) =>
serverName mustEqual "gemini"
token mustEqual ""
@@ -27,7 +27,7 @@ class ConnectToWorldRequestMessageTest extends Specification {
"encode" in {
val msg = ConnectToWorldRequestMessage("gemini", "", 0, 0, 0, "", 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ContinentalLockUpdateMessageTest.scala b/src/test/scala/game/ContinentalLockUpdateMessageTest.scala
index 4db015235..5adae694f 100644
--- a/src/test/scala/game/ContinentalLockUpdateMessageTest.scala
+++ b/src/test/scala/game/ContinentalLockUpdateMessageTest.scala
@@ -11,7 +11,7 @@ class ContinentalLockUpdateMessageTest extends Specification {
val string = hex"A8 16 00 40"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ContinentalLockUpdateMessage(continent_guid, empire) =>
continent_guid mustEqual 22
empire mustEqual PlanetSideEmpire.NC
@@ -22,7 +22,7 @@ class ContinentalLockUpdateMessageTest extends Specification {
"encode" in {
val msg = ContinentalLockUpdateMessage(22, PlanetSideEmpire.NC)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/CreateShortcutMessageTest.scala b/src/test/scala/game/CreateShortcutMessageTest.scala
index 0f1f94740..5a8ad92d7 100644
--- a/src/test/scala/game/CreateShortcutMessageTest.scala
+++ b/src/test/scala/game/CreateShortcutMessageTest.scala
@@ -14,7 +14,7 @@ class CreateShortcutMessageTest extends Specification {
val stringRemove = hex"28 4C05 01 00 00"
"decode (medkit)" in {
- PacketCoding.DecodePacket(stringMedkit).require match {
+ PacketCoding.decodePacket(stringMedkit).require match {
case CreateShortcutMessage(player_guid, slot, unk, addShortcut, shortcut) =>
player_guid mustEqual PlanetSideGUID(4210)
slot mustEqual 1
@@ -31,7 +31,7 @@ class CreateShortcutMessageTest extends Specification {
}
"decode (macro)" in {
- PacketCoding.DecodePacket(stringMacro).require match {
+ PacketCoding.decodePacket(stringMacro).require match {
case CreateShortcutMessage(player_guid, slot, unk, addShortcut, shortcut) =>
player_guid mustEqual PlanetSideGUID(1356)
slot mustEqual 8
@@ -48,7 +48,7 @@ class CreateShortcutMessageTest extends Specification {
}
"decode (remove)" in {
- PacketCoding.DecodePacket(stringRemove).require match {
+ PacketCoding.decodePacket(stringRemove).require match {
case CreateShortcutMessage(player_guid, slot, unk, addShortcut, shortcut) =>
player_guid mustEqual PlanetSideGUID(1356)
slot mustEqual 1
@@ -62,7 +62,7 @@ class CreateShortcutMessageTest extends Specification {
"encode (medkit)" in {
val msg = CreateShortcutMessage(PlanetSideGUID(4210), 1, 0, true, Some(Shortcut(0, "medkit")))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringMedkit
}
@@ -75,14 +75,14 @@ class CreateShortcutMessageTest extends Specification {
true,
Some(Shortcut(1, "shortcut_macro", "NTU", "/platoon Incoming NTU spam!"))
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringMacro
}
"encode (remove)" in {
val msg = CreateShortcutMessage(PlanetSideGUID(1356), 1, 0, false)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringRemove
}
diff --git a/src/test/scala/game/DamageFeedbackMessageTest.scala b/src/test/scala/game/DamageFeedbackMessageTest.scala
index f1ec2bbc8..c8eb4dae4 100644
--- a/src/test/scala/game/DamageFeedbackMessageTest.scala
+++ b/src/test/scala/game/DamageFeedbackMessageTest.scala
@@ -12,7 +12,7 @@ class DamageFeedbackMessageTest extends Specification {
val string_2 = hex"7B 5E5826D8001DC0400000"
"decode (string 1)" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DamageFeedbackMessage(unk1, unk2, unk2a, unk2b, unk2c, unk3, unk3a, unk3b, unk3c, unk3d, unk4, unk5, unk6) =>
unk1 mustEqual 3
unk2 mustEqual true
@@ -33,7 +33,7 @@ class DamageFeedbackMessageTest extends Specification {
}
"decode (string 2)" in {
- PacketCoding.DecodePacket(string_2).require match {
+ PacketCoding.decodePacket(string_2).require match {
case DamageFeedbackMessage(unk1, unk2, unk2a, unk2b, unk2c, unk3, unk3a, unk3b, unk3c, unk3d, unk4, unk5, unk6) =>
unk1 mustEqual 5
unk2 mustEqual true
@@ -69,7 +69,7 @@ class DamageFeedbackMessageTest extends Specification {
2,
0
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -90,7 +90,7 @@ class DamageFeedbackMessageTest extends Specification {
750,
0
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_2
}
diff --git a/src/test/scala/game/DamageMessageTest.scala b/src/test/scala/game/DamageMessageTest.scala
index ed8dcf3c5..991e8874d 100644
--- a/src/test/scala/game/DamageMessageTest.scala
+++ b/src/test/scala/game/DamageMessageTest.scala
@@ -11,7 +11,7 @@ class DamageMessageTest extends Specification {
val string = hex"0b610b02610b00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DamageMessage(guid1, unk1, guid2, unk2) =>
guid1 mustEqual PlanetSideGUID(2913)
unk1 mustEqual 2
@@ -24,7 +24,7 @@ class DamageMessageTest extends Specification {
"encode" in {
val msg = DamageMessage(PlanetSideGUID(2913), 2, PlanetSideGUID(2913), false)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DamageWithPositionMessageTest.scala b/src/test/scala/game/DamageWithPositionMessageTest.scala
index 807ca6296..1c7e9eafd 100644
--- a/src/test/scala/game/DamageWithPositionMessageTest.scala
+++ b/src/test/scala/game/DamageWithPositionMessageTest.scala
@@ -11,7 +11,7 @@ class DamageWithPositionMessageTest extends Specification {
val string = hex"A6 11 6C2D7 65535 CA16"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DamageWithPositionMessage(unk, pos) =>
unk mustEqual 17
pos.x mustEqual 3674.8438f
@@ -24,7 +24,7 @@ class DamageWithPositionMessageTest extends Specification {
"encode" in {
val msg = DamageWithPositionMessage(17, Vector3(3674.8438f, 2726.789f, 91.15625f))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DataChallengeMessageRespTest.scala b/src/test/scala/game/DataChallengeMessageRespTest.scala
index 51e002dfd..2c6df191a 100644
--- a/src/test/scala/game/DataChallengeMessageRespTest.scala
+++ b/src/test/scala/game/DataChallengeMessageRespTest.scala
@@ -10,7 +10,7 @@ class DataChallengeMessageRespTest extends Specification {
val string = hex"948673616d706c6501000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DataChallengeMessageResp(attribute, value) =>
attribute mustEqual "sample"
value mustEqual 1L
@@ -21,7 +21,7 @@ class DataChallengeMessageRespTest extends Specification {
"encode" in {
val msg = DataChallengeMessageResp("sample", 1L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DataChallengeMessageTest.scala b/src/test/scala/game/DataChallengeMessageTest.scala
index 16fb41d41..d36bf813b 100644
--- a/src/test/scala/game/DataChallengeMessageTest.scala
+++ b/src/test/scala/game/DataChallengeMessageTest.scala
@@ -10,7 +10,7 @@ class DataChallengeMessageTest extends Specification {
val string = hex"938673616d706c6501000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DataChallengeMessage(attribute, value) =>
attribute mustEqual "sample"
value mustEqual 1L
@@ -21,7 +21,7 @@ class DataChallengeMessageTest extends Specification {
"encode" in {
val msg = DataChallengeMessage("sample", 1L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DelayedPathMountMsgTest.scala b/src/test/scala/game/DelayedPathMountMsgTest.scala
index 429be8ed9..f5179be0e 100644
--- a/src/test/scala/game/DelayedPathMountMsgTest.scala
+++ b/src/test/scala/game/DelayedPathMountMsgTest.scala
@@ -11,7 +11,7 @@ class DelayedPathMountMsgTest extends Specification {
val string = hex"5a f50583044680"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DelayedPathMountMsg(player_guid, vehicle_guid, u3, u4) =>
player_guid mustEqual PlanetSideGUID(1525)
vehicle_guid mustEqual PlanetSideGUID(1155)
@@ -24,7 +24,7 @@ class DelayedPathMountMsgTest extends Specification {
"encode" in {
val msg = DelayedPathMountMsg(PlanetSideGUID(1525), PlanetSideGUID(1155), 70, true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DensityLevelUpdateMessageTest.scala b/src/test/scala/game/DensityLevelUpdateMessageTest.scala
index cb5c3e668..06d7f3bd0 100644
--- a/src/test/scala/game/DensityLevelUpdateMessageTest.scala
+++ b/src/test/scala/game/DensityLevelUpdateMessageTest.scala
@@ -10,7 +10,7 @@ class DensityLevelUpdateMessageTest extends Specification {
val string = hex"cd 0100 1f4e 000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DensityLevelUpdateMessage(zone_id, building_id, unk) =>
zone_id mustEqual 1
building_id mustEqual 19999
@@ -30,23 +30,23 @@ class DensityLevelUpdateMessageTest extends Specification {
"encode" in {
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, 0, 0, 0))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (failure; wrong number of list entries)" in {
val msg = DensityLevelUpdateMessage(1, 19999, List(0))
- PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
+ PacketCoding.encodePacket(msg).isSuccessful mustEqual false
}
"encode (failure; list number too big)" in {
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, 0, 0, 8))
- PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
+ PacketCoding.encodePacket(msg).isSuccessful mustEqual false
}
"encode (failure; list number too small)" in {
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, -1, 0, 0))
- PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
+ PacketCoding.encodePacket(msg).isSuccessful mustEqual false
}
}
diff --git a/src/test/scala/game/DeployObjectMessageTest.scala b/src/test/scala/game/DeployObjectMessageTest.scala
index c9ac48c1f..7057fe3c1 100644
--- a/src/test/scala/game/DeployObjectMessageTest.scala
+++ b/src/test/scala/game/DeployObjectMessageTest.scala
@@ -11,7 +11,7 @@ class DeployObjectMessageTest extends Specification {
val string = hex"5d 740b e8030000 a644b 6e3c6 7e18 00 00 3f 01000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DeployObjectMessage(guid, unk1, pos, orient, unk2) =>
guid mustEqual PlanetSideGUID(2932)
unk1 mustEqual 1000L
@@ -31,7 +31,7 @@ class DeployObjectMessageTest extends Specification {
Vector3.z(272.8125f),
1L
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DeployRequestMessageTest.scala b/src/test/scala/game/DeployRequestMessageTest.scala
index 8e8a44b60..bdfa04b51 100644
--- a/src/test/scala/game/DeployRequestMessageTest.scala
+++ b/src/test/scala/game/DeployRequestMessageTest.scala
@@ -11,7 +11,7 @@ class DeployRequestMessageTest extends Specification {
val string = hex"4b 4b00 7c01 40 0cf73b52aa6a9300"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DeployRequestMessage(player_guid, vehicle_guid, deploy_state, unk2, unk3, pos) =>
player_guid mustEqual PlanetSideGUID(75)
vehicle_guid mustEqual PlanetSideGUID(380)
@@ -35,7 +35,7 @@ class DeployRequestMessageTest extends Specification {
false,
Vector3(4060.1953f, 2218.8281f, 155.32812f)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DeployableObjectsInfoMessageTest.scala b/src/test/scala/game/DeployableObjectsInfoMessageTest.scala
index c9ad04e1c..fc4aef236 100644
--- a/src/test/scala/game/DeployableObjectsInfoMessageTest.scala
+++ b/src/test/scala/game/DeployableObjectsInfoMessageTest.scala
@@ -11,7 +11,7 @@ class DeployableObjectsInfoMessageTest extends Specification {
val string = hex"76 00 80 00 00 31 85 41 CF D3 7E B3 34 00 E6 30 48" //this was a TRAP @ Ogma, Forseral
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DeployableObjectsInfoMessage(action, list) =>
action mustEqual DeploymentAction.Dismiss
list.size mustEqual 1
@@ -37,7 +37,7 @@ class DeployableObjectsInfoMessageTest extends Specification {
PlanetSideGUID(2502)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DestroyDisplayMessageTest.scala b/src/test/scala/game/DestroyDisplayMessageTest.scala
index c283f4d82..2869ffc69 100644
--- a/src/test/scala/game/DestroyDisplayMessageTest.scala
+++ b/src/test/scala/game/DestroyDisplayMessageTest.scala
@@ -12,7 +12,7 @@ class DestroyDisplayMessageTest extends Specification {
hex"81 87 41006E00670065006C006C006F00 35BCD801 8 F201 9207 0A 0 48004D00460049004300 B18ED901 00" // Angello-VS (???) HMFIC-TR
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DestroyDisplayMessage(
killer,
killer_charId,
@@ -53,7 +53,7 @@ class DestroyDisplayMessageTest extends Specification {
PlanetSideEmpire.TR,
false
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/DestroyMessageTest.scala b/src/test/scala/game/DestroyMessageTest.scala
index 6fcd185d7..755f417a3 100644
--- a/src/test/scala/game/DestroyMessageTest.scala
+++ b/src/test/scala/game/DestroyMessageTest.scala
@@ -12,7 +12,7 @@ class DestroyMessageTest extends Specification {
"DestroyMessage" should {
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DestroyMessage(unk1, unk2, unk3, pos) =>
unk1 mustEqual PlanetSideGUID(2420)
unk2 mustEqual PlanetSideGUID(2420)
@@ -30,7 +30,7 @@ class DestroyMessageTest extends Specification {
PlanetSideGUID(0),
Vector3(1642.0469f, 4091.6172f, 32.59375f)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DisconnectMessageTest.scala b/src/test/scala/game/DisconnectMessageTest.scala
index 6e4f4c3a7..a51ffcc22 100644
--- a/src/test/scala/game/DisconnectMessageTest.scala
+++ b/src/test/scala/game/DisconnectMessageTest.scala
@@ -10,7 +10,7 @@ class DisconnectMessageTest extends Specification {
val string = hex"B7 85 46 69 72 73 74 86 53 65 63 6F 6E 64 8E 46 69 72 73 74 20 26 20 73 65 63 6F 6E 64"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DisconnectMessage(unk1, unk2, unk3) =>
unk1 mustEqual "First"
unk2 mustEqual "Second"
@@ -22,7 +22,7 @@ class DisconnectMessageTest extends Specification {
"encode" in {
val msg = DisconnectMessage("First", "Second", "First & second")
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DismountBuildingMsgTest.scala b/src/test/scala/game/DismountBuildingMsgTest.scala
index 44932732a..edd1ba4a5 100644
--- a/src/test/scala/game/DismountBuildingMsgTest.scala
+++ b/src/test/scala/game/DismountBuildingMsgTest.scala
@@ -11,7 +11,7 @@ class DismountBuildingMsgTest extends Specification {
val string = hex"7C 4B00 2E00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DismountBuildingMsg(player_guid, building_guid) =>
player_guid mustEqual PlanetSideGUID(75)
building_guid mustEqual PlanetSideGUID(46)
@@ -22,7 +22,7 @@ class DismountBuildingMsgTest extends Specification {
"encode" in {
val msg = DismountBuildingMsg(PlanetSideGUID(75), PlanetSideGUID(46))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DismountVehicleMsgTest.scala b/src/test/scala/game/DismountVehicleMsgTest.scala
index 74b8e2861..7c55d3d40 100644
--- a/src/test/scala/game/DismountVehicleMsgTest.scala
+++ b/src/test/scala/game/DismountVehicleMsgTest.scala
@@ -11,7 +11,7 @@ class DismountVehicleMsgTest extends Specification {
val string = hex"0F C609 00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DismountVehicleMsg(player_guid, bailType, wasKickedByDriver) =>
player_guid mustEqual PlanetSideGUID(2502)
bailType mustEqual BailType.Normal
@@ -23,7 +23,7 @@ class DismountVehicleMsgTest extends Specification {
"encode" in {
val msg = DismountVehicleMsg(PlanetSideGUID(2502), BailType.Normal, false)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DisplayedAwardMessageTest.scala b/src/test/scala/game/DisplayedAwardMessageTest.scala
index 3b848fad8..2bb05d768 100644
--- a/src/test/scala/game/DisplayedAwardMessageTest.scala
+++ b/src/test/scala/game/DisplayedAwardMessageTest.scala
@@ -11,7 +11,7 @@ class DisplayedAwardMessageTest extends Specification {
val string = hex"D1 9F06 A6010000 3 0"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DisplayedAwardMessage(player_guid, ribbon, bar) =>
player_guid mustEqual PlanetSideGUID(1695)
ribbon mustEqual MeritCommendation.TwoYearVS
@@ -23,7 +23,7 @@ class DisplayedAwardMessageTest extends Specification {
"encode" in {
val msg = DisplayedAwardMessage(PlanetSideGUID(1695), MeritCommendation.TwoYearVS, RibbonBarsSlot.TermOfService)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DropItemMessageTest.scala b/src/test/scala/game/DropItemMessageTest.scala
index 05fd0cf4c..9b95477bd 100644
--- a/src/test/scala/game/DropItemMessageTest.scala
+++ b/src/test/scala/game/DropItemMessageTest.scala
@@ -11,7 +11,7 @@ class DropItemMessageTest extends Specification {
val string = hex"37 4C00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DropItemMessage(item_guid) =>
item_guid mustEqual PlanetSideGUID(76)
case _ =>
@@ -21,7 +21,7 @@ class DropItemMessageTest extends Specification {
"encode" in {
val msg = DropItemMessage(PlanetSideGUID(76))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/DroppodFreefallingMessageTest.scala b/src/test/scala/game/DroppodFreefallingMessageTest.scala
index 17046f16e..36b1aa93f 100644
--- a/src/test/scala/game/DroppodFreefallingMessageTest.scala
+++ b/src/test/scala/game/DroppodFreefallingMessageTest.scala
@@ -13,7 +13,7 @@ class DroppodFreefallingMessageTest extends Specification {
"DroppodFreefallingMessage" should {
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case DroppodFreefallingMessage(guid, pos, vel, pos2, orientation1, orientation2) =>
guid mustEqual PlanetSideGUID(3618)
pos mustEqual Vector3(5724, 3612, 1085)
@@ -35,7 +35,7 @@ class DroppodFreefallingMessageTest extends Specification {
Vector3(0, 70.3125f, 272.8125f),
Vector3(0, 0, 272.8125f)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/EmoteMsgTest.scala b/src/test/scala/game/EmoteMsgTest.scala
index a9f69485a..d44aba21b 100644
--- a/src/test/scala/game/EmoteMsgTest.scala
+++ b/src/test/scala/game/EmoteMsgTest.scala
@@ -11,7 +11,7 @@ class EmoteMsgTest extends Specification {
val string = hex"25 4B00 15"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case EmoteMsg(avatar_guid, emote) =>
avatar_guid mustEqual PlanetSideGUID(75)
emote mustEqual EmoteType.Thumbsdown
@@ -22,7 +22,7 @@ class EmoteMsgTest extends Specification {
"encode" in {
val msg = EmoteMsg(PlanetSideGUID(75), EmoteType.Thumbsdown)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ExperienceAddedMessageTest.scala b/src/test/scala/game/ExperienceAddedMessageTest.scala
index c9e2d71d1..b4b4a2439 100644
--- a/src/test/scala/game/ExperienceAddedMessageTest.scala
+++ b/src/test/scala/game/ExperienceAddedMessageTest.scala
@@ -10,7 +10,7 @@ class ExperienceAddedMessageTest extends Specification {
val string = hex"B8 04 03"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ExperienceAddedMessage(exp, unk) =>
exp mustEqual 260 //0x104
unk mustEqual true
@@ -21,7 +21,7 @@ class ExperienceAddedMessageTest extends Specification {
"encode" in {
val msg = ExperienceAddedMessage(260)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/FacilityBenefitShieldChargeRequestMessageTest.scala b/src/test/scala/game/FacilityBenefitShieldChargeRequestMessageTest.scala
index 7230c2ccd..ec70708ea 100644
--- a/src/test/scala/game/FacilityBenefitShieldChargeRequestMessageTest.scala
+++ b/src/test/scala/game/FacilityBenefitShieldChargeRequestMessageTest.scala
@@ -11,7 +11,7 @@ class FacilityBenefitShieldChargeRequestMessageTest extends Specification {
val string = hex"C2 4C00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case FacilityBenefitShieldChargeRequestMessage(guid) =>
guid mustEqual PlanetSideGUID(76)
case _ =>
@@ -21,7 +21,7 @@ class FacilityBenefitShieldChargeRequestMessageTest extends Specification {
"encode" in {
val msg = FacilityBenefitShieldChargeRequestMessage(PlanetSideGUID(76))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/FavoritesMessageTest.scala b/src/test/scala/game/FavoritesMessageTest.scala
index 8971408c3..1780f47b0 100644
--- a/src/test/scala/game/FavoritesMessageTest.scala
+++ b/src/test/scala/game/FavoritesMessageTest.scala
@@ -12,7 +12,7 @@ class FavoritesMessageTest extends Specification {
val stringInfantry = hex"60 2C 03 82 34 4100 6700 6900 6C00 6500 2000 2800 6200 6100 7300 6900 6300 2900 20"
"decode (for infantry)" in {
- PacketCoding.DecodePacket(stringInfantry).require match {
+ PacketCoding.decodePacket(stringInfantry).require match {
case FavoritesMessage(list, player_guid, line, label, armor) =>
list mustEqual LoadoutType.Infantry
player_guid mustEqual PlanetSideGUID(3760)
@@ -27,13 +27,13 @@ class FavoritesMessageTest extends Specification {
"encode (for infantry)" in {
val msg = FavoritesMessage(LoadoutType.Infantry, PlanetSideGUID(3760), 0, "Agile (basic)", 1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringInfantry
}
"decode (for vehicles)" in {
- PacketCoding.DecodePacket(stringVehicles).require match {
+ PacketCoding.decodePacket(stringVehicles).require match {
case FavoritesMessage(list, player_guid, line, label, armor) =>
list mustEqual LoadoutType.Vehicle
player_guid mustEqual PlanetSideGUID(4210)
@@ -47,7 +47,7 @@ class FavoritesMessageTest extends Specification {
"encode (for vehicles)" in {
val msg = FavoritesMessage(LoadoutType.Vehicle, PlanetSideGUID(4210), 0, "Skyguard")
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringVehicles
}
diff --git a/src/test/scala/game/FavoritesRequestTest.scala b/src/test/scala/game/FavoritesRequestTest.scala
index 2f50715ec..dad4c94eb 100644
--- a/src/test/scala/game/FavoritesRequestTest.scala
+++ b/src/test/scala/game/FavoritesRequestTest.scala
@@ -11,7 +11,7 @@ class FavoritesRequestTest extends Specification {
val stringInfantry = hex"5E 4B00 1187 4500 7800 6100 6D00 7000 6C00 6500"
"decode (for infantry)" in {
- PacketCoding.DecodePacket(stringInfantry).require match {
+ PacketCoding.decodePacket(stringInfantry).require match {
case FavoritesRequest(player_guid, list, action, line, label) =>
player_guid mustEqual PlanetSideGUID(75)
list mustEqual LoadoutType.Infantry
@@ -26,7 +26,7 @@ class FavoritesRequestTest extends Specification {
"encode (for infantry)" in {
val msg = FavoritesRequest(PlanetSideGUID(75), LoadoutType.Infantry, FavoritesAction.Save, 1, Some("Example"))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringInfantry
}
diff --git a/src/test/scala/game/FireHintMessageTest.scala b/src/test/scala/game/FireHintMessageTest.scala
index 5d16b371e..4eeb1c8bd 100644
--- a/src/test/scala/game/FireHintMessageTest.scala
+++ b/src/test/scala/game/FireHintMessageTest.scala
@@ -12,7 +12,7 @@ class FireHintMessageTest extends Specification {
val string2 = hex"a1 080e 65af5705074411 0000cffee0fc7b08899f5580"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case FireHintMessage(weapon_guid, pos, u1, u2, u3, u4, u5) =>
weapon_guid mustEqual PlanetSideGUID(5889)
pos mustEqual Vector3(3482.2734f, 3642.4922f, 53.125f)
@@ -26,7 +26,7 @@ class FireHintMessageTest extends Specification {
}
}
"decode string2" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case FireHintMessage(weapon_guid, pos, u1, u2, u3, u4, u5) =>
weapon_guid mustEqual PlanetSideGUID(3592)
pos mustEqual Vector3(2910.789f, 3744.875f, 69.0625f)
@@ -42,7 +42,7 @@ class FireHintMessageTest extends Specification {
"encode" in {
val msg = FireHintMessage(PlanetSideGUID(5889), Vector3(3482.2734f, 3642.4922f, 53.125f), 0, 65399, 7581, 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -56,7 +56,7 @@ class FireHintMessageTest extends Specification {
3,
Some(Vector3(21.5f, -6.8125f, 2.65625f))
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string2
}
diff --git a/src/test/scala/game/FriendsRequestTest.scala b/src/test/scala/game/FriendsRequestTest.scala
index 14499e434..3c058e427 100644
--- a/src/test/scala/game/FriendsRequestTest.scala
+++ b/src/test/scala/game/FriendsRequestTest.scala
@@ -10,7 +10,7 @@ class FriendsRequestTest extends Specification {
val string = hex"72 3 0A0 46004A0048004E004300"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case FriendsRequest(action, friend) =>
action mustEqual 1
friend.length mustEqual 5
@@ -22,7 +22,7 @@ class FriendsRequestTest extends Specification {
"encode" in {
val msg = FriendsRequest(1, "FJHNC")
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/FriendsResponseTest.scala b/src/test/scala/game/FriendsResponseTest.scala
index 09a0d2121..8e1858931 100644
--- a/src/test/scala/game/FriendsResponseTest.scala
+++ b/src/test/scala/game/FriendsResponseTest.scala
@@ -13,7 +13,7 @@ class FriendsResponseTest extends Specification {
val stringShort = hex"73 81 80"
"decode (one friend)" in {
- PacketCoding.DecodePacket(stringOneFriend).require match {
+ PacketCoding.decodePacket(stringOneFriend).require match {
case FriendsResponse(action, unk2, unk3, unk4, list) =>
action mustEqual FriendAction.UpdateFriend
unk2 mustEqual 0
@@ -28,7 +28,7 @@ class FriendsResponseTest extends Specification {
}
"decode (multiple friends)" in {
- PacketCoding.DecodePacket(stringManyFriends).require match {
+ PacketCoding.decodePacket(stringManyFriends).require match {
case FriendsResponse(action, unk2, unk3, unk4, list) =>
action mustEqual FriendAction.InitializeFriendList
unk2 mustEqual 0
@@ -51,7 +51,7 @@ class FriendsResponseTest extends Specification {
}
"decode (short)" in {
- PacketCoding.DecodePacket(stringShort).require match {
+ PacketCoding.decodePacket(stringShort).require match {
case FriendsResponse(action, unk2, unk3, unk4, list) =>
action mustEqual FriendAction.InitializeIgnoreList
unk2 mustEqual 0
@@ -72,7 +72,7 @@ class FriendsResponseTest extends Specification {
Friend("KurtHectic-G", false) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringOneFriend
}
@@ -90,14 +90,14 @@ class FriendsResponseTest extends Specification {
Friend("KurtHectic-G", false) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringManyFriends
}
"encode (short)" in {
val msg = FriendsResponse(FriendAction.InitializeIgnoreList, 0, true, true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringShort
}
diff --git a/src/test/scala/game/GenericActionMessageTest.scala b/src/test/scala/game/GenericActionMessageTest.scala
index 2ccff915d..658fe3e4e 100644
--- a/src/test/scala/game/GenericActionMessageTest.scala
+++ b/src/test/scala/game/GenericActionMessageTest.scala
@@ -10,7 +10,7 @@ class GenericActionMessageTest extends Specification {
val string = hex"A7 94"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case GenericActionMessage(action) =>
action mustEqual 37
case _ =>
@@ -20,7 +20,7 @@ class GenericActionMessageTest extends Specification {
"encode" in {
val msg = GenericActionMessage(37)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/GenericCollisionMsgTest.scala b/src/test/scala/game/GenericCollisionMsgTest.scala
index 6c020a464..dca780451 100644
--- a/src/test/scala/game/GenericCollisionMsgTest.scala
+++ b/src/test/scala/game/GenericCollisionMsgTest.scala
@@ -12,7 +12,7 @@ class GenericCollisionMsgTest extends Specification {
val string =
hex"3C 92C00000190000001B2A8010932CEF505C70946F00000000000000000000000017725EBC6D6A058000000000000000000000000000003F8FF45140"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case GenericCollisionMsg(unk1, p, t, php, thp, pv, tv, ppos, tpos, unk2, unk3, unk4) =>
unk1 mustEqual 2
p mustEqual PlanetSideGUID(75)
@@ -53,7 +53,7 @@ class GenericCollisionMsgTest extends Specification {
0L,
1171341310L
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/GenericObjectActionMessageTest.scala b/src/test/scala/game/GenericObjectActionMessageTest.scala
index cf9970f57..0c805caec 100644
--- a/src/test/scala/game/GenericObjectActionMessageTest.scala
+++ b/src/test/scala/game/GenericObjectActionMessageTest.scala
@@ -11,7 +11,7 @@ class GenericObjectActionMessageTest extends Specification {
val string = hex"56 B501 24"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case GenericObjectActionMessage(object_guid, action) =>
object_guid mustEqual PlanetSideGUID(437)
action mustEqual 9
@@ -22,7 +22,7 @@ class GenericObjectActionMessageTest extends Specification {
"encode" in {
val msg = GenericObjectActionMessage(PlanetSideGUID(437), 9)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/GenericObjectStateMsgTest.scala b/src/test/scala/game/GenericObjectStateMsgTest.scala
index 1ba55af86..62f480a05 100644
--- a/src/test/scala/game/GenericObjectStateMsgTest.scala
+++ b/src/test/scala/game/GenericObjectStateMsgTest.scala
@@ -11,7 +11,7 @@ class GenericObjectStateMsgTest extends Specification {
val string = hex"1D 6401 10000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case GenericObjectStateMsg(object_guid, state) =>
object_guid mustEqual PlanetSideGUID(356)
state mustEqual 16
@@ -22,7 +22,7 @@ class GenericObjectStateMsgTest extends Specification {
"encode" in {
val msg = GenericObjectStateMsg(PlanetSideGUID(356), 16)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/HackMessageTest.scala b/src/test/scala/game/HackMessageTest.scala
index e16863d7d..bd6bc9433 100644
--- a/src/test/scala/game/HackMessageTest.scala
+++ b/src/test/scala/game/HackMessageTest.scala
@@ -12,7 +12,7 @@ class HackMessageTest extends Specification {
val string = hex"54 000105c3800000202fc04200000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case HackMessage(unk1, target_guid, player_guid, progress, unk5, hack_state, unk7) =>
unk1 mustEqual 0
target_guid mustEqual PlanetSideGUID(1024)
@@ -28,7 +28,7 @@ class HackMessageTest extends Specification {
"encode" in {
val msg = HackMessage(0, PlanetSideGUID(1024), PlanetSideGUID(3607), 0, 3212836864L, HackState.Start, 8L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/HitHintTest.scala b/src/test/scala/game/HitHintTest.scala
index 4721588fe..a395630d3 100644
--- a/src/test/scala/game/HitHintTest.scala
+++ b/src/test/scala/game/HitHintTest.scala
@@ -11,7 +11,7 @@ class HitHintTest extends Specification {
val string = hex"0A 460B 0100"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case HitHint(source, player) =>
source mustEqual PlanetSideGUID(2886)
player mustEqual PlanetSideGUID(1)
@@ -22,7 +22,7 @@ class HitHintTest extends Specification {
"encode" in {
val msg = HitHint(PlanetSideGUID(2886), PlanetSideGUID(1))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/HitMessageTest.scala b/src/test/scala/game/HitMessageTest.scala
index bd9187f7f..f2145e2d5 100644
--- a/src/test/scala/game/HitMessageTest.scala
+++ b/src/test/scala/game/HitMessageTest.scala
@@ -12,7 +12,7 @@ class HitMessageTest extends Specification {
val string_hitobj = hex"09 99292705F4B1FB9514585F08BDD3D454CC5EE80300"
"decode (generic)" in {
- PacketCoding.DecodePacket(string_hitgeneric).require match {
+ PacketCoding.decodePacket(string_hitgeneric).require match {
case HitMessage(seq_time, projectile_guid, unk1, hit_info, unk2, unk3, unk4) =>
seq_time mustEqual 777
projectile_guid mustEqual PlanetSideGUID(40102)
@@ -27,7 +27,7 @@ class HitMessageTest extends Specification {
}
"decode (object)" in {
- PacketCoding.DecodePacket(string_hitobj).require match {
+ PacketCoding.decodePacket(string_hitobj).require match {
case HitMessage(seq_time, projectile_guid, unk1, hit_info, unk2, unk3, unk4) =>
seq_time mustEqual 153
projectile_guid mustEqual PlanetSideGUID(40100)
@@ -49,7 +49,7 @@ class HitMessageTest extends Specification {
"encode (generic)" in {
val msg_hitgeneric = HitMessage(777, PlanetSideGUID(40102), 0, None, true, false, None)
- val pkt_hitgeneric = PacketCoding.EncodePacket(msg_hitgeneric).require.toByteVector
+ val pkt_hitgeneric = PacketCoding.encodePacket(msg_hitgeneric).require.toByteVector
pkt_hitgeneric mustEqual string_hitgeneric
}
@@ -69,7 +69,7 @@ class HitMessageTest extends Specification {
false,
None
)
- val pkt_hitobj = PacketCoding.EncodePacket(msg_hitobj).require.toByteVector
+ val pkt_hitobj = PacketCoding.encodePacket(msg_hitobj).require.toByteVector
pkt_hitobj mustEqual string_hitobj
}
diff --git a/src/test/scala/game/HotSpotUpdateMessageTest.scala b/src/test/scala/game/HotSpotUpdateMessageTest.scala
index f07413fa3..b4564551b 100644
--- a/src/test/scala/game/HotSpotUpdateMessageTest.scala
+++ b/src/test/scala/game/HotSpotUpdateMessageTest.scala
@@ -13,7 +13,7 @@ class HotSpotUpdateMessageTest extends Specification {
val stringThree = hex"9F 0A00 4 030 00FC8 00F0A 80000 002E9 00BEA 80000 00FC8 00BEA 80000 0"
"decode (clear)" in {
- PacketCoding.DecodePacket(stringClear).require match {
+ PacketCoding.decodePacket(stringClear).require match {
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 5
unk mustEqual 1
@@ -24,7 +24,7 @@ class HotSpotUpdateMessageTest extends Specification {
}
"decode (one)" in {
- PacketCoding.DecodePacket(stringOne).require match {
+ PacketCoding.decodePacket(stringOne).require match {
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 5
unk mustEqual 1
@@ -36,7 +36,7 @@ class HotSpotUpdateMessageTest extends Specification {
}
"decode (two)" in {
- PacketCoding.DecodePacket(stringTwo).require match {
+ PacketCoding.decodePacket(stringTwo).require match {
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 5
unk mustEqual 5
@@ -49,7 +49,7 @@ class HotSpotUpdateMessageTest extends Specification {
}
"decode (three)" in {
- PacketCoding.DecodePacket(stringThree).require match {
+ PacketCoding.decodePacket(stringThree).require match {
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 10
unk mustEqual 4
@@ -64,20 +64,20 @@ class HotSpotUpdateMessageTest extends Specification {
"encode (clear)" in {
val msg = HotSpotUpdateMessage(5, 1, Nil)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringClear
}
"encode (one)" in {
val msg = HotSpotUpdateMessage(5, 1, List(HotSpotInfo(4700.0f, 2600.0f, 64.0f)))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringOne
}
"encode (two)" in {
val msg =
HotSpotUpdateMessage(5, 5, List(HotSpotInfo(4000.0f, 5400.0f, 64.0f), HotSpotInfo(5500.0f, 2200.0f, 64.0f)))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringTwo
}
@@ -91,7 +91,7 @@ class HotSpotUpdateMessageTest extends Specification {
HotSpotInfo(4600.0f, 5500.0f, 64.0f)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringThree
}
}
diff --git a/src/test/scala/game/InventoryStateMessageTest.scala b/src/test/scala/game/InventoryStateMessageTest.scala
index 9fb94a8f1..39e480bc1 100644
--- a/src/test/scala/game/InventoryStateMessageTest.scala
+++ b/src/test/scala/game/InventoryStateMessageTest.scala
@@ -11,7 +11,7 @@ class InventoryStateMessageTest extends Specification {
val string = hex"38 5C0B 00 3C02 B20000000 0"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case InventoryStateMessage(object_guid, unk, inv_guid, value) =>
object_guid mustEqual PlanetSideGUID(2908)
unk mustEqual 0
@@ -24,7 +24,7 @@ class InventoryStateMessageTest extends Specification {
"encode" in {
val msg = InventoryStateMessage(PlanetSideGUID(2908), 0, PlanetSideGUID(2800), 200)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ItemTransactionMessageTest.scala b/src/test/scala/game/ItemTransactionMessageTest.scala
index d6dcc1bbb..b65757063 100644
--- a/src/test/scala/game/ItemTransactionMessageTest.scala
+++ b/src/test/scala/game/ItemTransactionMessageTest.scala
@@ -13,7 +13,7 @@ class ItemTransactionMessageTest extends Specification {
val string_forget = hex"44 BA00 600011006861726173736572000000"
"decode (buy)" in {
- PacketCoding.DecodePacket(string_buy).require match {
+ PacketCoding.decodePacket(string_buy).require match {
case ItemTransactionMessage(terminal_guid, transaction_type, item_page, item_name, unk1, item_guid) =>
terminal_guid mustEqual PlanetSideGUID(844)
transaction_type mustEqual TransactionType.Buy
@@ -27,7 +27,7 @@ class ItemTransactionMessageTest extends Specification {
}
"decode (sell)" in {
- PacketCoding.DecodePacket(string_sell).require match {
+ PacketCoding.decodePacket(string_sell).require match {
case ItemTransactionMessage(terminal_guid, transaction_type, item_page, item_name, unk1, item_guid) =>
terminal_guid mustEqual PlanetSideGUID(851)
transaction_type mustEqual TransactionType.Sell
@@ -41,7 +41,7 @@ class ItemTransactionMessageTest extends Specification {
}
"decode (forget)" in {
- PacketCoding.DecodePacket(string_forget).require match {
+ PacketCoding.decodePacket(string_forget).require match {
case ItemTransactionMessage(terminal_guid, transaction_type, item_page, item_name, unk1, item_guid) =>
terminal_guid mustEqual PlanetSideGUID(186)
transaction_type mustEqual TransactionType.Sell
@@ -56,13 +56,13 @@ class ItemTransactionMessageTest extends Specification {
"encode (buy)" in {
val msg_buy = ItemTransactionMessage(PlanetSideGUID(844), TransactionType.Buy, 0, "punisher", 0, PlanetSideGUID(0))
- val pkt_buy = PacketCoding.EncodePacket(msg_buy).require.toByteVector
+ val pkt_buy = PacketCoding.encodePacket(msg_buy).require.toByteVector
pkt_buy mustEqual string_buy
}
"encode (sell)" in {
val msg_sell = ItemTransactionMessage(PlanetSideGUID(851), TransactionType.Sell, 0, "", 0, PlanetSideGUID(78))
- val pkt_sell = PacketCoding.EncodePacket(msg_sell).require.toByteVector
+ val pkt_sell = PacketCoding.encodePacket(msg_sell).require.toByteVector
pkt_sell mustEqual string_sell
}
@@ -70,7 +70,7 @@ class ItemTransactionMessageTest extends Specification {
"encode (forget)" in {
val msg_forget =
ItemTransactionMessage(PlanetSideGUID(186), TransactionType.Sell, 0, "harasser", 0, PlanetSideGUID(0))
- val pkt_forget = PacketCoding.EncodePacket(msg_forget).require.toByteVector
+ val pkt_forget = PacketCoding.encodePacket(msg_forget).require.toByteVector
pkt_forget mustEqual string_forget
}
diff --git a/src/test/scala/game/ItemTransactionResultMessageTest.scala b/src/test/scala/game/ItemTransactionResultMessageTest.scala
index a1db8bc94..14644ecaa 100644
--- a/src/test/scala/game/ItemTransactionResultMessageTest.scala
+++ b/src/test/scala/game/ItemTransactionResultMessageTest.scala
@@ -12,7 +12,7 @@ class ItemTransactionResultMessageTest extends Specification {
val string_request = hex"44 DD 03 40 00 11 40 73 75 70 70 72 65 73 73 6F 72 00 00 00"
val string_result = hex"45 DD 03 50 00"
"decode" in {
- PacketCoding.DecodePacket(string_result).require match {
+ PacketCoding.decodePacket(string_result).require match {
case ItemTransactionResultMessage(terminal_guid, transaction_type, is_success, error_code) =>
terminal_guid mustEqual PlanetSideGUID(989)
transaction_type mustEqual TransactionType.Buy
@@ -25,15 +25,15 @@ class ItemTransactionResultMessageTest extends Specification {
"encode" in {
val msg = ItemTransactionResultMessage(PlanetSideGUID(989), TransactionType.Buy, true, 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_result
}
"proper reply" in {
try {
- val request = PacketCoding.DecodePacket(string_request).require.asInstanceOf[ItemTransactionMessage]
- val result = PacketCoding.DecodePacket(string_result).require.asInstanceOf[ItemTransactionResultMessage]
+ val request = PacketCoding.decodePacket(string_request).require.asInstanceOf[ItemTransactionMessage]
+ val result = PacketCoding.decodePacket(string_result).require.asInstanceOf[ItemTransactionResultMessage]
request.terminal_guid mustEqual result.terminal_guid
request.transaction_type mustEqual result.transaction_type
} catch {
diff --git a/src/test/scala/game/KeepAliveMessageTest.scala b/src/test/scala/game/KeepAliveMessageTest.scala
index f3190561c..93bec3b36 100644
--- a/src/test/scala/game/KeepAliveMessageTest.scala
+++ b/src/test/scala/game/KeepAliveMessageTest.scala
@@ -10,7 +10,7 @@ class KeepAliveMessageTest extends Specification {
val string = hex"BA 0000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case KeepAliveMessage(code) =>
code mustEqual 0
case _ =>
@@ -20,7 +20,7 @@ class KeepAliveMessageTest extends Specification {
"encode" in {
val msg = KeepAliveMessage()
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/LashMessageTest.scala b/src/test/scala/game/LashMessageTest.scala
index 8e23bc024..0020efd37 100644
--- a/src/test/scala/game/LashMessageTest.scala
+++ b/src/test/scala/game/LashMessageTest.scala
@@ -11,7 +11,7 @@ class LashMessageTest extends Specification {
val string = hex"4f644a82e2c297a738a1ed0b01b886c0"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case LashMessage(seq_time, player, victim, bullet, pos, unk1) =>
seq_time mustEqual 356
player mustEqual PlanetSideGUID(2858)
@@ -33,7 +33,7 @@ class LashMessageTest extends Specification {
Vector3(5903.7656f, 3456.5156f, 111.53125f),
0
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/LoadMapMessageTest.scala b/src/test/scala/game/LoadMapMessageTest.scala
index 96907ab6e..2aafd942b 100644
--- a/src/test/scala/game/LoadMapMessageTest.scala
+++ b/src/test/scala/game/LoadMapMessageTest.scala
@@ -10,7 +10,7 @@ class LoadMapMessageTest extends Specification {
val string = hex"31 85 6D61703130 83 7A3130 0FA0 19000000 F6 F1 60 86 80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case LoadMapMessage(map_name, nav_map_name, unk1, unk2, weapons_unlocked, unk3) =>
map_name mustEqual "map10"
nav_map_name mustEqual "z10"
@@ -25,7 +25,7 @@ class LoadMapMessageTest extends Specification {
"encode" in {
val msg = LoadMapMessage("map10", "z10", 40975, 25, true, 230810349)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/LoginMessageTest.scala b/src/test/scala/game/LoginMessageTest.scala
index e43c3e923..6b2413982 100644
--- a/src/test/scala/game/LoginMessageTest.scala
+++ b/src/test/scala/game/LoginMessageTest.scala
@@ -13,7 +13,7 @@ class LoginMessageTest extends Specification {
"LoginMessage" should {
"decode (username)" in {
- PacketCoding.DecodePacket(string_password).require match {
+ PacketCoding.decodePacket(string_password).require match {
case LoginMessage(majorVersion, minorVersion, buildDate, username, password, token, revision) =>
majorVersion mustEqual 3
minorVersion mustEqual 15
@@ -28,7 +28,7 @@ class LoginMessageTest extends Specification {
}
"decode (token)" in {
- PacketCoding.DecodePacket(string_token).require match {
+ PacketCoding.decodePacket(string_token).require match {
case LoginMessage(majorVersion, minorVersion, buildDate, username, password, token, revision) =>
majorVersion mustEqual 3
minorVersion mustEqual 15
@@ -52,7 +52,7 @@ class LoginMessageTest extends Specification {
None,
84
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_password
}
@@ -68,7 +68,7 @@ class LoginMessageTest extends Specification {
Some("AAAABBBBCCCCDDDDEEEEFFFFGGGGHHH"),
84
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_token
}
diff --git a/src/test/scala/game/LoginRespMessageTest.scala b/src/test/scala/game/LoginRespMessageTest.scala
index 419c07ba5..46e7ea3f1 100644
--- a/src/test/scala/game/LoginRespMessageTest.scala
+++ b/src/test/scala/game/LoginRespMessageTest.scala
@@ -30,7 +30,7 @@ class LoginRespMessageTest extends Specification {
0
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -45,12 +45,12 @@ class LoginRespMessageTest extends Specification {
10001
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_priv
}
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case LoginRespMessage(token, error, stationError, subscription, unk, username, priv) =>
token mustEqual "HaHLdYzs0VASjksR"
error mustEqual LoginError.Success
@@ -65,7 +65,7 @@ class LoginRespMessageTest extends Specification {
}
"decode with privilege" in {
- PacketCoding.DecodePacket(string_priv).require match {
+ PacketCoding.decodePacket(string_priv).require match {
case LoginRespMessage(token, error, stationError, subscription, unk, username, priv) =>
token mustEqual "HaHLdYzs0VASjksR"
error mustEqual LoginError.Success
diff --git a/src/test/scala/game/LootItemMessageTest.scala b/src/test/scala/game/LootItemMessageTest.scala
index f82e34e24..adc027685 100644
--- a/src/test/scala/game/LootItemMessageTest.scala
+++ b/src/test/scala/game/LootItemMessageTest.scala
@@ -11,7 +11,7 @@ class LootItemMessageTest extends Specification {
val string = hex"6C DD0D 5C14"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case LootItemMessage(item_guid, target_guid) =>
item_guid mustEqual PlanetSideGUID(3549)
target_guid mustEqual PlanetSideGUID(5212)
@@ -22,7 +22,7 @@ class LootItemMessageTest extends Specification {
"encode" in {
val msg = LootItemMessage(PlanetSideGUID(3549), PlanetSideGUID(5212))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/MailMessageTest.scala b/src/test/scala/game/MailMessageTest.scala
index 726060c7e..8cc518f87 100644
--- a/src/test/scala/game/MailMessageTest.scala
+++ b/src/test/scala/game/MailMessageTest.scala
@@ -11,7 +11,7 @@ class MailMessageTest extends Specification {
val string = hex"F1 86466174654A489250726 96F72697479204D61696C2054657374 8E48656C6C6F204175726178697321"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case MailMessage(sender, subject, msg) =>
sender mustEqual "FateJH"
subject mustEqual "Priority Mail Test"
@@ -23,7 +23,7 @@ class MailMessageTest extends Specification {
"encode" in {
val msg = MailMessage("FateJH", "Priority Mail Test", "Hello Auraxis!")
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/MountVehicleMsgTest.scala b/src/test/scala/game/MountVehicleMsgTest.scala
index 43e1ed43d..d9d2ec03b 100644
--- a/src/test/scala/game/MountVehicleMsgTest.scala
+++ b/src/test/scala/game/MountVehicleMsgTest.scala
@@ -11,7 +11,7 @@ class MountVehicleMsgTest extends Specification {
val string = hex"0E E104 6704 06"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case MountVehicleMsg(player_guid, vehicle_guid, entry) =>
player_guid mustEqual PlanetSideGUID(1249)
vehicle_guid mustEqual PlanetSideGUID(1127)
@@ -23,7 +23,7 @@ class MountVehicleMsgTest extends Specification {
"encode" in {
val msg = MountVehicleMsg(PlanetSideGUID(1249), PlanetSideGUID(1127), 6)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/MoveItemMessageTest.scala b/src/test/scala/game/MoveItemMessageTest.scala
index 4b893f9e9..8b51299ab 100644
--- a/src/test/scala/game/MoveItemMessageTest.scala
+++ b/src/test/scala/game/MoveItemMessageTest.scala
@@ -11,7 +11,7 @@ class MoveItemMessageTest extends Specification {
val string = hex"11 4C00 4B00 4B00 0900 0100"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case MoveItemMessage(item_guid, avatar_guid_1, avatar_guid_2, dest, unk1) =>
item_guid mustEqual PlanetSideGUID(76)
avatar_guid_1 mustEqual PlanetSideGUID(75)
@@ -25,7 +25,7 @@ class MoveItemMessageTest extends Specification {
"encode" in {
val msg = MoveItemMessage(PlanetSideGUID(76), PlanetSideGUID(75), PlanetSideGUID(75), 9, 1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ObjectAttachMessageTest.scala b/src/test/scala/game/ObjectAttachMessageTest.scala
index 350c92b20..708921326 100644
--- a/src/test/scala/game/ObjectAttachMessageTest.scala
+++ b/src/test/scala/game/ObjectAttachMessageTest.scala
@@ -12,7 +12,7 @@ class ObjectAttachMessageTest extends Specification {
val stringToCursor = hex"2A 9F05 D405 00FA"
"decode (inventory 1,1)" in {
- PacketCoding.DecodePacket(stringToInventory).require match {
+ PacketCoding.decodePacket(stringToInventory).require match {
case ObjectAttachMessage(player_guid, item_guid, index) =>
player_guid mustEqual PlanetSideGUID(1439)
item_guid mustEqual PlanetSideGUID(1492)
@@ -23,7 +23,7 @@ class ObjectAttachMessageTest extends Specification {
}
"decode (cursor)" in {
- PacketCoding.DecodePacket(stringToCursor).require match {
+ PacketCoding.decodePacket(stringToCursor).require match {
case ObjectAttachMessage(player_guid, item_guid, index) =>
player_guid mustEqual PlanetSideGUID(1439)
item_guid mustEqual PlanetSideGUID(1492)
@@ -35,14 +35,14 @@ class ObjectAttachMessageTest extends Specification {
"encode (inventory 1,1)" in {
val msg = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 6)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringToInventory
}
"encode (cursor)" in {
val msg = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 250)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringToCursor
}
diff --git a/src/test/scala/game/ObjectDeleteMessageTest.scala b/src/test/scala/game/ObjectDeleteMessageTest.scala
index 9ebf66684..8897f0e04 100644
--- a/src/test/scala/game/ObjectDeleteMessageTest.scala
+++ b/src/test/scala/game/ObjectDeleteMessageTest.scala
@@ -11,7 +11,7 @@ class ObjectDeleteMessageTest extends Specification {
val string = hex"19 4C00 00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ObjectDeleteMessage(object_guid, unk1) =>
object_guid mustEqual PlanetSideGUID(76)
unk1 mustEqual 0
@@ -22,7 +22,7 @@ class ObjectDeleteMessageTest extends Specification {
"encode" in {
val msg = ObjectDeleteMessage(PlanetSideGUID(76), 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ObjectDeployedMessageTest.scala b/src/test/scala/game/ObjectDeployedMessageTest.scala
index a9dbba5a3..25cc28aaa 100644
--- a/src/test/scala/game/ObjectDeployedMessageTest.scala
+++ b/src/test/scala/game/ObjectDeployedMessageTest.scala
@@ -10,7 +10,7 @@ class ObjectDeployedMessageTest extends Specification {
val string_boomer = hex"86 000086626F6F6D6572040000000100000019000000"
"decode" in {
- PacketCoding.DecodePacket(string_boomer).require match {
+ PacketCoding.decodePacket(string_boomer).require match {
case ObjectDeployedMessage(unk: Int, desc: String, act: DeployOutcome.Value, count: Long, max: Long) =>
unk mustEqual 0
desc mustEqual "boomer"
@@ -24,7 +24,7 @@ class ObjectDeployedMessageTest extends Specification {
"encode" in {
val msg = ObjectDeployedMessage("boomer", DeployOutcome.Success, 1, 25)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_boomer
}
diff --git a/src/test/scala/game/ObjectDetachMessageTest.scala b/src/test/scala/game/ObjectDetachMessageTest.scala
index ed881cc9b..5bafdd034 100644
--- a/src/test/scala/game/ObjectDetachMessageTest.scala
+++ b/src/test/scala/game/ObjectDetachMessageTest.scala
@@ -11,7 +11,7 @@ class ObjectDetachMessageTest extends Specification {
val string = hex"27 640B C609 92F76 01D65 F611 00 00 40"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ObjectDetachMessage(parent_guid, child_guid, pos, roll, pitch, yaw) =>
parent_guid mustEqual PlanetSideGUID(2916)
child_guid mustEqual PlanetSideGUID(2502)
@@ -35,7 +35,7 @@ class ObjectDetachMessageTest extends Specification {
0f,
270f
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -47,7 +47,7 @@ class ObjectDetachMessageTest extends Specification {
Vector3(3567.1406f, 2988.0078f, 71.84375f),
Vector3(0f, 0f, 270f)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -55,7 +55,7 @@ class ObjectDetachMessageTest extends Specification {
"encode (3)" in {
val msg =
ObjectDetachMessage(PlanetSideGUID(2916), PlanetSideGUID(2502), Vector3(3567.1406f, 2988.0078f, 71.84375f), 270f)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ObjectDetectedMessageTest.scala b/src/test/scala/game/ObjectDetectedMessageTest.scala
index 5e4de7901..73cb2d3c1 100644
--- a/src/test/scala/game/ObjectDetectedMessageTest.scala
+++ b/src/test/scala/game/ObjectDetectedMessageTest.scala
@@ -11,7 +11,7 @@ class ObjectDetectedMessageTest extends Specification {
val string = hex"61 E60F E60F 00 1C9C39F8304030AC18A8183436D42C"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ObjectDetectedMessage(guid1, guid2, unk1, list) =>
guid1 mustEqual PlanetSideGUID(4070)
guid2 mustEqual PlanetSideGUID(4070)
@@ -43,7 +43,7 @@ class ObjectDetectedMessageTest extends Specification {
PlanetSideGUID(2997) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ObjectHeldMessageTest.scala b/src/test/scala/game/ObjectHeldMessageTest.scala
index c3cb43aa7..4b7ea7749 100644
--- a/src/test/scala/game/ObjectHeldMessageTest.scala
+++ b/src/test/scala/game/ObjectHeldMessageTest.scala
@@ -11,7 +11,7 @@ class ObjectHeldMessageTest extends Specification {
val string = hex"33 4B00 02 00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ObjectHeldMessage(avatar_guid, held_holsters, unk1) =>
avatar_guid mustEqual PlanetSideGUID(75)
held_holsters mustEqual 2
@@ -23,7 +23,7 @@ class ObjectHeldMessageTest extends Specification {
"encode" in {
val msg = ObjectHeldMessage(PlanetSideGUID(75), 2, false)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/OrbitalStrikeWaypointMessageTest.scala b/src/test/scala/game/OrbitalStrikeWaypointMessageTest.scala
index 8d10b3347..051f83b07 100644
--- a/src/test/scala/game/OrbitalStrikeWaypointMessageTest.scala
+++ b/src/test/scala/game/OrbitalStrikeWaypointMessageTest.scala
@@ -12,7 +12,7 @@ class OrbitalStrikeWaypointMessageTest extends Specification {
val string_off = hex"B9 46 0C 00"
"decode (on)" in {
- PacketCoding.DecodePacket(string_on).require match {
+ PacketCoding.decodePacket(string_on).require match {
case OrbitalStrikeWaypointMessage(guid, coords) =>
guid mustEqual PlanetSideGUID(3142)
coords.isDefined mustEqual true
@@ -24,7 +24,7 @@ class OrbitalStrikeWaypointMessageTest extends Specification {
}
"decode (off)" in {
- PacketCoding.DecodePacket(string_off).require match {
+ PacketCoding.decodePacket(string_off).require match {
case OrbitalStrikeWaypointMessage(guid, coords) =>
guid mustEqual PlanetSideGUID(3142)
coords.isDefined mustEqual false
@@ -35,14 +35,14 @@ class OrbitalStrikeWaypointMessageTest extends Specification {
"encode (on)" in {
val msg = OrbitalStrikeWaypointMessage(PlanetSideGUID(3142), 5518.664f, 2212.539f)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_on
}
"encode (off)" in {
val msg = OrbitalStrikeWaypointMessage(PlanetSideGUID(3142))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_off
}
diff --git a/src/test/scala/game/OxygenStateMessageTest.scala b/src/test/scala/game/OxygenStateMessageTest.scala
index 7bd31f6a6..bc3b58c15 100644
--- a/src/test/scala/game/OxygenStateMessageTest.scala
+++ b/src/test/scala/game/OxygenStateMessageTest.scala
@@ -12,7 +12,7 @@ class OxygenStateMessageTest extends Specification {
val string_vehicle = hex"78 4b00f4385037a180"
"decode (self)" in {
- PacketCoding.DecodePacket(string_self).require match {
+ PacketCoding.decodePacket(string_self).require match {
case OxygenStateMessage(guid, progress, active, veh_state) =>
guid mustEqual PlanetSideGUID(75)
progress mustEqual 50.0
@@ -24,7 +24,7 @@ class OxygenStateMessageTest extends Specification {
}
"decode (vehicle)" in {
- PacketCoding.DecodePacket(string_vehicle).require match {
+ PacketCoding.decodePacket(string_vehicle).require match {
case OxygenStateMessage(guid, progress, active, veh_state) =>
guid mustEqual PlanetSideGUID(75)
progress mustEqual 50.0f
@@ -40,7 +40,7 @@ class OxygenStateMessageTest extends Specification {
"encode (self)" in {
val msg = OxygenStateMessage(PlanetSideGUID(75), 50.0f, true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_self
}
@@ -48,7 +48,7 @@ class OxygenStateMessageTest extends Specification {
"encode (vehicle)" in {
val msg =
OxygenStateMessage(PlanetSideGUID(75), 50.0f, true, WaterloggedVehicleState(PlanetSideGUID(1546), 50.0f, true))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_vehicle
}
diff --git a/src/test/scala/game/PickupItemMessageTest.scala b/src/test/scala/game/PickupItemMessageTest.scala
index 63ee2ed4c..6c22613a3 100644
--- a/src/test/scala/game/PickupItemMessageTest.scala
+++ b/src/test/scala/game/PickupItemMessageTest.scala
@@ -11,7 +11,7 @@ class PickupItemMessageTest extends Specification {
val string = hex"36 5600 4B00 00 0000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case PickupItemMessage(item_guid, player_guid, unk1, unk2) =>
item_guid mustEqual PlanetSideGUID(86)
player_guid mustEqual PlanetSideGUID(75)
@@ -24,7 +24,7 @@ class PickupItemMessageTest extends Specification {
"encode" in {
val msg = PickupItemMessage(PlanetSideGUID(86), PlanetSideGUID(75), 0, 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/PingMsgTest.scala b/src/test/scala/game/PingMsgTest.scala
index 679f42688..d5783bf36 100644
--- a/src/test/scala/game/PingMsgTest.scala
+++ b/src/test/scala/game/PingMsgTest.scala
@@ -10,7 +10,7 @@ class PingMsgTest extends Specification {
val packet = hex"1a 00000000 b0360000"
"decode" in {
- PacketCoding.DecodePacket(packet).require match {
+ PacketCoding.decodePacket(packet).require match {
case PingMsg(unk1, unk2) =>
unk1 === 0
unk2 === 14000
@@ -21,6 +21,6 @@ class PingMsgTest extends Specification {
"encode" in {
val msg = PingMsg(0, 14000)
- PacketCoding.EncodePacket(msg).require.toByteVector === packet
+ PacketCoding.encodePacket(msg).require.toByteVector === packet
}
}
diff --git a/src/test/scala/game/PlanetsideAttributeMessageTest.scala b/src/test/scala/game/PlanetsideAttributeMessageTest.scala
index c512bdeef..6aecc8781 100644
--- a/src/test/scala/game/PlanetsideAttributeMessageTest.scala
+++ b/src/test/scala/game/PlanetsideAttributeMessageTest.scala
@@ -11,7 +11,7 @@ class PlanetsideAttributeMessageTest extends Specification {
val string = hex"2c d9040458000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case PlanetsideAttributeMessage(player_guid, attribute_type, attribute_value) =>
player_guid mustEqual PlanetSideGUID(1241)
attribute_type mustEqual 4
@@ -23,7 +23,7 @@ class PlanetsideAttributeMessageTest extends Specification {
"encode" in {
val msg = PlanetsideAttributeMessage(PlanetSideGUID(1241), 4, 88)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/PlanetsideStringAttributeMessageTest.scala b/src/test/scala/game/PlanetsideStringAttributeMessageTest.scala
index e02532eb9..8d9cf29b5 100644
--- a/src/test/scala/game/PlanetsideStringAttributeMessageTest.scala
+++ b/src/test/scala/game/PlanetsideStringAttributeMessageTest.scala
@@ -11,7 +11,7 @@ class PlanetsideStringAttributeMessageTest extends Specification {
val string = hex"92 fb04 00 90540068006500200042006c00610063006b00200052006100760065006e007300"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case PlanetsideStringAttributeMessage(guid, string_type, string_value) =>
guid mustEqual PlanetSideGUID(1275)
string_type mustEqual 0
@@ -23,7 +23,7 @@ class PlanetsideStringAttributeMessageTest extends Specification {
"encode" in {
val msg = PlanetsideStringAttributeMessage(PlanetSideGUID(1275), 0, "The Black Ravens")
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/PlayerStasisMessageTest.scala b/src/test/scala/game/PlayerStasisMessageTest.scala
index 9c7302089..33df05cac 100644
--- a/src/test/scala/game/PlayerStasisMessageTest.scala
+++ b/src/test/scala/game/PlayerStasisMessageTest.scala
@@ -11,7 +11,7 @@ class PlayerStasisMessageTest extends Specification {
val string = hex"8A 4B00 80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case PlayerStasisMessage(player_guid, stasis) =>
player_guid mustEqual PlanetSideGUID(75)
stasis mustEqual true
@@ -22,7 +22,7 @@ class PlayerStasisMessageTest extends Specification {
"encode" in {
val msg = PlayerStasisMessage(PlanetSideGUID(75))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/PlayerStateMessageTest.scala b/src/test/scala/game/PlayerStateMessageTest.scala
index 7842aca6f..35c5c6021 100644
--- a/src/test/scala/game/PlayerStateMessageTest.scala
+++ b/src/test/scala/game/PlayerStateMessageTest.scala
@@ -14,7 +14,7 @@ class PlayerStateMessageTest extends Specification {
val string_vel = hex"08 A006 4DD47 CDB1B 0C0B A8C1A5000403008014A4"
"decode (short)" in {
- PacketCoding.DecodePacket(string_short).require match {
+ PacketCoding.decodePacket(string_short).require match {
case PlayerStateMessage(
guid,
pos,
@@ -47,7 +47,7 @@ class PlayerStateMessageTest extends Specification {
}
"decode (mod)" in {
- PacketCoding.DecodePacket(string_mod).require match {
+ PacketCoding.decodePacket(string_mod).require match {
case PlayerStateMessage(
guid,
pos,
@@ -80,7 +80,7 @@ class PlayerStateMessageTest extends Specification {
}
"decode (vel)" in {
- PacketCoding.DecodePacket(string_vel).require match {
+ PacketCoding.decodePacket(string_vel).require match {
case PlayerStateMessage(
guid,
pos,
@@ -129,7 +129,7 @@ class PlayerStateMessageTest extends Specification {
false,
false
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_short
}
@@ -147,7 +147,7 @@ class PlayerStateMessageTest extends Specification {
false,
true
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_mod
}
@@ -165,7 +165,7 @@ class PlayerStateMessageTest extends Specification {
false,
false
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_vel
}
}
diff --git a/src/test/scala/game/PlayerStateMessageUpstreamTest.scala b/src/test/scala/game/PlayerStateMessageUpstreamTest.scala
index 019cc7581..8598e385b 100644
--- a/src/test/scala/game/PlayerStateMessageUpstreamTest.scala
+++ b/src/test/scala/game/PlayerStateMessageUpstreamTest.scala
@@ -11,7 +11,7 @@ class PlayerStateMessageUpstreamTest extends Specification {
val string = hex"BD 4B000 E377BA575B616C640A70004014060110007000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case PlayerStateMessageUpstream(
avatar_guid,
pos,
@@ -64,7 +64,7 @@ class PlayerStateMessageUpstreamTest extends Specification {
112,
0
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/PlayerStateShiftMessageTest.scala b/src/test/scala/game/PlayerStateShiftMessageTest.scala
index 8c9c3f696..dd3043ff1 100644
--- a/src/test/scala/game/PlayerStateShiftMessageTest.scala
+++ b/src/test/scala/game/PlayerStateShiftMessageTest.scala
@@ -13,7 +13,7 @@ class PlayerStateShiftMessageTest extends Specification {
val string_posAndVel = hex"BE AE 01 29 CD 59 B9 40 C0 EA D4 00 0F 86 40"
"decode (short)" in {
- PacketCoding.DecodePacket(string_short).require match {
+ PacketCoding.decodePacket(string_short).require match {
case PlayerStateShiftMessage(state, unk) =>
state.isDefined mustEqual false
unk.isDefined mustEqual true
@@ -24,7 +24,7 @@ class PlayerStateShiftMessageTest extends Specification {
}
"decode (pos)" in {
- PacketCoding.DecodePacket(string_pos).require match {
+ PacketCoding.decodePacket(string_pos).require match {
case PlayerStateShiftMessage(state, unk) =>
state.isDefined mustEqual true
state.get.unk mustEqual 1
@@ -40,7 +40,7 @@ class PlayerStateShiftMessageTest extends Specification {
}
"decode (pos and vel)" in {
- PacketCoding.DecodePacket(string_posAndVel).require match {
+ PacketCoding.decodePacket(string_posAndVel).require match {
case PlayerStateShiftMessage(state, unk) =>
state.isDefined mustEqual true
state.get.unk mustEqual 2
@@ -60,14 +60,14 @@ class PlayerStateShiftMessageTest extends Specification {
"encode (short)" in {
val msg = PlayerStateShiftMessage(5)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_short
}
"encode (pos)" in {
val msg = PlayerStateShiftMessage(ShiftState(1, Vector3(4624.703f, 5922.1484f, 46.171875f), 92.8125f))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_pos
}
@@ -76,7 +76,7 @@ class PlayerStateShiftMessageTest extends Specification {
val msg = PlayerStateShiftMessage(
ShiftState(2, Vector3(4645.75f, 5811.6016f, 50.3125f), 50.625f, Vector3(2.8125f, -8.0f, 0.375f))
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_posAndVel
}
diff --git a/src/test/scala/game/ProjectileStateMessageTest.scala b/src/test/scala/game/ProjectileStateMessageTest.scala
index 2db34e84f..88a435816 100644
--- a/src/test/scala/game/ProjectileStateMessageTest.scala
+++ b/src/test/scala/game/ProjectileStateMessageTest.scala
@@ -11,7 +11,7 @@ class ProjectileStateMessageTest extends Specification {
val string = hex"3f 259d c5019 30e4a 9514 c52c9541 d9ba05c2 c5973941 00 f8 ec 02000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ProjectileStateMessage(projectile, pos, vel, orient, sequence, explode, unk) =>
projectile mustEqual PlanetSideGUID(40229)
pos mustEqual Vector3(4611.539f, 5576.375f, 82.328125f)
@@ -35,7 +35,7 @@ class ProjectileStateMessageTest extends Specification {
false,
PlanetSideGUID(0)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
//pkt mustEqual string
val pkt_bits = pkt.toBitVector
diff --git a/src/test/scala/game/PropertyOverrideMessageTest.scala b/src/test/scala/game/PropertyOverrideMessageTest.scala
index 3a20c939a..ea4c90594 100644
--- a/src/test/scala/game/PropertyOverrideMessageTest.scala
+++ b/src/test/scala/game/PropertyOverrideMessageTest.scala
@@ -12,7 +12,7 @@ class PropertyOverrideMessageTest extends Specification {
hex"D5 0B 00 00 00 01 0A E4 0C 02 48 70 75 72 63 68 61 73 65 5F 65 78 65 6D 70 74 5F 76 73 80 92 70 75 72 63 68 61 73 65 5F 65 78 65 6D 70 74 5F 74 72 80 92 70 75 72 63 68 61 73 65 5F 65 78 65 6D 70 74 5F 6E 63 80 11 00 01 14 A4 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 12 00 01 14 A4 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 13 00 01 14 A4 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 14 00 01 14 A4 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 15 00 01 14 A4 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 16 00 01 14 A4 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 1D 00 15 0A 60 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 54 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 76 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 87 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C7 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C8 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 26 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 52 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 AD 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B0 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CE 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 D6 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 2C 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 82 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 83 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CA 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 61 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 9B 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 DA 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 1E 00 15 0A 60 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 54 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 76 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 87 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C7 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C8 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 26 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 52 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 AD 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B0 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CE 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 D6 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 2C 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 82 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 83 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CA 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 61 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 9B 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 DA 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 1F 00 15 0A 60 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 54 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 76 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 87 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C7 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C8 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 26 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 52 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 AD 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B0 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CE 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 D6 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 2C 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 82 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 83 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CA 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 61 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 9B 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 DA 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 20 00 15 0A 60 04 02 1C 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 54 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 76 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 87 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C7 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 C8 00 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 26 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 52 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 AD 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B0 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CE 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 D6 20 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 2C 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 82 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 83 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 B9 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 CA 40 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 61 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 9B 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65 DA 60 20 10 E0 61 6C 6C 6F 77 65 64 85 66 61 6C 73 65"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case PropertyOverrideMessage(list) =>
list.length mustEqual 11
//
@@ -547,7 +547,7 @@ class PropertyOverrideMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/ProximityTerminalUseMessageTest.scala b/src/test/scala/game/ProximityTerminalUseMessageTest.scala
index 80ee2791e..326d43072 100644
--- a/src/test/scala/game/ProximityTerminalUseMessageTest.scala
+++ b/src/test/scala/game/ProximityTerminalUseMessageTest.scala
@@ -10,7 +10,7 @@ import scodec.bits._
class ProximityTerminalUseMessageTest extends Specification {
val string = hex"C3 4B00 A700 80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ProximityTerminalUseMessage(player_guid, object_guid, unk) =>
player_guid mustEqual PlanetSideGUID(75)
object_guid mustEqual PlanetSideGUID(167)
@@ -21,7 +21,7 @@ class ProximityTerminalUseMessageTest extends Specification {
}
"encode" in {
val msg = ProximityTerminalUseMessage(PlanetSideGUID(75), PlanetSideGUID(167), true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/QuantityDeltaUpdateMessageTest.scala b/src/test/scala/game/QuantityDeltaUpdateMessageTest.scala
index 3e8e81399..2f7d75c9f 100644
--- a/src/test/scala/game/QuantityDeltaUpdateMessageTest.scala
+++ b/src/test/scala/game/QuantityDeltaUpdateMessageTest.scala
@@ -11,7 +11,7 @@ class QuantityDeltaUpdateMessageTest extends Specification {
val string = hex"C4 5300 FBFFFFFF"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case QuantityDeltaUpdateMessage(item_guid, quantity) =>
item_guid mustEqual PlanetSideGUID(83)
quantity mustEqual -5
@@ -22,7 +22,7 @@ class QuantityDeltaUpdateMessageTest extends Specification {
"encode" in {
val msg = QuantityDeltaUpdateMessage(PlanetSideGUID(83), -5)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/QuantityUpdateMessageTest.scala b/src/test/scala/game/QuantityUpdateMessageTest.scala
index 7997acb5a..1d802c33b 100644
--- a/src/test/scala/game/QuantityUpdateMessageTest.scala
+++ b/src/test/scala/game/QuantityUpdateMessageTest.scala
@@ -11,7 +11,7 @@ class QuantityUpdateMessageTest extends Specification {
val string = hex"3D 5300 7B000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case QuantityUpdateMessage(item_guid, quantity) =>
item_guid mustEqual PlanetSideGUID(83)
quantity mustEqual 123
@@ -22,7 +22,7 @@ class QuantityUpdateMessageTest extends Specification {
"encode" in {
val msg = QuantityUpdateMessage(PlanetSideGUID(83), 123)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ReleaseAvatarRequestMessageTest.scala b/src/test/scala/game/ReleaseAvatarRequestMessageTest.scala
index 05666382f..fd75101e2 100644
--- a/src/test/scala/game/ReleaseAvatarRequestMessageTest.scala
+++ b/src/test/scala/game/ReleaseAvatarRequestMessageTest.scala
@@ -10,7 +10,7 @@ class ReleaseAvatarRequestMessageTest extends Specification {
val string = hex"ac"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ReleaseAvatarRequestMessage() =>
ok
case _ =>
@@ -20,7 +20,7 @@ class ReleaseAvatarRequestMessageTest extends Specification {
"encode" in {
val msg = ReleaseAvatarRequestMessage()
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ReloadMessageTest.scala b/src/test/scala/game/ReloadMessageTest.scala
index b2fda764b..67a69e718 100644
--- a/src/test/scala/game/ReloadMessageTest.scala
+++ b/src/test/scala/game/ReloadMessageTest.scala
@@ -11,7 +11,7 @@ class ReloadMessageTest extends Specification {
val string = hex"0D 4C00 7B000000 FFFFFFFF"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ReloadMessage(item_guid, ammo_clip, unk1) =>
item_guid mustEqual PlanetSideGUID(76)
ammo_clip mustEqual 123
@@ -23,7 +23,7 @@ class ReloadMessageTest extends Specification {
"encode" in {
val msg = ReloadMessage(PlanetSideGUID(76), 123, -1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/RepairMessageTest.scala b/src/test/scala/game/RepairMessageTest.scala
index bbff8cd84..3d21abac4 100644
--- a/src/test/scala/game/RepairMessageTest.scala
+++ b/src/test/scala/game/RepairMessageTest.scala
@@ -11,7 +11,7 @@ class RepairMessageTest extends Specification {
val string = hex"4D 2709 5C000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case RepairMessage(item_guid, repair_value) =>
item_guid mustEqual PlanetSideGUID(2343)
repair_value mustEqual 92
@@ -22,7 +22,7 @@ class RepairMessageTest extends Specification {
"encode" in {
val msg = RepairMessage(PlanetSideGUID(2343), 92)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ReplicationStreamMessageTest.scala b/src/test/scala/game/ReplicationStreamMessageTest.scala
index 78fdd8880..f2e887b9e 100644
--- a/src/test/scala/game/ReplicationStreamMessageTest.scala
+++ b/src/test/scala/game/ReplicationStreamMessageTest.scala
@@ -66,7 +66,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (clear)" in {
- PacketCoding.DecodePacket(stringListClear).require match {
+ PacketCoding.decodePacket(stringListClear).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 5
behavior2.isDefined mustEqual true
@@ -78,7 +78,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (one)" in {
- PacketCoding.DecodePacket(stringListOne).require match {
+ PacketCoding.decodePacket(stringListOne).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 5
behavior2.get mustEqual 6
@@ -103,7 +103,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (two)" in {
- PacketCoding.DecodePacket(stringListTwo).require match {
+ PacketCoding.decodePacket(stringListTwo).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 5
behavior2.get mustEqual 6
@@ -128,7 +128,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (three)" in {
- PacketCoding.DecodePacket(stringListThree).require match {
+ PacketCoding.decodePacket(stringListThree).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 5
behavior2.get mustEqual 6
@@ -160,7 +160,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (remove)" in {
- PacketCoding.DecodePacket(stringListRemove).require match {
+ PacketCoding.decodePacket(stringListRemove).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 1
behavior2.isDefined mustEqual false
@@ -173,7 +173,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (update leader)" in {
- PacketCoding.DecodePacket(stringUpdateLeader).require match {
+ PacketCoding.decodePacket(stringUpdateLeader).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 6
behavior2.isDefined mustEqual false
@@ -193,7 +193,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (update task)" in {
- PacketCoding.DecodePacket(stringUpdateTask).require match {
+ PacketCoding.decodePacket(stringUpdateTask).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 6
behavior2.isDefined mustEqual false
@@ -213,7 +213,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (update continent)" in {
- PacketCoding.DecodePacket(stringUpdateContinent).require match {
+ PacketCoding.decodePacket(stringUpdateContinent).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 6
behavior2.isDefined mustEqual false
@@ -233,7 +233,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (update size)" in {
- PacketCoding.DecodePacket(stringUpdateSize).require match {
+ PacketCoding.decodePacket(stringUpdateSize).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 6
behavior2.isDefined mustEqual false
@@ -253,7 +253,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (update leader and size)" in {
- PacketCoding.DecodePacket(stringUpdateLeaderSize).require match {
+ PacketCoding.decodePacket(stringUpdateLeaderSize).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 6
behavior2.isDefined mustEqual false
@@ -274,7 +274,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (update task and continent)" in {
- PacketCoding.DecodePacket(stringUpdateTaskContinent).require match {
+ PacketCoding.decodePacket(stringUpdateTaskContinent).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 6
behavior2.isDefined mustEqual false
@@ -295,7 +295,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (update all)" in {
- PacketCoding.DecodePacket(stringUpdateAll).require match {
+ PacketCoding.decodePacket(stringUpdateAll).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 6
behavior2.isDefined mustEqual false
@@ -320,7 +320,7 @@ class ReplicationStreamMessageTest extends Specification {
}
"decode (remove 1 and update 0)" in {
- PacketCoding.DecodePacket(stringRemoveUpdate).require match {
+ PacketCoding.decodePacket(stringRemoveUpdate).require match {
case ReplicationStreamMessage(behavior, behavior2, entries) =>
behavior mustEqual 1
behavior2.isDefined mustEqual false
@@ -341,7 +341,7 @@ class ReplicationStreamMessageTest extends Specification {
"encode (clear)" in {
val msg = ReplicationStreamMessage(5, Some(6), Vector.empty)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringListClear
}
@@ -352,7 +352,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadInfo("FragLANdINC", "Frag", PlanetSideZoneID(10), 0, 10, PlanetSideGUID(1))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringListOne
}
@@ -364,7 +364,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadInfo("KOKkiasMFCN", "Squad 2", PlanetSideZoneID(4), 6, 10, PlanetSideGUID(4))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringListTwo
}
@@ -377,7 +377,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadInfo("KOKkiasMFCN", "Squad 2", PlanetSideZoneID(4), 6, 10, PlanetSideGUID(4))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringListThree
}
@@ -390,7 +390,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(5, None)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringListRemove
}
@@ -403,7 +403,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(2, SquadInfo("FateJHNC"))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringUpdateLeader
}
@@ -416,7 +416,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(5, SquadInfo(None, "RIP PS1, visit PSForever.net"))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringUpdateTask
}
@@ -429,7 +429,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(3, SquadInfo(PlanetSideZoneID(10)))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringUpdateContinent
}
@@ -442,7 +442,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(1, SquadInfo(6))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringUpdateSize
}
@@ -455,7 +455,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(5, SquadInfo("Jimmyn").And(SquadInfo(3)))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringUpdateLeaderSize
}
@@ -468,7 +468,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(5, SquadInfo(None, "2").And(SquadInfo(PlanetSideZoneID(4))))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringUpdateTaskContinent
}
@@ -481,7 +481,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(7, SquadInfo("madmuj", "", PlanetSideZoneID(4), 0, 10, PlanetSideGUID(11)))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringUpdateAll
}
@@ -495,7 +495,7 @@ class ReplicationStreamMessageTest extends Specification {
SquadListing(0, SquadInfo(10))
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringRemoveUpdate
}
diff --git a/src/test/scala/game/RequestDestroyMessageTest.scala b/src/test/scala/game/RequestDestroyMessageTest.scala
index e3390601c..7b7cbbb34 100644
--- a/src/test/scala/game/RequestDestroyMessageTest.scala
+++ b/src/test/scala/game/RequestDestroyMessageTest.scala
@@ -11,7 +11,7 @@ class RequestDestroyMessageTest extends Specification {
val string = hex"2D A49C"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case RequestDestroyMessage(object_guid) =>
object_guid mustEqual PlanetSideGUID(40100)
case _ =>
@@ -21,7 +21,7 @@ class RequestDestroyMessageTest extends Specification {
"encode" in {
val msg = RequestDestroyMessage(PlanetSideGUID(40100))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ServerVehicleOverrideMsgTest.scala b/src/test/scala/game/ServerVehicleOverrideMsgTest.scala
index 91a107841..391992f38 100644
--- a/src/test/scala/game/ServerVehicleOverrideMsgTest.scala
+++ b/src/test/scala/game/ServerVehicleOverrideMsgTest.scala
@@ -11,7 +11,7 @@ class ServerVehicleOverrideMsgTest extends Specification {
val string2 = hex"4E 10 050 0"
"decode (1)" in {
- PacketCoding.DecodePacket(string1).require match {
+ PacketCoding.decodePacket(string1).require match {
case ServerVehicleOverrideMsg(u1, u2, u3, u4, u5, u6, u7, u8) =>
u1 mustEqual true
u2 mustEqual true
@@ -28,7 +28,7 @@ class ServerVehicleOverrideMsgTest extends Specification {
}
"decode (2)" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case ServerVehicleOverrideMsg(u1, u2, u3, u4, u5, u6, u7, u8) =>
u1 mustEqual false
u2 mustEqual false
@@ -45,14 +45,14 @@ class ServerVehicleOverrideMsgTest extends Specification {
"encode (1)" in {
val msg = ServerVehicleOverrideMsg(true, true, false, false, 0, 0, 12, Some(0L))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string1
}
"encode (2)" in {
val msg = ServerVehicleOverrideMsg(false, false, false, true, 0, 0, 5, None)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string2
}
diff --git a/src/test/scala/game/SetChatFilterMessageTest.scala b/src/test/scala/game/SetChatFilterMessageTest.scala
index 27bc0e929..3388ec259 100644
--- a/src/test/scala/game/SetChatFilterMessageTest.scala
+++ b/src/test/scala/game/SetChatFilterMessageTest.scala
@@ -11,7 +11,7 @@ class SetChatFilterMessageTest extends Specification {
val string_custom = hex"63 05C180"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SetChatFilterMessage(send, origin, filters) =>
send mustEqual ChatChannel.Local
origin mustEqual true
@@ -31,7 +31,7 @@ class SetChatFilterMessageTest extends Specification {
}
"decode (custom)" in {
- PacketCoding.DecodePacket(string_custom).require match {
+ PacketCoding.decodePacket(string_custom).require match {
case SetChatFilterMessage(send, origin, filters) =>
send mustEqual ChatChannel.Local
origin mustEqual true
@@ -61,7 +61,7 @@ class SetChatFilterMessageTest extends Specification {
ChatChannel.SquadLeader
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -84,7 +84,7 @@ class SetChatFilterMessageTest extends Specification {
ChatChannel.SquadLeader
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -105,7 +105,7 @@ class SetChatFilterMessageTest extends Specification {
ChatChannel.Local
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -116,7 +116,7 @@ class SetChatFilterMessageTest extends Specification {
true,
List(ChatChannel.Unknown, ChatChannel.Tells, ChatChannel.Broadcast, ChatChannel.SquadLeader)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_custom
}
diff --git a/src/test/scala/game/SetEmpireMessageTest.scala b/src/test/scala/game/SetEmpireMessageTest.scala
index abcdf937c..4863d4af7 100644
--- a/src/test/scala/game/SetEmpireMessageTest.scala
+++ b/src/test/scala/game/SetEmpireMessageTest.scala
@@ -11,7 +11,7 @@ class SetEmpireMessageTest extends Specification {
val string = hex"24 02 00 80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SetEmpireMessage(object_guid, empire) =>
object_guid mustEqual PlanetSideGUID(2)
empire mustEqual PlanetSideEmpire.VS
@@ -22,7 +22,7 @@ class SetEmpireMessageTest extends Specification {
"encode" in {
val msg = SetEmpireMessage(PlanetSideGUID(2), PlanetSideEmpire.VS)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/SimDataChallengeRespTest.scala b/src/test/scala/game/SimDataChallengeRespTest.scala
index dc2d033c6..6a304aef7 100644
--- a/src/test/scala/game/SimDataChallengeRespTest.scala
+++ b/src/test/scala/game/SimDataChallengeRespTest.scala
@@ -10,7 +10,7 @@ class SimDataChallengeRespTest extends Specification {
val string = hex"97050067030000e9030000e1040000000100006502000005003b3388faa52df48fb27971e7c3a9d0c109d5b03f00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SimDataChallengeResp(u1, u2, u3) =>
u1 mustEqual List(871L, 1001L, 1249L, 256L, 613L)
u2 mustEqual List(4203230011L, 2415144357L, 3882973618L, 3251677635L, 1068553481L)
@@ -26,7 +26,7 @@ class SimDataChallengeRespTest extends Specification {
List(4203230011L, 2415144357L, 3882973618L, 3251677635L, 1068553481L),
false
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/SimDataChallengeTest.scala b/src/test/scala/game/SimDataChallengeTest.scala
index 90b068e45..bbf082a7d 100644
--- a/src/test/scala/game/SimDataChallengeTest.scala
+++ b/src/test/scala/game/SimDataChallengeTest.scala
@@ -10,7 +10,7 @@ class SimDataChallengeTest extends Specification {
val string = hex"96050067030000e9030000e10400000001000065020000808000000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SimDataChallenge(u1, u2, u3, u4, u5) =>
u1 mustEqual List(871L, 1001L, 1249L, 256L, 613L)
u2 mustEqual true
@@ -24,7 +24,7 @@ class SimDataChallengeTest extends Specification {
"encode" in {
val msg = SimDataChallenge(List(871L, 1001L, 1249L, 256L, 613L), true, 1, 0, false)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/SpawnRequestMessageTest.scala b/src/test/scala/game/SpawnRequestMessageTest.scala
index 2b5939091..33a0c6f58 100644
--- a/src/test/scala/game/SpawnRequestMessageTest.scala
+++ b/src/test/scala/game/SpawnRequestMessageTest.scala
@@ -11,7 +11,7 @@ class SpawnRequestMessageTest extends Specification {
val string = hex"4a000007000000000000000200"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SpawnRequestMessage(unk1, unk2, unk3, unk4, unk5) =>
unk1 mustEqual 0
unk2 mustEqual SpawnGroup.Facility
@@ -25,7 +25,7 @@ class SpawnRequestMessageTest extends Specification {
"encode" in {
val msg = SpawnRequestMessage(0, SpawnGroup.Facility, 0, 0, 2)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/SplashHitMessageTest.scala b/src/test/scala/game/SplashHitMessageTest.scala
index 40e978b41..4c60fc922 100644
--- a/src/test/scala/game/SplashHitMessageTest.scala
+++ b/src/test/scala/game/SplashHitMessageTest.scala
@@ -12,7 +12,7 @@ class SplashHitMessageTest extends Specification {
hex"62 7129e72b0c1dd1516ec58000051e01d8371f0100000025803616bb2a9ae50b000008889d00644bdd35454c45c000000400"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SplashHitMessage(unk1, projectile_uid, projectile_pos, unk2, unk3, projectile_vel, unk4, targets) =>
unk1 mustEqual 113
projectile_uid mustEqual PlanetSideGUID(40103)
@@ -59,7 +59,7 @@ class SplashHitMessageTest extends Specification {
SplashedTarget(PlanetSideGUID(372), Vector3(3679.1328f, 2722.6016f, 92.765625f), 268435456L, None) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/SquadDefinitionActionMessageTest.scala b/src/test/scala/game/SquadDefinitionActionMessageTest.scala
index e48748966..a2ada2677 100644
--- a/src/test/scala/game/SquadDefinitionActionMessageTest.scala
+++ b/src/test/scala/game/SquadDefinitionActionMessageTest.scala
@@ -46,7 +46,7 @@ class SquadDefinitionActionMessageTest extends Specification {
val string_failure = hex"E7 ff"
"decode (00)" in {
- PacketCoding.DecodePacket(string_00).require match {
+ PacketCoding.decodePacket(string_00).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(3)
unk2 mustEqual 0
@@ -57,7 +57,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (03)" in {
- PacketCoding.DecodePacket(string_03).require match {
+ PacketCoding.decodePacket(string_03).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 3
@@ -68,7 +68,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (03)" in {
- PacketCoding.DecodePacket(string_04).require match {
+ PacketCoding.decodePacket(string_04).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 3
@@ -79,7 +79,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (07)" in {
- PacketCoding.DecodePacket(string_07).require match {
+ PacketCoding.decodePacket(string_07).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 3
@@ -90,7 +90,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (08)" in {
- PacketCoding.DecodePacket(string_08).require match {
+ PacketCoding.decodePacket(string_08).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -101,7 +101,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (10)" in {
- PacketCoding.DecodePacket(string_10).require match {
+ PacketCoding.decodePacket(string_10).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -112,7 +112,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (19)" in {
- PacketCoding.DecodePacket(string_19).require match {
+ PacketCoding.decodePacket(string_19).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -123,7 +123,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (20)" in {
- PacketCoding.DecodePacket(string_20).require match {
+ PacketCoding.decodePacket(string_20).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -134,7 +134,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (21)" in {
- PacketCoding.DecodePacket(string_21).require match {
+ PacketCoding.decodePacket(string_21).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -145,7 +145,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (22)" in {
- PacketCoding.DecodePacket(string_22).require match {
+ PacketCoding.decodePacket(string_22).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -156,7 +156,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (23)" in {
- PacketCoding.DecodePacket(string_23).require match {
+ PacketCoding.decodePacket(string_23).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -167,7 +167,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (24)" in {
- PacketCoding.DecodePacket(string_24).require match {
+ PacketCoding.decodePacket(string_24).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -178,7 +178,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (25)" in {
- PacketCoding.DecodePacket(string_25).require match {
+ PacketCoding.decodePacket(string_25).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -192,7 +192,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (26)" in {
- PacketCoding.DecodePacket(string_26).require match {
+ PacketCoding.decodePacket(string_26).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -203,7 +203,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (28)" in {
- PacketCoding.DecodePacket(string_28).require match {
+ PacketCoding.decodePacket(string_28).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -214,7 +214,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (31)" in {
- PacketCoding.DecodePacket(string_31).require match {
+ PacketCoding.decodePacket(string_31).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -225,7 +225,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (34a)" in {
- PacketCoding.DecodePacket(string_34a).require match {
+ PacketCoding.decodePacket(string_34a).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -236,7 +236,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (34b)" in {
- PacketCoding.DecodePacket(string_34b).require match {
+ PacketCoding.decodePacket(string_34b).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -247,7 +247,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (34c)" in {
- PacketCoding.DecodePacket(string_34c).require match {
+ PacketCoding.decodePacket(string_34c).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -258,7 +258,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (34d)" in {
- PacketCoding.DecodePacket(string_34d).require match {
+ PacketCoding.decodePacket(string_34d).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -274,7 +274,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (34e)" in {
- PacketCoding.DecodePacket(string_34e).require match {
+ PacketCoding.decodePacket(string_34e).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -290,7 +290,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (35)" in {
- PacketCoding.DecodePacket(string_35).require match {
+ PacketCoding.decodePacket(string_35).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -301,7 +301,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (40)" in {
- PacketCoding.DecodePacket(string_40).require match {
+ PacketCoding.decodePacket(string_40).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -312,7 +312,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (41)" in {
- PacketCoding.DecodePacket(string_41).require match {
+ PacketCoding.decodePacket(string_41).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -323,7 +323,7 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (43, unknown)" in {
- PacketCoding.DecodePacket(string_43).require match {
+ PacketCoding.decodePacket(string_43).require match {
case SquadDefinitionActionMessage(unk1, unk2, action) =>
unk1 mustEqual PlanetSideGUID(0)
unk2 mustEqual 0
@@ -334,82 +334,82 @@ class SquadDefinitionActionMessageTest extends Specification {
}
"decode (failure)" in {
- PacketCoding.DecodePacket(string_failure).isFailure mustEqual true
+ PacketCoding.decodePacket(string_failure).isFailure mustEqual true
}
"encode (00)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(3), 0, DisplaySquad())
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_00
}
"encode (03)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 3, SaveSquadFavorite())
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_03
}
"encode (03)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 3, LoadSquadFavorite())
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_04
}
"encode (07)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 3, ListSquadFavorite("Cops and Military Officers"))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_07
}
"encode (08)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, RequestListSquad())
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_08
}
"encode (10)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, SelectRoleForYourself(1))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_10
}
"encode (19)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, ChangeSquadPurpose("A-Team"))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_19
}
"encode (20)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, ChangeSquadZone(PlanetSideZoneID(1)))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_20
}
"encode (21)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, CloseSquadMemberPosition(2))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_21
}
"encode (22)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, AddSquadMemberPosition(2))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_22
}
"encode (23)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, ChangeSquadMemberRequirementsRole(1, "BLUFOR"))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_23
}
@@ -420,7 +420,7 @@ class SquadDefinitionActionMessageTest extends Specification {
0,
ChangeSquadMemberRequirementsDetailedOrders(1, "kill bad dudes")
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_24
}
@@ -434,28 +434,28 @@ class SquadDefinitionActionMessageTest extends Specification {
Set(Certification.AntiVehicular, Certification.InfiltrationSuit)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_25
}
"encode (26)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, ResetAll())
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_26
}
"encode (28)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, AutoApproveInvitationRequests(true))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_28
}
"encode (31)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, LocationFollowsSquadLead(true))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_31
}
@@ -466,7 +466,7 @@ class SquadDefinitionActionMessageTest extends Specification {
0,
SearchForSquadsWithParticularRole("Badass", Set(), 1, SearchMode.AnyPositions)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_34a
}
@@ -477,7 +477,7 @@ class SquadDefinitionActionMessageTest extends Specification {
0,
SearchForSquadsWithParticularRole("Badass", Set(), 2, SearchMode.AnyPositions)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_34b
}
@@ -488,7 +488,7 @@ class SquadDefinitionActionMessageTest extends Specification {
0,
SearchForSquadsWithParticularRole("Badass", Set(), 2, SearchMode.AvailablePositions)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_34c
}
@@ -504,7 +504,7 @@ class SquadDefinitionActionMessageTest extends Specification {
SearchMode.SomeCertifications
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_34d
}
@@ -520,35 +520,35 @@ class SquadDefinitionActionMessageTest extends Specification {
SearchMode.AllCertifications
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_34e
}
"encode (35)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, CancelSquadSearch())
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_35
}
"encode (40)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, FindLfsSoldiersForRole(1))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_40
}
"encode (41)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, CancelFind())
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_41
}
"encode (43, unknown)" in {
val msg = SquadDefinitionActionMessage(PlanetSideGUID(0), 0, Unknown(43, BitVector.empty))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_43
}
diff --git a/src/test/scala/game/SquadDetailDefinitionUpdateMessageTest.scala b/src/test/scala/game/SquadDetailDefinitionUpdateMessageTest.scala
index dce13fca2..6903bf0dd 100644
--- a/src/test/scala/game/SquadDetailDefinitionUpdateMessageTest.scala
+++ b/src/test/scala/game/SquadDetailDefinitionUpdateMessageTest.scala
@@ -31,7 +31,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
"SquadDetailDefinitionUpdateMessage" should {
"decode (unk1 + members)" in {
- PacketCoding.DecodePacket(string_unk1).require match {
+ PacketCoding.decodePacket(string_unk1).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -48,7 +48,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (char id)" in {
- PacketCoding.DecodePacket(string_leader_char_id).require match {
+ PacketCoding.decodePacket(string_leader_char_id).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(5)
detail match {
@@ -64,7 +64,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (unk3 + leader name)" in {
- PacketCoding.DecodePacket(string_unk3LeaderName).require match {
+ PacketCoding.decodePacket(string_unk3LeaderName).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -82,7 +82,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (task)" in {
- PacketCoding.DecodePacket(string_task).require match {
+ PacketCoding.decodePacket(string_task).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(5)
detail match {
@@ -98,7 +98,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (zone)" in {
- PacketCoding.DecodePacket(string_zone).require match {
+ PacketCoding.decodePacket(string_zone).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -114,7 +114,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (task + zone)" in {
- PacketCoding.DecodePacket(string_taskZone).require match {
+ PacketCoding.decodePacket(string_taskZone).require match {
case SquadDetailDefinitionUpdateMessage(_, detail) =>
detail match {
case SquadDetail(None, None, None, None, None, Some(task), Some(zone), None, None) =>
@@ -130,7 +130,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (unk7 + members)" in {
- PacketCoding.DecodePacket(string_unk7).require match {
+ PacketCoding.decodePacket(string_unk7).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -147,7 +147,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (member closed)" in {
- PacketCoding.DecodePacket(string_member_closed).require match {
+ PacketCoding.decodePacket(string_member_closed).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -170,7 +170,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (member role)" in {
- PacketCoding.DecodePacket(string_member_role).require match {
+ PacketCoding.decodePacket(string_member_role).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(7)
detail match {
@@ -193,7 +193,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (member role + requirements)" in {
- PacketCoding.DecodePacket(string_member_roleRequirements).require match {
+ PacketCoding.decodePacket(string_member_roleRequirements).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(1)
detail match {
@@ -218,7 +218,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (member char id + name)" in {
- PacketCoding.DecodePacket(string_member_charIdName).require match {
+ PacketCoding.decodePacket(string_member_charIdName).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -242,7 +242,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (task + member etc)" in {
- PacketCoding.DecodePacket(string_task_memberEtc).require match {
+ PacketCoding.decodePacket(string_task_memberEtc).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(1)
detail match {
@@ -278,7 +278,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (full squad)" in {
- PacketCoding.DecodePacket(string_full).require match {
+ PacketCoding.decodePacket(string_full).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -501,7 +501,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
}
"decode (mixed)" in {
- PacketCoding.DecodePacket(string_mixed).require match {
+ PacketCoding.decodePacket(string_mixed).require match {
case SquadDetailDefinitionUpdateMessage(guid, detail) =>
guid mustEqual PlanetSideGUID(3)
detail match {
@@ -659,7 +659,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_unk1
}
@@ -668,7 +668,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
PlanetSideGUID(5),
SquadDetail().LeaderCharId(30910985L)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_leader_char_id
}
@@ -684,7 +684,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_unk3LeaderName
}
@@ -693,7 +693,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
PlanetSideGUID(5),
SquadDetail().Task("All Welcome ")
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_task
}
@@ -702,7 +702,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
PlanetSideGUID(3),
SquadDetail().ZoneId(PlanetSideZoneID(21))
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_zone
}
@@ -713,7 +713,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
.Task("\\#FF0000 The \\#ffffff Blades")
.ZoneId(PlanetSideZoneID(4))
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_taskZone
}
@@ -738,7 +738,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_unk7
}
@@ -752,7 +752,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_member_closed
}
@@ -766,7 +766,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_member_role
}
@@ -785,7 +785,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_member_roleRequirements
}
@@ -799,7 +799,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_member_charIdName
}
@@ -823,7 +823,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_task_memberEtc
}
@@ -853,7 +853,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_full
}
@@ -865,7 +865,7 @@ class SquadDetailDefinitionUpdateMessageTest extends Specification {
.Task("PSForever Packet Collection")
.Members((0 to 9).map { index => SquadPositionEntry(index, position) }.reverse.toList)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_mixed
}
}
diff --git a/src/test/scala/game/SquadMemberEventTest.scala b/src/test/scala/game/SquadMemberEventTest.scala
index 2f431991f..d0ae6d78c 100644
--- a/src/test/scala/game/SquadMemberEventTest.scala
+++ b/src/test/scala/game/SquadMemberEventTest.scala
@@ -10,7 +10,7 @@ class SquadMemberEventTest extends Specification {
val string = hex"7000e008545180410848006f0066004400070051150800"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case SquadMemberEvent(u1, u2, u3, u4, u5, u6, u7) =>
u1 mustEqual MemberEvent.Add
u2 mustEqual 7
@@ -26,7 +26,7 @@ class SquadMemberEventTest extends Specification {
"encode" in {
val msg = SquadMemberEvent(MemberEvent.Add, 7, 42771010L, 0, Some("HofD"), Some(7), Some(529745L))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/SquadMembershipRequestTest.scala b/src/test/scala/game/SquadMembershipRequestTest.scala
index 79cb9319f..3f0a7ecdc 100644
--- a/src/test/scala/game/SquadMembershipRequestTest.scala
+++ b/src/test/scala/game/SquadMembershipRequestTest.scala
@@ -16,7 +16,7 @@ class SquadMembershipRequestTest extends Specification {
//TODO find example where unk field is defined and is a string
"decode (1)" in {
- PacketCoding.DecodePacket(string1).require match {
+ PacketCoding.decodePacket(string1).require match {
case SquadMembershipRequest(req_type, unk2, unk3, p_name, unk5) =>
req_type mustEqual SquadRequestType.Invite
unk2 mustEqual 41593365L
@@ -29,7 +29,7 @@ class SquadMembershipRequestTest extends Specification {
}
"decode (2)" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case SquadMembershipRequest(req_type, unk2, unk3, p_name, unk5) =>
req_type mustEqual SquadRequestType.Accept
unk2 mustEqual 41606501L
@@ -43,7 +43,7 @@ class SquadMembershipRequestTest extends Specification {
"encode (1)" in {
val msg = SquadMembershipRequest(SquadRequestType.Invite, 41593365, Some(41605156L), "", Some(None))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string1
}
@@ -57,7 +57,7 @@ class SquadMembershipRequestTest extends Specification {
"encode (2)" in {
val msg = SquadMembershipRequest(SquadRequestType.Accept, 41606501, None, "", None)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string2
}
diff --git a/src/test/scala/game/SquadMembershipResponseTest.scala b/src/test/scala/game/SquadMembershipResponseTest.scala
index 0212c783c..b1ad38357 100644
--- a/src/test/scala/game/SquadMembershipResponseTest.scala
+++ b/src/test/scala/game/SquadMembershipResponseTest.scala
@@ -28,7 +28,7 @@ class SquadMembershipResponseTest extends Specification {
"SquadMembershipResponse" should {
"decode (0-1)" in {
- PacketCoding.DecodePacket(string_01).require match {
+ PacketCoding.decodePacket(string_01).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Invite
unk2 mustEqual 0
@@ -44,7 +44,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (0-2)" in {
- PacketCoding.DecodePacket(string_02).require match {
+ PacketCoding.decodePacket(string_02).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Invite
unk2 mustEqual 0
@@ -60,7 +60,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (1-1)" in {
- PacketCoding.DecodePacket(string_11).require match {
+ PacketCoding.decodePacket(string_11).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Unk01
unk2 mustEqual 19
@@ -76,7 +76,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (1-2)" in {
- PacketCoding.DecodePacket(string_12).require match {
+ PacketCoding.decodePacket(string_12).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Unk01
unk2 mustEqual 18
@@ -92,7 +92,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (2-1)" in {
- PacketCoding.DecodePacket(string_21).require match {
+ PacketCoding.decodePacket(string_21).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Accept
unk2 mustEqual 0
@@ -108,7 +108,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (2-2)" in {
- PacketCoding.DecodePacket(string_22).require match {
+ PacketCoding.decodePacket(string_22).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Accept
unk2 mustEqual 0
@@ -124,7 +124,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (3-1)" in {
- PacketCoding.DecodePacket(string_31).require match {
+ PacketCoding.decodePacket(string_31).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Reject
unk2 mustEqual 0
@@ -140,7 +140,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (3-2)" in {
- PacketCoding.DecodePacket(string_32).require match {
+ PacketCoding.decodePacket(string_32).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Reject
unk2 mustEqual 0
@@ -156,7 +156,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (4-1)" in {
- PacketCoding.DecodePacket(string_41).require match {
+ PacketCoding.decodePacket(string_41).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Cancel
unk2 mustEqual 0
@@ -172,7 +172,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (4-2)" in {
- PacketCoding.DecodePacket(string_42).require match {
+ PacketCoding.decodePacket(string_42).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Cancel
unk2 mustEqual 0
@@ -188,7 +188,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (5-1)" in {
- PacketCoding.DecodePacket(string_51).require match {
+ PacketCoding.decodePacket(string_51).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.Leave
unk2 mustEqual 0
@@ -204,7 +204,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (7-1)" in {
- PacketCoding.DecodePacket(string_71).require match {
+ PacketCoding.decodePacket(string_71).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.PlatoonInvite
unk2 mustEqual 2
@@ -220,7 +220,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (7-2)" in {
- PacketCoding.DecodePacket(string_72).require match {
+ PacketCoding.decodePacket(string_72).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.PlatoonInvite
unk2 mustEqual 0
@@ -236,7 +236,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (8-1)" in {
- PacketCoding.DecodePacket(string_81).require match {
+ PacketCoding.decodePacket(string_81).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.PlatoonAccept
unk2 mustEqual 0
@@ -252,7 +252,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (9-1)" in {
- PacketCoding.DecodePacket(string_91).require match {
+ PacketCoding.decodePacket(string_91).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.PlatoonReject
unk2 mustEqual 0
@@ -268,7 +268,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (9-2)" in {
- PacketCoding.DecodePacket(string_92).require match {
+ PacketCoding.decodePacket(string_92).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.PlatoonReject
unk2 mustEqual 0
@@ -284,7 +284,7 @@ class SquadMembershipResponseTest extends Specification {
}
"decode (b-1)" in {
- PacketCoding.DecodePacket(string_b1).require match {
+ PacketCoding.decodePacket(string_b1).require match {
case SquadMembershipResponse(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8) =>
unk1 mustEqual SquadResponseType.PlatoonLeave
unk2 mustEqual 0
@@ -301,7 +301,7 @@ class SquadMembershipResponseTest extends Specification {
"encode (0-1)" in {
val msg = SquadMembershipResponse(SquadResponseType.Invite, 0, 0, 42771010L, Some(1300870L), "HofD", false, None)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_01
}
@@ -309,21 +309,21 @@ class SquadMembershipResponseTest extends Specification {
"encode (0-2)" in {
val msg =
SquadMembershipResponse(SquadResponseType.Invite, 0, 0, 1176612L, Some(1004937L), "SPOILERS", true, None)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_02
}
"encode (1-1)" in {
val msg = SquadMembershipResponse(SquadResponseType.Unk01, 19, 0, 41530025L, Some(0L), "", true, Some(None))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_11
}
"encode (1-2)" in {
val msg = SquadMembershipResponse(SquadResponseType.Unk01, 18, 0, 41578085L, Some(0L), "", true, Some(None))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_12
}
@@ -339,7 +339,7 @@ class SquadMembershipResponseTest extends Specification {
true,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_21
}
@@ -355,7 +355,7 @@ class SquadMembershipResponseTest extends Specification {
true,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_22
}
@@ -363,7 +363,7 @@ class SquadMembershipResponseTest extends Specification {
"encode (3-1)" in {
val msg =
SquadMembershipResponse(SquadResponseType.Reject, 0, 3, 31035057L, Some(42771010L), "HMFIC", false, Some(None))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_31
}
@@ -379,7 +379,7 @@ class SquadMembershipResponseTest extends Specification {
false,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_32
}
@@ -395,7 +395,7 @@ class SquadMembershipResponseTest extends Specification {
false,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_41
}
@@ -411,7 +411,7 @@ class SquadMembershipResponseTest extends Specification {
false,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_42
}
@@ -419,14 +419,14 @@ class SquadMembershipResponseTest extends Specification {
"encode (5-1)" in {
val msg =
SquadMembershipResponse(SquadResponseType.Leave, 0, 1, 1176612L, Some(1176612L), "CCRIDER", true, Some(None))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_51
}
"encode (7-1)" in {
val msg = SquadMembershipResponse(SquadResponseType.PlatoonInvite, 2, 0, 1176612L, Some(0L), "", true, Some(None))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_71
}
@@ -442,7 +442,7 @@ class SquadMembershipResponseTest extends Specification {
true,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_72
}
@@ -458,7 +458,7 @@ class SquadMembershipResponseTest extends Specification {
false,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_81
}
@@ -466,7 +466,7 @@ class SquadMembershipResponseTest extends Specification {
"encode (9-1)" in {
val msg =
SquadMembershipResponse(SquadResponseType.PlatoonReject, 0, 0, 297025L, Some(41605002L), "", true, Some(None))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_91
}
@@ -482,7 +482,7 @@ class SquadMembershipResponseTest extends Specification {
false,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_92
}
@@ -498,7 +498,7 @@ class SquadMembershipResponseTest extends Specification {
false,
Some(None)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_b1
}
diff --git a/src/test/scala/game/SquadStateTest.scala b/src/test/scala/game/SquadStateTest.scala
index 2ae1b595c..947d70fd3 100644
--- a/src/test/scala/game/SquadStateTest.scala
+++ b/src/test/scala/game/SquadStateTest.scala
@@ -14,7 +14,7 @@ class SquadStateTest extends Specification {
hex"7704008dd9ccf010042a9837310e1b82a8c006646c7a028103984f34759c904a800014f01c26f3d014081ddd3896931bc25478037680ea80c081d699a147b01e154000031c0bc81407e08c1a3a890de1542c022070bd0140815958bf29efa6214300108023c01000ae491ac68d1a61342c023623c50140011d6ea0878f3026a00009e014"
"decode (1)" in {
- PacketCoding.DecodePacket(string1).require match {
+ PacketCoding.decodePacket(string1).require match {
case SquadState(guid, list) =>
guid mustEqual PlanetSideGUID(7)
list.size mustEqual 1
@@ -40,7 +40,7 @@ class SquadStateTest extends Specification {
}
"decode (2)" in {
- PacketCoding.DecodePacket(string2).require match {
+ PacketCoding.decodePacket(string2).require match {
case SquadState(guid, list) =>
guid mustEqual PlanetSideGUID(7)
list.size mustEqual 2
@@ -81,7 +81,7 @@ class SquadStateTest extends Specification {
}
"decode (8)" in {
- PacketCoding.DecodePacket(stringx).require match {
+ PacketCoding.decodePacket(stringx).require match {
case SquadState(guid, list) =>
guid mustEqual PlanetSideGUID(4)
list.size mustEqual 8
@@ -218,7 +218,7 @@ class SquadStateTest extends Specification {
SquadStateInfo(1300870L, 64, 64, Vector3(3464.0469f, 4065.5703f, 20.015625f), 2, 2, false, 0)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string1
}
@@ -230,7 +230,7 @@ class SquadStateTest extends Specification {
SquadStateInfo(42644970L, 64, 64, Vector3(2908.7422f, 3742.6875f, 67.296875f), 2, 2, false, 680)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string2
}
@@ -248,7 +248,7 @@ class SquadStateTest extends Specification {
SquadStateInfo(42616684L, 64, 0, Vector3(2927.1094f, 3704.0312f, 78.375f), 1, 1, false, 0, 572, true)
)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual stringx
}
}
diff --git a/src/test/scala/game/SquadWaypointEventTest.scala b/src/test/scala/game/SquadWaypointEventTest.scala
index 2084d7d2d..4ad97d827 100644
--- a/src/test/scala/game/SquadWaypointEventTest.scala
+++ b/src/test/scala/game/SquadWaypointEventTest.scala
@@ -14,7 +14,7 @@ class SquadWaypointEventTest extends Specification {
val string_4 = hex"84 40c03f1e5e80804100000000" //fabricated example
"decode (1)" in {
- PacketCoding.DecodePacket(string_1).require match {
+ PacketCoding.decodePacket(string_1).require match {
case SquadWaypointEvent(unk1, unk2, unk3, unk4, unk5, unk6) =>
unk1 mustEqual WaypointEventAction.Remove
unk2 mustEqual 11
@@ -28,7 +28,7 @@ class SquadWaypointEventTest extends Specification {
}
"decode (2)" in {
- PacketCoding.DecodePacket(string_2).require match {
+ PacketCoding.decodePacket(string_2).require match {
case SquadWaypointEvent(unk1, unk2, unk3, unk4, unk5, unk6) =>
unk1 mustEqual WaypointEventAction.Remove
unk2 mustEqual 10
@@ -42,7 +42,7 @@ class SquadWaypointEventTest extends Specification {
}
"decode (3)" in {
- PacketCoding.DecodePacket(string_3).require match {
+ PacketCoding.decodePacket(string_3).require match {
case SquadWaypointEvent(unk1, unk2, unk3, unk4, unk5, unk6) =>
unk1 mustEqual WaypointEventAction.Add
unk2 mustEqual 3
@@ -56,7 +56,7 @@ class SquadWaypointEventTest extends Specification {
}
"decode (4)" in {
- PacketCoding.DecodePacket(string_4).require match {
+ PacketCoding.decodePacket(string_4).require match {
case SquadWaypointEvent(unk1, unk2, unk3, unk4, unk5, unk6) =>
unk1 mustEqual WaypointEventAction.Unknown1
unk2 mustEqual 3
@@ -71,14 +71,14 @@ class SquadWaypointEventTest extends Specification {
"encode (1)" in {
val msg = SquadWaypointEvent.Remove(11, 31155863L, SquadWaypoints.One)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_1
}
"encode (2)" in {
val msg = SquadWaypointEvent.Remove(10, 0L, SquadWaypoints.ExperienceRally)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_2
}
@@ -90,14 +90,14 @@ class SquadWaypointEventTest extends Specification {
SquadWaypoints.Two,
WaypointEvent(10, Vector3(3457.9688f, 5514.4688f, 0.0f), 1)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_3
}
"encode (4)" in {
val msg = SquadWaypointEvent.Unknown1(3, 41581052L, SquadWaypoints.Two, 4L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_4
}
diff --git a/src/test/scala/game/TargetingImplantRequestTest.scala b/src/test/scala/game/TargetingImplantRequestTest.scala
index d6ebd6093..b05010bb3 100644
--- a/src/test/scala/game/TargetingImplantRequestTest.scala
+++ b/src/test/scala/game/TargetingImplantRequestTest.scala
@@ -13,7 +13,7 @@ class TargetingImplantRequestTest extends Specification {
hex"b5 41edeb12d4409f0144053f8010541ba91d03df376831b1e26000611041e1107c0209c0" //0510085013d9ffb6720d5b132900003770?
"decode (single)" in {
- PacketCoding.DecodePacket(string_single).require match {
+ PacketCoding.decodePacket(string_single).require match {
case TargetingImplantRequest(target_list) =>
target_list.length mustEqual 1
//0
@@ -25,7 +25,7 @@ class TargetingImplantRequestTest extends Specification {
}
"decode (long)" in {
- PacketCoding.DecodePacket(string_long).require match {
+ PacketCoding.decodePacket(string_long).require match {
case TargetingImplantRequest(target_list) =>
target_list.length mustEqual 16
//0
@@ -86,7 +86,7 @@ class TargetingImplantRequestTest extends Specification {
TargetRequest(PlanetSideGUID(1412), true) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_single
}
@@ -111,7 +111,7 @@ class TargetingImplantRequestTest extends Specification {
TargetRequest(PlanetSideGUID(14401), false) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_long
}
diff --git a/src/test/scala/game/TargetingInfoMessageTest.scala b/src/test/scala/game/TargetingInfoMessageTest.scala
index 827adcdcf..865ef2ada 100644
--- a/src/test/scala/game/TargetingInfoMessageTest.scala
+++ b/src/test/scala/game/TargetingInfoMessageTest.scala
@@ -11,7 +11,7 @@ class TargetingInfoMessageTest extends Specification {
val string = hex"50 05 3D10C200 570EFF3C 2406EC00 2B068C00 2A069400"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case TargetingInfoMessage(target_list) =>
target_list.size mustEqual 5
//0
@@ -48,7 +48,7 @@ class TargetingInfoMessageTest extends Specification {
TargetInfo(PlanetSideGUID(1578), 0.5803922f) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/TimeOfDayMessageTest.scala b/src/test/scala/game/TimeOfDayMessageTest.scala
index e21acb284..c2a1c5bbe 100644
--- a/src/test/scala/game/TimeOfDayMessageTest.scala
+++ b/src/test/scala/game/TimeOfDayMessageTest.scala
@@ -10,7 +10,7 @@ class TimeOfDayMessageTest extends Specification {
val string = hex"48 00 00 00 47 00 00 20 41"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case TimeOfDayMessage(time, unk) =>
time mustEqual 1191182336
unk mustEqual 1092616192
@@ -21,7 +21,7 @@ class TimeOfDayMessageTest extends Specification {
"encode" in {
val msg = TimeOfDayMessage(1191182336)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/TrainingZoneMessageTest.scala b/src/test/scala/game/TrainingZoneMessageTest.scala
index 28db66784..3f66325e0 100644
--- a/src/test/scala/game/TrainingZoneMessageTest.scala
+++ b/src/test/scala/game/TrainingZoneMessageTest.scala
@@ -11,7 +11,7 @@ class TrainingZoneMessageTest extends Specification {
val string = hex"75 1300 0000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case TrainingZoneMessage(zone, _) =>
zone mustEqual PlanetSideGUID(19)
case _ =>
@@ -21,7 +21,7 @@ class TrainingZoneMessageTest extends Specification {
"encode" in {
val msg = TrainingZoneMessage(PlanetSideGUID(19))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/TriggerEffectMessageTest.scala b/src/test/scala/game/TriggerEffectMessageTest.scala
index 5e4647e18..955fb649a 100644
--- a/src/test/scala/game/TriggerEffectMessageTest.scala
+++ b/src/test/scala/game/TriggerEffectMessageTest.scala
@@ -13,7 +13,7 @@ class TriggerEffectMessageTest extends Specification {
val string_boomer_explode = hex"51 DF09 8F 6465746F6E6174655F626F6F6D6572 00"
"decode (motion alarm sensor)" in {
- PacketCoding.DecodePacket(string_motionalarmsensor).require match {
+ PacketCoding.decodePacket(string_motionalarmsensor).require match {
case TriggerEffectMessage(guid, effect, unk, location) =>
guid mustEqual PlanetSideGUID(2967)
effect mustEqual "on"
@@ -27,7 +27,7 @@ class TriggerEffectMessageTest extends Specification {
}
"decode (boomer)" in {
- PacketCoding.DecodePacket(string_boomer).require match {
+ PacketCoding.decodePacket(string_boomer).require match {
case TriggerEffectMessage(guid, effect, unk, location) =>
guid mustEqual PlanetSideGUID(0)
effect mustEqual "spawn_object_effect"
@@ -41,7 +41,7 @@ class TriggerEffectMessageTest extends Specification {
}
"decode (boomer explode)" in {
- PacketCoding.DecodePacket(string_boomer_explode).require match {
+ PacketCoding.decodePacket(string_boomer_explode).require match {
case TriggerEffectMessage(guid, effect, unk, location) =>
guid mustEqual PlanetSideGUID(2527)
effect mustEqual "detonate_boomer"
@@ -54,7 +54,7 @@ class TriggerEffectMessageTest extends Specification {
"encode (motion alarm sensor)" in {
val msg = TriggerEffectMessage(PlanetSideGUID(2967), "on", true, 1000L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_motionalarmsensor
}
@@ -62,14 +62,14 @@ class TriggerEffectMessageTest extends Specification {
"encode (boomer)" in {
val msg =
TriggerEffectMessage("spawn_object_effect", Vector3(3567.0156f, 3278.6953f, 114.484375f), Vector3(0, 0, 90))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_boomer
}
"encode (boomer explode)" in {
val msg = TriggerEffectMessage(PlanetSideGUID(2527), "detonate_boomer")
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_boomer_explode
}
diff --git a/src/test/scala/game/TriggerEnvironmentalDamageMessageTest.scala b/src/test/scala/game/TriggerEnvironmentalDamageMessageTest.scala
index ca2ed3df4..9cfe72097 100644
--- a/src/test/scala/game/TriggerEnvironmentalDamageMessageTest.scala
+++ b/src/test/scala/game/TriggerEnvironmentalDamageMessageTest.scala
@@ -11,7 +11,7 @@ class TriggerEnvironmentalDamageMessageTest extends Specification {
val string = hex"74 a7c44140000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case TriggerEnvironmentalDamageMessage(unk1, guid, unk2) =>
unk1 mustEqual 2
guid mustEqual PlanetSideGUID(4511)
@@ -23,7 +23,7 @@ class TriggerEnvironmentalDamageMessageTest extends Specification {
"encode" in {
val msg = TriggerEnvironmentalDamageMessage(2, PlanetSideGUID(4511), 5L)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/TriggerSoundMessageTest.scala b/src/test/scala/game/TriggerSoundMessageTest.scala
index 2db61b456..4f588b242 100644
--- a/src/test/scala/game/TriggerSoundMessageTest.scala
+++ b/src/test/scala/game/TriggerSoundMessageTest.scala
@@ -11,7 +11,7 @@ class TriggerSoundMessageTest extends Specification {
val string = hex"6B 1FD5E1B466DB3858F1FC"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case TriggerSoundMessage(sound, pos, unk2, volume) =>
sound mustEqual TriggeredSound.HackDoor
pos.x mustEqual 1913.9531f
@@ -26,7 +26,7 @@ class TriggerSoundMessageTest extends Specification {
"encode" in {
val msg = TriggerSoundMessage(TriggeredSound.HackDoor, Vector3(1913.9531f, 6042.8125f, 45.609375f), 30, 0.49803925f)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/UnuseItemMessageTest.scala b/src/test/scala/game/UnuseItemMessageTest.scala
index 2c7433721..547953191 100644
--- a/src/test/scala/game/UnuseItemMessageTest.scala
+++ b/src/test/scala/game/UnuseItemMessageTest.scala
@@ -11,7 +11,7 @@ class UnuseItemMessageTest extends Specification {
val string = hex"26 4B00 340D"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case UnuseItemMessage(player, item) =>
player mustEqual PlanetSideGUID(75)
item mustEqual PlanetSideGUID(3380)
@@ -22,7 +22,7 @@ class UnuseItemMessageTest extends Specification {
"encode" in {
val msg = UnuseItemMessage(PlanetSideGUID(75), PlanetSideGUID(3380))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/UseItemMessageTest.scala b/src/test/scala/game/UseItemMessageTest.scala
index 26e38dc6b..7777c090d 100644
--- a/src/test/scala/game/UseItemMessageTest.scala
+++ b/src/test/scala/game/UseItemMessageTest.scala
@@ -11,7 +11,7 @@ class UseItemMessageTest extends Specification {
val string = hex"10 4B00 0000 7401 FFFFFFFF 4001000000000000000000000000058C803600800000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case UseItemMessage(avatar_guid, unk1, object_guid, unk2, unk3, unk4, unk5, unk6, unk7, unk8, itemType) =>
avatar_guid mustEqual PlanetSideGUID(75)
unk1 mustEqual PlanetSideGUID(0)
@@ -43,7 +43,7 @@ class UseItemMessageTest extends Specification {
0,
364
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/VNLWorldStatusMessageTest.scala b/src/test/scala/game/VNLWorldStatusMessageTest.scala
index 1230349df..8d4433196 100644
--- a/src/test/scala/game/VNLWorldStatusMessageTest.scala
+++ b/src/test/scala/game/VNLWorldStatusMessageTest.scala
@@ -16,7 +16,7 @@ class VNLWorldStatusMessageTest extends Specification {
hex"67656d696e69" ++ hex"0100 03 00 01459e2540 3775" ++ bin"01".toByteVector
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case VNLWorldStatusMessage(message, worlds) =>
message mustEqual "Welcome to PlanetSide! "
@@ -64,7 +64,7 @@ class VNLWorldStatusMessageTest extends Specification {
//0100 04 00 01459e2540377540
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -72,11 +72,11 @@ class VNLWorldStatusMessageTest extends Specification {
"encode and decode empty messages" in {
val string = hex"0584410041004100410000"
val empty_msg = VNLWorldStatusMessage("AAAA", Vector())
- val empty_pkt = PacketCoding.EncodePacket(empty_msg).require.toByteVector
+ val empty_pkt = PacketCoding.encodePacket(empty_msg).require.toByteVector
empty_pkt mustEqual string
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case VNLWorldStatusMessage(message, worlds) =>
message mustEqual "AAAA"
worlds.length mustEqual 0
@@ -97,11 +97,11 @@ class VNLWorldStatusMessageTest extends Specification {
)
val msg = VNLWorldStatusMessage("Welcome to PlanetSide! ", worlds)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case VNLWorldStatusMessage(message, pkt_worlds) =>
message mustEqual "Welcome to PlanetSide! "
diff --git a/src/test/scala/game/VehicleStateMessageTest.scala b/src/test/scala/game/VehicleStateMessageTest.scala
index df4765de4..f6e9045df 100644
--- a/src/test/scala/game/VehicleStateMessageTest.scala
+++ b/src/test/scala/game/VehicleStateMessageTest.scala
@@ -11,7 +11,7 @@ class VehicleStateMessageTest extends Specification {
val string = hex"1b 9d010d85aecaa6b8c2dfdfefffc020008006000078"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case VehicleStateMessage(guid, unk1, pos, ang, vel, unk2, unk3, unk4, wheel, unk5, unk6) =>
guid mustEqual PlanetSideGUID(413)
unk1 mustEqual 0
@@ -50,7 +50,7 @@ class VehicleStateMessageTest extends Specification {
false,
false
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/VehicleSubStateMessageTest.scala b/src/test/scala/game/VehicleSubStateMessageTest.scala
index 2fbc19c32..c84d1ead1 100644
--- a/src/test/scala/game/VehicleSubStateMessageTest.scala
+++ b/src/test/scala/game/VehicleSubStateMessageTest.scala
@@ -11,7 +11,7 @@ class VehicleSubStateMessageTest extends Specification {
val string = hex"6D D91C 300D 529F5845 D1953345 E51AB642 21000F63E6F80C1CCF80"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case VehicleSubStateMessage(vehicle_guid, player_guid, vehicle_pos, vehicle_ang, vel, unk1, unk2) =>
vehicle_guid mustEqual PlanetSideGUID(7385)
player_guid mustEqual PlanetSideGUID(3376)
@@ -36,7 +36,7 @@ class VehicleSubStateMessageTest extends Specification {
false,
None
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/VoiceHostInfoTest.scala b/src/test/scala/game/VoiceHostInfoTest.scala
index 7cd25bf0a..850d4669b 100644
--- a/src/test/scala/game/VoiceHostInfoTest.scala
+++ b/src/test/scala/game/VoiceHostInfoTest.scala
@@ -11,7 +11,7 @@ class VoiceHostInfoTest extends Specification {
val string_info = hex"b2 4b00"
"decode" in {
- PacketCoding.DecodePacket(string_info).require match {
+ PacketCoding.decodePacket(string_info).require match {
case VoiceHostInfo(player, _) =>
player mustEqual PlanetSideGUID(75)
case _ =>
@@ -21,7 +21,7 @@ class VoiceHostInfoTest extends Specification {
"encode" in {
val msg = VoiceHostInfo(PlanetSideGUID(75), ByteVector.empty)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_info
}
diff --git a/src/test/scala/game/VoiceHostKillTest.scala b/src/test/scala/game/VoiceHostKillTest.scala
index fa85c2e9d..d499df93e 100644
--- a/src/test/scala/game/VoiceHostKillTest.scala
+++ b/src/test/scala/game/VoiceHostKillTest.scala
@@ -10,7 +10,7 @@ class VoiceHostKillTest extends Specification {
val string_kill = hex"b1"
"decode" in {
- PacketCoding.DecodePacket(string_kill).require match {
+ PacketCoding.decodePacket(string_kill).require match {
case VoiceHostKill() =>
ok
case _ =>
@@ -20,7 +20,7 @@ class VoiceHostKillTest extends Specification {
"encode" in {
val msg = VoiceHostKill()
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_kill
}
diff --git a/src/test/scala/game/VoiceHostRequestTest.scala b/src/test/scala/game/VoiceHostRequestTest.scala
index 91b65d97a..82ef72a26 100644
--- a/src/test/scala/game/VoiceHostRequestTest.scala
+++ b/src/test/scala/game/VoiceHostRequestTest.scala
@@ -11,7 +11,7 @@ class VoiceHostRequestTest extends Specification {
val string_request = hex"b0 2580 00"
"decode" in {
- PacketCoding.DecodePacket(string_request).require match {
+ PacketCoding.decodePacket(string_request).require match {
case VoiceHostRequest(unk, player, _) =>
unk mustEqual false
player mustEqual PlanetSideGUID(75)
@@ -22,7 +22,7 @@ class VoiceHostRequestTest extends Specification {
"encode" in {
val msg = VoiceHostRequest(false, PlanetSideGUID(75), ByteVector.empty)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_request
}
diff --git a/src/test/scala/game/WarpgateRequestTest.scala b/src/test/scala/game/WarpgateRequestTest.scala
index 3eb21b8f0..9bf45f0cb 100644
--- a/src/test/scala/game/WarpgateRequestTest.scala
+++ b/src/test/scala/game/WarpgateRequestTest.scala
@@ -11,7 +11,7 @@ class WarpgateRequestTest extends Specification {
val string = hex"A4 1D00 1F00 1327 1F00 00 00" //an Extinction warp gate to a Desolation warp gate
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case WarpgateRequest(continent_guid, building_guid, dest_building_guid, dest_continent_guid, unk1, unk2) =>
continent_guid mustEqual PlanetSideGUID(29)
building_guid mustEqual PlanetSideGUID(31)
@@ -25,7 +25,7 @@ class WarpgateRequestTest extends Specification {
}
"encode" in {
val msg = WarpgateRequest(PlanetSideGUID(29), PlanetSideGUID(31), PlanetSideGUID(10003), PlanetSideGUID(31), 0, 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/WeaponDelayFireMessageTest.scala b/src/test/scala/game/WeaponDelayFireMessageTest.scala
index 263414480..1fa361d1e 100644
--- a/src/test/scala/game/WeaponDelayFireMessageTest.scala
+++ b/src/test/scala/game/WeaponDelayFireMessageTest.scala
@@ -11,7 +11,7 @@ class WeaponDelayFireMessageTest extends Specification {
val string = hex"88 A3140000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case WeaponDelayFireMessage(seq_time, weapon_guid) =>
seq_time mustEqual 163
weapon_guid mustEqual PlanetSideGUID(80)
@@ -22,7 +22,7 @@ class WeaponDelayFireMessageTest extends Specification {
"encode" in {
val msg = WeaponDelayFireMessage(163, PlanetSideGUID(80))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/WeaponDryFireMessageTest.scala b/src/test/scala/game/WeaponDryFireMessageTest.scala
index 76be093c3..b4be724c2 100644
--- a/src/test/scala/game/WeaponDryFireMessageTest.scala
+++ b/src/test/scala/game/WeaponDryFireMessageTest.scala
@@ -11,7 +11,7 @@ class WeaponDryFireMessageTest extends Specification {
val string = hex"52 4C00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case WeaponDryFireMessage(weapon_guid) =>
weapon_guid mustEqual PlanetSideGUID(76)
case _ =>
@@ -21,7 +21,7 @@ class WeaponDryFireMessageTest extends Specification {
"encode" in {
val msg = WeaponDryFireMessage(PlanetSideGUID(76))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/WeaponFireMessageTest.scala b/src/test/scala/game/WeaponFireMessageTest.scala
index 7304a52d6..6548dbb85 100644
--- a/src/test/scala/game/WeaponFireMessageTest.scala
+++ b/src/test/scala/game/WeaponFireMessageTest.scala
@@ -11,7 +11,7 @@ class WeaponFireMessageTest extends Specification {
val string = hex"34 44130029272F0B5DFD4D4EC5C00009BEF78172003FC0"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case WeaponFireMessage(
seq_time,
weapon_guid,
@@ -55,7 +55,7 @@ class WeaponFireMessageTest extends Specification {
0,
None
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/WeaponJammedMessageTest.scala b/src/test/scala/game/WeaponJammedMessageTest.scala
index 273a117ae..e6f6063e4 100644
--- a/src/test/scala/game/WeaponJammedMessageTest.scala
+++ b/src/test/scala/game/WeaponJammedMessageTest.scala
@@ -11,7 +11,7 @@ class WeaponJammedMessageTest extends Specification {
val string = hex"66 4C00"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case WeaponJammedMessage(weapon_guid) =>
weapon_guid mustEqual PlanetSideGUID(76)
case _ =>
@@ -21,7 +21,7 @@ class WeaponJammedMessageTest extends Specification {
"encode" in {
val msg = WeaponJammedMessage(PlanetSideGUID(76))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/WeaponLazeTargetPositionMessageTest.scala b/src/test/scala/game/WeaponLazeTargetPositionMessageTest.scala
index a4f1df7a6..4de018b1b 100644
--- a/src/test/scala/game/WeaponLazeTargetPositionMessageTest.scala
+++ b/src/test/scala/game/WeaponLazeTargetPositionMessageTest.scala
@@ -11,7 +11,7 @@ class WeaponLazeTargetPositionMessageTest extends Specification {
val string = hex"C8 4C00 6C2D7 65535 CA16 982D7 4A535 CA16"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case WeaponLazeTargetPositionMessage(weapon_uid, pos1, pos2) =>
weapon_uid mustEqual PlanetSideGUID(76)
pos1.x mustEqual 3674.8438f
@@ -31,7 +31,7 @@ class WeaponLazeTargetPositionMessageTest extends Specification {
Vector3(3674.8438f, 2726.789f, 91.15625f),
Vector3(3675.1875f, 2726.5781f, 91.15625f)
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/WeatherMessageTest.scala b/src/test/scala/game/WeatherMessageTest.scala
index 23da1d137..67476c37c 100644
--- a/src/test/scala/game/WeatherMessageTest.scala
+++ b/src/test/scala/game/WeatherMessageTest.scala
@@ -12,7 +12,7 @@ class WeatherMessageTest extends Specification {
hex"9501000000004A0807C0D65B8FBF2427663F178608BE0B000000006CE13E0C390E3F64445CB7BF3E0C2FF23DA46264A3193FBA522E3F597D9A96093F95B99E3D0800096FE53E6CD6523F39198EAF683F9BA0363D01009C35503F9E5F3E3F3C304E46F23EF9668E3E6B56C8277F3FB084F33EB6C10291423FB17F663F00008C077F3E3135D03E320A"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case WeatherMessage(clouds, storms) =>
clouds.size mustEqual 1
clouds.head.id mustEqual 0
@@ -99,7 +99,7 @@ class WeatherMessageTest extends Specification {
StormInfo(Vector3(0.24905223f, 0.40665582f, 0.0f), 50, 10) ::
Nil
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
diff --git a/src/test/scala/game/ZipLineMessageTest.scala b/src/test/scala/game/ZipLineMessageTest.scala
index 25e405a65..dccdf651d 100644
--- a/src/test/scala/game/ZipLineMessageTest.scala
+++ b/src/test/scala/game/ZipLineMessageTest.scala
@@ -11,7 +11,7 @@ class ZipLineMessageTest extends Specification {
val string = hex"BF 4B00 19 80000010 5bb4089c 52116881 cf76e840"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ZipLineMessage(player_guid, origin_side, action, uid, pos) =>
player_guid mustEqual PlanetSideGUID(75)
origin_side mustEqual false
@@ -28,7 +28,7 @@ class ZipLineMessageTest extends Specification {
"encode" in {
val msg = ZipLineMessage(PlanetSideGUID(75), false, 0, 204, Vector3(1286.9221f, 1116.5276f, 91.74034f))
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ZoneForcedCavernConnectionsMessageTest.scala b/src/test/scala/game/ZoneForcedCavernConnectionsMessageTest.scala
index 29a364ea3..acc74db71 100644
--- a/src/test/scala/game/ZoneForcedCavernConnectionsMessageTest.scala
+++ b/src/test/scala/game/ZoneForcedCavernConnectionsMessageTest.scala
@@ -10,7 +10,7 @@ class ZoneForcedCavernConnectionsMessageTest extends Specification {
val string = hex"E3200040"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ZoneForcedCavernConnectionsMessage(zone, unk) =>
zone mustEqual 32
unk mustEqual 1
@@ -21,7 +21,7 @@ class ZoneForcedCavernConnectionsMessageTest extends Specification {
"encode" in {
val msg = ZoneForcedCavernConnectionsMessage(32, 1)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ZoneInfoMessageTest.scala b/src/test/scala/game/ZoneInfoMessageTest.scala
index ad161e52f..812926d6a 100644
--- a/src/test/scala/game/ZoneInfoMessageTest.scala
+++ b/src/test/scala/game/ZoneInfoMessageTest.scala
@@ -11,7 +11,7 @@ class ZoneInfoMessageTest extends Specification {
val string_cavern = hex"C6 1B 00 1D F9 F3 00 00"
"decode (normal)" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ZoneInfoMessage(zone, empire_status, unk) =>
zone mustEqual 12
empire_status mustEqual true
@@ -22,7 +22,7 @@ class ZoneInfoMessageTest extends Specification {
}
"decode (cavern)" in {
- PacketCoding.DecodePacket(string_cavern).require match {
+ PacketCoding.decodePacket(string_cavern).require match {
case ZoneInfoMessage(zone, empire_status, unk) =>
zone mustEqual 27
empire_status mustEqual false
@@ -34,14 +34,14 @@ class ZoneInfoMessageTest extends Specification {
"encode (normal)" in {
val msg = ZoneInfoMessage(12, true, 0)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (cavern)" in {
val msg = ZoneInfoMessage(27, false, 15135547)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_cavern
}
diff --git a/src/test/scala/game/ZoneLockInfoMesageTest.scala b/src/test/scala/game/ZoneLockInfoMesageTest.scala
index a4238a38d..6cfdd0dff 100644
--- a/src/test/scala/game/ZoneLockInfoMesageTest.scala
+++ b/src/test/scala/game/ZoneLockInfoMesageTest.scala
@@ -10,7 +10,7 @@ class ZoneLockInfoMesageTest extends Specification {
val string = hex"DF 1B 00 40"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ZoneLockInfoMessage(zone, locked, unk) =>
zone mustEqual 27
locked mustEqual false
@@ -22,7 +22,7 @@ class ZoneLockInfoMesageTest extends Specification {
"encode" in {
val msg = ZoneLockInfoMessage(27, false, true)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/ZonePopulationUpdateMessageTest.scala b/src/test/scala/game/ZonePopulationUpdateMessageTest.scala
index 5a4784e89..a74462504 100644
--- a/src/test/scala/game/ZonePopulationUpdateMessageTest.scala
+++ b/src/test/scala/game/ZonePopulationUpdateMessageTest.scala
@@ -10,7 +10,7 @@ class ZonePopulationUpdateMessageTest extends Specification {
val string = hex"B6 0400 9E010000 8A000000 25000000 8A000000 25000000 8A000000 25000000 8A000000 25000000"
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ZonePopulationUpdateMessage(
continent_guid,
zone_queue,
@@ -40,7 +40,7 @@ class ZonePopulationUpdateMessageTest extends Specification {
"encode" in {
val msg = ZonePopulationUpdateMessage(4, 414, 138, 37, 138, 37, 138, 37, 138, 37)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/objectcreate/AegisShieldGeneratorDataTest.scala b/src/test/scala/game/objectcreate/AegisShieldGeneratorDataTest.scala
index a301f90e5..6745c33a9 100644
--- a/src/test/scala/game/objectcreate/AegisShieldGeneratorDataTest.scala
+++ b/src/test/scala/game/objectcreate/AegisShieldGeneratorDataTest.scala
@@ -13,7 +13,7 @@ class AegisShieldGeneratorDataTest extends Specification {
"AegisShieldGeneratorData" should {
"decode" in {
- PacketCoding.DecodePacket(string_aegis).require match {
+ PacketCoding.decodePacket(string_aegis).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 272
cls mustEqual ObjectClass.deployable_shield_generator
@@ -53,7 +53,7 @@ class AegisShieldGeneratorDataTest extends Specification {
255
)
val msg = ObjectCreateMessage(ObjectClass.deployable_shield_generator, PlanetSideGUID(2556), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_aegis
}
}
diff --git a/src/test/scala/game/objectcreate/CaptureFlagDataTest.scala b/src/test/scala/game/objectcreate/CaptureFlagDataTest.scala
index 0fec7e4f4..5855f3a27 100644
--- a/src/test/scala/game/objectcreate/CaptureFlagDataTest.scala
+++ b/src/test/scala/game/objectcreate/CaptureFlagDataTest.scala
@@ -14,7 +14,7 @@ class CaptureFlagDataTest extends Specification {
"CaptureFlagData" in {
"decode" in {
- PacketCoding.DecodePacket(string_captureflag).require match {
+ PacketCoding.decodePacket(string_captureflag).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 229
cls mustEqual ObjectClass.capture_flag
@@ -48,7 +48,7 @@ class CaptureFlagDataTest extends Specification {
9
)
val msg = ObjectCreateMessage(ObjectClass.capture_flag, PlanetSideGUID(4330), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_captureflag
}
}
diff --git a/src/test/scala/game/objectcreate/CharacterDataTest.scala b/src/test/scala/game/objectcreate/CharacterDataTest.scala
index 4afca1c2b..840abcf6f 100644
--- a/src/test/scala/game/objectcreate/CharacterDataTest.scala
+++ b/src/test/scala/game/objectcreate/CharacterDataTest.scala
@@ -23,7 +23,7 @@ class CharacterDataTest extends Specification {
"CharacterData" should {
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 1907
cls mustEqual ObjectClass.avatar
@@ -145,7 +145,7 @@ class CharacterDataTest extends Specification {
}
//
"decode (seated)" in {
- PacketCoding.DecodePacket(string_seated).require match {
+ PacketCoding.decodePacket(string_seated).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 1795
cls mustEqual ObjectClass.avatar
@@ -210,7 +210,7 @@ class CharacterDataTest extends Specification {
}
"decode (backpack)" in {
- PacketCoding.DecodePacket(string_backpack).require match {
+ PacketCoding.decodePacket(string_backpack).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 924L
cls mustEqual ObjectClass.avatar
@@ -399,7 +399,7 @@ class CharacterDataTest extends Specification {
val obj = PlayerData(pos, app, char, inv, DrawnSlot.Rifle1)
val msg = ObjectCreateMessage(ObjectClass.avatar, PlanetSideGUID(3902), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
@@ -511,7 +511,7 @@ class CharacterDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(1234), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_seated
}
@@ -589,7 +589,7 @@ class CharacterDataTest extends Specification {
val obj = PlayerData(pos, app, char, DrawnSlot.Pistol1)
val msg = ObjectCreateMessage(ObjectClass.avatar, PlanetSideGUID(3380), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
//granular test
val pkt_bitv = pkt.toBitVector
val ori_bitv = string_backpack.toBitVector
diff --git a/src/test/scala/game/objectcreate/CommonFieldDataTest.scala b/src/test/scala/game/objectcreate/CommonFieldDataTest.scala
index 95070b793..9c255a7fb 100644
--- a/src/test/scala/game/objectcreate/CommonFieldDataTest.scala
+++ b/src/test/scala/game/objectcreate/CommonFieldDataTest.scala
@@ -15,7 +15,7 @@ object CommonFieldDataTest extends Specification {
"AmmoBoxData" should {
"decode (shotgun shells, dropped)" in {
- PacketCoding.DecodePacket(string_shotgunshell_dropped).require match {
+ PacketCoding.decodePacket(string_shotgunshell_dropped).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 165
cls mustEqual ObjectClass.shotgun_shell
@@ -54,14 +54,14 @@ object CommonFieldDataTest extends Specification {
CommonFieldData()(false)
)
val msg = ObjectCreateMessage(ObjectClass.shotgun_shell, PlanetSideGUID(3453), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_shotgunshell_dropped
}
}
"TerminalData" should {
"decode (implant interface)" in {
- PacketCoding.DecodePacket(string_implant_interface).require match {
+ PacketCoding.decodePacket(string_implant_interface).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 108
cls mustEqual 0x199
@@ -76,7 +76,7 @@ object CommonFieldDataTest extends Specification {
}
"decode (order terminal a)" in {
- PacketCoding.DecodePacket(string_order_terminala).require match {
+ PacketCoding.decodePacket(string_order_terminala).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 165
cls mustEqual ObjectClass.order_terminala
@@ -100,7 +100,7 @@ object CommonFieldDataTest extends Specification {
"encode (implant interface)" in {
val obj = CommonFieldData(PlanetSideEmpire.VS)(false)
val msg = ObjectCreateMessage(0x199, PlanetSideGUID(1075), ObjectCreateMessageParent(PlanetSideGUID(514), 1), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_implant_interface
}
@@ -110,7 +110,7 @@ object CommonFieldDataTest extends Specification {
CommonFieldData(PlanetSideEmpire.NC)(false)
)
val msg = ObjectCreateMessage(ObjectClass.order_terminala, PlanetSideGUID(3827), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_order_terminala
}
diff --git a/src/test/scala/game/objectcreate/CommonFieldDataWithPlacementTest.scala b/src/test/scala/game/objectcreate/CommonFieldDataWithPlacementTest.scala
index 5833a32c3..dd5a89fde 100644
--- a/src/test/scala/game/objectcreate/CommonFieldDataWithPlacementTest.scala
+++ b/src/test/scala/game/objectcreate/CommonFieldDataWithPlacementTest.scala
@@ -13,7 +13,7 @@ class CommonFieldDataWithPlacementTest extends Specification {
"Boomer" should {
"decode" in {
- PacketCoding.DecodePacket(string_boomer).require match {
+ PacketCoding.decodePacket(string_boomer).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 165
cls mustEqual ObjectClass.boomer
@@ -51,7 +51,7 @@ class CommonFieldDataWithPlacementTest extends Specification {
CommonFieldData(PlanetSideEmpire.TR, false, false, false, None, false, Some(false), None, PlanetSideGUID(8290))
)
val msg = ObjectCreateMessage(ObjectClass.boomer, PlanetSideGUID(3840), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_boomer
}
}
diff --git a/src/test/scala/game/objectcreate/HandheldDataTest.scala b/src/test/scala/game/objectcreate/HandheldDataTest.scala
index 6337fc672..fa99c00ed 100644
--- a/src/test/scala/game/objectcreate/HandheldDataTest.scala
+++ b/src/test/scala/game/objectcreate/HandheldDataTest.scala
@@ -14,7 +14,7 @@ class HandheldDataTest extends Specification {
"ACE" should {
"decode (held)" in {
- PacketCoding.DecodePacket(string_ace_held).require match {
+ PacketCoding.decodePacket(string_ace_held).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 118
cls mustEqual ObjectClass.ace
@@ -42,7 +42,7 @@ class HandheldDataTest extends Specification {
}
"decode (dropped)" in {
- PacketCoding.DecodePacket(string_ace_dropped).require match {
+ PacketCoding.decodePacket(string_ace_dropped).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 175
cls mustEqual ObjectClass.ace
@@ -84,7 +84,7 @@ class HandheldDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(3336), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ace_held
}
@@ -96,7 +96,7 @@ class HandheldDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.ace, PlanetSideGUID(4388), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ace_dropped
}
}
@@ -105,7 +105,7 @@ class HandheldDataTest extends Specification {
"Telepad" should {
"decode" in {
- PacketCoding.DecodePacket(string_telepad).require match {
+ PacketCoding.decodePacket(string_telepad).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 134
cls mustEqual ObjectClass.router_telepad
@@ -142,7 +142,7 @@ class HandheldDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(430), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_telepad
}
@@ -152,7 +152,7 @@ class HandheldDataTest extends Specification {
"Boomer Trigger" should {
"decode" in {
- PacketCoding.DecodePacket(string_boomertrigger).require match {
+ PacketCoding.decodePacket(string_boomertrigger).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 118
cls mustEqual ObjectClass.boomer_trigger
@@ -189,7 +189,7 @@ class HandheldDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(4272), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_boomertrigger
}
}
@@ -199,7 +199,7 @@ class HandheldDataTest extends Specification {
"Command Detonater" should {
"decode (held)" in {
- PacketCoding.DecodePacket(string_detonater_held).require match {
+ PacketCoding.decodePacket(string_detonater_held).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 118
cls mustEqual ObjectClass.command_detonater
@@ -227,7 +227,7 @@ class HandheldDataTest extends Specification {
}
"decode (dropped)" in {
- PacketCoding.DecodePacket(string_detonater_dropped).require match {
+ PacketCoding.decodePacket(string_detonater_dropped).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 175
cls mustEqual ObjectClass.command_detonater
@@ -268,7 +268,7 @@ class HandheldDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(4149), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_detonater_held
}
@@ -280,7 +280,7 @@ class HandheldDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.command_detonater, PlanetSideGUID(3682), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_detonater_dropped
}
}
diff --git a/src/test/scala/game/objectcreate/LockerContainerDataTest.scala b/src/test/scala/game/objectcreate/LockerContainerDataTest.scala
index 239f5dce1..1562c8f6d 100644
--- a/src/test/scala/game/objectcreate/LockerContainerDataTest.scala
+++ b/src/test/scala/game/objectcreate/LockerContainerDataTest.scala
@@ -14,7 +14,7 @@ class LockerContainerDataTest extends Specification {
"LockerContainerData" should {
"decode" in {
- PacketCoding.DecodePacket(string_locker_container).require match {
+ PacketCoding.decodePacket(string_locker_container).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 431
cls mustEqual ObjectClass.locker_container
@@ -92,7 +92,7 @@ class LockerContainerDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.locker_container, PlanetSideGUID(3148), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_locker_container
}
}
diff --git a/src/test/scala/game/objectcreate/OneMannedFieldTurretDataTest.scala b/src/test/scala/game/objectcreate/OneMannedFieldTurretDataTest.scala
index cc01167a7..b812d7df9 100644
--- a/src/test/scala/game/objectcreate/OneMannedFieldTurretDataTest.scala
+++ b/src/test/scala/game/objectcreate/OneMannedFieldTurretDataTest.scala
@@ -14,7 +14,7 @@ class OneMannedFieldTurretDataTest extends Specification {
"OneMannedFieldTurretData" should {
"decode (orion)" in {
- PacketCoding.DecodePacket(string_orion).require match {
+ PacketCoding.decodePacket(string_orion).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 350
cls mustEqual ObjectClass.portable_manned_turret_vs
@@ -140,7 +140,7 @@ class OneMannedFieldTurretDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.portable_manned_turret_vs, PlanetSideGUID(2916), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_orion
}
}
diff --git a/src/test/scala/game/objectcreate/REKDataTest.scala b/src/test/scala/game/objectcreate/REKDataTest.scala
index 552e58505..44241978b 100644
--- a/src/test/scala/game/objectcreate/REKDataTest.scala
+++ b/src/test/scala/game/objectcreate/REKDataTest.scala
@@ -14,7 +14,7 @@ class REKDataTest extends Specification {
"REKData" should {
"decode (held)" in {
- PacketCoding.DecodePacket(string_rek_held).require match {
+ PacketCoding.decodePacket(string_rek_held).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 134
cls mustEqual ObjectClass.remote_electronics_kit
@@ -44,7 +44,7 @@ class REKDataTest extends Specification {
}
"decode (dropped)" in {
- PacketCoding.DecodePacket(string_rek_dropped).require match {
+ PacketCoding.decodePacket(string_rek_dropped).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 191
cls mustEqual ObjectClass.remote_electronics_kit
@@ -88,7 +88,7 @@ class REKDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(4174), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_rek_held
}
@@ -102,7 +102,7 @@ class REKDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.remote_electronics_kit, PlanetSideGUID(4355), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_rek_dropped
}
}
diff --git a/src/test/scala/game/objectcreate/RemoteProjectileDataTest.scala b/src/test/scala/game/objectcreate/RemoteProjectileDataTest.scala
index b88d3c2af..dc3d062e0 100644
--- a/src/test/scala/game/objectcreate/RemoteProjectileDataTest.scala
+++ b/src/test/scala/game/objectcreate/RemoteProjectileDataTest.scala
@@ -14,7 +14,7 @@ class RemoteProjectileDataTest extends Specification {
"RemoteProjectileData" should {
"decode (striker_missile_targeting_projectile)" in {
- PacketCoding.DecodePacket(string_striker_projectile).require match {
+ PacketCoding.decodePacket(string_striker_projectile).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 197
cls mustEqual ObjectClass.striker_missile_targeting_projectile
@@ -48,7 +48,7 @@ class RemoteProjectileDataTest extends Specification {
}
"decode (hunter_seeker_missile_projectile)" in {
- PacketCoding.DecodePacket(string_hunter_seeker_missile_projectile).require match {
+ PacketCoding.decodePacket(string_hunter_seeker_missile_projectile).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 197
cls mustEqual ObjectClass.hunter_seeker_missile_projectile
@@ -94,7 +94,7 @@ class RemoteProjectileDataTest extends Specification {
0
)
val msg = ObjectCreateMessage(ObjectClass.striker_missile_targeting_projectile, PlanetSideGUID(40192), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
//pkt mustEqual string_striker_projectile
pkt.toBitVector.take(132) mustEqual string_striker_projectile.toBitVector.take(132)
@@ -116,7 +116,7 @@ class RemoteProjectileDataTest extends Specification {
0
)
val msg = ObjectCreateMessage(ObjectClass.hunter_seeker_missile_projectile, PlanetSideGUID(40619), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
//pkt mustEqual string_hunter_seeker_missile_projectile
pkt.toBitVector.take(132) mustEqual string_hunter_seeker_missile_projectile.toBitVector.take(132)
diff --git a/src/test/scala/game/objectcreate/SmallTurretDataTest.scala b/src/test/scala/game/objectcreate/SmallTurretDataTest.scala
index 1c179691d..e5c1e77ed 100644
--- a/src/test/scala/game/objectcreate/SmallTurretDataTest.scala
+++ b/src/test/scala/game/objectcreate/SmallTurretDataTest.scala
@@ -15,7 +15,7 @@ class SmallTurretDataTest extends Specification {
"SmallTurretData" should {
"decode (spitfire, short)" in {
- PacketCoding.DecodePacket(string_spitfire_short).require match {
+ PacketCoding.decodePacket(string_spitfire_short).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 187
cls mustEqual ObjectClass.spitfire_turret
@@ -46,7 +46,7 @@ class SmallTurretDataTest extends Specification {
}
"decode (spitfire)" in {
- PacketCoding.DecodePacket(string_spitfire).require match {
+ PacketCoding.decodePacket(string_spitfire).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 335
cls mustEqual ObjectClass.spitfire_turret
@@ -129,7 +129,7 @@ class SmallTurretDataTest extends Specification {
0
)
val msg = ObjectCreateMessage(ObjectClass.spitfire_turret, PlanetSideGUID(4208), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_spitfire_short
}
@@ -184,7 +184,7 @@ class SmallTurretDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.spitfire_turret, PlanetSideGUID(4265), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_spitfire
}
}
diff --git a/src/test/scala/game/objectcreate/TRAPDataTest.scala b/src/test/scala/game/objectcreate/TRAPDataTest.scala
index cba08bd60..01f2a842c 100644
--- a/src/test/scala/game/objectcreate/TRAPDataTest.scala
+++ b/src/test/scala/game/objectcreate/TRAPDataTest.scala
@@ -13,7 +13,7 @@ class TRAPDataTest extends Specification {
"TRAPData" should {
"decode" in {
- PacketCoding.DecodePacket(string_trap).require match {
+ PacketCoding.decodePacket(string_trap).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 187
cls mustEqual ObjectClass.tank_traps
@@ -50,7 +50,7 @@ class TRAPDataTest extends Specification {
255
)
val msg = ObjectCreateMessage(ObjectClass.tank_traps, PlanetSideGUID(2659), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
val pkt_bitv = pkt.toBitVector
val ori_bitv = string_trap.toBitVector
pkt_bitv.take(173) mustEqual ori_bitv.take(173)
diff --git a/src/test/scala/game/objectcreate/TelepadDeployableDataTest.scala b/src/test/scala/game/objectcreate/TelepadDeployableDataTest.scala
index ac58d661d..2a8446e42 100644
--- a/src/test/scala/game/objectcreate/TelepadDeployableDataTest.scala
+++ b/src/test/scala/game/objectcreate/TelepadDeployableDataTest.scala
@@ -14,7 +14,7 @@ class TelepadDeployableDataTest extends Specification {
"TelepadData" should {
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 200
cls mustEqual ObjectClass.router_telepad_deployable
@@ -78,7 +78,7 @@ class TelepadDeployableDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.router_telepad_deployable, PlanetSideGUID(353), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string
}
diff --git a/src/test/scala/game/objectcreate/WeaponDataTest.scala b/src/test/scala/game/objectcreate/WeaponDataTest.scala
index 7c7197ec6..b7e184b5a 100644
--- a/src/test/scala/game/objectcreate/WeaponDataTest.scala
+++ b/src/test/scala/game/objectcreate/WeaponDataTest.scala
@@ -17,7 +17,7 @@ class WeaponDataTest extends Specification {
"WeaponData" should {
"decode (lasher, held)" in {
- PacketCoding.DecodePacket(string_lasher_held).require match {
+ PacketCoding.decodePacket(string_lasher_held).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 187
cls mustEqual ObjectClass.lasher
@@ -70,7 +70,7 @@ class WeaponDataTest extends Specification {
}
"decode (punisher, held)" in {
- PacketCoding.DecodePacket(string_punisher_held).require match {
+ PacketCoding.decodePacket(string_punisher_held).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 246
cls mustEqual ObjectClass.punisher
@@ -142,7 +142,7 @@ class WeaponDataTest extends Specification {
}
"decode (lasher, dropped)" in {
- PacketCoding.DecodePacket(string_lasher_dropped).require match {
+ PacketCoding.decodePacket(string_lasher_dropped).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 244
cls mustEqual ObjectClass.lasher
@@ -201,7 +201,7 @@ class WeaponDataTest extends Specification {
}
"decode (punisher, dropped)" in {
- PacketCoding.DecodePacket(string_punisher_dropped).require match {
+ PacketCoding.decodePacket(string_punisher_dropped).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 303
cls mustEqual ObjectClass.punisher
@@ -297,7 +297,7 @@ class WeaponDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(4141), 3),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_lasher_held
}
@@ -327,7 +327,7 @@ class WeaponDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(3092), 3),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_punisher_held
}
@@ -341,7 +341,7 @@ class WeaponDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.lasher, PlanetSideGUID(3074), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_lasher_dropped
}
@@ -358,7 +358,7 @@ class WeaponDataTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.punisher, PlanetSideGUID(2978), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_punisher_dropped
}
}
diff --git a/src/test/scala/game/objectcreatedetailed/DetailedAmmoBoxDataTest.scala b/src/test/scala/game/objectcreatedetailed/DetailedAmmoBoxDataTest.scala
index 5ea0a5f03..dcafcf363 100644
--- a/src/test/scala/game/objectcreatedetailed/DetailedAmmoBoxDataTest.scala
+++ b/src/test/scala/game/objectcreatedetailed/DetailedAmmoBoxDataTest.scala
@@ -13,7 +13,7 @@ class DetailedAmmoBoxDataTest extends Specification {
"DetailedAmmoBoxData" should {
"decode (9mm)" in {
- PacketCoding.DecodePacket(string_9mm).require match {
+ PacketCoding.decodePacket(string_9mm).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 124
cls mustEqual ObjectClass.bullet_9mm
@@ -35,7 +35,7 @@ class DetailedAmmoBoxDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(75), 33),
obj
)
- val out = PacketCoding.EncodePacket(msg)
+ val out = PacketCoding.encodePacket(msg)
val pkt = out.require.toByteVector
pkt mustEqual string_9mm
diff --git a/src/test/scala/game/objectcreatedetailed/DetailedCharacterDataTest.scala b/src/test/scala/game/objectcreatedetailed/DetailedCharacterDataTest.scala
index c159bd98c..8b28c1421 100644
--- a/src/test/scala/game/objectcreatedetailed/DetailedCharacterDataTest.scala
+++ b/src/test/scala/game/objectcreatedetailed/DetailedCharacterDataTest.scala
@@ -54,7 +54,7 @@ class DetailedCharacterDataTest extends Specification {
"DetailedCharacterData" should {
"decode" in {
- PacketCoding.DecodePacket(string).require match {
+ PacketCoding.decodePacket(string).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 3159
cls mustEqual ObjectClass.avatar
@@ -244,7 +244,7 @@ class DetailedCharacterDataTest extends Specification {
}
"decode (character, seated)" in {
- PacketCoding.DecodePacket(string_seated).require match {
+ PacketCoding.decodePacket(string_seated).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 3103
cls mustEqual ObjectClass.avatar
@@ -432,7 +432,7 @@ class DetailedCharacterDataTest extends Specification {
}
"decode (max)" in {
- PacketCoding.DecodePacket(string_max).require match {
+ PacketCoding.decodePacket(string_max).require match {
case ObjectCreateDetailedMessage(_, _, _, _, data) =>
//this test is mainly for an alternate bitstream parsing order
//the object produced is massive and most of it is already covered in other tests
@@ -659,7 +659,7 @@ class DetailedCharacterDataTest extends Specification {
}
"decode (BR32)" in {
- PacketCoding.DecodePacket(string_br32).require match {
+ PacketCoding.decodePacket(string_br32).require match {
case ObjectCreateDetailedMessage(_, _, _, _, data) =>
//this test is mainly for an alternate bitstream parsing order
//the object produced is massive and most of it is already covered in other tests
@@ -1179,7 +1179,7 @@ class DetailedCharacterDataTest extends Specification {
}
"decode (ccrider)" in {
- PacketCoding.DecodePacket(string_ccrider).require match {
+ PacketCoding.decodePacket(string_ccrider).require match {
case ObjectCreateDetailedMessage(len, _, _, None, data) =>
len mustEqual 51018L
data match {
@@ -1320,7 +1320,7 @@ class DetailedCharacterDataTest extends Specification {
}
"decode (xRider912)" in {
- PacketCoding.DecodePacket(string_xrider912).require match {
+ PacketCoding.decodePacket(string_xrider912).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parentInfo, data) =>
len mustEqual 36047
cls mustEqual ObjectClass.avatar
@@ -1684,7 +1684,7 @@ class DetailedCharacterDataTest extends Specification {
val obj = DetailedPlayerData.apply(pos, app, char, inv, DrawnSlot.Pistol1)
val msg = ObjectCreateDetailedMessage(0x79, PlanetSideGUID(75), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
val pkt_bitv = pkt.toBitVector
val ori_bitv = string.toBitVector
pkt_bitv.take(724) mustEqual ori_bitv.take(724) //skip 1; this is the highest bit of facingPitch
@@ -1868,7 +1868,7 @@ class DetailedCharacterDataTest extends Specification {
val msg =
ObjectCreateDetailedMessage(0x79, PlanetSideGUID(75), ObjectCreateMessageParent(PlanetSideGUID(43981), 0), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
val pkt_bitv = pkt.toBitVector
val ori_bitv = string_seated.toBitVector
pkt_bitv.take(668) mustEqual ori_bitv.take(668) //skip 1; this is the highest bit of facingPitch
@@ -2089,7 +2089,7 @@ class DetailedCharacterDataTest extends Specification {
val obj = DetailedPlayerData(pos, app, char, inv, DrawnSlot.Pistol1)
val msg = ObjectCreateDetailedMessage(ObjectClass.avatar, PlanetSideGUID(1), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_max
}
@@ -3574,7 +3574,7 @@ class DetailedCharacterDataTest extends Specification {
val obj = DetailedPlayerData(pos, app, char, inv, DrawnSlot.None)
val msg = ObjectCreateDetailedMessage(ObjectClass.avatar, PlanetSideGUID(75), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_br32
}
@@ -4498,7 +4498,7 @@ class DetailedCharacterDataTest extends Specification {
val obj = DetailedPlayerData.apply(pos, app, char, inv, DrawnSlot.None)
val msg = ObjectCreateDetailedMessage(0x79, PlanetSideGUID(75), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ccrider
}
@@ -5723,7 +5723,7 @@ class DetailedCharacterDataTest extends Specification {
val obj = DetailedPlayerData.apply(pos, app, char, inv, DrawnSlot.None)
val msg = ObjectCreateDetailedMessage(0x79, PlanetSideGUID(3390), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
val pkt_bitv = pkt.toBitVector
val ori_bitv = string_xrider912.toBitVector
pkt_bitv.take(140) mustEqual ori_bitv.take(140) //skip 1; this is the highest bit of PlacementData::Orientation::z
diff --git a/src/test/scala/game/objectcreatedetailed/DetailedCommandDetonaterDataTest.scala b/src/test/scala/game/objectcreatedetailed/DetailedCommandDetonaterDataTest.scala
index 239d927ed..a1f00149f 100644
--- a/src/test/scala/game/objectcreatedetailed/DetailedCommandDetonaterDataTest.scala
+++ b/src/test/scala/game/objectcreatedetailed/DetailedCommandDetonaterDataTest.scala
@@ -13,7 +13,7 @@ class DetailedCommandDetonaterDataTest extends Specification {
"DetailedCommandDetonaterData" should {
"decode" in {
- PacketCoding.DecodePacket(string_detonater).require match {
+ PacketCoding.decodePacket(string_detonater).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 135
cls mustEqual ObjectClass.command_detonater
@@ -52,7 +52,7 @@ class DetailedCommandDetonaterDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(3530), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_detonater
}
}
diff --git a/src/test/scala/game/objectcreatedetailed/DetailedConstructionToolDataTest.scala b/src/test/scala/game/objectcreatedetailed/DetailedConstructionToolDataTest.scala
index 56b07814f..2bb745668 100644
--- a/src/test/scala/game/objectcreatedetailed/DetailedConstructionToolDataTest.scala
+++ b/src/test/scala/game/objectcreatedetailed/DetailedConstructionToolDataTest.scala
@@ -16,7 +16,7 @@ class DetailedConstructionToolDataTest extends Specification {
"ACE (detailed)" should {
"decode" in {
- PacketCoding.DecodePacket(string_ace).require match {
+ PacketCoding.decodePacket(string_ace).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 135
cls mustEqual ObjectClass.ace
@@ -53,7 +53,7 @@ class DetailedConstructionToolDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(3104), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ace
}
@@ -61,7 +61,7 @@ class DetailedConstructionToolDataTest extends Specification {
"Boomer Trigger (detailed)" should {
"decode" in {
- PacketCoding.DecodePacket(string_boomer_trigger).require match {
+ PacketCoding.decodePacket(string_boomer_trigger).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 135
cls mustEqual ObjectClass.boomer_trigger
@@ -98,7 +98,7 @@ class DetailedConstructionToolDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(2502), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_boomer_trigger
}
@@ -106,7 +106,7 @@ class DetailedConstructionToolDataTest extends Specification {
"Telepad (detailed)" should {
"decode" in {
- PacketCoding.DecodePacket(string_telepad).require match {
+ PacketCoding.decodePacket(string_telepad).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 151
cls mustEqual ObjectClass.router_telepad
@@ -134,7 +134,7 @@ class DetailedConstructionToolDataTest extends Specification {
}
"decode (short)" in {
- PacketCoding.DecodePacket(string_telepad_short).require match {
+ PacketCoding.decodePacket(string_telepad_short).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 135
cls mustEqual ObjectClass.router_telepad
@@ -171,7 +171,7 @@ class DetailedConstructionToolDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(414), 0),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_telepad
}
@@ -184,7 +184,7 @@ class DetailedConstructionToolDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(340), 9),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_telepad_short
}
diff --git a/src/test/scala/game/objectcreatedetailed/DetailedREKDataTest.scala b/src/test/scala/game/objectcreatedetailed/DetailedREKDataTest.scala
index 1e0f5c9b8..843d81c7e 100644
--- a/src/test/scala/game/objectcreatedetailed/DetailedREKDataTest.scala
+++ b/src/test/scala/game/objectcreatedetailed/DetailedREKDataTest.scala
@@ -13,7 +13,7 @@ class DetailedREKDataTest extends Specification {
"DetailedREKData" should {
"decode" in {
- PacketCoding.DecodePacket(string_rek).require match {
+ PacketCoding.decodePacket(string_rek).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 151
cls mustEqual ObjectClass.remote_electronics_kit
@@ -51,7 +51,7 @@ class DetailedREKDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(75), 1),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_rek
}
diff --git a/src/test/scala/game/objectcreatedetailed/DetailedWeaponDataTest.scala b/src/test/scala/game/objectcreatedetailed/DetailedWeaponDataTest.scala
index c00ba37c9..a0844128e 100644
--- a/src/test/scala/game/objectcreatedetailed/DetailedWeaponDataTest.scala
+++ b/src/test/scala/game/objectcreatedetailed/DetailedWeaponDataTest.scala
@@ -14,7 +14,7 @@ class DetailedWeaponDataTest extends Specification {
"DetailedWeaponData" should {
"decode (gauss)" in {
- PacketCoding.DecodePacket(string_gauss).require match {
+ PacketCoding.decodePacket(string_gauss).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 220
cls mustEqual ObjectClass.gauss
@@ -55,7 +55,7 @@ class DetailedWeaponDataTest extends Specification {
}
"decode (punisher)" in {
- PacketCoding.DecodePacket(string_punisher).require match {
+ PacketCoding.decodePacket(string_punisher).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 295
cls mustEqual ObjectClass.punisher
@@ -111,7 +111,7 @@ class DetailedWeaponDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(75), 2),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_gauss
}
@@ -141,7 +141,7 @@ class DetailedWeaponDataTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(75), 2),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_punisher
}
diff --git a/src/test/scala/game/objectcreatevehicle/DestroyedVehiclesTest.scala b/src/test/scala/game/objectcreatevehicle/DestroyedVehiclesTest.scala
index 111be72a7..75eb69374 100644
--- a/src/test/scala/game/objectcreatevehicle/DestroyedVehiclesTest.scala
+++ b/src/test/scala/game/objectcreatevehicle/DestroyedVehiclesTest.scala
@@ -13,7 +13,7 @@ class DestroyedVehiclesTest extends Specification {
"Destroyed vehicles" should {
"decode (ams, destroyed)" in {
- PacketCoding.DecodePacket(string_ams_destroyed).require match {
+ PacketCoding.decodePacket(string_ams_destroyed).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 141L
cls mustEqual ObjectClass.ams_destroyed
@@ -35,7 +35,7 @@ class DestroyedVehiclesTest extends Specification {
"encode (ams, destroyed)" in {
val obj = DestroyedVehicleData(PlacementData(3674.0f, 2726.789f, 91.15625f, 0f, 0f, 90.0f))
val msg = ObjectCreateMessage(ObjectClass.ams_destroyed, PlanetSideGUID(4157), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ams_destroyed
}
diff --git a/src/test/scala/game/objectcreatevehicle/MountedVehiclesTest.scala b/src/test/scala/game/objectcreatevehicle/MountedVehiclesTest.scala
index 5d064fd61..7b45ed481 100644
--- a/src/test/scala/game/objectcreatevehicle/MountedVehiclesTest.scala
+++ b/src/test/scala/game/objectcreatevehicle/MountedVehiclesTest.scala
@@ -18,7 +18,7 @@ class MountedVehiclesTest extends Specification {
hex"20e21c0c80c000007722120e81c0000000808063483603000000"
"decode (Scrawny Ronnie's mosquito)" in {
- PacketCoding.DecodePacket(string_mosquito_seated).require match {
+ PacketCoding.decodePacket(string_mosquito_seated).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 1991
cls mustEqual ObjectClass.mosquito
@@ -295,7 +295,7 @@ class MountedVehiclesTest extends Specification {
)
)(VehicleFormat.Variant)
val msg = ObjectCreateMessage(ObjectClass.mosquito, PlanetSideGUID(4308), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_mosquito_seated
}
}
diff --git a/src/test/scala/game/objectcreatevehicle/NonstandardVehiclesTest.scala b/src/test/scala/game/objectcreatevehicle/NonstandardVehiclesTest.scala
index 03b538bb4..894325c67 100644
--- a/src/test/scala/game/objectcreatevehicle/NonstandardVehiclesTest.scala
+++ b/src/test/scala/game/objectcreatevehicle/NonstandardVehiclesTest.scala
@@ -15,7 +15,7 @@ class NonstandardVehiclesTest extends Specification {
"Nonstandard vehicles" should {
"decode (droppod)" in {
- PacketCoding.DecodePacket(string_droppod).require match {
+ PacketCoding.decodePacket(string_droppod).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 193L
cls mustEqual ObjectClass.droppod
@@ -46,7 +46,7 @@ class NonstandardVehiclesTest extends Specification {
}
"decode (shuttle 1)" in {
- PacketCoding.DecodePacket(string_orbital_shuttle_1).require match {
+ PacketCoding.decodePacket(string_orbital_shuttle_1).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 130
cls mustEqual ObjectClass.orbital_shuttle
@@ -63,7 +63,7 @@ class NonstandardVehiclesTest extends Specification {
}
"decode (shuttle 2)" in {
- PacketCoding.DecodePacket(string_orbital_shuttle_2).require match {
+ PacketCoding.decodePacket(string_orbital_shuttle_2).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 195
cls mustEqual ObjectClass.orbital_shuttle
@@ -92,7 +92,7 @@ class NonstandardVehiclesTest extends Specification {
)
)
val msg = ObjectCreateMessage(ObjectClass.droppod, PlanetSideGUID(3595), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_droppod
}
@@ -105,7 +105,7 @@ class NonstandardVehiclesTest extends Specification {
ObjectCreateMessageParent(PlanetSideGUID(786), 3),
obj
)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_orbital_shuttle_1
}
@@ -113,7 +113,7 @@ class NonstandardVehiclesTest extends Specification {
"encode (shuttle 2)" in {
val obj = OrbitalShuttleData(PlacementData(5610.0156f, 4255.258f, 134.1875f, 0f, 0f, 180.0f), PlanetSideEmpire.VS)
val msg = ObjectCreateMessage(ObjectClass.orbital_shuttle, PlanetSideGUID(1127), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_orbital_shuttle_2
}
diff --git a/src/test/scala/game/objectcreatevehicle/NormalVehiclesTest.scala b/src/test/scala/game/objectcreatevehicle/NormalVehiclesTest.scala
index 560b4e6df..c0c3aadda 100644
--- a/src/test/scala/game/objectcreatevehicle/NormalVehiclesTest.scala
+++ b/src/test/scala/game/objectcreatevehicle/NormalVehiclesTest.scala
@@ -18,7 +18,7 @@ class NormalVehiclesTest extends Specification {
"Normal vehicles" should {
"decode (fury)" in {
- PacketCoding.DecodePacket(string_fury).require match {
+ PacketCoding.decodePacket(string_fury).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 336
cls mustEqual ObjectClass.fury
@@ -86,7 +86,7 @@ class NormalVehiclesTest extends Specification {
}
"decode (lightning)" in {
- PacketCoding.DecodePacket(string_lightning).require match {
+ PacketCoding.decodePacket(string_lightning).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 395L
cls mustEqual ObjectClass.lightning
@@ -172,7 +172,7 @@ class NormalVehiclesTest extends Specification {
}
"decode (medium transport)" in {
- PacketCoding.DecodePacket(string_mediumtransport).require match {
+ PacketCoding.decodePacket(string_mediumtransport).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 474L
cls mustEqual ObjectClass.mediumtransport
@@ -342,7 +342,7 @@ class NormalVehiclesTest extends Specification {
)
)(VehicleFormat.Normal)
val msg = ObjectCreateMessage(ObjectClass.fury, PlanetSideGUID(413), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_fury
}
@@ -381,7 +381,7 @@ class NormalVehiclesTest extends Specification {
)
)(VehicleFormat.Normal)
val msg = ObjectCreateMessage(ObjectClass.lightning, PlanetSideGUID(90), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_lightning
}
@@ -441,7 +441,7 @@ class NormalVehiclesTest extends Specification {
)
)(VehicleFormat.Normal)
val msg = ObjectCreateMessage(ObjectClass.mediumtransport, PlanetSideGUID(387), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_mediumtransport
}
diff --git a/src/test/scala/game/objectcreatevehicle/UtilityVehiclesTest.scala b/src/test/scala/game/objectcreatevehicle/UtilityVehiclesTest.scala
index 569f71ba0..b6bec222d 100644
--- a/src/test/scala/game/objectcreatevehicle/UtilityVehiclesTest.scala
+++ b/src/test/scala/game/objectcreatevehicle/UtilityVehiclesTest.scala
@@ -17,7 +17,7 @@ class UtilityVehiclesTest extends Specification {
"Utility vehicles" should {
"decode (ant)" in {
- PacketCoding.DecodePacket(string_ant).require match {
+ PacketCoding.decodePacket(string_ant).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 194L
cls mustEqual ObjectClass.ant
@@ -46,7 +46,7 @@ class UtilityVehiclesTest extends Specification {
}
"decode (ams)" in {
- PacketCoding.DecodePacket(string_ams).require match {
+ PacketCoding.decodePacket(string_ams).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 440L
cls mustEqual ObjectClass.ams
@@ -111,7 +111,7 @@ class UtilityVehiclesTest extends Specification {
None
)(VehicleFormat.Utility)
val msg = ObjectCreateMessage(ObjectClass.ant, PlanetSideGUID(380), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ant
}
@@ -161,7 +161,7 @@ class UtilityVehiclesTest extends Specification {
)
)(VehicleFormat.Utility)
val msg = ObjectCreateMessage(ObjectClass.ams, PlanetSideGUID(4157), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_ams
}
diff --git a/src/test/scala/game/objectcreatevehicle/VariantVehiclesTest.scala b/src/test/scala/game/objectcreatevehicle/VariantVehiclesTest.scala
index a418385a4..cb6be6795 100644
--- a/src/test/scala/game/objectcreatevehicle/VariantVehiclesTest.scala
+++ b/src/test/scala/game/objectcreatevehicle/VariantVehiclesTest.scala
@@ -14,7 +14,7 @@ class VariantVehiclesTest extends Specification {
"Variant vehicles" should {
"decode (switchblade)" in {
- PacketCoding.DecodePacket(string_switchblade).require match {
+ PacketCoding.decodePacket(string_switchblade).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 403L
cls mustEqual ObjectClass.switchblade
@@ -156,7 +156,7 @@ class VariantVehiclesTest extends Specification {
)
)(VehicleFormat.Variant)
val msg = ObjectCreateMessage(ObjectClass.switchblade, PlanetSideGUID(418), obj)
- val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
+ val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_switchblade
}
diff --git a/tools/client/src/main/scala/net/psforever/tools/client/Client.scala b/tools/client/src/main/scala/net/psforever/tools/client/Client.scala
new file mode 100644
index 000000000..712c5861a
--- /dev/null
+++ b/tools/client/src/main/scala/net/psforever/tools/client/Client.scala
@@ -0,0 +1,173 @@
+package net.psforever.tools.client
+
+import java.net.{DatagramPacket, DatagramSocket, InetSocketAddress}
+import java.security.{SecureRandom, Security}
+
+import akka.actor.typed.ActorRef
+import akka.io.Udp
+import enumeratum.{Enum, EnumEntry}
+import net.psforever.packet.{CryptoPacketOpcode, PacketCoding, PlanetSideControlPacket, PlanetSideCryptoPacket, PlanetSideGamePacket, PlanetSidePacket}
+import net.psforever.packet.PacketCoding.CryptoCoding
+import net.psforever.packet.control.{ClientStart, ServerStart}
+import net.psforever.packet.crypto.{ClientChallengeXchg, ServerChallengeXchg}
+import org.bouncycastle.jce.provider.BouncyCastleProvider
+import scodec.{Attempt, Err}
+import scodec.Attempt.{Failure, Successful}
+import scodec.bits._
+
+import scala.concurrent.duration.{DurationInt, FiniteDuration}
+import scala.util.control.Breaks._
+
+object Client {
+ Security.addProvider(new BouncyCastleProvider)
+
+ def main(args: Array[String]): Unit = {
+ val client = new Client("test", "test")
+ client.login(new InetSocketAddress("localhost", 51000))
+ }
+
+ sealed trait ClientState extends EnumEntry
+
+ object ClientState extends Enum[ClientState] {
+
+ case object Disconnected extends ClientState
+ case object WorldSelection extends ClientState
+ case object AvatarSelection extends ClientState
+ case object AvatarCreation extends ClientState
+
+ val values: IndexedSeq[ClientState] = findValues
+
+ }
+}
+
+class Client(username: String, password: String) {
+ import Client._
+
+ private var sequence = 0
+ private def nextSequence = {
+ val r = sequence
+ sequence += 1
+ r
+ }
+
+ private val socket = new DatagramSocket()
+ socket.setSoTimeout(1000)
+ private var host: Option[InetSocketAddress] = None
+ private var ref: Option[ActorRef[Udp.Message]] = None
+ private var crypto: Option[CryptoCoding] = None
+ private val buffer = new Array[Byte](65535)
+ val random = new SecureRandom()
+
+ private var _state: ClientState = ClientState.Disconnected
+ def state: ClientState = _state
+
+ /** Login using given host address */
+ def login(host: InetSocketAddress): Unit = {
+ this.host = Some(host)
+ login()
+ }
+
+ /** Login using given actor ref */
+ /*
+ def login(ref: ActorRef[Udp.Message]): Unit = {
+ this.ref = Some(ref)
+ login()
+ }
+ */
+
+ private def login() = {
+ assert(state == ClientState.Disconnected)
+ var macBuffer: ByteVector = ByteVector.empty
+
+ send(ClientStart(0))]
+ val serverStart = waitFor[ServerStart]().require
+ assert(.clientNonce == 0)
+
+ val time = System.currentTimeMillis()
+ val challenge = randomBytes(12)
+ val p = randomBytes(16)
+ val g = ByteVector(1.toByte).reverse.padTo(16).reverse
+ send(ClientChallengeXchg(time, challenge, p, g))
+
+ val serverKey = waitFor[ServerChallengeXchg]().require.pubKey
+
+ val
+
+ println(res)
+ }
+
+ private def waitFor[T](
+ cryptoState: CryptoPacketOpcode.Type = CryptoPacketOpcode.Ignore,
+ timeout: FiniteDuration = 5.seconds
+ ): Attempt[T] = {
+ val time = System.currentTimeMillis()
+ var res: Attempt[T] = Failure(Err("timeout"))
+ while (res.isFailure && System.currentTimeMillis() - time < timeout.toMillis) {
+ receive(cryptoState) match {
+ case Successful((packet, sequence)) =>
+ packet match {
+ case packet: T => res = Successful(packet)
+ case p =>
+ println(s"receive: ${p}")
+ ()
+ }
+ case Failure(cause) => ???
+
+ }
+ }
+ res
+ }
+
+ def send(packet: PlanetSideControlPacket): Attempt[BitVector] = {
+ send(packet, if (crypto.isDefined) Some(nextSequence) else None, crypto)
+ }
+
+ def send(packet: PlanetSideCryptoPacket): Attempt[BitVector] = {
+ send(packet, Some(nextSequence), crypto)
+ }
+
+ def send(packet: PlanetSideGamePacket): Attempt[BitVector] = {
+ send(packet, Some(nextSequence), crypto)
+ }
+
+ private def send(
+ packet: PlanetSidePacket,
+ sequence: Option[Int],
+ crypto: Option[CryptoCoding]
+ ): Attempt[BitVector] = {
+ PacketCoding.marshalPacket(packet, sequence, crypto) match {
+ case Successful(payload) =>
+ send(payload.toByteArray)
+ Successful(payload)
+ case f: Failure =>
+ f
+ }
+ }
+
+ private def send(payload: Array[Byte]): Unit = {
+ (host, ref) match {
+ case (Some(host), None) =>
+ socket.send(new DatagramPacket(payload, payload.length, host))
+ case (None, Some(ref)) =>
+ // ref ! Udp.Received(ByteString(payload), new InetSocketAddress(socket.getInetAddress, socket.getPort))
+ }
+ }
+
+ private def receive(
+ cryptoState: CryptoPacketOpcode.Type = CryptoPacketOpcode.Ignore
+ ): Attempt[(PlanetSidePacket, Option[Int])] = {
+ try {
+ val p = new DatagramPacket(buffer, buffer.length)
+ socket.receive(p)
+ PacketCoding.unmarshalPacket(ByteVector.view(p.getData), crypto, cryptoState)
+ } catch {
+ case e: Throwable => Failure(Err(e.getMessage))
+ }
+ }
+
+ private def randomBytes(amount: Int): ByteVector = {
+ val array = Array.ofDim[Byte](amount)
+ random.nextBytes(array)
+ ByteVector.view(array)
+ }
+}
diff --git a/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala b/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala
index 950d0cb04..bac910e16 100644
--- a/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala
+++ b/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala
@@ -96,12 +96,9 @@ object DecodePackets {
var linesToSkip = 0
for (line <- lines.drop(1)) {
- breakable {
- if (linesToSkip > 0) {
- linesToSkip -= 1
- break()
- }
-
+ if (linesToSkip > 0) {
+ linesToSkip -= 1
+ } else {
val decodedLine = decodePacket(line.drop(line.lastIndexOf(' ')))
writer.write(s"${shortGcapyString(line)}")
writer.newLine()
@@ -142,10 +139,9 @@ object DecodePackets {
FileUtils.forceDelete(tmpFolder)
}
- /*
- Traverse down any nested packets such as SlottedMetaPacket, MultiPacket and MultiPacketEx and add indent for each layer down
- The number of lines to skip will be returned so duplicate lines following SlottedMetaPackets in the gcapy output can be filtered out
- */
+ /** Traverse down any nested packets such as SlottedMetaPacket, MultiPacket and MultiPacketEx and add indent for each layer down
+ * The number of lines to skip will be returned so duplicate lines following SlottedMetaPackets in the gcapy output can be filtered out
+ */
def recursivelyHandleNestedPacket(decodedLine: String, writer: BufferedWriter, depth: Int = 0): Int = {
if (decodedLine.indexOf("Failed to parse") >= 0) return depth
val regex = "(0x[a-f0-9]+)".r
@@ -190,9 +186,9 @@ object DecodePackets {
}
def decodePacket(hexString: String): String = {
- PacketCoding.DecodePacket(ByteVector.fromValidHex(hexString)) match {
+ PacketCoding.decodePacket(ByteVector.fromValidHex(hexString)) match {
case Successful(value) => value.toString
- case Failure(cause) => cause.toString
+ case Failure(cause) => s"Decoding error '${cause.toString}' for data ${hexString}"
}
}
}