Skip to content

Commit 132c3fc

Browse files
committed
style: clean up
1 parent 7965389 commit 132c3fc

File tree

20 files changed

+42
-78
lines changed

20 files changed

+42
-78
lines changed

src/OTAPI.UnifiedServerProcess/Commons/IL.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Code.Ldloca_S or
251251
variable = method.Body.Variables[localIndex];
252252
return true;
253253
}
254-
public static bool MatchLoadVariable(MethodDefinition method, Instruction instruction, [NotNullWhen(true)] out VariableDefinition? variable) {
254+
public static bool MatchLoadVariable(MethodDefinition method, Instruction instruction, [NotNullWhen(true)] out VariableDefinition? variable) {
255255
VariableDefinition? tmpCheck = null;
256256

257257
var localIndex = instruction.OpCode.Code switch {

src/OTAPI.UnifiedServerProcess/Commons/Stack.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Mono.Cecil;
22
using Mono.Cecil.Cil;
33
using MonoMod.Cil;
4-
using OTAPI.UnifiedServerProcess.Extensions;
5-
using OTAPI.UnifiedServerProcess.Optimize.FastCollections;
64
using OTAPI.UnifiedServerProcess.Optimize.LinkObjects;
75
using System;
86
using System.Collections.Generic;
@@ -360,7 +358,7 @@ static void FindEndpoints(IEnumerable<Instruction> nodes, out Instruction min, o
360358

361359
Instruction leftCursor = start;
362360
HashSet<Instruction> leftCollected = [];
363-
Instruction rightCursor = start;
361+
Instruction rightCursor = start;
364362
HashSet<Instruction> rightCollected = [];
365363

366364
while (nodeSet.Count > 0) {
@@ -380,7 +378,7 @@ static void FindEndpoints(IEnumerable<Instruction> nodes, out Instruction min, o
380378
if (nodeSet.Count == 0) break;
381379

382380
if (rightCursor.Next != null) {
383-
rightCursor = rightCursor.Next;
381+
rightCursor = rightCursor.Next;
384382

385383
rightCollected.Add(rightCursor);
386384

src/OTAPI.UnifiedServerProcess/Core/Analysis/ParameterFlowAnalysis/ParameterFlowAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ void HandleStoreCollectionElements(Instruction instruction) {
609609
.First();
610610
if (instancePath.StackTopType is null)
611611
return;
612-
var instanceInstr = instancePath.RealPushValueInstruction;
612+
var instanceInstr = instancePath.RealPushValueInstruction;
613613
var valuesPath = MonoModCommon.Stack.AnalyzeStackTopTypeAllPaths(method, path.ParametersSources[1].Instructions.Last(), jumpSites)
614614
.First();
615615
if (valuesPath.StackTopType is null)

src/OTAPI.UnifiedServerProcess/Core/FunctionalFeatures/IMethodCheckCacheFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static bool CheckUsedContextBoundField<TFeature>(
9595
if (methodRef.Name.OrdinalStartsWith("add_")) {
9696
autoDeleFieldName = methodRef.Name[4..];
9797
}
98-
else if (methodRef.Name.OrdinalStartsWith("remove_")) {
98+
else if (methodRef.Name.OrdinalStartsWith("remove_")) {
9999
autoDeleFieldName = methodRef.Name[7..];
100100
}
101101
if (autoDeleFieldName is null) {

src/OTAPI.UnifiedServerProcess/Core/FunctionalFeatures/IStaticModificationCheckFeature.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public interface IStaticModificationCheckFeature : IJumpSitesCacheFeature
1919
}
2020
public static class StaticModificationCheckFeatureExtensions
2121
{
22-
public static bool IsAboutStaticFieldModification(this IStaticModificationCheckFeature point,
22+
public static bool IsAboutStaticFieldModification(this IStaticModificationCheckFeature point,
2323
MethodDefinition method,
24-
Instruction inst,
24+
Instruction inst,
2525
[NotNullWhen(true)] out HashSet<FieldDefinition>? modifiedFields, [NotNullWhen(true)] out HashSet<Instruction>? modificationOperations) {
2626

2727
modifiedFields = [];
@@ -63,7 +63,7 @@ public static bool IsAboutStaticFieldModification(this IStaticModificationCheckF
6363
return true;
6464
}
6565
public static bool IsReferencedStaticFieldModified(this IStaticModificationCheckFeature point,
66-
MethodDefinition method,
66+
MethodDefinition method,
6767
Instruction pushedFieldReference,
6868
[NotNullWhen(true)] out Dictionary<string, SingleStaticFieldTrace>? modified,
6969
[NotNullWhen(true)] out HashSet<Instruction>? modificationOperations) {
@@ -93,7 +93,7 @@ public static bool IsReferencedStaticFieldModified(this IStaticModificationCheck
9393
!path.ParametersSources[paramIndex].Instructions.Contains(pushedFieldReference)) {
9494
continue;
9595
}
96-
96+
9797
modificationOperations.Add(usage);
9898

9999
foreach (var referencedFieldTracing in trace.TrackedStaticFields.Values) {

src/OTAPI.UnifiedServerProcess/Core/Infrastructure/CacheManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Mono.Cecil;
22
using OTAPI.UnifiedServerProcess.Loggers;
33
using System;
4-
using System.Collections.Generic;
54
using System.IO;
65
using System.Linq;
76

src/OTAPI.UnifiedServerProcess/Core/NetworkLogicPruner.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
using MonoMod.Utils;
77
using OTAPI.UnifiedServerProcess.Commons;
88
using OTAPI.UnifiedServerProcess.Extensions;
9-
using System;
109
using System.Collections.Generic;
1110
using System.Linq;
12-
using System.Text;
13-
using System.Threading.Tasks;
1411

1512
namespace OTAPI.UnifiedServerProcess.Core
1613
{
@@ -90,8 +87,8 @@ public void Prune() {
9087
checking = checking.Next;
9188
}
9289

93-
if (blockEnd.OpCode != OpCodes.Ret
94-
&& blockEnd.OpCode != OpCodes.Br
90+
if (blockEnd.OpCode != OpCodes.Ret
91+
&& blockEnd.OpCode != OpCodes.Br
9592
&& blockEnd.OpCode != OpCodes.Br_S
9693
&& blockEnd != switchEnd) {
9794

@@ -123,7 +120,7 @@ public void Prune() {
123120

124121
var data = (-1, -1);
125122

126-
for (int i = 0; i < method.Body.Instructions.Count; ) {
123+
for (int i = 0; i < method.Body.Instructions.Count;) {
127124
var reachableInst = method.Body.Instructions[i];
128125
CanReachCurrentInstruction(method.Body, jumpSites, switchBlockEnd, reachableInst, removes, indexMap, ref i, ref data);
129126
reachableInstructions.Add(reachableInst);
@@ -141,16 +138,16 @@ public void Prune() {
141138

142139
void CanReachCurrentInstruction(
143140

144-
MethodBody body,
141+
MethodBody body,
145142
Dictionary<Instruction, List<Instruction>> jumpSites,
146-
Dictionary<Instruction, Instruction> switchBlockToEnd,
147-
Instruction instruction,
148-
List<Instruction> rm,
143+
Dictionary<Instruction, Instruction> switchBlockToEnd,
144+
Instruction instruction,
145+
List<Instruction> rm,
149146
Dictionary<Instruction, int> indexMap,
150147

151148
ref int index, ref (int end_dedServIsTrueBlock, int end_skipMenuIsFalseBlock) data) {
152149

153-
150+
154151
if (index > data.end_dedServIsTrueBlock) {
155152
data.end_dedServIsTrueBlock = -1;
156153
}
@@ -259,7 +256,7 @@ void CanReachCurrentInstruction(
259256
return;
260257

261258
static bool CheckIsJumpOutOfBlock(MethodBody body, Instruction instruction, Dictionary<Instruction, Instruction> switchBlockToEnd, List<Instruction> rm, Dictionary<Instruction, int> indexMap, ref int index, int endOfBlock) {
262-
259+
263260
if (endOfBlock >= 0) {
264261

265262
if (instruction.OpCode == OpCodes.Br || instruction.OpCode == OpCodes.Br_S) {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using Mono.Cecil;
22
using OTAPI.UnifiedServerProcess.Core.Patching.Framework;
3-
using System.Collections;
43
using System.Collections.Generic;
5-
using System.Diagnostics.CodeAnalysis;
64

75
namespace OTAPI.UnifiedServerProcess.Core.Patching.FieldFilterPatching
86
{
9-
7+
108
public class FilterArgumentSource(ModuleDefinition module, MethodDefinition[] initialMethods) : Argument, IArgumentSource<FilterArgumentSource, FilterArgument>
119
{
1210
public ModuleDefinition MainModule = module;
@@ -15,8 +13,8 @@ public class FilterArgumentSource(ModuleDefinition module, MethodDefinition[] in
1513
public Dictionary<string, FieldDefinition> ModifiedStaticFields = [];
1614
public Dictionary<string, FieldDefinition> InitialStaticFields = [];
1715
public FilterArgument Build() => new(
18-
MainModule,
19-
[.. UnmodifiedStaticFields.Values],
16+
MainModule,
17+
[.. UnmodifiedStaticFields.Values],
2018
[.. ModifiedStaticFields.Values],
2119
[.. InitialStaticFields.Values]);
2220
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
using OTAPI.UnifiedServerProcess.Loggers;
2-
using System;
3-
using System.Collections.Generic;
42
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
73

84
namespace OTAPI.UnifiedServerProcess.Core.Patching.FieldFilterPatching
95
{

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using OTAPI.UnifiedServerProcess.Extensions;
2-
using OTAPI.UnifiedServerProcess.Loggers;
1+
using OTAPI.UnifiedServerProcess.Loggers;
32
using System.Collections.Generic;
43
using System.Linq;
54

@@ -27,8 +26,6 @@ public class ForceStaticProcessor() : IFieldFilterArgProcessor
2726
"Terraria.Localization.GameCulture",
2827
// ignore hit tile, it should not run on server
2928
"Terraria.HitTile",
30-
31-
"Terraria.ObjectData.TileObjectData._baseObject"
3229
];
3330
public void Apply(LoggedComponent logger, ref FilterArgumentSource source) {
3431
foreach (var modified in source.ModifiedStaticFields.ToArray()) {

0 commit comments

Comments
 (0)