Skip to content

Commit

Permalink
[hotfix] fix mia on server-sent stop (#284)
Browse files Browse the repository at this point in the history
Hotfix for now, but the whole extract+quit out logic will need to be
simplified/unified in the next major release.

Sequence of events triggering the bug:
- guest extracts (regardless of exfil type/map)
- guest's collider is disabled so that existing players do not get
bodyblocked
- no more collision with exfil point means `OnCancelExtraction` is
called, which has new "runner" detection logic, setting the exit status
to mia (restoring "default" value)
- host quits (i.e. pressed F8)
- host's `profileId` is before guest's `profileId` in the `Players` list
- host "kicks" all players including itself before it "kicks" the guest
- nodejs server sees host left, sends a "everybody leave now!" message
to all remaining connected players, including guest
- guest leaves without recomputing its exit status, which was set to MIA
by `OnCancelExtraction` above
- player sad
  • Loading branch information
mihaicm93 authored Apr 24, 2024
2 parents 55bb507 + 1b02684 commit 2682798
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Source/Coop/SITGameModes/CoopSITGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1273,17 +1273,17 @@ public void CreateExfiltrationPointAndInitDeathHandler()

private void ExfiltrationPoint_OnCancelExtraction(ExfiltrationPoint point, EFT.Player player)
{
if (!player.IsYourPlayer)
if (!player.IsYourPlayer || ExtractedPlayers.Contains(player.ProfileId))
{
return;
}

Logger.LogDebug($"{nameof(ExfiltrationPoint_OnCancelExtraction)} {point.Settings.Name} {point.Status}");
ExtractingPlayers.Remove(player.ProfileId);

var matchEnd = Singleton<BackendConfigSettingsClass>.Instance.Experience.MatchEnd;

BackendConfigSettingsClass.BackendConfigSettingsClassExperience.BackendConfigSettingsClassMatchEnd matchEnd = Singleton<BackendConfigSettingsClass>.Instance.Experience.MatchEnd;


if (Profile_0.EftStats.SessionCounters.GetAllInt(new object[] { CounterTag.Exp }) > matchEnd.SurvivedExpRequirement ||
if (Profile_0.EftStats.SessionCounters.GetAllInt([CounterTag.Exp]) > matchEnd.SurvivedExpRequirement ||
RaidTimeUtil.GetElapsedRaidSeconds() > matchEnd.SurvivedTimeRequirement)
{
MyExitStatus = (player.HealthController.IsAlive ? ExitStatus.MissingInAction : ExitStatus.Killed);
Expand Down Expand Up @@ -1387,15 +1387,19 @@ public override void Stop(string profileId, ExitStatus exitStatus, string exitNa
// If I am the Host/Server, then ensure all the bots have left too
if (SITMatchmaking.IsServer)
{
var hostProfileId = Singleton<GameWorld>.Instance.MainPlayer.ProfileId;
foreach (var p in SITGameComponent.GetCoopGameComponent().Players)
{
AkiBackendCommunication.Instance.PostJson("/coop/server/update", new Dictionary<string, object>() {

var pid = p.Value.ProfileId;
// make sure the host does not "leave game" before other players since Relay has special handling Aki-side
if (pid != hostProfileId)
{
AkiBackendCommunication.Instance.PostJson("/coop/server/update", new Dictionary<string, object>() {
{ "m", "PlayerLeft" },
{ "profileId", p.Value.ProfileId },
{ "profileId", pid },
{ "serverId", SITGameComponent.GetServerId() }

}.ToJson());
}
}
}

Expand Down

0 comments on commit 2682798

Please sign in to comment.