mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-04-29 15:55:23 +00:00
adjusted fields for slot numbering of either 8u or 16u index
This commit is contained in:
parent
3cfa08b3cb
commit
ccd3fe0ada
2 changed files with 38 additions and 20 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) 2016 PSForever.net to present
|
// Copyright (c) 2016 PSForever.net to present
|
||||||
package net.psforever.packet.game
|
package net.psforever.packet.game
|
||||||
|
|
||||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
|
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||||
import scodec.Codec
|
import scodec.Codec
|
||||||
import scodec.codecs._
|
import scodec.codecs._
|
||||||
|
|
||||||
|
|
@ -16,29 +16,31 @@ import scodec.codecs._
|
||||||
* This packet is a complementary packet that simulates a lazy TCP-like approach to coordinating item manipulation.
|
* This packet is a complementary packet that simulates a lazy TCP-like approach to coordinating item manipulation.
|
||||||
* In some cases, the client will (appear to) proceed with what it intended to do without waiting for the server to confirm.
|
* In some cases, the client will (appear to) proceed with what it intended to do without waiting for the server to confirm.
|
||||||
* For example, grabbing an item from an inventory position will generate a `MoveItemMessage` that defines "the player's cursor" as a destination.
|
* For example, grabbing an item from an inventory position will generate a `MoveItemMessage` that defines "the player's cursor" as a destination.
|
||||||
* The client will "attach to the player's cursor" without waiting for the `ObjectAttachMessage` from the server which echoes the destination.
|
* The client will "attach to the player's cursor" without waiting for an `ObjectAttachMessage` from the server which echoes the destination.
|
||||||
* The change is observable.
|
* The change is observable.
|
||||||
* Inversely, the client is blocked from detaching the item from "the player's cursor" and putting it back into the inventory on its own.
|
* Inversely, the client is blocked from detaching the item from "the player's cursor" and putting it back into the inventory on its own.
|
||||||
* It waits until it receives an `ObjectAttachMessage` in confirmation.<br>
|
* It waits until it receives an `ObjectAttachMessage` in confirmation.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* Destination codes:<br>
|
* Destination codes:<br>
|
||||||
* `80` is the first pistol slot<br>
|
* `0x80` is the first pistol slot<br>
|
||||||
* `81` is the second pistol slot<br>
|
* `0x81` is the second pistol slot<br>
|
||||||
* `82` is the first rifle slot<br>
|
* `0x82` is the first rifle slot<br>
|
||||||
* `83` is the second rifle slot<br>
|
* `0x83` is the second rifle slot<br>
|
||||||
* `86` is the first entry in the player's inventory<br>
|
* `0x84` is the melee/knife slot<br>
|
||||||
* `00 FA` is a special dest/extra code that "attaches the object to the player's cursor"
|
* `0x86` is the first entry in the player's grid inventory<br>
|
||||||
|
* `0x00FA` is a special dest/extra code that "attaches the object to the player's cursor"<br>
|
||||||
|
* <br>
|
||||||
|
* Exploration:<br>
|
||||||
|
* What is slot `0x85`?
|
||||||
* @param player_guid the player GUID
|
* @param player_guid the player GUID
|
||||||
* @param item_guid the item GUID
|
* @param item_guid the item GUID
|
||||||
* @param dest a codified location within the player's inventory see above
|
* @param slot a codified location within the player's inventory;
|
||||||
* @param extra optional; a special kind of item manipulation; the common one is `FA`
|
* may be 8u (0 is 0x80, to 127) or 16u (128 is 0x0080)
|
||||||
* @see MoveItemMessage
|
* @see MoveItemMessage
|
||||||
* @see ObjectAttachMessage
|
|
||||||
*/
|
*/
|
||||||
final case class ObjectAttachMessage(player_guid : PlanetSideGUID,
|
final case class ObjectAttachMessage(player_guid : PlanetSideGUID,
|
||||||
item_guid : PlanetSideGUID,
|
item_guid : PlanetSideGUID,
|
||||||
dest : Int,
|
slot : Int)
|
||||||
extra : Option[Int])
|
|
||||||
extends PlanetSideGamePacket {
|
extends PlanetSideGamePacket {
|
||||||
type Packet = ObjectAttachMessage
|
type Packet = ObjectAttachMessage
|
||||||
def opcode = GamePacketOpcode.ObjectAttachMessage
|
def opcode = GamePacketOpcode.ObjectAttachMessage
|
||||||
|
|
@ -49,8 +51,6 @@ object ObjectAttachMessage extends Marshallable[ObjectAttachMessage] {
|
||||||
implicit val codec : Codec[ObjectAttachMessage] = (
|
implicit val codec : Codec[ObjectAttachMessage] = (
|
||||||
("player_guid" | PlanetSideGUID.codec) ::
|
("player_guid" | PlanetSideGUID.codec) ::
|
||||||
("item_guid" | PlanetSideGUID.codec) ::
|
("item_guid" | PlanetSideGUID.codec) ::
|
||||||
(("dest" | uint8L) >>:~ { loc =>
|
("slot" | PacketHelpers.encodedStringSize)
|
||||||
conditional(loc == 0, "extra" | uint8L).hlist
|
|
||||||
})
|
|
||||||
).as[ObjectAttachMessage]
|
).as[ObjectAttachMessage]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -303,23 +303,41 @@ class GamePacketTest extends Specification {
|
||||||
val stringToInventory = hex"2A 9F05 D405 86"
|
val stringToInventory = hex"2A 9F05 D405 86"
|
||||||
val stringToCursor = hex"2A 9F05 D405 00FA"
|
val stringToCursor = hex"2A 9F05 D405 00FA"
|
||||||
|
|
||||||
"encode" in {
|
"encode (inventory 1,1)" in {
|
||||||
PacketCoding.DecodePacket(stringToInventory).require match {
|
PacketCoding.DecodePacket(stringToInventory).require match {
|
||||||
case ObjectAttachMessage(player_guid, item_guid, index) =>
|
case ObjectAttachMessage(player_guid, item_guid, index) =>
|
||||||
player_guid mustEqual PlanetSideGUID(1439)
|
player_guid mustEqual PlanetSideGUID(1439)
|
||||||
item_guid mustEqual PlanetSideGUID(1492)
|
item_guid mustEqual PlanetSideGUID(1492)
|
||||||
index mustEqual 134
|
index mustEqual 6
|
||||||
case default =>
|
case default =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"decode" in {
|
"encode (cursor)" in {
|
||||||
val msg = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 134)
|
PacketCoding.DecodePacket(stringToCursor).require match {
|
||||||
|
case ObjectAttachMessage(player_guid, item_guid, index) =>
|
||||||
|
player_guid mustEqual PlanetSideGUID(1439)
|
||||||
|
item_guid mustEqual PlanetSideGUID(1492)
|
||||||
|
index mustEqual 250
|
||||||
|
case default =>
|
||||||
|
ko
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"decode (inventory 1,1)" in {
|
||||||
|
val msg = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 6)
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual stringToInventory
|
pkt mustEqual stringToInventory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"decode (cursor)" in {
|
||||||
|
val msg = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 250)
|
||||||
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
|
pkt mustEqual stringToCursor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"DropItemMessage" should {
|
"DropItemMessage" should {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue