Packet: GenericObjectStateMsg (#36)

* Add GenericObjectStateMsg packet

* Add GenericObjectStateMsg test

* Add GenericObjectStateMsg handler stub
This commit is contained in:
tfarley 2016-07-25 19:20:58 -07:00 committed by pschord
parent 5b5bf28c52
commit d496fc1c2e
4 changed files with 48 additions and 1 deletions

View file

@ -352,7 +352,7 @@ object GamePacketOpcode extends Enumeration {
case PingMsg => noDecoder(opcode)
case VehicleStateMessage => noDecoder(opcode)
case FrameVehicleStateMessage => noDecoder(opcode)
case GenericObjectStateMsg => noDecoder(opcode)
case GenericObjectStateMsg => game.GenericObjectStateMsg.decode
// OPCODE 30
case ChildObjectStateMessage => noDecoder(opcode)

View file

@ -0,0 +1,21 @@
// Copyright (c) 2016 PSForever.net to present
package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import scodec.Codec
import scodec.codecs._
final case class GenericObjectStateMsg(object_guid : PlanetSideGUID,
state : Long)
extends PlanetSideGamePacket {
type Packet = GenericObjectStateMsg
def opcode = GamePacketOpcode.GenericObjectStateMsg
def encode = GenericObjectStateMsg.encode(this)
}
object GenericObjectStateMsg extends Marshallable[GenericObjectStateMsg] {
implicit val codec : Codec[GenericObjectStateMsg] = (
("object_guid" | PlanetSideGUID.codec) ::
("state" | uint32L)
).as[GenericObjectStateMsg]
}

View file

@ -498,5 +498,26 @@ class GamePacketTest extends Specification {
pkt mustEqual string
}
}
"GenericObjectStateMsg" should {
val string = hex"1D 6401 10000000"
"decode" in {
PacketCoding.DecodePacket(string).require match {
case GenericObjectStateMsg(object_guid, state) =>
object_guid mustEqual PlanetSideGUID(356)
state mustEqual 16
case default =>
ko
}
}
"encode" in {
val msg = GenericObjectStateMsg(PlanetSideGUID(356), 16)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
}
}

View file

@ -197,6 +197,11 @@ class WorldSessionActor extends Actor with MDCContextAware {
// TODO: Not all fields in the response are identical to source in real packet logs (but seems to be ok)
// TODO: Not all incoming UseItemMessage's respond with another UseItemMessage (i.e. doors only send out GenericObjectStateMsg)
sendResponse(PacketCoding.CreateGamePacket(0, UseItemMessage(avatar_guid, unk1, object_guid, unk2, unk3, unk4, unk5, unk6, unk7, unk8, unk9)))
// TODO: This should only actually be sent to doors upon opening; may break non-door items upon use
sendResponse(PacketCoding.CreateGamePacket(0, GenericObjectStateMsg(object_guid, 16)))
case msg @ GenericObjectStateMsg(object_guid, unk1) =>
log.info("GenericObjectState: " + msg)
case default => log.debug(s"Unhandled GamePacket ${pkt}")
}