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

Commit 28cd4c5

Browse files
committed
1.3.1 update
1 parent db5f7db commit 28cd4c5

34 files changed

+375
-101
lines changed

Binaries/OTA.Commands.dll

0 Bytes
Binary file not shown.

Binaries/OTA.Patcher.exe

-512 Bytes
Binary file not shown.

Binaries/OTA.Patcher.pdb

-4 KB
Binary file not shown.

Binaries/OTA.dll

-23 KB
Binary file not shown.

Binaries/OTA.pdb

10 KB
Binary file not shown.

Binaries/Plugins/OTA.Commands.dll

0 Bytes
Binary file not shown.

Binaries/Plugins/OTA.Commands.pdb

0 Bytes
Binary file not shown.

Binaries/Plugins/TDSM.Core.dll

-19 KB
Binary file not shown.

Binaries/Plugins/TDSM.Core.pdb

4 KB
Binary file not shown.

Binaries/Server/OTA.Commands.dll

-32.5 KB
Binary file not shown.

Binaries/Server/OTA.dll

-319 KB
Binary file not shown.

Binaries/Server/TerrariaServer.exe

365 KB
Binary file not shown.

Binaries/TerrariaServer.exe

365 KB
Binary file not shown.

Binaries/server.config

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#-lobby <friends> or <private> Allows friends to join the server or sets it to private if Steam is enabled
1919
#-ip <ip address> Sets the IP address for the server to listen on
2020
#-forcepriority <priority> Sets the process priority for this task. If this is used the "priority" setting below will be ignored.
21+
#-disableannouncementbox Disables the text announcements Announcement Box makes when pulsed from wire.
22+
#-announcementboxrange <number> Sets the announcement box text messaging range in pixels, -1 for serverwide announcements.
2123

2224
#remove the # in front of commands to enable them.
2325

Binaries/start-server.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ TerrariaServer.exe -config server.config
55
@echo.
66
@echo Restarting server...
77
@echo.
8-
goto start
8+
goto start

Core/Core.csproj

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<ErrorReport>prompt</ErrorReport>
2727
<WarningLevel>4</WarningLevel>
2828
<ConsolePause>False</ConsolePause>
29+
<DefineConstants>DAPPER</DefineConstants>
30+
<PlatformTarget>AnyCPU</PlatformTarget>
2931
</PropertyGroup>
3032
<PropertyGroup>
3133
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
@@ -166,12 +168,13 @@
166168
<HintPath>..\Open-Terraria-API\Binaries\Libraries\KopiLua.dll</HintPath>
167169
</Reference>
168170
<Reference Include="System.Net.Http" />
171+
<Reference Include="System.Collections.Concurrent" />
169172
<Reference Include="TerrariaServer">
170173
<HintPath>..\Open-Terraria-API\Binaries\Server\TerrariaServer.exe</HintPath>
171174
</Reference>
172-
<Reference Include="System.Collections.Concurrent" />
173175
</ItemGroup>
174176
<ItemGroup>
177+
<Compile Include="Core\Command\Commands\ConnectionCommand.cs" />
175178
<Compile Include="Core\Command\Commands\DebugCommand.cs" />
176179
<Compile Include="Core\Command\Commands\ChangePasswordCommand.cs" />
177180
<Compile Include="Core\Command\Commands\PrivateMessageCommand.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using OTA;
3+
using OTA.Command;
4+
using Terraria;
5+
using System.Linq;
6+
7+
namespace TDSM.Core.Command.Commands
8+
{
9+
public class ConnectionCommand : CoreCommand
10+
{
11+
public override void Initialise()
12+
{
13+
AddCommand("conn")
14+
.WithAccessLevel(AccessLevel.OP)
15+
.WithPermissionNode("tdsm.conn")
16+
.WithHelpText("count")
17+
.WithHelpText("kill <slot>")
18+
.WithHelpText("check")
19+
.Calls((ISender sender, ArgumentList args) =>
20+
{
21+
switch (args.GetString(0).ToLower())
22+
{
23+
case "count":
24+
sender.Message("Active connectons: " + (Netplay.Clients.Count(x => x.IsActive)));
25+
break;
26+
27+
case "kill":
28+
var at = args.GetInt(1);
29+
var client = Netplay.Clients[at];
30+
if (client != null && client.IsActive)
31+
{
32+
client.PendingTermination = true;
33+
}
34+
break;
35+
36+
case "check":
37+
for (var i = 0; i < Main.player.Length; i++)
38+
{
39+
var player = Main.player[i];
40+
var conn = Netplay.Clients[i];
41+
42+
if (conn == null && player == null) continue;
43+
if (player != null && conn != null)
44+
{
45+
if (player.active != conn.IsActive)
46+
{
47+
sender.Message($"Slot {i}, player active: {player.active}, conn active: {conn.IsActive}.");
48+
}
49+
}
50+
else if (player == null && conn.IsActive)
51+
{
52+
sender.Message($"Player at slot {i} is null, but the connection instance is active.");
53+
}
54+
else if (conn == null && player.active)
55+
{
56+
sender.Message($"Connection at slot {i} is null, but the player instance is active.");
57+
}
58+
}
59+
break;
60+
}
61+
});
62+
}
63+
}
64+
}
65+

Core/Core/Command/Commands/ServerListCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void ServerList(ISender sender, ArgumentList args)
107107
sender.SendMessage("Last beat: " + Heartbeat.LastBeat);
108108
else
109109
sender.SendMessage("Last beat: n/a");
110-
sender.SendMessage("Server list " + (Heartbeat.PublishToList ? "public" : "private"));
110+
sender.SendMessage("Server list is " + (Heartbeat.PublishToList ? "public" : "private"));
111111
sender.SendMessage("Current name: " + Heartbeat.ServerName);
112112
sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
113113
sender.SendMessage("Current description: " + Heartbeat.ServerDescription);

Core/Core/Events.cs

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ namespace TDSM.Core
1919
{
2020
public partial class Entry
2121
{
22+
[Hook]
23+
private void OnSetTitle(ref HookContext ctx, ref HookArgs.SetWindowTitle args)
24+
{
25+
ctx.SetResult( HookResult.RECTIFY, resultParam: $"{args.Title} | TDSM ({Entry.CoreVersion}) , OTAPI ({Globals.BuildInfo})");
26+
}
27+
2228
[Hook(HookOrder.LATE)]
2329
private void Command(ref HookContext ctx, ref TDSMHookArgs.ServerCommand args)
2430
{

Core/Data/Models/Migrations/CreateAndSeed/CreateAndSeed.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace TDSM.Core.Data.Models.Migrations
55
{
6-
[OTAMigration(1, typeof(Core.Entry))]
6+
[OTAMigration(1, typeof(Entry))]
77
public partial class CreateAndSeed : Migration
88
{
99
public override void Up()

Core/Definitions/item.xml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0"?>
22
<DefinitionFileOfItemInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<Version>3</Version>
44
<Data>
@@ -15893,9 +15893,9 @@
1589315893
<ItemInfo>
1589415894
<Id>414</Id>
1589515895
<NetId>414</NetId>
15896-
<Affix>Mudstone Block</Affix>
15896+
<Affix>Mudstone Brick</Affix>
1589715897
<Prefix>0</Prefix>
15898-
<Name>Mudstone Block</Name>
15898+
<Name>Mudstone Brick</Name>
1589915899
<MaxStack>999</MaxStack>
1590015900
</ItemInfo>
1590115901
<ItemInfo>
@@ -20682,6 +20682,14 @@
2068220682
<Name>Red Torch</Name>
2068320683
<MaxStack>99</MaxStack>
2068420684
</ItemInfo>
20685+
<ItemInfo>
20686+
<Id>509</Id>
20687+
<NetId>509</NetId>
20688+
<Affix>Red Wrench</Affix>
20689+
<Prefix>0</Prefix>
20690+
<Name>Red Wrench</Name>
20691+
<MaxStack>1</MaxStack>
20692+
</ItemInfo>
2068520693
<ItemInfo>
2068620694
<Id>667</Id>
2068720695
<NetId>667</NetId>
@@ -28018,14 +28026,6 @@
2801828026
<Name>Wrath Potion</Name>
2801928027
<MaxStack>30</MaxStack>
2802028028
</ItemInfo>
28021-
<ItemInfo>
28022-
<Id>509</Id>
28023-
<NetId>509</NetId>
28024-
<Affix>Wrench</Affix>
28025-
<Prefix>0</Prefix>
28026-
<Name>Wrench</Name>
28027-
<MaxStack>1</MaxStack>
28028-
</ItemInfo>
2802928029
<ItemInfo>
2803028030
<Id>1700</Id>
2803128031
<NetId>1700</NetId>

Core/Mono/Sigterm.cs

+33-25
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ public static void Detach(Entry plugin)
3030

3131
/// <summary>
3232
/// 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.
33+
/// The Sigterm class is used to check what platform is running without triggering
34+
/// a load of the Mono.Posix dll. Calling this class will trigger the load.
3535
/// </summary>
3636
internal static class MonoSigterm
3737
{
38-
private static bool _attached;
39-
private static Thread signal_thread;
38+
private static bool _attached, _exiting;
39+
private static Thread _signal_thread;
4040

4141
public static void Attach(Entry plugin)
4242
{
4343
try
4444
{
45-
if (!_attached)
45+
if (!_exiting && !_attached)
4646
{
4747
_attached = true;
4848
// Catch SIGINT, SIGUSR1 and SIGTERM
@@ -53,44 +53,52 @@ public static void Attach(Entry plugin)
5353
new UnixSignal(Signum.SIGTERM)
5454
};
5555

56-
(signal_thread = new Thread(delegate ()
56+
(_signal_thread = new Thread(() =>
5757
{
5858
System.Threading.Thread.CurrentThread.Name = "SIG";
59-
while (!Terraria.Netplay.disconnect && _attached)
59+
try
6060
{
61-
// Wait for a signal to be delivered
62-
var index = UnixSignal.WaitAny(signals, -1);
63-
var signal = signals[index].Signum;
64-
65-
if (!Terraria.Netplay.disconnect && _attached)
61+
while (!Terraria.Netplay.disconnect && _attached)
6662
{
67-
_attached = false;
68-
OTA.Logging.ProgramLog.Log("Server received Exit Signal");
63+
// Wait for a signal to be delivered
64+
if (UnixSignal.WaitAll(signals, 250))
65+
{
66+
if (!Terraria.Netplay.disconnect && _attached)
67+
{
68+
_attached = false;
69+
OTA.Logging.ProgramLog.Log("Server received Exit Signal");
6970

70-
Terraria.IO.WorldFile.saveWorld(false);
71-
Terraria.Netplay.disconnect = true;
71+
Terraria.IO.WorldFile.saveWorld(false);
72+
Terraria.Netplay.disconnect = true;
73+
}
74+
}
7275
}
76+
77+
OTA.Logging.ProgramLog.Debug.Log("Sigterm thread exiting");
78+
}
79+
catch (System.Exception e)
80+
{
81+
OTA.Logging.ProgramLog.Log(e, "Sigterm exception");
7382
}
7483
})).Start();
7584
}
76-
77-
OTA.Logging.ProgramLog.Log("Server can accept SIGTERM");
7885
}
7986
catch
8087
{
81-
OTA.Logging.ProgramLog.Log("Failed to attatch SIGTERM listener");
88+
OTA.Logging.ProgramLog.Log("Failed to attach Sigterm listener");
8289
}
8390
}
8491

8592
public static void Detach(Entry plugin)
8693
{
87-
_attached = false;
88-
try
89-
{
90-
signal_thread.Abort();
91-
}
92-
catch
94+
if (_attached && _signal_thread != null)
9395
{
96+
_attached = false;
97+
_exiting = true;
98+
99+
//Instead of killing the thread, wait for it to exit.
100+
_signal_thread.Join();
101+
_signal_thread = null;
94102
}
95103
}
96104
}

0 commit comments

Comments
 (0)