|
You last visited: Today at 09:59
Advertisement
Error While parsing a Spawn Packet
Discussion on Error While parsing a Spawn Packet within the SRO Coding Corner forum part of the Silkroad Online category.
05/08/2018, 00:18
|
#1
|
elite*gold: 53
Join Date: Sep 2014
Posts: 308
Received Thanks: 86
|
Error While parsing a Spawn Packet
While i'm parsing a spawn packets i got some erros i didn't knew why it come Although it working fine in another program which i extracted the code from it
Full code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SilkroadSecurityApi;
using System.Threading;
using System.Drawing;
#pragma warning disable
namespace UnixEvents
{
class CharSpawn
{
public static Packet CharPacket;
public static byte[] skip_charid;
public struct CAVE_
{
public bool char_incave;
public byte xsector;
public float zcoord;
public float xcoord;
}
public static CAVE_ cave = new CAVE_();
public static List<string> explist = new List<string>();
public static int Level;
public static int maxLevel;
public static ulong exp;
public static ulong expmax;
public static ulong Gold;
public static uint SkillPoints;
public static uint AvailableStatPoints;
public static byte Zerk;
public static uint CurrentHP;
public static uint CurrentMP;
public static byte itemscount;
public static byte inventoryslot;
public static byte questspending;
public static ushort questscompleted;
public static uint ID;
public static uint AccountID;
public static int X;
public static int Y;
public static string PlayerName;
public static string guildName;
public static ushort STR;
public static ushort INT;
public static uint MaxHP;
public static uint MaxMP;
public static uint some;
public static uint model;
public static byte volh;
public static float speed;
public static byte data_loaded = 0;
public static bool groupspawnIsSpawn = false;
public static int spawnAmount = 0;
public static bool groupspawn = false;
public static void parseSpawn(Packet packet)
{
try
{
CharStrings.GlobalsTypeSlot.Clear();
#region Main
CharSpawn.some = packet.ReadUInt32(); // ServerTime
CharSpawn.model = packet.ReadUInt32(); //Model
CharSpawn.volh = packet.ReadUInt8(); //Volume and Height - scale -
CharStrings.Level = packet.ReadUInt8(); // CurLevel
CharStrings.MaxLevel = packet.ReadUInt8(); //MaxLevel
int maxlvl = (int)CharStrings.Level - 1;
CharStrings.Exp = packet.ReadUInt64(); // ExpOffset
packet.ReadUInt32(); //SP bar SExpOffset
CharStrings.Gold = packet.ReadUInt64(); //RemainGold
CharStrings.SkillPoints = packet.ReadUInt32(); //RemainSkillPoint
CharStrings.StatPoints = packet.ReadUInt16(); //RemainStatPoint
packet.ReadUInt8();//Zerk?!! RemainHwanCount
packet.ReadUInt32(); // GatheredExpPoint
CharStrings.CurrentHP = packet.ReadUInt32();
CharStrings.CurrentMP = packet.ReadUInt32();
packet.ReadUInt8(); //AutoInverstExp
packet.ReadUInt8(); //DailyPK
packet.ReadUInt16(); //TotalPK
packet.ReadUInt32(); //PKPenaltyPoint
packet.ReadUInt8(); //HwanLevel
packet.ReadUInt8(); //FreePVP //0 = None, 1 = Red, 2 = Gray, 3 = Blue, 4 = White, 5 = Gold
#endregion
#region Items
CharSpawn.inventoryslot = packet.ReadUInt8(); // Inventory.Size
CharSpawn.itemscount = packet.ReadUInt8(); // Inventory.ItemCount
for (int y = 0; y < CharSpawn.itemscount; y++)
{
byte slot = packet.ReadUInt8(); // item.Slot
uint RentType = packet.ReadUInt32(); // item.RentType
/* if (RentType == 1)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt32(); // item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
}
else if (RentType == 2)
{
packet.ReadUInt16(); // item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.MeterRateTime
}
else if (RentType == 3)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
packet.ReadUInt32(); //item.RentInfo.PackingTime
}*/
uint item_id = packet.ReadUInt32();
int index = Items_Info.itemsidlist.IndexOf(item_id);
if (index > -1)
{
string type = Items_Info.itemstypelist[index];
string name = Items_Info.itemsnamelist[index];
//Console.WriteLine("ID " + item_id + " |Type : " + type + " |Name : " + name + " |Slot : " + slot); Char Items
CharStrings.inventoryslot.Add(slot);
CharStrings.inventorytype.Add(type);
CharStrings.inventoryid.Add(item_id);
//Program.f1.inventory_list.Items.Add(name);
// Console.WriteLine("______________ Current Type : " + type); Current Type Search
if (type.StartsWith("ITEM_CH") || type.StartsWith("ITEM_ROC_CH") || type.StartsWith("ITEM_ROC_EU") || type.StartsWith("ITEM_EU") || type.StartsWith("ITEM_MALL_AVATAR") || type.StartsWith("ITEM_ETC_E060529_GOLDDRAGONFLAG") || type.StartsWith("ITEM_EVENT_CH") || type.StartsWith("ITEM_EVENT_EU") || type.StartsWith("ITEM_EVENT_AVATAR_W_NASRUN") || type.StartsWith("ITEM_EVENT_AVATAR_M_NASRUN"))
{
byte item_plus = packet.ReadUInt8();
packet.ReadUInt64();
CharStrings.inventorydurability.Add(packet.ReadUInt32());
byte blueamm = packet.ReadUInt8();
for (int i = 0; i < blueamm; i++)
{
packet.ReadUInt32();
packet.ReadUInt32();
}
packet.ReadUInt8(); //Unknwon
packet.ReadUInt8(); //Unknwon
packet.ReadUInt8(); //Unknwon
byte flag1 = packet.ReadUInt8(); // Flag ?
if (flag1 == 1)
{
packet.ReadUInt8(); //Unknown
packet.ReadUInt32(); // Unknown ID ? ADV Elexir ID ?
packet.ReadUInt32(); // Unknwon Count
}
CharStrings.inventorycount.Add(1);
}
else if ((type.StartsWith("ITEM_COS") && type.Contains("SILK")) || (type.StartsWith("ITEM_EVENT_COS") && !type.Contains("_C_")))
{
// orginial mn 8er De wala Else
if (GlobalControl.Types.grabpet_spawn_types.IndexOf(type) != -1 || GlobalControl.Types.attack_spawn_types.IndexOf(type) != -1)
{
byte flag = packet.ReadUInt8();
if (flag == 2 || flag == 3 || flag == 4)
{
packet.ReadUInt32(); //Model
packet.ReadAscii();
if (GlobalControl.Types.attack_spawn_types.IndexOf(type) == -1)
{
packet.ReadUInt32();
}
packet.ReadUInt8();
}
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
else
{
byte flag = packet.ReadUInt8();
if (flag == 2 || flag == 3 || flag == 4)
{
packet.ReadUInt32(); //Model
packet.ReadAscii();
packet.ReadUInt8();
if (GlobalControl.Types.attack_spawn_types.IndexOf(type) == -1)
{
packet.ReadUInt32();
}
}
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
}
else if (type == "ITEM_ETC_TRANS_MONSTER")
{
packet.ReadUInt32();
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
else if (type.StartsWith("ITEM_MALL_MAGIC_CUBE")) //
{
packet.ReadUInt32();
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
else
{
ushort count = packet.ReadUInt16();
if (type.Contains("ITEM_ETC_ARCHEMY_ATTRSTONE")) // || type.Contains("ITEM_ETC_ARCHEMY_MAGICSTONE"))
{
packet.ReadUInt8();
}
CharStrings.inventorycount.Add(count);
if (type == "ITEM_EVENT_RENT_GLOBAL_CHATTING")
{
CharStrings.GlobalsTypeSlot.Add(type + "," + count + "," + slot);
}
CharStrings.inventorydurability.Add(0);
}
}
}
if (CharStrings.GlobalsTypeSlot.Count > 0)
{
foreach (string TTType in CharStrings.GlobalsTypeSlot) // Loop through List with foreach.
{
Program.UpdateLogs("Inventory Globals : " + TTType,Color.Red);
}
}
else
{
Program.UpdateLogs("Warrning : Bot Charachter Dosent Have ITEM_EVENT_RENT_GLOBAL_CHATTING", Color.Red);
Program.UpdateLogs(Items_Info.itemsidlist.Count().ToString(),Color.Red);
// ConnTestConsole.Program.AutoRefill();
}
/*foreach (string TTType in CharStrings.GlobalsTypeSlot) // Loop through List with foreach.
{
Console.WriteLine("Laaaast : " + TTType);
}*/
//ItemsCount.CountManager();
#endregion
#region Avatars
packet.ReadUInt8(); // AvatarInventory.Size
int avatarcount = packet.ReadUInt8(); // AvatarInventory.ItemCount
for (int i = 0; i < avatarcount; i++)
{
packet.ReadUInt8(); //Slot
uint AvatarRentType = packet.ReadUInt32(); // item.RentType
int index = Items_Info.itemsidlist.IndexOf(AvatarRentType);
if (index > -1)
{
string type = Items_Info.itemstypelist[index];
}
/*if (AvatarRentType == 1)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt32(); //item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
}
else if (AvatarRentType == 2)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.MeterRateTime
}
else if (AvatarRentType == 3)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
packet.ReadUInt32(); // item.RentInfo.PackingTime
}*/
byte item_plus = packet.ReadUInt8();
packet.ReadUInt64();
packet.ReadUInt32();
byte blueamm = packet.ReadUInt8();
for (int a = 0; a < blueamm; a++)
{
packet.ReadUInt32();
packet.ReadUInt32();
}
packet.ReadUInt32();
}
#endregion
packet.ReadUInt8(); //Avatars End
packet.ReadUInt8();//
packet.ReadUInt8();//Unknown
packet.ReadUInt8();//
int mastery = packet.ReadUInt8(); // Mastery Start
while (mastery == 1)
{
packet.ReadUInt32(); // Mastery ID
packet.ReadUInt8(); // Mastery LV
mastery = packet.ReadUInt8(); // New Mastery Start / List End
}
packet.ReadUInt8(); // Mastery END
uint skilllist = packet.ReadUInt8(); // Skill List Start
//MessageBox.Show("" + skilllist);
while (skilllist == 1)
{
uint skillid = packet.ReadUInt32(); // Skill ID
packet.ReadUInt8();
skilllist = packet.ReadUInt8(); // New Skill Start / List End
Program.UpdateLogs(" __ HEre " + skilllist,Color.Red);
// Char.addSkill(skillid);
}
#region Skipping Quest Part
Packet charid = new Packet(3020);
charid.WriteUInt32(CharStrings.UniqueID);
charid.Lock();
byte idpart1 = charid.ReadUInt8();
byte idpart2 = charid.ReadUInt8();
byte idpart3 = charid.ReadUInt8();
byte idpart4 = charid.ReadUInt8();
while (true)
{
if (packet.ReadUInt8() == idpart1)
{
if (packet.ReadUInt8() == idpart2)
{
if (packet.ReadUInt8() == idpart3)
{
if (packet.ReadUInt8() == idpart4)
{
break;
}
}
}
}
}
#endregion
//CharSpawn.ID = packet.ReadUInt32();
byte xsec = packet.ReadUInt8();
byte ysec = packet.ReadUInt8();
float xcoord = packet.ReadSingle();
float zcoord = packet.ReadSingle();
float ycoord = packet.ReadSingle();
//MessageBox.Show(xsec + " | " + ysec + " ||| " + xcoord + " " + ycoord + " " + zcoord);
/*if (positionTools.InCave(ysec))
{
cave.char_incave = true;
cave.xsector = xsec;
cave.zcoord = zcoord;
cave.xcoord = xcoord;
}
else
{
cave.char_incave = false;
}*/
//CoordXY ingameCoords = ConvertCoord.toGame(xsec, ysec, (uint)xcoord, (uint)ycoord);
//positionTools.setPosition(ingameCoords.x, ingameCoords.y);
//MessageBox.Show(xsec + " | " + ysec + " ||| " + xcoord + " " + ycoord + " " + zcoord + Environment.NewLine + ingameCoords.x + " | " + ingameCoords.y);
packet.ReadUInt16(); // Position
int move = packet.ReadUInt8(); // Move ?? Maybie Useless
packet.ReadUInt8(); // Run
packet.ReadUInt8();
packet.ReadUInt16();
packet.ReadUInt8();
packet.ReadUInt8(); //DeathFlag
packet.ReadUInt8(); //Movement Flag
packet.ReadUInt8(); //Berserker Flag
//Char.WalkSpeed = packet.ReadUInt32(); //Walking Speed
//Char.RunSpeed = packet.ReadUInt32(); //Running Speed
CharStrings.WalkSpeed = packet.ReadSingle() * 1.1f; //Walking Speed
CharStrings.RunSpeed = packet.ReadSingle() * 1.1f; //Running Speed
CharStrings.ZerkSpeed = packet.ReadUInt32() * 1.1f; //Berserker Speed
packet.ReadUInt8();
//packet.ReadUInt16();
CharStrings.PlayerName = packet.ReadAscii();
Program.UpdateLogs(CharStrings.PlayerName, Color.Red);
//string alias = packet.ReadAscii(); // ALIAS
}
catch (Exception ex)
{
Program.UpdateLogs("Error Parsing CharSpawn Packet" + ex.Message ,Color.Red);
}
}
public static void START_ParseChar(Packet packet)
{
//BIONIC:
// CHARACTER
// NPC
// NPC_FORTRESS_STRUCT
// NPC_MOB
// NPC_COS
// NPC_FORTRESS_COS
try
{
uint model = packet.ReadUInt32();
//Console.WriteLine(" the Unique ID : " + model.ToString());
int index = Mobs_Info.mobsidlist.IndexOf(model);
if (index != -1)
{
if (Mobs_Info.mobstypelist[index].StartsWith("CHAR"))
{
//CharSpawn.ParseChar(packet, index);
Thread t = new Thread(() => ParseChar(packet, index));
t.Start();
}
}
}
catch
{
}
}
public static void ParseChar(Packet packet, int index) // 3015 single spawn
{
string name = string.Empty;
uint UniqueID = 0;
try
{
int trade = 0;
int stall = 0;
packet.ReadUInt8(); // Volume/Height scale
packet.ReadUInt8(); // HwanLevel
packet.ReadUInt8(); //PVPCape //0 = None, 1 = Red, 2 = Gray, 3 = Blue, 4 = White, 5 = Orange
packet.ReadUInt8(); // AutoInverstExp //1 = Beginner Icon, 2 = Helpful, 3 = Beginner & Helpful
packet.ReadUInt8(); // Max Slots Inventory.Size
int items_count = packet.ReadUInt8(); //Inventory.ItemCount
for (int a = 0; a < items_count; a++)
{
uint itemid = packet.ReadUInt32(); //item.RefItemID
/*if (itemid >= 80000 && itemid <= 80504) // edits for bypass For Choas
{
byte plus = packet.ReadUInt8(); // Item Plus
//Console.WriteLine("Bypass item Done");
}
else
{*/
int itemindex = Items_Info.itemsidlist.IndexOf(itemid);
if (Items_Info.itemstypelist[itemindex].StartsWith("ITEM_CH") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_EU") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_FORT") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_ROC_CH") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_ROC_EU"))
{
byte plus = packet.ReadUInt8(); // Item Plus
}
if (Items_Info.itemstypelist[itemindex].StartsWith("ITEM_EU_M_TRADE") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_EU_F_TRADE") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_CH_M_TRADE") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_CH_W_TRADE"))
{
trade = 1;
}
//}
}
packet.ReadUInt8(); // Max Avatars Slot Inventory.Size
int avatar_count = packet.ReadUInt8(); //Inventory.ItemCount
for (int a = 0; a < avatar_count; a++)
{
uint avatarid = packet.ReadUInt32(); // item.RefItemID
int avatarindex = Items_Info.itemsidlist.IndexOf(avatarid);
byte plus = packet.ReadUInt8();// Avatar Plus
if (avatarindex == -1)
{
//Globals.UpdateLogs("Error on avatars !!! Avatar ID: " + avatarid);
}
}
int mask = packet.ReadUInt8(); //HasMask
if (mask == 1)
{
uint id = packet.ReadUInt32(); //mask.RefObjID
string type = Mobs_Info.mobstypelist[Mobs_Info.mobsidlist.IndexOf(id)];
if (type.StartsWith("CHAR"))
{
packet.ReadUInt8(); //Mask.Scale
byte count = packet.ReadUInt8(); //Mask.ItemCount
for (int i = 0; i < count; i++)
{
packet.ReadUInt32(); //item.RefItemID
}
}
}
/*
else if(obj.TypeID2 == 2 && obj.TypeID3 == 5)
{
//NPC_FORTRESS_STRUCT
4 uint HP
4 uint RefEventStructID
2 ushort State
}
* */
//uint
UniqueID = packet.ReadUInt32(); // Char Unique Spawn ID
/* //Position
ushort RegionID = packet.ReadUInt16(); //Position.RegionID
float posX = packet.ReadUInt32(); //Position.X
float posY = packet.ReadUInt32(); //Position.Y
float posZ = packet.ReadUInt32(); //Position.Z
ushort posAngle = packet.ReadUInt16(); //Position.Angle
*/
byte xsec = packet.ReadUInt8(); //Position.RegionID
byte ysec = packet.ReadUInt8();
float xcoord = packet.ReadSingle();
packet.ReadSingle();
float ycoord = packet.ReadSingle();
packet.ReadUInt16(); // Position
byte move = packet.ReadUInt8(); // Moving // Movement.HasDestination
packet.ReadUInt8(); // Running // Movement.Type
if (move == 1)
{
xsec = packet.ReadUInt8();
ysec = packet.ReadUInt8();
if (ysec == 0x80)
{
xcoord = packet.ReadUInt16() - packet.ReadUInt16();
packet.ReadUInt16();
packet.ReadUInt16();
ycoord = packet.ReadUInt16() - packet.ReadUInt16();
}
else
{
xcoord = packet.ReadUInt16();
packet.ReadUInt16();
ycoord = packet.ReadUInt16();
}
}
else
{
packet.ReadUInt8(); // No Destination
packet.ReadUInt16(); ; // Angle
}
packet.ReadUInt8(); // Alive
packet.ReadUInt8(); // Unknown
packet.ReadUInt8(); // Unknown
packet.ReadUInt8(); // Unknown
packet.ReadUInt32(); // Walking speed
packet.ReadUInt32(); // Running speed
packet.ReadUInt32(); // Berserk speed
int active_skills = packet.ReadUInt8(); // Buffs count
//Spawns.characters[s_index].buffs = new Spawns.Characters_.Buffs_[100];
//try
// {
for (int a = 0; a < active_skills; a++)
{
uint skillid = packet.ReadUInt32();
int buffindex = Skills_Info.skillsidlist.IndexOf(skillid);
//Spawns.characters[s_index].buffs[a].name = Skills_Info.skillsnamelist[Skills_Info.skillsidlist.IndexOf(skillid)];
string type = Skills_Info.skillstypelist[buffindex];
packet.ReadUInt32(); // Temp ID
if (type.StartsWith("SKILL_EU_CLERIC_RECOVERYA_GROUP") || type.StartsWith("SKILL_EU_BARD_BATTLAA_GUARD") || type.StartsWith("SKILL_EU_BARD_DANCEA") || type.StartsWith("SKILL_EU_BARD_SPEEDUPA_HITRATE"))
{
packet.ReadUInt8();
}
}
/* }
catch
{
Console.WriteLine("Unknown Parsing Skill");
}*/
// string
name = packet.ReadAscii();
Console.ForegroundColor = ConsoleColor.DarkCyan;
Program.UpdateLogs("Player Arround Unique ID: " + UniqueID + " Player Name: " + name,Color.Red);
Console.ForegroundColor = ConsoleColor.Gray;
//Everything.CharStrings.CharNameANDuniqueID.Add(name + "," + UniqueID.ToString());
for (int i = 0; i < CharStrings.CharNameANDuniqueID.Count; i++) // Loop through List with foreach.
{
if (CharStrings.CharNameANDuniqueID[i].StartsWith(name))
{
int AlreadyIndex = CharStrings.CharNameANDuniqueID.IndexOf(CharStrings.CharNameANDuniqueID[i]);
CharStrings.CharNameANDuniqueID.RemoveAt(AlreadyIndex);
}
}
CharStrings.CharNameANDuniqueID.Add(name + "," + UniqueID.ToString());
/*//Spawns.characters[s_index].charname = name;
packet.ReadUInt8(); // Unknown
packet.ReadUInt8(); // Job type
packet.ReadUInt8(); // Job level
int cnt = packet.ReadUInt8();
packet.ReadUInt8();
if (cnt == 1)
{
packet.ReadUInt32();
}
packet.ReadUInt8(); // Unknown
stall = packet.ReadUInt8(); // Stall flag
packet.ReadUInt8(); // Unknown
string guild = packet.ReadAscii(); // Guild
//Spawns.characters[s_index].guildname = guild;
if (trade == 1)
{
packet.ReadUInt64();
}
else
{
packet.data.ReadDWORD(); // Guild ID
packet.data.ReadSTRING(enumStringType.ASCII); // Grant Name
packet.data.ReadDWORD();
packet.data.ReadDWORD();
packet.data.ReadDWORD();
packet.data.ReadWORD();
if (stall == 4)
{
packet.data.ReadSTRING(enumStringType.ASCII);
packet.data.ReadDWORD();
packet.data.ReadWORD();
}
else
{
packet.data.ReadWORD();
}
}*/
}
catch (Exception ex)
{
Program.UpdateLogs("Error Spawn Unique ID: " + UniqueID + " Player Name: " + name + ex.Message ,Color.Red);
Program.UpdateLogs("Spawn" + ex.Message + " Count: " + packet + ex.Message, Color.Red);
}
}
public static void begin(Packet packet)
{
try
{
//Globals.sendToClient = false;
byte action = packet.ReadUInt8();
//Console.WriteLine("Action : " + action);
if (action == 1)
{
groupspawnIsSpawn = true;//spawn
}
else if (action == 2)
{
groupspawnIsSpawn = false;//despawn
}
//spawnAmount = Convert.ToInt16(packet.ReadUInt16());
spawnAmount = (int)packet.ReadUInt16();
//Console.WriteLine("Spawn Amount : " + spawnAmount);
groupspawn = true;
}
catch(Exception ex) { Program.UpdateLogs("Error Start Record Amount Of Group Spawn " + ex.Message,Color.Red); }
}
public static void end(Packet packet)
{
groupspawn = false;
//refreshMobs();
}
public static void GroupeSpawn(Packet packet)
{
try
{
/*if (groupspawnIsSpawn)//group spawn
{*/
/*for (int i = 0; i < spawnAmount; i++)
{*/
//System.Threading.Thread.Sleep(1);
#region DetectType
uint model = packet.ReadUInt32();
int index = Mobs_Info.mobsidlist.IndexOf(model);
int itemsindex = Items_Info.itemsidlist.IndexOf(model);
//MessageBox.Show(index.ToString() + itemsindex.ToString());
#endregion
if (itemsindex != -1)
{
#region ItemsParsing
//Parse.ParseItems(packet, itemsindex);
#endregion
}
if (index != -1)
{
#region PetsParsing
if (Mobs_Info.mobstypelist[index].StartsWith("COS"))
{
//Console.WriteLine("COS : " + index);
//Parse.ParsePets(packet, index);
}
#endregion
#region NPCParsing
else if (Mobs_Info.mobstypelist[index].StartsWith("NPC"))
{
//Console.WriteLine("NPC : " + index);
//Parse.ParseNPC(packet, index);
}
#endregion
#region CharParsing
else if (Mobs_Info.mobstypelist[index].StartsWith("CHAR"))
{
//Console.WriteLine("CHAR : " + index);
//ParseChar(packet, index);
// new from annoying
Thread t = new Thread(() => CharSpawn.ParseChar(packet, index));
t.Start();
}
#endregion
#region MobsParsing
else if (Mobs_Info.mobstypelist[index].StartsWith("MOB"))
{
//Console.WriteLine("MOB : " + index);
//Parse.ParseMob(packet, index);
}
#endregion
#region PortalParsing
else if (Mobs_Info.mobstypelist[index].Contains("_GATE"))
{
//Console.WriteLine("_GATE : " + index);
//Parse.ParsePortal(packet, index);
}
#endregion
#region OtherParsing
else
{
// Console.WriteLine("OtherParsing : " + index);
//Parse.ParseOther(packet, index);
}
#endregion
}
// }
// }
}
catch(Exception ex) { Program.UpdateLogs("Error Parse group Spawn" + ex.Message,Color.Red); }
}
}
}
Agent Part
Code:
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_CHARDATA:
Program.UpdateLogs("[Notify]: " + Program._Char + ": Spawned successfully !", Color.Green);
Thread t = new Thread(() => CharSpawn.parseSpawn(current));
t.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_GROUPSPAWNB:
Thread t2 = new Thread(() => CharSpawn.begin(current));
t2.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_GROUPSPAWNEND:
Thread t3 = new Thread(() => CharSpawn.end(current));
t3.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_GROUPESPAWN:
Thread t4 = new Thread(() => CharSpawn.GroupeSpawn(current));
t4.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_SINGLESPAWN:
Thread t5 = new Thread(() => CharSpawn.START_ParseChar(current));
t5.Start();
break;
Error which i got:
Error Start Record Amount Of Group Spawn Unable to read beyond the end of the stream.
Error Parse group Spawn
|
|
|
05/08/2018, 17:04
|
#2
|
elite*gold: 350
Join Date: Aug 2015
Posts: 1,999
Received Thanks: 1,184
|
i don't recall 3015/3019 having "skills,detailed inventory" of player
|
|
|
05/08/2018, 23:47
|
#3
|
elite*gold: 0
Join Date: May 2006
Posts: 667
Received Thanks: 345
|
Quote:
Originally Posted by Mr.Awesome1337
While i'm parsing a spawn packets i got some erros i didn't knew why it come Although it working fine in another program which i extracted the code from it
Full code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SilkroadSecurityApi;
using System.Threading;
using System.Drawing;
#pragma warning disable
namespace UnixEvents
{
class CharSpawn
{
public static Packet CharPacket;
public static byte[] skip_charid;
public struct CAVE_
{
public bool char_incave;
public byte xsector;
public float zcoord;
public float xcoord;
}
public static CAVE_ cave = new CAVE_();
public static List<string> explist = new List<string>();
public static int Level;
public static int maxLevel;
public static ulong exp;
public static ulong expmax;
public static ulong Gold;
public static uint SkillPoints;
public static uint AvailableStatPoints;
public static byte Zerk;
public static uint CurrentHP;
public static uint CurrentMP;
public static byte itemscount;
public static byte inventoryslot;
public static byte questspending;
public static ushort questscompleted;
public static uint ID;
public static uint AccountID;
public static int X;
public static int Y;
public static string PlayerName;
public static string guildName;
public static ushort STR;
public static ushort INT;
public static uint MaxHP;
public static uint MaxMP;
public static uint some;
public static uint model;
public static byte volh;
public static float speed;
public static byte data_loaded = 0;
public static bool groupspawnIsSpawn = false;
public static int spawnAmount = 0;
public static bool groupspawn = false;
public static void parseSpawn(Packet packet)
{
try
{
CharStrings.GlobalsTypeSlot.Clear();
#region Main
CharSpawn.some = packet.ReadUInt32(); // ServerTime
CharSpawn.model = packet.ReadUInt32(); //Model
CharSpawn.volh = packet.ReadUInt8(); //Volume and Height - scale -
CharStrings.Level = packet.ReadUInt8(); // CurLevel
CharStrings.MaxLevel = packet.ReadUInt8(); //MaxLevel
int maxlvl = (int)CharStrings.Level - 1;
CharStrings.Exp = packet.ReadUInt64(); // ExpOffset
packet.ReadUInt32(); //SP bar SExpOffset
CharStrings.Gold = packet.ReadUInt64(); //RemainGold
CharStrings.SkillPoints = packet.ReadUInt32(); //RemainSkillPoint
CharStrings.StatPoints = packet.ReadUInt16(); //RemainStatPoint
packet.ReadUInt8();//Zerk?!! RemainHwanCount
packet.ReadUInt32(); // GatheredExpPoint
CharStrings.CurrentHP = packet.ReadUInt32();
CharStrings.CurrentMP = packet.ReadUInt32();
packet.ReadUInt8(); //AutoInverstExp
packet.ReadUInt8(); //DailyPK
packet.ReadUInt16(); //TotalPK
packet.ReadUInt32(); //PKPenaltyPoint
packet.ReadUInt8(); //HwanLevel
packet.ReadUInt8(); //FreePVP //0 = None, 1 = Red, 2 = Gray, 3 = Blue, 4 = White, 5 = Gold
#endregion
#region Items
CharSpawn.inventoryslot = packet.ReadUInt8(); // Inventory.Size
CharSpawn.itemscount = packet.ReadUInt8(); // Inventory.ItemCount
for (int y = 0; y < CharSpawn.itemscount; y++)
{
byte slot = packet.ReadUInt8(); // item.Slot
uint RentType = packet.ReadUInt32(); // item.RentType
/* if (RentType == 1)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt32(); // item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
}
else if (RentType == 2)
{
packet.ReadUInt16(); // item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.MeterRateTime
}
else if (RentType == 3)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
packet.ReadUInt32(); //item.RentInfo.PackingTime
}*/
uint item_id = packet.ReadUInt32();
int index = Items_Info.itemsidlist.IndexOf(item_id);
if (index > -1)
{
string type = Items_Info.itemstypelist[index];
string name = Items_Info.itemsnamelist[index];
//Console.WriteLine("ID " + item_id + " |Type : " + type + " |Name : " + name + " |Slot : " + slot); Char Items
CharStrings.inventoryslot.Add(slot);
CharStrings.inventorytype.Add(type);
CharStrings.inventoryid.Add(item_id);
//Program.f1.inventory_list.Items.Add(name);
// Console.WriteLine("______________ Current Type : " + type); Current Type Search
if (type.StartsWith("ITEM_CH") || type.StartsWith("ITEM_ROC_CH") || type.StartsWith("ITEM_ROC_EU") || type.StartsWith("ITEM_EU") || type.StartsWith("ITEM_MALL_AVATAR") || type.StartsWith("ITEM_ETC_E060529_GOLDDRAGONFLAG") || type.StartsWith("ITEM_EVENT_CH") || type.StartsWith("ITEM_EVENT_EU") || type.StartsWith("ITEM_EVENT_AVATAR_W_NASRUN") || type.StartsWith("ITEM_EVENT_AVATAR_M_NASRUN"))
{
byte item_plus = packet.ReadUInt8();
packet.ReadUInt64();
CharStrings.inventorydurability.Add(packet.ReadUInt32());
byte blueamm = packet.ReadUInt8();
for (int i = 0; i < blueamm; i++)
{
packet.ReadUInt32();
packet.ReadUInt32();
}
packet.ReadUInt8(); //Unknwon
packet.ReadUInt8(); //Unknwon
packet.ReadUInt8(); //Unknwon
byte flag1 = packet.ReadUInt8(); // Flag ?
if (flag1 == 1)
{
packet.ReadUInt8(); //Unknown
packet.ReadUInt32(); // Unknown ID ? ADV Elexir ID ?
packet.ReadUInt32(); // Unknwon Count
}
CharStrings.inventorycount.Add(1);
}
else if ((type.StartsWith("ITEM_COS") && type.Contains("SILK")) || (type.StartsWith("ITEM_EVENT_COS") && !type.Contains("_C_")))
{
// orginial mn 8er De wala Else
if (GlobalControl.Types.grabpet_spawn_types.IndexOf(type) != -1 || GlobalControl.Types.attack_spawn_types.IndexOf(type) != -1)
{
byte flag = packet.ReadUInt8();
if (flag == 2 || flag == 3 || flag == 4)
{
packet.ReadUInt32(); //Model
packet.ReadAscii();
if (GlobalControl.Types.attack_spawn_types.IndexOf(type) == -1)
{
packet.ReadUInt32();
}
packet.ReadUInt8();
}
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
else
{
byte flag = packet.ReadUInt8();
if (flag == 2 || flag == 3 || flag == 4)
{
packet.ReadUInt32(); //Model
packet.ReadAscii();
packet.ReadUInt8();
if (GlobalControl.Types.attack_spawn_types.IndexOf(type) == -1)
{
packet.ReadUInt32();
}
}
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
}
else if (type == "ITEM_ETC_TRANS_MONSTER")
{
packet.ReadUInt32();
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
else if (type.StartsWith("ITEM_MALL_MAGIC_CUBE")) //
{
packet.ReadUInt32();
CharStrings.inventorycount.Add(1);
CharStrings.inventorydurability.Add(0);
}
else
{
ushort count = packet.ReadUInt16();
if (type.Contains("ITEM_ETC_ARCHEMY_ATTRSTONE")) // || type.Contains("ITEM_ETC_ARCHEMY_MAGICSTONE"))
{
packet.ReadUInt8();
}
CharStrings.inventorycount.Add(count);
if (type == "ITEM_EVENT_RENT_GLOBAL_CHATTING")
{
CharStrings.GlobalsTypeSlot.Add(type + "," + count + "," + slot);
}
CharStrings.inventorydurability.Add(0);
}
}
}
if (CharStrings.GlobalsTypeSlot.Count > 0)
{
foreach (string TTType in CharStrings.GlobalsTypeSlot) // Loop through List with foreach.
{
Program.UpdateLogs("Inventory Globals : " + TTType,Color.Red);
}
}
else
{
Program.UpdateLogs("Warrning : Bot Charachter Dosent Have ITEM_EVENT_RENT_GLOBAL_CHATTING", Color.Red);
Program.UpdateLogs(Items_Info.itemsidlist.Count().ToString(),Color.Red);
// ConnTestConsole.Program.AutoRefill();
}
/*foreach (string TTType in CharStrings.GlobalsTypeSlot) // Loop through List with foreach.
{
Console.WriteLine("Laaaast : " + TTType);
}*/
//ItemsCount.CountManager();
#endregion
#region Avatars
packet.ReadUInt8(); // AvatarInventory.Size
int avatarcount = packet.ReadUInt8(); // AvatarInventory.ItemCount
for (int i = 0; i < avatarcount; i++)
{
packet.ReadUInt8(); //Slot
uint AvatarRentType = packet.ReadUInt32(); // item.RentType
int index = Items_Info.itemsidlist.IndexOf(AvatarRentType);
if (index > -1)
{
string type = Items_Info.itemstypelist[index];
}
/*if (AvatarRentType == 1)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt32(); //item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
}
else if (AvatarRentType == 2)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.MeterRateTime
}
else if (AvatarRentType == 3)
{
packet.ReadUInt16(); //item.RentInfo.CanDelete
packet.ReadUInt16(); //item.RentInfo.CanRecharge
packet.ReadUInt32(); //item.RentInfo.PeriodBeginTime
packet.ReadUInt32(); //item.RentInfo.PeriodEndTime
packet.ReadUInt32(); // item.RentInfo.PackingTime
}*/
byte item_plus = packet.ReadUInt8();
packet.ReadUInt64();
packet.ReadUInt32();
byte blueamm = packet.ReadUInt8();
for (int a = 0; a < blueamm; a++)
{
packet.ReadUInt32();
packet.ReadUInt32();
}
packet.ReadUInt32();
}
#endregion
packet.ReadUInt8(); //Avatars End
packet.ReadUInt8();//
packet.ReadUInt8();//Unknown
packet.ReadUInt8();//
int mastery = packet.ReadUInt8(); // Mastery Start
while (mastery == 1)
{
packet.ReadUInt32(); // Mastery ID
packet.ReadUInt8(); // Mastery LV
mastery = packet.ReadUInt8(); // New Mastery Start / List End
}
packet.ReadUInt8(); // Mastery END
uint skilllist = packet.ReadUInt8(); // Skill List Start
//MessageBox.Show("" + skilllist);
while (skilllist == 1)
{
uint skillid = packet.ReadUInt32(); // Skill ID
packet.ReadUInt8();
skilllist = packet.ReadUInt8(); // New Skill Start / List End
Program.UpdateLogs(" __ HEre " + skilllist,Color.Red);
// Char.addSkill(skillid);
}
#region Skipping Quest Part
Packet charid = new Packet(3020);
charid.WriteUInt32(CharStrings.UniqueID);
charid.Lock();
byte idpart1 = charid.ReadUInt8();
byte idpart2 = charid.ReadUInt8();
byte idpart3 = charid.ReadUInt8();
byte idpart4 = charid.ReadUInt8();
while (true)
{
if (packet.ReadUInt8() == idpart1)
{
if (packet.ReadUInt8() == idpart2)
{
if (packet.ReadUInt8() == idpart3)
{
if (packet.ReadUInt8() == idpart4)
{
break;
}
}
}
}
}
#endregion
//CharSpawn.ID = packet.ReadUInt32();
byte xsec = packet.ReadUInt8();
byte ysec = packet.ReadUInt8();
float xcoord = packet.ReadSingle();
float zcoord = packet.ReadSingle();
float ycoord = packet.ReadSingle();
//MessageBox.Show(xsec + " | " + ysec + " ||| " + xcoord + " " + ycoord + " " + zcoord);
/*if (positionTools.InCave(ysec))
{
cave.char_incave = true;
cave.xsector = xsec;
cave.zcoord = zcoord;
cave.xcoord = xcoord;
}
else
{
cave.char_incave = false;
}*/
//CoordXY ingameCoords = ConvertCoord.toGame(xsec, ysec, (uint)xcoord, (uint)ycoord);
//positionTools.setPosition(ingameCoords.x, ingameCoords.y);
//MessageBox.Show(xsec + " | " + ysec + " ||| " + xcoord + " " + ycoord + " " + zcoord + Environment.NewLine + ingameCoords.x + " | " + ingameCoords.y);
packet.ReadUInt16(); // Position
int move = packet.ReadUInt8(); // Move ?? Maybie Useless
packet.ReadUInt8(); // Run
packet.ReadUInt8();
packet.ReadUInt16();
packet.ReadUInt8();
packet.ReadUInt8(); //DeathFlag
packet.ReadUInt8(); //Movement Flag
packet.ReadUInt8(); //Berserker Flag
//Char.WalkSpeed = packet.ReadUInt32(); //Walking Speed
//Char.RunSpeed = packet.ReadUInt32(); //Running Speed
CharStrings.WalkSpeed = packet.ReadSingle() * 1.1f; //Walking Speed
CharStrings.RunSpeed = packet.ReadSingle() * 1.1f; //Running Speed
CharStrings.ZerkSpeed = packet.ReadUInt32() * 1.1f; //Berserker Speed
packet.ReadUInt8();
//packet.ReadUInt16();
CharStrings.PlayerName = packet.ReadAscii();
Program.UpdateLogs(CharStrings.PlayerName, Color.Red);
//string alias = packet.ReadAscii(); // ALIAS
}
catch (Exception ex)
{
Program.UpdateLogs("Error Parsing CharSpawn Packet" + ex.Message ,Color.Red);
}
}
public static void START_ParseChar(Packet packet)
{
//BIONIC:
// CHARACTER
// NPC
// NPC_FORTRESS_STRUCT
// NPC_MOB
// NPC_COS
// NPC_FORTRESS_COS
try
{
uint model = packet.ReadUInt32();
//Console.WriteLine(" the Unique ID : " + model.ToString());
int index = Mobs_Info.mobsidlist.IndexOf(model);
if (index != -1)
{
if (Mobs_Info.mobstypelist[index].StartsWith("CHAR"))
{
//CharSpawn.ParseChar(packet, index);
Thread t = new Thread(() => ParseChar(packet, index));
t.Start();
}
}
}
catch
{
}
}
public static void ParseChar(Packet packet, int index) // 3015 single spawn
{
string name = string.Empty;
uint UniqueID = 0;
try
{
int trade = 0;
int stall = 0;
packet.ReadUInt8(); // Volume/Height scale
packet.ReadUInt8(); // HwanLevel
packet.ReadUInt8(); //PVPCape //0 = None, 1 = Red, 2 = Gray, 3 = Blue, 4 = White, 5 = Orange
packet.ReadUInt8(); // AutoInverstExp //1 = Beginner Icon, 2 = Helpful, 3 = Beginner & Helpful
packet.ReadUInt8(); // Max Slots Inventory.Size
int items_count = packet.ReadUInt8(); //Inventory.ItemCount
for (int a = 0; a < items_count; a++)
{
uint itemid = packet.ReadUInt32(); //item.RefItemID
/*if (itemid >= 80000 && itemid <= 80504) // edits for bypass For Choas
{
byte plus = packet.ReadUInt8(); // Item Plus
//Console.WriteLine("Bypass item Done");
}
else
{*/
int itemindex = Items_Info.itemsidlist.IndexOf(itemid);
if (Items_Info.itemstypelist[itemindex].StartsWith("ITEM_CH") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_EU") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_FORT") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_ROC_CH") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_ROC_EU"))
{
byte plus = packet.ReadUInt8(); // Item Plus
}
if (Items_Info.itemstypelist[itemindex].StartsWith("ITEM_EU_M_TRADE") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_EU_F_TRADE") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_CH_M_TRADE") || Items_Info.itemstypelist[itemindex].StartsWith("ITEM_CH_W_TRADE"))
{
trade = 1;
}
//}
}
packet.ReadUInt8(); // Max Avatars Slot Inventory.Size
int avatar_count = packet.ReadUInt8(); //Inventory.ItemCount
for (int a = 0; a < avatar_count; a++)
{
uint avatarid = packet.ReadUInt32(); // item.RefItemID
int avatarindex = Items_Info.itemsidlist.IndexOf(avatarid);
byte plus = packet.ReadUInt8();// Avatar Plus
if (avatarindex == -1)
{
//Globals.UpdateLogs("Error on avatars !!! Avatar ID: " + avatarid);
}
}
int mask = packet.ReadUInt8(); //HasMask
if (mask == 1)
{
uint id = packet.ReadUInt32(); //mask.RefObjID
string type = Mobs_Info.mobstypelist[Mobs_Info.mobsidlist.IndexOf(id)];
if (type.StartsWith("CHAR"))
{
packet.ReadUInt8(); //Mask.Scale
byte count = packet.ReadUInt8(); //Mask.ItemCount
for (int i = 0; i < count; i++)
{
packet.ReadUInt32(); //item.RefItemID
}
}
}
/*
else if(obj.TypeID2 == 2 && obj.TypeID3 == 5)
{
//NPC_FORTRESS_STRUCT
4 uint HP
4 uint RefEventStructID
2 ushort State
}
* */
//uint
UniqueID = packet.ReadUInt32(); // Char Unique Spawn ID
/* //Position
ushort RegionID = packet.ReadUInt16(); //Position.RegionID
float posX = packet.ReadUInt32(); //Position.X
float posY = packet.ReadUInt32(); //Position.Y
float posZ = packet.ReadUInt32(); //Position.Z
ushort posAngle = packet.ReadUInt16(); //Position.Angle
*/
byte xsec = packet.ReadUInt8(); //Position.RegionID
byte ysec = packet.ReadUInt8();
float xcoord = packet.ReadSingle();
packet.ReadSingle();
float ycoord = packet.ReadSingle();
packet.ReadUInt16(); // Position
byte move = packet.ReadUInt8(); // Moving // Movement.HasDestination
packet.ReadUInt8(); // Running // Movement.Type
if (move == 1)
{
xsec = packet.ReadUInt8();
ysec = packet.ReadUInt8();
if (ysec == 0x80)
{
xcoord = packet.ReadUInt16() - packet.ReadUInt16();
packet.ReadUInt16();
packet.ReadUInt16();
ycoord = packet.ReadUInt16() - packet.ReadUInt16();
}
else
{
xcoord = packet.ReadUInt16();
packet.ReadUInt16();
ycoord = packet.ReadUInt16();
}
}
else
{
packet.ReadUInt8(); // No Destination
packet.ReadUInt16(); ; // Angle
}
packet.ReadUInt8(); // Alive
packet.ReadUInt8(); // Unknown
packet.ReadUInt8(); // Unknown
packet.ReadUInt8(); // Unknown
packet.ReadUInt32(); // Walking speed
packet.ReadUInt32(); // Running speed
packet.ReadUInt32(); // Berserk speed
int active_skills = packet.ReadUInt8(); // Buffs count
//Spawns.characters[s_index].buffs = new Spawns.Characters_.Buffs_[100];
//try
// {
for (int a = 0; a < active_skills; a++)
{
uint skillid = packet.ReadUInt32();
int buffindex = Skills_Info.skillsidlist.IndexOf(skillid);
//Spawns.characters[s_index].buffs[a].name = Skills_Info.skillsnamelist[Skills_Info.skillsidlist.IndexOf(skillid)];
string type = Skills_Info.skillstypelist[buffindex];
packet.ReadUInt32(); // Temp ID
if (type.StartsWith("SKILL_EU_CLERIC_RECOVERYA_GROUP") || type.StartsWith("SKILL_EU_BARD_BATTLAA_GUARD") || type.StartsWith("SKILL_EU_BARD_DANCEA") || type.StartsWith("SKILL_EU_BARD_SPEEDUPA_HITRATE"))
{
packet.ReadUInt8();
}
}
/* }
catch
{
Console.WriteLine("Unknown Parsing Skill");
}*/
// string
name = packet.ReadAscii();
Console.ForegroundColor = ConsoleColor.DarkCyan;
Program.UpdateLogs("Player Arround Unique ID: " + UniqueID + " Player Name: " + name,Color.Red);
Console.ForegroundColor = ConsoleColor.Gray;
//Everything.CharStrings.CharNameANDuniqueID.Add(name + "," + UniqueID.ToString());
for (int i = 0; i < CharStrings.CharNameANDuniqueID.Count; i++) // Loop through List with foreach.
{
if (CharStrings.CharNameANDuniqueID[i].StartsWith(name))
{
int AlreadyIndex = CharStrings.CharNameANDuniqueID.IndexOf(CharStrings.CharNameANDuniqueID[i]);
CharStrings.CharNameANDuniqueID.RemoveAt(AlreadyIndex);
}
}
CharStrings.CharNameANDuniqueID.Add(name + "," + UniqueID.ToString());
/*//Spawns.characters[s_index].charname = name;
packet.ReadUInt8(); // Unknown
packet.ReadUInt8(); // Job type
packet.ReadUInt8(); // Job level
int cnt = packet.ReadUInt8();
packet.ReadUInt8();
if (cnt == 1)
{
packet.ReadUInt32();
}
packet.ReadUInt8(); // Unknown
stall = packet.ReadUInt8(); // Stall flag
packet.ReadUInt8(); // Unknown
string guild = packet.ReadAscii(); // Guild
//Spawns.characters[s_index].guildname = guild;
if (trade == 1)
{
packet.ReadUInt64();
}
else
{
packet.data.ReadDWORD(); // Guild ID
packet.data.ReadSTRING(enumStringType.ASCII); // Grant Name
packet.data.ReadDWORD();
packet.data.ReadDWORD();
packet.data.ReadDWORD();
packet.data.ReadWORD();
if (stall == 4)
{
packet.data.ReadSTRING(enumStringType.ASCII);
packet.data.ReadDWORD();
packet.data.ReadWORD();
}
else
{
packet.data.ReadWORD();
}
}*/
}
catch (Exception ex)
{
Program.UpdateLogs("Error Spawn Unique ID: " + UniqueID + " Player Name: " + name + ex.Message ,Color.Red);
Program.UpdateLogs("Spawn" + ex.Message + " Count: " + packet + ex.Message, Color.Red);
}
}
public static void begin(Packet packet)
{
try
{
//Globals.sendToClient = false;
byte action = packet.ReadUInt8();
//Console.WriteLine("Action : " + action);
if (action == 1)
{
groupspawnIsSpawn = true;//spawn
}
else if (action == 2)
{
groupspawnIsSpawn = false;//despawn
}
//spawnAmount = Convert.ToInt16(packet.ReadUInt16());
spawnAmount = (int)packet.ReadUInt16();
//Console.WriteLine("Spawn Amount : " + spawnAmount);
groupspawn = true;
}
catch(Exception ex) { Program.UpdateLogs("Error Start Record Amount Of Group Spawn " + ex.Message,Color.Red); }
}
public static void end(Packet packet)
{
groupspawn = false;
//refreshMobs();
}
public static void GroupeSpawn(Packet packet)
{
try
{
/*if (groupspawnIsSpawn)//group spawn
{*/
/*for (int i = 0; i < spawnAmount; i++)
{*/
//System.Threading.Thread.Sleep(1);
#region DetectType
uint model = packet.ReadUInt32();
int index = Mobs_Info.mobsidlist.IndexOf(model);
int itemsindex = Items_Info.itemsidlist.IndexOf(model);
//MessageBox.Show(index.ToString() + itemsindex.ToString());
#endregion
if (itemsindex != -1)
{
#region ItemsParsing
//Parse.ParseItems(packet, itemsindex);
#endregion
}
if (index != -1)
{
#region PetsParsing
if (Mobs_Info.mobstypelist[index].StartsWith("COS"))
{
//Console.WriteLine("COS : " + index);
//Parse.ParsePets(packet, index);
}
#endregion
#region NPCParsing
else if (Mobs_Info.mobstypelist[index].StartsWith("NPC"))
{
//Console.WriteLine("NPC : " + index);
//Parse.ParseNPC(packet, index);
}
#endregion
#region CharParsing
else if (Mobs_Info.mobstypelist[index].StartsWith("CHAR"))
{
//Console.WriteLine("CHAR : " + index);
//ParseChar(packet, index);
// new from annoying
Thread t = new Thread(() => CharSpawn.ParseChar(packet, index));
t.Start();
}
#endregion
#region MobsParsing
else if (Mobs_Info.mobstypelist[index].StartsWith("MOB"))
{
//Console.WriteLine("MOB : " + index);
//Parse.ParseMob(packet, index);
}
#endregion
#region PortalParsing
else if (Mobs_Info.mobstypelist[index].Contains("_GATE"))
{
//Console.WriteLine("_GATE : " + index);
//Parse.ParsePortal(packet, index);
}
#endregion
#region OtherParsing
else
{
// Console.WriteLine("OtherParsing : " + index);
//Parse.ParseOther(packet, index);
}
#endregion
}
// }
// }
}
catch(Exception ex) { Program.UpdateLogs("Error Parse group Spawn" + ex.Message,Color.Red); }
}
}
}
Agent Part
Code:
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_CHARDATA:
Program.UpdateLogs("[Notify]: " + Program._Char + ": Spawned successfully !", Color.Green);
Thread t = new Thread(() => CharSpawn.parseSpawn(current));
t.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_GROUPSPAWNB:
Thread t2 = new Thread(() => CharSpawn.begin(current));
t2.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_GROUPSPAWNEND:
Thread t3 = new Thread(() => CharSpawn.end(current));
t3.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_GROUPESPAWN:
Thread t4 = new Thread(() => CharSpawn.GroupeSpawn(current));
t4.Start();
break;
case (ushort)Opcode.SERVER_PacketsOpcodes.SERVER_SINGLESPAWN:
Thread t5 = new Thread(() => CharSpawn.START_ParseChar(current));
t5.Start();
break;
Error which i got:
Error Start Record Amount Of Group Spawn Unable to read beyond the end of the stream.
Error Parse group Spawn
|
dont know from where you copied this code, but its horrible lol starting a thread for every different bytes, this is just a sorrow to my eyes, do things properly, catch the packet on real-time with a your own environment, then parse it as it were.
ultimately this causes the excpetion because you are trying to read a byte(s) that does not exist.
|
|
|
05/09/2018, 07:01
|
#4
|
elite*gold: 53
Join Date: Sep 2014
Posts: 308
Received Thanks: 86
|
Quote:
Originally Posted by eitai123
dont know from where you copied this code, but its horrible lol starting a thread for every different bytes, this is just a sorrow to my eyes, do things properly, catch the packet on real-time with a your own environment, then parse it as it were.
ultimately this causes the excpetion because you are trying to read a byte(s) that does not exist.
|
erros has been solved by remove the threads
but still cann't read UQ and name but i realized that when he parse items he got the index = -1 and the index must be more than -1 so it cann't parse any thing but in another prog he read the all index in char inventory so it read the spawn packet correctly,i still don't know why my prog couldn't parse correctly
##Solved
|
|
|
05/09/2018, 07:57
|
#5
|
elite*gold: 0
Join Date: May 2006
Posts: 667
Received Thanks: 345
|
Quote:
Originally Posted by Mr.Awesome1337
erros has been solved by remove the threads
but still cann't read UQ and name but i realized that when he parse items he got the index = -1 and the index must be more than -1 so it cann't parse any thing but in another prog he read the all index in char inventory so it read the spawn packet correctly,i still don't know why my prog couldn't parse correctly
##Solved
|
In theory, there could be many "bad" scenarios when your reading more bytes that you actually have, it could be the multi threading environment because execution context is determined by the thread pool manager, and you cant really know for sure what happens and in which order on runtime, that being said it is highly unlikely, in most cases its just you, reading more bytes then you have, regardless of any threading context.
You can simply check the amount of bytes available for that particular packet by calling the .GetBytes() method and then use the extension method .Length
Code:
packet.Packet.GetBytes().Length
I wouldnt advise you to learn from that pattern, its wrong in so many ways,
but then again its just me.
|
|
|
05/09/2018, 14:07
|
#6
|
elite*gold: 350
Join Date: Aug 2015
Posts: 1,999
Received Thanks: 1,184
|
Quote:
Originally Posted by eitai123
In theory, there could be many "bad" scenarios when your reading more bytes that you actually have, it could be the multi threading environment because execution context is determined by the thread pool manager, and you cant really know for sure what happens and in which order on runtime, that being said it is highly unlikely, in most cases its just you, reading more bytes then you have, regardless of any threading context.
You can simply check the amount of bytes available for that particular packet by calling the .GetBytes() method and then use the extension method .Length
Code:
packet.Packet.GetBytes().Length
I wouldnt advise you to learn from that pattern, its wrong in so many ways,
but then again its just me.
|
it's not the length that he should check it's the packet structure say the length returns 0 but there's still the uniqueid/charname to read. that could lead to problems if he's using this for an event
side note: .Length is not a method it's a property
|
|
|
05/09/2018, 19:54
|
#7
|
elite*gold: 0
Join Date: May 2006
Posts: 667
Received Thanks: 345
|
Quote:
Originally Posted by B1Q
it's not the length that he should check it's the packet structure say the length returns 0 but there's still the uniqueid/charname to read. that could lead to problems if he's using this for an event
side note: .Length is not a method it's a property
|
As i said the packet structure is sometimes can be unpredictable, different events causes different packet structures and if you're setting a fixed amount of data to read and the packet does not contain more then the amount of bytes your reading, its gonna throw an exception.
You check the amount of data available before you read, needless to say that most of the packet structures are not released nor accurate, and i doubt that most people here will attempt to figure them out.
Thats just my way of doing things, ofc that up to decide what do to.
|
|
|
05/10/2018, 05:56
|
#8
|
elite*gold: 350
Join Date: Aug 2015
Posts: 1,999
Received Thanks: 1,184
|
Quote:
Originally Posted by eitai123
As i said the packet structure is sometimes can be unpredictable, different events causes different packet structures and if you're setting a fixed amount of data to read and the packet does not contain more then the amount of bytes your reading, its gonna throw an exception.
You check the amount of data available before you read, needless to say that most of the packet structures are not released nor accurate, and i doubt that most people here will attempt to figure them out.
Thats just my way of doing things, ofc that up to decide what do to.
|
there's no way the packet structure can be "unpredictable" if you parsed every situation in which a player spawns nearby.
you understand a player can be in the middle of a 3019 along with items/monsters that's the point of a group spawn packet.
i remember someone releasing the 3015 & 3013 packets i think it was DexterSoul or might be someone else.
parsing the packet is quite easy really but this guy is just trying to make it work with just copying & pasting from other tools which i do not support.
i'm withdrawing from this topic
|
|
|
05/10/2018, 10:34
|
#9
|
elite*gold: 0
Join Date: Jan 2009
Posts: 313
Received Thanks: 667
|
Quote:
Originally Posted by eitai123
As i said the packet structure is sometimes can be unpredictable, different events causes different packet structures and if you're setting a fixed amount of data to read and the packet does not contain more then the amount of bytes your reading, its gonna throw an exception.
You check the amount of data available before you read, needless to say that most of the packet structures are not released nor accurate, and i doubt that most people here will attempt to figure them out.
Thats just my way of doing things, ofc that up to decide what do to.
|
If you're trying to read more bytes than the stream contains, your previous reading operation(s) has/have already returned invalid data. It's better to throw an exception and fix the structure where it really failed instead of masking it. It might not be as critical in most packets, but it definitively is for 0x3013, 0x3015/0x3019 as a single invalid operation renders all future data invalid, thus creating unknown entities.
Furthermore I'm personally not a fan of...
Code:
if packet.Length == 5 then ReadThis else ReadThat
...where in almost all packets there is an identifying byte.
The exception being packets where it's depending on entities reference data such as...
Code:
else if ((type.StartsWith("ITEM_COS") && type.Contains("SILK")) || (type.StartsWith("ITEM_EVENT_COS") && !type.Contains("_C_")))
...where you should rather compare against the TypeIDs (as shown in my release) in order to reduce wrongly named objects made by private server "developers".
If you're eager to deliver a product to your players, you shouldn't shy away from the work involved in coding or parsing packets properly, otherwise you're just contributing to the money-grabbing nemesis of this game.
But it's up for you to decide what to do
|
|
|
05/10/2018, 20:10
|
#10
|
elite*gold: 53
Join Date: Sep 2014
Posts: 308
Received Thanks: 86
|
Quote:
Originally Posted by DaxterSoul
If you're trying to read more bytes than the stream contains, your previous reading operation(s) has/have already returned invalid data. It's better to throw an exception and fix the structure where it really failed instead of masking it. It might not be as critical in most packets, but it definitively is for 0x3013, 0x3015/0x3019 as a single invalid operation renders all future data invalid, thus creating unknown entities.
Furthermore I'm personally not a fan of...
Code:
if packet.Length == 5 then ReadThis else ReadThat
...where in almost all packets there is an identifying byte.
The exception being packets where it's depending on entities reference data such as...
Code:
else if ((type.StartsWith("ITEM_COS") && type.Contains("SILK")) || (type.StartsWith("ITEM_EVENT_COS") && !type.Contains("_C_")))
...where you should rather compare against the TypeIDs (as shown in my release) in order to reduce wrongly named objects made by private server "developers".
If you're eager to deliver a product to your players, you shouldn't shy away from the work involved in coding or parsing packets properly, otherwise you're just contributing to the money-grabbing nemesis of this game.
But it's up for you to decide what to do
|
thanks for your help and your advice
i have solved it and i will do as you say
|
|
|
|
Similar Threads
|
There was a problem parsing the spawn packet
06/01/2016 - SRO Private Server - 1 Replies
Me and my trader friends in a private server(Lotus SRO) gets client crash when we kill thief npc mobs while trading. This happens rarely. We use phbot, but i heard this also happens to those who use mbot aswell.
3923F9012B010912
...
|
Parsing Char-Spawn Paket correctly
04/01/2016 - SRO Coding Corner - 2 Replies
Dear Coding Community,
I am stucking with the parsing of the Single-Spawn Char Paket...
Below u can find the whole Paket of a single Spawn
74 07 00 00 t...............
44 D...............
|
[Need Help]Parsing groupspawn packet[3019]
10/27/2011 - SRO Coding Corner - 2 Replies
i have problem with buffs of groupspawn packet
sometimes silkroad sends
06 ................
0B 26 00 00 .&..............
B1 9A 04 00 ................
17 26 00 00 .&..............
36 90 05 00 6...............
02 ................
D2 26 00 00 ...
|
Parsing Character Data Packet
10/22/2011 - SRO Coding Corner - 6 Replies
Hello guys.
i have to say first thank you everyone here.
i learned a lot of thing from here. and sorry for my poor english. im working on it :P
So, my problem about character data.
i found Nep7Un2 post http://www.elitepvpers.com/forum/sro-ask-experts/3 90076-request-packet-structure-chardata-packet.htm l#post5289110 a while ago.
that is correct and i parsed all of data but im stuck on character coordinate.
i cant parsing it how can i calculate. i tried some way from walking structures like...
|
[Need Help]Parsing solo spawn packet[3015]
10/20/2011 - SRO Coding Corner - 5 Replies
public static void ParseSoloSpawn(Packet p)
{
Packet copy1 = p;
copy1.Skip(copy1.GetBytes().Length - 1);
int type = copy1.Readbyte();
if (type == 1)
{
int charid = p.ReadInt32();
p.ReadInt32();
p.Readbyte();
|
All times are GMT +2. The time now is 09:59.
|
|