diff --git a/ClassicalSharp/2D/Widgets/Chat/ChatInputWidget.cs b/ClassicalSharp/2D/Widgets/Chat/ChatInputWidget.cs
index de7d1d84d..335dc5efa 100644
--- a/ClassicalSharp/2D/Widgets/Chat/ChatInputWidget.cs
+++ b/ClassicalSharp/2D/Widgets/Chat/ChatInputWidget.cs
@@ -21,7 +21,7 @@ namespace ClassicalSharp.Gui.Widgets {
int typingLogPos;
string originalText;
- public override int UsedLines {
+ public override int UsedLines {
get { return !game.ClassicMode && game.Server.SupportsPartialMessages ? 3 : 1; }
}
@@ -48,7 +48,12 @@ namespace ClassicalSharp.Gui.Widgets {
public override void EnterInput() {
- SendChat();
+ if (!Text.Empty) {
+ // Don't want trailing spaces in output message
+ string allText = new String(Text.value, 0, Text.TextLength);
+ game.Chat.Send(allText);
+ }
+
originalText = null;
typingLogPos = game.Chat.InputLog.Count; // Index of newest entry + 1.
@@ -57,53 +62,6 @@ namespace ClassicalSharp.Gui.Widgets {
base.EnterInput();
}
-
- void SendChat() {
- if (Text.Empty) return;
- // Don't want trailing spaces in output message
- string allText = new String(Text.value, 0, Text.TextLength);
- game.Chat.InputLog.Add(allText);
-
- if (game.Server.SupportsPartialMessages) {
- SendWithPartial(allText);
- } else {
- SendNormal();
- }
- }
-
- void SendWithPartial(string allText) {
- // don't automatically word wrap the message.
- while (allText.Length > Utils.StringLength) {
- game.Chat.Send(allText.Substring(0, Utils.StringLength), true);
- allText = allText.Substring(Utils.StringLength);
- }
- game.Chat.Send(allText, false);
- }
-
- void SendNormal() {
- int packetsCount = 0;
- for (int i = 0; i < lines.Length; i++) {
- if (lines[i] == null) break;
- packetsCount++;
- }
-
- // split up into both partial and final packet.
- for (int i = 0; i < packetsCount - 1; i++)
- SendNormalText(i, true);
- SendNormalText(packetsCount - 1, false);
- }
-
- void SendNormalText(int i, bool partial) {
- string text = lines[i];
- char lastCol = i == 0 ? 'f' : GetLastColour(0, i); // no previous colour on first line
- // TODO: this needs to be better, in case second/third line starts with a colour code
-
- if (!IDrawer2D.IsWhiteCol(lastCol))
- text = "&" + lastCol + text;
- game.Chat.Send(text, partial);
- }
-
-
#region Input handling
public override bool HandlesKeyPress(char key) {
diff --git a/ClassicalSharp/Game/ChatLog.cs b/ClassicalSharp/Game/ChatLog.cs
index 3c7d995a9..ffbf1446a 100644
--- a/ClassicalSharp/Game/ChatLog.cs
+++ b/ClassicalSharp/Game/ChatLog.cs
@@ -30,15 +30,15 @@ namespace ClassicalSharp {
/// List of chat messages sent by the user to the server.
public List InputLog = new List();
- public void Send(string text, bool partial) {
- text = text.TrimEnd(trimChars);
+ public void Send(string text) {
if (String.IsNullOrEmpty(text)) return;
+ InputLog.Add(text);
if (game.CommandList.IsCommandPrefix(text)) {
game.CommandList.Execute(text);
- return;
+ } else {
+ game.Server.SendChat(text);
}
- game.Server.SendChat(text, partial);
}
static char[] trimChars = new char[] { ' ', '\0' };
@@ -91,10 +91,10 @@ namespace ClassicalSharp {
}
static bool Allowed(char c) {
- return
- c == '{' || c == '}' ||
- c == '[' || c == ']' ||
- c == '(' || c == ')' ||
+ return
+ c == '{' || c == '}' ||
+ c == '[' || c == ']' ||
+ c == '(' || c == ')' ||
(c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z');
}
diff --git a/ClassicalSharp/Game/InputHandler.cs b/ClassicalSharp/Game/InputHandler.cs
index 063374de0..79731793e 100644
--- a/ClassicalSharp/Game/InputHandler.cs
+++ b/ClassicalSharp/Game/InputHandler.cs
@@ -190,7 +190,7 @@ namespace ClassicalSharp {
if (!Hotkeys.IsHotkey(key, game.Input, out text, out more)) return;
if (!more) {
- game.Server.SendChat(text, false);
+ game.Server.SendChat(text);
} else if (game.Gui.activeScreen == null) {
game.Gui.hudScreen.OpenTextInputBar(text);
}
diff --git a/ClassicalSharp/Network/IServerConnection.cs b/ClassicalSharp/Network/IServerConnection.cs
index 1732f35f2..23296e5c8 100644
--- a/ClassicalSharp/Network/IServerConnection.cs
+++ b/ClassicalSharp/Network/IServerConnection.cs
@@ -24,7 +24,7 @@ namespace ClassicalSharp {
/// Opens a connection to the given IP address and port, and prepares the initial state of the client.
public abstract void Connect(IPAddress address, int port);
- public abstract void SendChat(string text, bool partial);
+ public abstract void SendChat(string text);
/// Informs the server of the client's current position and orientation.
public abstract void SendPosition(Vector3 pos, float rotY, float headX);
diff --git a/ClassicalSharp/Network/NetworkProcessor.Helpers.cs b/ClassicalSharp/Network/NetworkProcessor.Helpers.cs
index f1345c4d6..487f5e83f 100644
--- a/ClassicalSharp/Network/NetworkProcessor.Helpers.cs
+++ b/ClassicalSharp/Network/NetworkProcessor.Helpers.cs
@@ -10,9 +10,15 @@ namespace ClassicalSharp.Network {
internal bool addEntityHack = true;
- public override void SendChat(string text, bool partial) {
+ public override void SendChat(string text) {
if (String.IsNullOrEmpty(text)) return;
- classic.WriteChat(text, partial);
+
+ while (text.Length > Utils.StringLength) {
+ classic.WriteChat(text.Substring(0, Utils.StringLength), true);
+ SendPacket();
+ text = text.Substring(Utils.StringLength);
+ }
+ classic.WriteChat(text, false);
SendPacket();
}
@@ -55,7 +61,7 @@ namespace ClassicalSharp.Network {
game.LocalPlayer.fetchedSkin = false;
game.LocalPlayer.DisplayName = displayName;
- game.LocalPlayer.SkinName = skinName;
+ game.LocalPlayer.SkinName = skinName;
game.LocalPlayer.UpdateName();
}
@@ -71,7 +77,7 @@ namespace ClassicalSharp.Network {
internal void RemoveEntity(byte id) {
Entity entity = game.Entities.List[id];
- if (entity == null) return;
+ if (entity == null) return;
if (id != EntityList.SelfID) game.Entities.RemoveEntity(id);
// See comment about some servers in HandleAddEntity
diff --git a/ClassicalSharp/Network/Protocols/WoM.cs b/ClassicalSharp/Network/Protocols/WoM.cs
index 962f88f77..4fcda02e3 100644
--- a/ClassicalSharp/Network/Protocols/WoM.cs
+++ b/ClassicalSharp/Network/Protocols/WoM.cs
@@ -42,7 +42,7 @@ namespace ClassicalSharp.Network.Protocols {
internal void CheckSendWomID() {
if (sendWomId && !sentWomId) {
- net.SendChat("/womid WoMClient-2.0.7", false);
+ net.SendChat("/womid WoMClient-2.0.7");
sentWomId = true;
}
}
diff --git a/ClassicalSharp/Singleplayer/Server.cs b/ClassicalSharp/Singleplayer/Server.cs
index 92da1fc2c..04f31e63e 100644
--- a/ClassicalSharp/Singleplayer/Server.cs
+++ b/ClassicalSharp/Singleplayer/Server.cs
@@ -40,10 +40,15 @@ namespace ClassicalSharp.Singleplayer {
}
char lastCol = '\0';
- public override void SendChat(string text, bool partial) {
- if (!String.IsNullOrEmpty(text))
- AddChat(text);
- if (!partial) lastCol = '\0';
+ public override void SendChat(string text) {
+ if (String.IsNullOrEmpty(text)) return;
+ lastCol = '\0';
+
+ while (text.Length > Utils.StringLength) {
+ AddChat(text.Substring(0, Utils.StringLength));
+ text = text.Substring(Utils.StringLength);
+ }
+ AddChat(text);
}
void AddChat(string text) {