Fix long messages being incorrectly trimmed on IRC sometimes, fixes #223

This commit is contained in:
UnknownShadow200 2017-10-27 17:58:13 +11:00
parent 3bbff57d8f
commit fe67055701
4 changed files with 6 additions and 26 deletions

View File

@ -20,37 +20,19 @@ using System;
namespace MCGalaxy.Games {
public abstract class IGame {
/// <summary> Name of the map this game is running on. </summary>
public string MapName;
/// <summary> Level instance of the map this game is running on. </summary>
public Level Map;
/// <summary> Gets whether this game is currently running. </summary>
public abstract bool Running { get; }
/// <summary> Whether players are allowed to teleport to others when not in referee mode. </summary>
public virtual bool TeleportAllowed { get { return true; } }
public virtual bool TeleportAllowed { get { return true; } }
/// <summary> Returns whether this game handled the player sending a chat message. </summary>
public virtual bool HandlesChatMessage(Player p, string message) {
return false;
}
public virtual bool HandlesChatMessage(Player p, string message) { return false; }
/// <summary> Raised when a player joins the server. </summary>
public virtual void PlayerJoinedServer(Player p) { }
/// <summary> Raised when a player joins this game. </summary>
public virtual void PlayerJoinedGame(Player p) { }
/// <summary> Raised when a player leaves this game. </summary>
public virtual void PlayerLeftGame(Player p) { }
/// <summary> Raised when a player moves to a different map/level. </summary>
public virtual void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl) { }
/// <summary> Raised when the server is about to send a heartbeat. </summary>
public virtual void OnHeartbeat(ref string name) { }
/// <summary> Adjusts the prefix (e.g. title) shown before the player's name in chat. </summary>

View File

@ -22,11 +22,7 @@ using System.Threading;
namespace MCGalaxy.Games {
public abstract class LevelPicker {
/// <summary> Level specifically chosen to be used in the next round. </summary>
public string QueuedMap;
/// <summary> List of maps that have been recently played in this game. </summary>
public List<string> RecentMaps = new List<string>();
internal string Candidate1 = "", Candidate2 = "", Candidate3 = "";

View File

@ -41,6 +41,8 @@ namespace Sharkbite.Irc
internal const char SPACE = ' ';
internal const string SPACE_COLON = " :";
internal const int MAX_COMMAND_SIZE = 512;
internal const int MAX_HOSTNAME_LEN = 63;
internal const int MAX_NICKNAME_LEN = 30;
internal const char CtcpQuote = '\u0001';
internal CommandBuilder(Connection connection) {

View File

@ -755,7 +755,7 @@ namespace Sharkbite.Irc
if (Rfc2812Util.IsValidChannelName(channel))
{
// 11 is PRIVMSG + 2 x Spaces + : + CR + LF
int max = MAX_COMMAND_SIZE - 11 - channel.Length;
int max = MAX_COMMAND_SIZE - 11 - channel.Length - MAX_HOSTNAME_LEN - MAX_NICKNAME_LEN;
if (message.Length > max)
{
string[] parts = BreakUpMessage( message, max );
@ -806,7 +806,7 @@ namespace Sharkbite.Irc
if (Rfc2812Util.IsValidNick(nick))
{
// 11 is PRIVMSG + 2 x Spaces + : + CR + LF
int max = MAX_COMMAND_SIZE - 11 - nick.Length;
int max = MAX_COMMAND_SIZE - 11 - nick.Length - MAX_HOSTNAME_LEN - MAX_NICKNAME_LEN;
if (message.Length > max)
{
string[] parts = BreakUpMessage( message, max );