Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix antag selection being evil #28197

Merged
merged 15 commits into from
May 26, 2024
3 changes: 3 additions & 0 deletions Content.IntegrationTests/Tests/GameRules/NukeOpsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public async Task TryStopNukeOpsFromConstantlyFailing()
var invSys = server.System<InventorySystem>();
var factionSys = server.System<NpcFactionSystem>();

// test urist is a noob let him be nukie
server.CfgMan.SetCVar(CCVars.GameRoleTimers, false);

deltanedas marked this conversation as resolved.
Show resolved Hide resolved
Assert.That(server.CfgMan.GetCVar(CCVars.GridFill), Is.False);
server.CfgMan.SetCVar(CCVars.GridFill, true);

Expand Down
11 changes: 1 addition & 10 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,11 @@ public AntagSelectionPlayerPool GetPlayerPool(Entity<AntagSelectionComponent> en
{
var preferredList = new List<ICommonSession>();
var fallbackList = new List<ICommonSession>();
var unwantedList = new List<ICommonSession>();
var invalidList = new List<ICommonSession>();
foreach (var session in sessions)
{
if (!IsSessionValid(ent, session, def) ||
!IsEntityValid(session.AttachedEntity, def))
{
invalidList.Add(session);
continue;
}

var pref = (HumanoidCharacterProfile) _pref.GetPreferences(session.UserId).SelectedCharacter;
if (def.PrefRoles.Count != 0 && pref.AntagPreferences.Any(p => def.PrefRoles.Contains(p)))
Expand All @@ -345,13 +340,9 @@ public AntagSelectionPlayerPool GetPlayerPool(Entity<AntagSelectionComponent> en
{
fallbackList.Add(session);
}
else
{
unwantedList.Add(session);
}
}

return new AntagSelectionPlayerPool(new() { preferredList, fallbackList, unwantedList, invalidList });
return new AntagSelectionPlayerPool(new() { preferredList, fallbackList });
Copy link
Member

@VasilisThePikachu VasilisThePikachu May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When i was trying to fix this myself i basically did the same thing. My only consairn and why i never made a pr was cause. What happens if we got no one in the prefferedlist or fallbacklist? Are we starting the gamemode without any antags. This resulting in a broken gamerule/greenshift.

Yes i agree this should be intended behavior (#24292). But i don't think we currently have a solution to prevent broken gamerules.

Copy link
Contributor Author

@deltanedas deltanedas May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this doesnt cancel it, but nukies should be changed to make spawners if theres not enough players like in my issue
traitors zombies etc doesnt really matter as theres no unused map lying around doing nothing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik it also picks people at random in game not just in the lobby (look at sleeper agents. There are reports that players get sleeper agent given to them when they never opted in)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this fixes that since it wont pick anyone that didnt opt in

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the unwanted list but not the invalid one at least until we have ways of setting up ghost roles and other rules properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the majority of the issue is people that arent opted in getting picked, invalid is only really picked in a dev environment. nukies making ghost roles for missing players wyci

}

/// <summary>
Expand Down
Loading