mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 07:24:53 +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
3 changed files with 54 additions and 17 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) 2017 PSForever
|
// Copyright (c) 2017 PSForever
|
||||||
package net.psforever.packet.game
|
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.Codec
|
||||||
import scodec.codecs._
|
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
|
* Is sent by the server when the client has performed an action from a menu item
|
||||||
* (i.e create character, delete character, etc...)
|
* (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 {
|
extends PlanetSideGamePacket {
|
||||||
type Packet = ActionResultMessage
|
type Packet = ActionResultMessage
|
||||||
def opcode = GamePacketOpcode.ActionResultMessage
|
def opcode = GamePacketOpcode.ActionResultMessage
|
||||||
|
|
@ -18,6 +19,14 @@ final case class ActionResultMessage(successfull : Boolean, errorCode : Option[L
|
||||||
}
|
}
|
||||||
|
|
||||||
object ActionResultMessage extends Marshallable[ActionResultMessage] {
|
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] = (
|
implicit val codec : Codec[ActionResultMessage] = (
|
||||||
("successful" | bool) >>:~ { res =>
|
("successful" | bool) >>:~ { res =>
|
||||||
// if not successful, look for an error code
|
// if not successful, look for an error code
|
||||||
|
|
|
||||||
|
|
@ -7,27 +7,54 @@ import net.psforever.packet.game._
|
||||||
import scodec.bits._
|
import scodec.bits._
|
||||||
|
|
||||||
class ActionResultMessageTest extends Specification {
|
class ActionResultMessageTest extends Specification {
|
||||||
"decode" in {
|
val string_pass = hex"1f 80"
|
||||||
PacketCoding.DecodePacket(hex"1f 80").require match {
|
val string_fail = hex"1f 0080000000"
|
||||||
case ActionResultMessage(okay, code) =>
|
|
||||||
okay === true
|
|
||||||
code === None
|
|
||||||
case _ =>
|
|
||||||
ko
|
|
||||||
}
|
|
||||||
|
|
||||||
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) =>
|
case ActionResultMessage(okay, code) =>
|
||||||
okay === false
|
okay mustEqual true
|
||||||
code === Some(1)
|
code mustEqual None
|
||||||
case _ =>
|
case _ =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode" in {
|
"decode (fail)" in {
|
||||||
PacketCoding.EncodePacket(ActionResultMessage(true, None)).require.toByteVector === hex"1f 80"
|
PacketCoding.DecodePacket(string_fail).require match {
|
||||||
PacketCoding.EncodePacket(ActionResultMessage(false, Some(1))).require.toByteVector ===
|
case ActionResultMessage(okay, code) =>
|
||||||
(hex"1f".bits ++ bin"0" ++ hex"01000000".bits).toByteVector
|
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
|
definition.Packet.DetailedConstructorData(item).get
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
sendResponse(ActionResultMessage())
|
||||||
if(tplayer.VisibleSlots.contains(slot)) {
|
if(tplayer.VisibleSlots.contains(slot)) {
|
||||||
avatarService ! AvatarServiceMessage(tplayer.Continent, AvatarAction.EquipmentInHand(player_guid, player_guid, slot, item))
|
avatarService ! AvatarServiceMessage(tplayer.Continent, AvatarAction.EquipmentInHand(player_guid, player_guid, slot, item))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue