Register for your free account! | Forgot your password?

You last visited: Today at 19:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



A Little Help

Discussion on A Little Help within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
A Little Help

Hi,

I have some data from walk packet...
Walk Packet Parse Code
Code:
oku.ReadByte();
byte xSector = oku.ReadByte();
byte ySector = oku.ReadByte();
float x = oku.ReadInt16();
float z = oku.ReadInt16();
float y = oku.ReadInt16();

int gameX, gameY;
gameX = (int)Formula.CalculateX(x, xSector);
gameY = (int)Formula.CalculateY(y, ySector);
It Shows
Code:
xSec: 168
ySec: 96
x: 731
z: -14
y: 1090

Coords: 6409:876
I have some data from 0x3013 Packet From elite silkroad
Code:
Character.Position.xSector = oku.ReadByte();
Character.Position.ySector = oku.ReadByte();
float x = oku.ReadInt16();
float z = oku.ReadInt16();
float y = oku.ReadInt16();
Character.Position.x = (int)Formula.CalculateX(x, Character.Position.xSector);
Character.Position.y = (int)Formula.CalculateY(y, Character.Position.ySector);
But it gives
Code:
xSec: 168
ySec: 96
x: -16384
z: 17462
y: 22168
I can't find wrong section... help pls
lvszoc is offline  
Old 07/01/2011, 13:36   #2
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
Play arround a bit with those values. mabye it's a float and is the packet length the same for elite sro?
cause if the packet is bigger you can take a look at the difference in the bytes if the elite sro packet is 6 bytes longer than the values should be read as a float.

btw I don't know if it matters but:
Code:
float x = oku.ReadInt16();
float z = oku.ReadInt16();
float y = oku.ReadInt16();

shouldn't this be 

short x = oku.ReadInt16();
short z = oku.ReadInt16();
short y = oku.ReadInt16();
kevin_owner is offline  
Old 07/01/2011, 13:44   #3
 
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
Quote:
Originally Posted by kevin_owner View Post
Play arround a bit with those values. mabye it's a float and is the packet length the same for elite sro?
cause if the packet is bigger you can take a look at the difference in the bytes if the elite sro packet is 6 bytes longer than the values should be read as a float.

btw I don't know if it matters but:
Code:
float x = oku.ReadInt16();
float z = oku.ReadInt16();
float y = oku.ReadInt16();

shouldn't this be 

short x = oku.ReadInt16();
short z = oku.ReadInt16();
short y = oku.ReadInt16();
but walk packet
Code:
oku.ReadByte();
                            byte xSector = oku.ReadByte();
                            byte ySector = oku.ReadByte();
                            float x = oku.ReadInt16();
                            float z = oku.ReadInt16();
                            float y = oku.ReadInt16();

                            int gameX, gameY;
                            gameX = (int)Formula.CalculateX(x, xSector);
                            gameY = (int)Formula.CalculateY(y, ySector);
in elitesilkroad, too... why this evaluates true and 3013 evals false ?
lvszoc is offline  
Old 07/01/2011, 15:38   #4
 
bootdisk's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 134
Received Thanks: 41
because what Kevin said was that on 3013 is not a 16bit integer (2 bytes) it's a float, you should read 4 bytes (which is 32bits) as float. So for 3013's pos you should change those:

Code:
float x = oku.ReadInt16();
float z = oku.ReadInt16();
float y = oku.ReadInt16();
for:

Code:
float x = oku.ReadFloat();
float z = oku.ReadFloat();
float y = oku.ReadFloat();
Your walkpacket is Ok as each component is a 16bit value.
bootdisk is offline  
Old 07/01/2011, 15:47   #5
 
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2


:s
lvszoc is offline  
Old 07/01/2011, 16:04   #6
 
bootdisk's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 134
Received Thanks: 41
A float is not an uint although both uses 32bits, do you have a way to read floats?
bootdisk is offline  
Old 07/01/2011, 16:12   #7
 
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
err, no ^^
i use packetreader in SilkroadSecurityApi ^^
lvszoc is offline  
Old 07/01/2011, 16:14   #8
 
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
i try
Code:
 byte xSec = oku.ReadByte();
                byte ySec = oku.ReadByte();
                float x = oku.ReadSingle();
                float z = oku.ReadSingle();
                float y = oku.ReadSingle();
and it gives -25920:7488 but my coordinates 6441:846
lvszoc is offline  
Old 07/01/2011, 18:10   #9
 
zeteris's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 575
Received Thanks: 752
Quote:
Originally Posted by lvszoc View Post
i try
Code:
 byte xSec = oku.ReadByte();
                byte ySec = oku.ReadByte();
                float x = oku.ReadSingle();
                float z = oku.ReadSingle();
                float y = oku.ReadSingle();
and it gives -25920:7488 but my coordinates 6441:846
Use ushort on [B021] and float on [3013]. And it should work.
zeteris is offline  
Old 07/01/2011, 18:13   #10
 
lesderid's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
System.Single == float.

Also, use the var keyword.
lesderid is offline  
Old 07/01/2011, 18:21   #11
 
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
0x3013
Code:
public void parseCharData(Packet p)
        {
            try 
            {
                PacketReader oku = new PacketReader(p.GetBytes());
                oku.ReadInt32();
                oku.ReadInt32();//Type
                oku.ReadByte();//Volume
                byte level = oku.ReadByte();//Level
                labelCharName.Text += " Level: " + level;
                oku.ReadByte();
                long exp = oku.ReadInt64();//Exp
                exProgressBar.Maximum = (int)Character.level[level - 1].exp;
                exProgressBar.Value = (int)exp;
                int sexp = oku.ReadInt32();//sexp
                long gold = oku.ReadInt64();//gold
                labelGold.Text = gold.ToString();
                int sp = oku.ReadInt32();//sp
                labelSp.Text = sp.ToString();
                oku.ReadInt16();//attr
                oku.ReadByte();//Berserker
                oku.ReadBytes(4);//?
                Character.Info.currentHP =  oku.ReadInt32();//Hp
                Character.Info.currentMP = oku.ReadInt32();//mp

                oku.ReadByte();//NoobIcon
                oku.ReadByte();//DailyPk
                oku.ReadInt16();//pklevel
                oku.ReadInt32();//MurderLevel
                oku.ReadByte();
                oku.ReadByte();//MaxSlot

                try
                {
                    byte itemCount = oku.ReadByte();
                    for (int i = 0; i < itemCount; i++)
                    {
                        byte itemSlot = oku.ReadByte();
                        UInt32 itemID = oku.ReadUInt32();
                        string itemType = Character.FindItemType(itemID);
                        if (itemType.StartsWith("SN_ITEM_EU") || itemType.StartsWith("SN_ITEM_CH"))
                        {
                            byte plus = oku.ReadByte();
                            oku.ReadInt64();
                            UInt32 durability = oku.ReadUInt32();
                            byte blueCount = oku.ReadByte();
                            for (int blue = 0; blue < blueCount; blue++)
                            {
                                UInt32 blueId = oku.ReadUInt32();
                                UInt32 blueValue = oku.ReadUInt32();
                            }
                            log_yaz("Item: " + itemType + " Plus: " + plus);
                        }
                        else
                        {
                            UInt16 quant = oku.ReadUInt16();
                            log_yaz("Item: " + itemType + " Quantity: " + quant);
                        }
                    }
                }
                catch { }

                /*Masteries*/
                oku.ReadBytes(3);
                masteries.Items.Clear();
                while (oku.ReadByte() == 1)
                {
                    UInt32 masteryID = oku.ReadUInt32();
                    byte masteryLevel = oku.ReadByte();
                    ListViewItem mastery = new ListViewItem();
                    mastery.Text = masteryID.ToString();
                    mastery.SubItems.Add(masteryLevel.ToString());
                    masteries.Items.Add(mastery);
                }

                /*Skills*/
                oku.ReadBytes(1);
                while (oku.ReadByte() == 1)
                {
                    UInt32 skillID = oku.ReadUInt32();
                    oku.ReadByte();
                    log_yaz("Skill: " + skillID);
                }

                oku.ReadBytes(9);
                uint playerid = oku.ReadUInt32();

                byte xSec = oku.ReadByte();
                byte ySec = oku.ReadByte();
                float x = oku.ReadSingle();
                float z = oku.ReadSingle();
                float y = oku.ReadSingle();

                log_yaz(Formula.CalculateX(x, xSec) + ":" + Formula.CalculateY(y, ySec));
            }
            catch { }
        }
I can't :S
lvszoc is offline  
Old 07/01/2011, 23:32   #12
 
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
i have some code from server side (arcane)
Code:
Writer.Byte(c.Position.xSec);
            Writer.Byte(c.Position.ySec);
            Writer.Float(Function.Formule.packetx(c.Position.x, c.Position.xSec));
            Writer.Float(c.Position.z);
            Writer.Float(Function.Formule.packety(c.Position.y, c.Position.ySec));

public static float packetx(float x, byte sector)
        {
            return ((x - ((sector) - 135) * 192) * 10);
        }
        public static float packety(float y, byte sector)
        {
            return ((y - ((sector) - 92) * 192) * 10);
        }
Maybe my formula is wrong, how does packetx -> in-game x
lvszoc is offline  
Old 07/08/2011, 18:04   #13

 
sarkoplata's Avatar
 
elite*gold: 166
Join Date: Apr 2009
Posts: 2,339
Received Thanks: 2,661
Quote:
Originally Posted by lvszoc View Post
i have some code from server side (arcane)
Code:
Writer.Byte(c.Position.xSec);
            Writer.Byte(c.Position.ySec);
            Writer.Float(Function.Formule.packetx(c.Position.x, c.Position.xSec));
            Writer.Float(c.Position.z);
            Writer.Float(Function.Formule.packety(c.Position.y, c.Position.ySec));

public static float packetx(float x, byte sector)
        {
            return ((x - ((sector) - 135) * 192) * 10);
        }
        public static float packety(float y, byte sector)
        {
            return ((y - ((sector) - 92) * 192) * 10);
        }
Maybe my formula is wrong, how does packetx -> in-game x
CInt(Math.Round(CDbl((((xsec - &H87) * &HC0) + (CDbl(xpos) / 10)))))
sarkoplata is offline  
Reply




All times are GMT +1. The time now is 19:18.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.