mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-16 00:44:43 +00:00
Cleaned up warnings
This commit is contained in:
parent
4d87fd2665
commit
2555875d49
1 changed files with 21 additions and 18 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) 2023 PSForever
|
// Copyright (c) 2023 PSForever
|
||||||
package net.psforever.packet.game
|
package net.psforever.packet.game
|
||||||
|
|
||||||
|
import net.psforever.packet.GamePacketOpcode.Type
|
||||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||||
import net.psforever.types.PlanetSideGUID
|
import net.psforever.types.PlanetSideGUID
|
||||||
import scodec.{Attempt, Codec, Err}
|
import scodec.{Attempt, Codec, Err}
|
||||||
|
|
@ -16,9 +17,9 @@ final case class OutfitMembershipRequest(
|
||||||
) extends PlanetSideGamePacket {
|
) extends PlanetSideGamePacket {
|
||||||
type Packet = OutfitMembershipRequest
|
type Packet = OutfitMembershipRequest
|
||||||
|
|
||||||
def opcode = GamePacketOpcode.OutfitMembershipRequest
|
def opcode: Type = GamePacketOpcode.OutfitMembershipRequest
|
||||||
|
|
||||||
def encode = OutfitMembershipRequest.encode(this)
|
def encode: Attempt[BitVector] = OutfitMembershipRequest.encode(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class OutfitAction(val code: Int)
|
abstract class OutfitAction(val code: Int)
|
||||||
|
|
@ -43,7 +44,7 @@ object OutfitAction {
|
||||||
object Codecs {
|
object Codecs {
|
||||||
private val everFailCondition = conditional(included = false, bool)
|
private val everFailCondition = conditional(included = false, bool)
|
||||||
|
|
||||||
val CreateOutfitCodec =
|
val CreateOutfitCodec: Codec[CreateOutfit] =
|
||||||
(PacketHelpers.encodedWideString :: uint4L :: bool :: PacketHelpers.encodedWideString).xmap[CreateOutfit](
|
(PacketHelpers.encodedWideString :: uint4L :: bool :: PacketHelpers.encodedWideString).xmap[CreateOutfit](
|
||||||
{
|
{
|
||||||
case unk2 :: unk3 :: unk4 :: outfit_name :: HNil =>
|
case unk2 :: unk3 :: unk4 :: outfit_name :: HNil =>
|
||||||
|
|
@ -55,7 +56,7 @@ object OutfitAction {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val FormOutfitCodec =
|
val FormOutfitCodec: Codec[FormOutfit] =
|
||||||
(PacketHelpers.encodedWideString :: uint4L :: bool :: PacketHelpers.encodedWideString).xmap[FormOutfit](
|
(PacketHelpers.encodedWideString :: uint4L :: bool :: PacketHelpers.encodedWideString).xmap[FormOutfit](
|
||||||
{
|
{
|
||||||
case unk2 :: unk3 :: unk4 :: outfit_name :: HNil =>
|
case unk2 :: unk3 :: unk4 :: outfit_name :: HNil =>
|
||||||
|
|
@ -67,8 +68,8 @@ object OutfitAction {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val AcceptOutfitCodec =
|
val AcceptOutfitCodec: Codec[AcceptOutfitInvite] =
|
||||||
(PacketHelpers.encodedWideString).xmap[AcceptOutfitInvite](
|
PacketHelpers.encodedWideString.xmap[AcceptOutfitInvite](
|
||||||
{
|
{
|
||||||
case unk2 =>
|
case unk2 =>
|
||||||
AcceptOutfitInvite(unk2)
|
AcceptOutfitInvite(unk2)
|
||||||
|
|
@ -79,8 +80,8 @@ object OutfitAction {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val RejectOutfitCodec =
|
val RejectOutfitCodec: Codec[RejectOutfitInvite] =
|
||||||
(PacketHelpers.encodedWideString).xmap[RejectOutfitInvite](
|
PacketHelpers.encodedWideString.xmap[RejectOutfitInvite](
|
||||||
{
|
{
|
||||||
case unk2 =>
|
case unk2 =>
|
||||||
RejectOutfitInvite(unk2)
|
RejectOutfitInvite(unk2)
|
||||||
|
|
@ -91,7 +92,7 @@ object OutfitAction {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val CancelOutfitCodec =
|
val CancelOutfitCodec: Codec[CancelOutfitInvite] =
|
||||||
(uint16L :: uint16L :: PacketHelpers.encodedWideStringAligned(5)).xmap[CancelOutfitInvite](
|
(uint16L :: uint16L :: PacketHelpers.encodedWideStringAligned(5)).xmap[CancelOutfitInvite](
|
||||||
{
|
{
|
||||||
case unk5 :: unk6 :: outfit_name :: HNil =>
|
case unk5 :: unk6 :: outfit_name :: HNil =>
|
||||||
|
|
@ -108,7 +109,7 @@ object OutfitAction {
|
||||||
* @param action the action behavior code
|
* @param action the action behavior code
|
||||||
* @return a transformation between the action code and the unknown bit data
|
* @return a transformation between the action code and the unknown bit data
|
||||||
*/
|
*/
|
||||||
def unknownCodec(action: Int) =
|
def unknownCodec(action: Int): Codec[Unknown] =
|
||||||
bits.xmap[Unknown](
|
bits.xmap[Unknown](
|
||||||
data => Unknown(action, data),
|
data => Unknown(action, data),
|
||||||
{
|
{
|
||||||
|
|
@ -121,7 +122,7 @@ object OutfitAction {
|
||||||
* @param action the action behavior code
|
* @param action the action behavior code
|
||||||
* @return nothing; always fail
|
* @return nothing; always fail
|
||||||
*/
|
*/
|
||||||
def failureCodec(action: Int) =
|
def failureCodec(action: Int): Codec[OutfitAction] =
|
||||||
everFailCondition.exmap[OutfitAction](
|
everFailCondition.exmap[OutfitAction](
|
||||||
_ => Attempt.failure(Err(s"can not match a codec pattern for decoding $action")),
|
_ => Attempt.failure(Err(s"can not match a codec pattern for decoding $action")),
|
||||||
_ => Attempt.failure(Err(s"can not match a codec pattern for encoding $action"))
|
_ => Attempt.failure(Err(s"can not match a codec pattern for encoding $action"))
|
||||||
|
|
@ -134,17 +135,19 @@ object OutfitMembershipRequest extends Marshallable[OutfitMembershipRequest] {
|
||||||
object RequestType extends Enumeration {
|
object RequestType extends Enumeration {
|
||||||
type Type = Value
|
type Type = Value
|
||||||
|
|
||||||
val Create = Value(0)
|
val Create: RequestType.Value = Value(0)
|
||||||
val Form = Value(1)
|
val Form: RequestType.Value = Value(1)
|
||||||
val Unk2 = Value(2)
|
val Unk2: RequestType.Value = Value(2)
|
||||||
val Accept = Value(3)
|
val Accept: RequestType.Value = Value(3)
|
||||||
val Reject = Value(4)
|
val Reject: RequestType.Value = Value(4)
|
||||||
val Cancel = Value(5)
|
val Cancel: RequestType.Value = Value(5)
|
||||||
|
val Unk6: RequestType.Value = Value(6) // 6 and 7 seen as failed decodes, validity unknown
|
||||||
|
val Unk7: RequestType.Value = Value(7)
|
||||||
|
|
||||||
implicit val codec: Codec[Type] = PacketHelpers.createEnumerationCodec(this, uintL(3))
|
implicit val codec: Codec[Type] = PacketHelpers.createEnumerationCodec(this, uintL(3))
|
||||||
}
|
}
|
||||||
|
|
||||||
def selectFromType(code: Int): Codec[OutfitAction] = {
|
private def selectFromType(code: Int): Codec[OutfitAction] = {
|
||||||
import OutfitAction.Codecs._
|
import OutfitAction.Codecs._
|
||||||
import scala.annotation.switch
|
import scala.annotation.switch
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue