Adds a configurable world name to be sent to clients which is saved as
the name of the server.
This commit is contained in:
Deathmax 2012-05-27 11:46:49 +08:00
parent ccdedca196
commit 727bff5bd4
3 changed files with 5 additions and 3 deletions

View file

@ -83,7 +83,8 @@ namespace TShockAPI
[Description("Not implemented")] public string RconPassword = ""; [Description("Not implemented")] public string RconPassword = "";
[Description("Not implemented")] public int RconPort = 7777; [Description("Not implemented")] public int RconPort = 7777;
[Description("Used when replying to a rest /status request.")] public string ServerName = ""; [Description("Used when replying to a rest /status request or sent to the client when UseServerName is true.")] public string ServerName = "";
[Description("Sends ServerName in place of the world name to clients.")] public bool UseServerName = false;
[Description("Not implemented")] public string MasterServer = "127.0.0.1"; [Description("Not implemented")] public string MasterServer = "127.0.0.1";
[Description("Valid types are \"sqlite\" and \"mysql\"")] public string StorageType = "sqlite"; [Description("Valid types are \"sqlite\" and \"mysql\"")] public string StorageType = "sqlite";

View file

@ -238,7 +238,7 @@ namespace TShockAPI
} }
private void SendWorldInfo(int tilex, int tiley, bool fakeid) public void SendWorldInfo(int tilex, int tiley, bool fakeid)
{ {
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
{ {
@ -263,7 +263,7 @@ namespace TShockAPI
(NPC.downedBoss3 ? WorldInfoFlag.DownedBoss3 : WorldInfoFlag.None) | (NPC.downedBoss3 ? WorldInfoFlag.DownedBoss3 : WorldInfoFlag.None) |
(Main.hardMode ? WorldInfoFlag.HardMode : WorldInfoFlag.None) | (Main.hardMode ? WorldInfoFlag.HardMode : WorldInfoFlag.None) |
(NPC.downedClown ? WorldInfoFlag.DownedClown : WorldInfoFlag.None), (NPC.downedClown ? WorldInfoFlag.DownedClown : WorldInfoFlag.None),
WorldName = Main.worldName WorldName = TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName
}; };
msg.PackFull(ms); msg.PackFull(ms);
SendRawData(ms.ToArray()); SendRawData(ms.ToArray());

View file

@ -739,6 +739,7 @@ namespace TShockAPI
handler.Handled = true; handler.Handled = true;
return; return;
} }
player.SendWorldInfo(Main.spawnTileX, Main.spawnTileY, false);
} }
private void OnLeave(int ply) private void OnLeave(int ply)