mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
merge with ChangeShortcutBankMessage
This commit is contained in:
commit
23d4b3f93c
|
|
@ -367,7 +367,7 @@ object GamePacketOpcode extends Enumeration {
|
|||
case 0x27 => noDecoder(ObjectDetachMessage)
|
||||
// 0x28
|
||||
case 0x28 => game.CreateShortcutMessage.decode
|
||||
case 0x29 => noDecoder(ChangeShortcutBankMessage)
|
||||
case 0x29 => game.ChangeShortcutBankMessage.decode
|
||||
case 0x2a => noDecoder(ObjectAttachMessage)
|
||||
case 0x2b => noDecoder(UnknownMessage43)
|
||||
case 0x2c => noDecoder(PlanetsideAttributeMessage)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) 2016 PSForever.net to present
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
|
||||
/**
|
||||
* Switch the set of shortcuts displayed on the HUD's hotbar.<br>
|
||||
* <br>
|
||||
* The hotbar contains eight slots for user shortcuts - medkits, implants, and text macros.
|
||||
* Next to the first slot are up and down arrow buttons with a number.
|
||||
* By progressing through the options available from the arrows, eight sets of eight shortcut slots are revealed.
|
||||
* Which set is visible determines the effect of the respective binding keys (the Function keys) for the hotbar.
|
||||
* Each set is called a "bank," obviously.<br>
|
||||
* <br>
|
||||
* This packet coordinates the bank number both as an upstream and as a downstream packet.
|
||||
* @param player_guid the player
|
||||
* @param bank the shortcut bank (zero-indexed);
|
||||
* 0-7 are the valid banks
|
||||
*/
|
||||
final case class ChangeShortcutBankMessage(player_guid : PlanetSideGUID,
|
||||
bank : Int)
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = ChangeShortcutBankMessage
|
||||
def opcode = GamePacketOpcode.ChangeShortcutBankMessage
|
||||
def encode = ChangeShortcutBankMessage.encode(this)
|
||||
}
|
||||
|
||||
object ChangeShortcutBankMessage extends Marshallable[ChangeShortcutBankMessage] {
|
||||
implicit val codec : Codec[ChangeShortcutBankMessage] = (
|
||||
("player_guid" | PlanetSideGUID.codec) ::
|
||||
("bank" | uint4L)
|
||||
).as[ChangeShortcutBankMessage]
|
||||
}
|
||||
|
|
@ -57,7 +57,13 @@ final case class Shortcut(purpose : Int,
|
|||
* <br>
|
||||
* When `addShortcut` is `true`, the provided `Shortcut` will be defined and attached to the respective hotbar slot indicated by `slot`.
|
||||
* If it is `false`, the given `slot` will be unbound.
|
||||
* Nothing happens if the `slot` selection is invalid.
|
||||
* Nothing happens if the `slot` selection is invalid.<br>
|
||||
* <br>
|
||||
* This packet coordinates the shortcut both as an upstream and as a downstream packet, leaning heavily towards the latter.
|
||||
* An interesting application is that, if the user does not already have a medkit or a medkit shortcut;
|
||||
* but, if he places a medkit in his inventory, the shortcut will be automatically added to his hotbar.
|
||||
* This, in turn, dispatches a packet informing the server.
|
||||
* The prior functionality will rarely be appreciated, however, as players rarely never have their medkit shortcut unbound.
|
||||
* @param player_guid the player
|
||||
* @param slot the hotbar slot number (one-indexed)
|
||||
* @param unk na; always zero?
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ class GamePacketTest extends Specification {
|
|||
shortcut.get.tile mustEqual "shortcut_macro"
|
||||
shortcut.get.effect1 mustEqual "NTU"
|
||||
shortcut.get.effect2 mustEqual "/platoon Incoming NTU spam!"
|
||||
case default =>
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
|
@ -407,6 +407,27 @@ class GamePacketTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"ChangeShortcutBankMessage" should {
|
||||
val string = hex"29 4B00 20"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case ChangeShortcutBankMessage(player_guid, bank) =>
|
||||
player_guid mustEqual PlanetSideGUID(75)
|
||||
bank mustEqual 2
|
||||
case default =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = ChangeShortcutBankMessage(PlanetSideGUID(75), 2)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
||||
"DropItemMessage" should {
|
||||
val string = hex"37 4C00"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue