PSF-LoginServer/src/test/scala/game/PlayerStateMessageUpstreamTest.scala

72 lines
1.7 KiB
Scala
Raw Normal View History

2017-03-06 19:30:45 -05:00
// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types.{PlanetSideGUID, Vector3}
import scodec.bits._
class PlayerStateMessageUpstreamTest extends Specification {
val string = hex"BD 4B000 E377BA575B616C640A70004014060110007000000"
"decode" in {
PacketCoding.DecodePacket(string).require match {
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
case PlayerStateMessageUpstream(
avatar_guid,
pos,
vel,
facingYaw,
facingPitch,
facingYawUpper,
seq_time,
unk1,
is_crouching,
is_jumping,
jump_thrust,
is_cloaked,
unk2,
unk3
) =>
avatar_guid mustEqual PlanetSideGUID(75)
pos mustEqual Vector3(3694.1094f, 2735.4531f, 90.84375f)
vel.contains(Vector3(4.375f, 2.59375f, 0.0f)) mustEqual true
facingYaw mustEqual 61.875f
facingPitch mustEqual -8.4375f
facingYawUpper mustEqual 0.0f
seq_time mustEqual 136
2017-04-11 14:03:56 +02:00
unk1 mustEqual 0
is_crouching mustEqual false
2017-04-11 14:03:56 +02:00
is_jumping mustEqual false
jump_thrust mustEqual false
is_cloaked mustEqual false
unk2 mustEqual 112
unk3 mustEqual 0
case _ =>
ko
}
}
"encode" in {
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
val msg = PlayerStateMessageUpstream(
PlanetSideGUID(75),
Vector3(3694.1094f, 2735.4531f, 90.84375f),
Some(Vector3(4.375f, 2.59375f, 0.0f)),
61.875f,
-8.4375f,
0.0f,
136,
0,
false,
false,
false,
false,
112,
0
)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}