clarifying the fields of this packet; adding working tests; adding WSA match case; reset starting continent back to home3 (my mistake)

This commit is contained in:
FateJH 2017-05-02 08:38:11 -04:00
parent 12d2bdf1bb
commit bdd7d0ec36
3 changed files with 43 additions and 7 deletions

View file

@ -6,11 +6,16 @@ import scodec.Codec
import scodec.codecs._
/**
* Dispatched by the client when its player is done using something.
* The classic example is sifting through backpacks, an exclusive activity that only one player can do at a time.
* Dispatched by the client when its player is done using something.<br>
* <br>
* The common example is sifting through backpacks, an activity that only one player is allowed to do at a time.
* When a backpack is accessed by one player, other players are blocked.
* When the first player is done accessing the backpack, this packet informs the server so other players may be allowed access.
* @param player_guid the player
* @param item_guid the item
*/
final case class UnuseItemMessage(guid1 : PlanetSideGUID,
guid2 : PlanetSideGUID)
final case class UnuseItemMessage(player_guid : PlanetSideGUID,
item_guid : PlanetSideGUID)
extends PlanetSideGamePacket {
type Packet = UnuseItemMessage
def opcode = GamePacketOpcode.UnuseItemMessage
@ -19,7 +24,7 @@ final case class UnuseItemMessage(guid1 : PlanetSideGUID,
object UnuseItemMessage extends Marshallable[UnuseItemMessage] {
implicit val codec : Codec[UnuseItemMessage] = (
("guid1" | PlanetSideGUID.codec) ::
("guid2" | PlanetSideGUID.codec)
("player_guid" | PlanetSideGUID.codec) ::
("item_guid" | PlanetSideGUID.codec)
).as[UnuseItemMessage]
}

View file

@ -0,0 +1,28 @@
// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import scodec.bits._
class UnuseItemMessageTest extends Specification {
val string = hex"26 4B00 340D"
"decode" in {
PacketCoding.DecodePacket(string).require match {
case UnuseItemMessage(player, item) =>
player mustEqual PlanetSideGUID(75)
item mustEqual PlanetSideGUID(3380)
case _ =>
ko
}
}
"encode" in {
val msg = UnuseItemMessage(PlanetSideGUID(75), PlanetSideGUID(3380))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}

View file

@ -190,7 +190,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
log.debug("Object: " + obj)
// LoadMapMessage 13714 in mossy .gcap
// XXX: hardcoded shit
sendResponse(PacketCoding.CreateGamePacket(0, LoadMapMessage("map10","z10",40100,25,true,3770441820L))) //VS Sanctuary
sendResponse(PacketCoding.CreateGamePacket(0, LoadMapMessage("map13","home3",40100,25,true,3770441820L))) //VS Sanctuary
sendResponse(PacketCoding.CreateGamePacket(0, ZonePopulationUpdateMessage(PlanetSideGUID(13), 414, 138, 0, 138, 0, 138, 0, 138, 0)))
sendResponse(PacketCoding.CreateGamePacket(0, objectHex))
@ -355,6 +355,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
sendResponse(PacketCoding.CreateGamePacket(0, GenericObjectStateMsg(object_guid, 16)))
}
case msg @ UnuseItemMessage(player, item) =>
log.info("UnuseItem: " + msg)
case msg @ GenericObjectStateMsg(object_guid, unk1) =>
log.info("GenericObjectState: " + msg)