mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
fix handling of empty and invalid item clobs
This commit is contained in:
parent
0d4a5ad40e
commit
60caf2c76b
|
|
@ -380,14 +380,16 @@ class AvatarActor(
|
|||
|
||||
result.onComplete {
|
||||
case Success((loadouts, implants, certs, locker)) =>
|
||||
avatarCopy(avatar.copy(
|
||||
avatarCopy(
|
||||
avatar.copy(
|
||||
loadouts = loadouts,
|
||||
// make sure we always have the base certifications
|
||||
certifications =
|
||||
certs.map(cert => Certification.withValue(cert.id)).toSet ++ Config.app.game.baseCertifications,
|
||||
implants = implants.map(implant => Some(Implant(implant.toImplantDefinition))).padTo(3, None),
|
||||
locker = locker
|
||||
))
|
||||
)
|
||||
)
|
||||
// if we need to start stamina regeneration
|
||||
tryRestoreStaminaForSession(stamina = 1) match {
|
||||
case Some(_) =>
|
||||
|
|
@ -524,7 +526,8 @@ class AvatarActor(
|
|||
if (certification == Certification.ReinforcedExoSuit) player.ExoSuit == ExoSuitType.Reinforced
|
||||
else if (certification == Certification.InfiltrationSuit) player.ExoSuit == ExoSuitType.Infiltration
|
||||
else if (player.ExoSuit == ExoSuitType.MAX) {
|
||||
lazy val subtype = InfantryLoadout.DetermineSubtypeA(ExoSuitType.MAX, player.Slot(slot = 0).Equipment)
|
||||
lazy val subtype =
|
||||
InfantryLoadout.DetermineSubtypeA(ExoSuitType.MAX, player.Slot(slot = 0).Equipment)
|
||||
if (certification == Certification.UniMAX) true
|
||||
else if (certification == Certification.AAMAX) subtype == 1
|
||||
else if (certification == Certification.AIMAX) subtype == 2
|
||||
|
|
@ -692,8 +695,7 @@ class AvatarActor(
|
|||
(
|
||||
number + 15,
|
||||
player.Zone.GUID(avatar.vehicle) match {
|
||||
case Some(vehicle: Vehicle)
|
||||
if GlobalDefinitions.isBattleFrameVehicle(vehicle.Definition) =>
|
||||
case Some(vehicle: Vehicle) if GlobalDefinitions.isBattleFrameVehicle(vehicle.Definition) =>
|
||||
storeVehicleLoadout(player, name, number + 5, vehicle)
|
||||
case _ =>
|
||||
throwLoadoutFailure(s"no owned battleframe found for ${player.Name}")
|
||||
|
|
@ -814,9 +816,11 @@ class AvatarActor(
|
|||
} else if (implant.definition.implantType.disabledFor.contains(session.get.player.ExoSuit)) {
|
||||
// TODO can this really happen? can we prevent it?
|
||||
} else {
|
||||
avatarCopy(avatar.copy(
|
||||
avatarCopy(
|
||||
avatar.copy(
|
||||
implants = avatar.implants.updated(slot, Some(implant.copy(active = true)))
|
||||
))
|
||||
)
|
||||
)
|
||||
sessionActor ! SessionActor.SendResponse(
|
||||
AvatarImplantMessage(session.get.player.GUID, ImplantAction.Activation, slot, 1)
|
||||
)
|
||||
|
|
@ -835,7 +839,8 @@ class AvatarActor(
|
|||
if (interval.toMillis > 0) {
|
||||
implantTimers(slot) = context.system.scheduler.scheduleWithFixedDelay(interval, interval)(() => {
|
||||
val player = session.get.player
|
||||
if (implantType match {
|
||||
if (
|
||||
implantType match {
|
||||
case ImplantType.AdvancedRegen =>
|
||||
//for every 1hp: 2sp (running), 1.5sp (standing), 1sp (crouched)
|
||||
// to simulate '1.5sp (standing)', find if 0.0...1.0 * 100 is an even number
|
||||
|
|
@ -860,7 +865,8 @@ class AvatarActor(
|
|||
}
|
||||
case _ =>
|
||||
!player.isAlive || !consumeThisMuchStamina(implant.definition.StaminaCost)
|
||||
}) {
|
||||
}
|
||||
) {
|
||||
context.self ! DeactivateImplant(implantType)
|
||||
}
|
||||
})
|
||||
|
|
@ -1253,9 +1259,11 @@ class AvatarActor(
|
|||
AvatarImplantMessage(session.get.player.GUID, ImplantAction.Initialization, index, 0)
|
||||
)
|
||||
)
|
||||
avatarCopy(avatar.copy(
|
||||
avatarCopy(
|
||||
avatar.copy(
|
||||
implants = avatar.implants.updated(index, Some(imp.copy(initialized = false, active = false)))
|
||||
))
|
||||
)
|
||||
)
|
||||
//restart initialization process
|
||||
implantTimers.get(index).foreach(_.cancel())
|
||||
implantTimers(index) = context.scheduleOnce(
|
||||
|
|
@ -1277,9 +1285,11 @@ class AvatarActor(
|
|||
} match {
|
||||
case Some((implant, slot)) =>
|
||||
implantTimers.get(slot).foreach(_.cancel())
|
||||
avatarCopy(avatar.copy(
|
||||
avatarCopy(
|
||||
avatar.copy(
|
||||
implants = avatar.implants.updated(slot, Some(implant.copy(active = false)))
|
||||
))
|
||||
)
|
||||
)
|
||||
// Deactivation sound / effect
|
||||
session.get.zone.AvatarEvents ! AvatarServiceMessage(
|
||||
session.get.zone.id,
|
||||
|
|
@ -1434,8 +1444,7 @@ class AvatarActor(
|
|||
val items: String = {
|
||||
val clobber: StringBuilder = new StringBuilder()
|
||||
//encode holsters
|
||||
vehicle
|
||||
.Weapons
|
||||
vehicle.Weapons
|
||||
.collect {
|
||||
case (index, slot: EquipmentSlot) if slot.Equipment.nonEmpty =>
|
||||
clobber.append(encodeLoadoutClobFragment(slot.Equipment.get, index))
|
||||
|
|
@ -1488,12 +1497,14 @@ class AvatarActor(
|
|||
if (items.nonEmpty) {
|
||||
saveLockerFunc = storeLocker
|
||||
import ctx._
|
||||
ctx.run(
|
||||
ctx
|
||||
.run(
|
||||
query[persistence.Locker].insert(
|
||||
_.avatarId -> lift(avatar.id),
|
||||
_.items -> lift(items)
|
||||
)
|
||||
).onComplete {
|
||||
)
|
||||
.onComplete {
|
||||
case Success(_) =>
|
||||
log.debug(s"saving locker contents belonging to ${avatar.name}")
|
||||
case Failure(e) =>
|
||||
|
|
@ -1595,7 +1606,8 @@ class AvatarActor(
|
|||
}
|
||||
|
||||
def refreshLoadouts(loadouts: Iterable[(Option[Loadout], Int)]): Unit = {
|
||||
loadouts.map {
|
||||
loadouts
|
||||
.map {
|
||||
case (Some(loadout: InfantryLoadout), index) =>
|
||||
FavoritesMessage.Infantry(
|
||||
session.get.player.GUID,
|
||||
|
|
@ -1632,7 +1644,8 @@ class AvatarActor(
|
|||
"",
|
||||
0
|
||||
)
|
||||
}.foreach { sessionActor ! SessionActor.SendResponse(_) }
|
||||
}
|
||||
.foreach { sessionActor ! SessionActor.SendResponse(_) }
|
||||
}
|
||||
|
||||
def refreshLoadout(line: Int): Unit = {
|
||||
|
|
@ -1646,8 +1659,7 @@ class AvatarActor(
|
|||
InfantryLoadout.DetermineSubtypeB(loadout.exosuit, loadout.subtype)
|
||||
)
|
||||
)
|
||||
case Some(Some(loadout: VehicleLoadout))
|
||||
if GlobalDefinitions.isBattleFrameVehicle(loadout.vehicle_definition) =>
|
||||
case Some(Some(loadout: VehicleLoadout)) if GlobalDefinitions.isBattleFrameVehicle(loadout.vehicle_definition) =>
|
||||
sessionActor ! SessionActor.SendResponse(
|
||||
FavoritesMessage.Battleframe(
|
||||
session.get.player.GUID,
|
||||
|
|
@ -1698,11 +1710,13 @@ class AvatarActor(
|
|||
}
|
||||
|
||||
def buildContainedEquipmentFromClob(container: Container, clob: String): Unit = {
|
||||
clob.split("/").foreach {
|
||||
value =>
|
||||
clob.split("/").filter(_.trim.nonEmpty).foreach { value =>
|
||||
val (objectType, objectIndex, objectId, toolAmmo) = value.split(",") match {
|
||||
case Array(a, b: String, c: String) => (a, b.toInt, c.toInt, None)
|
||||
case Array(a, b: String, c: String, d) => (a, b.toInt, c.toInt, Some(d))
|
||||
case _ =>
|
||||
log.warn(s"ignoring invalid item string: '$value'")
|
||||
return
|
||||
}
|
||||
|
||||
objectType match {
|
||||
|
|
@ -1729,7 +1743,7 @@ class AvatarActor(
|
|||
}
|
||||
|
||||
toolAmmo foreach { toolAmmo =>
|
||||
toolAmmo.toString.split("_").drop(1).foreach { value =>
|
||||
toolAmmo.split("_").drop(1).foreach { value =>
|
||||
val (ammoSlots, ammoTypeIndex, ammoBoxDefinition) = value.split("-") match {
|
||||
case Array(a: String, b: String, c: String) => (a.toInt, b.toInt, c.toInt)
|
||||
}
|
||||
|
|
@ -1770,17 +1784,12 @@ class AvatarActor(
|
|||
def resolvePurchaseTimeName(faction: PlanetSideEmpire.Value, item: BasicDefinition): (BasicDefinition, String) = {
|
||||
val factionName: String = faction.toString.toLowerCase
|
||||
val name = item match {
|
||||
case GlobalDefinitions.trhev_dualcycler |
|
||||
GlobalDefinitions.nchev_scattercannon |
|
||||
case GlobalDefinitions.trhev_dualcycler | GlobalDefinitions.nchev_scattercannon |
|
||||
GlobalDefinitions.vshev_quasar =>
|
||||
s"${factionName}hev_antipersonnel"
|
||||
case GlobalDefinitions.trhev_pounder |
|
||||
GlobalDefinitions.nchev_falcon |
|
||||
GlobalDefinitions.vshev_comet =>
|
||||
case GlobalDefinitions.trhev_pounder | GlobalDefinitions.nchev_falcon | GlobalDefinitions.vshev_comet =>
|
||||
s"${factionName}hev_antivehicular"
|
||||
case GlobalDefinitions.trhev_burster |
|
||||
GlobalDefinitions.nchev_sparrow |
|
||||
GlobalDefinitions.vshev_starfire =>
|
||||
case GlobalDefinitions.trhev_burster | GlobalDefinitions.nchev_sparrow | GlobalDefinitions.vshev_starfire =>
|
||||
s"${factionName}hev_antiaircraft"
|
||||
case _ =>
|
||||
item.Name
|
||||
|
|
@ -1794,25 +1803,21 @@ class AvatarActor(
|
|||
val faction = name.take(2)
|
||||
(if (faction.equals("nc")) {
|
||||
Seq(GlobalDefinitions.nchev_scattercannon, GlobalDefinitions.nchev_falcon, GlobalDefinitions.nchev_sparrow)
|
||||
}
|
||||
else if (faction.equals("vs")) {
|
||||
} else if (faction.equals("vs")) {
|
||||
Seq(GlobalDefinitions.vshev_quasar, GlobalDefinitions.vshev_comet, GlobalDefinitions.vshev_starfire)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Seq(GlobalDefinitions.trhev_dualcycler, GlobalDefinitions.trhev_pounder, GlobalDefinitions.trhev_burster)
|
||||
}).zip(
|
||||
Seq(s"${faction}hev_antipersonnel", s"${faction}hev_antivehicular", s"${faction}hev_antiaircraft")
|
||||
)
|
||||
} else {
|
||||
definition match {
|
||||
case vdef: VehicleDefinition
|
||||
if GlobalDefinitions.isBattleFrameFlightVehicle(vdef) =>
|
||||
case vdef: VehicleDefinition if GlobalDefinitions.isBattleFrameFlightVehicle(vdef) =>
|
||||
val bframe = name.substring(0, name.indexOf('_'))
|
||||
val gunner = bframe + "_gunner"
|
||||
Seq((DefinitionUtil.fromString(gunner), gunner), (vdef, name))
|
||||
|
||||
case vdef: VehicleDefinition
|
||||
if GlobalDefinitions.isBattleFrameGunnerVehicle(vdef) =>
|
||||
case vdef: VehicleDefinition if GlobalDefinitions.isBattleFrameGunnerVehicle(vdef) =>
|
||||
val bframe = name.substring(0, name.indexOf('_'))
|
||||
val flight = bframe + "_flight"
|
||||
Seq((vdef, name), (DefinitionUtil.fromString(flight), flight))
|
||||
|
|
|
|||
Loading…
Reference in a new issue