示例#1
0
    static public void LoginGet(NetworkMessage netMsg)
    {
        tempConn = netMsg.conn;
        Message_Sr.LoginSendMess_Sr Aut = netMsg.ReadMessage <Message_Sr.LoginSendMess_Sr>();
        int accID = -1;

        if (SQL_FindLogPass.CheckLP(Aut.log, Aut.pass, out data, out accID))
        {
            AccountData acc = new AccountData();
            acc.conn      = netMsg.conn;
            acc.login     = Aut.log;
            acc.password  = Aut.pass;
            acc.accountID = accID;

            int sessionID = -1;
            if (freeSlots.Count > 0)
            {
                sessionID = freeSlots[0];
                freeSlots.RemoveAt(0);
                Accounts[sessionID] = acc;
            }
            else
            {
                sessionID = Accounts.Count;
                Accounts.Add(acc);
            }
            ConnectionIDList.Add(netMsg.conn.connectionId, sessionID);
            AccountOnline.Add(accID, true);

            Message_Sr.CharData charsList = new Message_Sr.CharData();
            charsList.index   = sessionID;
            charsList.players = data;
            netMsg.conn.Send(Networking_msgType_Sr.PlayerDataGet, charsList.Serialize());
        }
    }
示例#2
0
    //Add new char on account
    public static void CreateChar(NetworkMessage netmsg)
    {
        Message_Sr.CreateChar character = netmsg.ReadMessage <Message_Sr.CreateChar> ();
        if (Networking_OnConnect.AccountVerefication(character.sessionID, character.log, character.pass))
        {
            if (character.nick.Length < NickSymbolMin)
            {
                Message_Sr.CreateChar create = new Message_Sr.CreateChar();
                create.msg = minNickSymbol;
                netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create);
            }
            else
            {
                Linq.CommandText = "SELECT id FROM accountlist WHERE AccountName='" + character.log + "' AND PasswordAc = '" + character.pass + "'";
                MySqlDataReader read = Linq.ExecuteReader();

                if (read.Read())
                {
                    int ID = int.Parse(read.GetString(0));
                    read.Close();
                    Linq.CommandText = "SELECT COUNT(*) FROM charecter WHERE PlayerName = '" + character.nick + "'";
                    read             = Linq.ExecuteReader();

                    if (read.Read())
                    {
                        if (int.Parse(read.GetString(0)) == 1)
                        {
                            read.Close();
                            Message_Sr.CreateChar create = new Message_Sr.CreateChar();
                            create.msg = busyNick;
                            netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create);
                        }
                        else
                        {
                            read.Close();
                            Linq.CommandText = "SELECT COUNT(*) FROM charecter WHERE account_id = '" + ID.ToString() + "'";
                            read             = Linq.ExecuteReader();

                            if (read.Read())
                            {
                                int numberChars = int.Parse(read.GetString(0));
                                read.Close();

                                if (numberChars < maxCharInAccount)
                                {
                                    Linq.CommandText = "INSERT INTO charecter (account_id, PlayerName, MaxHP, PlayerScores, scene_ID, x, y, z) VALUES (" + ID.ToString() + ", '" + character.nick + "', 100, 0, 0, '5', '120', '5')";
                                    int row = Linq.ExecuteNonQuery();
                                    Debug.Log("Succsess create new character '" + character.nick + "' " + row + ".");
                                    Message_Sr.CreateChar create = new Message_Sr.CreateChar();
                                    create.msg = characterCreated;
                                    netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create);
                                    List <Data_PlayerFile_Sr> list = SQL_FindLogPass.CharDataGet(ID.ToString());
                                    Message_Sr.CharData       data = new Message_Sr.CharData();
                                    data.index   = character.sessionID;
                                    data.players = list;
                                    netmsg.conn.Send(Networking_msgType_Sr.PlayerDataGet, data.Serialize());
                                }
                                else
                                {
                                    Message_Sr.CreateChar create = new Message_Sr.CreateChar();
                                    create.msg = maxChars;
                                    netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create);
                                }
                            }
                            else
                            {
                                Message_Sr.CreateChar create = new Message_Sr.CreateChar();
                                create.msg = notValidAcc;
                                netmsg.conn.Send(Networking_msgType_Sr.CharCreate, create);
                            }
                        }
                    }
                }
            }
        }
    }