예제 #1
0
 static bool IsValidHex(string hex)
 {
     for (int i = 0; i < hex.Length; i++)
     {
         if (!Colors.IsStandardColor(hex[i]))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
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);
 }
예제 #3
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);
            }
        }
예제 #4
0
        void ParseColors(StringBuilder sb)
        {
            for (int i = 0; i < 128; i++)
            {
                if (Colors.IsStandardColor((char)i))
                {
                    if (i >= 'A' && i <= 'F') // WoM does not work with uppercase color codes.
                    {
                        sb.Replace("&" + (char)i, "&" + (char)(i + ' '));
                    }
                    continue;
                }

                CustomColor col = Colors.ExtColors[i];
                if (col.Undefined)
                {
                    sb.Replace("&" + (char)i, ""); continue;
                }
                if (!hasTextColors)
                {
                    sb.Replace("&" + (char)i, "&" + col.Fallback); continue;
                }
            }
        }
예제 #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;
            }
        }