mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-06 13:40:21 +00:00
added DensityLevelUpdateMessage packet and tests; including default packet during initialization phase
This commit is contained in:
parent
77b4890706
commit
3965437116
5 changed files with 103 additions and 4 deletions
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class DensityLevelUpdateMessageTest extends Specification {
|
||||
val string = hex"cd 0100 1f4e 000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case DensityLevelUpdateMessage(zone_id, building_id, unk) =>
|
||||
zone_id mustEqual PlanetSideGUID(1)
|
||||
building_id mustEqual PlanetSideGUID(19999)
|
||||
unk.length mustEqual 8
|
||||
unk.head mustEqual 0
|
||||
unk(1) mustEqual 0
|
||||
unk(2) mustEqual 0
|
||||
unk(3) mustEqual 0
|
||||
unk(4) mustEqual 0
|
||||
unk(5) mustEqual 0
|
||||
unk(6) mustEqual 0
|
||||
unk(7) mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0,0, 0,0, 0,0, 0,0))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
||||
"encode (failure; wrong number of list entries)" in {
|
||||
val msg = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too big)" in {
|
||||
val msg1 = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0,0, 0,0, 0,0, 0,8))
|
||||
PacketCoding.EncodePacket(msg1).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too small)" in {
|
||||
val msg1 = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0,0, 0,0, 0,-1, 0,0))
|
||||
PacketCoding.EncodePacket(msg1).isSuccessful mustEqual false
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue