Skip to content

Commit 90aee18

Browse files
committed
Merge remote-tracking branch 'upstream/master' into MBF
2 parents bc9a990 + dabcd18 commit 90aee18

File tree

1,205 files changed

+341172
-31510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,205 files changed

+341172
-31510
lines changed

.github/workflows/update-wiki.yml

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ on:
66
branches: [ master, jsondump ]
77
paths:
88
- '.github/workflows/update-wiki.yml'
9-
- 'Content.Shared/Chemistry/**.cs'
10-
- 'Content.Server/Chemistry/**.cs'
11-
- 'Content.Server/GuideGenerator/**.cs'
12-
- 'Content.Server/Corvax/GuideGenerator/**.cs'
13-
- 'Resources/Prototypes/Reagents/**.yml'
14-
- 'Resources/Prototypes/Chemistry/**.yml'
15-
- 'Resources/Prototypes/Recipes/Reactions/**.yml'
9+
- 'Content.Shared/**'
10+
- 'Content.Server/**'
11+
- 'Content.Client/**'
12+
- 'Resources/**'
1613
- 'RobustToolbox/'
17-
- 'Resources/Locale/**.ftl'
1814

1915
jobs:
2016
update-wiki:
@@ -52,52 +48,53 @@ jobs:
5248
run: dotnet ./bin/Content.Server/Content.Server.dll --cvar autogen.destination_file=prototypes.json
5349
continue-on-error: true
5450

55-
- name: Upload chem_prototypes.json to wiki
56-
uses: jtmullen/mediawiki-edit-action@v0.1.1
57-
with:
58-
wiki_text_file: ./bin/Content.Server/data/chem_prototypes.json
59-
edit_summary: Update chem_prototypes.json via GitHub Actions
60-
page_name: "${{ secrets.WIKI_PAGE_ROOT }}/chem_prototypes.json"
61-
api_url: ${{ secrets.WIKI_ROOT_URL }}/api.php
62-
username: ${{ secrets.WIKI_BOT_USER }}
63-
password: ${{ secrets.WIKI_BOT_PASS }}
64-
65-
- name: Upload react_prototypes.json to wiki
66-
uses: jtmullen/mediawiki-edit-action@v0.1.1
67-
with:
68-
wiki_text_file: ./bin/Content.Server/data/react_prototypes.json
69-
edit_summary: Update react_prototypes.json via GitHub Actions
70-
page_name: "${{ secrets.WIKI_PAGE_ROOT }}/react_prototypes.json"
71-
api_url: ${{ secrets.WIKI_ROOT_URL }}/api.php
72-
username: ${{ secrets.WIKI_BOT_USER }}
73-
password: ${{ secrets.WIKI_BOT_PASS }}
74-
75-
- name: Upload entity_prototypes.json to wiki
76-
uses: jtmullen/mediawiki-edit-action@v0.1.1
77-
with:
78-
wiki_text_file: ./bin/Content.Server/data/entity_prototypes.json
79-
edit_summary: Update entity_prototypes.json via GitHub Actions
80-
page_name: "${{ secrets.WIKI_PAGE_ROOT }}/entity_prototypes.json"
81-
api_url: ${{ secrets.WIKI_ROOT_URL }}/api.php
82-
username: ${{ secrets.WIKI_BOT_USER }}
83-
password: ${{ secrets.WIKI_BOT_PASS }}
84-
85-
- name: Upload mealrecipes_prototypes.json to wiki
86-
uses: jtmullen/mediawiki-edit-action@v0.1.1
87-
with:
88-
wiki_text_file: ./bin/Content.Server/data/mealrecipes_prototypes.json
89-
edit_summary: Update mealrecipes_prototypes.json via GitHub Actions
90-
page_name: "${{ secrets.WIKI_PAGE_ROOT }}/mealrecipes_prototypes.json"
91-
api_url: ${{ secrets.WIKI_ROOT_URL }}/api.php
92-
username: ${{ secrets.WIKI_BOT_USER }}
93-
password: ${{ secrets.WIKI_BOT_PASS }}
94-
95-
- name: Upload loc.json to wiki
96-
uses: jtmullen/mediawiki-edit-action@v0.1.1
97-
with:
98-
wiki_text_file: ./bin/Content.Server/data/loc.json
99-
edit_summary: Update loc.json via GitHub Actions
100-
page_name: "${{ secrets.WIKI_PAGE_ROOT }}/loc.json"
101-
api_url: ${{ secrets.WIKI_ROOT_URL }}/api.php
102-
username: ${{ secrets.WIKI_BOT_USER }}
103-
password: ${{ secrets.WIKI_BOT_PASS }}
51+
# Проходит по всем JSON-файлам в директории BASE и загружает каждый файл как страницу в MediaWiki.
52+
# Имя страницы формируется из относительного пути к файлу.
53+
- name: Upload JSON files to wiki
54+
shell: bash
55+
run: |
56+
set -euo pipefail
57+
58+
BASE="./bin/Content.Server/data"
59+
ROOT="${{ secrets.WIKI_PAGE_ROOT }}"
60+
API="${{ secrets.WIKI_ROOT_URL }}/api.php"
61+
USER="${{ secrets.WIKI_BOT_USER }}"
62+
PASS="${{ secrets.WIKI_BOT_PASS }}"
63+
64+
API="$(printf "%s" "$API" | tr -d '\r\n' | sed 's/[[:space:]]*$//')"
65+
USER="$(printf "%s" "$USER" | tr -d '\r\n')"
66+
PASS="$(printf "%s" "$PASS" | tr -d '\r\n')"
67+
ROOT="$(printf "%s" "$ROOT" | tr -d '\r\n' | sed 's/[[:space:]]*$//')"
68+
69+
cookiejar="$(mktemp)"
70+
trap 'rm -f "$cookiejar"' EXIT
71+
72+
login_token=$(curl -sS -c "$cookiejar" --data "action=query&meta=tokens&type=login&format=json" "$API" | jq -r '.query.tokens.logintoken')
73+
curl -sS -c "$cookiejar" -b "$cookiejar" \
74+
--data-urlencode "action=login" \
75+
--data-urlencode "lgname=$USER" \
76+
--data-urlencode "lgpassword=$PASS" \
77+
--data-urlencode "lgtoken=$login_token" \
78+
--data-urlencode "format=json" \
79+
"$API" > /dev/null
80+
81+
find "$BASE" -type f -name '*.json' | while IFS= read -r file; do
82+
rel="${file#$BASE/}"
83+
rel="$(printf "%s" "$rel" | tr -d '\r\n' | sed 's/:/_/g')"
84+
page="$ROOT/$rel"
85+
echo "Uploading $rel → $page"
86+
87+
token=$(curl -sS -b "$cookiejar" --data "action=query&meta=tokens&format=json" "$API" | jq -r '.query.tokens.csrftoken')
88+
89+
curl -sS -b "$cookiejar" \
90+
--data-urlencode "action=edit" \
91+
--data-urlencode "title=$page" \
92+
--data-urlencode "summary=Update $rel via GitHub Actions" \
93+
--data-urlencode "text@${file}" \
94+
--data-urlencode "token=$token" \
95+
--data-urlencode "bot=true" \
96+
--data-urlencode "minor=true" \
97+
--data-urlencode "assert=bot" \
98+
--data-urlencode "format=json" \
99+
"$API" | jq -r '.'
100+
done
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System.Threading.Tasks;
2+
using BenchmarkDotNet.Attributes;
3+
using Content.IntegrationTests;
4+
using Content.IntegrationTests.Pair;
5+
using Content.Server.Atmos.EntitySystems;
6+
using Content.Shared.Atmos;
7+
using Robust.Shared;
8+
using Robust.Shared.Analyzers;
9+
using Robust.Shared.GameObjects;
10+
11+
namespace Content.Benchmarks;
12+
13+
[Virtual]
14+
[GcServer(true)]
15+
[MemoryDiagnoser]
16+
public class HeatCapacityBenchmark
17+
{
18+
private TestPair _pair = default!;
19+
private IEntityManager _sEntMan = default!;
20+
private IEntityManager _cEntMan = default!;
21+
private Client.Atmos.EntitySystems.AtmosphereSystem _cAtmos = default!;
22+
private AtmosphereSystem _sAtmos = default!;
23+
private GasMixture _mix;
24+
25+
[GlobalSetup]
26+
public async Task SetupAsync()
27+
{
28+
ProgramShared.PathOffset = "../../../../";
29+
PoolManager.Startup();
30+
_pair = await PoolManager.GetServerClient();
31+
await _pair.Connect();
32+
_cEntMan = _pair.Client.ResolveDependency<IEntityManager>();
33+
_sEntMan = _pair.Server.ResolveDependency<IEntityManager>();
34+
_cAtmos = _cEntMan.System<Client.Atmos.EntitySystems.AtmosphereSystem>();
35+
_sAtmos = _sEntMan.System<AtmosphereSystem>();
36+
37+
const float volume = 2500f;
38+
const float temperature = 293.15f;
39+
40+
const float o2 = 12.3f;
41+
const float n2 = 45.6f;
42+
const float co2 = 0.42f;
43+
const float plasma = 0.05f;
44+
45+
_mix = new GasMixture(volume) { Temperature = temperature };
46+
47+
_mix.AdjustMoles(Gas.Oxygen, o2);
48+
_mix.AdjustMoles(Gas.Nitrogen, n2);
49+
_mix.AdjustMoles(Gas.CarbonDioxide, co2);
50+
_mix.AdjustMoles(Gas.Plasma, plasma);
51+
}
52+
53+
[Benchmark]
54+
public async Task ClientHeatCapacityBenchmark()
55+
{
56+
await _pair.Client.WaitPost(delegate
57+
{
58+
for (var i = 0; i < 10000; i++)
59+
{
60+
_cAtmos.GetHeatCapacity(_mix, applyScaling: true);
61+
}
62+
});
63+
}
64+
65+
[Benchmark]
66+
public async Task ServerHeatCapacityBenchmark()
67+
{
68+
await _pair.Server.WaitPost(delegate
69+
{
70+
for (var i = 0; i < 10000; i++)
71+
{
72+
_sAtmos.GetHeatCapacity(_mix, applyScaling: true);
73+
}
74+
});
75+
}
76+
77+
[GlobalCleanup]
78+
public async Task CleanupAsync()
79+
{
80+
await _pair.DisposeAsync();
81+
PoolManager.Shutdown();
82+
}
83+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Runtime.CompilerServices;
2+
using Content.Shared.Atmos;
3+
4+
namespace Content.Client.Atmos.EntitySystems;
5+
6+
public sealed partial class AtmosphereSystem
7+
{
8+
/*
9+
Partial class for operations involving GasMixtures.
10+
11+
Any method that is overridden here is usually because the server-sided implementation contains
12+
code that would escape sandbox. As such these methods are overridden here with a safe
13+
implementation.
14+
*/
15+
16+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
17+
protected override float GetHeatCapacityCalculation(float[] moles, bool space)
18+
{
19+
// Little hack to make space gas mixtures have heat capacity, therefore allowing them to cool down rooms.
20+
if (space && MathHelper.CloseTo(NumericsHelpers.HorizontalAdd(moles), 0f))
21+
{
22+
return Atmospherics.SpaceHeatCapacity;
23+
}
24+
25+
// explicit stackalloc call is banned on client tragically.
26+
// the JIT does not stackalloc this during runtime,
27+
// though this isnt the hottest code path so it should be fine
28+
// the gc can eat a little as a treat
29+
var tmp = new float[moles.Length];
30+
NumericsHelpers.Multiply(moles, GasSpecificHeats, tmp);
31+
// Adjust heat capacity by speedup, because this is primarily what
32+
// determines how quickly gases heat up/cool.
33+
return MathF.Max(NumericsHelpers.HorizontalAdd(tmp), Atmospherics.MinimumHeatCapacity);
34+
}
35+
}

Content.Client/Atmos/EntitySystems/AtmosphereSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Content.Client.Atmos.EntitySystems;
77

8-
public sealed class AtmosphereSystem : SharedAtmosphereSystem
8+
public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
99
{
1010
public override void Initialize()
1111
{

Content.Client/BarSign/BarSignSystem.cs

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Content.Shared.BarSign;
2+
using Content.Shared.Power;
3+
using Robust.Client.GameObjects;
4+
using Robust.Shared.Prototypes;
5+
6+
namespace Content.Client.BarSign;
7+
8+
public sealed class BarSignVisualizerSystem : VisualizerSystem<BarSignComponent>
9+
{
10+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
11+
12+
protected override void OnAppearanceChange(EntityUid uid, BarSignComponent component, ref AppearanceChangeEvent args)
13+
{
14+
AppearanceSystem.TryGetData<bool>(uid, PowerDeviceVisuals.Powered, out var powered, args.Component);
15+
AppearanceSystem.TryGetData<string>(uid, BarSignVisuals.BarSignPrototype, out var currentSign, args.Component);
16+
17+
if (powered
18+
&& currentSign != null
19+
&& _prototypeManager.Resolve<BarSignPrototype>(currentSign, out var proto))
20+
{
21+
SpriteSystem.LayerSetSprite((uid, args.Sprite), 0, proto.Icon);
22+
args.Sprite?.LayerSetShader(0, "unshaded");
23+
}
24+
else
25+
{
26+
SpriteSystem.LayerSetRsiState((uid, args.Sprite), 0, "empty");
27+
args.Sprite?.LayerSetShader(0, null, null);
28+
}
29+
}
30+
}

Content.Client/BarSign/Ui/BarSignBoundUserInterface.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,27 @@ protected override void Open()
1919
var sign = EntMan.GetComponentOrNull<BarSignComponent>(Owner)?.Current is { } current
2020
? _prototype.Index(current)
2121
: null;
22-
var allSigns = Shared.BarSign.BarSignSystem.GetAllBarSigns(_prototype)
22+
var allSigns = BarSignSystem.GetAllBarSigns(_prototype)
2323
.OrderBy(p => Loc.GetString(p.Name))
2424
.ToList();
2525
_menu = new(sign, allSigns);
2626

2727
_menu.OnSignSelected += id =>
2828
{
29-
SendMessage(new SetBarSignMessage(id));
29+
SendPredictedMessage(new SetBarSignMessage(id));
3030
};
3131

3232
_menu.OnClose += Close;
3333
_menu.OpenCentered();
3434
}
3535

36-
public void Update(ProtoId<BarSignPrototype>? sign)
36+
public override void Update()
3737
{
38-
if (_prototype.Resolve(sign, out var signPrototype))
39-
_menu?.UpdateState(signPrototype);
40-
}
41-
42-
protected override void Dispose(bool disposing)
43-
{
44-
base.Dispose(disposing);
45-
if (!disposing)
38+
if (!EntMan.TryGetComponent<BarSignComponent>(Owner, out var signComp))
4639
return;
47-
_menu?.Dispose();
40+
41+
if (_prototype.Resolve(signComp.Current, out var signPrototype))
42+
_menu?.UpdateState(signPrototype);
4843
}
4944
}
5045

0 commit comments

Comments
 (0)