mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-12 23:14:42 +00:00
merge of master and friends-request
This commit is contained in:
commit
3284e1d391
3 changed files with 75 additions and 7 deletions
|
|
@ -454,7 +454,7 @@ object GamePacketOpcode extends Enumeration {
|
||||||
// OPCODES 0x70-7f
|
// OPCODES 0x70-7f
|
||||||
case 0x70 => noDecoder(SquadMemberEvent)
|
case 0x70 => noDecoder(SquadMemberEvent)
|
||||||
case 0x71 => noDecoder(PlatoonEvent)
|
case 0x71 => noDecoder(PlatoonEvent)
|
||||||
case 0x72 => noDecoder(FriendsRequest)
|
case 0x72 => game.FriendsRequest.decode
|
||||||
case 0x73 => game.FriendsResponse.decode
|
case 0x73 => game.FriendsResponse.decode
|
||||||
case 0x74 => noDecoder(TriggerEnvironmentalDamageMessage)
|
case 0x74 => noDecoder(TriggerEnvironmentalDamageMessage)
|
||||||
case 0x75 => noDecoder(TrainingZoneMessage)
|
case 0x75 => noDecoder(TrainingZoneMessage)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// 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._
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage the lists of other players whose names are retained by the given player.<br>
|
||||||
|
* <br>
|
||||||
|
* Players can be remembered by their names and added to a list of remembered names - the "friends list."
|
||||||
|
* They can also be dropped from the list.
|
||||||
|
* A list of "ignored" player names can also be retained.
|
||||||
|
* Ignored players will have their comments stifled in the given player's chat window.
|
||||||
|
* No name will be appended or removed from any list until the response to this packet is received.<br>
|
||||||
|
* <br>
|
||||||
|
* Actions that involve the "remove" functionality will locate the entered name in the local list before dispatching this packet.
|
||||||
|
* A complaint will be logged to the event window if the name is not found.<br>
|
||||||
|
* <br>
|
||||||
|
* Actions:<br>
|
||||||
|
* 0 - display friends list<br>
|
||||||
|
* 1 - add player to friends list<br>
|
||||||
|
* 2 - remove player from friends list<br>
|
||||||
|
* 4 - display ignored player list<br>
|
||||||
|
* 5 - add player to ignored player list<br>
|
||||||
|
* 6 - remove player from ignored player list<br>
|
||||||
|
* <br>
|
||||||
|
* Exploration:<br>
|
||||||
|
* Are action = 3 and action = 7 supposed to do anything?
|
||||||
|
* @param action the purpose of this packet
|
||||||
|
* @param friend the player name that was entered;
|
||||||
|
* blank in certain situations
|
||||||
|
*/
|
||||||
|
final case class FriendsRequest(action : Int,
|
||||||
|
friend : String)
|
||||||
|
extends PlanetSideGamePacket {
|
||||||
|
type Packet = FriendsRequest
|
||||||
|
def opcode = GamePacketOpcode.FriendsRequest
|
||||||
|
def encode = FriendsRequest.encode(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
object FriendsRequest extends Marshallable[FriendsRequest] {
|
||||||
|
implicit val codec : Codec[FriendsRequest] = (
|
||||||
|
("action" | uintL(3)) ::
|
||||||
|
("friend" | PacketHelpers.encodedWideStringAligned(5))
|
||||||
|
).as[FriendsRequest]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -869,8 +869,6 @@ class GamePacketTest extends Specification {
|
||||||
list(3).online mustEqual false
|
list(3).online mustEqual false
|
||||||
list(4).name mustEqual "KurtHectic-G"
|
list(4).name mustEqual "KurtHectic-G"
|
||||||
list(4).online mustEqual false
|
list(4).online mustEqual false
|
||||||
case default =>
|
|
||||||
ko
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -896,10 +894,10 @@ class GamePacketTest extends Specification {
|
||||||
|
|
||||||
"encode (multiple friends)" in {
|
"encode (multiple friends)" in {
|
||||||
val msg = FriendsResponse(0, 0, true, true, Friend("Angello-W", false) ::
|
val msg = FriendsResponse(0, 0, true, true, Friend("Angello-W", false) ::
|
||||||
Friend("thephattphrogg", false) ::
|
Friend("thephattphrogg", false) ::
|
||||||
Friend("Kimpossible12", false) ::
|
Friend("Kimpossible12", false) ::
|
||||||
Friend("Zearthling", false) ::
|
Friend("Zearthling", false) ::
|
||||||
Friend("KurtHectic-G", false) :: Nil)
|
Friend("KurtHectic-G", false) :: Nil)
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual stringManyFriends
|
pkt mustEqual stringManyFriends
|
||||||
|
|
@ -913,6 +911,28 @@ class GamePacketTest extends Specification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"FriendsRequest" should {
|
||||||
|
val string = hex"72 3 0A0 46004A0048004E004300"
|
||||||
|
|
||||||
|
"decode" in {
|
||||||
|
PacketCoding.DecodePacket(string).require match {
|
||||||
|
case FriendsRequest(action, friend) =>
|
||||||
|
action mustEqual 1
|
||||||
|
friend.length mustEqual 5
|
||||||
|
friend mustEqual "FJHNC"
|
||||||
|
case default =>
|
||||||
|
ko
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"encode" in {
|
||||||
|
val msg = FriendsRequest(1, "FJHNC")
|
||||||
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
|
pkt mustEqual string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
"WeaponDryFireMessage" should {
|
"WeaponDryFireMessage" should {
|
||||||
val string = hex"52 4C00"
|
val string = hex"52 4C00"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue