public void LoadRealms() { try { Character_items Itm = Database.SelectObject <Character_items>("1=1 ORDER BY `Guid` DESC LIMIT 0, 1"); if (Itm != null) { ItemGuid = ++Itm.Guid; } Log.Succes("LoadRealm", "ItemGuidMax = " + ItemGuid); Realm[] Rms = Database.SelectAllObjects <Realm>().ToArray(); foreach (Realm Rm in Rms) { AddRealm(Rm); } } catch (Exception e) { } }
public bool Load(Character_items Item) { if (Item == null) return false; Info = WorldMgr.GetItem_Info(Item.Entry); if (Info == null) { Log.Error("ItemInterface", "Load : Info==null,Entry=" + Item.Entry); return false; } CharItem = Item; return true; }
public Character_items Create(int CharacterId) { CharItem = new Character_items(); CharItem.CharacterId = CharacterId; CharItem.Counts = _Count; CharItem.Entry = Info.Entry; CharItem.ModelId = _ModelId; CharItem.SlotId = _SlotId; CharMgr.CreateItem(CharItem); return CharItem; }
public byte[] BuildCharacters() { PacketOut Out = new PacketOut((byte)0); Out.Position = 0; Out.WriteUInt16(GetCharacterCount()); Character Char = null; for (int i = 0; i < MAX_CHARS; ++i) { Char = Chars[i]; if (Char == null) { Out.Write(new byte[280], 0, 280); } else { Out.FillString(Char.Name, 48); Out.WriteByte(Char.Info[0].Level); Out.WriteByte(Char.Career); Out.WriteByte(Char.Realm); Out.WriteByte(Char.Sex); Out.WriteByte(Char.ModelId); Out.WriteUInt16(Char.Info[0].ZoneId); Out.Write(new byte[5], 0, 5); Character_items Item = null; for (UInt16 SlotId = 14; SlotId < 30; ++SlotId) { Item = Char.GetItemInSlot(SlotId); if (Item == null) { Out.WriteUInt16(0); } else { Out.WriteUInt16Reverse(Item.ModelId); } Out.Write(new byte[6], 0, 6); } Out.Write(new byte[6], 0, 6); for (int j = 0; j < 5; ++j) { Out.Write(new byte[6], 0, 6); Out.WriteUInt16(0xFF00); } for (UInt16 SlotId = 10; SlotId < 13; ++SlotId) { Item = Char.GetItemInSlot(SlotId); Out.WriteUInt16(0); if (Item == null) { Out.WriteUInt16(0); } else { Out.WriteUInt16Reverse(Item.ModelId); } } Out.Write(new byte[10], 0, 10); Out.WriteUInt16(0xFF00); Out.WriteByte(0); Out.WriteByte(Char.Race); Out.WriteUInt16(0); Out.Write(Char.bTraits, 0, Char.bTraits.Length); Out.Write(new byte[10], 0, 10); } } return(Out.ToArray()); }
public static void LoadItem(Character_items CharItem) { lock (_Items) { _Items[CharItem.Guid] = CharItem; if (!_CharItems.ContainsKey(CharItem.CharacterId)) _CharItems.Add(CharItem.CharacterId, new List<Character_items>() { CharItem }); else _CharItems[CharItem.CharacterId].Add(CharItem); } }
public static void DeleteItem(Character_items Itm) { Log.Info("DeleteItem", "Guid=" + Itm.Guid + ",CharId=" + Itm.CharacterId); lock (_Items) { if (_CharItems.ContainsKey(Itm.CharacterId)) _CharItems[Itm.CharacterId].Remove(Itm); _Items[Itm.Guid] = null; } CharMgr.Database.DeleteObject(Itm); }
public static bool CreateItem(Character_items Item) { lock(_Items) for(long i=0;i<_Items.Length;++i) if (_Items[i] == null) { Item.Guid = i; LoadItem(Item); Database.AddObject(Item); return true; } Log.Error("CreateItem", "Maximum number of items reaches !"); return false; }
public static void F_CREATE_CHARACTER(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; CreateInfo Info; Info.slot = packet.GetUint8(); Info.race = packet.GetUint8(); Info.career = packet.GetUint8(); Info.sex = packet.GetUint8(); Info.model = packet.GetUint8(); Info.NameSize = packet.GetUint16(); packet.Skip(2); byte[] Traits = new byte[8]; packet.Read(Traits, 0, Traits.Length); packet.Skip(7); string Name = packet.GetString(Info.NameSize); if (Name.Length > 2 && !CharMgr.NameIsUsed(Name)) { CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career); if (CharInfo == null) { Log.Error("ON_CREATE", "Can not find career :" + Info.career); } else { Log.Success("OnCreate", "Creating new Character : " + Name); Character Char = new Character(); Char.AccountId = cclient._Account.AccountId; Char.bTraits = Traits; Char.Career = Info.career; Char.CareerLine = CharInfo.CareerLine; Char.ModelId = Info.model; Char.Name = Name; Char.Race = Info.race; Char.Realm = CharInfo.Realm; Char.RealmId = Program.Rm.RealmId; Char.Sex = Info.sex; if (!CharMgr.CreateChar(Char)) { Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!"); } else { Character_items Citm = null; CharacterInfo_item[] Items = CharMgr.GetCharacterInfoItem(Char.CareerLine); for (int i = 0; i < Items.Length; ++i) { if (Items[i] == null) continue; Citm = new Character_items(); Citm.Counts = Items[i].Count; Citm.CharacterId = Char.CharacterId; Citm.Entry = Items[i].Entry; Citm.ModelId = Items[i].ModelId; Citm.SlotId = Items[i].SlotId; CharMgr.CreateItem(Citm); } Character_value CInfo = new Character_value(); CInfo.CharacterId = Char.CharacterId; CInfo.Level = 1; CInfo.Money = 0; CInfo.Online = false; CInfo.RallyPoint = CharInfo.RallyPt; CInfo.RegionId = CharInfo.Region; CInfo.Renown = 0; CInfo.RenownRank = 1; CInfo.RestXp = 0; CInfo.Skills = CharInfo.Skills; CInfo.Speed = 100; CInfo.WorldO = CharInfo.WorldO; CInfo.WorldX = CharInfo.WorldX; CInfo.WorldY = CharInfo.WorldY; CInfo.WorldZ = CharInfo.WorldZ; CInfo.Xp = 0; CInfo.ZoneId = CharInfo.ZoneId; CharMgr.Database.AddObject(CInfo); Char.Value = new Character_value[1] { CInfo }; PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE); Out.WritePascalString(cclient._Account.Username); cclient.SendTCP(Out); } } } else { PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR); Out.WritePascalString(cclient._Account.Username); cclient.SendTCP(Out); } }