Skip to content

Commit 5edf3b7

Browse files
authored
Merge branch 'SignatureBeef:upcoming' into upcoming
2 parents 318066d + 1fdc42b commit 5edf3b7

20 files changed

Lines changed: 189 additions & 68 deletions

.github/workflows/ci-nuget.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ jobs:
2424
patch_target: p,
2525
package_path: OTAPI.PC.nupkg,
2626
},
27-
{
28-
name: Mobile,
29-
patch_target: m,
30-
package_path: OTAPI.Mobile.nupkg,
31-
},
32-
{
33-
name: tModLoader,
34-
patch_target: t,
35-
package_path: OTAPI.TML.nupkg,
36-
},
27+
# {
28+
# name: Mobile,
29+
# patch_target: m,
30+
# package_path: OTAPI.Mobile.nupkg,
31+
# },
32+
# {
33+
# name: tModLoader,
34+
# patch_target: t,
35+
# package_path: OTAPI.TML.nupkg,
36+
# },
3737
]
3838

3939
name: ${{ matrix.profile.name }} Server

OTAPI.Client.Launcher/OTAPI.Client.Launcher.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
</ItemGroup>
5454
<ItemGroup>
5555
<PackageReference Include="ImGui.NET" Version="1.91.6.1" GeneratePathProperty="true" />
56-
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.14" GeneratePathProperty="true" />
57-
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.14" GeneratePathProperty="true" />
58-
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.14" GeneratePathProperty="true" />
56+
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.15" GeneratePathProperty="true" />
57+
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.15" GeneratePathProperty="true" />
58+
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.15" GeneratePathProperty="true" />
5959
<PackageReference Include="SharpZipLib" Version="1.4.2" />
6060
<PackageReference Include="System.Drawing.Common" Version="9.0.2" />
6161
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="22.7.31.1" />

OTAPI.Patcher/OTAPI.Patcher.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net9.0</TargetFramework>
6-
<Version>3.2.5</Version>
6+
<Version>3.3.0</Version>
77
<PreserveCompilationContext>true</PreserveCompilationContext>
88
<RuntimeIdentifiers>win;osx;linux;</RuntimeIdentifiers>
99
<Nullable>enable</Nullable>
10-
<PackageReleaseNotes>Terraria 1.4.4.9 on .NET9</PackageReleaseNotes>
10+
<PackageReleaseNotes>Terraria 1.4.5.0 on .NET9</PackageReleaseNotes>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.14" />
14-
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.14" />
15-
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.14" />
13+
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.15" />
14+
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.15" />
15+
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.15" />
1616
<PackageReference Include="Steamworks.NET" Version="2024.8.0" />
1717
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="22.7.31.1" />
1818
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.2.3" />

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-1449.zip";
31+
public virtual string SupportedDownloadUrl { get; } = $"{TerrariaWebsite}/api/download/pc-dedicated-server/terraria-server-1450.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
@@ -160,6 +160,8 @@ public static void AddConstants(this IModPatchTarget target, string inputName, M
160160
constants.Add($"{inputName}_1442_OrAbove");
161161
if (version >= new Version("1.4.4.8"))
162162
constants.Add($"{inputName}_1448_OrAbove");
163+
if (version >= new Version("1.4.5"))
164+
constants.Add($"{inputName}_1450_OrAbove");
163165

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

OTAPI.Scripts/Mods/HookCommandProcessing.Server.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ void HookCommandProcessing(MonoModder modder)
4747
throw new NotSupportedException("Expected the second variable to be string");
4848

4949
var exceptionHandler = startDedInputCallBack.Body.ExceptionHandlers.Single(
50-
x => x.TryStart.Next.OpCode == OpCodes.Ldstr
50+
x => (
51+
x.TryStart.Next.OpCode == OpCodes.Ldstr
5152
&& x.TryStart.Next.Operand.Equals("CLI.Help_Command")
53+
) || (
54+
x.TryStart.OpCode == OpCodes.Ldstr
55+
&& x.TryStart.Operand.Equals("CLI.Help_Command")
56+
)
5257
);
5358

5459
startDedInputCallBack.Goto(exceptionHandler.TryStart, MoveType.Before);

OTAPI.Scripts/Mods/HookNpcBossBag.Server.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ void HookNpcBossBag(ModFramework.ModFwModder modder)
3939
})
4040
{
4141
var callback = csr.Module.ImportReference(
42-
#if TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
42+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
43+
modder.GetMethodDefinition(() => OTAPI.Hooks.NPC.InvokeBossBag(null, 0, 0, 0, 0, 0, 0, false, 0, false, null))
44+
#elif TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
4345
modder.GetMethodDefinition(() => OTAPI.Hooks.NPC.InvokeBossBag(null, 0, 0, 0, 0, 0, 0, false, 0, false, false, null))
4446
#else
4547
modder.GetMethodDefinition(() => OTAPI.Hooks.NPC.InvokeBossBag(0, 0, 0, 0, 0, 0, false, 0, false, false, null))
@@ -98,6 +100,9 @@ public class BossBagEventArgs : EventArgs
98100
public bool NoBroadcast { get; set; }
99101
public int Pfix { get; set; }
100102
public bool NoGrabDelay { get; set; }
103+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
104+
[Obsolete("ReverseLookup is no longer used in Terraria 1.4.5 and above, but is kept for API compatibility.")]
105+
#endif
101106
public bool ReverseLookup { get; set; }
102107
}
103108
public static event EventHandler<BossBagEventArgs> BossBag;
@@ -115,7 +120,9 @@ public static int InvokeBossBag(
115120
bool noBroadcast,
116121
int pfix,
117122
bool noGrabDelay,
123+
#if !TerrariaServer_1450_OrAbove && !Terraria__1450_OrAbove && !tModLoader_1450_OrAbove
118124
bool reverseLookup,
125+
#endif
119126
Terraria.NPC npc
120127
)
121128
{
@@ -133,14 +140,19 @@ Terraria.NPC npc
133140
NoBroadcast = noBroadcast,
134141
Pfix = pfix,
135142
NoGrabDelay = noGrabDelay,
143+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
144+
ReverseLookup = false, // no longer used, but kept for api compatibility.
145+
#else
136146
ReverseLookup = reverseLookup,
147+
#endif
137148
Npc = npc,
138149
};
139150
BossBag?.Invoke(null, args);
140151
if (args.Result == HookResult.Cancel)
141152
return -1;
142-
143-
#if TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
153+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
154+
return Terraria.Item.NewItem(Source, args.X, args.Y, args.Width, args.Height, args.Type, args.Stack, args.NoBroadcast, args.Pfix, args.NoGrabDelay);
155+
#elif TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
144156
return Terraria.Item.NewItem(Source, args.X, args.Y, args.Width, args.Height, args.Type, args.Stack, args.NoBroadcast, args.Pfix, args.NoGrabDelay, args.ReverseLookup);
145157
#else
146158
return Terraria.Item.NewItem(args.X, args.Y, args.Width, args.Height, args.Type, args.Stack, args.NoBroadcast, args.Pfix, args.NoGrabDelay, args.ReverseLookup);

OTAPI.Scripts/Mods/HookNpcKilled.Server.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ void HookNpcKilled(MonoModder modder)
3434
{
3535
var checkDead = modder.GetILCursor(() => (new Terraria.NPC()).checkDead());
3636

37+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
38+
var declaringType = "Terraria.NPC";
39+
#else
40+
var declaringType = "Terraria.Entity";
41+
#endif
42+
3743
checkDead.GotoNext(
3844
// active = false;
3945
i => i.OpCode == OpCodes.Ldc_I4_0
40-
, i => i.OpCode == OpCodes.Stfld && i.Operand is FieldReference fieldReference && fieldReference.Name == "active" && fieldReference.DeclaringType.FullName == "Terraria.Entity"
46+
, i => i.OpCode == OpCodes.Stfld && i.Operand is FieldReference fieldReference && fieldReference.Name == "active" && fieldReference.DeclaringType.FullName == declaringType
4147
);
4248

4349
checkDead.EmitDelegate(OTAPI.Hooks.NPC.InvokeKilled);

OTAPI.Scripts/Mods/HookNpcLoot.Server.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ void HookNpcLoot(MonoModder modder)
4242
);
4343

4444
NewNPC.Emit(OpCodes.Ldarg_0); // NPC instance
45-
#if TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
45+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
46+
NewNPC.Next.Operand = modder.GetMethodDefinition(() => OTAPI.Hooks.NPC.InvokeDropLoot(default, default, default, default, default, default, default, default, default, default, default));
47+
#elif TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
4648
NewNPC.Next.Operand = modder.GetMethodDefinition(() => OTAPI.Hooks.NPC.InvokeDropLoot(default, default, default, default, default, default, default, default, default, default, default, default));
4749
#else
4850
NewNPC.Next.Operand = modder.GetMethodDefinition(() => OTAPI.Hooks.NPC.InvokeDropLoot(default, default, default, default, default, default, default, default, default, default, default));
@@ -74,6 +76,9 @@ public class DropLootEventArgs : EventArgs
7476
public bool NoBroadcast { get; set; }
7577
public int Pfix { get; set; }
7678
public bool NoGrabDelay { get; set; }
79+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
80+
[Obsolete("ReverseLookup is no longer used in Terraria 1.4.5 and above, but is kept for API compatibility.")]
81+
#endif
7782
public bool ReverseLookup { get; set; }
7883
}
7984
public static event EventHandler<DropLootEventArgs>? DropLoot;
@@ -83,7 +88,12 @@ public static int InvokeDropLoot(Terraria.DataStructures.IEntitySource source, i
8388
#else
8489
public static int InvokeDropLoot(int X, int Y, int Width, int Height, int Type,
8590
#endif
91+
92+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
93+
int Stack, bool noBroadcast, int pfix, bool noGrabDelay,
94+
#else
8695
int Stack, bool noBroadcast, int pfix, bool noGrabDelay, bool reverseLookup,
96+
#endif
8797
Terraria.NPC instance)
8898
{
8999
var args = new DropLootEventArgs()
@@ -101,15 +111,21 @@ public static int InvokeDropLoot(int X, int Y, int Width, int Height, int Type,
101111
NoBroadcast = noBroadcast,
102112
Pfix = pfix,
103113
NoGrabDelay = noGrabDelay,
114+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
115+
ReverseLookup = false, // no longer used, but kept for api compatibility.
116+
#else
104117
ReverseLookup = reverseLookup,
118+
#endif
105119
Npc = instance,
106120

107121
ItemIndex = 0,
108122
};
109123
DropLoot?.Invoke(null, args);
110124
if (args.Result != HookResult.Cancel)
111125
{
112-
#if TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
126+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
127+
args.ItemIndex = Terraria.Item.NewItem(args.Source, X, Y, Width, Height, Type, Stack, noBroadcast, pfix, noGrabDelay);
128+
#elif TerrariaServer_EntitySourcesActive || Terraria_EntitySourcesActive || tModLoader_EntitySourcesActive
113129
args.ItemIndex = Terraria.Item.NewItem(args.Source, X, Y, Width, Height, Type, Stack, noBroadcast, pfix, noGrabDelay, reverseLookup);
114130
#else
115131
args.ItemIndex = Terraria.Item.NewItem(X, Y, Width, Height, Type, Stack, noBroadcast, pfix, noGrabDelay, reverseLookup);

OTAPI.Scripts/Mods/HookNpcTransform.Server.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ You should have received a copy of the GNU General Public License
3333
[MonoMod.MonoModIgnore]
3434
void HookNpcTransform(MonoModder modder)
3535
{
36+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
37+
var transform = modder.GetILCursor(() => (new Terraria.NPC()).Transform(0, 0f, 0f, 0f, 0f, false));
38+
#else
3639
var transform = modder.GetILCursor(() => (new Terraria.NPC()).Transform(0));
40+
#endif
3741

3842
transform.GotoNext(ins => ins.Operand is FieldReference fr && fr.Name == "netMode" && ins.Next.OpCode == OpCodes.Ldc_I4_2);
3943
transform.Emit(OpCodes.Ldarg_0);
40-
transform.Emit(OpCodes.Ldarga, transform.Method.Parameters.Single());
44+
foreach(var parameter in transform.Method.Parameters)
45+
transform.Emit(OpCodes.Ldarga, parameter);
4146
transform.EmitDelegate(OTAPI.Hooks.NPC.InvokeTransforming);
4247
transform.Emit(OpCodes.Brtrue, transform.Next);
4348
transform.Emit(OpCodes.Ret);
@@ -55,18 +60,44 @@ public class TransformingEventArgs : EventArgs
5560

5661
public Terraria.NPC Npc { get; set; }
5762
public int NewType { get; set; }
63+
64+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
65+
public float Ai0 { get; set; }
66+
public float Ai1 { get; set; }
67+
public float Ai2 { get; set; }
68+
public float Ai3 { get; set; }
69+
public bool WithReposition { get; set; }
70+
#endif
5871
}
5972
public static event EventHandler<TransformingEventArgs> Transforming;
6073

61-
public static bool InvokeTransforming(Terraria.NPC instance, ref int newType)
74+
public static bool InvokeTransforming(Terraria.NPC instance, ref int newType
75+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
76+
, ref float ai0, ref float ai1, ref float ai2, ref float ai3, ref bool withReposition
77+
#endif
78+
)
6279
{
6380
var args = new TransformingEventArgs()
6481
{
6582
Npc = instance,
6683
NewType = newType,
84+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
85+
Ai0 = ai0,
86+
Ai1 = ai1,
87+
Ai2 = ai2,
88+
Ai3 = ai3,
89+
WithReposition = withReposition,
90+
#endif
6791
};
6892
Transforming?.Invoke(null, args);
6993
newType = args.NewType;
94+
#if TerrariaServer_1450_OrAbove || Terraria__1450_OrAbove || tModLoader_1450_OrAbove
95+
ai0 = args.Ai0;
96+
ai1 = args.Ai1;
97+
ai2 = args.Ai2;
98+
ai3 = args.Ai3;
99+
withReposition = args.WithReposition;
100+
#endif
70101
return args.Result != HookResult.Cancel;
71102
}
72103
}

0 commit comments

Comments
 (0)