modified cached guard tests; adjusted list mechanics for SendResponse contents

This commit is contained in:
Fate-JH 2026-06-23 12:03:17 -04:00
parent 3937bb8455
commit 4afe8550c0
25 changed files with 333 additions and 279 deletions

View file

@ -96,6 +96,15 @@ object SessionActor {
final case class SetMode(mode: PlayerMode) extends Command
/**
* Determine if a response handler would process a given reply message, ignoring its guards.
* Treat handlers already ignoring their guards as "determined (will not pass)".
* @see `CommonHandlerFunctions.IgnoreFilter_=`
* @param reply message
* @param handler message handler
* @return `true`, if the response handler will process the response;
* `false`, if the handler is skipped or if it would not process
*/
private def HandlerAcceptingMessageTest(reply: Any)(handler: CommonHandlerFunctions): Boolean = {
if (handler.IgnoreFilter) {
false
@ -417,14 +426,15 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
responseHandler.IgnoreFilter = true
if (!responseHandler.isDefinedAt(reply)) {
//find every handler that might accept the input response, ignoring guard booleans only for the search
//try each discovered handler with the input response
listOfHandlers.filter(SessionActor.HandlerAcceptingMessageTest(reply)) match {
//try each discovered handler against the input response until one works
val test: CommonHandlerFunctions => Boolean = SessionActor.HandlerAcceptingMessageTest(reply)
listOfHandlers.filter(test) match {
case Nil =>
log.error(s"received completely unhandled response message - $envelope for ${envelope.stamp}")
log.error(s"received completely unhandled response message - $reply for ${envelope.stamp}:$toChannel")
case first :: Nil =>
first.handle(toChannel, guid, reply)
first.tryToHandle(reply)
case first :: others =>
first.handle(toChannel, guid, reply) || others.exists(_.handle(toChannel, guid, reply))
first.tryToHandle(reply) || others.exists(_.tryToHandle(reply))
}
}
responseHandler.IgnoreFilter = false

View file

@ -46,13 +46,13 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
def receive: Receive = {
/* special messages */
case AvatarAction.TeardownConnection
if TestFilter(_ => { player.spectator }) =>
if TestFilter(() => { player.spectator }) =>
context.self ! SessionActor.SetMode(CustomerServiceRepresentativeMode)
context.self.forward(GenericResponseEnvelope(AvatarStamp, "", filterGuid, AvatarAction.TeardownConnection))
context.self.forward(GenericResponseEnvelope(AvatarStamp, "", FilterGuid, AvatarAction.TeardownConnection))
case AvatarAction.TeardownConnection =>
context.self ! SessionActor.SetMode(NormalMode)
context.self.forward(GenericResponseEnvelope(AvatarStamp, "", filterGuid, AvatarAction.TeardownConnection))
context.self.forward(GenericResponseEnvelope(AvatarStamp, "", FilterGuid, AvatarAction.TeardownConnection))
/* really common messages (very frequently, every life) */
case pstate @ AvatarAction.PlayerState(
@ -68,9 +68,9 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
isCloaking,
isNotRendered,
canSeeReallyFar
) if TestFilter(_ => isNotSameTarget) =>
) if TestFilter(NotSameTargetTest) =>
val pstateToSave = pstate.copy(timestamp = 0)
val (lastMsg, lastTime, lastPosition, wasVisible, wasShooting) = ops.lastSeenStreamMessage.get(filterGuid.guid) match {
val (lastMsg, lastTime, lastPosition, wasVisible, wasShooting) = ops.lastSeenStreamMessage.get(FilterGuid.guid) match {
case Some(SessionAvatarHandlers.LastUpstream(Some(msg), visible, shooting, time)) => (Some(msg), time, msg.pos, visible, shooting)
case _ => (None, 0L, Vector3.Zero, false, None)
}
@ -113,7 +113,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
//must draw
sendResponse(
PlayerStateMessage(
filterGuid,
FilterGuid,
pos,
vel,
yaw,
@ -126,10 +126,10 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
isCloaking
)
)
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, now))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, now))
} else {
//is visible, but skip reinforcement
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, lastTime))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, lastTime))
}
} else {
//conditions where the target is not currently visible
@ -138,7 +138,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
val lat = (1 + ops.hidingPlayerRandomizer.nextInt(continent.map.scale.height.toInt)).toFloat
sendResponse(
PlayerStateMessage(
filterGuid,
FilterGuid,
Vector3(1f, lat, 1f),
vel=None,
facingYaw=0f,
@ -148,28 +148,28 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
is_cloaked = isCloaking
)
)
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, now))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, now))
} else {
//skip drawing altogether
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, lastTime))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, lastTime))
}
}
case AvatarAction.AvatarImplant(ImplantAction.Add, implant_slot, value)
if TestFilter(_ => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(resolvedGuid, ImplantAction.Add, implant_slot, 7))
if TestFilter(() => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(ResolvedGuid, ImplantAction.Add, implant_slot, 7))
//second wind does not normally load its icon into the shortcut hotbar
avatar
.shortcuts
.zipWithIndex
.find { case (s, _) => s.isEmpty}
.foreach { case (_, index) =>
sendResponse(CreateShortcutMessage(resolvedGuid, index + 1, Some(ImplantType.SecondWind.shortcut)))
sendResponse(CreateShortcutMessage(ResolvedGuid, index + 1, Some(ImplantType.SecondWind.shortcut)))
}
case AvatarAction.AvatarImplant(ImplantAction.Remove, implant_slot, value)
if TestFilter(_ => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(resolvedGuid, ImplantAction.Remove, implant_slot, value))
if TestFilter(() => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(ResolvedGuid, ImplantAction.Remove, implant_slot, value))
//second wind does not normally unload its icon from the shortcut hotbar
val shortcut = {
val imp = ImplantType.SecondWind.shortcut
@ -180,15 +180,15 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
.zipWithIndex
.find { case (s, _) => s.contains(shortcut) }
.foreach { case (_, index) =>
sendResponse(CreateShortcutMessage(resolvedGuid, index + 1, None))
sendResponse(CreateShortcutMessage(ResolvedGuid, index + 1, None))
}
case AvatarAction.AvatarImplant(action, implant_slot, value) =>
sendResponse(AvatarImplantMessage(resolvedGuid, action, implant_slot, value))
sendResponse(AvatarImplantMessage(ResolvedGuid, action, implant_slot, value))
case AvatarAction.ObjectHeld(slot, _)
if TestFilter(_ => { isSameTarget && player.VisibleSlots.contains(slot) }) =>
sendResponse(ObjectHeldMessage(filterGuid, slot, unk1=true))
if TestFilter(() => { SameTarget && player.VisibleSlots.contains(slot) }) =>
sendResponse(ObjectHeldMessage(FilterGuid, slot, unk1=true))
//Stop using proximity terminals if player unholsters a weapon
continent.GUID(sessionLogic.terminals.usingMedicalTerminal).collect {
case term: Terminal with ProximityUnit => sessionLogic.terminals.StopUsingProximityUnit(term)
@ -198,33 +198,33 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
}
case AvatarAction.ObjectHeld(slot, _)
if TestFilter(_ => {isSameTarget && slot > -1 }) =>
sendResponse(ObjectHeldMessage(filterGuid, slot, unk1=true))
if TestFilter(() => {SameTarget && slot > -1 }) =>
sendResponse(ObjectHeldMessage(FilterGuid, slot, unk1=true))
case AvatarAction.ObjectHeld(_, _)
if TestFilter(_ => isSameTarget) => ()
if TestFilter(SameTargetTest) => ()
case AvatarAction.ObjectHeld(_, previousSlot) =>
sendResponse(ObjectHeldMessage(filterGuid, previousSlot, unk1=false))
sendResponse(ObjectHeldMessage(FilterGuid, previousSlot, unk1=false))
case ChangeFireState_Start(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
sendResponse(ChangeFireStateMessage_Start(weaponGuid))
val entry = ops.lastSeenStreamMessage(filterGuid.guid)
ops.lastSeenStreamMessage.put(filterGuid.guid, entry.copy(shooting = Some(weaponGuid)))
val entry = ops.lastSeenStreamMessage(FilterGuid.guid)
ops.lastSeenStreamMessage.put(FilterGuid.guid, entry.copy(shooting = Some(weaponGuid)))
case ChangeFireState_Stop(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { msg => msg.visible || msg.shooting.nonEmpty } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { msg => msg.visible || msg.shooting.nonEmpty } }) =>
sendResponse(ChangeFireStateMessage_Stop(weaponGuid))
val entry = ops.lastSeenStreamMessage(filterGuid.guid)
ops.lastSeenStreamMessage.put(filterGuid.guid, entry.copy(shooting = None))
val entry = ops.lastSeenStreamMessage(FilterGuid.guid)
ops.lastSeenStreamMessage.put(FilterGuid.guid, entry.copy(shooting = None))
case AvatarAction.LoadCreatedPlayer(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.EquipmentCreatedInHand(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.Destroy(victim, killer, weapon, pos) =>
@ -235,7 +235,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sendResponse(ops.destroyDisplayMessage(killer, victim, method, unk))
case AvatarAction.TerminalOrderResult(terminalGuid, action, result)
if TestFilter(_ => { result && (action == TransactionType.Buy || action == TransactionType.Loadout) }) =>
if TestFilter(() => { result && (action == TransactionType.Buy || action == TransactionType.Loadout) }) =>
sendResponse(ItemTransactionResultMessage(terminalGuid, action, result))
sessionLogic.terminals.lastTerminalOrderFulfillment = true
AvatarActor.savePlayerData(player)
@ -257,7 +257,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
inventory,
drop,
delete
) if TestFilter(_ => {resolvedGuid == target }) =>
) if TestFilter(() => {ResolvedGuid == target }) =>
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, attribute_type=4, armor))
//happening to this player
@ -339,7 +339,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
oldInventory,
inventory,
drops
) if TestFilter(_ => { resolvedGuid == target }) =>
) if TestFilter(() => { ResolvedGuid == target }) =>
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, attribute_type=4, armor))
//happening to this player
@ -376,9 +376,9 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
case AvatarAction.UseKit(kguid, kObjId) =>
sendResponse(
UseItemMessage(
resolvedGuid,
ResolvedGuid,
kguid,
resolvedGuid,
ResolvedGuid,
unk2 = 4294967295L,
unk3 = false,
unk4 = Vector3.Zero,
@ -401,7 +401,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
/* common messages (maybe once every respawn) */
case ReloadTool(itemGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
sendResponse(ReloadMessage(itemGuid, ammo_clip=1, unk1=0))
case AvatarAction.Killed(_, mount) =>
@ -412,23 +412,23 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sessionLogic.zoning.zoningStatus = Zoning.Status.None
continent.GUID(mount).collect {
case obj: Vehicle if obj.Destroyed =>
ops.killedWhileMounted(obj, resolvedGuid)
ops.killedWhileMounted(obj, ResolvedGuid)
sessionLogic.vehicles.ConditionalDriverVehicleControl(obj)
sessionLogic.general.unaccessContainer(obj)
case obj: Vehicle =>
ops.killedWhileMounted(obj, resolvedGuid)
ops.killedWhileMounted(obj, ResolvedGuid)
sessionLogic.vehicles.ConditionalDriverVehicleControl(obj)
case obj: PlanetSideGameObject with Mountable with Container if obj.Destroyed =>
ops.killedWhileMounted(obj, resolvedGuid)
ops.killedWhileMounted(obj, ResolvedGuid)
sessionLogic.general.unaccessContainer(obj)
case obj: PlanetSideGameObject with Mountable with Container =>
ops.killedWhileMounted(obj, resolvedGuid)
ops.killedWhileMounted(obj, ResolvedGuid)
case obj: PlanetSideGameObject with Mountable =>
ops.killedWhileMounted(obj, resolvedGuid)
ops.killedWhileMounted(obj, ResolvedGuid)
}
//player state changes
sessionLogic.general.dropSpecialSlotItem()
@ -442,11 +442,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
CustomerServiceRepresentativeMode.renderPlayer(sessionLogic, continent, player)
case AvatarAction.ReleasePlayer(tplayer)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sessionLogic.zoning.spawn.DepictPlayerAsCorpse(tplayer)
case AvatarAction.Revive(revivalTargetGuid)
if TestFilter(_ => { resolvedGuid == revivalTargetGuid }) =>
if TestFilter(() => { ResolvedGuid == revivalTargetGuid }) =>
ops.revive()
player.Actor ! Player.Revive
player.History
@ -461,12 +461,12 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
/* uncommon messages (utility, or once in a while) */
case ChangeAmmo(weapon_guid, weapon_slot, previous_guid, ammo_id, ammo_guid, ammo_data)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
ops.changeAmmoProcedure(weapon_guid, previous_guid, ammo_id, ammo_guid, weapon_slot, ammo_data)
sendResponse(ChangeAmmoMessage(weapon_guid, 1))
case AvatarAction.ChangeFireMode(itemGuid, mode)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ChangeFireModeMessage(itemGuid, mode))
case AvatarAction.EnvironmentalDamage(_, _, _) =>
@ -474,7 +474,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sessionLogic.zoning.CancelZoningProcess()
case AvatarAction.DropCreatedItem(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
/* rare messages */
@ -488,11 +488,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
))
case AvatarAction.LoadCreatedProjectile(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.ProjectileState(projectileGuid, shotPos, shotVel, shotOrient, seq, end, targetGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ProjectileStateMessage(projectileGuid, shotPos, shotVel, shotOrient, seq, end, targetGuid))
case AvatarAction.ProjectileExplodes(projectileGuid, projectile) =>
@ -513,11 +513,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sendResponse(GenericActionMessage(mode))
case AvatarAction.PutDownFDU(target)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(GenericObjectActionMessage(target, code=53))
case AvatarAction.StowEquipment(target, slot, item)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
val definition = item.Definition
sendResponse(
ObjectCreateDetailedMessage(
@ -529,7 +529,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
)
case WeaponDryFire(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
continent.GUID(weaponGuid).collect {
case tool: Tool if tool.Magazine == 0 =>
sendResponse(WeaponDryFireMessage(weaponGuid))

View file

@ -66,9 +66,9 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
isCloaking,
isNotRendered,
canSeeReallyFar
) if TestFilter(_ => isNotSameTarget) =>
) if TestFilter(NotSameTargetTest) =>
val pstateToSave = pstate.copy(timestamp = 0)
val (lastMsg, lastTime, lastPosition, wasVisible, wasShooting) = ops.lastSeenStreamMessage.get(filterGuid.guid) match {
val (lastMsg, lastTime, lastPosition, wasVisible, wasShooting) = ops.lastSeenStreamMessage.get(FilterGuid.guid) match {
case Some(SessionAvatarHandlers.LastUpstream(Some(msg), visible, shooting, time)) => (Some(msg), time, msg.pos, visible, shooting)
case _ => (None, 0L, Vector3.Zero, false, None)
}
@ -111,7 +111,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
//must draw
sendResponse(
PlayerStateMessage(
filterGuid,
FilterGuid,
pos,
vel,
yaw,
@ -124,10 +124,10 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
isCloaking
)
)
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, now))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, now))
} else {
//is visible, but skip reinforcement
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, lastTime))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, lastTime))
}
} else {
//conditions where the target is not currently visible
@ -136,7 +136,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
val lat = (1 + ops.hidingPlayerRandomizer.nextInt(continent.map.scale.height.toInt)).toFloat
sendResponse(
PlayerStateMessage(
filterGuid,
FilterGuid,
Vector3(1f, lat, 1f),
vel=None,
facingYaw=0f,
@ -146,28 +146,28 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
is_cloaked = isCloaking
)
)
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, now))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, now))
} else {
//skip drawing altogether
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, lastTime))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, lastTime))
}
}
case AvatarAction.AvatarImplant(ImplantAction.Add, implant_slot, value)
if TestFilter(_ => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(resolvedGuid, ImplantAction.Add, implant_slot, 7))
if TestFilter(() => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(ResolvedGuid, ImplantAction.Add, implant_slot, 7))
//second wind does not normally load its icon into the shortcut hotbar
avatar
.shortcuts
.zipWithIndex
.find { case (s, _) => s.isEmpty}
.foreach { case (_, index) =>
sendResponse(CreateShortcutMessage(resolvedGuid, index + 1, Some(ImplantType.SecondWind.shortcut)))
sendResponse(CreateShortcutMessage(ResolvedGuid, index + 1, Some(ImplantType.SecondWind.shortcut)))
}
case AvatarAction.AvatarImplant(ImplantAction.Remove, implant_slot, value)
if TestFilter(_ => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(resolvedGuid, ImplantAction.Remove, implant_slot, value))
if TestFilter(() => { value == ImplantType.SecondWind.value }) =>
sendResponse(AvatarImplantMessage(ResolvedGuid, ImplantAction.Remove, implant_slot, value))
//second wind does not normally unload its icon from the shortcut hotbar
val shortcut = {
val imp = ImplantType.SecondWind.shortcut
@ -178,15 +178,15 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
.zipWithIndex
.find { case (s, _) => s.contains(shortcut) }
.foreach { case (_, index) =>
sendResponse(CreateShortcutMessage(resolvedGuid, index + 1, None))
sendResponse(CreateShortcutMessage(ResolvedGuid, index + 1, None))
}
case AvatarAction.AvatarImplant(action, implant_slot, value) =>
sendResponse(AvatarImplantMessage(resolvedGuid, action, implant_slot, value))
sendResponse(AvatarImplantMessage(ResolvedGuid, action, implant_slot, value))
case AvatarAction.ObjectHeld(slot, _)
if TestFilter(_ => { isSameTarget && player.VisibleSlots.contains(slot) }) =>
sendResponse(ObjectHeldMessage(filterGuid, slot, unk1=true))
if TestFilter(() => { SameTarget && player.VisibleSlots.contains(slot) }) =>
sendResponse(ObjectHeldMessage(FilterGuid, slot, unk1=true))
//Stop using proximity terminals if player unholsters a weapon
continent.GUID(sessionLogic.terminals.usingMedicalTerminal).collect {
case term: Terminal with ProximityUnit => sessionLogic.terminals.StopUsingProximityUnit(term)
@ -196,37 +196,37 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
}
case AvatarAction.ObjectHeld(slot, _)
if TestFilter(_ => { isSameTarget && slot > -1 }) =>
sendResponse(ObjectHeldMessage(filterGuid, slot, unk1=true))
if TestFilter(() => { SameTarget && slot > -1 }) =>
sendResponse(ObjectHeldMessage(FilterGuid, slot, unk1=true))
case AvatarAction.ObjectHeld(_, _)
if TestFilter(_ => isSameTarget) => ()
if TestFilter(SameTargetTest) => ()
case AvatarAction.ObjectHeld(_, previousSlot) =>
sendResponse(ObjectHeldMessage(filterGuid, previousSlot, unk1=false))
sendResponse(ObjectHeldMessage(FilterGuid, previousSlot, unk1=false))
case ChangeFireState_Start(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
sendResponse(ChangeFireStateMessage_Start(weaponGuid))
val entry = ops.lastSeenStreamMessage(filterGuid.guid)
ops.lastSeenStreamMessage.put(filterGuid.guid, entry.copy(shooting = Some(weaponGuid)))
val entry = ops.lastSeenStreamMessage(FilterGuid.guid)
ops.lastSeenStreamMessage.put(FilterGuid.guid, entry.copy(shooting = Some(weaponGuid)))
case ChangeFireState_Stop(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { msg => msg.visible || msg.shooting.nonEmpty } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { msg => msg.visible || msg.shooting.nonEmpty } }) =>
sendResponse(ChangeFireStateMessage_Stop(weaponGuid))
val entry = ops.lastSeenStreamMessage(filterGuid.guid)
ops.lastSeenStreamMessage.put(filterGuid.guid, entry.copy(shooting = None))
val entry = ops.lastSeenStreamMessage(FilterGuid.guid)
ops.lastSeenStreamMessage.put(FilterGuid.guid, entry.copy(shooting = None))
case AvatarAction.LoadCreatedPlayer(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.EquipmentCreatedInHand(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.PlanetsideStringAttribute(attributeType, attributeValue) =>
sendResponse(PlanetsideStringAttributeMessage(filterGuid, attributeType, attributeValue))
sendResponse(PlanetsideStringAttributeMessage(FilterGuid, attributeType, attributeValue))
case AvatarAction.Destroy(victim, killer, weapon, pos) =>
// guid = victim // killer = killer
@ -262,7 +262,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
inventory,
drop,
delete
) if TestFilter(_ => { resolvedGuid == target }) =>
) if TestFilter(() => { ResolvedGuid == target }) =>
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, attribute_type=4, armor))
//happening to this player
@ -362,7 +362,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
oldInventory,
inventory,
drops
) if TestFilter(_ => { resolvedGuid == target }) =>
) if TestFilter(() => { ResolvedGuid == target }) =>
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, attribute_type=4, armor))
//happening to this player
@ -402,9 +402,9 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
case AvatarAction.UseKit(kguid, kObjId) =>
sendResponse(
UseItemMessage(
resolvedGuid,
ResolvedGuid,
kguid,
resolvedGuid,
ResolvedGuid,
unk2 = 4294967295L,
unk3 = false,
unk4 = Vector3.Zero,
@ -453,7 +453,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
/* common messages (maybe once every respawn) */
case ReloadTool(itemGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
sendResponse(ReloadMessage(itemGuid, ammo_clip=1, unk1=0))
case AvatarAction.Killed(cause, mount) =>
@ -519,16 +519,16 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sessionLogic.zoning.spawn.deadState = DeadState.Dead
continent.GUID(mount).collect {
case obj: Vehicle =>
killedWhileMounted(obj, resolvedGuid)
killedWhileMounted(obj, ResolvedGuid)
sessionLogic.vehicles.ConditionalDriverVehicleControl(obj)
sessionLogic.general.unaccessContainer(obj)
case obj: PlanetSideGameObject with Mountable with Container =>
killedWhileMounted(obj, resolvedGuid)
killedWhileMounted(obj, ResolvedGuid)
sessionLogic.general.unaccessContainer(obj)
case obj: PlanetSideGameObject with Mountable =>
killedWhileMounted(obj, resolvedGuid)
killedWhileMounted(obj, ResolvedGuid)
}
sessionLogic.actionsToCancel()
sessionLogic.terminals.CancelAllProximityUnits()
@ -547,11 +547,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
}
case AvatarAction.ReleasePlayer(tplayer)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sessionLogic.zoning.spawn.DepictPlayerAsCorpse(tplayer)
case AvatarAction.Revive(revivalTargetGuid)
if TestFilter(_ => { resolvedGuid == revivalTargetGuid }) =>
if TestFilter(() => { ResolvedGuid == revivalTargetGuid }) =>
log.info(s"No time for rest, ${player.Name}. Back on your feet!")
ops.revive()
player.Actor ! Player.Revive
@ -567,12 +567,12 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
/* uncommon messages (utility, or once in a while) */
case ChangeAmmo(weapon_guid, weapon_slot, previous_guid, ammo_id, ammo_guid, ammo_data)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
ops.changeAmmoProcedure(weapon_guid, previous_guid, ammo_id, ammo_guid, weapon_slot, ammo_data)
sendResponse(ChangeAmmoMessage(weapon_guid, 1))
case AvatarAction.ChangeFireMode(itemGuid, mode)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ChangeFireModeMessage(itemGuid, mode))
case AvatarAction.EnvironmentalDamage(_, _, _) =>
@ -580,7 +580,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sessionLogic.zoning.CancelZoningProcessWithDescriptiveReason("cancel_dmg")
case AvatarAction.DropCreatedItem(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
/* rare messages */
@ -594,11 +594,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
))
case AvatarAction.LoadCreatedProjectile(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.ProjectileState(projectileGuid, shotPos, shotVel, shotOrient, seq, end, targetGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ProjectileStateMessage(projectileGuid, shotPos, shotVel, shotOrient, seq, end, targetGuid))
case AvatarAction.ProjectileExplodes(projectileGuid, projectile) =>
@ -619,11 +619,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sendResponse(GenericActionMessage(mode))
case AvatarAction.PutDownFDU(target)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(GenericObjectActionMessage(target, code=53))
case AvatarAction.StowEquipment(target, slot, item)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
val definition = item.Definition
sendResponse(
ObjectCreateDetailedMessage(
@ -635,7 +635,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
)
case WeaponDryFire(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
continent.GUID(weaponGuid).collect {
case tool: Tool if tool.Magazine == 0 =>
sendResponse(WeaponDryFireMessage(weaponGuid))

View file

@ -83,7 +83,7 @@ class GalaxyHandlerLogic(val ops: SessionGalaxyHandlers, implicit val context: A
sendResponse(ZonePopulationUpdateMessage(zone.Number, 414, 138, popTR, 138, popNC, 138, popVS, 138, popBO))
case GalaxyAction.LogStatusChange(name)
if TestFilter(_ => avatar.people.friend.exists(_.name.equals(name))) =>
if TestFilter(() => avatar.people.friend.exists(_.name.equals(name))) =>
avatarActor ! AvatarActor.MemberListRequest(MemberAction.UpdateFriend, name)
}
}

View file

@ -50,7 +50,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
}
case LocalAction.DeployableMapIcon(behavior, deployInfo)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(DeployableObjectsInfoMessage(behavior, deployInfo))
case LocalAction.DeployableUIFor(item) =>
@ -70,7 +70,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
log.warn(s"LocalAction.Detonate: ${obj.Definition.Name} not configured to explode correctly")
case LocalAction.DoorOpens(_, door)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
val doorGuid = door.GUID
val pos = player.Position.xy
val range = ops.doorLoadRange()
@ -89,7 +89,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
sendResponse(GenericObjectStateMsg(doorGuid, state=17))
case LocalAction.EliminateDeployable(obj: TurretDeployable, dguid, _, _)
if TestFilter(_ => obj.Destroyed) =>
if TestFilter(() => obj.Destroyed) =>
sendResponse(ObjectDeleteMessage(dguid, unk1=0))
case LocalAction.EliminateDeployable(obj: TurretDeployable, dguid, pos, _) =>
@ -103,7 +103,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
)
case LocalAction.EliminateDeployable(obj: ExplosiveDeployable, dguid, _, _)
if TestFilter(_ => { obj.Destroyed || obj.Jammed || obj.Health == 0 }) =>
if TestFilter(() => { obj.Destroyed || obj.Jammed || obj.Health == 0 }) =>
sendResponse(ObjectDeleteMessage(dguid, unk1=0))
case LocalAction.EliminateDeployable(obj: ExplosiveDeployable, dguid, pos, effect) =>
@ -111,7 +111,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
ops.DeconstructDeployable(obj, dguid, pos, obj.Orientation, effect)
case LocalAction.EliminateDeployable(obj: TelepadDeployable, dguid, _, _)
if TestFilter(_ => { obj.Active && obj.Destroyed }) =>
if TestFilter(() => { obj.Active && obj.Destroyed }) =>
//if active, deactivate
obj.Active = false
ops.deactivateTelpadDeployableMessages(dguid)
@ -119,7 +119,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
sendResponse(ObjectDeleteMessage(dguid, unk1=0))
case LocalAction.EliminateDeployable(obj: TelepadDeployable, dguid, pos, _)
if TestFilter(_ => obj.Active) =>
if TestFilter(() => obj.Active) =>
//if active, deactivate
obj.Active = false
ops.deactivateTelpadDeployableMessages(dguid)
@ -128,7 +128,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
ops.DeconstructDeployable(obj, dguid, pos, obj.Orientation, deletionType=2)
case LocalAction.EliminateDeployable(obj: TelepadDeployable, dguid, _, _)
if TestFilter(_ => obj.Destroyed) =>
if TestFilter(() => obj.Destroyed) =>
//standard deployable elimination behavior
sendResponse(ObjectDeleteMessage(dguid, unk1=0))
@ -138,7 +138,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
ops.DeconstructDeployable(obj, dguid, pos, obj.Orientation, deletionType=2)
case LocalAction.EliminateDeployable(obj, dguid, _, _)
if TestFilter(_ => obj.Destroyed) =>
if TestFilter(() => obj.Destroyed) =>
sendResponse(ObjectDeleteMessage(dguid, unk1=0))
case LocalAction.EliminateDeployable(obj, dguid, pos, effect) =>
@ -146,14 +146,11 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
ops.DeconstructDeployable(obj, dguid, pos, obj.Orientation, effect)
case LocalAction.HackClear(targetGuid, unk1, unk2) =>
sendResponse(HackMessage(HackState1.Unk0, targetGuid, filterGuid, progress=0, unk1.toFloat, HackState.HackCleared, unk2))
sendResponse(HackMessage(HackState1.Unk0, targetGuid, FilterGuid, progress=0, unk1.toFloat, HackState.HackCleared, unk2))
case LocalAction.HackObject(targetGuid, unk1, unk2) =>
sessionLogic.general.hackObject(targetGuid, unk1, unk2)
case PlanetsideAttribute(targetGuid, attributeType, attributeValue) =>
sessionLogic.general.sendPlanetsideAttributeMessage(targetGuid, attributeType, attributeValue)
case LocalAction.GenericActionMessage(actionNumber) =>
sendResponse(GenericActionMessage(actionNumber))
@ -224,7 +221,7 @@ class LocalHandlerLogic(val ops: SessionLocalHandlers, implicit val context: Act
sendResponse(GenericObjectActionMessage(buildingGuid, 12))
case LocalAction.RechargeVehicleWeapon(vehicleGuid, weaponGuid)
if TestFilter(_ => isSameTarget) =>
if TestFilter(SameTargetTest) =>
continent.GUID(vehicleGuid)
.collect { case vehicle: MountableWeapons => (vehicle, vehicle.PassengerInSeat(player)) }
.collect { case (vehicle, Some(seat_num)) => vehicle.WeaponControlledFromSeat(seat_num) }

View file

@ -46,7 +46,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
wheelDirection,
unk5,
unk6
) if TestFilter(_ => { isNotSameTarget && player.VehicleSeated.contains(vehicleGuid) }) =>
) if TestFilter(() => { NotSameTarget && player.VehicleSeated.contains(vehicleGuid) }) =>
//player who is also in the vehicle (not driver)
sendResponse(VehicleStateMessage(vehicleGuid, unk1, pos, orient, vel, unk2, unk3, unk4, wheelDirection, unk5, unk6))
player.Position = pos
@ -74,36 +74,36 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
wheelDirection,
unk5,
unk6
) if TestFilter(_ => isNotSameTarget) =>
) if TestFilter(NotSameTargetTest) =>
//player who is watching the vehicle from the outside
sendResponse(VehicleStateMessage(vehicleGuid, unk1, pos, ang, vel, unk2, unk3, unk4, wheelDirection, unk5, unk6))
case VehicleAction.ChildObjectState(objectGuid, pitch, yaw)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ChildObjectStateMessage(objectGuid, pitch, yaw))
case VehicleAction.FrameVehicleState(vguid, u1, pos, oient, vel, u2, u3, u4, is_crouched, u6, u7, u8, u9, uA)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(FrameVehicleStateMessage(vguid, u1, pos, oient, vel, u2, u3, u4, is_crouched, u6, u7, u8, u9, uA))
case VehicleAction.DismountVehicle(bailType, wasKickedByDriver)
if TestFilter(_ => isNotSameTarget) =>
sendResponse(DismountVehicleMsg(filterGuid, bailType, wasKickedByDriver))
if TestFilter(NotSameTargetTest) =>
sendResponse(DismountVehicleMsg(FilterGuid, bailType, wasKickedByDriver))
case VehicleAction.MountVehicle(vehicleGuid, seat)
if TestFilter(_ => isNotSameTarget) =>
sendResponse(ObjectAttachMessage(vehicleGuid, filterGuid, seat))
if TestFilter(NotSameTargetTest) =>
sendResponse(ObjectAttachMessage(vehicleGuid, FilterGuid, seat))
case VehicleAction.DeployRequest(objectGuid, state, unk1, unk2, pos)
if TestFilter(_ => isNotSameTarget) =>
sendResponse(DeployRequestMessage(filterGuid, objectGuid, state, unk1, unk2, pos))
if TestFilter(NotSameTargetTest) =>
sendResponse(DeployRequestMessage(FilterGuid, objectGuid, state, unk1, unk2, pos))
case VehicleAction.EquipmentCreatedInSlot(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case VehicleAction.InventoryState(obj, parentGuid, start, conData)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//TODO prefer ObjectDetachMessage, but how to force ammo pools to update properly?
val objGuid = obj.GUID
sendResponse(ObjectDeleteMessage(objGuid, unk1=0))
@ -115,10 +115,10 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
))
case VehicleAction.KickPassenger(_, wasKickedByDriver, vehicleGuid)
if TestFilter(_ => isSameTarget) =>
if TestFilter(SameTargetTest) =>
//seat number (first field) seems to be correct if passenger is kicked manually by driver
//but always seems to return 4 if user is kicked by mount permissions changing
sendResponse(DismountVehicleMsg(filterGuid, BailType.Kicked, wasKickedByDriver))
sendResponse(DismountVehicleMsg(FilterGuid, BailType.Kicked, wasKickedByDriver))
val typeOfRide = continent.GUID(vehicleGuid) match {
case Some(obj: Vehicle) =>
sessionLogic.general.unaccessContainer(obj)
@ -132,33 +132,33 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
case VehicleAction.KickPassenger(_, wasKickedByDriver, _) =>
//seat number (first field) seems to be correct if passenger is kicked manually by driver
//but always seems to return 4 if user is kicked by mount permissions changing
sendResponse(DismountVehicleMsg(filterGuid, BailType.Kicked, wasKickedByDriver))
sendResponse(DismountVehicleMsg(FilterGuid, BailType.Kicked, wasKickedByDriver))
case VehicleAction.InventoryState2(objGuid, parentGuid, value)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(InventoryStateMessage(objGuid, unk=0, parentGuid, value))
case VehicleAction.LoadVehicle(vehicle, vtype, vguid, vdata)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//this is not be suitable for vehicles with people who are seated in it before it spawns (if that is possible)
sendResponse(ObjectCreateMessage(vtype, vguid, vdata))
Vehicles.ReloadAccessPermissions(vehicle, player.Name)
case VehicleAction.Ownership(vehicleGuid)
if TestFilter(_ => isSameTarget) =>
if TestFilter(SameTargetTest) =>
//Only the player that owns this vehicle needs the ownership packet
avatarActor ! AvatarActor.SetVehicle(Some(vehicleGuid))
sendResponse(PlanetsideAttributeMessage(resolvedGuid, attribute_type=21, vehicleGuid))
sendResponse(PlanetsideAttributeMessage(ResolvedGuid, attribute_type=21, vehicleGuid))
case VehicleAction.LoseOwnership(_, vehicleGuid) =>
ops.announceAmsDecay(vehicleGuid,msg = "@ams_decaystarted")
case VehicleAction.SeatPermissions(vehicleGuid, seatGroup, permission)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(PlanetsideAttributeMessage(vehicleGuid, seatGroup, permission))
case VehicleAction.StowCreatedEquipment(vehicleGuid, slot, itemType, itemGuid, itemData)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//TODO prefer ObjectAttachMessage, but how to force ammo pools to update properly?
sendResponse(ObjectCreateDetailedMessage(itemType, itemGuid, ObjectCreateMessageParent(vehicleGuid, slot), itemData))
@ -176,7 +176,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
}
case VehicleAction.UnstowEquipment(itemGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//TODO prefer ObjectDetachMessage, but how to force ammo pools to update properly?
sendResponse(ObjectDeleteMessage(itemGuid, unk1=0))
@ -185,7 +185,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
sessionLogic.zoning.spawn.DrawCurrentAmsSpawnPoint()
case VehicleAction.TransferPassengerChannel(oldChannel, tempChannel, vehicle, vehicleToDelete)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sessionLogic.zoning.interstellarFerry = Some(vehicle)
sessionLogic.zoning.interstellarFerryTopLevelGUID = Some(vehicleToDelete)
continent.VehicleEvents ! Service.Leave(oldChannel) //old vehicle-specific channel (was s"${vehicle.Actor}")
@ -193,7 +193,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
log.debug(s"TransferPassengerChannel: ${player.Name} now subscribed to $tempChannel for vehicle gating")
case VehicleAction.KickCargo(vehicle, speed, delay)
if TestFilter(_ => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive && speed > 0 }) =>
if TestFilter(() => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive && speed > 0 }) =>
val strafe = 1 + Vehicles.CargoOrientation(vehicle)
val reverseSpeed = if (strafe > 1) { 0 } else { speed }
//strafe or reverse, not both
@ -221,11 +221,11 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
context.system.scheduler.scheduleOnce(delay milliseconds, context.self, resp)
case VehicleAction.KickCargo(cargo, _, _)
if TestFilter(_ => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive }) =>
if TestFilter(() => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive }) =>
sessionLogic.vehicles.TotalDriverVehicleControl(cargo)
case VehicleAction.ChangeLoadout(target, oldWeapons, addedWeapons, oldInventory, newInventory)
if TestFilter(_ => { player.avatar.vehicle.contains(target) }) =>
if TestFilter(() => { player.avatar.vehicle.contains(target) }) =>
//TODO when vehicle weapons can be changed without visual glitches, rewrite this
continent.GUID(target).collect { case vehicle: Vehicle =>
import net.psforever.login.WorldSession.boolToInt
@ -249,7 +249,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
}
case VehicleAction.ChangeLoadout(target, oldWeapons, _, oldInventory, _)
if TestFilter(_ => { sessionLogic.general.accessedContainer.map(_.GUID).contains(target) }) =>
if TestFilter(() => { sessionLogic.general.accessedContainer.map(_.GUID).contains(target) }) =>
//TODO when vehicle weapons can be changed without visual glitches, rewrite this
continent.GUID(target).collect { case vehicle: Vehicle =>
//external participant: observe changes to equipment
@ -287,7 +287,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
sendResponse(GenericObjectActionMessage(playerGuid, code=10))
case VehicleSpawnPad.StartPlayerSeatedInVehicle(vehicle, _)
if TestFilter(_ => { player.VisibleSlots.contains(player.DrawnSlot) }) =>
if TestFilter(() => { player.VisibleSlots.contains(player.DrawnSlot) }) =>
player.DrawnSlot = Player.HandsDownSlot
startPlayerSeatedInVehicle(vehicle)

View file

@ -61,9 +61,9 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
isCloaking,
isNotRendered,
canSeeReallyFar
) if TestFilter(_ => isNotSameTarget) =>
) if TestFilter(NotSameTargetTest) =>
val pstateToSave = pstate.copy(timestamp = 0)
val (lastMsg, lastTime, lastPosition, wasVisible, wasShooting) = ops.lastSeenStreamMessage.get(filterGuid.guid) match {
val (lastMsg, lastTime, lastPosition, wasVisible, wasShooting) = ops.lastSeenStreamMessage.get(FilterGuid.guid) match {
case Some(SessionAvatarHandlers.LastUpstream(Some(msg), visible, shooting, time)) => (Some(msg), time, msg.pos, visible, shooting)
case _ => (None, 0L, Vector3.Zero, false, None)
}
@ -106,7 +106,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
//must draw
sendResponse(
PlayerStateMessage(
filterGuid,
FilterGuid,
pos,
vel,
yaw,
@ -119,10 +119,10 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
isCloaking
)
)
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, now))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, now))
} else {
//is visible, but skip reinforcement
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, lastTime))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=true, wasShooting, lastTime))
}
} else {
//conditions where the target is not currently visible
@ -131,7 +131,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
val lat = (1 + ops.hidingPlayerRandomizer.nextInt(continent.map.scale.height.toInt)).toFloat
sendResponse(
PlayerStateMessage(
filterGuid,
FilterGuid,
Vector3(1f, lat, 1f),
vel=None,
facingYaw=0f,
@ -141,16 +141,16 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
is_cloaked = isCloaking
)
)
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, now))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, now))
} else {
//skip drawing altogether
ops.lastSeenStreamMessage.put(filterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, lastTime))
ops.lastSeenStreamMessage.put(FilterGuid.guid, SessionAvatarHandlers.LastUpstream(Some(pstateToSave), visible=false, wasShooting, lastTime))
}
}
case AvatarAction.ObjectHeld(slot, _)
if TestFilter(_ => { isSameTarget && player.VisibleSlots.contains(slot) }) =>
sendResponse(ObjectHeldMessage(filterGuid, slot, unk1=true))
if TestFilter(() => { SameTarget && player.VisibleSlots.contains(slot) }) =>
sendResponse(ObjectHeldMessage(FilterGuid, slot, unk1=true))
//Stop using proximity terminals if player unholsters a weapon
continent.GUID(sessionLogic.terminals.usingMedicalTerminal).collect {
case term: Terminal with ProximityUnit => sessionLogic.terminals.StopUsingProximityUnit(term)
@ -160,33 +160,33 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
}
case AvatarAction.ObjectHeld(slot, _)
if TestFilter(_ => { isSameTarget && slot > -1 }) =>
sendResponse(ObjectHeldMessage(filterGuid, slot, unk1=true))
if TestFilter(() => { SameTarget && slot > -1 }) =>
sendResponse(ObjectHeldMessage(FilterGuid, slot, unk1=true))
case AvatarAction.ObjectHeld(_, _)
if TestFilter(_ => isSameTarget) => ()
if TestFilter(SameTargetTest) => ()
case AvatarAction.ObjectHeld(_, previousSlot) =>
sendResponse(ObjectHeldMessage(filterGuid, previousSlot, unk1=false))
sendResponse(ObjectHeldMessage(FilterGuid, previousSlot, unk1=false))
case ChangeFireState_Start(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
sendResponse(ChangeFireStateMessage_Start(weaponGuid))
val entry = ops.lastSeenStreamMessage(filterGuid.guid)
ops.lastSeenStreamMessage.put(filterGuid.guid, entry.copy(shooting = Some(weaponGuid)))
val entry = ops.lastSeenStreamMessage(FilterGuid.guid)
ops.lastSeenStreamMessage.put(FilterGuid.guid, entry.copy(shooting = Some(weaponGuid)))
case ChangeFireState_Stop(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { msg => msg.visible || msg.shooting.nonEmpty } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { msg => msg.visible || msg.shooting.nonEmpty } }) =>
sendResponse(ChangeFireStateMessage_Stop(weaponGuid))
val entry = ops.lastSeenStreamMessage(filterGuid.guid)
ops.lastSeenStreamMessage.put(filterGuid.guid, entry.copy(shooting = None))
val entry = ops.lastSeenStreamMessage(FilterGuid.guid)
ops.lastSeenStreamMessage.put(FilterGuid.guid, entry.copy(shooting = None))
case AvatarAction.LoadCreatedPlayer(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.EquipmentCreatedInHand(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.Destroy(victim, killer, weapon, pos) =>
@ -197,7 +197,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sendResponse(ops.destroyDisplayMessage(killer, victim, method, unk))
case AvatarAction.TerminalOrderResult(terminalGuid, action, result)
if TestFilter(_ => { result && (action == TransactionType.Buy || action == TransactionType.Loadout) }) =>
if TestFilter(() => { result && (action == TransactionType.Buy || action == TransactionType.Loadout) }) =>
sendResponse(ItemTransactionResultMessage(terminalGuid, action, result))
sessionLogic.terminals.lastTerminalOrderFulfillment = true
AvatarActor.savePlayerData(player)
@ -219,7 +219,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
inventory,
drop,
delete
) if TestFilter(_ => { resolvedGuid == target }) =>
) if TestFilter(() => { ResolvedGuid == target }) =>
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, attribute_type=4, armor))
//happening to this player
@ -297,7 +297,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
oldInventory,
inventory,
drops
) if TestFilter(_ => { resolvedGuid == target }) =>
) if TestFilter(() => { ResolvedGuid == target }) =>
sendResponse(ArmorChangedMessage(target, exosuit, subtype))
sendResponse(PlanetsideAttributeMessage(target, attribute_type = 4, armor))
//happening to this player
@ -331,9 +331,9 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
case AvatarAction.UseKit(kguid, kObjId) =>
sendResponse(
UseItemMessage(
resolvedGuid,
ResolvedGuid,
kguid,
resolvedGuid,
ResolvedGuid,
unk2 = 4294967295L,
unk3 = false,
unk4 = Vector3.Zero,
@ -354,7 +354,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sendResponse(ChatMsg(ChatMessageType.UNK_225, msg))
case AvatarAction.UpdateKillsDeathsAssists(_, kda: Kill)
if TestFilter(_ => kda.experienceEarned > 0) =>
if TestFilter(() => kda.experienceEarned > 0) =>
continent.actor ! ZoneActor.RewardOurSupporters(
PlayerSource(player),
Players.produceContributionTranscriptFromKill(continent, player, kda),
@ -389,7 +389,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
/* common messages (maybe once every respawn) */
case ReloadTool(itemGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible }}) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible }}) =>
sendResponse(ReloadMessage(itemGuid, ammo_clip=1, unk1=0))
case AvatarAction.Killed(_, mount) =>
@ -444,11 +444,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
}
case AvatarAction.ReleasePlayer(tplayer)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sessionLogic.zoning.spawn.DepictPlayerAsCorpse(tplayer)
case AvatarAction.Revive(revivalTargetGuid)
if TestFilter(_ => { resolvedGuid == revivalTargetGuid }) =>
if TestFilter(() => { ResolvedGuid == revivalTargetGuid }) =>
log.info(s"No time for rest, ${player.Name}. Back on your feet!")
sessionLogic.zoning.spawn.reviveTimer.cancel()
sessionLogic.zoning.spawn.deadState = DeadState.Alive
@ -463,12 +463,12 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
/* uncommon messages (utility, or once in a while) */
case ChangeAmmo(weapon_guid, weapon_slot, previous_guid, ammo_id, ammo_guid, ammo_data)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
ops.changeAmmoProcedure(weapon_guid, previous_guid, ammo_id, ammo_guid, weapon_slot, ammo_data)
sendResponse(ChangeAmmoMessage(weapon_guid, 1))
case AvatarAction.ChangeFireMode(itemGuid, mode)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ChangeFireModeMessage(itemGuid, mode))
case AvatarAction.EnvironmentalDamage(_, _, _) =>
@ -476,7 +476,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sessionLogic.zoning.CancelZoningProcess()
case AvatarAction.DropCreatedItem(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
/* rare messages */
@ -490,11 +490,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
))
case AvatarAction.LoadCreatedProjectile(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case AvatarAction.ProjectileState(projectileGuid, shotPos, shotVel, shotOrient, seq, end, targetGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ProjectileStateMessage(projectileGuid, shotPos, shotVel, shotOrient, seq, end, targetGuid))
case AvatarAction.ProjectileExplodes(projectileGuid, projectile) =>
@ -515,11 +515,11 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
sendResponse(GenericActionMessage(mode))
case AvatarAction.PutDownFDU(target)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(GenericObjectActionMessage(target, code=53))
case AvatarAction.StowEquipment(target, slot, item)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
val definition = item.Definition
sendResponse(
ObjectCreateDetailedMessage(
@ -531,7 +531,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
)
case WeaponDryFire(weaponGuid)
if TestFilter(_ => { isNotSameTarget && ops.lastSeenStreamMessage.get(filterGuid.guid).exists { _.visible } }) =>
if TestFilter(() => { NotSameTarget && ops.lastSeenStreamMessage.get(FilterGuid.guid).exists { _.visible } }) =>
continent.GUID(weaponGuid).collect {
case tool: Tool if tool.Magazine == 0 =>
sendResponse(WeaponDryFireMessage(weaponGuid))

View file

@ -39,7 +39,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
wheelDirection,
unk5,
unk6
) if TestFilter(_ => { isNotSameTarget && player.VehicleSeated.contains(vehicleGuid) }) =>
) if TestFilter(() => { NotSameTarget && player.VehicleSeated.contains(vehicleGuid) }) =>
//player who is also in the vehicle (not driver)
sendResponse(VehicleStateMessage(vehicleGuid, unk1, pos, orient, vel, unk2, unk3, unk4, wheelDirection, unk5, unk6))
player.Position = pos
@ -59,36 +59,36 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
wheelDirection,
unk5,
unk6
) if TestFilter(_ => isNotSameTarget) =>
) if TestFilter(NotSameTargetTest) =>
//player who is watching the vehicle from the outside
sendResponse(VehicleStateMessage(vehicleGuid, unk1, pos, ang, vel, unk2, unk3, unk4, wheelDirection, unk5, unk6))
case VehicleAction.ChildObjectState(objectGuid, pitch, yaw)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ChildObjectStateMessage(objectGuid, pitch, yaw))
case VehicleAction.FrameVehicleState(vguid, u1, pos, oient, vel, u2, u3, u4, is_crouched, u6, u7, u8, u9, uA)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(FrameVehicleStateMessage(vguid, u1, pos, oient, vel, u2, u3, u4, is_crouched, u6, u7, u8, u9, uA))
case VehicleAction.DismountVehicle(bailType, wasKickedByDriver)
if TestFilter(_ => isNotSameTarget) =>
sendResponse(DismountVehicleMsg(filterGuid, bailType, wasKickedByDriver))
if TestFilter(NotSameTargetTest) =>
sendResponse(DismountVehicleMsg(FilterGuid, bailType, wasKickedByDriver))
case VehicleAction.MountVehicle(vehicleGuid, seat)
if TestFilter(_ => isNotSameTarget) =>
sendResponse(ObjectAttachMessage(vehicleGuid, filterGuid, seat))
if TestFilter(NotSameTargetTest) =>
sendResponse(ObjectAttachMessage(vehicleGuid, FilterGuid, seat))
case VehicleAction.DeployRequest(objectGuid, state, unk1, unk2, pos)
if TestFilter(_ => isNotSameTarget) =>
sendResponse(DeployRequestMessage(filterGuid, objectGuid, state, unk1, unk2, pos))
if TestFilter(NotSameTargetTest) =>
sendResponse(DeployRequestMessage(FilterGuid, objectGuid, state, unk1, unk2, pos))
case VehicleAction.EquipmentCreatedInSlot(pkt)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(pkt)
case VehicleAction.InventoryState(obj, parentGuid, start, conData)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//TODO prefer ObjectDetachMessage, but how to force ammo pools to update properly?
val objGuid = obj.GUID
sendResponse(ObjectDeleteMessage(objGuid, unk1=0))
@ -100,10 +100,10 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
))
case VehicleAction.KickPassenger(_, wasKickedByDriver, vehicleGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//seat number (first field) seems to be correct if passenger is kicked manually by driver
//but always seems to return 4 if user is kicked by mount permissions changing
sendResponse(DismountVehicleMsg(filterGuid, BailType.Kicked, wasKickedByDriver))
sendResponse(DismountVehicleMsg(FilterGuid, BailType.Kicked, wasKickedByDriver))
continent.GUID(vehicleGuid) match {
case Some(obj: Vehicle) =>
sessionLogic.general.unaccessContainer(obj)
@ -113,27 +113,27 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
case VehicleAction.KickPassenger(_, wasKickedByDriver, _) =>
//seat number (first field) seems to be correct if passenger is kicked manually by driver
//but always seems to return 4 if user is kicked by mount permissions changing
sendResponse(DismountVehicleMsg(filterGuid, BailType.Kicked, wasKickedByDriver))
sendResponse(DismountVehicleMsg(FilterGuid, BailType.Kicked, wasKickedByDriver))
case VehicleAction.InventoryState2(objGuid, parentGuid, value)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(InventoryStateMessage(objGuid, unk=0, parentGuid, value))
case VehicleAction.LoadVehicle(vehicle, vtype, vguid, vdata)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//this is not be suitable for vehicles with people who are seated in it before it spawns (if that is possible)
sendResponse(ObjectCreateMessage(vtype, vguid, vdata))
Vehicles.ReloadAccessPermissions(vehicle, player.Name)
case VehicleAction.SeatPermissions(vehicleGuid, seatGroup, permission)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(PlanetsideAttributeMessage(vehicleGuid, seatGroup, permission))
case VehicleAction.UnloadVehicle(_, vehicleGuid) =>
sendResponse(ObjectDeleteMessage(vehicleGuid, unk1=1))
case VehicleAction.UnstowEquipment(itemGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
//TODO prefer ObjectDetachMessage, but how to force ammo pools to update properly?
sendResponse(ObjectDeleteMessage(itemGuid, unk1=0))
@ -142,7 +142,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
sessionLogic.zoning.spawn.DrawCurrentAmsSpawnPoint()
case VehicleAction.KickCargo(vehicle, speed, delay)
if TestFilter(_ => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive && speed > 0 }) =>
if TestFilter(() => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive && speed > 0 }) =>
val strafe = 1 + Vehicles.CargoOrientation(vehicle)
val reverseSpeed = if (strafe > 1) { 0 } else { speed }
//strafe or reverse, not both
@ -170,7 +170,7 @@ class VehicleHandlerLogic(val ops: SessionVehicleHandlers, implicit val context:
context.system.scheduler.scheduleOnce(delay milliseconds, context.self, resp)
case VehicleAction.KickCargo(cargo, _, _)
if TestFilter(_ => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive }) =>
if TestFilter(() => { player.VehicleSeated.nonEmpty && sessionLogic.zoning.spawn.deadState == DeadState.Alive }) =>
sessionLogic.vehicles.TotalDriverVehicleControl(cargo)
case VehicleSpawnPad.AttachToRails(vehicle, pad) =>

View file

@ -2,33 +2,22 @@
package net.psforever.actors.session.support
import akka.actor.Actor.Receive
import net.psforever.objects.Default
import net.psforever.objects.{Default, Player}
import net.psforever.services.base.message.EventResponse
import net.psforever.types.PlanetSideGUID
trait CommonHandlerFunctions {
_: CommonSessionInterfacingFunctionality =>
protected var resolvedGuid: PlanetSideGUID = Default.GUID0
protected var filterGuid: PlanetSideGUID = Default.GUID0
protected var isNotSameTarget: Boolean = false
protected var isSameTarget: Boolean = false
/**
* A shared filter container utilized by all response handlers connected by a certain mode.
* It is expected that the filters are treated in a true-oriented context -
* always check `isNotSameTarget` and not `!isSameTarget`, etc..
*/
protected[support] class CommonHandlerFilters {
var resolvedGuid: PlanetSideGUID = Default.GUID0
var filterGuid: PlanetSideGUID = Default.GUID0
var isNotSameTarget: Boolean = false
var isSameTarget: Boolean = false
private var ignoreFilter: Boolean = false
def IgnoreFilter: Boolean = ignoreFilter
def IgnoreFilter_=(state: Boolean): Boolean = {
ignoreFilter = state
IgnoreFilter
}
/**
* na
* @param toChannel na
* @param guid na
* @param reply na
*/
def handle(toChannel: String, guid: PlanetSideGUID, reply: EventResponse): Boolean = {
def Configure(player: Player, guid: PlanetSideGUID): Unit = {
filterGuid = guid
if (player != null && player.HasGUID) {
resolvedGuid = player.GUID
@ -39,20 +28,73 @@ trait CommonHandlerFunctions {
isNotSameTarget = false
isSameTarget = false
}
}
}
trait CommonHandlerFunctions {
_: CommonSessionInterfacingFunctionality =>
final def ResolvedGuid: PlanetSideGUID = sessionLogic.handlerFilters.resolvedGuid
final def FilterGuid: PlanetSideGUID = sessionLogic.handlerFilters.filterGuid
final def NotSameTarget: Boolean = sessionLogic.handlerFilters.isNotSameTarget
final def SameTarget: Boolean = sessionLogic.handlerFilters.isSameTarget
val NotSameTargetTest: () => Boolean = () => NotSameTarget
val SameTargetTest: () => Boolean = () => SameTarget
private var ignoreFilter: Boolean = false
final def IgnoreFilter: Boolean = ignoreFilter
final def IgnoreFilter_=(state: Boolean): Boolean = {
ignoreFilter = state
IgnoreFilter
}
/**
* Process the output of a received response envelope.
* Sets the response handler filter.
* @param toChannel set of subscribers on an event system bus the envelope should reach
* @param guid a specific subscriber endpoint to be excluded
* @param reply output payload transported by this envelope
* @return `true`, if the response was processed; `false`, otherwise
*/
final def handle(toChannel: String, guid: PlanetSideGUID, reply: EventResponse): Boolean = {
sessionLogic.handlerFilters.Configure(player, guid)
tryToHandle(reply)
}
def receive: Receive
/**
* Can the response handler process this message (with the guard boolean permissions set as they currently are).
* @see `Actor.isDefinedAt`
* @param x payload for processing
* @return `true`, if the payload was processed; `false`, otherwise
*/
def isDefinedAt(x: Any): Boolean = receive.isDefinedAt(x)
/**
* Process the output.
* @param x payload for processing
* @return `true`, if the payload was processed; `false`, otherwise
*/
final def tryToHandle(x: Any): Boolean = {
var passed = true
receive.applyOrElse(x, (_: Any) => { passed = false })
passed
}
def TestFilter(filter: Unit => Boolean): Boolean = {
/**
* If ignoring guard booleans (filters), always pass.
* If not, test filters using the provided function.
* @param filter contained guard booleans
* @return `true`. if ignoring filter tests or the filter test passed; `false`, otherwise
*/
final def TestFilter(filter: () => Boolean): Boolean = {
ignoreFilter || filter()
}
/**
* @see `Actor.receive`
*/
def receive: Receive
}

View file

@ -12,52 +12,52 @@ class CommonHandlerLogic(val sessionLogic: SessionData, implicit val context: Ac
def receive: Receive = {
case PlanetsideAttribute(target_guid, attributeType, attributeValue)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(PlanetsideAttributeMessage(target_guid, attributeType, attributeValue))
case GenericObjectAction(objectGuid, actionCode)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(GenericObjectActionMessage(objectGuid, actionCode))
case ObjectDelete(itemGuid, unk)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ObjectDeleteMessage(itemGuid, unk))
case ChangeFireState_Start(weaponGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ChangeFireStateMessage_Start(weaponGuid))
case ChangeFireState_Stop(weaponGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ChangeFireStateMessage_Stop(weaponGuid))
case ReloadTool(itemGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(ReloadMessage(itemGuid, ammo_clip=1, unk1=0))
case ChangeAmmo(weapon_guid, weapon_slot, previous_guid, ammo_id, ammo_guid, ammo_data)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sessionLogic.avatarResponse.changeAmmoProcedure(weapon_guid, previous_guid, ammo_id, ammo_guid, weapon_slot, ammo_data)
sendResponse(ChangeAmmoMessage(weapon_guid, 1))
case WeaponDryFire(weaponGuid)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
continent.GUID(weaponGuid).collect {
case tool: Tool if tool.Magazine == 0 =>
sendResponse(WeaponDryFireMessage(weaponGuid))
}
case HintsAtAttacker(sourceGuid)
if TestFilter(_ => { player.isAlive }) =>
sendResponse(HitHint(sourceGuid, filterGuid))
if TestFilter(() => { player.isAlive }) =>
sendResponse(HitHint(sourceGuid, FilterGuid))
sessionLogic.zoning.CancelZoningProcessWithDescriptiveReason("cancel_dmg")
case SetEmpire(objectGuid, faction)
if TestFilter(_ => isNotSameTarget) =>
if TestFilter(NotSameTargetTest) =>
sendResponse(SetEmpireMessage(objectGuid, faction))
case ConcealPlayer(_) =>
sendResponse(GenericObjectActionMessage(filterGuid, code=9))
sendResponse(GenericObjectActionMessage(FilterGuid, code=9))
case SendResponse(msgs) =>
msgs.foreach(sendResponse)

View file

@ -120,6 +120,8 @@ class SessionData(
def zoning: ZoningOperations = zoningOpt.orNull
def chat: ChatOperations = chatOpt.orNull
val handlerFilters: CommonHandlerFilters = new CommonHandlerFilters()
ServiceManager.serviceManager ! Lookup("accountIntermediary")
ServiceManager.serviceManager ! Lookup("accountPersistence")
ServiceManager.serviceManager ! Lookup("galaxy")

View file

@ -208,9 +208,9 @@ class SessionMountHandlers(
sessionLogic.keepAliveFunc = sessionLogic.zoning.NormalKeepAlive
continent.VehicleEvents ! MessageEnvelope(
continent.id,
SendResponse(List(
SendResponse(
PlanetsideAttributeMessage(obj.GUID, 81, 1),
ObjectDetachMessage(obj.GUID, tplayer.GUID, tplayer.Position, obj.Orientation))
ObjectDetachMessage(obj.GUID, tplayer.GUID, tplayer.Position, obj.Orientation)
)
)
}

View file

@ -73,7 +73,7 @@ object SessionOutfitHandlers {
player.outfit_id = outfitId
player.outfit_name = outfitName
zone.AvatarEvents ! BundledEnvelope(
MessageEnvelope(pname, SendResponse(List(
MessageEnvelope(pname, SendResponse(
OutfitEvent(outfitId, Update(
OutfitInfo(
outfitName, 0, 0, 1,
@ -84,7 +84,7 @@ object SessionOutfitHandlers {
OutfitMemberUpdate(outfitId, charid, 7, flag = true),
ChatMsg(ChatMessageType.UNK_227, "@OutfitCreateSuccess"),
OutfitMembershipResponse(CreateResponse, 0, 0, charid, 0, "", "", flag = true),
))),
)),
MessageEnvelope(
zoneid,
PlanetsideAttribute(player.GUID, 39, outfitId)
@ -148,7 +148,7 @@ object SessionOutfitHandlers {
val outfitName = outfit.name
val seconds: Long = outfit.created.atZone(ZoneId.systemDefault()).toInstant.toEpochMilli / 1000
fromZone.AvatarEvents ! BundledEnvelope(
MessageEnvelope(fromName, SendResponse(List(
MessageEnvelope(fromName, SendResponse(
OutfitMembershipResponse(
OutfitMembershipResponse.PacketType.InviteAccepted, 0, 0,
toCharId, fromCharId, toName, outfitName, flag = false
@ -159,10 +159,10 @@ object SessionOutfitHandlers {
OutfitMemberEventAction.PacketType.Padding, 0
)
)
)))
))
)
toZone.AvatarEvents ! BundledEnvelope(
MessageEnvelope(toName, SendResponse(List(
MessageEnvelope(toName, SendResponse(
OutfitMembershipResponse(
OutfitMembershipResponse.PacketType.InviteAccepted, 0, 0,
toCharId, fromCharId, toName, outfitName, flag = true
@ -174,7 +174,7 @@ object SessionOutfitHandlers {
14, unk11 = true, 0, seconds, 0, 0, 0
))),
OutfitMemberUpdate(outfitId, toCharId, 0, flag=true)
))),
)),
MessageEnvelope(
toZoneId,
PlanetsideAttribute(toGuid, 39, outfitId)
@ -266,13 +266,13 @@ object SessionOutfitHandlers {
if (deleted > 0) {
findPlayerByIdForOutfitAction(zones, kickedId, kickedBy).foreach { kicked =>
kicked.Zone.AvatarEvents ! BundledEnvelope(
MessageEnvelope(kicked.Name, SendResponse(List(
MessageEnvelope(kicked.Name, SendResponse(
OutfitEvent(outfit_id, Leaving()),
OutfitMembershipResponse(
OutfitMembershipResponse.PacketType.YouGotKicked, 0, 1,
kickedBy.CharId, kicked.CharId, kickedBy.Name, kicked.Name, flag = false
)
))),
)),
MessageEnvelope(kicked.Zone.id,
PlanetsideAttribute(kicked.GUID, 39, 0)
),
@ -599,7 +599,7 @@ object SessionOutfitHandlers {
case (Some(outfit), memberCount, points) =>
val seconds: Long = outfit.created.atZone(ZoneId.systemDefault()).toInstant.toEpochMilli / 1000
player.Zone.AvatarEvents ! BundledEnvelope(
MessageEnvelope(player.Name, SendResponse(List(
MessageEnvelope(player.Name, SendResponse(
OutfitEvent(outfitId, Update(OutfitInfo(
outfit.name, points, points, memberCount,
OutfitRankNames(
@ -611,7 +611,7 @@ object SessionOutfitHandlers {
14, unk11 = true, 0, seconds, 0, 0, 0
))),
OutfitMemberUpdate(outfit.id, player.CharId, membership.rank, flag = true)
))),
)),
MessageEnvelope(
player.Zone.id,
PlanetsideAttribute(player.GUID, 39, outfit.id)

View file

@ -3502,7 +3502,7 @@ class ZoningOperations(
val events = zone.AvatarEvents
events ! MessageEnvelope(
channel,
SendResponse(List(PlanetsideAttributeMessage(guid, 0, 120), PlanetsideAttributeMessage(guid, 1, 120)))
SendResponse(PlanetsideAttributeMessage(guid, 0, 120), PlanetsideAttributeMessage(guid, 1, 120))
)
case _ => ()
}

View file

@ -242,10 +242,10 @@ case object MajorFacilityLogic
val guid = building.GUID
//1. reset ???; might be global?
//2. This facility's generator is back on line
val list = SendResponse(List(
val list = SendResponse(
PlanetsideAttributeMessage(guid, 46, 0),
GenericObjectActionMessage(guid, 17)
))
)
events ! BundledEnvelope(building.PlayersInSOI.map { player => MessageEnvelope(player.Name, list) })
true
case _ =>
@ -300,7 +300,7 @@ case object MajorFacilityLogic
//2 .disable spawn target on deployment map
events ! MessageEnvelope(
zoneId,
SendResponse(List(PlanetsideAttributeMessage(guid, 48, 1), PlanetsideAttributeMessage(guid, 38, 0)))
SendResponse(PlanetsideAttributeMessage(guid, 48, 1), PlanetsideAttributeMessage(guid, 38, 0))
)
Behaviors.same
}
@ -325,7 +325,7 @@ case object MajorFacilityLogic
//2. enable spawn target on deployment map
events ! MessageEnvelope(
zoneId,
SendResponse(List(PlanetsideAttributeMessage(guid, 48, 0), PlanetsideAttributeMessage(guid, 38, 1)))
SendResponse(PlanetsideAttributeMessage(guid, 48, 0), PlanetsideAttributeMessage(guid, 38, 1))
)
Behaviors.same
}

View file

@ -39,7 +39,7 @@ object DamageableAmenity {
val targetGUID = target.GUID
events ! MessageEnvelope(
zoneId,
SendResponse(List(PlanetsideAttributeMessage(targetGUID, 50, 1), PlanetsideAttributeMessage(targetGUID, 51, 1)))
SendResponse(PlanetsideAttributeMessage(targetGUID, 50, 1), PlanetsideAttributeMessage(targetGUID, 51, 1))
)
}
}

View file

@ -274,7 +274,7 @@ object GenericHackables {
)
zone.LocalEvents ! MessageEnvelope(
zone.id,
SendResponse(List(GenericObjectActionMessage(target.GUID, 61), GenericObjectActionMessage(target.GUID, 58)))
SendResponse(GenericObjectActionMessage(target.GUID, 61), GenericObjectActionMessage(target.GUID, 58))
)
//amenities if applicable
virus match {

View file

@ -40,7 +40,7 @@ object RepairableAmenity {
val targetGUID = target.GUID
events ! MessageEnvelope(
zoneId,
SendResponse(List(PlanetsideAttributeMessage(targetGUID, 50, 0), PlanetsideAttributeMessage(targetGUID, 51, 0)))
SendResponse(PlanetsideAttributeMessage(targetGUID, 50, 0), PlanetsideAttributeMessage(targetGUID, 51, 0))
)
RestorationOfHistory(target)
}

View file

@ -110,10 +110,10 @@ trait FacilityHackParticipation extends ParticipationLogic {
import net.psforever.objects.serverobject.terminals.Terminal
import net.psforever.objects.GlobalDefinitions
val mainTerm = building.Amenities.filter(x => x.isInstanceOf[Terminal] && x.Definition == GlobalDefinitions.main_terminal).head.GUID
val pkts = SendResponse(List(
val pkts = SendResponse(
GenericObjectActionMessage(mainTerm, 61),
GenericObjectActionMessage(mainTerm, 58)
))
)
val events = building.Zone.AvatarEvents
events ! BundledEnvelope(list.map { p =>
MessageEnvelope(p.Name, pkts)

View file

@ -43,7 +43,7 @@ trait TurretControl
val tguid = TurretObject.GUID
events ! MessageEnvelope(
zoneId,
SendResponse(List(PlanetsideAttributeMessage(tguid, 50, 0), PlanetsideAttributeMessage(tguid, 51, 0)))
SendResponse(PlanetsideAttributeMessage(tguid, 50, 0), PlanetsideAttributeMessage(tguid, 51, 0))
)
}
@ -62,7 +62,7 @@ trait TurretControl
CancelJammeredStatus(target)
events ! MessageEnvelope(
zoneId,
SendResponse(List(PlanetsideAttributeMessage(tguid, 50, 1), PlanetsideAttributeMessage(tguid, 51, 1)))
SendResponse(PlanetsideAttributeMessage(tguid, 50, 1), PlanetsideAttributeMessage(tguid, 51, 1))
)
}
}

View file

@ -163,7 +163,7 @@ trait AntTransferBehavior extends TransferBehavior with NtuStorageBehavior {
//2. orb particle effect off
events ! MessageEnvelope(
zoneId,
SendResponse(List(PlanetsideAttributeMessage(vguid, 52, 0L), PlanetsideAttributeMessage(vguid, 49, 0L)))
SendResponse(PlanetsideAttributeMessage(vguid, 52, 0L), PlanetsideAttributeMessage(vguid, 49, 0L))
)
} else if (transferEvent == TransferBehavior.Event.Discharging) {
events ! MessageEnvelope(

View file

@ -17,8 +17,8 @@ trait GenericMessageEnvelope
object GenericMessageEnvelope {
/**
* The `unapply`ed data from a message envelope resembles the data from includes the filter and the channel information.
* The original channel information.
* The extracted data from a message envelope resembles the data from,
* including the filter and the original channel information.
* @param obj response envelope
* @return a tuple containing the channel, filter, and reply message
*/

View file

@ -24,7 +24,7 @@ object GenericResponseEnvelope {
* @param stamp marker indicating the routing through which the original message was processed
* @param channel set of subscribers on an event system bus the envelope should reach
* @param filter a specific subscriber endpoint to be excluded
* @param msg input payload transported by this envelope
* @param msg output payload transported by this envelope
* @return a faked but typically acceptable response envelope
*/
def apply(stamp: EventSystemStamp, channel: String, filter: PlanetSideGUID, msg: EventMessage): GenericResponseEnvelope = {

View file

@ -49,11 +49,6 @@ trait MessageTransformationBehavior
def reply: EventResponse = outputReply
}
/**
* A proper event system envelope.
*/
case class MessageEnvelope(channel: String, filter: PlanetSideGUID, msg: EventMessage)
extends MessageTransformationBehavior
object MessageEnvelope {
def apply(msg: EventMessage): MessageEnvelope =
@ -62,3 +57,9 @@ object MessageEnvelope {
def apply(channel: String, msg: EventMessage): MessageEnvelope =
MessageEnvelope(channel, Default.GUID0, msg)
}
/**
* A proper event system envelope.
*/
case class MessageEnvelope(channel: String, filter: PlanetSideGUID, msg: EventMessage)
extends MessageTransformationBehavior

View file

@ -7,4 +7,6 @@ final case class SendResponse(pkts: Seq[PlanetSideGamePacket]) extends SelfRespo
object SendResponse {
def apply(pkt: PlanetSideGamePacket): SendResponse = SendResponse(Seq(pkt))
def apply(first: PlanetSideGamePacket, msgs: PlanetSideGamePacket*): SendResponse = SendResponse(first +: msgs)
}