Merge pull request #1335 from NyxStudios/mintaka
Do not merge: Move to Mintaka.
This commit is contained in:
commit
564a80cc5b
36 changed files with 373 additions and 71 deletions
|
|
@ -26,6 +26,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
|||
* Added `/uploadssc [player]` which allows someone to upload SSC data for [player] and store it on the server. Adds `tshock.ssc.upload` and `tshock.ssc.upload.others` permission nodes to match (@DogooFalchion).
|
||||
* Added hardened stone to the whitelist of tiles editable by players (@DogooFalchion).
|
||||
* Added conversion system to send convert old MOTD format into smart text, while preserving initial line starting values to keep byte optimization for background colors Thanks to (@WhiteXZ, @Simon311, and especially @DogooFalchion) for the hard work on this issue.
|
||||
* Fixed server-sided inventory issues caused by bank3 (@ProfessorXZ)
|
||||
|
||||
## TShock 4.3.20
|
||||
* Security improvement: The auth system is now automatically disabled if a superadmin exists in the database (@Enerdy).
|
||||
|
|
|
|||
35
TShock.sln
35
TShock.sln
|
|
@ -1,21 +1,27 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{755F5B05-0924-47E9-9563-26EB20FE3F67}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaServer", "TerrariaServerAPI\TerrariaServer.csproj", "{6877506E-ADC6-4142-98A6-79E4FA02855A}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaServerAPI", "TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj", "{6877506E-ADC6-4142-98A6-79E4FA02855A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Mono|Any CPU = Mono|Any CPU
|
||||
Mono|Mixed Platforms = Mono|Mixed Platforms
|
||||
Mono|x64 = Mono|x64
|
||||
Mono|x86 = Mono|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
|
|
@ -23,20 +29,43 @@ Global
|
|||
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Any CPU.Build.0 = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x64.ActiveCfg = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x64.Build.0 = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x86.ActiveCfg = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Mono|x86.Build.0 = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x64.Build.0 = Release|Any CPU
|
||||
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x64.Build.0 = Debug|x64
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.Build.0 = Debug|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Any CPU.ActiveCfg = Mono|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Mixed Platforms.ActiveCfg = Mono|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|Mixed Platforms.Build.0 = Mono|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x64.ActiveCfg = Mono|x64
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x64.Build.0 = Mono|x64
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x86.ActiveCfg = Mono|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Mono|x86.Build.0 = Mono|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.ActiveCfg = Release|x64
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x64.Build.0 = Release|x64
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.ActiveCfg = Release|x86
|
||||
{6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace TShockAPI
|
|||
string worldname = Main.worldPathName;
|
||||
string name = Path.GetFileName(worldname);
|
||||
|
||||
Main.worldPathName = Path.Combine(BackupPath, string.Format("{0}.{1:dd.MM.yy-HH.mm.ss}.bak", name, DateTime.UtcNow));
|
||||
Main.ActiveWorldFileData._path = Path.Combine(BackupPath, string.Format("{0}.{1:dd.MM.yy-HH.mm.ss}.bak", name, DateTime.UtcNow));
|
||||
|
||||
string worldpath = Path.GetDirectoryName(Main.worldPathName);
|
||||
if (worldpath != null && !Directory.Exists(worldpath))
|
||||
|
|
@ -80,7 +80,7 @@ namespace TShockAPI
|
|||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
TShock.Log.Info(string.Format("World backed up ({0}).", Main.worldPathName));
|
||||
|
||||
Main.worldPathName = worldname;
|
||||
Main.ActiveWorldFileData._path = worldname;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
8
TShockAPI/Commands.cs
Executable file → Normal file
8
TShockAPI/Commands.cs
Executable file → Normal file
|
|
@ -31,6 +31,8 @@ using TShockAPI.DB;
|
|||
using TerrariaApi.Server;
|
||||
using TShockAPI.Hooks;
|
||||
using Terraria.GameContent.Events;
|
||||
using Microsoft.Xna.Framework;
|
||||
using OTAPI.Tile;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -2116,7 +2118,7 @@ namespace TShockAPI
|
|||
else
|
||||
{
|
||||
Main.anglerWhoFinishedToday.Clear();
|
||||
NetMessage.SendAnglerQuest();
|
||||
NetMessage.SendAnglerQuest(-1);
|
||||
args.Player.SendSuccessMessage("Cleared all users from the angler quest completion list for today.");
|
||||
}
|
||||
}
|
||||
|
|
@ -4437,7 +4439,7 @@ namespace TShockAPI
|
|||
// Could be improved by sending raw tile data to the client instead but not really
|
||||
// worth the effort as chances are very low that overwriting the wire for a few
|
||||
// nanoseconds will cause much trouble.
|
||||
Tile tile = Main.tile[boundaryPoint.X, boundaryPoint.Y];
|
||||
ITile tile = Main.tile[boundaryPoint.X, boundaryPoint.Y];
|
||||
bool oldWireState = tile.wire();
|
||||
tile.wire(true);
|
||||
|
||||
|
|
@ -5177,7 +5179,7 @@ namespace TShockAPI
|
|||
else
|
||||
{
|
||||
var plr = players[0];
|
||||
plr.DamagePlayer(999999);
|
||||
plr.KillPlayer();
|
||||
args.Player.SendSuccessMessage(string.Format("You just killed {0}!", plr.Name));
|
||||
plr.SendErrorMessage("{0} just killed you!", args.Player.Name);
|
||||
}
|
||||
|
|
|
|||
0
TShockAPI/ConfigFile.cs
Executable file → Normal file
0
TShockAPI/ConfigFile.cs
Executable file → Normal file
0
TShockAPI/DB/BanManager.cs
Executable file → Normal file
0
TShockAPI/DB/BanManager.cs
Executable file → Normal file
0
TShockAPI/DB/CharacterManager.cs
Executable file → Normal file
0
TShockAPI/DB/CharacterManager.cs
Executable file → Normal file
0
TShockAPI/DB/GroupManager.cs
Executable file → Normal file
0
TShockAPI/DB/GroupManager.cs
Executable file → Normal file
0
TShockAPI/DB/ItemManager.cs
Executable file → Normal file
0
TShockAPI/DB/ItemManager.cs
Executable file → Normal file
0
TShockAPI/DB/ProjectileManager.cs
Executable file → Normal file
0
TShockAPI/DB/ProjectileManager.cs
Executable file → Normal file
1
TShockAPI/DB/RegionManager.cs
Executable file → Normal file
1
TShockAPI/DB/RegionManager.cs
Executable file → Normal file
|
|
@ -22,6 +22,7 @@ using System.Data;
|
|||
using System.Linq;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace TShockAPI.DB
|
||||
{
|
||||
|
|
|
|||
1
TShockAPI/DB/RememberedPosManager.cs
Executable file → Normal file
1
TShockAPI/DB/RememberedPosManager.cs
Executable file → Normal file
|
|
@ -20,6 +20,7 @@ using System;
|
|||
using System.Data;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace TShockAPI.DB
|
||||
{
|
||||
|
|
|
|||
0
TShockAPI/DB/SqlTable.cs
Executable file → Normal file
0
TShockAPI/DB/SqlTable.cs
Executable file → Normal file
0
TShockAPI/DB/TileManager.cs
Executable file → Normal file
0
TShockAPI/DB/TileManager.cs
Executable file → Normal file
0
TShockAPI/DB/UserManager.cs
Executable file → Normal file
0
TShockAPI/DB/UserManager.cs
Executable file → Normal file
1
TShockAPI/DB/WarpsManager.cs
Executable file → Normal file
1
TShockAPI/DB/WarpsManager.cs
Executable file → Normal file
|
|
@ -23,6 +23,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using System.Linq;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace TShockAPI.DB
|
||||
{
|
||||
|
|
|
|||
4
TShockAPI/GetDataHandlers.cs
Executable file → Normal file
4
TShockAPI/GetDataHandlers.cs
Executable file → Normal file
|
|
@ -32,6 +32,8 @@ using Terraria;
|
|||
using Terraria.ObjectData;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Tile_Entities;
|
||||
using Microsoft.Xna.Framework;
|
||||
using OTAPI.Tile;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -2053,7 +2055,7 @@ namespace TShockAPI
|
|||
|
||||
Item selectedItem = args.Player.SelectedItem;
|
||||
int lastKilledProj = args.Player.LastKilledProjectile;
|
||||
Tile tile = Main.tile[tileX, tileY];
|
||||
ITile tile = Main.tile[tileX, tileY];
|
||||
|
||||
if (action == EditAction.PlaceTile)
|
||||
{
|
||||
|
|
|
|||
0
TShockAPI/Hooks/AccountHooks.cs
Executable file → Normal file
0
TShockAPI/Hooks/AccountHooks.cs
Executable file → Normal file
|
|
@ -76,6 +76,15 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public static readonly int MaxInventory = InventorySlots + ArmorSlots + DyeSlots + MiscEquipSlots + MiscDyeSlots + PiggySlots + SafeSlots + ForgeSlots + 1;
|
||||
|
||||
public static readonly Tuple<int, int> InventoryIndex = new Tuple<int, int>(0, InventorySlots);
|
||||
public static readonly Tuple<int, int> ArmorIndex = new Tuple<int, int>(InventoryIndex.Item2, InventoryIndex.Item2 + ArmorSlots);
|
||||
public static readonly Tuple<int, int> DyeIndex = new Tuple<int, int>(ArmorIndex.Item2, ArmorIndex.Item2 + DyeSlots);
|
||||
public static readonly Tuple<int, int> MiscEquipIndex = new Tuple<int, int>(DyeIndex.Item2, DyeIndex.Item2 + MiscEquipSlots);
|
||||
public static readonly Tuple<int, int> MiscDyeIndex = new Tuple<int, int>(MiscEquipIndex.Item2, MiscEquipIndex.Item2 + MiscDyeSlots);
|
||||
public static readonly Tuple<int, int> PiggyIndex = new Tuple<int, int>(MiscDyeIndex.Item2, MiscDyeIndex.Item2 + PiggySlots);
|
||||
public static readonly Tuple<int, int> SafeIndex = new Tuple<int, int>(PiggyIndex.Item2, PiggyIndex.Item2 + SafeSlots);
|
||||
public static readonly Tuple<int, int> ForgeIndex = new Tuple<int, int>(SafeIndex.Item2, SafeIndex.Item2 + ForgeSlots);
|
||||
|
||||
[JsonProperty("netID")]
|
||||
private int _netId;
|
||||
[JsonProperty("prefix")]
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ 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 Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using TShockAPI;
|
||||
|
||||
namespace TShockAPI
|
||||
|
|
@ -122,64 +123,51 @@ namespace TShockAPI
|
|||
|
||||
for (int i = 0; i < NetItem.MaxInventory; i++)
|
||||
{
|
||||
if (i < NetItem.InventorySlots)
|
||||
if (i < NetItem.InventoryIndex.Item2)
|
||||
{
|
||||
//0-58
|
||||
this.inventory[i] = (NetItem)inventory[i];
|
||||
}
|
||||
else if (i < NetItem.InventorySlots + NetItem.ArmorSlots)
|
||||
else if (i < NetItem.ArmorIndex.Item2)
|
||||
{
|
||||
//59-78
|
||||
var index = i - NetItem.InventorySlots;
|
||||
var index = i - NetItem.ArmorIndex.Item1;
|
||||
this.inventory[i] = (NetItem)armor[index];
|
||||
}
|
||||
else if (i < NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots)
|
||||
else if (i < NetItem.DyeIndex.Item2)
|
||||
{
|
||||
//79-88
|
||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots);
|
||||
var index = i - NetItem.DyeIndex.Item1;
|
||||
this.inventory[i] = (NetItem)dye[index];
|
||||
}
|
||||
else if (i <
|
||||
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots)
|
||||
else if (i < NetItem.MiscEquipIndex.Item2)
|
||||
{
|
||||
//89-93
|
||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots);
|
||||
var index = i - NetItem.MiscEquipIndex.Item1;
|
||||
this.inventory[i] = (NetItem)miscEqups[index];
|
||||
}
|
||||
else if (i <
|
||||
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots
|
||||
+ NetItem.MiscDyeSlots)
|
||||
else if (i < NetItem.MiscDyeIndex.Item2)
|
||||
{
|
||||
//93-98
|
||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
||||
+ NetItem.MiscEquipSlots);
|
||||
var index = i - NetItem.MiscDyeIndex.Item1;
|
||||
this.inventory[i] = (NetItem)miscDyes[index];
|
||||
}
|
||||
else if (i <
|
||||
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots +
|
||||
NetItem.MiscDyeSlots + NetItem.PiggySlots)
|
||||
else if (i < NetItem.PiggyIndex.Item2)
|
||||
{
|
||||
//98-138
|
||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
||||
+ NetItem.MiscEquipSlots + NetItem.MiscDyeSlots);
|
||||
var index = i - NetItem.PiggyIndex.Item1;
|
||||
this.inventory[i] = (NetItem)piggy[index];
|
||||
}
|
||||
else if (i <
|
||||
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots +
|
||||
NetItem.MiscDyeSlots + NetItem.PiggySlots + NetItem.SafeSlots)
|
||||
else if (i < NetItem.SafeIndex.Item2)
|
||||
{
|
||||
//138-178
|
||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
||||
+ NetItem.MiscEquipSlots + NetItem.MiscDyeSlots + NetItem.PiggySlots);
|
||||
var index = i - NetItem.SafeIndex.Item1;
|
||||
this.inventory[i] = (NetItem)safe[index];
|
||||
}
|
||||
else if (i <
|
||||
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots +
|
||||
NetItem.MiscDyeSlots + NetItem.PiggySlots + NetItem.SafeSlots + NetItem.ForgeSlots)
|
||||
else if (i < NetItem.ForgeIndex.Item2)
|
||||
{
|
||||
//179-219
|
||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
||||
+ NetItem.MiscEquipSlots + NetItem.MiscDyeSlots + NetItem.PiggySlots + NetItem.ForgeSlots);
|
||||
var index = i - NetItem.ForgeIndex.Item1;
|
||||
this.inventory[i] = (NetItem)forge[index];
|
||||
}
|
||||
else
|
||||
|
|
@ -463,4 +451,4 @@ namespace TShockAPI
|
|||
NetMessage.SendData(39, player.Index, -1, "", 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
TShockAPI/Properties/AssemblyInfo.cs
Executable file → Normal file
0
TShockAPI/Properties/AssemblyInfo.cs
Executable file → Normal file
|
|
@ -23,6 +23,7 @@ using System.Net;
|
|||
using HttpServer;
|
||||
using TShockAPI;
|
||||
using TShockAPI.DB;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Rests
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ GNU General Public License for more details.
|
|||
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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
|
|
|||
178
TShockAPI/Sockets/LinuxTcpSocket.cs
Normal file
178
TShockAPI/Sockets/LinuxTcpSocket.cs
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Terraria;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Net;
|
||||
using Terraria.Net.Sockets;
|
||||
|
||||
namespace TShockAPI.Sockets
|
||||
{
|
||||
public class LinuxTcpSocket : ISocket
|
||||
{
|
||||
private byte[] _packetBuffer = new byte[1024];
|
||||
|
||||
private int _packetBufferLength;
|
||||
|
||||
private List<object> _callbackBuffer = new List<object>();
|
||||
|
||||
private int _messagesInQueue;
|
||||
|
||||
private TcpClient _connection;
|
||||
|
||||
private TcpListener _listener;
|
||||
|
||||
private SocketConnectionAccepted _listenerCallback;
|
||||
|
||||
private RemoteAddress _remoteAddress;
|
||||
|
||||
private bool _isListening;
|
||||
|
||||
public int MessagesInQueue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._messagesInQueue;
|
||||
}
|
||||
}
|
||||
|
||||
public LinuxTcpSocket()
|
||||
{
|
||||
this._connection = new TcpClient();
|
||||
this._connection.NoDelay = true;
|
||||
}
|
||||
|
||||
public LinuxTcpSocket(TcpClient tcpClient)
|
||||
{
|
||||
this._connection = tcpClient;
|
||||
this._connection.NoDelay = true;
|
||||
IPEndPoint iPEndPoint = (IPEndPoint)tcpClient.Client.RemoteEndPoint;
|
||||
this._remoteAddress = new TcpAddress(iPEndPoint.Address, iPEndPoint.Port);
|
||||
}
|
||||
|
||||
void ISocket.Close()
|
||||
{
|
||||
this._remoteAddress = null;
|
||||
this._connection.Close();
|
||||
}
|
||||
|
||||
bool ISocket.IsConnected()
|
||||
{
|
||||
return this._connection != null && this._connection.Client != null && this._connection.Connected;
|
||||
}
|
||||
|
||||
void ISocket.Connect(RemoteAddress address)
|
||||
{
|
||||
TcpAddress tcpAddress = (TcpAddress)address;
|
||||
this._connection.Connect(tcpAddress.Address, tcpAddress.Port);
|
||||
this._remoteAddress = address;
|
||||
}
|
||||
|
||||
private void ReadCallback(IAsyncResult result)
|
||||
{
|
||||
Tuple<SocketReceiveCallback, object> tuple = (Tuple<SocketReceiveCallback, object>)result.AsyncState;
|
||||
tuple.Item1(tuple.Item2, this._connection.GetStream().EndRead(result));
|
||||
}
|
||||
|
||||
private void SendCallback(IAsyncResult result)
|
||||
{
|
||||
object[] expr_0B = (object[])result.AsyncState;
|
||||
LegacyNetBufferPool.ReturnBuffer((byte[])expr_0B[1]);
|
||||
Tuple<SocketSendCallback, object> tuple = (Tuple<SocketSendCallback, object>)expr_0B[0];
|
||||
try
|
||||
{
|
||||
this._connection.GetStream().EndWrite(result);
|
||||
tuple.Item1(tuple.Item2);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
((ISocket)this).Close();
|
||||
}
|
||||
}
|
||||
|
||||
void ISocket.SendQueuedPackets()
|
||||
{
|
||||
}
|
||||
|
||||
void ISocket.AsyncSend(byte[] data, int offset, int size, SocketSendCallback callback, object state)
|
||||
{
|
||||
byte[] array = LegacyNetBufferPool.RequestBuffer(data, offset, size);
|
||||
this._connection.GetStream().BeginWrite(array, 0, size, new AsyncCallback(this.SendCallback), new object[]
|
||||
{
|
||||
new Tuple<SocketSendCallback, object>(callback, state),
|
||||
array
|
||||
});
|
||||
}
|
||||
|
||||
void ISocket.AsyncReceive(byte[] data, int offset, int size, SocketReceiveCallback callback, object state)
|
||||
{
|
||||
this._connection.GetStream().BeginRead(data, offset, size, new AsyncCallback(this.ReadCallback), new Tuple<SocketReceiveCallback, object>(callback, state));
|
||||
}
|
||||
|
||||
bool ISocket.IsDataAvailable()
|
||||
{
|
||||
return this._connection.GetStream().DataAvailable;
|
||||
}
|
||||
|
||||
RemoteAddress ISocket.GetRemoteAddress()
|
||||
{
|
||||
return this._remoteAddress;
|
||||
}
|
||||
|
||||
bool ISocket.StartListening(SocketConnectionAccepted callback)
|
||||
{
|
||||
IPAddress any = IPAddress.Any;
|
||||
string ipString;
|
||||
if (Program.LaunchParameters.TryGetValue("-ip", out ipString) && !IPAddress.TryParse(ipString, out any))
|
||||
{
|
||||
any = IPAddress.Any;
|
||||
}
|
||||
this._isListening = true;
|
||||
this._listenerCallback = callback;
|
||||
if (this._listener == null)
|
||||
{
|
||||
this._listener = new TcpListener(any, Netplay.ListenPort);
|
||||
}
|
||||
try
|
||||
{
|
||||
this._listener.Start();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(this.ListenLoop));
|
||||
return true;
|
||||
}
|
||||
|
||||
void ISocket.StopListening()
|
||||
{
|
||||
this._isListening = false;
|
||||
}
|
||||
|
||||
private void ListenLoop(object unused)
|
||||
{
|
||||
while (this._isListening && !Netplay.disconnect)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISocket socket = new LinuxTcpSocket(this._listener.AcceptTcpClient());
|
||||
Console.WriteLine(Language.GetTextValue("Net.ClientConnecting", socket.GetRemoteAddress()));
|
||||
this._listenerCallback(socket);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
this._listener.Stop();
|
||||
|
||||
// currently vanilla will stop listening when the slots are full, however it appears that this Netplay.IsListening
|
||||
// flag is still set, making the server loop beleive it's still listening when it's actually not.
|
||||
// clearing this flag when we actually have stopped will allow the ServerLoop to start listening again when
|
||||
// there are enough slots available.
|
||||
Netplay.IsListening = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
TShockAPI/TSPlayer.cs
Executable file → Normal file
22
TShockAPI/TSPlayer.cs
Executable file → Normal file
|
|
@ -16,6 +16,7 @@ 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -24,6 +25,7 @@ using System.IO;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Timers;
|
||||
using OTAPI.Tile;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
|
|
@ -121,12 +123,12 @@ namespace TShockAPI
|
|||
/// <summary>
|
||||
/// A queue of tiles destroyed by the player for reverting.
|
||||
/// </summary>
|
||||
public Dictionary<Vector2, Tile> TilesDestroyed { get; protected set; }
|
||||
public Dictionary<Vector2, ITile> TilesDestroyed { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// A queue of tiles placed by the player for reverting.
|
||||
/// </summary>
|
||||
public Dictionary<Vector2, Tile> TilesCreated { get; protected set; }
|
||||
public Dictionary<Vector2, ITile> TilesCreated { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The player's group.
|
||||
|
|
@ -641,8 +643,8 @@ namespace TShockAPI
|
|||
/// <param name="index">The player's index in the.</param>
|
||||
public TSPlayer(int index)
|
||||
{
|
||||
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
||||
TilesCreated = new Dictionary<Vector2, Tile>();
|
||||
TilesDestroyed = new Dictionary<Vector2, ITile>();
|
||||
TilesCreated = new Dictionary<Vector2, ITile>();
|
||||
Index = index;
|
||||
Group = Group.DefaultGroup;
|
||||
IceTiles = new List<Point>();
|
||||
|
|
@ -655,8 +657,8 @@ namespace TShockAPI
|
|||
/// <param name="playerName">The player's name.</param>
|
||||
protected TSPlayer(String playerName)
|
||||
{
|
||||
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
||||
TilesCreated = new Dictionary<Vector2, Tile>();
|
||||
TilesDestroyed = new Dictionary<Vector2, ITile>();
|
||||
TilesCreated = new Dictionary<Vector2, ITile>();
|
||||
Index = -1;
|
||||
FakePlayer = new Player {name = playerName, whoAmI = -1};
|
||||
Group = Group.DefaultGroup;
|
||||
|
|
@ -1022,6 +1024,14 @@ namespace TShockAPI
|
|||
NetMessage.SendPlayerHurt(Index, PlayerDeathReason.LegacyDefault(), damage, (new Random()).Next(-1, 1), false, false, 0, -1, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kills the player.
|
||||
/// </summary>
|
||||
public virtual void KillPlayer()
|
||||
{
|
||||
NetMessage.SendPlayerDeath(Index, PlayerDeathReason.LegacyDefault(), 99999, (new Random()).Next(-1, 1), false, -1, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the player's team.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ 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 Microsoft.Xna.Framework;
|
||||
using OTAPI.Tile;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria;
|
||||
|
|
@ -165,10 +167,10 @@ namespace TShockAPI
|
|||
NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
||||
}
|
||||
|
||||
public void RevertTiles(Dictionary<Vector2, Tile> tiles)
|
||||
public void RevertTiles(Dictionary<Vector2, ITile> tiles)
|
||||
{
|
||||
// Update Main.Tile first so that when tile sqaure is sent it is correct
|
||||
foreach (KeyValuePair<Vector2, Tile> entry in tiles)
|
||||
foreach (KeyValuePair<Vector2, ITile> entry in tiles)
|
||||
{
|
||||
Main.tile[(int)entry.Key.X, (int)entry.Key.Y] = entry.Value;
|
||||
}
|
||||
|
|
|
|||
40
TShockAPI/TShock.cs
Executable file → Normal file
40
TShockAPI/TShock.cs
Executable file → Normal file
|
|
@ -39,6 +39,8 @@ using TShockAPI.DB;
|
|||
using TShockAPI.Hooks;
|
||||
using TShockAPI.ServerSideCharacters;
|
||||
using Terraria.Utilities;
|
||||
using Microsoft.Xna.Framework;
|
||||
using TShockAPI.Sockets;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -46,13 +48,13 @@ namespace TShockAPI
|
|||
/// This is the TShock main class. TShock is a plugin on the TerrariaServerAPI, so it extends the base TerrariaPlugin.
|
||||
/// TShock also complies with the API versioning system, and defines its required API version here.
|
||||
/// </summary>
|
||||
[ApiVersion(1, 26)]
|
||||
[ApiVersion(2, 0)]
|
||||
public class TShock : TerrariaPlugin
|
||||
{
|
||||
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
|
||||
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
/// <summary>VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions.</summary>
|
||||
public static readonly string VersionCodename = "Yoraiz0r R0cks";
|
||||
public static readonly string VersionCodename = "Mintaka";
|
||||
|
||||
/// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary>
|
||||
public static string SavePath = "tshock";
|
||||
|
|
@ -183,7 +185,20 @@ namespace TShockAPI
|
|||
string logFilename;
|
||||
string logPathSetupWarning;
|
||||
|
||||
TerrariaApi.Reporting.CrashReporter.HeapshotRequesting += CrashReporter_HeapshotRequesting;
|
||||
OTAPI.Hooks.Net.Socket.Create = () =>
|
||||
{
|
||||
//Console.WriteLine($"Creating socket {nameof(LinuxTcpSocket)}");
|
||||
return new LinuxTcpSocket();
|
||||
//return new OTAPI.Sockets.PoolSocket();
|
||||
//return new Terraria.Net.Sockets.TcpSocket();
|
||||
};
|
||||
OTAPI.Hooks.Player.Announce = (int playerId) =>
|
||||
{
|
||||
//TShock handles this
|
||||
return OTAPI.HookResult.Cancel;
|
||||
};
|
||||
|
||||
TerrariaApi.Reporting.CrashReporter.HeapshotRequesting += CrashReporter_HeapshotRequesting;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -197,6 +212,10 @@ namespace TShockAPI
|
|||
|
||||
Main.ServerSideCharacter = ServerSideCharacterConfig.Enabled;
|
||||
|
||||
//TSAPI previously would do this automatically, but the vanilla server wont
|
||||
if (Netplay.ServerIP == null)
|
||||
Netplay.ServerIP = IPAddress.Any;
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
// Log path was not already set by the command line parameter?
|
||||
if (LogPath == LogPathDefault)
|
||||
|
|
@ -578,7 +597,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (Main.worldPathName != null && Config.SaveWorldOnCrash)
|
||||
{
|
||||
Main.worldPathName += ".crash";
|
||||
Main.ActiveWorldFileData._path += ".crash";
|
||||
SaveManager.Instance.SaveWorld();
|
||||
}
|
||||
}
|
||||
|
|
@ -685,7 +704,7 @@ namespace TShockAPI
|
|||
}
|
||||
case "-autoshutdown":
|
||||
{
|
||||
Main.instance.autoShut();
|
||||
Main.instance.EnableAutoShutdown();
|
||||
break;
|
||||
}
|
||||
case "-autocreate":
|
||||
|
|
@ -715,9 +734,11 @@ namespace TShockAPI
|
|||
int limit;
|
||||
if (int.TryParse(parms[++i], out limit))
|
||||
{
|
||||
/* Todo - Requires an OTAPI modification
|
||||
Netplay.MaxConnections = limit;
|
||||
ServerApi.LogWriter.PluginWriteLine(this, string.Format(
|
||||
"Connections per IP have been limited to {0} connections.", limit), TraceLevel.Verbose);
|
||||
"Connections per IP have been limited to {0} connections.", limit), TraceLevel.Verbose);*/
|
||||
ServerApi.LogWriter.PluginWriteLine(this, "\"-connperip\" is not supported in this version of TShock.", TraceLevel.Verbose);
|
||||
}
|
||||
else
|
||||
ServerApi.LogWriter.PluginWriteLine(this, "Invalid value given for command line argument \"-connperip\".", TraceLevel.Warning);
|
||||
|
|
@ -1190,7 +1211,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
|
||||
if (!Config.AllowCrimsonCreep && (args.Type == TileID.Dirt || args.Type == TileID.FleshWeeds
|
||||
|| TileID.Sets.Crimson[args.Type]))
|
||||
{
|
||||
|
|
@ -1694,7 +1715,10 @@ namespace TShockAPI
|
|||
invasionSize = 100 + (Config.InvasionMultiplier * Utils.ActivePlayers());
|
||||
}
|
||||
|
||||
Main.StartInvasion(type, invasionSize);
|
||||
// Note: This is a workaround to previously providing the size as a parameter in StartInvasion
|
||||
Main.invasionSize = invasionSize;
|
||||
|
||||
Main.StartInvasion(type);
|
||||
}
|
||||
|
||||
/// <summary>CheckProjectilePermission - Checks if a projectile is banned.</summary>
|
||||
|
|
|
|||
|
|
@ -68,10 +68,14 @@
|
|||
<HintPath>..\packages\MySql.Data.6.9.8\lib\net45\MySql.Data.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="OTAPI, Version=1.3.4.4, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\TerrariaServerAPI\TerrariaServerAPI\bin\Debug\OTAPI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web" />
|
||||
|
|
@ -88,6 +92,7 @@
|
|||
<Compile Include="ILog.cs" />
|
||||
<Compile Include="NetItem.cs" />
|
||||
<Compile Include="PlayerData.cs" />
|
||||
<Compile Include="Sockets\LinuxTcpSocket.cs" />
|
||||
<Compile Include="SqlLog.cs" />
|
||||
<Compile Include="TextLog.cs" />
|
||||
<Compile Include="PaginationTools.cs" />
|
||||
|
|
@ -178,9 +183,9 @@
|
|||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServer.csproj">
|
||||
<Project>{6877506E-ADC6-4142-98A6-79E4FA02855A}</Project>
|
||||
<Name>TerrariaServer</Name>
|
||||
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj">
|
||||
<Project>{6877506e-adc6-4142-98a6-79e4fa02855a}</Project>
|
||||
<Name>TerrariaServerAPI</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
@ -194,7 +199,7 @@
|
|||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
|
||||
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
1
TShockAPI/UpdateManager.cs
Executable file → Normal file
1
TShockAPI/UpdateManager.cs
Executable file → Normal file
|
|
@ -22,6 +22,7 @@ using System.IO;
|
|||
using System.Net;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ using Terraria.ID;
|
|||
using Terraria.Utilities;
|
||||
using TShockAPI.DB;
|
||||
using BCrypt.Net;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="MySql.Data.MySqlClient" />
|
||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
||||
<remove invariant="MySql.Data.MySqlClient"/>
|
||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
</configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
<packages>
|
||||
<package id="BCrypt.Net" version="0.1.0" targetFramework="net45" />
|
||||
<package id="MySql.Data" version="6.9.8" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
|
||||
</packages>
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9050642fb6a98d4f50d97db34f837aaf485d3bf7
|
||||
Subproject commit 302124e1bcf6a6661d518b84f630384a90dbcbcb
|
||||
0
prebuilts/sqlite3.dll
Executable file → Normal file
0
prebuilts/sqlite3.dll
Executable file → Normal file
|
|
@ -29,6 +29,7 @@ cur_wd = os.getcwd()
|
|||
release_dir = os.path.join(cur_wd, "releases")
|
||||
|
||||
terraria_bin_name = "TerrariaServer.exe"
|
||||
otapi_bin_name = "OTAPI.dll"
|
||||
mysql_bin_name = "MySql.Data.dll"
|
||||
sqlite_dep_name = "sqlite3.dll"
|
||||
sqlite_bin_name = "Mono.Data.Sqlite.dll"
|
||||
|
|
@ -39,13 +40,14 @@ tshock_symbols = "TShockAPI.dll.mdb"
|
|||
bcrypt_bin_name = "BCrypt.Net.dll"
|
||||
geoip_db_name = "GeoIP.dat"
|
||||
|
||||
terraria_release_bin = os.path.join(cur_wd, "TerrariaServerAPI", "bin", "Release", terraria_bin_name)
|
||||
terraria_debug_bin = os.path.join(cur_wd, "TerrariaServerAPI", "bin", "Debug", terraria_bin_name)
|
||||
terraria_release_bin = os.path.join(cur_wd, "TerrariaServerAPI", "TerrariaServerAPI", "bin", "Release", terraria_bin_name)
|
||||
terraria_debug_bin = os.path.join(cur_wd, "TerrariaServerAPI", "TerrariaServerAPI", "bin", "Debug", terraria_bin_name)
|
||||
otapi_bin = os.path.join(cur_wd, "TerrariaServerAPI", "TerrariaServerAPI", "bin", "Release", otapi_bin_name)
|
||||
mysql_bin = os.path.join(cur_wd, "packages", "MySql.Data.6.9.8", "lib", "net45", mysql_bin_name)
|
||||
sqlite_dep = os.path.join(cur_wd, "prebuilts", sqlite_dep_name)
|
||||
sqlite_bin = os.path.join(cur_wd, "prebuilts", sqlite_bin_name)
|
||||
http_bin = os.path.join(cur_wd, "prebuilts", http_bin_name)
|
||||
json_bin = os.path.join(cur_wd, "packages", "Newtonsoft.Json.8.0.3", "lib", "net45", json_bin_name)
|
||||
json_bin = os.path.join(cur_wd, "packages", "Newtonsoft.Json.9.0.1", "lib", "net45", json_bin_name)
|
||||
bcrypt_bin = os.path.join(cur_wd, "packages", "BCrypt.Net.0.1.0", "lib", "net35", bcrypt_bin_name)
|
||||
geoip_db = os.path.join(cur_wd, "prebuilts", geoip_db_name)
|
||||
release_bin = os.path.join(cur_wd, "TShockAPI", "bin", "Release", tshock_bin_name)
|
||||
|
|
@ -66,18 +68,20 @@ def copy_dependencies():
|
|||
|
||||
def copy_debug_files():
|
||||
shutil.copy(terraria_debug_bin, release_dir)
|
||||
shutil.copy(otapi_bin, release_dir)
|
||||
shutil.copy(os.path.join(debug_folder, tshock_bin_name), release_dir)
|
||||
shutil.copy(os.path.join(debug_folder, tshock_symbols), release_dir)
|
||||
|
||||
def copy_release_files():
|
||||
shutil.copy(terraria_release_bin, release_dir)
|
||||
shutil.copy(release_bin, release_dir)
|
||||
shutil.copy(otapi_bin, release_dir)
|
||||
shutil.copy(release_bin, release_dir)
|
||||
|
||||
def create_base_zip(name):
|
||||
os.chdir(release_dir)
|
||||
zip = zipfile.ZipFile(name, "w")
|
||||
zip.write(terraria_bin_name)
|
||||
zip.write(otapi_bin_name)
|
||||
zip.write(sqlite_dep_name)
|
||||
zip.write(geoip_db_name)
|
||||
zip.write(http_bin_name, os.path.join("ServerPlugins", http_bin_name))
|
||||
|
|
@ -136,6 +140,44 @@ def upload_artifacts():
|
|||
def update_terraria_source():
|
||||
subprocess.check_call(['/usr/bin/git', 'submodule', 'init'])
|
||||
subprocess.check_call(['/usr/bin/git', 'submodule', 'update'])
|
||||
subprocess.check_call(['nuget', 'restore', 'TerrariaServerAPI/'])
|
||||
|
||||
def run_bootstrapper():
|
||||
for build_config in ['Debug','Release'] :
|
||||
mod_bootstrapper_proc = subprocess.Popen(['xbuild', './TerrariaServerAPI/TShock.Modifications.Bootstrapper/TShock.Modifications.Bootstrapper.csproj', '/p:Configuration=' + build_config])
|
||||
mod_clientuuid_proc = subprocess.Popen(['xbuild', './TerrariaServerAPI/TShock.Modifications.ClientUUID/TShock.Modifications.ClientUUID.csproj', '/p:Configuration=' + build_config])
|
||||
mod_explosives_proc = subprocess.Popen(['xbuild', './TerrariaServerAPI/TShock.Modifications.Explosives/TShock.Modifications.Explosives.csproj', '/p:Configuration=' + build_config])
|
||||
mod_ssc_proc = subprocess.Popen(['xbuild', './TerrariaServerAPI/TShock.Modifications.SSC/TShock.Modifications.SSC.csproj', '/p:Configuration=' + build_config])
|
||||
|
||||
mod_bootstrapper_proc.wait()
|
||||
mod_clientuuid_proc.wait()
|
||||
mod_explosives_proc.wait()
|
||||
mod_ssc_proc.wait()
|
||||
|
||||
if (mod_bootstrapper_proc.returncode != 0):
|
||||
raise CalledProcessError(mod_bootstrapper_proc.returncode)
|
||||
if (mod_clientuuid_proc.returncode != 0):
|
||||
raise CalledProcessError(mod_clientuuid_proc.returncode)
|
||||
if (mod_explosives_proc.returncode != 0):
|
||||
raise CalledProcessError(mod_explosives_proc.returncode)
|
||||
if (mod_ssc_proc.returncode != 0):
|
||||
raise CalledProcessError(mod_ssc_proc.returncode)
|
||||
|
||||
# run the bootstrapper to generate the new OTAPI.dll
|
||||
os.chdir('./TerrariaServerAPI/TShock.Modifications.Bootstrapper/bin/' + build_config)
|
||||
bootstrapper_proc = subprocess.Popen(['mono', 'TShock.Modifications.Bootstrapper.exe', '-in=OTAPI.dll', '-mod=../../../TShock.Modifications.**/bin/' + build_config + '/TShock.Modifications.*.dll', '-o=Output/OTAPI.dll'])
|
||||
os.chdir(cur_wd)
|
||||
|
||||
bootstrapper_proc.wait()
|
||||
if (bootstrapper_proc.returncode != 0):
|
||||
raise CalledProcessError(bootstrapper_proc.returncode)
|
||||
|
||||
tsapi_proc = subprocess.Popen(['xbuild', './TerrariaServerAPI/TerrariaServerAPI/TerrariaServerAPI.csproj', '/p:Configuration=' + build_config])
|
||||
|
||||
tsapi_proc.wait()
|
||||
|
||||
if (tsapi_proc.returncode != 0):
|
||||
raise CalledProcessError(tsapi_proc.returncode)
|
||||
|
||||
def build_software():
|
||||
release_proc = subprocess.Popen(['xbuild', './TShockAPI/TShockAPI.csproj', '/p:Configuration=Release'])
|
||||
|
|
@ -146,10 +188,12 @@ def build_software():
|
|||
raise CalledProcessError(release_proc.returncode)
|
||||
if (debug_proc.returncode != 0):
|
||||
raise CalledProcessError(debug_proc.returncode)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
create_release_folder()
|
||||
update_terraria_source()
|
||||
run_bootstrapper();
|
||||
copy_dependencies()
|
||||
build_software()
|
||||
package_release()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue