mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 07:24:53 +00:00
comments in class; added a match case in WSA; short test, to at least show a full working sample
This commit is contained in:
parent
3a2d8062bf
commit
5ceded71c1
3 changed files with 42 additions and 5 deletions
|
|
@ -5,9 +5,20 @@ import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacke
|
||||||
import scodec.Codec
|
import scodec.Codec
|
||||||
import scodec.codecs._
|
import scodec.codecs._
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entry regarding a specific target.
|
||||||
|
* @param target_guid the target
|
||||||
|
* @param unk na
|
||||||
|
*/
|
||||||
final case class TargetRequest(target_guid : PlanetSideGUID,
|
final case class TargetRequest(target_guid : PlanetSideGUID,
|
||||||
unk : Boolean)
|
unk : Boolean)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatched by the client when the advanced targeting implant activates to collect status information from the server.<br>
|
||||||
|
* <br>
|
||||||
|
* This packet is answered by a `TargetingInfoMessage` with `List` entries of thed corresponding UIDs.
|
||||||
|
* @param target_list a `List` of targets
|
||||||
|
*/
|
||||||
final case class TargetingImplantRequest(target_list : List[TargetRequest])
|
final case class TargetingImplantRequest(target_list : List[TargetRequest])
|
||||||
extends PlanetSideGamePacket {
|
extends PlanetSideGamePacket {
|
||||||
type Packet = TargetingImplantRequest
|
type Packet = TargetingImplantRequest
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,23 @@ import net.psforever.packet.game._
|
||||||
import scodec.bits._
|
import scodec.bits._
|
||||||
|
|
||||||
class TargetingImplantRequestTest extends Specification {
|
class TargetingImplantRequestTest extends Specification {
|
||||||
val string = hex"b5 41edeb12d4409f0144053f8010541ba91d03df376831b1e26000611041e1107c0209c0"//0510085013d9ffb6720d5b132900003770?
|
val string_single = hex"b5 061016"
|
||||||
|
val string_long = hex"b5 41edeb12d4409f0144053f8010541ba91d03df376831b1e26000611041e1107c0209c0"//0510085013d9ffb6720d5b132900003770?
|
||||||
|
|
||||||
"decode" in {
|
"decode (single)" in {
|
||||||
PacketCoding.DecodePacket(string).require match {
|
PacketCoding.DecodePacket(string_single).require match {
|
||||||
|
case TargetingImplantRequest(target_list) =>
|
||||||
|
target_list.length mustEqual 1
|
||||||
|
//0
|
||||||
|
target_list.head.target_guid mustEqual PlanetSideGUID(1412)
|
||||||
|
target_list.head.unk mustEqual true
|
||||||
|
case _ =>
|
||||||
|
ko
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"decode (long)" in {
|
||||||
|
PacketCoding.DecodePacket(string_long).require match {
|
||||||
case TargetingImplantRequest(target_list) =>
|
case TargetingImplantRequest(target_list) =>
|
||||||
target_list.length mustEqual 16
|
target_list.length mustEqual 16
|
||||||
//0
|
//0
|
||||||
|
|
@ -66,7 +79,17 @@ class TargetingImplantRequestTest extends Specification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode" in {
|
"encode (single)" in {
|
||||||
|
val msg = TargetingImplantRequest(
|
||||||
|
TargetRequest(PlanetSideGUID(1412), true) ::
|
||||||
|
Nil
|
||||||
|
)
|
||||||
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
|
pkt mustEqual string_single
|
||||||
|
}
|
||||||
|
|
||||||
|
"encode (long)" in {
|
||||||
val msg = TargetingImplantRequest(
|
val msg = TargetingImplantRequest(
|
||||||
TargetRequest(PlanetSideGUID(31355), true) ::
|
TargetRequest(PlanetSideGUID(31355), true) ::
|
||||||
TargetRequest(PlanetSideGUID(27273), false) ::
|
TargetRequest(PlanetSideGUID(27273), false) ::
|
||||||
|
|
@ -88,6 +111,6 @@ class TargetingImplantRequestTest extends Specification {
|
||||||
)
|
)
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string
|
pkt mustEqual string_long
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -425,6 +425,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
case msg @ WeaponDryFireMessage(weapon) =>
|
case msg @ WeaponDryFireMessage(weapon) =>
|
||||||
log.info("WeaponDryFireMessage: "+msg)
|
log.info("WeaponDryFireMessage: "+msg)
|
||||||
|
|
||||||
|
case msg @ TargetingImplantRequest(list) =>
|
||||||
|
log.info("TargetingImplantRequest: "+msg)
|
||||||
|
|
||||||
case default => log.error(s"Unhandled GamePacket ${pkt}")
|
case default => log.error(s"Unhandled GamePacket ${pkt}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue