Skip to content

Commit

Permalink
Merge branch 'SerbiaStrong-220:master' into PumpkinLantern-Craft
Browse files Browse the repository at this point in the history
  • Loading branch information
Helm4142 authored Feb 23, 2025
2 parents 34fb012 + 8241016 commit 2bdd457
Show file tree
Hide file tree
Showing 63 changed files with 954 additions and 389 deletions.
52 changes: 41 additions & 11 deletions .github/workflows/labeler-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,49 @@

on:
pull_request_review:
types: [submitted]
types: [submitted, edited, dismissed]

permissions: write-all

jobs:
remove_label:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
permissions:
actions: write
pull-requests: write
contents: write
if: github.event.review.state == 'approved'
steps:
- uses: actions-ecosystem/action-remove-labels@v1
with:
labels: |
Status: Needs Review
Status: Awaiting Changes
- name: check all revs
id: check_approvals
uses: actions/github-script@v7
with:
script: |
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const requiredApprovals = context.payload.pull_request.requested_reviewers.length;
const approvedReviews = reviews.filter(review => review.state === 'APPROVED').length;
return approvedReviews >= requiredApprovals;
- name: rm labels
if: steps.check_approvals.outputs.result == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labelsToRemove = ['Status: Needs Review', 'Status: Awaiting Changes'];
const currentLabels = context.payload.pull_request.labels.map(label => label.name);
for (const label of labelsToRemove) {
if (currentLabels.includes(label)) {
await github.request("DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}", {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: label,
});
}
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 0 additions & 7 deletions .github/workflows/labeler-mapping-issues-and-untriaged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,4 @@ jobs:
issue_number: context.issue.number,
assignees: [selectedOption.assignee]
}); // added assignee
} else {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ["Status: Needs Labels"]
}); // add "Status: Needs Labels"
}
10 changes: 6 additions & 4 deletions Content.Server/Connection/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ session.Status is SessionStatus.Connected or SessionStatus.InGame

// Corvax-Start: Allow privileged players bypass bunker
var isPrivileged = await HavePrivilegedJoin(e.UserId);
if (_cfg.GetCVar(CCVars.PanicBunkerEnabled) && adminData == null && !isPrivileged)
var sponsorBypass = await _discordPlayerManager.HasPriorityJoinTierAsync(e.UserId) && _discordPlayerManager.HaveFreeSponsorSlot(); // SS220 Sponsors
if (_cfg.GetCVar(CCVars.PanicBunkerEnabled) && adminData == null && !isPrivileged && !sponsorBypass) // SS220 Sponsors
// Corvax-End
{
var showReason = _cfg.GetCVar(CCVars.PanicBunkerShowReason);
Expand Down Expand Up @@ -306,7 +307,8 @@ session.Status is SessionStatus.Connected or SessionStatus.InGame
softPlayerCount -= _adminManager.ActiveAdmins.Count();
}

if ((softPlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && !adminBypass) && !wasInGame && !isQueueEnabled) // Corvax-Queue
if ((softPlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && !adminBypass && !wasInGame && !isQueueEnabled && // Corvax-Queue
!sponsorBypass)) // SS220 Sponsors
{
return (ConnectionDenyReason.Full, Loc.GetString("soft-player-cap-full"), null);
}
Expand Down Expand Up @@ -397,12 +399,12 @@ private bool HasTemporaryBypass(NetUserId user)
public async Task<bool> HavePrivilegedJoin(NetUserId userId)
{
var isAdmin = await _db.GetAdminDataForAsync(userId) != null;
var havePriorityJoin = _sponsorsManager.TryGetInfo(userId, out var sponsor) && sponsor.HavePriorityJoin; // Corvax-Sponsors
// var havePriorityJoin = _sponsorsManager.TryGetInfo(userId, out var sponsor) && sponsor.HavePriorityJoin; // SS220 Sponsors
var wasInGame = EntitySystem.TryGet<GameTicker>(out var ticker) &&
ticker.PlayerGameStatuses.TryGetValue(userId, out var status) &&
status == PlayerGameStatus.JoinedGame;
return isAdmin ||
havePriorityJoin || // Corvax-Sponsors
//havePriorityJoin || // SS220 Sponsors
wasInGame;
}
// Corvax-Queue-End
Expand Down
56 changes: 50 additions & 6 deletions Content.Server/Corvax/JoinQueue/JoinQueueManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.CCVar;
using Content.Shared.Corvax.CCCVars;
using Content.Shared.Corvax.JoinQueue;
using Content.Shared.Destructible;
using Prometheus;
using Robust.Server.Player;
using Robust.Shared.Configuration;
Expand Down Expand Up @@ -87,9 +88,10 @@ private async void OnPlayerVerified(object? sender, ICommonSession session)
}

var isPrivileged = await _connectionManager.HavePrivilegedJoin(session.UserId);
var sponsorBypass = await _discordPlayerManager.HasPriorityJoinTierAsync(session.UserId) && _discordPlayerManager.HaveFreeSponsorSlot(); // SS220 Sponsor
var currentOnline = _playerManager.PlayerCount - 1; // Do not count current session in general online, because we are still deciding her fate
var haveFreeSlot = currentOnline < _cfg.GetCVar(CCVars.SoftMaxPlayers);
if (isPrivileged || haveFreeSlot)
if (isPrivileged || haveFreeSlot || sponsorBypass) // SS220 Sponsor
{
SendToGame(session);

Expand Down Expand Up @@ -130,17 +132,37 @@ private void ProcessQueue(bool isDisconnect, DateTime connectedTime)
if (isDisconnect)
players--; // Decrease currently disconnected session but that has not yet been deleted

var haveFreeSlot = players < _cfg.GetCVar(CCVars.SoftMaxPlayers);
// SS220 sponsors begin
//var haveFreeSlot = players < _cfg.GetCVar(CCVars.SoftMaxPlayers);
//var haveFreeSponsorSlot = _connectionManager.HaveFreeSponsorSlot(); // SS220 sponsors
//var queueContains = _queue.Count > 0;
//if (haveFreeSlot && queueContains)
//{
// var session = _queue.First();
// _queue.Remove(session);

// SendToGame(session);

// QueueTimings.WithLabels("Waited").Observe((DateTime.UtcNow - connectedTime).TotalSeconds);
//}

var queueContains = _queue.Count > 0;
if (haveFreeSlot && queueContains)
if (queueContains)
{
SortQueueBySponsors();
var session = _queue.First();
_queue.Remove(session);

SendToGame(session);
var canDequeue = CanDequeue(players, session);
if (canDequeue)
{
_queue.Remove(session);

SendToGame(session);

QueueTimings.WithLabels("Waited").Observe((DateTime.UtcNow - connectedTime).TotalSeconds);
QueueTimings.WithLabels("Waited").Observe((DateTime.UtcNow - connectedTime).TotalSeconds);
}
}
// SS220 sponsors end

SendUpdateMessages();
QueueCount.Set(_queue.Count);
Expand Down Expand Up @@ -169,4 +191,26 @@ private void SendToGame(ICommonSession s)
{
Timer.Spawn(0, () => _playerManager.JoinGame(s));
}

// SS220 sponsors begin
private void SortQueueBySponsors()
{
_queue.Sort((ICommonSession s1, ICommonSession s2) =>
{
var s1HasPriorityJoin = _discordPlayerManager.HasPriorityJoinTier(s1.UserId);
var s2HasPriorityJoin = _discordPlayerManager.HasPriorityJoinTier(s2.UserId);
if (s1HasPriorityJoin && !s2HasPriorityJoin) return -1;
else if (!s1HasPriorityJoin && s2HasPriorityJoin) return 1;
else return 0;
});
}

private bool CanDequeue(int actualPlayers, ICommonSession session)
{
var sponsorBypass = _discordPlayerManager.HasPriorityJoinTier(session.UserId) && _discordPlayerManager.HaveFreeSponsorSlot();
var haveFreeSlot = actualPlayers < _cfg.GetCVar(CCVars.SoftMaxPlayers);

return haveFreeSlot || sponsorBypass;
}
// SS220 sponsors end
}
16 changes: 16 additions & 0 deletions Content.Server/Forensics/Systems/ForensicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Cloning;
using Content.Shared.DoAfter;
using Content.Shared.Forensics;
using Content.Shared.Forensics.Components;
Expand Down Expand Up @@ -35,6 +36,8 @@ public override void Initialize()
SubscribeLocalEvent<FingerprintComponent, MapInitEvent>(OnFingerprintInit);
SubscribeLocalEvent<DnaComponent, MapInitEvent>(OnDNAInit);

SubscribeLocalEvent<DnaComponent, CloningEvent>(OnDNACloning); //ss220 add cloning entity copy DNA from source

SubscribeLocalEvent<ForensicsComponent, BeingGibbedEvent>(OnBeingGibbed);
SubscribeLocalEvent<ForensicsComponent, MeleeHitEvent>(OnMeleeHit);
SubscribeLocalEvent<ForensicsComponent, GotRehydratedEvent>(OnRehydrated);
Expand Down Expand Up @@ -79,6 +82,19 @@ private void OnDNAInit(EntityUid uid, DnaComponent component, MapInitEvent args)
}
}

//ss220 add cloning entity copy DNA from source start
private void OnDNACloning(Entity<DnaComponent> ent, ref CloningEvent args)
{
if (!TryComp<DnaComponent>(args.Target, out var sourceDnaComp))
return;

sourceDnaComp.DNA = ent.Comp.DNA;

var ev = new GenerateDnaEvent { Owner = args.Target, DNA = ent.Comp.DNA };
RaiseLocalEvent(args.Target, ref ev);
}
//ss220 add cloning entity copy DNA from source end

private void OnBeingGibbed(EntityUid uid, ForensicsComponent component, BeingGibbedEvent args)
{
string dna = Loc.GetString("forensics-dna-unknown");
Expand Down
12 changes: 12 additions & 0 deletions Content.Server/SS220/AirlockVisuals/AirlockVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Robust.Shared.GameStates;

namespace Content.Server.SS220.AirlockVisuals;

/// <summary>
/// This component used for our airlock visuals
/// </summary>
[RegisterComponent]
public sealed partial class AirlockVisualsComponent : Component
{

}
19 changes: 19 additions & 0 deletions Content.Server/SS220/AirlockVisuals/AirlockVisualsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Content.Shared.Doors.Components;
using Robust.Server.GameObjects;

namespace Content.Server.SS220.AirlockVisuals;

public sealed class AirlockVisualsSystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;

public override void Initialize()
{
SubscribeLocalEvent<AirlockVisualsComponent, ComponentInit>(OnComponentInit);
}

private void OnComponentInit(Entity<AirlockVisualsComponent> ent, ref ComponentInit args)
{
_appearance.SetData(ent.Owner, DoorVisuals.ClosedLights, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Server.SS220.BackendApi.ResponseModels;

internal sealed class ServerStatusResponseModel
{
public int PlayersCount { get; set; }

public TimeSpan RoundDuration { get; set; }

public int AdminCount { get; set; }
}
Loading

0 comments on commit 2bdd457

Please sign in to comment.