public static ObjectDef Read(NReader rdr) { ObjectDef ret = new ObjectDef(); ret.ObjectType = rdr.ReadInt16(); ret.Stats = ObjectStats.Read(rdr); return(ret); }
public static ObjectSlot Read(NReader rdr) { ObjectSlot ret = new ObjectSlot(); ret.ObjectId = rdr.ReadInt32(); ret.SlotId = rdr.ReadByte(); ret.ObjectType = rdr.ReadInt16(); return(ret); }
public static ObjectStats Read(NReader rdr) { ObjectStats ret = new ObjectStats(); ret.Id = rdr.ReadInt32(); ret.Position = Position.Read(rdr); ret.Stats = new KeyValuePair <StatsType, object> [rdr.ReadInt16()]; for (var i = 0; i < ret.Stats.Length; i++) { StatsType type = (StatsType)rdr.ReadByte(); if (type == StatsType.Guild || type == StatsType.Name) { ret.Stats[i] = new KeyValuePair <StatsType, object>(type, rdr.ReadUTF()); } else { ret.Stats[i] = new KeyValuePair <StatsType, object>(type, rdr.ReadInt32()); } } return(ret); }
void ProcessCli() { try { var rdr = new NReader(new NetworkStream(skt)); var wtr = new NWriter(dest.GetStream()); while (true) { int len = rdr.ReadInt32(); byte id = rdr.ReadByte(); byte[] content = rdr.ReadBytes(len - 5); var state = ReceiveKey.SaveState(); content = ReceiveKey.Crypt(content); ReceiveKey.LoadState(state); //if (id == 17) //{ // MemoryStream ms = new MemoryStream(); // using (NWriter w = new NWriter(ms)) // using (NReader r = new NReader(new MemoryStream(content))) // { // w.WriteUTF(r.ReadUTF()); // Console.WriteLine(r.ReadInt32()); w.Write(-3); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.Write(r.ReadInt32()); // var c = r.ReadBytes(r.ReadInt16()); // w.Write((short)c.Length); // w.Write(c); // w.Write32UTF(r.Read32UTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // } // content = ms.ToArray(); //} if (id == 4) { using (NReader r = new NReader(new MemoryStream(content))) { var Name = rdr.ReadUTF(); var Host = rdr.ReadUTF(); var Port = rdr.ReadInt32(); var GameId = rdr.ReadInt32(); var KeyTime = rdr.ReadInt32(); var Key = rdr.ReadBytes(rdr.ReadInt16()); } } content = ReceiveKey.Crypt(content); ReceiveKey.LoadState(state); wtr.Write(len); wtr.Write((byte)id); wtr.Write(content); cliPkts.Add(new Packet() { id = id, content = ReceiveKey.Crypt(content) }); } } catch { } finally { skt.Close(); } for (var i = 0; i < cliPkts.Count; i++) File.WriteAllBytes("cli_pkt/" + i + "_" + cliPkts[i].id, cliPkts[i].content); }
void ProcessSvr() { try { var rdr = new NReader(dest.GetStream()); var wtr = new NWriter(new NetworkStream(skt)); while (true) { int len = rdr.ReadInt32() - 5; byte id = rdr.ReadByte(); byte[] content = rdr.ReadBytes(len); wtr.Write(len + 5); wtr.Write((byte)id); wtr.Write(content); svrPkts.Add(new Packet() { id = id, content = SendKey.Crypt(content) }); } } catch { } finally { skt.Close(); } JsonMap map = new JsonMap(); for (var i = 0; i < svrPkts.Count; i++) { File.WriteAllBytes("svr_pkt/" + i + "_" + svrPkts[i].id, svrPkts[i].content); if (svrPkts[i].id == 37) { map.Init(IPAddress.NetworkToHostOrder(BitConverter.ToInt32(svrPkts[i].content, 0)), IPAddress.NetworkToHostOrder(BitConverter.ToInt32(svrPkts[i].content, 4))); File.WriteAllBytes("mapinfo.packet", svrPkts[i].content); } if (svrPkts[i].id == 5) { using (NReader rdr = new NReader(new MemoryStream(svrPkts[i].content))) { short count = rdr.ReadInt16(); for (var x = 0; x < count; x++) { map.Tiles[rdr.ReadInt16()][rdr.ReadInt16()] = (Tile)rdr.ReadByte(); } count = rdr.ReadInt16(); for (var x = 0; x < count; x++) { ObjectDef def = ObjectDef.Read(rdr); def.Stats.Position.X -= 0.5F; def.Stats.Position.Y -= 0.5F; if (def.Stats.Position.X == (int)def.Stats.Position.X && def.Stats.Position.Y == (int)def.Stats.Position.Y) { int _x = (int)def.Stats.Position.X; int _y = (int)def.Stats.Position.Y; Array.Resize(ref map.Entities[_x][_y], map.Entities[_x][_y].Length + 1); ObjectDef[] arr = map.Entities[_x][_y]; arr[arr.Length - 1] = def; } } } } } File.WriteAllText("map.jm", map.ToJson()); }
public static ObjectDef Read(NReader rdr) { ObjectDef ret = new ObjectDef(); ret.ObjectType = rdr.ReadInt16(); ret.Stats = ObjectStats.Read(rdr); return ret; }
public static ObjectStats Read(NReader rdr) { ObjectStats ret = new ObjectStats(); ret.Id = rdr.ReadInt32(); ret.Position = Position.Read(rdr); ret.Stats = new KeyValuePair<StatsType, object>[rdr.ReadInt16()]; for (var i = 0; i < ret.Stats.Length; i++) { StatsType type = (StatsType)rdr.ReadByte(); if (type == StatsType.Guild || type == StatsType.Name) ret.Stats[i] = new KeyValuePair<StatsType, object>(type, rdr.ReadUTF()); else ret.Stats[i] = new KeyValuePair<StatsType, object>(type, rdr.ReadInt32()); } return ret; }
void ProcessCli() { try { var rdr = new NReader(new NetworkStream(skt)); var wtr = new NWriter(dest.GetStream()); while (true) { int len = rdr.ReadInt32(); byte id = rdr.ReadByte(); byte[] content = rdr.ReadBytes(len - 5); var state = ReceiveKey.SaveState(); content = ReceiveKey.Crypt(content); ReceiveKey.LoadState(state); //if (id == 17) //{ // MemoryStream ms = new MemoryStream(); // using (NWriter w = new NWriter(ms)) // using (NReader r = new NReader(new MemoryStream(content))) // { // w.WriteUTF(r.ReadUTF()); // Console.WriteLine(r.ReadInt32()); w.Write(-3); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.Write(r.ReadInt32()); // var c = r.ReadBytes(r.ReadInt16()); // w.Write((short)c.Length); // w.Write(c); // w.Write32UTF(r.Read32UTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // w.WriteUTF(r.ReadUTF()); // } // content = ms.ToArray(); //} if (id == 4) { using (NReader r = new NReader(new MemoryStream(content))) { var Name = rdr.ReadUTF(); var Host = rdr.ReadUTF(); var Port = rdr.ReadInt32(); var GameId = rdr.ReadInt32(); var KeyTime = rdr.ReadInt32(); var Key = rdr.ReadBytes(rdr.ReadInt16()); } } content = ReceiveKey.Crypt(content); ReceiveKey.LoadState(state); wtr.Write(len); wtr.Write((byte)id); wtr.Write(content); cliPkts.Add(new Packet() { id = id, content = ReceiveKey.Crypt(content) }); } } catch { } finally { skt.Close(); } for (var i = 0; i < cliPkts.Count; i++) File.WriteAllBytes("cli_pkt/" + i + "_" + cliPkts[i].id, cliPkts[i].content); }
void ProcessSvr() { try { var rdr = new NReader(dest.GetStream()); var wtr = new NWriter(new NetworkStream(skt)); while (true) { int len = rdr.ReadInt32() - 5; byte id = rdr.ReadByte(); byte[] content = rdr.ReadBytes(len); wtr.Write(len + 5); wtr.Write((byte)id); wtr.Write(content); svrPkts.Add(new Packet() { id = id, content = SendKey.Crypt(content) }); } } catch { } finally { skt.Close(); } JsonMap map = new JsonMap(); for (var i = 0; i < svrPkts.Count; i++) { File.WriteAllBytes("svr_pkt/" + i + "_" + svrPkts[i].id, svrPkts[i].content); if (svrPkts[i].id == 37) { map.Init(IPAddress.NetworkToHostOrder(BitConverter.ToInt32(svrPkts[i].content, 0)), IPAddress.NetworkToHostOrder(BitConverter.ToInt32(svrPkts[i].content, 4))); File.WriteAllBytes("mapinfo.packet", svrPkts[i].content); } if (svrPkts[i].id == 5) { using (NReader rdr = new NReader(new MemoryStream(svrPkts[i].content))) { short count = rdr.ReadInt16(); for (var x = 0; x < count; x++) { map.Tiles[rdr.ReadInt16()][rdr.ReadInt16()] = (Tile)rdr.ReadByte(); } count = rdr.ReadInt16(); for (var x = 0; x < count; x++) { ObjectDef def = ObjectDef.Read(rdr); def.Stats.Position.X -= 0.5F; def.Stats.Position.Y -= 0.5F; if (def.Stats.Position.X == (int)def.Stats.Position.X && def.Stats.Position.Y == (int)def.Stats.Position.Y) { int _x = (int)def.Stats.Position.X; int _y = (int)def.Stats.Position.Y; Array.Resize(ref map.Entities[_x][_y], map.Entities[_x][_y].Length + 1); ObjectDef[] arr = map.Entities[_x][_y]; arr[arr.Length - 1] = def; } } } } } File.WriteAllText("map.jm", map.ToJson()); }