Ejemplo n.º 1
0
        public void CM_DELETE_CHARACTER(CMSG_INTERNAL_DELETIONREPLY cpkt)
        {
            ServerInfo2  info;
            LoginSession session;

            if (LoginSessionHandler.sessions.TryGetValue(cpkt.SessionId, out session))
            {
                if (ServerManager2.Instance.server.TryGetValue(session.World, out info))
                {
                    Predicate <CharInfo> callback = delegate(CharInfo info2)
                    {
                        return(info2.charId == session.PedingCharDeletion);
                    };

                    int index = session.list.FindIndex(callback);


                    SMSG_DELETECHARACTER spkt = new SMSG_DELETECHARACTER();
                    spkt.SessionId = cpkt.SessionId;
                    spkt.Index     = (byte)index;

                    //CHARACTER CREATION SUCCESS
                    if (cpkt.Result == 0)
                    {
                        Singleton.Database.RemoveCharacterOnWorld(session.playerid, session.World);
                        session.CachedCharacterStates.Remove(session.PedingCharDeletion);
                        if (index > -1)
                        {
                            session.list.RemoveAt(index);
                        }
                        session.PedingCharDeletion = 0;
                        session.client.Send((byte[])spkt);

                        SMSG_CHARACTERLIST spkt2 = new SMSG_CHARACTERLIST();
                        spkt2.Result         = 0;
                        spkt2.CountAllServer = (byte)--session.NCharacterCount;
                        spkt2.ServerName     = info.name;
                        spkt2.SessionId      = cpkt.SessionId;
                        foreach (CharInfo info2 in session.list)
                        {
                            spkt2.AddChar(info2.charId, info2.name, 1, info2.cexp, info2.job, 0, info2.map);
                        }
                        session.client.Send((byte[])spkt2);
                    }
                    else
                    {
                        session.PedingCharDeletion = 0;
                        spkt.Result = cpkt.Result;
                        session.client.Send((byte[])spkt);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void OnDeleteChar(CMSG_DELETECHARACTER cpkt)
        {
            //HELPER VARIABLES
            ServerInfo2  info2;
            LoginSession session;


            //START CREATING THE CHARACTER ON OUR SERVER
            if (LoginSessionHandler.sessions.TryGetValue(cpkt.SessionId, out session))
            {
                if (ServerManager2.Instance.server.TryGetValue(session.World, out info2))
                {
                    //CHECK IF INDEX IS VALID
                    if (cpkt.Index < 0 || cpkt.Index >= session.list.Count)
                    {
                        SMSG_DELETECHARACTER spkt = new SMSG_DELETECHARACTER();
                        spkt.Result    = (byte)LoginError.INCORRECT_KEY_OR_SERVERNUMBERVALUE;
                        spkt.SessionId = cpkt.SessionId;
                        this.Send((byte[])spkt);
                    }
                    //CHECK IF NAME MATCHES OUR INDEX VALUE
                    else if (session.list[cpkt.Index].name.ToLowerInvariant() != cpkt.Name.ToLowerInvariant())
                    {
                        SMSG_DELETECHARACTER spkt = new SMSG_DELETECHARACTER();
                        spkt.Result    = (byte)LoginError.INCORRECT_KEY_OR_SERVERNUMBERVALUE;
                        spkt.SessionId = cpkt.SessionId;
                        this.Send((byte[])spkt);
                    }
                    //DELETE CHARACTER
                    else
                    {
                        uint charid = session.list[cpkt.Index].charId;
                        session.PedingCharDeletion = charid;
                        info2.client.SM_DELETE_CHARACTER(charid, cpkt.SessionId);
                    }
                }
            }
        }