mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-04 04:30:21 +00:00
Tuned positioning on player spawned at an AMS; fixed 'AMS' label draw and clear issue by expanding deployment options; modifications to BattlePlanMessage packet
This commit is contained in:
parent
cd91080c9a
commit
e00202e8fb
3 changed files with 72 additions and 38 deletions
|
|
@ -7,6 +7,8 @@ import scodec.{Attempt, Codec, Err}
|
|||
import scodec.codecs._
|
||||
import shapeless.{::, HNil}
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
||||
/**
|
||||
* A `Codec` for the actions that each layer of the diagram performs.
|
||||
* `Style`, `Vertex`, `Action5`, `DrawString`, and `Action7` have additional `DiagramStroke` input data.
|
||||
|
|
@ -152,7 +154,7 @@ final case class BattleDiagramAction(action : DiagramActionCode.Value,
|
|||
*/
|
||||
final case class BattleplanMessage(char_id : Long,
|
||||
player_name : String,
|
||||
zone_id : PlanetSideGUID,
|
||||
zone_id : Int,
|
||||
diagrams : List[BattleDiagramAction])
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = BattleplanMessage
|
||||
|
|
@ -365,11 +367,11 @@ object BattleplanMessage extends Marshallable[BattleplanMessage] {
|
|||
* @param list a `List` of extracted `BattleDiagrams`;
|
||||
* technically, the output
|
||||
*/
|
||||
private def rollDiagramLayers(element : Option[BattleDiagramChain], list : ListBuffer[BattleDiagramAction]) : Unit = {
|
||||
if(element.isEmpty)
|
||||
return
|
||||
list += element.get.diagram
|
||||
rollDiagramLayers(element.get.next, list) //tail call optimization
|
||||
@tailrec private def rollDiagramLayers(element : Option[BattleDiagramChain], list : ListBuffer[BattleDiagramAction]) : Unit = {
|
||||
if(element.nonEmpty) {
|
||||
list += element.get.diagram
|
||||
rollDiagramLayers(element.get.next, list)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -380,17 +382,20 @@ object BattleplanMessage extends Marshallable[BattleplanMessage] {
|
|||
* technically, the output
|
||||
* @return a linked list of `BattleDiagramChain` objects
|
||||
*/
|
||||
private def unrollDiagramLayers(revIter : Iterator[BattleDiagramAction], layers : Option[BattleDiagramChain] = None) : Option[BattleDiagramChain] = {
|
||||
if(!revIter.hasNext)
|
||||
return layers
|
||||
val elem : BattleDiagramAction = revIter.next
|
||||
unrollDiagramLayers(revIter, Some(BattleDiagramChain(elem, layers))) //tail call optimization
|
||||
@tailrec private def unrollDiagramLayers(revIter : Iterator[BattleDiagramAction], layers : Option[BattleDiagramChain] = None) : Option[BattleDiagramChain] = {
|
||||
if(!revIter.hasNext) {
|
||||
layers
|
||||
}
|
||||
else {
|
||||
val elem : BattleDiagramAction = revIter.next
|
||||
unrollDiagramLayers(revIter, Some(BattleDiagramChain(elem, layers)))
|
||||
}
|
||||
}
|
||||
|
||||
implicit val codec : Codec[BattleplanMessage] = (
|
||||
("char_id" | uint32L) ::
|
||||
("player_name" | PacketHelpers.encodedWideString) ::
|
||||
("zone_id" | PlanetSideGUID.codec) ::
|
||||
("zone_id" | uint16L) ::
|
||||
(uint8L >>:~ { count =>
|
||||
conditional(count > 0, "diagrams" | parse_diagrams_codec(count)).hlist
|
||||
})
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class BattleplanMessageTest extends Specification {
|
|||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41490746
|
||||
player_name mustEqual "YetAnotherFailureAlt"
|
||||
zone_id mustEqual PlanetSideGUID(0)
|
||||
zone_id mustEqual 0
|
||||
diagrams.size mustEqual 1
|
||||
//0
|
||||
diagrams.head.action mustEqual DiagramActionCode.StartDrawing
|
||||
|
|
@ -34,7 +34,7 @@ class BattleplanMessageTest extends Specification {
|
|||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41490746
|
||||
player_name mustEqual "YetAnotherFailureAlt"
|
||||
zone_id mustEqual PlanetSideGUID(0)
|
||||
zone_id mustEqual 0
|
||||
diagrams.size mustEqual 1
|
||||
//0
|
||||
diagrams.head.action mustEqual DiagramActionCode.StopDrawing
|
||||
|
|
@ -49,7 +49,7 @@ class BattleplanMessageTest extends Specification {
|
|||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41378949
|
||||
player_name mustEqual "Outstabulous"
|
||||
zone_id mustEqual PlanetSideGUID(10)
|
||||
zone_id mustEqual 10
|
||||
diagrams.size mustEqual 32
|
||||
//0
|
||||
diagrams.head.action mustEqual DiagramActionCode.Vertex
|
||||
|
|
@ -191,7 +191,7 @@ class BattleplanMessageTest extends Specification {
|
|||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41378949
|
||||
player_name mustEqual "Outstabulous"
|
||||
zone_id mustEqual PlanetSideGUID(10)
|
||||
zone_id mustEqual 10
|
||||
diagrams.size mustEqual 3
|
||||
//0
|
||||
diagrams.head.action mustEqual DiagramActionCode.Style
|
||||
|
|
@ -217,7 +217,7 @@ class BattleplanMessageTest extends Specification {
|
|||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41378949
|
||||
player_name mustEqual "Outstabulous"
|
||||
zone_id mustEqual PlanetSideGUID(10)
|
||||
zone_id mustEqual 10
|
||||
diagrams.size mustEqual 1
|
||||
//0
|
||||
diagrams.head.action mustEqual DiagramActionCode.DrawString
|
||||
|
|
@ -237,7 +237,7 @@ class BattleplanMessageTest extends Specification {
|
|||
val msg = BattleplanMessage(
|
||||
41490746,
|
||||
"YetAnotherFailureAlt",
|
||||
PlanetSideGUID(0),
|
||||
0,
|
||||
BattleDiagramAction(DiagramActionCode.StartDrawing) ::
|
||||
Nil
|
||||
)
|
||||
|
|
@ -250,7 +250,7 @@ class BattleplanMessageTest extends Specification {
|
|||
val msg = BattleplanMessage(
|
||||
41490746,
|
||||
"YetAnotherFailureAlt",
|
||||
PlanetSideGUID(0),
|
||||
0,
|
||||
BattleDiagramAction(DiagramActionCode.StopDrawing) ::
|
||||
Nil
|
||||
)
|
||||
|
|
@ -263,7 +263,7 @@ class BattleplanMessageTest extends Specification {
|
|||
val msg = BattleplanMessage(
|
||||
41378949,
|
||||
"Outstabulous",
|
||||
PlanetSideGUID(10),
|
||||
10,
|
||||
BattleDiagramAction.vertex(7512.0f, 6312.0f) ::
|
||||
BattleDiagramAction.vertex(7512.0f, 6328.0f) ::
|
||||
BattleDiagramAction.vertex(7512.0f, 6344.0f) ::
|
||||
|
|
@ -307,7 +307,7 @@ class BattleplanMessageTest extends Specification {
|
|||
val msg = BattleplanMessage(
|
||||
41378949,
|
||||
"Outstabulous",
|
||||
PlanetSideGUID(10),
|
||||
10,
|
||||
BattleDiagramAction.style(3.0f, 2) ::
|
||||
BattleDiagramAction.vertex(7512.0f, 6328.0f) ::
|
||||
BattleDiagramAction.vertex(7512.0f, 6344.0f) ::
|
||||
|
|
@ -322,7 +322,7 @@ class BattleplanMessageTest extends Specification {
|
|||
val msg = BattleplanMessage(
|
||||
41378949,
|
||||
"Outstabulous",
|
||||
PlanetSideGUID(10),
|
||||
10,
|
||||
BattleDiagramAction.drawString(7512.0f, 6312.0f, 2, 0, "Hello Auraxis!") :: Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue