diff --git a/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala b/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala index f30759472..29364076d 100644 --- a/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala +++ b/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala @@ -2535,7 +2535,7 @@ class ZoningOperations( if (player.outfit_id == 0) { SessionOutfitHandlers.HandleLoginOutfitCheck(player, sessionLogic) } - //make weather happen + /*make weather happen sendResponse(WeatherMessage(List(),List( StormInfo(Vector3(0.1f, 0.15f, 0.0f), 240, 217), StormInfo(Vector3(0.5f, 0.11f, 0.0f), 240, 215), @@ -2547,7 +2547,7 @@ class ZoningOperations( StormInfo(Vector3(0.9f, 0.57f, 0.0f), 244, 215), StormInfo(Vector3(0.9f, 0.9f, 0.0f), 243, 215), StormInfo(Vector3(0.1f, 0.2f, 0.0f), 241, 215), - StormInfo(Vector3(0.95f, 0.2f, 0.0f), 241, 215)))) + StormInfo(Vector3(0.95f, 0.2f, 0.0f), 241, 215))))*/ //begin looking for conditions to set the avatar context.system.scheduler.scheduleOnce(delay = 250 millisecond, context.self, SessionActor.SetCurrentAvatar(player, 200)) } @@ -2659,7 +2659,7 @@ class ZoningOperations( } setupAvatarFunc = AvatarCreate SessionOutfitHandlers.HandleLoginOutfitCheck(player, sessionLogic) - //make weather happen + /*make weather happen sendResponse(WeatherMessage(List(),List( StormInfo(Vector3(0.1f, 0.15f, 0.0f), 240, 217), StormInfo(Vector3(0.5f, 0.11f, 0.0f), 240, 215), @@ -2671,7 +2671,7 @@ class ZoningOperations( StormInfo(Vector3(0.9f, 0.57f, 0.0f), 244, 215), StormInfo(Vector3(0.9f, 0.9f, 0.0f), 243, 215), StormInfo(Vector3(0.1f, 0.2f, 0.0f), 241, 215), - StormInfo(Vector3(0.95f, 0.2f, 0.0f), 241, 215)))) + StormInfo(Vector3(0.95f, 0.2f, 0.0f), 241, 215))))*/ //begin looking for conditions to set the avatar context.system.scheduler.scheduleOnce(delay = 750 millisecond, context.self, SessionActor.SetCurrentAvatar(player, 200)) } diff --git a/src/main/scala/net/psforever/services/teamwork/SquadService.scala b/src/main/scala/net/psforever/services/teamwork/SquadService.scala index 3c372ee13..926dba54e 100644 --- a/src/main/scala/net/psforever/services/teamwork/SquadService.scala +++ b/src/main/scala/net/psforever/services/teamwork/SquadService.scala @@ -8,7 +8,7 @@ import scala.collection.concurrent.TrieMap import scala.collection.mutable // import net.psforever.actors.session.SessionActor -import net.psforever.objects.{LivePlayerList, Player} +import net.psforever.objects.{Default, LivePlayerList, Player} import net.psforever.objects.teamwork.{Member, Squad, SquadFeatures} import net.psforever.objects.avatar.{Avatar, Certification} import net.psforever.objects.definition.converter.StatConverter @@ -591,10 +591,32 @@ class SquadService extends Actor { .collect { case leavingPlayer if GetParticipatingSquad(leavingPlayer).contains(features) => //kicked player must be in the same squad if (actingPlayer == leader) { - if (leavingPlayer == leader || squad.Size == 2) { - //squad leader is leaving his own squad, so it will be disbanded - //OR squad is only composed of two people, so it will be closed-out when one of them leaves + if (squad.Size == 2) { + //squad is only composed of two people, so it will be closed-out when one of them leaves DisbandSquad(features) + } else if (leavingPlayer == leader) { + //squad leader leaves; promote another member + squad.Membership.drop(1).find { _.CharId > 0 } match { + case Some(member) => + //leader was shifted into a subordinate position and will retire from duty + SquadActionMembershipPromote( + leavingPlayer, + member.CharId, + features, + SquadServiceMessage(null, null, SquadAction.Membership(SquadRequestType.Promote, leavingPlayer, Some(member.CharId), member.Name, None)), + Default.Actor + ) + import scala.concurrent.duration._ + import context.dispatcher + context.system.scheduler.scheduleOnce(500.milliseconds) { + GetParticipatingSquad(leavingPlayer).foreach { updatedFeatures => + LeaveSquad(leavingPlayer, updatedFeatures) + } + } + case _ => + //the squad will be disbanded + DisbandSquad(features) + } } else { //kicked by the squad leader subs.Publish( @@ -1093,8 +1115,28 @@ class SquadService extends Actor { if (size > 2) { GetLeadingSquad(charId, pSquadOpt) match { case Some(_) => - //leader of a squad; the squad will be disbanded. Same logic as when a SL uses /leave and the squad is disbanded. - DisbandSquad(features) + //leader of a squad; search for a suitable substitute leader + squad.Membership.drop(1).find { _.CharId > 0 } match { + case Some(member) => + //leader was shifted into a subordinate position and will retire from duty + SquadActionMembershipPromote( + charId, + member.CharId, + features, + SquadServiceMessage(null, null, SquadAction.Membership(SquadRequestType.Promote, charId, Some(member.CharId), member.Name, None)), + Default.Actor + ) + import scala.concurrent.duration._ + import context.dispatcher + context.system.scheduler.scheduleOnce(500.milliseconds) { + GetParticipatingSquad(charId).foreach { updatedFeatures => + LeaveSquad(charId, updatedFeatures) + } + } + case _ => + //the squad will be disbanded + DisbandSquad(features) + } case None => //not the leader of a full squad; tell other members that we are leaving SquadSwitchboard.PanicLeaveSquad(