changing continent id to normal data types and away from PlanetSideGUID in DensityLevelUpdate, ZoneInfo, and ZoneLockInfo; implementing better init ZoneInfo, ZoneLockInfo, and ZonePopulationUpdate packets in WSA

This commit is contained in:
FateJH 2018-03-04 22:19:56 -05:00
parent 3965437116
commit b61097a22d
7 changed files with 32 additions and 26 deletions

View file

@ -12,8 +12,8 @@ import shapeless.{::, HNil}
* @param building_id the building
* @param density na
*/
final case class DensityLevelUpdateMessage(zone_id : PlanetSideGUID,
building_id : PlanetSideGUID,
final case class DensityLevelUpdateMessage(zone_id : Int,
building_id : Int,
density : List[Int])
extends PlanetSideGamePacket {
type Packet = DensityLevelUpdateMessage
@ -23,8 +23,8 @@ final case class DensityLevelUpdateMessage(zone_id : PlanetSideGUID,
object DensityLevelUpdateMessage extends Marshallable[DensityLevelUpdateMessage] {
implicit val codec : Codec[DensityLevelUpdateMessage] = (
("zone_id" | PlanetSideGUID.codec) ::
("building_id" | PlanetSideGUID.codec) ::
("zone_id" | uint16L) ::
("building_id" | uint16L) ::
("density" | PacketHelpers.listOfNSized(8, uint(3)))
).exmap[DensityLevelUpdateMessage] (
{

View file

@ -14,7 +14,7 @@ import scodec.codecs._
* @param unk na;
* usually `true`
*/
final case class ZoneLockInfoMessage(zone : PlanetSideGUID,
final case class ZoneLockInfoMessage(zone : Int,
lock_status : Boolean,
unk : Boolean)
extends PlanetSideGamePacket {
@ -25,7 +25,7 @@ final case class ZoneLockInfoMessage(zone : PlanetSideGUID,
object ZoneLockInfoMessage extends Marshallable[ZoneLockInfoMessage] {
implicit val codec : Codec[ZoneLockInfoMessage] = (
("zone" | PlanetSideGUID.codec) ::
("zone" | uint16L) ::
("lock_status" | bool) ::
("unk" | bool)
).as[ZoneLockInfoMessage]

View file

@ -32,7 +32,7 @@ import scodec.codecs._
* Sanctuary zones possess strange queue values that are occasionally zero'd.
* They do not have a lock icon and may not limit populations the same way as normal zones.
*
* @param continent_guid identifies the zone (continent)
* @param zone_id the continent
* @param zone_queue the maximum population of all three (four) empires that can join this zone
* @param tr_queue the maximum number of TR players that can join this zone
* @param tr_pop the current TR population in this zone
@ -43,7 +43,7 @@ import scodec.codecs._
* @param bo_queue the maximum number of Black OPs players that can join this zone
* @param bo_pop the current Black OPs population in this zone
*/
final case class ZonePopulationUpdateMessage(continent_guid : PlanetSideGUID,
final case class ZonePopulationUpdateMessage(zone_id : Int,
zone_queue : Long,
tr_queue : Long,
tr_pop : Long,
@ -61,7 +61,7 @@ final case class ZonePopulationUpdateMessage(continent_guid : PlanetSideGUID,
object ZonePopulationUpdateMessage extends Marshallable[ZonePopulationUpdateMessage] {
implicit val codec : Codec[ZonePopulationUpdateMessage] = (
("continent_guid" | PlanetSideGUID.codec) ::
("zone_id" | uint16L) ::
("zone_queue" | uint32L) ::
("tr_queue" | uint32L) :: ("tr_pop" | uint32L) ::
("nc_queue" | uint32L) :: ("nc_pop" | uint32L) ::

View file

@ -12,8 +12,8 @@ class DensityLevelUpdateMessageTest extends Specification {
"decode" in {
PacketCoding.DecodePacket(string).require match {
case DensityLevelUpdateMessage(zone_id, building_id, unk) =>
zone_id mustEqual PlanetSideGUID(1)
building_id mustEqual PlanetSideGUID(19999)
zone_id mustEqual 1
building_id mustEqual 19999
unk.length mustEqual 8
unk.head mustEqual 0
unk(1) mustEqual 0
@ -29,24 +29,24 @@ class DensityLevelUpdateMessageTest extends Specification {
}
"encode" in {
val msg = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0,0, 0,0, 0,0, 0,0))
val msg = DensityLevelUpdateMessage(1, 19999, List(0,0, 0,0, 0,0, 0,0))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (failure; wrong number of list entries)" in {
val msg = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0))
val msg = DensityLevelUpdateMessage(1, 19999, List(0))
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
}
"encode (failure; list number too big)" in {
val msg1 = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0,0, 0,0, 0,0, 0,8))
val msg1 = DensityLevelUpdateMessage(1, 19999, List(0,0, 0,0, 0,0, 0,8))
PacketCoding.EncodePacket(msg1).isSuccessful mustEqual false
}
"encode (failure; list number too small)" in {
val msg1 = DensityLevelUpdateMessage(PlanetSideGUID(1), PlanetSideGUID(19999), List(0,0, 0,0, 0,-1, 0,0))
val msg1 = DensityLevelUpdateMessage(1, 19999, List(0,0, 0,0, 0,-1, 0,0))
PacketCoding.EncodePacket(msg1).isSuccessful mustEqual false
}
}

View file

@ -12,7 +12,7 @@ class ZoneLockInfoMesageTest extends Specification {
"decode" in {
PacketCoding.DecodePacket(string).require match {
case ZoneLockInfoMessage(zone, locked, unk) =>
zone mustEqual PlanetSideGUID(27)
zone mustEqual 27
locked mustEqual false
unk mustEqual true
case _ =>
@ -21,7 +21,7 @@ class ZoneLockInfoMesageTest extends Specification {
}
"encode" in {
val msg = ZoneLockInfoMessage(PlanetSideGUID(27), false, true)
val msg = ZoneLockInfoMessage(27, false, true)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string

View file

@ -12,7 +12,7 @@ class ZonePopulationUpdateMessageTest extends Specification {
"decode" in {
PacketCoding.DecodePacket(string).require match {
case ZonePopulationUpdateMessage(continent_guid, zone_queue, tr_queue, tr_pop, nc_queue, nc_pop, vs_queue, vs_pop, bo_queue, bo_pop) =>
continent_guid mustEqual PlanetSideGUID(4)
continent_guid mustEqual 4
zone_queue mustEqual 414
tr_queue mustEqual 138
tr_pop mustEqual 37
@ -28,7 +28,7 @@ class ZonePopulationUpdateMessageTest extends Specification {
}
"encode" in {
val msg = ZonePopulationUpdateMessage(PlanetSideGUID(4), 414, 138, 37, 138, 37, 138, 37, 138, 37)
val msg = ZonePopulationUpdateMessage(4, 414, 138, 37, 138, 37, 138, 37, 138, 37)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string

View file

@ -980,15 +980,21 @@ class WorldSessionActor extends Actor with MDCContextAware {
//currently being handled by VehicleSpawnPad.LoadVehicle during testing phase
case Zone.ClientInitialization(initZone) =>
val continentNumber = PlanetSideGUID(initZone.Number)
initZone.Buildings.foreach({ case(id, building) => initBuilding(continentNumber, PlanetSideGUID(id), building) })
sendResponse(ZonePopulationUpdateMessage(continentNumber, 414, 138, 0, 138, 0, 138, 0, 138, 0))
val continentNumber = initZone.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) })
sendResponse(ZonePopulationUpdateMessage(continentNumber, 414, 138, popTR, 138, popNC, 138, popVS, 138, popBO))
//ContinentLockUpdateMessage()
//CaptureFlagUpdateMessage()
//VanuModuleUpdateMessage()
//ModuleLimitsMessage()
//ZoneInfoMessage()
//ZoneInfoLockMessage()
sendResponse(ZoneInfoMessage(continentNumber, true, 0))
sendResponse(ZoneLockInfoMessage(continentNumber, false, true))
//ZoneForcedCavernConnectionMessage()
case InterstellarCluster.ClientInitializationComplete(tplayer)=>
@ -3034,10 +3040,10 @@ class WorldSessionActor extends Actor with MDCContextAware {
log.error(s"DeployRequest: $obj can not transition to $state - $reason$mobileShift")
}
def initBuilding(continentNumber : PlanetSideGUID, buildingNumber : PlanetSideGUID, building : Building) : Unit = {
def initBuilding(continentNumber : Int, buildingNumber : Int, building : Building) : Unit = {
sendResponse(
BuildingInfoUpdateMessage(
continentNumber, buildingNumber,
PlanetSideGUID(continentNumber), PlanetSideGUID(buildingNumber),
10,
false,
PlanetSideEmpire.NEUTRAL,