|
You last visited: Today at 19:18
Advertisement
A Little Help
Discussion on A Little Help within the SRO Coding Corner forum part of the Silkroad Online category.
07/01/2011, 12:23
|
#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
|
|
|
07/01/2011, 13:36
|
#2
|
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();
|
|
|
07/01/2011, 13:44
|
#3
|
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
|
Quote:
Originally Posted by kevin_owner
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 ?
|
|
|
07/01/2011, 15:38
|
#4
|
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.
|
|
|
07/01/2011, 15:47
|
#5
|
elite*gold: 0
Join Date: May 2009
Posts: 19
Received Thanks: 2
|
:s
|
|
|
07/01/2011, 16:04
|
#6
|
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?
|
|
|
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 ^^
|
|
|
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
|
|
|
07/01/2011, 18:10
|
#9
|
elite*gold: 0
Join Date: Jan 2009
Posts: 575
Received Thanks: 752
|
Quote:
Originally Posted by lvszoc
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.
|
|
|
07/01/2011, 18:13
|
#10
|
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
|
System.Single == float.
Also, use the var keyword.
|
|
|
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
|
|
|
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
|
|
|
07/08/2011, 18:04
|
#13
|
elite*gold: 166
Join Date: Apr 2009
Posts: 2,339
Received Thanks: 2,661
|
Quote:
Originally Posted by lvszoc
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)))))
|
|
|
All times are GMT +1. The time now is 19:18.
|
|