mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-12 23:14:42 +00:00
add outfit (list) window event subscription handling
fix Kicked action send instead of Leaving action when players leave on their own
This commit is contained in:
parent
c84bf9ae74
commit
c0428bd3f6
3 changed files with 54 additions and 26 deletions
|
|
@ -837,13 +837,19 @@ class GeneralLogic(val ops: GeneralOperations, implicit val context: ActorContex
|
||||||
SessionOutfitHandlers.HandleOutfitRank(zones, List(r1, r2, r3, r4, r5, r6, r7, r8), player)
|
SessionOutfitHandlers.HandleOutfitRank(zones, List(r1, r2, r3, r4, r5, r6, r7, r8), player)
|
||||||
|
|
||||||
case OutfitRequest(_, OutfitRequestAction.OutfitWindowOpen(true)) =>
|
case OutfitRequest(_, OutfitRequestAction.OutfitWindowOpen(true)) =>
|
||||||
|
player.outfit_window_open = true
|
||||||
SessionOutfitHandlers.HandleViewOutfitWindow(zones, player, player.outfit_id)
|
SessionOutfitHandlers.HandleViewOutfitWindow(zones, player, player.outfit_id)
|
||||||
|
|
||||||
case OutfitRequest(_, OutfitRequestAction.OutfitWindowOpen(false)) =>
|
case OutfitRequest(_, OutfitRequestAction.OutfitWindowOpen(false)) =>
|
||||||
|
player.outfit_window_open = false
|
||||||
|
|
||||||
case OutfitRequest(_, OutfitRequestAction.OutfitListWindowOpen(true)) =>
|
case OutfitRequest(_, OutfitRequestAction.OutfitListWindowOpen(true)) =>
|
||||||
|
player.outfit_list_open = true
|
||||||
SessionOutfitHandlers.HandleGetOutfitList(player)
|
SessionOutfitHandlers.HandleGetOutfitList(player)
|
||||||
|
|
||||||
|
case OutfitRequest(_, OutfitRequestAction.OutfitListWindowOpen(false)) =>
|
||||||
|
player.outfit_list_open = false
|
||||||
|
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright (c) 2025 PSForever
|
// Copyright (c) 2025 PSForever
|
||||||
package net.psforever.actors.session.support
|
package net.psforever.actors.session.support
|
||||||
|
|
||||||
import io.getquill.{ActionReturning, EntityQuery, Insert, PostgresJAsyncContext, Query, Quoted, SnakeCase, Update}
|
import io.getquill.{Action, ActionReturning, EntityQuery, Insert, PostgresJAsyncContext, Query, Quoted, SnakeCase}
|
||||||
import net.psforever.objects.avatar.PlayerControl
|
import net.psforever.objects.avatar.PlayerControl
|
||||||
import net.psforever.objects.zones.Zone
|
import net.psforever.objects.zones.Zone
|
||||||
import net.psforever.objects.Player
|
import net.psforever.objects.Player
|
||||||
import net.psforever.packet.game.OutfitEventAction.{Leaving, OutfitInfo, OutfitRankNames, Initial, Unk1, Update, UpdateMemberCount}
|
import net.psforever.packet.game.OutfitEventAction.{Initial, Leaving, OutfitInfo, OutfitRankNames, Unk1, Update, UpdateMemberCount}
|
||||||
import net.psforever.packet.game.OutfitMembershipResponse.PacketType.CreateResponse
|
import net.psforever.packet.game.OutfitMembershipResponse.PacketType.CreateResponse
|
||||||
import net.psforever.packet.game._
|
import net.psforever.packet.game._
|
||||||
import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
|
import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
|
||||||
|
|
@ -207,22 +207,28 @@ object SessionOutfitHandlers {
|
||||||
def HandleOutfitKick(zones: Seq[Zone], kickedId: Long, kickedBy: Player, session: SessionData): Unit = {
|
def HandleOutfitKick(zones: Seq[Zone], kickedId: Long, kickedBy: Player, session: SessionData): Unit = {
|
||||||
// if same id, player has left the outfit by their own choice
|
// if same id, player has left the outfit by their own choice
|
||||||
if (kickedId == kickedBy.CharId) {
|
if (kickedId == kickedBy.CharId) {
|
||||||
removeMemberFromOutfit(kickedBy.outfit_id, kickedId).map {
|
|
||||||
|
// store outfit_id since it will be nulled soon
|
||||||
|
val outfit_id = kickedBy.outfit_id
|
||||||
|
|
||||||
|
removeMemberFromOutfit(outfit_id, kickedId).map {
|
||||||
case (deleted, _) =>
|
case (deleted, _) =>
|
||||||
if (deleted > 0) {
|
if (deleted > 0) {
|
||||||
PlayerControl.sendResponse(kickedBy.Zone, kickedBy.Name,
|
|
||||||
OutfitMemberEvent(kickedBy.outfit_id, kickedId, OutfitMemberEventAction.Kicked()))
|
|
||||||
|
|
||||||
zones.filter(z => z.AllPlayers.nonEmpty).flatMap(_.AllPlayers)
|
PlayerControl.sendResponse(kickedBy.Zone, kickedBy.Name,
|
||||||
.filter(p => p.outfit_id == kickedBy.outfit_id).foreach(outfitMember =>
|
OutfitEvent(outfit_id, Leaving())
|
||||||
PlayerControl.sendResponse(outfitMember.Zone, outfitMember.Name,
|
|
||||||
OutfitMemberEvent(kickedBy.outfit_id, kickedId, OutfitMemberEventAction.Kicked()))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
session.chat.LeaveChannel(OutfitChannel(kickedBy.outfit_id))
|
session.chat.LeaveChannel(OutfitChannel(outfit_id))
|
||||||
kickedBy.outfit_name = ""
|
kickedBy.outfit_name = ""
|
||||||
kickedBy.outfit_id = 0
|
kickedBy.outfit_id = 0
|
||||||
|
|
||||||
|
zones.filter(z => z.AllPlayers.nonEmpty).flatMap(_.AllPlayers)
|
||||||
|
.filter(p => p.outfit_id == outfit_id).foreach(outfitMember =>
|
||||||
|
PlayerControl.sendResponse(outfitMember.Zone, outfitMember.Name,
|
||||||
|
OutfitMemberEvent(outfit_id, kickedId, OutfitMemberEventAction.Kicked()))
|
||||||
|
)
|
||||||
|
|
||||||
kickedBy.Zone.AvatarEvents ! AvatarServiceMessage(kickedBy.Zone.id,
|
kickedBy.Zone.AvatarEvents ! AvatarServiceMessage(kickedBy.Zone.id,
|
||||||
AvatarAction.PlanetsideAttributeToAll(kickedBy.GUID, 39, 0))
|
AvatarAction.PlanetsideAttributeToAll(kickedBy.GUID, 39, 0))
|
||||||
|
|
||||||
|
|
@ -304,13 +310,15 @@ object SessionOutfitHandlers {
|
||||||
owner_points =>
|
owner_points =>
|
||||||
// announce owner rank change
|
// announce owner rank change
|
||||||
zones.foreach(zone => {
|
zones.foreach(zone => {
|
||||||
zone.AllPlayers.filter(_.outfit_id == outfit_id).foreach(outfitMember => {
|
zone.AllPlayers
|
||||||
PlayerControl.sendResponse(
|
.filter(_.outfit_id == outfit_id)
|
||||||
zone, outfitMember.Name,
|
.foreach(outfitMember => {
|
||||||
OutfitMemberEvent(outfit_id, promoter.avatar.id,
|
PlayerControl.sendResponse(
|
||||||
OutfitMemberEventAction.Update(promoter.Name, 6, owner_points, 0, OutfitMemberEventAction.PacketType.Padding, 0)))
|
zone, outfitMember.Name,
|
||||||
})
|
OutfitMemberEvent(outfit_id, promoter.avatar.id,
|
||||||
})
|
OutfitMemberEventAction.Update(promoter.Name, 6, owner_points, 0, OutfitMemberEventAction.PacketType.Padding, 0)))
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// update promoter rank
|
// update promoter rank
|
||||||
|
|
@ -328,12 +336,14 @@ object SessionOutfitHandlers {
|
||||||
member_points =>
|
member_points =>
|
||||||
// tell everyone about the new rank of the promoted member
|
// tell everyone about the new rank of the promoted member
|
||||||
zones.foreach(zone => {
|
zones.foreach(zone => {
|
||||||
zone.AllPlayers.filter(_.outfit_id == outfit_id).foreach(player => {
|
zone.AllPlayers
|
||||||
PlayerControl.sendResponse(
|
.filter(_.outfit_id == outfit_id)
|
||||||
zone, player.Name,
|
.foreach(player => {
|
||||||
OutfitMemberEvent(outfit_id, promoted.avatar.id,
|
PlayerControl.sendResponse(
|
||||||
OutfitMemberEventAction.Update(promoted.Name, newRank, member_points, 0, OutfitMemberEventAction.PacketType.Padding, 0)))
|
zone, player.Name,
|
||||||
})
|
OutfitMemberEvent(outfit_id, promoted.avatar.id,
|
||||||
|
OutfitMemberEventAction.Update(promoted.Name, newRank, member_points, 0, OutfitMemberEventAction.PacketType.Padding, 0)))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -472,7 +482,10 @@ object SessionOutfitHandlers {
|
||||||
)
|
)
|
||||||
|
|
||||||
zones.foreach(zone => {
|
zones.foreach(zone => {
|
||||||
zone.AllPlayers.filter(_.outfit_id == outfit_id).foreach(player => {
|
zone.AllPlayers
|
||||||
|
.filter(_.outfit_id == outfit_id)
|
||||||
|
.filter(_.outfit_window_open)
|
||||||
|
.foreach(player => {
|
||||||
PlayerControl.sendResponse(
|
PlayerControl.sendResponse(
|
||||||
zone, player.Name,
|
zone, player.Name,
|
||||||
outfit_event
|
outfit_event
|
||||||
|
|
@ -502,7 +515,7 @@ object SessionOutfitHandlers {
|
||||||
} yield {
|
} yield {
|
||||||
outfitOpt.foreach { outfit =>
|
outfitOpt.foreach { outfit =>
|
||||||
|
|
||||||
// send to all online players in outfit
|
// send to all online players in outfit with window open
|
||||||
val outfit_event = OutfitEvent(
|
val outfit_event = OutfitEvent(
|
||||||
outfit_id,
|
outfit_id,
|
||||||
Update(
|
Update(
|
||||||
|
|
@ -534,7 +547,10 @@ object SessionOutfitHandlers {
|
||||||
)
|
)
|
||||||
|
|
||||||
zones.foreach(zone => {
|
zones.foreach(zone => {
|
||||||
zone.AllPlayers.filter(_.outfit_id == outfit_id).foreach(player => {
|
zone.AllPlayers
|
||||||
|
.filter(_.outfit_id == outfit_id)
|
||||||
|
.filter(_.outfit_window_open)
|
||||||
|
.foreach(player => {
|
||||||
PlayerControl.sendResponse(
|
PlayerControl.sendResponse(
|
||||||
zone, player.Name,
|
zone, player.Name,
|
||||||
outfit_event
|
outfit_event
|
||||||
|
|
@ -823,4 +839,8 @@ object SessionOutfitHandlers {
|
||||||
} yield ()
|
} yield ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def updateOutfitPointMV(): Quoted[Action[Unit]] = quote(
|
||||||
|
infix"REFRESH MATERIALIZED VIEW outfitpoint_mv".as[Action[Unit]]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,8 @@ class Player(var avatar: Avatar)
|
||||||
var lastShotSeq_time: Int = -1
|
var lastShotSeq_time: Int = -1
|
||||||
var outfit_name: String = ""
|
var outfit_name: String = ""
|
||||||
var outfit_id: Long = 0
|
var outfit_id: Long = 0
|
||||||
|
var outfit_window_open: Boolean = false
|
||||||
|
var outfit_list_open: Boolean = false
|
||||||
|
|
||||||
/** From PlanetsideAttributeMessage */
|
/** From PlanetsideAttributeMessage */
|
||||||
var PlanetsideAttribute: Array[Long] = Array.ofDim(120)
|
var PlanetsideAttribute: Array[Long] = Array.ofDim(120)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue