Skip to content

Commit 4ff997f

Browse files
committed
style: clean up
1 parent 2445061 commit 4ff997f

File tree

256 files changed

+760
-618
lines changed

Some content is hidden

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

256 files changed

+760
-618
lines changed

src/OTAPI.UnifiedServerProcess.GlobalNetwork/ChatHandler.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
using OTAPI.UnifiedServerProcess.GlobalNetwork.Network;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
72
using Terraria.Localization;
83
using UnifiedServerProcess;
94

src/OTAPI.UnifiedServerProcess.GlobalNetwork/Network/Router.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Terraria;
55
using Terraria.Localization;
66
using Terraria.Net.Sockets;
7-
using UnifiedServerProcess;
87

98
namespace OTAPI.UnifiedServerProcess.GlobalNetwork.Network
109
{
@@ -284,7 +283,7 @@ void LaunchBroadcast() {
284283
}
285284
while (keepBroadcasting);
286285
}
287-
catch {
286+
catch {
288287
keepBroadcasting = false;
289288
}
290289
}

src/OTAPI.UnifiedServerProcess.GlobalNetwork/Network/SyncHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void SendRawData(ServerContext server, int plr, byte[] data, int offset,
9090
},
9191
null, plr);
9292
}
93-
static unsafe void SendSmallPacket<TPacket>(ServerContext server, int plr, TPacket packet) where TPacket : unmanaged, INetPacket {
93+
static unsafe void SendSmallPacket<TPacket>(ServerContext server, int plr, TPacket packet) where TPacket : unmanaged, INetPacket {
9494
var client = server.Netplay.Clients[plr];
9595
short size = (short)(sizeof(TPacket) + 4);
9696
var bufferArray = new byte[size];

src/OTAPI.UnifiedServerProcess.GlobalNetwork/Program.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using OTAPI.UnifiedServerProcess.GlobalNetwork.CLI;
2-
using OTAPI.UnifiedServerProcess.GlobalNetwork.Network;
1+
using OTAPI.UnifiedServerProcess.GlobalNetwork.Network;
32
using OTAPI.UnifiedServerProcess.GlobalNetwork.Servers;
43
using ReLogic.OS;
5-
using System.Diagnostics;
6-
using System.Diagnostics.Metrics;
7-
using System.Reflection;
8-
using System.Threading.Tasks;
94
using UnifiedServerProcess;
105

116
namespace OTAPI.UnifiedServerProcess.GlobalNetwork
@@ -24,7 +19,7 @@ static void Main(string[] args) {
2419
Console.WriteLine(@"---------------------------------------------------------------------------------------------------");
2520
Console.WriteLine(@" Demonstration For Terraria v{0} & OTAPI v{1} ", version.TerrariaVersion, version.OTAPIVersion);
2621
Console.WriteLine(@"---------------------------------------------------------------------------------------------------");
27-
22+
2823
WorkRunner.RunTimedWork("Global initialization started...", () => {
2924
SynchronizedGuard.Load();
3025
NetworkPatcher.Load();
@@ -57,7 +52,7 @@ static void Main(string[] args) {
5752
var tcs = new TaskCompletionSource();
5853
router.Started += () => tcs.SetResult();
5954
return tcs;
60-
},
55+
},
6156
() => {
6257
Console.WriteLine();
6358
Console.WriteLine("[USP] Unified Server Process Launched successfully.");

src/OTAPI.UnifiedServerProcess/Core/Patching/FieldFilterPatching/InitialFieldModificationProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ bool UsedStaticField(MethodDefinition method) {
718718
if (!UsedStaticField(resolvedCallee)) {
719719
continue;
720720
}
721-
721+
722722

723723
HashSet<Instruction> tmp = [];
724724
ExtractSources(this, method, tmp, inst);

src/OTAPI.UnifiedServerProcess/ModAssemblyMerger.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Mono.Cecil.Cil;
44
using Mono.Cecil.Rocks;
55
using Mono.Collections.Generic;
6-
using Mono.CompilerServices.SymbolWriter;
76
using MonoMod.Utils;
87
using OTAPI.UnifiedServerProcess.Extensions;
98
using System;
@@ -39,7 +38,7 @@ public ModAssemblyMerger(ModContext context, params System.Reflection.Assembly[]
3938
modder.PrePatchModule(mod);
4039
modder.PatchModule(mod);
4140
modderTypes = module.GetAllTypes().ToDictionary(x => x.FullName, x => x);
42-
41+
4342
foreach (var type in mod.GetAllTypes()) {
4443
var mappedType = module.GetType(type.FullName) ?? throw new NotSupportedException();
4544
AdjustTypeInfo(module, mod, type, mappedType);
@@ -54,9 +53,10 @@ public ModAssemblyMerger(ModContext context, params System.Reflection.Assembly[]
5453
}
5554

5655
private static void AdjustTypeInfo(ModuleDefinition target, ModuleDefinition mod, TypeDefinition type, TypeDefinition mappedType) {
57-
if (mappedType.DeclaringType is not null && mappedType.DeclaringType.Name == "<PrivateImplementationDetails>") {
58-
mappedType.Attributes = TypeAttributes.NestedPrivate | TypeAttributes.ExplicitLayout | TypeAttributes.Sealed;
59-
}
56+
mappedType.Attributes = type.Attributes;
57+
//if (mappedType.DeclaringType is not null && mappedType.DeclaringType.Name == "<PrivateImplementationDetails>") {
58+
// mappedType.Attributes = TypeAttributes.NestedPrivate | TypeAttributes.ExplicitLayout | TypeAttributes.Sealed;
59+
//}
6060
if (mappedType.IsStruct()) {
6161
mappedType.ClassSize = type.ClassSize;
6262
mappedType.PackingSize = type.PackingSize;
@@ -103,7 +103,7 @@ private static void AdjustMembers(ModuleDefinition target, ModuleDefinition mod,
103103
}
104104
AdjustMemberAttributes(target, mod, property.CustomAttributes);
105105
}
106-
foreach (var eventDef in mappedType.Events.ToArray()) {
106+
foreach (var eventDef in mappedType.Events.ToArray()) {
107107
var eventType = eventDef.EventType;
108108
if (RedirectTypeRef(target, mod, ref eventType)) {
109109
eventDef.EventType = eventType;
@@ -123,7 +123,7 @@ private static void AdjustMembers(ModuleDefinition target, ModuleDefinition mod,
123123
}
124124
AdjustMemberAttributes(target, mod, param.CustomAttributes);
125125
}
126-
foreach (var genericParam in method.GenericParameters) {
126+
foreach (var genericParam in method.GenericParameters) {
127127
foreach (var constraint in genericParam.Constraints) {
128128
var constraintType = constraint.ConstraintType;
129129
if (RedirectTypeRef(target, mod, ref constraintType)) {
@@ -223,7 +223,7 @@ static void AdjustInstructions(ModuleDefinition target, ModuleDefinition mod, Ty
223223
var returnType = callSite.ReturnType;
224224
RedirectTypeRef(target, mod, ref returnType);
225225
callSite.ReturnType = returnType;
226-
foreach (var arg in callSite.Parameters) {
226+
foreach (var arg in callSite.Parameters) {
227227
var argType = arg.ParameterType;
228228
RedirectTypeRef(target, mod, ref argType);
229229
arg.ParameterType = argType;
@@ -272,7 +272,7 @@ static MethodReference RedirectElementMethodRef(ModuleDefinition target, ModuleD
272272
}
273273
static void SetModTypePlaceholder(ModuleDefinition module, Dictionary<string, TypeDefinition> uspTypes, TypeDefinition modType, TypeDefinition? declaringType) {
274274
if (!uspTypes.TryGetValue(modType.FullName, out var target)) {
275-
target = new TypeDefinition(modType.Namespace, modType.Name, modType.Attributes, modType.BaseType) {
275+
target = new TypeDefinition(modType.Namespace, modType.Name, modType.Attributes, modType.BaseType) {
276276
Attributes = modType.Attributes,
277277
};
278278
if (declaringType is not null) {
@@ -324,7 +324,7 @@ static void AdjustMemberAttributes(ModuleDefinition target, ModuleDefinition mod
324324
attributes.Clear();
325325
foreach (var attr in array) {
326326
var mappedAttr = MapCustomAttribute(target, mod, attr);
327-
if (mappedAttr != null) {
327+
if (mappedAttr != null) {
328328
attributes.Add(mappedAttr);
329329
}
330330
}

src/OTAPI.UnifiedServerProcess/Mods/NetplayMod.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ void NetplayConnectionCheck(ModFwModder modder) {
3939
}
4040
}
4141

42-
namespace Terraria {
42+
namespace Terraria
43+
{
4344
public class NetMessage
4445
{
4546
public static bool CheckCanSend(int clientIndex) {

src/OTAPI.UnifiedServerProcess/Mods/RemoteClientMod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class patch_RemoteClient : RemoteClient
2929
public new void mfwh_orig_ctor_RemoteClient() {
3030
Name = "Anonymous";
3131
StatusText = "";
32-
TileSections = new bool[2,2];
32+
TileSections = new bool[2, 2];
3333
SpamProjectileMax = 100f;
3434
SpamAddBlockMax = 100f;
3535
SpamDeleteBlockMax = 500f;

src/TrProtocol.SerializerGenerator/CompilationContext.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
using System.Diagnostics.CodeAnalysis;
44
using TrProtocol.SerializerGenerator.Internal.Extensions;
55

6-
namespace TrProtocol.SerializerGenerator {
7-
public class CompilationContext : IEqualityComparer<Compilation> {
6+
namespace TrProtocol.SerializerGenerator
7+
{
8+
public class CompilationContext : IEqualityComparer<Compilation>
9+
{
810
bool IEqualityComparer<Compilation>.Equals(Compilation x, Compilation y) {
911
var ax = x.Assembly;
1012
var ay = y.Assembly;
@@ -136,33 +138,25 @@ void ForEachChild(SyntaxNode node, string? parentName, string? parantTypeName) {
136138
ForEachChild(child, null, null);
137139
}
138140
}
139-
if (node is NamespaceDeclarationSyntax nd)
140-
{
141-
if (parentName is null)
142-
{
141+
if (node is NamespaceDeclarationSyntax nd) {
142+
if (parentName is null) {
143143
parentName = nd.Name.ToString();
144144
}
145-
else
146-
{
145+
else {
147146
parentName = $"{parentName}.{nd.Name}";
148147
}
149-
foreach (var child in node.ChildNodes())
150-
{
148+
foreach (var child in node.ChildNodes()) {
151149
ForEachChild(child, parentName, null);
152150
}
153151
}
154-
else if (node is FileScopedNamespaceDeclarationSyntax fsnd)
155-
{
156-
if (parentName is null)
157-
{
152+
else if (node is FileScopedNamespaceDeclarationSyntax fsnd) {
153+
if (parentName is null) {
158154
parentName = fsnd.Name.ToString();
159155
}
160-
else
161-
{
156+
else {
162157
parentName = $"{parentName}.{fsnd.Name}";
163158
}
164-
foreach (var child in node.ChildNodes())
165-
{
159+
foreach (var child in node.ChildNodes()) {
166160
ForEachChild(child, parentName, null);
167161
}
168162
}

src/TrProtocol.SerializerGenerator/Internal/Diagnostics/DiagnosticException.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using Microsoft.CodeAnalysis;
22

3-
namespace TrProtocol.SerializerGenerator.Internal.Diagnostics {
3+
namespace TrProtocol.SerializerGenerator.Internal.Diagnostics
4+
{
45

5-
public class DiagnosticException : Exception {
6+
public class DiagnosticException : Exception
7+
{
68
public Diagnostic Diagnostic;
79
public DiagnosticException(Diagnostic diagnostic) {
810
Diagnostic = diagnostic;

0 commit comments

Comments
 (0)