Merge branch 'general-devel' of github.com:NyxStudios/TShock into general-devel

This commit is contained in:
Lucas Nicodemus 2015-04-12 21:46:46 -06:00
commit 0f1b334d8e
9 changed files with 29 additions and 85 deletions

View file

@ -1121,7 +1121,7 @@ namespace TShockAPI
private static void WorldInfo(CommandArgs args)
{
args.Player.SendInfoMessage("World name: " + Main.worldName);
args.Player.SendInfoMessage("World name: " + (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName));
args.Player.SendInfoMessage("World size: {0}x{1}", Main.maxTilesX, Main.maxTilesY);
args.Player.SendInfoMessage("World ID: " + Main.worldID);
}

View file

@ -123,13 +123,13 @@ namespace TShockAPI
void Write(string message, TraceLevel level);
/// <summary>
/// Writes a debug string to the log file.
/// Writes a debug string to the log file. Only works if the DEBUG preprocessor conditional is set.
/// </summary>
/// <param name="message">The message to be written.</param>
void Debug(string message);
/// <summary>
/// Writes a debug string to the log file.
/// Writes a debug string to the log file. Only works if the DEBUG preprocessor conditional is set.
/// </summary>
/// <param name="format">The format of the message to be written.</param>
/// <param name="args">The format arguments.</param>

View file

@ -154,7 +154,8 @@ namespace TShockAPI
{
ConsoleInfo(string.Format(format, args));
}
#if DEBUG
/// <summary>
/// Writes a debug string to the log file.
/// </summary>
@ -175,6 +176,7 @@ namespace TShockAPI
{
Debug(string.Format(format, args));
}
#endif
/// <summary>
/// Internal method which writes a message directly to the log file.

View file

@ -333,7 +333,7 @@ namespace TShockAPI
{"port", TShock.Config.ServerPort},
{"playercount", Main.player.Where(p => null != p && p.active).Count()},
{"maxplayers", TShock.Config.MaxSlots},
{"world", Main.worldName},
{"world", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName)},
{"uptime", (DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime).ToString(@"d'.'hh':'mm':'ss")},
{"serverpassword", !string.IsNullOrEmpty(TShock.Config.ServerPassword)}
};
@ -707,7 +707,7 @@ namespace TShockAPI
{
return new RestObject()
{
{"name", Main.worldName},
{"name", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName)},
{"size", Main.maxTilesX + "*" + Main.maxTilesY},
{"time", Main.time},
{"daytime", Main.dayTime},

View file

@ -211,7 +211,9 @@ namespace TShockAPI
/// <param name="message">The message to be written.</param>
public void Debug(string message)
{
#if DEBUG
Write(message, TraceLevel.Verbose);
#endif
}
/// <summary>
@ -221,7 +223,9 @@ namespace TShockAPI
/// <param name="args">The format arguments.</param>
public void Debug(string format, params object[] args)
{
#if DEBUG
Debug(string.Format(format, args));
#endif
}
public void Write(string message, TraceLevel level)

View file

@ -538,78 +538,6 @@ namespace TShockAPI
}
}
public void SendWorldInfo(int tilex, int tiley, bool fakeid)
{
using (var ms = new MemoryStream())
{
var msg = new WorldInfoMsg
{
Time = (int)Main.time,
DayTime = Main.dayTime,
MoonPhase = (byte)Main.moonPhase,
BloodMoon = Main.bloodMoon,
Eclipse = Main.eclipse,
MaxTilesX = (short)Main.maxTilesX,
MaxTilesY = (short)Main.maxTilesY,
SpawnX = (short)Main.spawnTileX,
SpawnY = (short)Main.spawnTileY,
WorldSurface = (short)Main.worldSurface,
RockLayer = (short)Main.rockLayer,
//Sending a fake world id causes the client to not be able to find a stored spawnx/y.
//This fixes the bed spawn point bug. With a fake world id it wont be able to find the bed spawn.
WorldID = Main.worldID,
MoonType = (byte)Main.moonType,
TreeX0 = Main.treeX[0],
TreeX1 = Main.treeX[1],
TreeX2 = Main.treeX[2],
TreeStyle0 = (byte)Main.treeStyle[0],
TreeStyle1 = (byte)Main.treeStyle[1],
TreeStyle2 = (byte)Main.treeStyle[2],
TreeStyle3 = (byte)Main.treeStyle[3],
CaveBackX0 = Main.caveBackX[0],
CaveBackX1 = Main.caveBackX[1],
CaveBackX2 = Main.caveBackX[2],
CaveBackStyle0 = (byte)Main.caveBackStyle[0],
CaveBackStyle1 = (byte)Main.caveBackStyle[1],
CaveBackStyle2 = (byte)Main.caveBackStyle[2],
CaveBackStyle3 = (byte)Main.caveBackStyle[3],
SetBG0 = (byte)WorldGen.treeBG,
SetBG1 = (byte)WorldGen.corruptBG,
SetBG2 = (byte)WorldGen.jungleBG,
SetBG3 = (byte)WorldGen.snowBG,
SetBG4 = (byte)WorldGen.hallowBG,
SetBG5 = (byte)WorldGen.crimsonBG,
SetBG6 = (byte)WorldGen.desertBG,
SetBG7 = (byte)WorldGen.oceanBG,
IceBackStyle = (byte)Main.iceBackStyle,
JungleBackStyle = (byte)Main.jungleBackStyle,
HellBackStyle = (byte)Main.hellBackStyle,
WindSpeed = Main.windSpeed,
NumberOfClouds = (byte)Main.numClouds,
BossFlags = (WorldGen.shadowOrbSmashed ? BossFlags.OrbSmashed : BossFlags.None) |
(NPC.downedBoss1 ? BossFlags.DownedBoss1 : BossFlags.None) |
(NPC.downedBoss2 ? BossFlags.DownedBoss2 : BossFlags.None) |
(NPC.downedBoss3 ? BossFlags.DownedBoss3 : BossFlags.None) |
(Main.hardMode ? BossFlags.HardMode : BossFlags.None) |
(NPC.downedClown ? BossFlags.DownedClown : BossFlags.None) |
(Main.ServerSideCharacter ? BossFlags.ServerSideCharacter : BossFlags.None) |
(NPC.downedPlantBoss ? BossFlags.DownedPlantBoss : BossFlags.None),
BossFlags2 = (NPC.downedMechBoss1 ? BossFlags2.DownedMechBoss1 : BossFlags2.None) |
(NPC.downedMechBoss2 ? BossFlags2.DownedMechBoss2 : BossFlags2.None) |
(NPC.downedMechBoss3 ? BossFlags2.DownedMechBoss3 : BossFlags2.None) |
(NPC.downedMechBossAny ? BossFlags2.DownedMechBossAny : BossFlags2.None) |
(Main.cloudBGActive == 1f ? BossFlags2.CloudBg : BossFlags2.None) |
(WorldGen.crimson ? BossFlags2.Crimson : BossFlags2.None) |
(Main.pumpkinMoon ? BossFlags2.PumpkinMoon : BossFlags2.None) |
(Main.snowMoon ? BossFlags2.SnowMoon : BossFlags2.None),
Rain = Main.maxRaining,
WorldName = TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName
};
msg.PackFull(ms);
SendRawData(ms.ToArray());
}
}
public bool Teleport(float x, float y, byte style = 1)
{
if (x > Main.rightWorld - 992)
@ -849,7 +777,7 @@ namespace TShockAPI
{
if (displayConsole)
{
TShock.Log.ConsoleInfo("Player {0} has been disabled for {1}.", Name, reason);
TShock.Log.ConsoleInfo("Player {0} has been disabled for {1}.", Name, reason);
}
else
{

View file

@ -1358,9 +1358,6 @@ namespace TShockAPI
}
else if (e.MsgId == PacketTypes.WorldInfo)
{
if (e.remoteClient == -1) return;
var player = Players[e.remoteClient];
if (player == null) return;
using (var ms = new MemoryStream())
{
var msg = new WorldInfoMsg
@ -1422,12 +1419,21 @@ namespace TShockAPI
(Main.cloudBGActive >= 1f ? BossFlags2.CloudBg : BossFlags2.None) |
(WorldGen.crimson ? BossFlags2.Crimson : BossFlags2.None) |
(Main.pumpkinMoon ? BossFlags2.PumpkinMoon : BossFlags2.None) |
(Main.snowMoon ? BossFlags2.SnowMoon : BossFlags2.None) ,
(Main.snowMoon ? BossFlags2.SnowMoon : BossFlags2.None),
Rain = Main.maxRaining,
WorldName = TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName
};
msg.PackFull(ms);
player.SendRawData(ms.ToArray());
if (e.remoteClient == -1)
{
TSPlayer.All.SendRawData(ms.ToArray());
}
else
{
var player = Players[e.remoteClient];
if (player == null) return;
player.SendRawData(ms.ToArray());
}
}
e.Handled = true;
return;

View file

@ -178,7 +178,9 @@ namespace TShockAPI
/// <param name="message">The message to be written.</param>
public void Debug(string message)
{
#if DEBUG
Write(message, TraceLevel.Verbose);
#endif
}
/// <summary>
@ -188,7 +190,9 @@ namespace TShockAPI
/// <param name="args">The format arguments.</param>
public void Debug(string format, params object[] args)
{
#if DEBUG
Debug(string.Format(format, args));
#endif
}
/// <summary>

View file

@ -650,7 +650,7 @@ namespace TShockAPI
continue;
}
foo = foo.Replace("%map%", Main.worldName);
foo = foo.Replace("%map%", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName));
foo = foo.Replace("%players%", String.Join(",", GetPlayers(false)));
Regex reg = new Regex("%\\s*(?<r>\\d{1,3})\\s*,\\s*(?<g>\\d{1,3})\\s*,\\s*(?<b>\\d{1,3})\\s*%");
var matches = reg.Matches(foo);