changing continent id to normal data type in HotSpotUpdate; implementing token logic for HotSpotUpdate in WSA; updating tests

This commit is contained in:
FateJH 2018-03-06 15:27:17 -05:00
parent 4973e8df29
commit 2526f15406
3 changed files with 49 additions and 32 deletions

View file

@ -32,13 +32,13 @@ final case class HotSpotInfo(x : Float,
* <br>
* Exploration:<br>
* What does (zone) priority entail?
* @param continent_guid the zone (continent)
* @param continent_id the zone
* @param priority na
* @param spots a List of HotSpotInfo
*/
final case class HotSpotUpdateMessage(continent_guid : PlanetSideGUID,
final case class HotSpotUpdateMessage(continent_id : Int,
priority : Int,
spots : List[HotSpotInfo] = Nil)
spots : List[HotSpotInfo])
extends PlanetSideGamePacket {
type Packet = HotSpotUpdateMessage
def opcode = GamePacketOpcode.HotSpotUpdateMessage
@ -47,9 +47,9 @@ final case class HotSpotUpdateMessage(continent_guid : PlanetSideGUID,
object HotSpotInfo extends Marshallable[HotSpotInfo] {
/*
the scale is technically not "correct"
the client is looking for a normal 0-8192 value
we are trying to enforce a more modest graphic scale at 128.0f
the client is looking for a normal 0-8192 value where default is 1.0f
we try to enforce a more modest graphic scale where default is 64.0f (arbitrary)
personally, I'd like scale to equal the sprite width in map units but the pulsation makes it hard to apply
*/
implicit val codec : Codec[HotSpotInfo] = {
("x" | newcodecs.q_float(0.0, 8192.0, 20)) ::
@ -60,8 +60,8 @@ object HotSpotInfo extends Marshallable[HotSpotInfo] {
object HotSpotUpdateMessage extends Marshallable[HotSpotUpdateMessage] {
implicit val codec : Codec[HotSpotUpdateMessage] = (
("continent_guid" | PlanetSideGUID.codec) ::
("continent_guid" | uint16L) ::
("priority" | uint4L) ::
("spots" | PacketHelpers.listOfNAligned(longL(8), 4, HotSpotInfo.codec))
("spots" | PacketHelpers.listOfNAligned(longL(12), 0, HotSpotInfo.codec))
).as[HotSpotUpdateMessage]
}

View file

@ -4,17 +4,19 @@ package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types.Vector3
import scodec.bits._
class HotSpotUpdateMessageTest extends Specification {
val stringClear = hex"9F 0500 1 00 0"
val stringOne = hex"9F 0500 1 01 0 00 2E9 00 145 80000 0"
val stringTwo = hex"9F 0500 5 02 0 00 D07 00 8CA 80000 00 BEA 00 4C4 80000"
val stringClear = hex"9F 0500 1 000"
val stringOne = hex"9F 0500 1 010 002E9 00145 80000 0"
val stringTwo = hex"9F 0500 5 020 00D07 008CA 80000 00BEA 004C4 80000"
val stringThree = hex"9F 0A00 4 030 00FC8 00F0A 80000 002E9 00BEA 80000 00FC8 00BEA 80000 0"
"decode (clear)" in {
PacketCoding.DecodePacket(stringClear).require match {
case HotSpotUpdateMessage(continent_guid, unk, spots) =>
continent_guid mustEqual PlanetSideGUID(5)
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 5
unk mustEqual 1
spots.size mustEqual 0
case _ =>
@ -24,13 +26,11 @@ class HotSpotUpdateMessageTest extends Specification {
"decode (one)" in {
PacketCoding.DecodePacket(stringOne).require match {
case HotSpotUpdateMessage(continent_guid, unk, spots) =>
continent_guid mustEqual PlanetSideGUID(5)
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 5
unk mustEqual 1
spots.size mustEqual 1
spots.head.x mustEqual 4700.0f
spots.head.y mustEqual 2600.0f
spots.head.scale mustEqual 64.0f
spots.head mustEqual HotSpotInfo(4700.0f, 2600.0f, 64.0f)
case _ =>
ko
}
@ -38,36 +38,52 @@ class HotSpotUpdateMessageTest extends Specification {
"decode (two)" in {
PacketCoding.DecodePacket(stringTwo).require match {
case HotSpotUpdateMessage(continent_guid, unk, spots) =>
continent_guid mustEqual PlanetSideGUID(5)
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 5
unk mustEqual 5
spots.size mustEqual 2
spots.head.x mustEqual 4000.0f
spots.head.y mustEqual 5400.0f
spots.head.scale mustEqual 64.0f
spots(1).x mustEqual 5500.0f
spots(1).y mustEqual 2200.0f
spots(1).scale mustEqual 64.0f
spots.head mustEqual HotSpotInfo(4000.0f, 5400.0f, 64.0f)
spots(1) mustEqual HotSpotInfo(5500.0f, 2200.0f, 64.0f)
case _ =>
ko
}
}
"decode (three)" in {
PacketCoding.DecodePacket(stringThree).require match {
case HotSpotUpdateMessage(continent_id, unk, spots) =>
continent_id mustEqual 10
unk mustEqual 4
spots.size mustEqual 3
spots.head mustEqual HotSpotInfo(4600.0f, 5600.0f, 64.0f)
spots(1) mustEqual HotSpotInfo(4700.0f, 5500.0f, 64.0f)
spots(2) mustEqual HotSpotInfo(4600.0f, 5500.0f, 64.0f)
case _ =>
ko
}
}
"encode (clear)" in {
val msg = HotSpotUpdateMessage(PlanetSideGUID(5),1)
val msg = HotSpotUpdateMessage(5,1, Nil)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual stringClear
}
"encode (one)" in {
val msg = HotSpotUpdateMessage(PlanetSideGUID(5),1, HotSpotInfo(4700.0f, 2600.0f, 64.0f)::Nil)
val msg = HotSpotUpdateMessage(5,1, List(HotSpotInfo(4700.0f, 2600.0f, 64.0f)))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual stringOne
}
"encode (two)" in {
val msg = HotSpotUpdateMessage(PlanetSideGUID(5),5, HotSpotInfo(4000.0f, 5400.0f, 64.0f)::HotSpotInfo(5500.0f, 2200.0f, 64.0f)::Nil)
val msg = HotSpotUpdateMessage(5,5, List(HotSpotInfo(4000.0f, 5400.0f, 64.0f), HotSpotInfo(5500.0f, 2200.0f, 64.0f)))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual stringTwo
}
"encode (three)" in {
val msg = HotSpotUpdateMessage(10,4, List(HotSpotInfo(4600.0f, 5600.0f, 64.0f), HotSpotInfo(4700.0f, 5500.0f, 64.0f), HotSpotInfo(4600.0f, 5500.0f, 64.0f)))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual stringThree
}
}

View file

@ -979,15 +979,15 @@ class WorldSessionActor extends Actor with MDCContextAware {
case VehicleLoaded(_/*vehicle*/) => ;
//currently being handled by VehicleSpawnPad.LoadVehicle during testing phase
case Zone.ClientInitialization(initZone) =>
val continentNumber = initZone.Number
case Zone.ClientInitialization(zone) =>
val continentNumber = zone.Number
val poplist = LivePlayerList.ZonePopulation(continentNumber, _ => true)
val popTR = poplist.count(_.Faction == PlanetSideEmpire.TR)
val popNC = poplist.count(_.Faction == PlanetSideEmpire.NC)
val popVS = poplist.count(_.Faction == PlanetSideEmpire.VS)
val popBO = poplist.size - popTR - popNC - popVS
initZone.Buildings.foreach({ case(id, building) => initBuilding(continentNumber, id, building) })
zone.Buildings.foreach({ case(id, building) => initBuilding(continentNumber, id, building) })
sendResponse(ZonePopulationUpdateMessage(continentNumber, 414, 138, popTR, 138, popNC, 138, popVS, 138, popBO))
sendResponse(ContinentalLockUpdateMessage(continentNumber, PlanetSideEmpire.NEUTRAL))
//CaptureFlagUpdateMessage()
@ -996,6 +996,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
sendResponse(ZoneInfoMessage(continentNumber, true, 0))
sendResponse(ZoneLockInfoMessage(continentNumber, false, true))
sendResponse(ZoneForcedCavernConnectionsMessage(continentNumber, 0))
sendResponse(HotSpotUpdateMessage(continentNumber, 1, Nil)) //normally set in bulk; should be fine doing per continent
case InterstellarCluster.ClientInitializationComplete(tplayer)=>
//custom