streamlined messaging; no longer query database if no need to query database exists

This commit is contained in:
Jason_DiDonato@yahoo.com 2021-11-01 10:44:18 -04:00
parent 92ada951e5
commit 6d61ff034a
2 changed files with 22 additions and 16 deletions

View file

@ -366,30 +366,26 @@ class AvatarActor(
result.onComplete {
case Success((loadouts, implants, certs, locker)) =>
val validatedLocker = if (avatar.locker.HasGUID || avatar.locker.Inventory.Size > 0) {
//if locker shows indication of being previously used, this player is rejoining an active session
avatar.locker
} else {
locker
}
avatar = 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 = validatedLocker
locker = locker
)
staminaRegenTimer.cancel()
staminaRegenTimer = defaultStaminaRegen()
replyTo ! AvatarLoginResponse(avatar)
case Failure(e) => log.error(e)("db failure")
case Failure(e) =>
log.error(e)("db failure")
}
Behaviors.same
case ReplaceAvatar(newAvatar) =>
replaceAvatar(newAvatar)
staminaRegenTimer.cancel()
staminaRegenTimer = defaultStaminaRegen()
Behaviors.same
case AddFirstTimeEvent(event) =>

View file

@ -431,9 +431,7 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
accountPersistence ! AccountPersistenceService.Login(avatar.name)
case AvatarActor.AvatarLoginResponse(avatar) =>
session = session.copy(avatar = avatar)
Deployables.InitializeDeployableQuantities(avatar)
cluster ! ICS.FilterZones(_ => true, context.self)
avatarLoginResponse(avatar)
case packet: PlanetSideGamePacket =>
handleGamePkt(packet)
@ -1390,7 +1388,7 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
deadState = DeadState.RespawnTime
session = session.copy(player = new Player(avatar))
//ay-coordinates indicate sanctuary spawn bias:
//xy-coordinates indicate sanctuary spawn bias:
player.Position = math.abs(scala.util.Random.nextInt() % avatar.name.hashCode % 4) match {
case 0 => Vector3(8192, 8192, 0) //NE
case 1 => Vector3(8192, 0, 0) //SE
@ -1422,7 +1420,7 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
persist()
setupAvatarFunc = AvatarRejoin
avatarActor ! AvatarActor.ReplaceAvatar(a)
avatarActor ! AvatarActor.LoginAvatar(context.self)
avatarLoginResponse(a)
case (Some(a), Some(p)) =>
//convert player to a corpse (unless in vehicle); automatic recall to closest spawn point
@ -1433,7 +1431,7 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
player.Zone = inZone
HandleReleaseAvatar(p, inZone)
avatarActor ! AvatarActor.ReplaceAvatar(a)
avatarActor ! AvatarActor.LoginAvatar(context.self)
avatarLoginResponse(a)
case (Some(a), None) =>
//respawn avatar as a new player; automatic recall to closest spawn point
@ -1452,7 +1450,7 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
}, avatar = a
)
avatarActor ! AvatarActor.ReplaceAvatar(a)
avatarActor ! AvatarActor.LoginAvatar(context.self)
avatarLoginResponse(a)
case _ =>
//fall back to sanctuary/prior?
@ -9378,6 +9376,18 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
heightLast = zHeight
}
/**
* During login, when the avatar is set, the response code sets up session and deployable toolbox stats.
* Immediately contact the interstellar cluster to deal with zoning conditions.
* Only call this once during login and never any time after that.
* @param avatar the avatar being set as the current one belonging to this session
*/
def avatarLoginResponse(avatar: Avatar): Unit = {
session = session.copy(avatar = avatar)
Deployables.InitializeDeployableQuantities(avatar)
cluster ! ICS.FilterZones(_ => true, context.self)
}
def failWithError(error: String) = {
log.error(error)
middlewareActor ! MiddlewareActor.Teardown()