Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.

Commit 2dcacf1

Browse files
committed
Prep for RC
1 parent d45a9b6 commit 2dcacf1

20 files changed

+68
-34
lines changed

Binaries/OTA.Commands.dll

0 Bytes
Binary file not shown.

Binaries/OTA.Patcher.exe

0 Bytes
Binary file not shown.

Binaries/OTA.Patcher.pdb

0 Bytes
Binary file not shown.

Binaries/OTA.dll

-1 KB
Binary file not shown.

Binaries/OTA.pdb

-2 KB
Binary file not shown.

Binaries/Plugins/OTA.Commands.dll

512 Bytes
Binary file not shown.

Binaries/Plugins/OTA.Commands.pdb

2 KB
Binary file not shown.

Binaries/Plugins/TDSM.Core.dll

0 Bytes
Binary file not shown.

Binaries/Plugins/TDSM.Core.dll.config

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
2323
<bindingRedirect oldVersion="0.0.0.0-1.1.38.0" newVersion="1.1.38.0" />
2424
</dependentAssembly>
25+
<dependentAssembly>
26+
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" />
27+
<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
28+
</dependentAssembly>
29+
<dependentAssembly>
30+
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
31+
<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
32+
</dependentAssembly>
33+
<dependentAssembly>
34+
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
35+
<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
36+
</dependentAssembly>
2537
</assemblyBinding>
2638
</runtime>
2739
<entityFramework>

Binaries/Plugins/TDSM.Core.pdb

2 KB
Binary file not shown.

Binaries/Server/OTA.Commands.dll

0 Bytes
Binary file not shown.

Binaries/Server/OTA.dll

-1 KB
Binary file not shown.

Binaries/Server/TerrariaServer.exe

0 Bytes
Binary file not shown.

Binaries/TerrariaServer.exe

0 Bytes
Binary file not shown.

Binaries/start-server.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22
cls
33
:start
4-
TerrariaServer.exe -config serverconfig.txt
4+
TerrariaServer.exe -config server.config
55
@echo.
66
@echo Restarting server...
77
@echo.

Binaries/start-server.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set AutoRestart=1
88
:: ~~~~ END USER EDIT ~~~~
99

1010
:start
11-
TerrariaServer.exe -config serverconfig.txt
11+
TerrariaServer.exe -config server.config
1212

1313
if %AutoRestart%==1 (
1414
echo.

Binaries/start-server.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
while true
33
do
4-
mono TerrariaServer.exe -config serverconfig.txt
4+
mono TerrariaServer.exe -config server.config
55
echo "Restarting server..."
66
sleep 1
77
done

Core/Mono/Sigterm.cs

+43-30
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
1-
using System;
2-
using System.Threading;
3-
4-
/// <summary>
5-
/// Mono specific code
6-
/// </summary>
1+
using Mono.Unix;
72
using Mono.Unix.Native;
8-
using Mono.Unix;
93
using OTA;
4+
using System.Threading;
105

116
namespace TDSM.Core.Mono
127
{
138
/// <summary>
14-
/// This is a Mono specific implementation to check for termination events
9+
/// This is a Mono specific implementation to check for termination events.
1510
/// </summary>
1611
public static class Sigterm
1712
{
18-
private static bool _attached;
19-
private static Thread signal_thread;
20-
2113
[TDSMComponent(ComponentEvent.ReadyForCommands)]
2214
public static void Attach(Entry plugin)
2315
{
2416
if (Tools.RuntimePlatform != OTA.Misc.RuntimePlatform.Microsoft)
17+
{
18+
MonoSigterm.Attach(plugin);
19+
}
20+
}
21+
22+
[TDSMComponent(ComponentEvent.ServerStopping)]
23+
public static void Detach(Entry plugin)
24+
{
25+
if (Tools.RuntimePlatform != OTA.Misc.RuntimePlatform.Microsoft)
26+
{
27+
MonoSigterm.Detach(plugin);
28+
}
29+
}
30+
31+
/// <summary>
32+
/// This class is used to isolate the mono specific code into it's own container.
33+
/// The Sigterm class is used to check what platform is running with triggering
34+
/// a load of the Mono.Posix dll.
35+
/// </summary>
36+
internal static class MonoSigterm
37+
{
38+
private static bool _attached;
39+
private static Thread signal_thread;
40+
41+
public static void Attach(Entry plugin)
2542
{
2643
try
2744
{
@@ -37,24 +54,24 @@ public static void Attach(Entry plugin)
3754
};
3855

3956
(signal_thread = new Thread(delegate ()
57+
{
58+
System.Threading.Thread.CurrentThread.Name = "SIG";
59+
while (!Terraria.Netplay.disconnect && _attached)
4060
{
41-
System.Threading.Thread.CurrentThread.Name = "SIG";
42-
while (!Terraria.Netplay.disconnect && _attached)
43-
{
44-
// Wait for a signal to be delivered
45-
var index = UnixSignal.WaitAny(signals, -1);
46-
var signal = signals[index].Signum;
61+
// Wait for a signal to be delivered
62+
var index = UnixSignal.WaitAny(signals, -1);
63+
var signal = signals[index].Signum;
4764

48-
if (!Terraria.Netplay.disconnect && _attached)
49-
{
50-
_attached = false;
51-
OTA.Logging.ProgramLog.Log("Server received Exit Signal");
65+
if (!Terraria.Netplay.disconnect && _attached)
66+
{
67+
_attached = false;
68+
OTA.Logging.ProgramLog.Log("Server received Exit Signal");
5269

53-
Terraria.IO.WorldFile.saveWorld(false);
54-
Terraria.Netplay.disconnect = true;
55-
}
70+
Terraria.IO.WorldFile.saveWorld(false);
71+
Terraria.Netplay.disconnect = true;
5672
}
57-
})).Start();
73+
}
74+
})).Start();
5875
}
5976

6077
OTA.Logging.ProgramLog.Log("Server can accept SIGTERM");
@@ -64,12 +81,8 @@ public static void Attach(Entry plugin)
6481
OTA.Logging.ProgramLog.Log("Failed to attatch SIGTERM listener");
6582
}
6683
}
67-
}
6884

69-
[TDSMComponent(ComponentEvent.ServerStopping)]
70-
public static void Detach(Entry plugin)
71-
{
72-
if (Tools.RuntimePlatform != OTA.Misc.RuntimePlatform.Microsoft)
85+
public static void Detach(Entry plugin)
7386
{
7487
_attached = false;
7588
try

Open-Terraria-API

TDSM-Patcher/Program.cs

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public static void ExampleExtension(this OTA.Patcher.Injector injector)
1515

1616
class MainClass
1717
{
18+
static void ReplaceTextInFile(string filepath, string search, string replacement)
19+
{
20+
File.WriteAllText(filepath, File.ReadAllText(filepath).Replace(search, replacement));
21+
}
22+
1823
public static void Main(string[] args)
1924
{
2025
//Debugging :)
@@ -132,6 +137,10 @@ public static void Main(string[] args)
132137
File.Copy(file.FullName, target);
133138
}
134139

140+
ReplaceTextInFile(Path.Combine(pathToBinaries.FullName, "start-server.bat"), "serverconfig.txt", "server.config");
141+
ReplaceTextInFile(Path.Combine(pathToBinaries.FullName, "start-server.cmd"), "serverconfig.txt", "server.config");
142+
ReplaceTextInFile(Path.Combine(pathToBinaries.FullName, "start-server.sh"), "serverconfig.txt", "server.config");
143+
135144
OTAPatcher.PromptUserToRun(OTAPatcher.OutputName + ".exe", Type.GetType("Mono.Runtime") != null);
136145

137146
// var isMono = Type.GetType("Mono.Runtime") != null;

0 commit comments

Comments
 (0)