Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of messages containing ACTION #660

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 16 additions & 35 deletions DXMainClient/Online/CnCNetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,46 +323,27 @@ private void DoChatMessageReceived(string receiver, string senderName, string id
return;

Color foreColor;

// Handle ACTION
if (message.Contains("ACTION"))
{
message = message.Remove(0, 7);
message = "====> " + senderName + " " + message;
senderName = String.Empty;

// Replace Funky's game identifiers with real game names
for (int i = 0; i < gameCollection.GameList.Count; i++)
// TODO localize this or not?
message = message.Replace("new " + gameCollection.GetGameIdentifierFromIndex(i) + " game",
"new " + gameCollection.GetFullGameNameFromIndex(i) + " game");

foreColor = Color.White;
}
else
// Color parsing
if (message.Contains(Convert.ToString((char)03)))
{
// Color parsing
if (message.Contains(Convert.ToString((char)03)))
if (message.Length < 3)
{
if (message.Length < 3)
{
foreColor = cDefaultChatColor;
}
else
{
string colorString = message.Substring(1, 2);
message = message.Remove(0, 3);
int colorIndex = Conversions.IntFromString(colorString, -1);
// Try to parse message color info; if fails, use default color
if (colorIndex < ircChatColors.Length && colorIndex > -1)
foreColor = ircChatColors[colorIndex].XnaColor;
else
foreColor = cDefaultChatColor;
}
foreColor = cDefaultChatColor;
}
else
foreColor = cDefaultChatColor;
{
string colorString = message.Substring(1, 2);
message = message.Remove(0, 3);
int colorIndex = Conversions.IntFromString(colorString, -1);
// Try to parse message color info; if fails, use default color
if (colorIndex < ircChatColors.Length && colorIndex > -1)
foreColor = ircChatColors[colorIndex].XnaColor;
else
foreColor = cDefaultChatColor;
}
}
else
foreColor = cDefaultChatColor;

if (message.Length > 1 && message[message.Length - 1] == '\u001f')
message = message.Remove(message.Length - 1);
Expand Down
Loading