/setspawn spawn shouldn't save into world file unless using /savespawn
This commit is contained in:
parent
679a28af0a
commit
a0c71e7b30
4 changed files with 178 additions and 6 deletions
|
|
@ -131,6 +131,7 @@ namespace TShockAPI
|
||||||
ChatCommands.Add(new Command("maxspawns", "cfg", MaxSpawns));
|
ChatCommands.Add(new Command("maxspawns", "cfg", MaxSpawns));
|
||||||
ChatCommands.Add(new Command("spawnrate", "cfg", SpawnRate));
|
ChatCommands.Add(new Command("spawnrate", "cfg", SpawnRate));
|
||||||
ChatCommands.Add(new Command("setspawn", "cfg", SetSpawn));
|
ChatCommands.Add(new Command("setspawn", "cfg", SetSpawn));
|
||||||
|
ChatCommands.Add(new Command("savespawn", "cfg", SaveSpawn));
|
||||||
ChatCommands.Add(new Command("time", "time", Time));
|
ChatCommands.Add(new Command("time", "time", Time));
|
||||||
ChatCommands.Add(new Command("slap", "pvpfun", Slap));
|
ChatCommands.Add(new Command("slap", "pvpfun", Slap));
|
||||||
ChatCommands.Add(new Command("antibuild", "editspawn", ToggleAntiBuild));
|
ChatCommands.Add(new Command("antibuild", "editspawn", ToggleAntiBuild));
|
||||||
|
|
@ -869,13 +870,21 @@ namespace TShockAPI
|
||||||
|
|
||||||
private static void SetSpawn(CommandArgs args)
|
private static void SetSpawn(CommandArgs args)
|
||||||
{
|
{
|
||||||
Main.spawnTileX = args.Player.TileX;
|
ConfigurationManager.spawnTileX = args.Player.TileX;
|
||||||
Main.spawnTileY = args.Player.TileY;
|
ConfigurationManager.spawnTileY = args.Player.TileY;
|
||||||
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
||||||
ConfigurationManager.WriteJsonConfiguration();
|
ConfigurationManager.WriteJsonConfiguration();
|
||||||
args.Player.SendMessage("Set server spawn point to your position");
|
args.Player.SendMessage("Set server spawn point to your position");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SaveSpawn(CommandArgs args)
|
||||||
|
{
|
||||||
|
Main.spawnTileX = ConfigurationManager.spawnTileX;
|
||||||
|
Main.spawnTileY = ConfigurationManager.spawnTileY;
|
||||||
|
WorldGen.saveWorld();
|
||||||
|
args.Player.SendMessage("Saved current spawn point to file.");
|
||||||
|
}
|
||||||
|
|
||||||
private static void DebugConfiguration(CommandArgs args)
|
private static void DebugConfiguration(CommandArgs args)
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("TShock Config:");
|
args.Player.SendMessage("TShock Config:");
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ namespace TShockAPI
|
||||||
public static int Spawn_WorldID;
|
public static int Spawn_WorldID;
|
||||||
public static int originalSpawnX;
|
public static int originalSpawnX;
|
||||||
public static int originalSpawnY;
|
public static int originalSpawnY;
|
||||||
|
public static int spawnTileX;
|
||||||
|
public static int spawnTileY;
|
||||||
|
|
||||||
public static bool hardcoreOnly = false;
|
public static bool hardcoreOnly = false;
|
||||||
public static bool KickOnHardcoreDeath = false;
|
public static bool KickOnHardcoreDeath = false;
|
||||||
|
|
@ -125,8 +127,8 @@ namespace TShockAPI
|
||||||
ListServer = cfg.ListServer;
|
ListServer = cfg.ListServer;
|
||||||
originalSpawnX = Main.spawnTileX;
|
originalSpawnX = Main.spawnTileX;
|
||||||
originalSpawnY = Main.spawnTileY;
|
originalSpawnY = Main.spawnTileY;
|
||||||
Main.spawnTileX = cfg.spawnTileX;
|
spawnTileX = cfg.spawnTileX;
|
||||||
Main.spawnTileY = cfg.spawnTileY;
|
spawnTileY = cfg.spawnTileY;
|
||||||
Spawn_WorldID = cfg.Spawn_WorldID;
|
Spawn_WorldID = cfg.Spawn_WorldID;
|
||||||
RememberLeavePos = cfg.RememberLeavePos;
|
RememberLeavePos = cfg.RememberLeavePos;
|
||||||
hardcoreOnly = cfg.HardcoreOnly;
|
hardcoreOnly = cfg.HardcoreOnly;
|
||||||
|
|
@ -166,8 +168,8 @@ namespace TShockAPI
|
||||||
cfg.BackupInterval = BackupInterval;
|
cfg.BackupInterval = BackupInterval;
|
||||||
cfg.BackupKeepFor = BackupKeepFor;
|
cfg.BackupKeepFor = BackupKeepFor;
|
||||||
cfg.ListServer = ListServer;
|
cfg.ListServer = ListServer;
|
||||||
cfg.spawnTileX = Main.spawnTileX;
|
cfg.spawnTileX = spawnTileX;
|
||||||
cfg.spawnTileY = Main.spawnTileY;
|
cfg.spawnTileY = spawnTileY;
|
||||||
cfg.RememberLeavePos = RememberLeavePos;
|
cfg.RememberLeavePos = RememberLeavePos;
|
||||||
cfg.Spawn_WorldID = Spawn_WorldID;
|
cfg.Spawn_WorldID = Spawn_WorldID;
|
||||||
cfg.HardcoreOnly = hardcoreOnly;
|
cfg.HardcoreOnly = hardcoreOnly;
|
||||||
|
|
|
||||||
|
|
@ -314,6 +314,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return Tools.HandleGriefer(args.Player, "Update Player abuse");
|
return Tools.HandleGriefer(args.Player, "Update Player abuse");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -473,6 +474,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
args.Player.InitSpawn = true;
|
args.Player.InitSpawn = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ using Microsoft.Xna.Framework.Content;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
using TerrariaAPI;
|
using TerrariaAPI;
|
||||||
using TerrariaAPI.Hooks;
|
using TerrariaAPI.Hooks;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
@ -87,6 +88,7 @@ namespace TShockAPI
|
||||||
ServerHooks.Command += ServerHooks_OnCommand;
|
ServerHooks.Command += ServerHooks_OnCommand;
|
||||||
NetHooks.GetData += GetData;
|
NetHooks.GetData += GetData;
|
||||||
NetHooks.GreetPlayer += OnGreetPlayer;
|
NetHooks.GreetPlayer += OnGreetPlayer;
|
||||||
|
NetHooks.SendData += OnSendData;
|
||||||
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
@ -228,10 +230,13 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var id = Main.worldID;
|
||||||
if (ConfigurationManager.Spawn_WorldID != Main.worldID)
|
if (ConfigurationManager.Spawn_WorldID != Main.worldID)
|
||||||
{
|
{
|
||||||
Main.spawnTileX = ConfigurationManager.originalSpawnX;
|
Main.spawnTileX = ConfigurationManager.originalSpawnX;
|
||||||
Main.spawnTileY = ConfigurationManager.originalSpawnY;
|
Main.spawnTileY = ConfigurationManager.originalSpawnY;
|
||||||
|
ConfigurationManager.spawnTileX = Main.spawnTileX;
|
||||||
|
ConfigurationManager.spawnTileY = Main.spawnTileY;
|
||||||
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -266,6 +271,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
Players[ply] = player;
|
Players[ply] = player;
|
||||||
Players[ply].InitSpawn = false;
|
Players[ply].InitSpawn = false;
|
||||||
|
|
||||||
Netplay.spamCheck = ConfigurationManager.SpamChecks;
|
Netplay.spamCheck = ConfigurationManager.SpamChecks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -319,6 +325,159 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSendData(SendDataEventArgs e)
|
||||||
|
{
|
||||||
|
int remoteClient = 256;
|
||||||
|
if (e.remoteClient >= 0)
|
||||||
|
remoteClient = e.remoteClient;
|
||||||
|
int num2 = 5;
|
||||||
|
int num3 = num2;
|
||||||
|
if (e.MsgID == PacketTypes.WorldInfo)
|
||||||
|
{
|
||||||
|
byte[] bytes18 = BitConverter.GetBytes((int)e.MsgID);
|
||||||
|
byte[] bytes19 = BitConverter.GetBytes((int)Main.time);
|
||||||
|
byte b6 = 0;
|
||||||
|
if (Main.dayTime)
|
||||||
|
{
|
||||||
|
b6 = 1;
|
||||||
|
}
|
||||||
|
byte b7 = (byte)Main.moonPhase;
|
||||||
|
byte b8 = 0;
|
||||||
|
if (Main.bloodMoon)
|
||||||
|
{
|
||||||
|
b8 = 1;
|
||||||
|
}
|
||||||
|
byte[] bytes20 = BitConverter.GetBytes(Main.maxTilesX);
|
||||||
|
byte[] bytes21 = BitConverter.GetBytes(Main.maxTilesY);
|
||||||
|
byte[] bytes22 = BitConverter.GetBytes(ConfigurationManager.spawnTileX);
|
||||||
|
byte[] bytes23 = BitConverter.GetBytes(ConfigurationManager.spawnTileY);
|
||||||
|
byte[] bytes24 = BitConverter.GetBytes((int)Main.worldSurface);
|
||||||
|
byte[] bytes25 = BitConverter.GetBytes((int)Main.rockLayer);
|
||||||
|
byte[] bytes26 = BitConverter.GetBytes(Main.worldID);
|
||||||
|
byte[] bytes27 = Encoding.ASCII.GetBytes(Main.worldName);
|
||||||
|
byte b9 = 0;
|
||||||
|
if (WorldGen.shadowOrbSmashed)
|
||||||
|
{
|
||||||
|
b9 += 1;
|
||||||
|
}
|
||||||
|
if (NPC.downedBoss1)
|
||||||
|
{
|
||||||
|
b9 += 2;
|
||||||
|
}
|
||||||
|
if (NPC.downedBoss2)
|
||||||
|
{
|
||||||
|
b9 += 4;
|
||||||
|
}
|
||||||
|
if (NPC.downedBoss3)
|
||||||
|
{
|
||||||
|
b9 += 8;
|
||||||
|
}
|
||||||
|
num2 += bytes19.Length + 1 + 1 + 1 + bytes20.Length + bytes21.Length + bytes22.Length + bytes23.Length + bytes24.Length + bytes25.Length + bytes26.Length + 1 + bytes27.Length;
|
||||||
|
byte[] bytes28 = BitConverter.GetBytes(num2 - 4);
|
||||||
|
Buffer.BlockCopy(bytes28, 0, NetMessage.buffer[remoteClient].writeBuffer, 0, 4);
|
||||||
|
Buffer.BlockCopy(bytes18, 0, NetMessage.buffer[remoteClient].writeBuffer, 4, 1);
|
||||||
|
Buffer.BlockCopy(bytes19, 0, NetMessage.buffer[remoteClient].writeBuffer, 5, bytes19.Length);
|
||||||
|
num3 += bytes19.Length;
|
||||||
|
NetMessage.buffer[remoteClient].writeBuffer[num3] = b6;
|
||||||
|
num3++;
|
||||||
|
NetMessage.buffer[remoteClient].writeBuffer[num3] = b7;
|
||||||
|
num3++;
|
||||||
|
NetMessage.buffer[remoteClient].writeBuffer[num3] = b8;
|
||||||
|
num3++;
|
||||||
|
Buffer.BlockCopy(bytes20, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes20.Length);
|
||||||
|
num3 += bytes20.Length;
|
||||||
|
Buffer.BlockCopy(bytes21, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes21.Length);
|
||||||
|
num3 += bytes21.Length;
|
||||||
|
Buffer.BlockCopy(bytes22, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes22.Length);
|
||||||
|
num3 += bytes22.Length;
|
||||||
|
Buffer.BlockCopy(bytes23, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes23.Length);
|
||||||
|
num3 += bytes23.Length;
|
||||||
|
Buffer.BlockCopy(bytes24, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes24.Length);
|
||||||
|
num3 += bytes24.Length;
|
||||||
|
Buffer.BlockCopy(bytes25, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes25.Length);
|
||||||
|
num3 += bytes25.Length;
|
||||||
|
Buffer.BlockCopy(bytes26, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes26.Length);
|
||||||
|
num3 += bytes26.Length;
|
||||||
|
NetMessage.buffer[remoteClient].writeBuffer[num3] = b9;
|
||||||
|
num3++;
|
||||||
|
Buffer.BlockCopy(bytes27, 0, NetMessage.buffer[remoteClient].writeBuffer, num3, bytes27.Length);
|
||||||
|
num3 += bytes27.Length;
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
if (e.Handled)
|
||||||
|
{
|
||||||
|
if (Main.netMode != 1)
|
||||||
|
{
|
||||||
|
goto IL_34D2;
|
||||||
|
}
|
||||||
|
if (Netplay.clientSock.tcpClient.Connected)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetMessage.buffer[remoteClient].spamCount++;
|
||||||
|
Netplay.clientSock.networkStream.BeginWrite(NetMessage.buffer[remoteClient].writeBuffer, 0, num2, new AsyncCallback(Netplay.clientSock.ClientWriteCallBack), Netplay.clientSock.networkStream);
|
||||||
|
goto IL_3612;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
goto IL_3612;
|
||||||
|
}
|
||||||
|
goto IL_34D2;
|
||||||
|
}
|
||||||
|
IL_3612:
|
||||||
|
if (Main.verboseNetplay)
|
||||||
|
{
|
||||||
|
for (int num10 = 0; num10 < num2; num10++)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
for (int num11 = 0; num11 < num2; num11++)
|
||||||
|
{
|
||||||
|
byte arg_3649_0 = NetMessage.buffer[remoteClient].writeBuffer[num11];
|
||||||
|
}
|
||||||
|
goto IL_365B;
|
||||||
|
}
|
||||||
|
goto IL_365B;
|
||||||
|
IL_34D2:
|
||||||
|
if (e.remoteClient == -1)
|
||||||
|
{
|
||||||
|
for (int num12 = 0; num12 < 256; num12++)
|
||||||
|
{
|
||||||
|
if (num12 != e.ignoreClient && (NetMessage.buffer[num12].broadcast || (Netplay.serverSock[num12].state >= 3 && (int)e.MsgID == 10)) && Netplay.serverSock[num12].tcpClient.Connected)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetMessage.buffer[num12].spamCount++;
|
||||||
|
Netplay.serverSock[num12].networkStream.BeginWrite(NetMessage.buffer[remoteClient].writeBuffer, 0, num2, new AsyncCallback(Netplay.serverSock[num12].ServerWriteCallBack), Netplay.serverSock[num12].networkStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
goto IL_3612;
|
||||||
|
}
|
||||||
|
if (Netplay.serverSock[remoteClient].tcpClient.Connected)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetMessage.buffer[remoteClient].spamCount++;
|
||||||
|
Netplay.serverSock[remoteClient].networkStream.BeginWrite(NetMessage.buffer[remoteClient].writeBuffer, 0, num2, new AsyncCallback(Netplay.serverSock[remoteClient].ServerWriteCallBack), Netplay.serverSock[remoteClient].networkStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
goto IL_3612;
|
||||||
|
}
|
||||||
|
goto IL_3612;
|
||||||
|
IL_365B:
|
||||||
|
NetMessage.buffer[remoteClient].writeLocked = false;
|
||||||
|
if ((int)e.MsgID == 2 && Main.netMode == 2)
|
||||||
|
{
|
||||||
|
Netplay.serverSock[remoteClient].kill = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When a server command is run.
|
/// When a server command is run.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue