Correctly set active=false when deinitializing implants

Plus a minor logging improvement in MA
This commit is contained in:
Jakob Gillich 2021-04-18 07:47:20 +02:00
parent 25bb2cc5ac
commit 490e6244e7
2 changed files with 8 additions and 9 deletions

View file

@ -297,7 +297,7 @@ class MiddlewareActor(
log.warn(s"Unexpected packet type $packet in start (before crypto)") log.warn(s"Unexpected packet type $packet in start (before crypto)")
Behaviors.same Behaviors.same
} }
case Failure(_) => case Failure(unmarshalError) =>
// There is a special case where no crypto is being used. // There is a special case where no crypto is being used.
// The only packet coming through looks like PingMsg. This is a hardcoded // The only packet coming through looks like PingMsg. This is a hardcoded
// feature of the client @ 0x005FD618 // feature of the client @ 0x005FD618
@ -318,8 +318,8 @@ class MiddlewareActor(
log.error(s"Unexpected non-crypto packet type $packet in start") log.error(s"Unexpected non-crypto packet type $packet in start")
Behaviors.same Behaviors.same
} }
case Failure(e) => case Failure(decodeError) =>
log.error(s"Could not decode packet in start: $e") log.error(s"Could not decode packet in start: '$unmarshalError' / '$decodeError'")
Behaviors.same Behaviors.same
} }
} }

View file

@ -784,7 +784,7 @@ class AvatarActor(
} match { } match {
case Some((implant, slot)) => case Some((implant, slot)) =>
if (!implant.initialized) { if (!implant.initialized) {
log.error(s"requested activation of uninitialized implant $implant") log.warn(s"requested activation of uninitialized implant $implantType")
} else if ( } else if (
!consumeStamina(implant.definition.ActivationStaminaCost) || !consumeStamina(implant.definition.ActivationStaminaCost) ||
avatar.stamina < implant.definition.StaminaCost avatar.stamina < implant.definition.StaminaCost
@ -877,7 +877,7 @@ class AvatarActor(
val totalStamina = math.min(avatar.maxStamina, avatar.stamina + stamina) val totalStamina = math.min(avatar.maxStamina, avatar.stamina + stamina)
val fatigued = if (avatar.fatigued && totalStamina >= 20) { val fatigued = if (avatar.fatigued && totalStamina >= 20) {
avatar.implants.zipWithIndex.foreach { avatar.implants.zipWithIndex.foreach {
case (Some(implant), slot) => case (Some(_), slot) =>
sessionActor ! SessionActor.SendResponse( sessionActor ! SessionActor.SendResponse(
AvatarImplantMessage(session.get.player.GUID, ImplantAction.OutOfStamina, slot, 0) AvatarImplantMessage(session.get.player.GUID, ImplantAction.OutOfStamina, slot, 0)
) )
@ -1103,16 +1103,15 @@ class AvatarActor(
AvatarImplantMessage(session.get.player.GUID, ImplantAction.Initialization, slot, 0) AvatarImplantMessage(session.get.player.GUID, ImplantAction.Initialization, slot, 0)
) )
) )
Some(implant.copy(initialized = false)) Some(implant.copy(initialized = false, active = false))
case (None, _) => None case (None, _) => None
}) })
} }
def deactivateImplant(implantType: ImplantType): Unit = { def deactivateImplant(implantType: ImplantType): Unit = {
val res = avatar.implants.zipWithIndex.collectFirst { avatar.implants.zipWithIndex.collectFirst {
case (Some(implant), index) if implant.definition.implantType == implantType => (implant, index) case (Some(implant), index) if implant.definition.implantType == implantType => (implant, index)
} } match {
res match {
case Some((implant, slot)) => case Some((implant, slot)) =>
implantTimers(slot).cancel() implantTimers(slot).cancel()
avatar = avatar.copy( avatar = avatar.copy(