public void GetChannels(IPCReceiver receiver, IPCReader data) { lock (channels) { var packet = new IPCWriter(IPC.ChannelList); packet.Write(channels.Count); // server count foreach (var server in channels) { packet.Write((int)server.Key); // server id packet.Write(server.Value.Count); // channel count foreach (var channel in server.Value) { packet.Write(channel.Value.id); packet.Write(channel.Value.type); packet.Write((int)channel.Value.ip); packet.Write(channel.Value.port); packet.Write(channel.Value.maxPlayers); packet.Write(channel.Value.curPlayers); } } receiver.Send(packet); } }
public void CreateCharacter(IPCReceiver receiver, IPCReader data) { var server = data.ReadByte(); var id = data.ReadInt32(); var slot = data.ReadByte(); var name = data.ReadString(); var _class = data.ReadByte(); var gender = data.ReadBoolean(); var face = data.ReadByte(); var hair = data.ReadByte(); var colour = data.ReadByte(); var stats = initialCharStats[_class]; var items = initialCharItems[_class]; var skills = initialCharSkills[_class]; var quickslots = initialCharQuickslots[_class]; var status = serverdbs[server].CreateCharacter(id, slot, name, _class, gender, face, hair, colour, stats.ToArray(), items, skills, quickslots); var packet = new IPCWriter(IPC.CreateCharacter); packet.Write((byte)status); receiver.Send(packet); }
/*CharacterStats GetStats(IPCReceiver receiver, IPCReader data, DatabaseHandler database) * { * serverdbs[server].GetStats(charId); * serverdbs[server].ReadRow(); * * return new CharacterStats((serverdbs[server]["curhp"] as ushort?).Value, * (serverdbs[server]["maxhp"] as ushort?).Value, * (serverdbs[server]["curmp"] as ushort?).Value, * (serverdbs[server]["maxmp"] as ushort?).Value, * (serverdbs[server]["cursp"] as ushort?).Value, * (serverdbs[server]["maxsp"] as ushort?).Value, * (serverdbs[server]["exp"] as ulong?).Value, * new Tuple<uint, uint, uint, uint, uint, byte, ushort, Tuple<ushort, byte, ushort, ushort, ulong, uint>>((serverdbs[server]["str_stat"] as uint?).Value, * (serverdbs[server]["int_stat"] as uint?).Value, * (serverdbs[server]["dex_stat"] as uint?).Value, * (serverdbs[server]["honour"] as uint?).Value, * (serverdbs[server]["rank"] as uint?).Value, * (serverdbs[server]["swordrank"] as byte?).Value, * (serverdbs[server]["swordxp"] as ushort?).Value, * Tuple.Create((serverdbs[server]["swordpoints"] as ushort?).Value, * (serverdbs[server]["magicrank"] as byte?).Value, * (serverdbs[server]["magicxp"] as ushort?).Value, * (serverdbs[server]["magicpoints"] as ushort?).Value, * (serverdbs[server]["alz"] as ulong?).Value, * (serverdbs[server]["pnt_stat"] as uint?).Value * ) * ) * ); * }*/ void CreateCharacter(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var serverId = data.ReadByte(); var id = data.ReadInt32(); var slot = data.ReadByte(); var name = data.ReadString(); var _class = data.ReadByte(); var gender = data.ReadBoolean(); var face = data.ReadByte(); var hair = data.ReadByte(); var colour = data.ReadByte(); var stats = sync.GetInitialCharStats(_class); var items = sync.GetInitialCharItems(_class); var skills = sync.GetInitialCharSkills(_class); var quickslots = sync.GetInitialCharQuickSlots(_class); var serverDB = sync.GetServerDBHandler(serverId); var status = serverDB.CreateCharacter(id, slot, name, _class, gender, face, hair, colour, stats.ToArray(), items, skills, quickslots); var packet = new IPCWriter(IPC.CreateCharacter); packet.Write((byte)status); receiver.Send(packet); }
void GetCashItemList(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var serverId = data.ReadByte(); var id = data.ReadInt32(); var serverDB = sync.GetServerDBHandler(serverId); var CashCount = serverDB.GetCashItemCount(id); var packet = new IPCWriter(IPC.GetCashItemList); packet.Write(CashCount); serverDB.GetCashItem(id); while (serverDB.ReadRow()) { packet.Write((serverDB["ID"] as int?).Value); packet.Write((serverDB["itemid"] as int?).Value); packet.Write(serverDB["itemopt"] as byte[]); packet.Write((serverDB["itemopt2"] as int?).Value); packet.Write((serverDB["duration"] as int?).Value); } receiver.Send(packet); }
public void GetSubPassTime(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var id = data.ReadInt32(); var logindb = sync.GetLoginDBHandler(); var packet = new IPCWriter(IPC.GetSubPassTime); var time = logindb.GetSubPassTime(id); var debug = Configuration.masterLog; if (!debug) { if (time == null) { packet.Write(true); } if (time >= DateTime.Now) { packet.Write(true); } if (time < DateTime.Now) { packet.Write(false); } } else { packet.Write(true); } receiver.Send(packet); }
public void Send(IPCWriter writer) { var packet = writer.GetRawPacket(); AwesomeSockets.Buffer.FinalizeBuffer(packet); SendIPC(packet); }
public void FetchAccount(IPCReceiver receiver, IPCReader data) { var name = data.ReadString(); var pass = data.ReadString(); var packet = new IPCWriter(IPC.FetchAccount); if (!logindb.FetchAccount(name)) { packet.Write(0x00); packet.Write((byte)0x03); } else { logindb.ReadRow(); var id = (logindb["id"] as int?).Value; var _pass = logindb["password"].ToString(); var auth = (logindb["auth"] as byte?).Value; if (pass != _pass) { packet.Write(0x00); packet.Write((byte)0x04); } else { packet.Write(id); packet.Write(auth); } } receiver.Send(packet); }
public void GetSubPassQuestion(IPCReceiver receiver, IPCReader data) { var id = data.ReadInt32(); var packet = new IPCWriter(IPC.GetSubPassQuestion); var question = logindb.GetSubPassQuestion(id); packet.Write((byte)question); receiver.Send(packet); }
public void GetSlotOrder(IPCReceiver receiver, IPCReader data) { var server = data.ReadByte(); var id = data.ReadInt32(); var packet = new IPCWriter(IPC.GetSlotOrder); var order = serverdbs[server].GetSlotOrder(id); packet.Write(order); receiver.Send(packet); }
public void VerifyPassword(IPCReceiver receiver, IPCReader data) { var id = data.ReadInt32(); var pass = data.ReadString(); var packet = new IPCWriter(IPC.VerifyPassword); var status = logindb.VerifyPassword(id, pass); packet.Write(status); receiver.Send(packet); }
public void CheckSubPass(IPCReceiver receiver, IPCReader data) { var id = data.ReadInt32(); string pass = data.ReadString(); var packet = new IPCWriter(IPC.CheckSubPass); var status = logindb.CheckSubPw(id, pass); packet.Write(status); receiver.Send(packet); }
public void DeleteCharacter(IPCReceiver receiver, IPCReader data) { var server = data.ReadByte(); var id = data.ReadInt32(); var slot = data.ReadByte(); var packet = new IPCWriter(IPC.DeleteCharacter); var status = serverdbs[server].DeleteCharacter(id, slot); packet.Write(status); receiver.Send(packet); }
void GetSlotOrder(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var serverId = data.ReadByte(); var id = data.ReadInt32(); var serverDB = sync.GetServerDBHandler(serverId); var packet = new IPCWriter(IPC.GetSlotOrder); var order = serverDB.GetSlotOrder(id); packet.Write(order); receiver.Send(packet); }
void VerifyPassword(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var id = data.ReadInt32(); var pass = data.ReadString(); var logindb = sync.GetLoginDBHandler(); var packet = new IPCWriter(IPC.VerifyPassword); var status = logindb.VerifyPassword(id, pass); packet.Write(status); receiver.Send(packet); }
public void CheckSubPass(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var id = data.ReadInt32(); var pass = data.ReadString(); var logindb = sync.GetLoginDBHandler(); var packet = new IPCWriter(IPC.CheckSubPass); var status = logindb.CheckSubPw(id, pass); packet.Write(status); receiver.Send(packet); }
void DeleteCharacter(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var serverId = data.ReadByte(); var id = data.ReadInt32(); var slot = data.ReadByte(); var serverDB = sync.GetServerDBHandler(serverId); var packet = new IPCWriter(IPC.DeleteCharacter); var status = serverDB.DeleteCharacter(id, slot); packet.Write(status); receiver.Send(packet); }
public void Send(IPCWriter writer) { try { var packet = writer.GetRawPacket(); AwesomeSockets.Buffer.FinalizeBuffer(packet); SendIPC(packet); var opcode = writer.Opcode; int size = writer.Size; events.IPCSentPacket(this, new IPCPacketEventArgs(opcode, size)); } catch (Exception ex) { Log.Error("Sending IPC Packet failed on packet {0}", writer.GetRawPacket().ToString(), "[ObjectBuddy::SyncReceiver::" + ex.TargetSite + "()]"); } }
public void GetSubPass(IPCReceiver receiver, IPCReader data) { var id = data.ReadInt32(); var packet = new IPCWriter(IPC.GetSubPass); if (!logindb.GetSubPass(id)) { packet.Write(false); } else { packet.Write(true); } receiver.Send(packet); }
void GetSubPass(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var id = data.ReadInt32(); var logindb = sync.GetLoginDBHandler(); var packet = new IPCWriter(IPC.GetSubPass); if (!logindb.GetSubPass(id)) { packet.Write(false); } else { packet.Write(true); } receiver.Send(packet); }
void CharacterList(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var serverId = data.ReadByte(); var account = data.ReadInt32(); var serverDB = sync.GetServerDBHandler(serverId); var charNum = serverDB.GetCharactersCount(account); var packet = new IPCWriter(IPC.GetCharacterList); packet.Write(charNum); serverDB.GetCharacters(account); while (serverDB.ReadRow()) { packet.Write((serverDB["id"] as int?).Value); packet.Write((serverDB["slot"] as byte?).Value); packet.Write(serverDB["name"] as string); packet.Write((serverDB["level"] as uint?).Value); packet.Write((serverDB["class"] as byte?).Value); packet.Write((serverDB["face"] as byte?).Value); packet.Write((serverDB["hair"] as byte?).Value); packet.Write((serverDB["colour"] as byte?).Value); packet.Write((serverDB["gender"] as bool?).Value); packet.Write((serverDB["map"] as byte?).Value); packet.Write((serverDB["x"] as byte?).Value); packet.Write((serverDB["y"] as byte?).Value); packet.Write((serverDB["created"] as DateTime?).Value.ToBinary()); packet.Write(serverDB["head"] as byte[]); packet.Write(serverDB["body"] as byte[]); packet.Write(serverDB["hands"] as byte[]); packet.Write(serverDB["feet"] as byte[]); packet.Write(serverDB["righthand"] as byte[]); packet.Write(serverDB["lefthand"] as byte[]); packet.Write(serverDB["back"] as byte[]); } receiver.Send(packet); }
void FetchAccount(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var name = data.ReadString(); var pass = data.ReadString(); var logindb = sync.GetLoginDBHandler(); var packet = new IPCWriter(IPC.FetchAccount); if (!logindb.FetchAccount(name)) { packet.Write(0x00); packet.Write((byte)0x03); packet.Write(false); } else { logindb.ReadRow(); var id = (logindb["id"] as int?).Value; var _pass = logindb["password"].ToString(); var auth = (logindb["auth"] as byte?).Value; var online = Convert.ToBoolean((logindb["online"])); if (pass != _pass) { packet.Write(0x00); packet.Write((byte)0x04); packet.Write(false); } else { packet.Write(id); packet.Write(auth); packet.Write(online); } } receiver.Send(packet); }
public void GetSubPassTime(IPCReceiver receiver, IPCReader data) { var id = data.ReadInt32(); var packet = new IPCWriter(IPC.GetSubPassTime); var time = logindb.GetSubPassTime(id); if (time == null) { packet.Write(true); } if (time >= DateTime.Now) { packet.Write(true); } if (time < DateTime.Now) { packet.Write(false); } receiver.Send(packet); }
public void GetUser(IPCReceiver receiver, IPCReader data) { lock (users) { var magic = data.ReadUInt64(); var packet = new IPCWriter(IPC.GetUser); if (!users.ContainsKey(magic)) { packet.Write(-1); receiver.Send(packet); return; } var id = users[magic]; users.Remove(magic); Log.Notice("User retrieved: " + magic.ToString("X2")); packet.Write(id); receiver.Send(packet); } }
public void GetFullCharacter(IPCReceiver receiver, IPCReader data) { var server = data.ReadByte(); var id = data.ReadInt32(); var slot = data.ReadByte(); var packet = new IPCWriter(IPC.GetFullCharacter); serverdbs[server].GetCharacter(id, slot); serverdbs[server].ReadRow(); var charId = (serverdbs[server]["id"] as int?).Value; packet.Write(charId); packet.Write((serverdbs[server]["slot"] as byte?).Value); packet.Write(serverdbs[server]["name"] as string); packet.Write((serverdbs[server]["level"] as uint?).Value); packet.Write((serverdbs[server]["class"] as byte?).Value); packet.Write((serverdbs[server]["face"] as byte?).Value); packet.Write((serverdbs[server]["hair"] as byte?).Value); packet.Write((serverdbs[server]["colour"] as byte?).Value); packet.Write((serverdbs[server]["gender"] as bool?).Value); packet.Write((serverdbs[server]["map"] as byte?).Value); packet.Write((serverdbs[server]["x"] as byte?).Value); packet.Write((serverdbs[server]["y"] as byte?).Value); packet.Write((serverdbs[server]["created"] as DateTime?).Value.ToBinary()); packet.Write(serverdbs[server]["head"] as byte[]); packet.Write(serverdbs[server]["body"] as byte[]); packet.Write(serverdbs[server]["hands"] as byte[]); packet.Write(serverdbs[server]["feet"] as byte[]); packet.Write(serverdbs[server]["righthand"] as byte[]); packet.Write(serverdbs[server]["lefthand"] as byte[]); packet.Write(serverdbs[server]["back"] as byte[]); serverdbs[server].GetStats(charId); serverdbs[server].ReadRow(); packet.Write((serverdbs[server]["curhp"] as ushort?).Value); packet.Write((serverdbs[server]["maxhp"] as ushort?).Value); packet.Write((serverdbs[server]["curmp"] as ushort?).Value); packet.Write((serverdbs[server]["maxmp"] as ushort?).Value); packet.Write((serverdbs[server]["cursp"] as ushort?).Value); packet.Write((serverdbs[server]["maxsp"] as ushort?).Value); packet.Write((serverdbs[server]["exp"] as ulong?).Value); packet.Write((serverdbs[server]["alz"] as ulong?).Value); packet.Write((serverdbs[server]["str_stat"] as uint?).Value); packet.Write((serverdbs[server]["int_stat"] as uint?).Value); packet.Write((serverdbs[server]["dex_stat"] as uint?).Value); packet.Write((serverdbs[server]["pnt_stat"] as uint?).Value); packet.Write((serverdbs[server]["honour"] as uint?).Value); packet.Write((serverdbs[server]["rank"] as uint?).Value); packet.Write((serverdbs[server]["swordrank"] as byte?).Value); packet.Write((serverdbs[server]["swordxp"] as ushort?).Value); packet.Write((serverdbs[server]["swordpoints"] as ushort?).Value); packet.Write((serverdbs[server]["magicrank"] as byte?).Value); packet.Write((serverdbs[server]["magicxp"] as ushort?).Value); packet.Write((serverdbs[server]["magicpoints"] as ushort?).Value); var itemCount = serverdbs[server].GetItemCount(charId); serverdbs[server].GetInventory(charId); packet.Write(itemCount); while (serverdbs[server].ReadRow()) { packet.Write((byte[])serverdbs[server]["item"] as byte[]); packet.Write((serverdbs[server]["amount"] as ushort?).Value); packet.Write((serverdbs[server]["slot"] as byte?).Value); } var skillCount = serverdbs[server].GetSkillCount(charId); serverdbs[server].GetSkills(charId); packet.Write(skillCount); while (serverdbs[server].ReadRow()) { packet.Write((serverdbs[server]["skill"] as ushort?).Value); packet.Write((serverdbs[server]["level"] as byte?).Value); packet.Write((serverdbs[server]["slot"] as byte?).Value); } var quickSlotCount = serverdbs[server].GetQuickSlotCount(charId); serverdbs[server].GetQuickslots(charId); packet.Write(quickSlotCount); while (serverdbs[server].ReadRow()) { packet.Write((serverdbs[server]["skill"] as byte?).Value); packet.Write((serverdbs[server]["slot"] as byte?).Value); } receiver.Send(packet); }
void GetFullCharacter(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var serverId = data.ReadByte(); var id = data.ReadInt32(); var slot = data.ReadByte(); var serverDB = sync.GetServerDBHandler(serverId); var packet = new IPCWriter(IPC.GetFullCharacter); serverDB.GetCharacter(id, slot); serverDB.ReadRow(); var charId = (serverDB["id"] as int?).Value; packet.Write(charId); packet.Write((serverDB["slot"] as byte?).Value); packet.Write(serverDB["name"] as string); packet.Write((serverDB["level"] as uint?).Value); packet.Write((serverDB["class"] as byte?).Value); packet.Write((serverDB["face"] as byte?).Value); packet.Write((serverDB["hair"] as byte?).Value); packet.Write((serverDB["colour"] as byte?).Value); packet.Write((serverDB["gender"] as bool?).Value); packet.Write((serverDB["map"] as byte?).Value); packet.Write((serverDB["x"] as byte?).Value); packet.Write((serverDB["y"] as byte?).Value); packet.Write((serverDB["created"] as DateTime?).Value.ToBinary()); packet.Write(serverDB["head"] as byte[]); packet.Write(serverDB["body"] as byte[]); packet.Write(serverDB["hands"] as byte[]); packet.Write(serverDB["feet"] as byte[]); packet.Write(serverDB["righthand"] as byte[]); packet.Write(serverDB["lefthand"] as byte[]); packet.Write(serverDB["back"] as byte[]); packet.Write(serverDB["card"] as byte[]); packet.Write(serverDB["neck"] as byte[]); packet.Write(serverDB["finger1"] as byte[]); packet.Write(serverDB["finger2"] as byte[]); packet.Write(serverDB["finger3"] as byte[]); packet.Write(serverDB["finger4"] as byte[]); packet.Write(serverDB["leftear"] as byte[]); packet.Write(serverDB["rightear"] as byte[]); packet.Write(serverDB["leftwrist"] as byte[]); packet.Write(serverDB["rightwrist"] as byte[]); packet.Write(serverDB["belt"] as byte[]); packet.Write(serverDB["charm"] as byte[]); packet.Write(serverDB["lefteffector"] as byte[]); packet.Write(serverDB["righteffector"] as byte[]); packet.Write(serverDB["cornalina"] as byte[]); packet.Write(serverDB["talisman"] as byte[]); packet.Write(serverDB["leftarcane"] as byte[]); packet.Write(serverDB["rightarcane"] as byte[]); serverDB.GetStats(charId); serverDB.ReadRow(); packet.Write((serverDB["curhp"] as ushort?).Value); packet.Write((serverDB["maxhp"] as ushort?).Value); packet.Write((serverDB["curmp"] as ushort?).Value); packet.Write((serverDB["maxmp"] as ushort?).Value); packet.Write((serverDB["cursp"] as ushort?).Value); packet.Write((serverDB["maxsp"] as ushort?).Value); packet.Write((serverDB["exp"] as ulong?).Value); packet.Write((serverDB["str_stat"] as uint?).Value); packet.Write((serverDB["int_stat"] as uint?).Value); packet.Write((serverDB["dex_stat"] as uint?).Value); packet.Write((serverDB["pnt_stat"] as uint?).Value); packet.Write((serverDB["honour"] as uint?).Value); packet.Write((serverDB["rank"] as uint?).Value); packet.Write((serverDB["swordrank"] as byte?).Value); packet.Write((serverDB["swordxp"] as ushort?).Value); packet.Write((serverDB["swordpoints"] as ushort?).Value); packet.Write((serverDB["magicrank"] as byte?).Value); packet.Write((serverDB["magicxp"] as ushort?).Value); packet.Write((serverDB["magicpoints"] as ushort?).Value); packet.Write((serverDB["alz"] as ulong?).Value); packet.Write((serverDB["wexp"] as ulong?).Value); packet.Write((serverDB["honor"] as ulong?).Value); var itemCount = serverDB.GetItemCount(charId); serverDB.GetInventory(charId); packet.Write(itemCount); while (serverDB.ReadRow()) { packet.Write((byte[])serverDB["item"] as byte[]); packet.Write((serverDB["amount"] as ushort?).Value); packet.Write((serverDB["slot"] as byte?).Value); } var skillCount = serverDB.GetSkillCount(charId); serverDB.GetSkills(charId); packet.Write(skillCount); while (serverDB.ReadRow()) { packet.Write((serverDB["skill"] as ushort?).Value); packet.Write((serverDB["level"] as byte?).Value); packet.Write((serverDB["slot"] as byte?).Value); } var quickSlotCount = serverDB.GetQuickSlotCount(charId); serverDB.GetQuickslots(charId); packet.Write(quickSlotCount); while (serverDB.ReadRow()) { packet.Write((serverDB["skill"] as byte?).Value); packet.Write((serverDB["slot"] as byte?).Value); } receiver.Send(packet); }