Skip to content

Commit 955c99f

Browse files
committed
3.3.7 for Terraria 1.4.5.5
1 parent 074e45a commit 955c99f

4 files changed

Lines changed: 38 additions & 34 deletions

File tree

OTAPI.Patcher/OTAPI.Patcher.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net9.0</TargetFramework>
6-
<Version>3.3.6</Version>
6+
<Version>3.3.7</Version>
77
<PreserveCompilationContext>true</PreserveCompilationContext>
88
<RuntimeIdentifiers>win;osx;linux;</RuntimeIdentifiers>
99
<Nullable>enable</Nullable>
10-
<PackageReleaseNotes>Terraria 1.4.5.4 on .NET9</PackageReleaseNotes>
10+
<PackageReleaseNotes>Terraria 1.4.5.5 on .NET9</PackageReleaseNotes>
1111
</PropertyGroup>
1212
<ItemGroup>
1313
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.15" />

OTAPI.Patcher/Resolvers/PCFileResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class PCFileResolver : IFileResolver
2828
{
2929
public const String TerrariaWebsite = "https://terraria.org";
3030

31-
public virtual string SupportedDownloadUrl { get; } = $"{TerrariaWebsite}/api/download/pc-dedicated-server/terraria-server-1454.zip";
31+
public virtual string SupportedDownloadUrl { get; } = $"{TerrariaWebsite}/api/download/pc-dedicated-server/terraria-server-1455.zip";
3232

3333
public virtual string GetUrlFromHttpResponse(string content)
3434
{

OTAPI.Patcher/Targets/IPatchTarget.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ public static void AddConstants(this IModPatchTarget target, string inputName, M
162162
constants.Add($"{inputName}_1448_OrAbove");
163163
if (version >= new Version("1.4.5"))
164164
constants.Add($"{inputName}_1450_OrAbove");
165+
if (version >= new Version("1.4.5.5"))
166+
constants.Add($"{inputName}_1455_OrAbove");
165167

166168
target.ModContext.ReferenceConstants.AddRange(constants.Select(x => $"#define {x}"));
167169

OTAPI.Scripts/Patches/ModifyCollisionSwitchTiles.Server.cs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,52 +33,55 @@ You should have received a copy of the GNU General Public License
3333
[MonoModIgnore]
3434
partial class CollisionSwitchTiles
3535
{
36-
//static ParameterDefinition Entity { get; set; }
37-
//static MethodDefinition SwitchTiles { get; set; }
38-
3936
[Modification(ModType.PreMerge, "Patching Collision.SwitchTiles")]
40-
static void ModifyCollisionSwitchTiles(ModFramework.ModFwModder modder)
37+
public static void ModifyCollisionSwitchTiles(ModFwModder modder)
4138
{
39+
#if TerrariaServer_1455_OrAbove
40+
var csr = modder.GetILCursor(() => Terraria.Collision.SwitchTiles(default, default, 0, 0, default, 0));
41+
#else
4242
var csr = modder.GetILCursor(() => Terraria.Collision.SwitchTiles(default, 0, 0, default, 0));
43+
#endif
4344
var redirects = csr.Method.DeclaringType.Methods
4445
.Where(x => (HookEmitter.HookMethodNamePrefix + x.Name) == csr.Method.Name || ("orig_" + x.Name) == csr.Method.Name)
4546
.Select(x => x.GetILCursor())
4647
.ToArray();
47-
//SwitchTiles = csr.Method;
4848

4949
foreach (var method in redirects.Append(csr))
5050
{
51-
ParameterDefinition entity;
52-
method.Method.Parameters.Add(entity = new("entity",
53-
ParameterAttributes.HasDefault | ParameterAttributes.Optional,
54-
55-
modder.Module.ImportReference(modder.GetDefinition<Terraria.Entity>())
56-
)
51+
ParameterDefinition? entity = method.Method.Parameters.FirstOrDefault(x => x.Name == "entity");
52+
if(entity is null) // 1455 added this natively.
5753
{
58-
Constant = null
59-
});
54+
method.Method.Parameters.Add(entity = new("entity",
55+
ParameterAttributes.HasDefault | ParameterAttributes.Optional,
6056

61-
modder.OnRewritingMethodBody += (MonoModder modder, MethodBody body, Instruction instr, int instri) =>
62-
{
63-
if (instr.Operand is MethodReference methodReference &&
64-
methodReference.DeclaringType.Name == method.Method.DeclaringType.Name &&
65-
methodReference.Name == method.Method.Name
57+
modder.Module.ImportReference(modder.GetDefinition<Terraria.Entity>())
6658
)
6759
{
68-
if (methodReference.Parameters.Any(x => x.Name == entity.Name))
69-
return;
60+
Constant = null
61+
});
7062

71-
methodReference.Parameters.Add(entity);
72-
73-
if (body.Method.DeclaringType.BaseType.FullName == typeof(Terraria.Entity).FullName)
63+
modder.OnRewritingMethodBody += (MonoModder modder, MethodBody body, Instruction instr, int instri) =>
64+
{
65+
if (instr.Operand is MethodReference methodReference &&
66+
methodReference.DeclaringType.Name == method.Method.DeclaringType.Name &&
67+
methodReference.Name == method.Method.Name
68+
)
7469
{
75-
body.GetILProcessor().InsertBefore(instr,
76-
new { OpCodes.Ldarg_0 }
77-
);
70+
if (methodReference.Parameters.Any(x => x.Name == entity.Name))
71+
return;
72+
73+
methodReference.Parameters.Add(entity);
74+
75+
if (body.Method.DeclaringType.BaseType.FullName == typeof(Terraria.Entity).FullName)
76+
{
77+
body.GetILProcessor().InsertBefore(instr,
78+
new { OpCodes.Ldarg_0 }
79+
);
80+
}
81+
else throw new NotImplementedException($"{body.Method.Name} is not a supported caller for this modification");
7882
}
79-
else throw new NotImplementedException($"{body.Method.Name} is not a supported caller for this modification");
80-
}
81-
};
83+
};
84+
}
8285

8386
// inject the callback if the target
8487
if(method == csr)
@@ -121,8 +124,7 @@ static void ModifyCollisionSwitchTiles(ModFramework.ModFwModder modder)
121124
}
122125
}
123126

124-
125-
[MonoMod.MonoModIgnore]
127+
[MonoModIgnore]
126128
public delegate bool PressurePlateCallback(int x, int y, Terraria.Entity entity);
127129

128130
namespace OTAPI

0 commit comments

Comments
 (0)