Skip() 공개 메소드

public Skip ( int HowMany ) : void
HowMany int
리턴 void
예제 #1
0
파일: Deletion.cs 프로젝트: CarlosX/DarkEmu
 //Void character delete
 void CharacterDelete()
 {
     //Wrap our function in a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Skip one not used byte
         Reader.Skip(1);
         //Get character name information
         string CharacterName = Reader.Text();
         //Close packet reader
         Reader.Close();
         //Update and set time + deletion state into the database
         MsSQL.InsertData("UPDATE character SET deletedtime=dateadd(dd,7,getdate()),deleted='1' WHERE name='" + CharacterName + "'");
         //Send visual state of character on screen sit down
         client.Send(Packet.ScreenSuccess(3));
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Character deletion error {0}", ex);
         //Write information to debug logger
         Systems.Debugger.Write(ex);
     }
 }
예제 #2
0
파일: Creation.cs 프로젝트: CarlosX/DarkEmu
 //This is for checking the new character name
 public void CharacterCheck(byte[] buff)
 {
     //Wrap our function into a catcher
     try
     {
         //Open our packet reader
         PacketReader Reader = new PacketReader(buff);
         //Ignore first byte
         Reader.Skip(1);
         //Read character name
         string Charactername = Reader.Text();
         //Close packet reader
         Reader.Close();
         //If Character name is in use
         if (CharacterCheck(Charactername))
             //Send in use packet
             client.Send(Packet.CharacterName(4));
         //If character name is ok
         else
             //Send succes packet
             client.Send(Packet.ScreenSuccess(4));
     }
     catch (Exception ex)
     {
         //Write any error to debog log
         Systems.Debugger.Write(ex);
     }
 }
예제 #3
0
 public void Connect()
 {
     //Wrap our function inside a catcher
     try
     {
         //Open our packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         byte type = Reader.Byte();
         Reader.Skip(3);
         string ID = Reader.Text();
         string PW = Reader.Text();
         Reader.Close();
         //Set login result information
         int LoginResult = LoginUser(ID, ref PW, ref Player, true);
         //If the login is succesfull
         if (LoginResult == 0)
         {
             //Send succes packet
             client.Send(Packet.ConnectSuccess());
         }
         //If the login is wrong
         else
         {
             //Disconnect the user
             client.Disconnect(PacketInformation.Client);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Client connect error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
예제 #4
0
파일: Restore.cs 프로젝트: CarlosX/DarkEmu
 void CharacterRestore()
 {
     //Wrap our function in a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Skip one byte
         Reader.Skip(1);
         //Read charactername to be restored
         string CharacterName = Reader.Text();
         Reader.Close();
         //Update database information set deleted state to 0
         MsSQL.InsertData("UPDATE character SET deleted='0' WHERE name='" + CharacterName + "'");
         //Send state packet to client character standing up
         client.Send(Packet.ScreenSuccess(5));
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Character restore error {0}", ex);
         //Write information to the debug log
         Systems.Debugger.Write(ex);
     }
 }
예제 #5
0
 void CharacterJobPick(byte[] buff)
 {
     //Wrap our function inside a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(buff);
         //Skip first byte not used
         Reader.Skip(1);
         //Read name lenght
         short CharacterNameLEN = Reader.Int16();
         //Read character name
         string CharacterName = Reader.String(CharacterNameLEN);
         //Read job selection
         byte job = Reader.Byte();
         //Close packet reader
         Reader.Close();
         //Get row count from character to check if the current account and character match
         int NameCheck = MsSQL.GetRowsCount("SELECT * FROM character WHERE account='" + Player.AccountName + "'");
         //Get job information from database as integer
         int jobcheck = MsSQL.GetDataInt("SELECT jobtype FROM users WHERE id='" + Player.AccountName + "'", "jobtype");
         //If the name check is succesfull and account has no job set.
         if (jobcheck == 0 && NameCheck != 0)
         {
             //Write new job information to the database
             MsSQL.UpdateData("UPDATE users SET jobtype='" + job + "' WHERE id='" + Player.AccountName + "'");
         }
         //Send visual confirmation in packet
         PacketWriter writer = new PacketWriter();
         //Add opcode
         writer.Create(Systems.SERVER_CHARACTERSCREEN);
         //Write static byte 10
         writer.Byte(0x10);
         //Write succes byte 1
         writer.Byte(1);
         //Send bytes to client
         client.Send(writer.GetBytes());
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write error information to the console
         Console.WriteLine("Job selection error {0}", ex);
         //Write error to debug log file
         Systems.Debugger.Write(ex);
     }
 }
예제 #6
0
        void GuildPermissions()
        {
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Skip first
                Reader.Skip(1);
                //Read member id
                int memberid = Reader.Int32();
                //Read permission byte
                byte permissions = (byte)Reader.Int32();
                //Set new char bits 8
                char[] bits = new char[8];
                //Repeat for each 8 bits
                for (int i = 0; i < 8; ++i) bits[i] = (char)0;
                //Convert bits to string / to char array
                bits = Convert.ToString(permissions, 2).ToCharArray();
                //Close reader
                Reader.Close();
                //Set amount to player targetindex
                int targetindex = this.Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == memberid);
                //If character is online
                if (this.Character.Network.Guild.MembersInfo[targetindex].Online)
                {
                    //Get detailed player information
                    Systems member = GetPlayerMainid(memberid);
                    //Set bits
                    member.Character.Network.Guild.joinRight = bits[4] == '1' ? true : false;
                    member.Character.Network.Guild.withdrawRight = bits[3] == '1' ? true : false;
                    member.Character.Network.Guild.unionRight = bits[2] == '1' ? true : false;
                    member.Character.Network.Guild.guildstorageRight = bits[0] == '1' ? true : false;
                    member.Character.Network.Guild.noticeeditRight = bits[1] == '1' ? true : false;
                }
                // set new amount to every guild members guild class
                foreach (int m in Character.Network.Guild.Members)
                {
                    //Set int index (Find member id)
                    int index = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m);
                    //If the character is online
                    if (Character.Network.Guild.MembersInfo[index].Online)
                    {
                        //Get detailed information of the player
                        Systems sys = Systems.GetPlayerMainid(m);

                        //Set new guild player
                        Global.guild_player mygp = new Global.guild_player();
                        int myindex = 0;
                        //Repeat for each player
                        foreach (Global.guild_player gp in sys.Character.Network.Guild.MembersInfo)
                        {
                            //if the member id equals the player
                            if (gp.MemberID == memberid)
                            {
                                //Set my gp
                                mygp = gp;
                                //Set bits
                                mygp.joinRight = bits[4] == '1' ? true : false;
                                mygp.withdrawRight = bits[3] == '1' ? true : false;
                                mygp.unionRight = bits[2] == '1' ? true : false;
                                mygp.guildstorageRight = bits[0] == '1' ? true : false;
                                mygp.noticeeditRight = bits[1] == '1' ? true : false;
                                break;
                            }
                            //Index ++
                            myindex++;
                        }
                        //Set membersinfo index as mygp
                        sys.Character.Network.Guild.MembersInfo[myindex] = mygp;
                    }
                }
                //Update guild database information rights
                MsSQL.UpdateData("UPDATE guild_members SET guild_perm_join='" + bits[4] + "',guild_perm_withdraw='" + bits[3] + "',guild_perm_union='" + bits[2] + "',guild_perm_storage='" + bits[0] + "',guild_perm_notice='" + bits[1] + "' WHERE guild_member_id='" + memberid + "'");
                //Send to everyone in guild update of permissions
                Character.Network.Guild.Send(Packet.GuildUpdate(Character, 4, 0, permissions, 0));
            }
            //If an error happens
            catch (Exception ex)
            {
                //Write the information to the console
                Console.WriteLine("Guild permission error: {0}", ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
예제 #7
0
        void ActionMain()
        {
            try
            {
                if (Character.State.Die || Character.Information.Scroll || Character.Action.Cast)
                    return;

                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Read main action type
                byte type = Reader.Byte();
                //If attack action byte is not equal to 2
                if (type != 2)
                {
                    //Read player action byte
                    byte PlayerAction = Reader.Byte();
                    //Create switch on player actions
                    switch (PlayerAction)
                    {
                        //Normal attacking
                        case 1:
                            //If character is allready using normal attack
                            if (Character.Action.nAttack)
                            {
                                //Return
                                return;
                            }
                            //If the character is riding a horse
                            if (Character.Transport.Right)
                            {
                                //Return, because character cannot attack while riding a horse.
                                return;
                            }
                            //If the character is picking up a item
                            if (Character.Action.PickUping)
                            {
                                //Stop pick up timer
                                StopPickUpTimer();
                            }
                            //Skip non needed byte
                            Reader.Skip(1);
                            //Read integer target id (DWORD).
                            int TargetID = Reader.Int32();
                            //Close packet reader
                            Reader.Close();
                            //Set target id for usage later in attacking.
                            Character.Action.Object = GetObjects(TargetID);
                            //Set bool normal attack to true
                            Character.Action.nAttack = true;
                            //Set character target id
                            Character.Action.Target = TargetID;
                            //Start attacking
                            StartAttackTimer(1425);
                            break;
                        case 2://pickup
                            if (Character.Action.nAttack) return;
                            if (Character.Action.sAttack) return;
                            if (Character.Action.sCasting) return;
                            if (Character.Action.PickUping) return;

                            Reader.Byte();
                            int id2 = Reader.Int32();
                            Reader.Close();

                            Character.Action.Target = id2;
                            Character.Action.PickUping = true;
                            StartPickupTimer(600);
                            break;
                        case 3://trace
                            if (Character.Action.sAttack) return;
                            if (Character.Action.sCasting) return;
                            if (Character.State.Sitting) return;
                            if (Character.Stall.Stallactive) return;

                            Reader.Byte();
                            int id3 = Reader.Int32();
                            Character.Action.Target = id3;
                            Reader.Close();
                            client.Send(Packet.ActionState(1, 1));
                            Character.Action.PickUping = false;
                            Player_Trace(id3);
                            break;
                        case 4://use skill
                            Character.Action.UsingSkillID = Reader.Int32();
                            SkillMain(Reader.Byte(), Reader);
                            break;
                        case 5:
                            int id4 = Reader.Int32();
                            byte b_index = SkillGetBuffIndex(id4);
                            SkillBuffEnd(b_index);
                            break;
                        default:
                            Console.WriteLine("ActionMain case: " + Reader.Byte());
                            break;
                    }
                }

                else
                    StopAttackTimer();
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
예제 #8
0
 public static void PlayerQuickBar(PacketReader Reader, PacketWriter Writer)
 {
     byte amm = 0;
     int[] skillid = new int[51];
     byte[] slotn = new byte[51];
     for (byte i = 0; i <= 50; i++)
     {
         slotn[i] = Reader.Byte();
         if (slotn[i] != 0)
         {
             skillid[i] = Reader.Int32();
             amm++;
         }
         else Reader.Skip(4);
     }
     Writer.Byte(amm);
     for (byte i = 0; i <= 50; i++)
     {
         if (slotn[i] != 0)
         {
             Writer.Byte(i);
             Writer.Byte(slotn[i]);
             Writer.DWord(skillid[i]);
         }
     }
     Reader.Close();
 }
예제 #9
0
파일: Alchemy.cs 프로젝트: CarlosX/DarkEmu
        /////////////////////////////////////////////////////////////////////////////////
        // Item reinforce with stones
        /////////////////////////////////////////////////////////////////////////////////
        public void AlchemyStoneMain()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                Character.Alchemy.ItemList = new List<Global.slotItem>();
                byte type = Reader.Byte();
                if (type == 1)
                {
                    try
                    {
                        this.Character.Alchemy.AlchemyThread.Abort();
                        this.client.Send(Packet.AlchemyCancel());
                    }
                    catch (Exception ex)
                    {
                        Systems.Debugger.Write(ex);
                    }
                }
                else if (type == 2)
                {
                    Reader.Skip(1);
                    byte numitem = Reader.Byte();
                    this.Character.Alchemy.ItemList.Add(GetItem((uint)this.Character.Information.CharacterID, Reader.Byte(), 0));
                    this.Character.Alchemy.ItemList.Add(GetItem((uint)this.Character.Information.CharacterID, Reader.Byte(), 0));

                }
                Alchemy = new Timer(new TimerCallback(StartAlchemyStoneResponse), 0, 3000, 0);
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
예제 #10
0
파일: Stall.cs 프로젝트: CarlosX/DarkEmu
        public void StallMain()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                byte Type = Reader.Byte();

                //Item edit
                if (Type == 1)
                {
                    if (Character.Network.Stall.isOpened) return;
                    byte stallslot = Reader.Byte();
                    Reader.Skip(2);
                    ulong price = Reader.UInt64();
                    if (price <= 999999999)
                    {
                        int StallItemIndex = Character.Network.Stall.ItemList.FindIndex(i => (i.stallSlot == stallslot));
                        Character.Network.Stall.ItemList[StallItemIndex].price = price;

                        Character.Network.Stall.Send(Packet.StallModifyItem(stallslot, price));
                    }
                    else
                        return;
                }
                //Add an item
                else if (Type == 2)
                {
                    if (Character.Network.Stall.isOpened) return;
                    byte stallslot = Reader.Byte();
                    byte invpos = Reader.Byte();
                    short quantity = Reader.Int16();
                    ulong price = Reader.UInt64();

                    Global.slotItem uItemID = GetItem((uint)Character.Information.CharacterID, invpos, 0);

                    //Disable item mall items in stalls for now.
                    if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GLOBALCHAT ||
                        Data.ItemBase[uItemID.ID].Type == Global.item_database.ArmorType.AVATAR ||
                        Data.ItemBase[uItemID.ID].Type == Global.item_database.ArmorType.AVATARHAT ||
                        Data.ItemBase[uItemID.ID].Type == Global.item_database.ArmorType.AVATARATTACH
                        ) return;

                    if (quantity <= Data.ItemBase[uItemID.ID].Max_Stack)
                    {
                        stall.stallItem StallItem = new stall.stallItem();
                        LoadBluesid(uItemID.dbID);
                        StallItem.stallSlot = stallslot;
                        StallItem.price = price;
                        StallItem.Item = (GetItem((uint)Character.Information.CharacterID, invpos, 0));

                        if (Character.Network.Stall.ItemList.Exists((get => get.Item.dbID == StallItem.Item.dbID))) return;

                        Character.Network.Stall.ItemList.Add(StallItem);
                        Character.Network.Stall.Send(Packet.StallItemMain(Character.Network.Stall.ItemList));
                    }
                    else
                        return;
                }
                //Item pulling out
                else if (Type == 3)
                {
                        if (Character.Network.Stall.isOpened) return;
                        byte stallslot = Reader.Byte();

                        //remove stallItem from stall
                        Character.Network.Stall.ItemList.Remove(Character.Network.Stall.ItemList.Find(i => (i.stallSlot == stallslot)));
                        Character.Network.Stall.Send(Packet.StallItemMain(Character.Network.Stall.ItemList));
                }
                //Stall modify state
                else if (Type == 5)
                {
                    byte State = Reader.Byte();
                    Character.Network.Stall.isOpened = (State == 1) ? true : false;

                    Character.Network.Stall.Send(Packet.StallSetState(State));
                }
                //Set Welcome msg
                else if (Type == 6)
                {
                    if (Character.Network.Stall.isOpened) return;
                    short length = Reader.Int16();
                    Character.Network.Stall.WelcomeMsg = Reader.Text3();
                    //Console.WriteLine("New Welcome msg:" + welcome);
                    Character.Network.Stall.Send(Packet.StallWelcome(Character.Network.Stall.WelcomeMsg));
                }
                //Set StallName
                else if (Type == 7)
                {
                    string stallname = Reader.Text3();
                    Send(Packet.StallNameGlobal(Character.Information.UniqueID, stallname));
                    Character.Network.Stall.Send(Packet.StallName(stallname));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Additem Stall error: {0}", ex);
            }
        }