mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-20 02:24:45 +00:00
in an attempt to decipher the pickup sound, it seems every item pickup comes with a 'congratulations' packet
This commit is contained in:
parent
c838ff3168
commit
e2dcf998e0
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
|
||||
|
|
@ -10,7 +10,8 @@ import scodec.codecs._
|
|||
* Is sent by the server when the client has performed an action from a menu item
|
||||
* (i.e create character, delete character, etc...)
|
||||
*/
|
||||
final case class ActionResultMessage(successfull : Boolean, errorCode : Option[Long])
|
||||
final case class ActionResultMessage(successful : Boolean,
|
||||
errorCode : Option[Long])
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = ActionResultMessage
|
||||
def opcode = GamePacketOpcode.ActionResultMessage
|
||||
|
|
@ -18,6 +19,14 @@ final case class ActionResultMessage(successfull : Boolean, errorCode : Option[L
|
|||
}
|
||||
|
||||
object ActionResultMessage extends Marshallable[ActionResultMessage] {
|
||||
def apply() : ActionResultMessage = {
|
||||
ActionResultMessage(true, None)
|
||||
}
|
||||
|
||||
def apply(error : Long) : ActionResultMessage = {
|
||||
ActionResultMessage(false, Some(error))
|
||||
}
|
||||
|
||||
implicit val codec : Codec[ActionResultMessage] = (
|
||||
("successful" | bool) >>:~ { res =>
|
||||
// if not successful, look for an error code
|
||||
|
|
|
|||
|
|
@ -7,27 +7,54 @@ import net.psforever.packet.game._
|
|||
import scodec.bits._
|
||||
|
||||
class ActionResultMessageTest extends Specification {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(hex"1f 80").require match {
|
||||
case ActionResultMessage(okay, code) =>
|
||||
okay === true
|
||||
code === None
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
val string_pass = hex"1f 80"
|
||||
val string_fail = hex"1f 0080000000"
|
||||
|
||||
PacketCoding.DecodePacket((hex"1f".bits ++ bin"0" ++ hex"01000000".bits).toByteVector).require match {
|
||||
"decode (pass)" in {
|
||||
PacketCoding.DecodePacket(string_pass).require match {
|
||||
case ActionResultMessage(okay, code) =>
|
||||
okay === false
|
||||
code === Some(1)
|
||||
okay mustEqual true
|
||||
code mustEqual None
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
PacketCoding.EncodePacket(ActionResultMessage(true, None)).require.toByteVector === hex"1f 80"
|
||||
PacketCoding.EncodePacket(ActionResultMessage(false, Some(1))).require.toByteVector ===
|
||||
(hex"1f".bits ++ bin"0" ++ hex"01000000".bits).toByteVector
|
||||
"decode (fail)" in {
|
||||
PacketCoding.DecodePacket(string_fail).require match {
|
||||
case ActionResultMessage(okay, code) =>
|
||||
okay mustEqual false
|
||||
code mustEqual Some(1)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (pass, full)" in {
|
||||
val msg = ActionResultMessage(true, None)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_pass
|
||||
}
|
||||
|
||||
"encode (pass, minimal)" in {
|
||||
val msg = ActionResultMessage()
|
||||
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
|
||||
|
||||
pkt mustEqual string_fail
|
||||
}
|
||||
|
||||
"encode (fail, minimal)" in {
|
||||
val msg = ActionResultMessage(1)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_fail
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1403,6 +1403,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
definition.Packet.DetailedConstructorData(item).get
|
||||
)
|
||||
)
|
||||
sendResponse(ActionResultMessage())
|
||||
if(tplayer.VisibleSlots.contains(slot)) {
|
||||
avatarService ! AvatarServiceMessage(tplayer.Continent, AvatarAction.EquipmentInHand(player_guid, player_guid, slot, item))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue