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

Commit

Permalink
1.3.1 update
Browse files Browse the repository at this point in the history
  • Loading branch information
SignatureBeef committed May 22, 2016
1 parent db5f7db commit 28cd4c5
Show file tree
Hide file tree
Showing 34 changed files with 375 additions and 101 deletions.
Binary file modified Binaries/OTA.Commands.dll
Binary file not shown.
Binary file modified Binaries/OTA.Patcher.exe
Binary file not shown.
Binary file modified Binaries/OTA.Patcher.pdb
Binary file not shown.
Binary file modified Binaries/OTA.dll
Binary file not shown.
Binary file modified Binaries/OTA.pdb
Binary file not shown.
Binary file modified Binaries/Plugins/OTA.Commands.dll
Binary file not shown.
Binary file modified Binaries/Plugins/OTA.Commands.pdb
Binary file not shown.
Binary file modified Binaries/Plugins/TDSM.Core.dll
Binary file not shown.
Binary file modified Binaries/Plugins/TDSM.Core.pdb
Binary file not shown.
Binary file removed Binaries/Server/OTA.Commands.dll
Binary file not shown.
Binary file removed Binaries/Server/OTA.dll
Binary file not shown.
Binary file modified Binaries/Server/TerrariaServer.exe
Binary file not shown.
Binary file modified Binaries/TerrariaServer.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions Binaries/server.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#-lobby <friends> or <private> Allows friends to join the server or sets it to private if Steam is enabled
#-ip <ip address> Sets the IP address for the server to listen on
#-forcepriority <priority> Sets the process priority for this task. If this is used the "priority" setting below will be ignored.
#-disableannouncementbox Disables the text announcements Announcement Box makes when pulsed from wire.
#-announcementboxrange <number> Sets the announcement box text messaging range in pixels, -1 for serverwide announcements.

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

Expand Down
2 changes: 1 addition & 1 deletion Binaries/start-server.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ TerrariaServer.exe -config server.config
@echo.
@echo Restarting server...
@echo.
goto start
goto start
5 changes: 4 additions & 1 deletion Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<DefineConstants>DAPPER</DefineConstants>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
Expand Down Expand Up @@ -166,12 +168,13 @@
<HintPath>..\Open-Terraria-API\Binaries\Libraries\KopiLua.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="TerrariaServer">
<HintPath>..\Open-Terraria-API\Binaries\Server\TerrariaServer.exe</HintPath>
</Reference>
<Reference Include="System.Collections.Concurrent" />
</ItemGroup>
<ItemGroup>
<Compile Include="Core\Command\Commands\ConnectionCommand.cs" />
<Compile Include="Core\Command\Commands\DebugCommand.cs" />
<Compile Include="Core\Command\Commands\ChangePasswordCommand.cs" />
<Compile Include="Core\Command\Commands\PrivateMessageCommand.cs" />
Expand Down
65 changes: 65 additions & 0 deletions Core/Core/Command/Commands/ConnectionCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using OTA;
using OTA.Command;
using Terraria;
using System.Linq;

namespace TDSM.Core.Command.Commands
{
public class ConnectionCommand : CoreCommand
{
public override void Initialise()
{
AddCommand("conn")
.WithAccessLevel(AccessLevel.OP)
.WithPermissionNode("tdsm.conn")
.WithHelpText("count")
.WithHelpText("kill <slot>")
.WithHelpText("check")
.Calls((ISender sender, ArgumentList args) =>
{
switch (args.GetString(0).ToLower())
{
case "count":
sender.Message("Active connectons: " + (Netplay.Clients.Count(x => x.IsActive)));
break;
case "kill":
var at = args.GetInt(1);
var client = Netplay.Clients[at];
if (client != null && client.IsActive)
{
client.PendingTermination = true;
}
break;
case "check":
for (var i = 0; i < Main.player.Length; i++)
{
var player = Main.player[i];
var conn = Netplay.Clients[i];
if (conn == null && player == null) continue;
if (player != null && conn != null)
{
if (player.active != conn.IsActive)
{
sender.Message($"Slot {i}, player active: {player.active}, conn active: {conn.IsActive}.");
}
}
else if (player == null && conn.IsActive)
{
sender.Message($"Player at slot {i} is null, but the connection instance is active.");
}
else if (conn == null && player.active)
{
sender.Message($"Connection at slot {i} is null, but the player instance is active.");
}
}
break;
}
});
}
}
}

2 changes: 1 addition & 1 deletion Core/Core/Command/Commands/ServerListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void ServerList(ISender sender, ArgumentList args)
sender.SendMessage("Last beat: " + Heartbeat.LastBeat);
else
sender.SendMessage("Last beat: n/a");
sender.SendMessage("Server list " + (Heartbeat.PublishToList ? "public" : "private"));
sender.SendMessage("Server list is " + (Heartbeat.PublishToList ? "public" : "private"));
sender.SendMessage("Current name: " + Heartbeat.ServerName);
sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
Expand Down
6 changes: 6 additions & 0 deletions Core/Core/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ namespace TDSM.Core
{
public partial class Entry
{
[Hook]
private void OnSetTitle(ref HookContext ctx, ref HookArgs.SetWindowTitle args)
{
ctx.SetResult( HookResult.RECTIFY, resultParam: $"{args.Title} | TDSM ({Entry.CoreVersion}) , OTAPI ({Globals.BuildInfo})");
}

[Hook(HookOrder.LATE)]
private void Command(ref HookContext ctx, ref TDSMHookArgs.ServerCommand args)
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Data/Models/Migrations/CreateAndSeed/CreateAndSeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace TDSM.Core.Data.Models.Migrations
{
[OTAMigration(1, typeof(Core.Entry))]
[OTAMigration(1, typeof(Entry))]
public partial class CreateAndSeed : Migration
{
public override void Up()
Expand Down
22 changes: 11 additions & 11 deletions Core/Definitions/item.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<DefinitionFileOfItemInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Version>3</Version>
<Data>
Expand Down Expand Up @@ -15893,9 +15893,9 @@
<ItemInfo>
<Id>414</Id>
<NetId>414</NetId>
<Affix>Mudstone Block</Affix>
<Affix>Mudstone Brick</Affix>
<Prefix>0</Prefix>
<Name>Mudstone Block</Name>
<Name>Mudstone Brick</Name>
<MaxStack>999</MaxStack>
</ItemInfo>
<ItemInfo>
Expand Down Expand Up @@ -20682,6 +20682,14 @@
<Name>Red Torch</Name>
<MaxStack>99</MaxStack>
</ItemInfo>
<ItemInfo>
<Id>509</Id>
<NetId>509</NetId>
<Affix>Red Wrench</Affix>
<Prefix>0</Prefix>
<Name>Red Wrench</Name>
<MaxStack>1</MaxStack>
</ItemInfo>
<ItemInfo>
<Id>667</Id>
<NetId>667</NetId>
Expand Down Expand Up @@ -28018,14 +28026,6 @@
<Name>Wrath Potion</Name>
<MaxStack>30</MaxStack>
</ItemInfo>
<ItemInfo>
<Id>509</Id>
<NetId>509</NetId>
<Affix>Wrench</Affix>
<Prefix>0</Prefix>
<Name>Wrench</Name>
<MaxStack>1</MaxStack>
</ItemInfo>
<ItemInfo>
<Id>1700</Id>
<NetId>1700</NetId>
Expand Down
58 changes: 33 additions & 25 deletions Core/Mono/Sigterm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ public static void Detach(Entry plugin)

/// <summary>
/// This class is used to isolate the mono specific code into it's own container.
/// The Sigterm class is used to check what platform is running with triggering
/// a load of the Mono.Posix dll.
/// The Sigterm class is used to check what platform is running without triggering
/// a load of the Mono.Posix dll. Calling this class will trigger the load.
/// </summary>
internal static class MonoSigterm
{
private static bool _attached;
private static Thread signal_thread;
private static bool _attached, _exiting;
private static Thread _signal_thread;

public static void Attach(Entry plugin)
{
try
{
if (!_attached)
if (!_exiting && !_attached)
{
_attached = true;
// Catch SIGINT, SIGUSR1 and SIGTERM
Expand All @@ -53,44 +53,52 @@ public static void Attach(Entry plugin)
new UnixSignal(Signum.SIGTERM)
};

(signal_thread = new Thread(delegate ()
(_signal_thread = new Thread(() =>
{
System.Threading.Thread.CurrentThread.Name = "SIG";
while (!Terraria.Netplay.disconnect && _attached)
try
{
// Wait for a signal to be delivered
var index = UnixSignal.WaitAny(signals, -1);
var signal = signals[index].Signum;

if (!Terraria.Netplay.disconnect && _attached)
while (!Terraria.Netplay.disconnect && _attached)
{
_attached = false;
OTA.Logging.ProgramLog.Log("Server received Exit Signal");
// Wait for a signal to be delivered
if (UnixSignal.WaitAll(signals, 250))
{
if (!Terraria.Netplay.disconnect && _attached)
{
_attached = false;
OTA.Logging.ProgramLog.Log("Server received Exit Signal");
Terraria.IO.WorldFile.saveWorld(false);
Terraria.Netplay.disconnect = true;
Terraria.IO.WorldFile.saveWorld(false);
Terraria.Netplay.disconnect = true;
}
}
}
OTA.Logging.ProgramLog.Debug.Log("Sigterm thread exiting");
}
catch (System.Exception e)
{
OTA.Logging.ProgramLog.Log(e, "Sigterm exception");
}
})).Start();
}

OTA.Logging.ProgramLog.Log("Server can accept SIGTERM");
}
catch
{
OTA.Logging.ProgramLog.Log("Failed to attatch SIGTERM listener");
OTA.Logging.ProgramLog.Log("Failed to attach Sigterm listener");
}
}

public static void Detach(Entry plugin)
{
_attached = false;
try
{
signal_thread.Abort();
}
catch
if (_attached && _signal_thread != null)
{
_attached = false;
_exiting = true;

//Instead of killing the thread, wait for it to exit.
_signal_thread.Join();
_signal_thread = null;
}
}
}
Expand Down
Loading

0 comments on commit 28cd4c5

Please sign in to comment.