mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-15 16:34:39 +00:00
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:
parent
3965437116
commit
b61097a22d
7 changed files with 32 additions and 26 deletions
|
|
@ -12,8 +12,8 @@ import shapeless.{::, HNil}
|
||||||
* @param building_id the building
|
* @param building_id the building
|
||||||
* @param density na
|
* @param density na
|
||||||
*/
|
*/
|
||||||
final case class DensityLevelUpdateMessage(zone_id : PlanetSideGUID,
|
final case class DensityLevelUpdateMessage(zone_id : Int,
|
||||||
building_id : PlanetSideGUID,
|
building_id : Int,
|
||||||
density : List[Int])
|
density : List[Int])
|
||||||
extends PlanetSideGamePacket {
|
extends PlanetSideGamePacket {
|
||||||
type Packet = DensityLevelUpdateMessage
|
type Packet = DensityLevelUpdateMessage
|
||||||
|
|
@ -23,8 +23,8 @@ final case class DensityLevelUpdateMessage(zone_id : PlanetSideGUID,
|
||||||
|
|
||||||
object DensityLevelUpdateMessage extends Marshallable[DensityLevelUpdateMessage] {
|
object DensityLevelUpdateMessage extends Marshallable[DensityLevelUpdateMessage] {
|
||||||
implicit val codec : Codec[DensityLevelUpdateMessage] = (
|
implicit val codec : Codec[DensityLevelUpdateMessage] = (
|
||||||
("zone_id" | PlanetSideGUID.codec) ::
|
("zone_id" | uint16L) ::
|
||||||
("building_id" | PlanetSideGUID.codec) ::
|
("building_id" | uint16L) ::
|
||||||
("density" | PacketHelpers.listOfNSized(8, uint(3)))
|
("density" | PacketHelpers.listOfNSized(8, uint(3)))
|
||||||
).exmap[DensityLevelUpdateMessage] (
|
).exmap[DensityLevelUpdateMessage] (
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import scodec.codecs._
|
||||||
* @param unk na;
|
* @param unk na;
|
||||||
* usually `true`
|
* usually `true`
|
||||||
*/
|
*/
|
||||||
final case class ZoneLockInfoMessage(zone : PlanetSideGUID,
|
final case class ZoneLockInfoMessage(zone : Int,
|
||||||
lock_status : Boolean,
|
lock_status : Boolean,
|
||||||
unk : Boolean)
|
unk : Boolean)
|
||||||
extends PlanetSideGamePacket {
|
extends PlanetSideGamePacket {
|
||||||
|
|
@ -25,7 +25,7 @@ final case class ZoneLockInfoMessage(zone : PlanetSideGUID,
|
||||||
|
|
||||||
object ZoneLockInfoMessage extends Marshallable[ZoneLockInfoMessage] {
|
object ZoneLockInfoMessage extends Marshallable[ZoneLockInfoMessage] {
|
||||||
implicit val codec : Codec[ZoneLockInfoMessage] = (
|
implicit val codec : Codec[ZoneLockInfoMessage] = (
|
||||||
("zone" | PlanetSideGUID.codec) ::
|
("zone" | uint16L) ::
|
||||||
("lock_status" | bool) ::
|
("lock_status" | bool) ::
|
||||||
("unk" | bool)
|
("unk" | bool)
|
||||||
).as[ZoneLockInfoMessage]
|
).as[ZoneLockInfoMessage]
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import scodec.codecs._
|
||||||
* Sanctuary zones possess strange queue values that are occasionally zero'd.
|
* 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.
|
* 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 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_queue the maximum number of TR players that can join this zone
|
||||||
* @param tr_pop the current TR population in 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_queue the maximum number of Black OPs players that can join this zone
|
||||||
* @param bo_pop the current Black OPs population in 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,
|
zone_queue : Long,
|
||||||
tr_queue : Long,
|
tr_queue : Long,
|
||||||
tr_pop : Long,
|
tr_pop : Long,
|
||||||
|
|
@ -61,7 +61,7 @@ final case class ZonePopulationUpdateMessage(continent_guid : PlanetSideGUID,
|
||||||
|
|
||||||
object ZonePopulationUpdateMessage extends Marshallable[ZonePopulationUpdateMessage] {
|
object ZonePopulationUpdateMessage extends Marshallable[ZonePopulationUpdateMessage] {
|
||||||
implicit val codec : Codec[ZonePopulationUpdateMessage] = (
|
implicit val codec : Codec[ZonePopulationUpdateMessage] = (
|
||||||
("continent_guid" | PlanetSideGUID.codec) ::
|
("zone_id" | uint16L) ::
|
||||||
("zone_queue" | uint32L) ::
|
("zone_queue" | uint32L) ::
|
||||||
("tr_queue" | uint32L) :: ("tr_pop" | uint32L) ::
|
("tr_queue" | uint32L) :: ("tr_pop" | uint32L) ::
|
||||||
("nc_queue" | uint32L) :: ("nc_pop" | uint32L) ::
|
("nc_queue" | uint32L) :: ("nc_pop" | uint32L) ::
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ class DensityLevelUpdateMessageTest extends Specification {
|
||||||
"decode" in {
|
"decode" in {
|
||||||
PacketCoding.DecodePacket(string).require match {
|
PacketCoding.DecodePacket(string).require match {
|
||||||
case DensityLevelUpdateMessage(zone_id, building_id, unk) =>
|
case DensityLevelUpdateMessage(zone_id, building_id, unk) =>
|
||||||
zone_id mustEqual PlanetSideGUID(1)
|
zone_id mustEqual 1
|
||||||
building_id mustEqual PlanetSideGUID(19999)
|
building_id mustEqual 19999
|
||||||
unk.length mustEqual 8
|
unk.length mustEqual 8
|
||||||
unk.head mustEqual 0
|
unk.head mustEqual 0
|
||||||
unk(1) mustEqual 0
|
unk(1) mustEqual 0
|
||||||
|
|
@ -29,24 +29,24 @@ class DensityLevelUpdateMessageTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode" in {
|
"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
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string
|
pkt mustEqual string
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (failure; wrong number of list entries)" in {
|
"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
|
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (failure; list number too big)" in {
|
"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
|
PacketCoding.EncodePacket(msg1).isSuccessful mustEqual false
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (failure; list number too small)" in {
|
"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
|
PacketCoding.EncodePacket(msg1).isSuccessful mustEqual false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@ class ZoneLockInfoMesageTest extends Specification {
|
||||||
"decode" in {
|
"decode" in {
|
||||||
PacketCoding.DecodePacket(string).require match {
|
PacketCoding.DecodePacket(string).require match {
|
||||||
case ZoneLockInfoMessage(zone, locked, unk) =>
|
case ZoneLockInfoMessage(zone, locked, unk) =>
|
||||||
zone mustEqual PlanetSideGUID(27)
|
zone mustEqual 27
|
||||||
locked mustEqual false
|
locked mustEqual false
|
||||||
unk mustEqual true
|
unk mustEqual true
|
||||||
case _ =>
|
case _ =>
|
||||||
|
|
@ -21,7 +21,7 @@ class ZoneLockInfoMesageTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode" in {
|
"encode" in {
|
||||||
val msg = ZoneLockInfoMessage(PlanetSideGUID(27), false, true)
|
val msg = ZoneLockInfoMessage(27, false, true)
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string
|
pkt mustEqual string
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class ZonePopulationUpdateMessageTest extends Specification {
|
||||||
"decode" in {
|
"decode" in {
|
||||||
PacketCoding.DecodePacket(string).require match {
|
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) =>
|
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
|
zone_queue mustEqual 414
|
||||||
tr_queue mustEqual 138
|
tr_queue mustEqual 138
|
||||||
tr_pop mustEqual 37
|
tr_pop mustEqual 37
|
||||||
|
|
@ -28,7 +28,7 @@ class ZonePopulationUpdateMessageTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode" in {
|
"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
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string
|
pkt mustEqual string
|
||||||
|
|
|
||||||
|
|
@ -980,15 +980,21 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
//currently being handled by VehicleSpawnPad.LoadVehicle during testing phase
|
//currently being handled by VehicleSpawnPad.LoadVehicle during testing phase
|
||||||
|
|
||||||
case Zone.ClientInitialization(initZone) =>
|
case Zone.ClientInitialization(initZone) =>
|
||||||
val continentNumber = PlanetSideGUID(initZone.Number)
|
val continentNumber = initZone.Number
|
||||||
initZone.Buildings.foreach({ case(id, building) => initBuilding(continentNumber, PlanetSideGUID(id), building) })
|
val poplist = LivePlayerList.ZonePopulation(continentNumber, _ => true)
|
||||||
sendResponse(ZonePopulationUpdateMessage(continentNumber, 414, 138, 0, 138, 0, 138, 0, 138, 0))
|
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()
|
//ContinentLockUpdateMessage()
|
||||||
//CaptureFlagUpdateMessage()
|
//CaptureFlagUpdateMessage()
|
||||||
//VanuModuleUpdateMessage()
|
//VanuModuleUpdateMessage()
|
||||||
//ModuleLimitsMessage()
|
//ModuleLimitsMessage()
|
||||||
//ZoneInfoMessage()
|
sendResponse(ZoneInfoMessage(continentNumber, true, 0))
|
||||||
//ZoneInfoLockMessage()
|
sendResponse(ZoneLockInfoMessage(continentNumber, false, true))
|
||||||
//ZoneForcedCavernConnectionMessage()
|
//ZoneForcedCavernConnectionMessage()
|
||||||
|
|
||||||
case InterstellarCluster.ClientInitializationComplete(tplayer)=>
|
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")
|
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(
|
sendResponse(
|
||||||
BuildingInfoUpdateMessage(
|
BuildingInfoUpdateMessage(
|
||||||
continentNumber, buildingNumber,
|
PlanetSideGUID(continentNumber), PlanetSideGUID(buildingNumber),
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
PlanetSideEmpire.NEUTRAL,
|
PlanetSideEmpire.NEUTRAL,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue