Skip to content

Commit

Permalink
Disable pdb/mdb, and add arm64 checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SignatureBeef committed Dec 28, 2024
1 parent dc0101c commit 844f745
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 145 deletions.
50 changes: 9 additions & 41 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,20 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Setup (Vanilla)",
"type": "coreclr",
"name": "C#: Patcher Debug",
"type": "dotnet",
"request": "launch",
"preLaunchTask": "build-setup",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/OTAPI.Setup/bin/Debug/net9.0/OTAPI.Setup.dll",
"args": ["-patchTarget=v", "-latestVanilla=n"],
"cwd": "${workspaceFolder}/OTAPI.Setup/bin/Debug/net9.0/",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
"projectPath": "${workspaceFolder}/OTAPI.Patcher/OTAPI.Patcher.csproj"
},
{
"name": "Patcher (Vanilla)",
"type": "coreclr",
"name": "C#: Server Launcher Debug",
"type": "dotnet",
"request": "launch",
"preLaunchTask": "build-mods",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/OTAPI.Patcher/bin/Debug/net9.0/OTAPI.Patcher.dll",
"args": ["-patchTarget=v", "-latestVanilla=n"],
"cwd": "${workspaceFolder}/OTAPI.Patcher/bin/Debug/net9.0/",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Launcher (Vanilla)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-launcher",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/OTAPI.Launcher/bin/Debug/net9.0/OTAPI.Launcher.dll",
"args": ["-patchTarget=v", "-latestVanilla=n"],
"cwd": "${workspaceFolder}/OTAPI.Launcher/bin/Debug/net9.0/", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "externalTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
"projectPath": "${workspaceFolder}/OTAPI.Server.Launcher/OTAPI.Server.Launcher.csproj"
}
]
}
66 changes: 0 additions & 66 deletions .vscode/tasks.json

This file was deleted.

3 changes: 1 addition & 2 deletions OTAPI.Patcher/OTAPI.Patcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<TargetFramework>net9.0</TargetFramework>
<Version>3.1.21</Version>
<PreserveCompilationContext>true</PreserveCompilationContext>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win;osx;linux;</RuntimeIdentifiers>
<Nullable>enable</Nullable>
<PackageReleaseNotes>Initial 1.4.4.9 support</PackageReleaseNotes>
</PropertyGroup>
Expand Down
15 changes: 0 additions & 15 deletions OTAPI.Patcher/Properties/launchSettings.json

This file was deleted.

5 changes: 4 additions & 1 deletion OTAPI.Patcher/Targets/PCServerTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PCServerTarget : IServerPatchTarget
public virtual string ArtifactName { get; } = "artifact-pc";

public virtual bool PublicEverything => true;
public virtual bool GenerateSymbols => true;
public virtual bool GenerateSymbols => false;

public virtual string GetEmbeddedResourcesDirectory(string fileinput)
{
Expand Down Expand Up @@ -308,6 +308,9 @@ public string GetZipUrl()

if (cli != "n")
{
if (Console.IsInputRedirected)
return FileResolver.AquireLatestBinaryUrl();

int attempts = 5;
do
{
Expand Down
3 changes: 3 additions & 0 deletions OTAPI.Patcher/Targets/PatchTargets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public static IPatchTarget DeterminePatchTarget()
if (!String.IsNullOrWhiteSpace(cli) && _targets.TryGetValue(cli[0], out IPatchTarget? match))
return match;

if(Console.IsInputRedirected)
return new PCServerTarget();

int attempts = 5;
do
{
Expand Down
13 changes: 10 additions & 3 deletions OTAPI.Server.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;

//namespace OTAPI.Launcher;

Expand Down Expand Up @@ -59,7 +60,6 @@ static void Program_LaunchGame(On.Terraria.Program.orig_LaunchGame orig, string[
Terraria.Main.dedServ = true;
Terraria.Program.ForceLoadAssembly(GetTerrariaAssembly(), initializeStaticMembers: true);
}
TShockHooks();
#endif
orig(args, monoArgs);
}
Expand Down Expand Up @@ -171,8 +171,15 @@ static void Main_DedServ(On.Terraria.Main.orig_DedServ orig, Terraria.Main self)
orig(self);
}

Terraria.Program.OnLaunched += Program_OnLaunched;
On.Terraria.Program.LaunchGame += Program_LaunchGame;
if (RuntimeInformation.ProcessArchitecture != Architecture.Arm64)
{
Terraria.Program.OnLaunched += Program_OnLaunched;
On.Terraria.Program.LaunchGame += Program_LaunchGame;
}
else
{
TShockHooks();
}

#if TML
On.MonoLaunch.GetBaseDirectory += (orig) =>
Expand Down
45 changes: 28 additions & 17 deletions examples/RuntimeExample.Server/MyClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,34 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System;
using System.Runtime.InteropServices;
using ModFramework;

namespace RuntimeExample.Server;

public static class Hooks
{
[Modification(ModType.Runtime, "Loading Runtime Example!")]
public static void OnRunning()
{
Console.WriteLine("[RuntimeExample Server] Hello World! from a compiled DLL");
On.Terraria.NetMessage.greetPlayer += NetMessage_greetPlayer;
}

private static void NetMessage_greetPlayer(On.Terraria.NetMessage.orig_greetPlayer orig, int plr)
{
Console.WriteLine($"[RuntimeExample Server] Greet player: {plr}");
orig(plr);
}
namespace RuntimeExample.Server;

public static class Hooks
{
[Modification(ModType.Runtime, "Loading Runtime Example!")]
public static void OnRunning()
{
Console.WriteLine("[RuntimeExample Server] Hello World! from a compiled DLL");

if (RuntimeInformation.ProcessArchitecture != Architecture.Arm64)
On.Terraria.NetMessage.greetPlayer += MonoMod_greetPlayer;
else
HookEvents.Terraria.NetMessage.greetPlayer += Modfw_greetPlayer;
}

private static void MonoMod_greetPlayer(On.Terraria.NetMessage.orig_greetPlayer orig, int plr)
{
Console.WriteLine($"[RuntimeExample Server] Greet player: {plr}");
orig(plr);
}

private static void Modfw_greetPlayer(object sender, HookEvents.Terraria.NetMessage.greetPlayerEventArgs args)
{
Console.WriteLine($"[RuntimeExample Server] Greet player: {args.plr}");
args.OriginalMethod(args.plr);
}
}

0 comments on commit 844f745

Please sign in to comment.