Example #1
0
        static void ParseColors(Player p, StringBuilder sb)
        {
            for (int i = 0; i < sb.Length; i++)
            {
                char c = sb[i];
                if (c != '&' || i == sb.Length - 1)
                {
                    continue;
                }

                char code = sb[i + 1];
                if (Colors.IsStandardColor(code))
                {
                    if (code >= 'A' && code <= 'F')
                    {
                        sb[i + 1] += ' '; // WoM does not work with uppercase color codes.
                    }
                }
                else
                {
                    char fallback = Colors.GetFallback(code);
                    if (fallback == '\0')
                    {
                        sb.Remove(i, 2); i--; // now need to check char at i again
                    }
                    else if (!p.hasTextColors)
                    {
                        sb[i + 1] = fallback;
                    }
                }
            }
        }
Example #2
0
        public static bool MapColor(ref char color)
        {
            if (IsStandardColor(color))
            {
                if (color >= 'A' && color <= 'F')
                {
                    color += ' ';
                }
                return(true);
            }

            if (color == 'S')
            {
                color = Server.DefaultColor[1]; return(true);
            }
            if (color == 'H')
            {
                color = Server.HelpDescriptionColor[1]; return(true);
            }
            if (color == 'T')
            {
                color = Server.HelpSyntaxColor[1]; return(true);
            }
            if (color == 'I')
            {
                color = Server.IRCColour[1]; return(true);
            }
            return(Colors.GetFallback(color) != '\0');
        }
Example #3
0
 internal static string GetSupportedCol(Player dst, string col)
 {
     if (col == null)
     {
         return(null);
     }
     if (col.Length >= 2 && !Colors.IsStandardColor(col[1]) && !dst.HasCpeExt(CpeExt.TextColors))
     {
         col = "&" + Colors.GetFallback(col[1]);
     }
     return(col);
 }
Example #4
0
        internal static void Spawn(Player dst, Player p, byte id, ushort x, ushort y, ushort z,
                                   byte rotx, byte roty, string possession = "")
        {
            if (!Server.zombie.Running || !p.Game.Infected)
            {
                string col = p.color;
                if (col.Length >= 2 && !Colors.IsStandardColor(col[1]) && !dst.HasCpeExt(CpeExt.TextColors))
                {
                    col = "&" + Colors.GetFallback(col[1]);
                }
                string group = p.Game.Referee ? "&2Referees" : "&fPlayers";

                if (dst.hasExtList)
                {
                    dst.SendExtAddEntity2(id, p.skinName, col + p.truename + possession, x, y, z, rotx, roty);
                    dst.SendExtAddPlayerName(id, p.skinName, col + p.truename, group, 0);
                }
                else
                {
                    dst.SendSpawn(id, col + p.truename + possession, x, y, z, rotx, roty);
                }
                return;
            }

            string name = p.truename, skinName = p.skinName;

            if (ZombieGame.ZombieName != "" && !dst.Game.Aka)
            {
                name = ZombieGame.ZombieName; skinName = name;
            }

            if (dst.hasExtList)
            {
                dst.SendExtAddEntity2(id, skinName, Colors.red + name + possession, x, y, z, rotx, roty);
                dst.SendExtAddPlayerName(id, skinName, Colors.red + name, "&cZombies", 0);
            }
            else
            {
                dst.SendSpawn(id, Colors.red + name + possession, x, y, z, rotx, roty);
            }

            if (dst.hasChangeModel && id != 0xFF)
            {
                dst.SendChangeModel(id, ZombieGame.ZombieModel);
            }
        }
Example #5
0
        static void ParseProperty(string key, string value, string s, ref Group grp, int version)
        {
            if (key.ToLower() == "rankname")
            {
                if (grp != null)
                {
                    AddGroup(ref grp, version);
                }
                string name = value.ToLower();

                if (name == "adv" || name == "op" || name == "super" || name == "nobody" || name == "noone")
                {
                    Server.s.Log("Cannot have a rank named \"" + name + "\", this rank is hard-coded.");
                }
                else if (Group.GroupList.Find(g => g.name == name) == null)
                {
                    grp          = new Group();
                    grp.trueName = value;
                }
                else
                {
                    Server.s.Log("Cannot add the rank " + value + " twice");
                }
                return;
            }
            if (grp == null)
            {
                return;
            }

            switch (key.ToLower())
            {
            case "permission":
                int perm;

                if (!int.TryParse(value, out perm))
                {
                    Server.s.Log("Invalid permission on " + s);
                    grp = null;
                }
                if (perm > 119 || perm < -50)
                {
                    Server.s.Log("Permission must be between -50 and 119 for ranks");
                    grp = null;
                }
                else if (Group.GroupList.Find(g => g.Permission == (LevelPermission)perm) == null)
                {
                    grp.Permission = (LevelPermission)perm;
                }
                else
                {
                    Server.s.Log("Cannot have 2 ranks set at permission level " + value);
                    grp = null;
                } break;

            case "limit":
                int foundLimit;

                if (!int.TryParse(value, out foundLimit))
                {
                    Server.s.Log("Invalid limit on " + s);
                }
                else
                {
                    grp.maxBlocks = foundLimit;
                } break;

            case "maxundo":
                int foundMax;

                if (!int.TryParse(value, out foundMax))
                {
                    Server.s.Log("Invalid max undo on " + s);
                    grp = null;
                }
                else
                {
                    grp.maxUndo = foundMax;
                } break;

            case "color":
                char col;
                char.TryParse(value, out col);

                if (Colors.IsStandardColor(col) || Colors.GetFallback(col) != '\0')
                {
                    grp.color = col.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    Server.s.Log("Invalid color code at " + s);
                    grp = null;
                } break;

            case "filename":
                if (value.Contains("\\") || value.Contains("/"))
                {
                    Server.s.Log("Invalid filename on " + s);
                    grp = null;
                }
                else
                {
                    grp.fileName = value;
                } break;

            case "motd":
                if (!String.IsNullOrEmpty(value))
                {
                    grp.MOTD = value;
                }
                break;

            case "osmaps":
                byte osmaps;
                if (!byte.TryParse(value, out osmaps))
                {
                    osmaps = 3;
                }
                grp.OverseerMaps = osmaps;
                break;

            case "prefix":
                grp.prefix = value;
                break;
            }
        }