示例#1
0
        static public void removePermit(string alias)
        {
            //Does the player already exist?
            if (!Logic_Permit.checkPermit(alias))
            {
                return;
            }

            //Does our permit file exist?
            if (!File.Exists("permit.xml"))
            {
                Log.write(TLog.Warning, "Permission-only enabled and no permit.xml could be located.");
                return;
            }

            //Load our doc
            XmlDocument doc = new XmlDocument();

            doc.Load("permit.xml");

            XmlNodeList xnList = doc.SelectNodes(String.Format("/players/player[@alias='{0}']", alias));

            foreach (XmlNode node in xnList)
            {
                doc.DocumentElement.RemoveChild(node);
            }

            //save back
            doc.Save("permit.xml");
        }
示例#2
0
        static public void addPermit(string alias)
        {
            //Does the player already exist?
            if (Logic_Permit.checkPermit(alias))
            {
                return;
            }

            //Does our permit file exist?
            if (!File.Exists("permit.xml"))
            {
                Log.write(TLog.Warning, "Permission-only enabled and no permit.xml could be located.");
                return;
            }

            //Load our doc
            XmlDocument doc = new XmlDocument();

            doc.Load("permit.xml");

            XmlNode      node = doc.CreateNode(XmlNodeType.Element, "player", null);
            XmlAttribute att  = doc.CreateAttribute("alias");

            att.Value = alias;
            node.Attributes.Append(att);

            //add to elements collection
            doc.DocumentElement.AppendChild(node);

            //save back
            doc.Save("permit.xml");
        }
示例#3
0
        /// <summary>
        /// Handles the login request packet sent by the client
        /// </summary>
        static public void Handle_CS_Login(CS_Login pkt, Client <Player> client)
        {               //Let's escalate our client's status to player!
            ZoneServer server = (client._handler as ZoneServer);

            // check for excessive joins to zone from same IP
            if (pkt.bCreateAlias != true && server._connections.ContainsKey(client._ipe.Address))
            {
                Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Please wait 10 seconds before logging in again.");
                Log.write(TLog.Warning, "Possible throttler removed: {0}", client._ipe.ToString());
                return;
            }
            else if (!server._connections.ContainsKey(client._ipe.Address))
            {
                server._connections.Add(client._ipe.Address, DateTime.Now.AddSeconds(10));
            }

            //Check their client version and UIDs
            //TODO: find out what the UIDs are and what an invalid UID might look like, and reject spoofed ones
            if (pkt.Version != Helpers._serverVersion ||
                pkt.UID1 <= 10000 ||
                pkt.UID2 <= 10000 ||
                pkt.UID3 <= 10000)
            {
                Log.write(TLog.Warning, "Suspicious login packet from {0} : Version ({1}) UID1({2}) UID2({3}) UID3({4})",
                          pkt.Username,
                          pkt.Version,
                          pkt.UID1,
                          pkt.UID2,
                          pkt.UID3);
            }

            String alias = pkt.Username;

            //Check alias for illegal characters
            if (String.IsNullOrWhiteSpace(alias))
            {
                Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias cannot be blank.");
                return;
            }
            try
            { //Temporary till we find the login bug
                if (!char.IsLetterOrDigit(alias, 0) ||
                    char.IsWhiteSpace(alias, 0) ||
                    char.IsWhiteSpace(alias, alias.Length - 1) ||
                    alias != Logic_Text.RemoveIllegalCharacters(alias))
                {   //Boot him..
                    Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias contains illegal characters, must start with a letter or number and cannot end with a space.");
                    return;
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                Log.write(TLog.Warning, "Player login name is {0}", alias);
                Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias contains illegal characters, must start with a letter or number and cannot end with a space.");
                return;
            }

            if (alias.Length > 64)
            {
                //Change this if alias.name in the db is changed.. currently at varchar(64)
                Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias length is too long.");
                return;
            }

            //Are we in permission mode?
            if (server._config["server/permitMode"].boolValue && !Logic_Permit.checkPermit(alias))
            {
                Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Zone is in permission only mode.");
                return;
            }

            Player newPlayer = server.newPlayer(client, alias);

            //If it failed for some reason, present a failure message
            if (newPlayer == null)
            {
                Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Login Failure, Zone is full.");
                Log.write(TLog.Error, "New player is null possibly due to zone being full.");
                return;
            }

            newPlayer._UID1 = pkt.UID1;
            newPlayer._UID2 = pkt.UID2;
            newPlayer._UID3 = pkt.UID3;


            //Are we in standalone mode?
            if (server.IsStandalone)
            {                   //Always first time setup in standalone mode
                newPlayer.assignFirstTimeStats(false);

                //Success! Let him in.
                Helpers.Login_Response(client, SC_Login.Login_Result.Success, "This server is currently in stand-alone mode. Your character's scores and stats will not be saved.");
            }
            else
            {                   //Defer the request to the database server
                CS_PlayerLogin <Data.Database> plogin = new CS_PlayerLogin <Data.Database>();

                plogin.bCreateAlias = pkt.bCreateAlias;

                plogin.player    = newPlayer.toInstance();
                plogin.alias     = alias;
                plogin.ticketid  = pkt.TicketID;
                plogin.UID1      = pkt.UID1;
                plogin.UID2      = pkt.UID2;
                plogin.UID3      = pkt.UID3;
                plogin.NICInfo   = pkt.NICInfo;
                plogin.ipaddress = pkt._client._ipe.Address.ToString().Trim();

                server._db.send(plogin);
            }
        }