public ANS_FRIENDLIST_STATE(UInt32 charUID, WorldClient client) : base((UInt32)Opcodes.ANS_FRIENDLIST_STATE) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteByte(1); WriteByte(client.LFG); WriteByte(client.groupStatus); WriteByte(client.groupPublic); WriteByte(client.groupInvite); WriteUInt32((uint)(client.districtID & client.districtType)); WriteByte(0); WriteUInt32Reverse(charUID); /* * * Receive [WS2GC_ANS_FRIENDLIST_STATE] * m_nReturnCode 0 * m_nMembers 49 * m_nCharacterUID[0] 1104126 * m_bLookingForGroup[0] false * m_nGroupStatus[0] 0 * m_nGroupPublic[0] 0 * m_nGroupInvite[0] 0 * m_nInstanceUID[0] (0,0) * m_nDistrictStatus[0] 0 * m_nStatus[0] 0 * m_nCharacterUID[1] 2509488 * m_bLookingForGroup[1] false * m_nGroupStatus[1] 0 * m_nGroupPublic[1] 0 * m_nGroupInvite[1] 0 * m_nInstanceUID[1] (0,0) * m_nDistrictStatus[1] 0 * m_nStatus[1] 0 */ }
public ANS_IGNORELIST_ADD(String charName, WorldClient client) : base((UInt32)Opcodes.ANS_IGNORELIST_ADD) { int count = Databases.CharacterTable.Count(c => c.Name == charName); CharacterEntry chr = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName); if (client.Character.Name == charName) WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SELF); else { if (client.Character.AccountIndex == chr.AccountIndex) WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SAME_ACCOUNT); else { if (count < 1) WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_NOT_FOUND); else if (count >= 1) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32Reverse((uint)chr.Index); WriteParsedString(charName); IgnoreEntry ign = new IgnoreEntry(); ign.Index = Databases.FriendTable.GenerateIndex(); ign.CharacterOwnerIndex = client.Character.Index; ign.CharacterIgnoreIndex = chr.Index; Databases.IgnoreTable.Add(ign); } } } }
public ANS_CHARACTERFINDER_INFO(String charName, WorldClient client) : base((UInt32)Opcodes.ANS_CHARACTERFINDER_INFO) { int count = Databases.CharacterTable.Count(c => c.Name == charName); CharacterEntry chr = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName); if (client.Character.Name == charName) WriteUInt32Reverse(0x01); else { if (client.Account.Index == chr.AccountIndex) WriteUInt32Reverse(0x01); else { if (count < 1) WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTERFINDER_INFO_NO_CHARACTER); else { if (chr.IsOnline == 1) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32Reverse((uint)chr.Index); WriteParsedString(charName); WriteByte(chr.Faction); WriteByte(chr.LFG); WriteByte(chr.GroupStatus); WriteByte(chr.IsGroupPublic); WriteByte(chr.GroupInvite); UInt32 code = (UInt32)(chr.DistrictType << 24); code += chr.DistrictID; WriteUInt32(code); WriteByte(0); //districtstatus WriteFloat(1.00f); } else WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTERFINDER_INFO_NO_CHARACTER); } } } }
public ANS_GROUP_INVITE(String charName, WorldClient client) : base((UInt32)Opcodes.ANS_GROUP_INVITE) { MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM `characters` WHERE `name`= @name", WorldServer.Database.Connection.Instance); try { cmd.Prepare(); cmd.Parameters.AddWithValue("@name", charName); Byte rows = Convert.ToByte(cmd.ExecuteScalar()); if (client.Name == charName) WriteUInt32Reverse((uint)ResponseCodes.RC_GROUP_INVITE_SELF); else if (client.Name != charName) { if (rows < 1) WriteUInt32Reverse((uint)ResponseCodes.RC_GROUP_INVITE_NOT_FOUND); else if (rows >= 1) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteParsedString(charName); } } } finally { cmd.Dispose(); } }
public ANS_CHAT_WHISPER(WorldClient client, UInt32 whisperUID, String charname, String message) : base((UInt32)Opcodes.ANS_CHAT_WHISPER) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32Reverse(whisperUID); UInt32 charUID = 0x00; //GetCharUid(String charname) TODO WriteUInt32Reverse(charUID); }
public ANS_NAME_QUERY(UInt16 type, UInt32 charUID, String charname, WorldClient client) : base((UInt32)Opcodes.ANS_NAME_QUERY) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt16Reverse(type); WriteUInt32Reverse(charUID); WriteParsedString(charname); //WritePascalString ? }
public ANS_DISTRICT_ENTER(District district, WorldClient client) : base((UInt32)Opcodes.ANS_DISTRICT_ENTER) { if (district != null) { WriteInt32((int)ResponseCodes.RC_SUCCESS); string[] delimiter = new string[] { "." }; string[] result = district.IP.Split(delimiter, StringSplitOptions.None); foreach (string s in result) WriteByte(Convert.ToByte(s)); WriteUInt16Reverse(2108); WriteInt32Reverse(TcpServer.GetTimeStamp()); } else WriteUInt32Reverse((uint)ResponseCodes.RC_DISTRICT_RESERVE_DISTRICT_OFFLINE); }
public ANS_GROUP_INVITE(String charName, WorldClient client) : base((UInt32)Opcodes.ANS_GROUP_INVITE) { int count = Databases.CharacterTable.Count(c => c.Name == charName); if (client.Character.Name == charName) WriteUInt32Reverse((uint)ResponseCodes.RC_GROUP_INVITE_SELF); else { if (count < 1) WriteUInt32Reverse((uint)ResponseCodes.RC_GROUP_INVITE_NOT_FOUND); else if (count >= 1) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteParsedString(charName); } } }
// ============================================================================================================ // Ctor, Initialization, Dispose, Update // ============================================================================================================ public WorldModel() { Service.Add<WorldModel>(this); m_Engine = Service.Get<UltimaGame>(); m_Network = Service.Get<INetworkClient>(); m_UserInterface = Service.Get<UserInterfaceService>(); Entities = new EntityManager(this); Entities.Reset(true); Effects = new EffectManager(this); Statics = new StaticManager(); Input = new WorldInput(this); Interaction = new WorldInteraction(this); Client = new WorldClient(this); }
public ANS_IGNORELIST_ADD(String charName, WorldClient client) : base((UInt32)Opcodes.ANS_IGNORELIST_ADD) { MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM `characters` WHERE `name`= @name", WorldServer.Database.Connection.Instance); MySqlCommand cmd2 = new MySqlCommand("SELECT * FROM `characters` WHERE `name` = @name", WorldServer.Database.Connection.Instance); try { cmd.Prepare(); cmd.Parameters.AddWithValue("@name", charName); cmd2.Prepare(); cmd2.Parameters.AddWithValue("@name", charName); cmd2.ExecuteNonQuery(); MySqlDataReader reader = cmd2.ExecuteReader(); try { while (reader.Read()) { charAccID = getAccID(reader); charID = getCharID(reader); } } catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); } finally { reader.Close(); reader.Dispose(); } Byte rows = Convert.ToByte(cmd.ExecuteScalar()); if (client.Name == charName) WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SELF); else if (client.Name != charName) { if (client.AccountId == charAccID) WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SAME_ACCOUNT); else if (client.AccountId != charAccID) { if (rows < 1) WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_NOT_FOUND); else if (rows >= 1) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32Reverse(charID); WriteParsedString(charName); } } } } finally { cmd.Dispose(); cmd2.Dispose(); } }
public ANS_DISTRICT_RESERVE(UInt32 code, UInt32 charUID, Byte group, WorldClient client) : base((UInt32)Opcodes.ANS_DISTRICT_RESERVE) { UInt32 soc = 16777216; UInt32 fin = 2 * soc; UInt32 wat = fin * 10 + soc; lock (Program.districtsListener.Districts) { foreach (KeyValuePair<UInt32, District> district in Program.districtsListener.Districts) { if (code - soc < 100) if (district.Value.Type == (Byte)DistrictTypes.SOCIAL) client.Reserved = new SocialDistrict(district.Value.Id); if (code - fin < 100) if (district.Value.Type == (Byte)DistrictTypes.FINANCIAL) client.Reserved = new FinancialDistrict(district.Value.Id); if (code - wat < 100) if (district.Value.Type == (Byte)DistrictTypes.WATERFRONT) client.Reserved = new WaterFrontDistrict(district.Value.Id); if(client.Reserved != null) { if (district.Value.isFull() == 0) { client.Reserved.Key = district.Key; client.Reserved.Id = district.Value.Id; client.Reserved.IP = district.Value.IP; client.Reserved.Port = district.Value.Port; client.Reserved.Criminals = district.Value.Criminals; client.Reserved.Enforcers = district.Value.Enforcers; client.Reserved.Queue = district.Value.Queue; client.Reserved.tcp = district.Value.tcp; WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32(client.Reserved.Key); WriteByte(group); WriteByte(0); client.Send(new ANS_DISTRICT_ENTER(client.Reserved, client)); } } else { WriteUInt32Reverse((uint)ResponseCodes.RC_DISTRICT_RESERVE_INVALID_DISTRICT); WriteUInt32(0); WriteByte(0); WriteByte(0); } } } }
public ANS_FRIENDLIST_ADD(String charName, WorldClient client) : base((UInt32)Opcodes.ANS_FRIENDLIST_ADD) { int count = Databases.CharacterTable.Count(c => c.Name == charName); CharacterEntry chr = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName); if (client.Character.Name == charName) WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SELF); else { if (client.Character.AccountIndex == chr.AccountIndex) WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SAME_ACCOUNT); else { if (count < 1) WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_INVALID_NAME); else if (count >= 1) { WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteParsedString(charName); WriteByte(chr.Faction); WriteByte(chr.IsOnline); WriteUInt32Reverse((uint)chr.Index); WriteByte(chr.LFG); WriteByte(chr.GroupStatus); WriteByte(chr.IsGroupPublic); WriteByte(chr.GroupInvite); UInt32 code = (UInt32)(chr.DistrictType << 24); code += chr.DistrictID; WriteUInt32(code); WriteByte(0); //districtstatus FriendEntry frnd = new FriendEntry(); frnd.Index = Databases.FriendTable.GenerateIndex(); frnd.CharacterOwnerIndex = client.Character.Index; frnd.CharacterFriendIndex = chr.Index; Databases.FriendTable.Add(frnd); } } } }
public ANS_DISTRICT_RESERVE(UInt32 code, UInt32 charUID, Byte group, WorldClient client) : base((UInt32)Opcodes.ANS_DISTRICT_RESERVE) { UInt32 social = 16777216; UInt32 social_2 = 16777217; UInt32 financial = 33554432; UInt32 financial_2 = 33554433; UInt32 waterfront = 352321536; UInt32 waterfront_2 = 352321537; if (code != social && code != financial && code != waterfront) { lock (Program.districtsListener.Districts) { foreach (KeyValuePair<UInt32, District> district in Program.districtsListener.Districts) { if (code == social_2) { if (district.Value.Type == (Byte)DistrictTypes.SOCIAL) { if (district.Value.isFull() == 0) { client.Reserved = new SocialDistrict(district.Value.Id); client.Reserved.Key = district.Key; client.Reserved.Id = district.Value.Id; client.Reserved.IP = district.Value.IP; client.Reserved.Criminals = district.Value.Criminals; client.Reserved.Enforcers = district.Value.Enforcers; client.Reserved.Queue = district.Value.Queue; client.Reserved.tcp = district.Value.tcp; WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32(client.Reserved.Key); WriteByte(group); WriteByte(0); client.Send(new ANS_DISTRICT_ENTER(client.Reserved, client)); break; } } } else if (code == financial_2) { if (district.Value.Type == (Byte)DistrictTypes.FINANCIAL) { if (district.Value.isFull() == 0) { client.Reserved = new FinancialDistrict(district.Value.Id); client.Reserved.Key = district.Key; client.Reserved.Id = district.Value.Id; client.Reserved.IP = district.Value.IP; client.Reserved.Criminals = district.Value.Criminals; client.Reserved.Enforcers = district.Value.Enforcers; client.Reserved.Queue = district.Value.Queue; client.Reserved.tcp = district.Value.tcp; WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32(client.Reserved.Key); WriteByte(group); WriteByte(0); client.Send(new ANS_DISTRICT_ENTER(client.Reserved, client)); break; } } } else if (code == waterfront_2) { if (district.Value.Type == (Byte)DistrictTypes.WATERFRONT) { if (district.Value.isFull() == 0) { client.Reserved = new WaterFrontDistrict(district.Value.Id); client.Reserved.Key = district.Key; client.Reserved.Id = district.Value.Id; client.Reserved.IP = district.Value.IP; client.Reserved.Criminals = district.Value.Criminals; client.Reserved.Enforcers = district.Value.Enforcers; client.Reserved.Queue = district.Value.Queue; client.Reserved.tcp = district.Value.tcp; WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32(client.Reserved.Key); WriteByte(group); WriteByte(0); client.Send(new ANS_DISTRICT_ENTER(client.Reserved, client)); break; } } } } } } else { lock (Program.districtsListener.Districts) { foreach (KeyValuePair<UInt32, District> district in Program.districtsListener.Districts) { if (code == social) { if (district.Value.Type == (Byte)DistrictTypes.SOCIAL) { if (district.Value.isFull() == 0) { client.Reserved = new SocialDistrict(district.Value.Id); client.Reserved.Key = district.Key; client.Reserved.Id = district.Value.Id; client.Reserved.IP = district.Value.IP; client.Reserved.Criminals = district.Value.Criminals; client.Reserved.Enforcers = district.Value.Enforcers; client.Reserved.Queue = district.Value.Queue; client.Reserved.tcp = district.Value.tcp; WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32(client.Reserved.Key); WriteByte(group); WriteByte(0); client.Send(new ANS_DISTRICT_ENTER(client.Reserved, client)); break; } } } else if (code == financial) { if (district.Value.Type == (Byte)DistrictTypes.FINANCIAL) { if (district.Value.isFull() == 0) { client.Reserved = new FinancialDistrict(district.Value.Id); client.Reserved.Key = district.Key; client.Reserved.Id = district.Value.Id; client.Reserved.IP = district.Value.IP; client.Reserved.Criminals = district.Value.Criminals; client.Reserved.Enforcers = district.Value.Enforcers; client.Reserved.Queue = district.Value.Queue; client.Reserved.tcp = district.Value.tcp; WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32(client.Reserved.Key); WriteByte(group); WriteByte(0); client.Send(new ANS_DISTRICT_ENTER(client.Reserved, client)); break; } } } else if (code == waterfront) { if (district.Value.Type == (Byte)DistrictTypes.WATERFRONT) { if (district.Value.isFull() == 0) { client.Reserved = new WaterFrontDistrict(district.Value.Id); client.Reserved.Key = district.Key; client.Reserved.Id = district.Value.Id; client.Reserved.IP = district.Value.IP; client.Reserved.Criminals = district.Value.Criminals; client.Reserved.Enforcers = district.Value.Enforcers; client.Reserved.Queue = district.Value.Queue; client.Reserved.tcp = district.Value.tcp; WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteUInt32(client.Reserved.Key); WriteByte(group); WriteByte(0); client.Send(new ANS_DISTRICT_ENTER(client.Reserved, client)); break; } } } } } } }
public void Handle(WorldClient client, LearnNewSkillPacket packet) { var result = _skillsManager.TryLearnNewSkill(packet.SkillId, packet.SkillLevel); _packetFactory.SendLearnedNewSkill(client, result.Ok, result.Skill); }
public static void HandleGuildCreationRequest(GuildCreationValidMessage message, WorldClient client) { GuildCreationResultEnum result = GuildProvider.Instance.CreateGuild(client.Character, message.guildName, message.guildEmblem); client.Character.OnGuildCreated(result); }
public static void SendGuildInformationsGeneral(WorldClient client) { client.Send(client.Character.Guild.GetGuildInformationsGeneralMessage()); }
public static void HandleGuildChangeMemberParameters(GuildChangeMemberParametersMessage message, WorldClient client) { if (client.Character.HasGuild) { GuildMemberInstance member = client.Character.Guild.GetMember((long)message.memberId); if (member != null && member.Guild == client.Character.Guild) { member.ChangeParameters(client.Character.GuildMember, message.rights, message.rank, message.experienceGivenPercent); } } }
public virtual void Execute(WorldClient client, CommandParameters parameters) { }
public override bool MoveItem(WorldClient Client, InventoryItemModel Item, ushort Quantity, bool Add = false) { return(false); }
public static void HandleExchangeCraftCount(ExchangeCraftCountRequestMessage message, WorldClient client) { if (client.Character.IsInExchange(ExchangeTypeEnum.CRAFT)) { client.Character.GetDialog <AbstractCraftExchange>().SetCount(message.count); } }
public static void HandleExchangePlayerRequest(ExchangePlayerRequestMessage message, WorldClient client) { Character target = client.Character.Map.Instance.GetEntity <Character>((long)message.target); if (target == null) { client.Character.OnExchangeError(ExchangeErrorEnum.REQUEST_IMPOSSIBLE); return; } if (target.Busy) { client.Character.OnExchangeError(ExchangeErrorEnum.REQUEST_CHARACTER_OCCUPIED); return; } if (target.Map == null || target.Record.MapId != client.Character.Record.MapId) { client.Character.OnExchangeError(ExchangeErrorEnum.REQUEST_IMPOSSIBLE); return; } if (!target.Map.Position.AllowExchangesBetweenPlayers) { client.Character.OnExchangeError(ExchangeErrorEnum.REQUEST_IMPOSSIBLE); return; } switch ((ExchangeTypeEnum)message.exchangeType) { case ExchangeTypeEnum.PLAYER_TRADE: target.OpenRequestBox(new PlayerTradeRequest(client.Character, target)); break; default: client.Send(new ExchangeErrorMessage((sbyte)ExchangeErrorEnum.REQUEST_IMPOSSIBLE)); break; } }
public static void HandleExchangeObjectMoveKamas(ExchangeObjectMoveKamaMessage message, WorldClient client) { if (client.Character.Record.Kamas >= message.quantity && client.Character.GetDialog <Exchange>() != null) { client.Character.GetDialog <Exchange>().MoveKamas(message.quantity); } }
public static void HandleExchangeObjectTransfertListToInv(ExchangeObjectTransfertListToInvMessage message, WorldClient client) { AbstractTradeExchange dialog = client.Character.GetDialog <AbstractTradeExchange>(); IEnumerable <ItemStack> allPresentItems = dialog.GetAllPresentItems().Where(x => message.ids.Contains(x.ItemUId)); foreach (ItemStack itemStack in allPresentItems) { dialog.MoveItem(itemStack.ItemUId, -1 * (int)itemStack.Quantity); } }
public static void HandleExchangeObjectTransfertExistingToInv(ExchangeObjectTransfertExistingToInvMessage message, WorldClient client) { AbstractTradeExchange dialog = client.Character.GetDialog <AbstractTradeExchange>(); IEnumerable <ItemStack> allPresentItems = dialog.GetAllPresentItems(); List <uint> characterItems = client.Character.Inventory.GetItems().ToList().ConvertAll(x => x.UId); foreach (ItemStack itemStack in allPresentItems) { if (characterItems.Contains(itemStack.ItemUId)) { dialog.MoveItem(itemStack.ItemUId, -1 * (int)itemStack.Quantity); } } }
public static void HandleExchangeObjectTransfertAllToInv(ExchangeObjectTransfertAllToInvMessage message, WorldClient client) { client.Character.GetDialog <AbstractTradeExchange>().RemoveAllItems(); }
private void RedirectMap(byte[] body) { try { if (world != null) { world.Send(body); } else { Console.WriteLine("world is null"); } } catch (ObjectDisposedException) { Trace.TraceError("Connection with the world server has been lost, packet are discared"); world = null; this.Close(); } catch (Exception) { Trace.TraceError("Connection with the world server has been lost, packet are discared"); this.Close(); } }
public static void HandleExchangeObjectTransfertExistingFromInv(ExchangeObjectTransfertExistingFromInvMessage message, WorldClient client) { AbstractTradeExchange dialog = client.Character.GetDialog <AbstractTradeExchange>(); Models.Entities.Inventory characterInventory = client.Character.Inventory; IEnumerable <ItemStack> transferableItems = from item in dialog.GetAllPresentItems() let characterItemRecord = characterInventory.GetItem(item.ItemUId) where characterItemRecord != null && item.Quantity > 0 select item; foreach (ItemStack item in transferableItems) { dialog.MoveItem(item.ItemUId, (int)item.Quantity); } }
public static void HandleExchangeSetCraftRecipe(ExchangeSetCraftRecipeMessage message, WorldClient client) { if (client.Character.IsInExchange(ExchangeTypeEnum.CRAFT)) { client.Character.GetDialog <CraftExchange>().SetRecipe(message.objectGID); } }
public override bool MoveKamas(WorldClient Client, long Quantity) { return(false); }
public static void HandleBidHouseSearch(ExchangeBidHouseSearchMessage message, WorldClient client) { if (client.Character.IsInExchange(ExchangeTypeEnum.BIDHOUSE_BUY)) { client.Character.GetDialog <BuyExchange>().ShowList(message.genId); } }
static void BuySell(WorldClient client, NpcSpawnRecord npc, NpcActionsRecord action) { client.Character.NpcShopExchange = new NpcBuySellExchange(client, action, npc); client.Character.NpcShopExchange.OpenPanel(); }
public static void HandleExchangeBidHouseBuy(ExchangeBidHouseBuyMessage message, WorldClient client) { if (client.Character.IsInExchange(ExchangeTypeEnum.BIDHOUSE_BUY)) { client.Character.GetDialog <BuyExchange>().Buy(message.uid, message.qty, message.price); } }
public static void HandleGuildGetInformations(GuildGetInformationsMessage message, WorldClient client) { switch ((GuildInformationsTypeEnum)message.infoType) { case GuildInformationsTypeEnum.INFO_GENERAL: SendGuildInformationsGeneral(client); break; case GuildInformationsTypeEnum.INFO_MEMBERS: SendGuildInformationsMembers(client); break; case GuildInformationsTypeEnum.INFO_BOOSTS: break; case GuildInformationsTypeEnum.INFO_PADDOCKS: break; case GuildInformationsTypeEnum.INFO_HOUSES: break; case GuildInformationsTypeEnum.INFO_TAX_COLLECTOR_GUILD_ONLY: break; case GuildInformationsTypeEnum.INFO_TAX_COLLECTOR_ALLIANCE: break; case GuildInformationsTypeEnum.INFO_TAX_COLLECTOR_LEAVE: break; } }
/// <summary> /// Connects to the world server. /// TODO: [LOW] make the connection process more aware. /// </summary> /// <param name="secretkey"></param> /// <returns></returns> public bool ConnectToWorld(string host, int port, string secretkey) { this.host = host; this.port = port; this.secretkey = secretkey; // TODO: [LOW] find a simpler way to set the account id. worldClient = new WorldClient(5, protocolVersion); worldClient.AccountId = this.accountId; worldClient.WorldConnected += new WorldClientEvent(HandleConnectEvent); worldClient.WorldDisconnected += new WorldClientEvent(HandleDisconnectEvent); worldClient.WorldMessageReceived += new WorldClientMsgEvent(HandleMessageReceivedEvent); State = WorldConnectionState.Connecting; if (worldClient.Connect(host, port)) { if (worldClient.Authenticate(secretkey)) { State = WorldConnectionState.Authenticating; return true; } else { disconnectMessage = "Unable to authenticate."; State = WorldConnectionState.Disconnected; worldClient.Dispose(); } } else { disconnectMessage = "Unable to connect."; State = WorldConnectionState.Disconnected; worldClient.Dispose(); } return false; }
public static void HandleGuildMotdSetRequest(GuildMotdSetRequestMessage message, WorldClient client) { if (client.Character.HasGuild) { // message.content = message.content.Replace('"', ' '); // message.content = message.content.Replace('\'', ' '); client.Character.Guild.SetMotd(client.Character.GuildMember, message.content); } }
public static void HandleExchangeObjectTransfertListFromInv(ExchangeObjectTransfertListFromInvMessage message, WorldClient client) { AbstractTradeExchange dialog = client.Character.GetDialog <AbstractTradeExchange>(); foreach (uint itemId in message.ids) { uint quantity = client.Character.Inventory.GetItem(itemId).Quantity; dialog.MoveItem(itemId, (int)quantity); } }
public static void HandleGuildInvitationMessage(GuildInvitationMessage message, WorldClient client) { if (client.Character.GuildMember.HasRight(GuildRightsBitEnum.GUILD_RIGHT_INVITE_NEW_MEMBERS)) { var target = WorldServer.Instance.GetOnlineClient((long)message.targetId); if (target == null) { client.Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 208); } else if (target.Character.HasGuild) { client.Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 206); } else if (target.Character.Busy) { client.Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 209); } else if (!client.Character.Guild.CanAddMember()) { client.Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 55, GuildProvider.MAX_MEMBERS_COUNT); } else { target.Character.OpenRequestBox(new GuildInvitation(client.Character, target.Character)); } } }
public ANS_FRIENDLIST_ADD(String charName, WorldClient client) : base((UInt32)Opcodes.ANS_FRIENDLIST_ADD) { MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM `characters` WHERE `name`= @name", WorldServer.Database.Connection.Instance); MySqlCommand cmd2 = new MySqlCommand("SELECT * FROM `characters` WHERE `name` = @name", WorldServer.Database.Connection.Instance); MySqlCommand cmd3 = new MySqlCommand("SELECT * FROM `clientstatus` WHERE `name` = @name", WorldServer.Database.Connection.Instance); try { cmd.Prepare(); cmd.Parameters.AddWithValue("@name", charName); cmd2.Prepare(); cmd2.Parameters.AddWithValue("@name", charName); cmd2.ExecuteNonQuery(); MySqlDataReader reader = cmd2.ExecuteReader(); try { while (reader.Read()) { charAccID = getAccID(reader); charID = getCharID(reader); faction = getFaction(reader); } } catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); } finally { reader.Close(); reader.Dispose(); } Byte rows = Convert.ToByte(cmd.ExecuteScalar()); cmd3.Prepare(); cmd3.Parameters.AddWithValue("@name", charName); cmd3.ExecuteNonQuery(); MySqlDataReader reader2 = cmd3.ExecuteReader(); if (client.Name == charName) { WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SELF); reader2.Close(); reader2.Dispose(); } else if (client.Name != charName) { if (client.AccountId == charAccID) { WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SAME_ACCOUNT); reader2.Close(); reader2.Dispose(); } else if (client.AccountId != charAccID) { if (rows < 1) { WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_INVALID_NAME); reader2.Close(); reader2.Dispose(); } else if (rows >= 1) { try { while (reader2.Read()) { districtID = getDistrictID(reader2); districtType = getDistrictType(reader2); isOnline = getOnlineStatus(reader2); isLfg = getLfgStatus(reader2); groupStatus = getGrpStatus(reader2); groupPubStatus = getGrpPubStatus(reader2); groupInvStatus = getGrpInvStatus(reader2); } } catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); } finally { reader2.Close(); reader2.Dispose(); } WriteUInt32((uint)ResponseCodes.RC_SUCCESS); WriteParsedString(charName); WriteByte(faction); WriteByte(isOnline); WriteUInt32Reverse(charID); WriteByte(isLfg); WriteByte(groupStatus); WriteByte(groupPubStatus); WriteByte(groupInvStatus); WriteUInt32((uint)(districtID & districtType)); WriteByte(0); //districtstatus } } } } finally { cmd.Dispose(); cmd2.Dispose(); cmd3.Dispose(); } }
public ZaapSkill(int skillId, WorldClient client) : base(skillId, client) { Console.WriteLine("Zaap todo"); }
public override bool Eval(WorldClient client) { return(true); }
public override bool Validate(WorldClient Client) { return(false); }
public NpcExchange(WorldClient Client, Npc Npc) { this.myClient = Client; this.Npc = Npc; }
public static void HandleExchangeBidhouseTypes(ExchangeBidHouseTypeMessage message, WorldClient client) { if (client.Character.IsInExchange(ExchangeTypeEnum.BIDHOUSE_BUY)) { client.Character.GetDialog <BuyExchange>().ShowTypes(message.type); } }
public static void HandleExchangeObjectTransfertAllFromInv(ExchangeObjectTransfertAllFromInvMessage message, WorldClient client) { AbstractTradeExchange dialog = client.Character.GetDialog <AbstractTradeExchange>(); foreach (CharacterItemRecord item in client.Character.Inventory.GetItems()) { dialog.MoveItem(item.UId, (int)item.Quantity); } }
public void Dispose() { try { if (worldClient != null) worldClient.Dispose(); worldClient = null; } finally { State = WorldConnectionState.Disconnected; } }
public static void HandleExchangeObjectMovePriced(ExchangeObjectMovePricedMessage message, WorldClient client) { if (client.Character.IsInExchange(ExchangeTypeEnum.BIDHOUSE_SELL)) { client.Character.GetDialog <SellExchange>().MoveItemPriced(message.objectUID, message.quantity, message.price); } }
public void savePlayer(WorldClient client) { UInt32 charID = NumericalUtils.ByteArrayToUint32(client.playerInstance.CharacterID.getValue(),1); string handle = StringUtils.charBytesToString_NZ(client.playerInstance.CharacterName.getValue()); int [] rsiValues = client.playerData.getRsiValues(); double x=0;double y=0;double z=0; byte[] Ltvector3d = client.playerInstance.Position.getValue(); NumericalUtils.LtVector3dToDoubles(Ltvector3d,ref x,ref y,ref z); int rotation =(int)client.playerInstance.YawInterval.getValue()[0]; string sqlQuery="update characters set x = '"+(float)x+"',y='"+(float)y+"',z='"+(float)z+"',rotation='"+rotation+"', districtId='" + client.playerData.getDistrictId()+"' where handle='"+handle+"';"; queryExecuter= conn.CreateCommand(); queryExecuter.CommandText = sqlQuery; Output.WriteLine(StringUtils.bytesToString(StringUtils.stringToBytes(sqlQuery))); Output.writeToLogForConsole(queryExecuter.ExecuteNonQuery() + " rows affecting saving"); string rsiQuery="update rsivalues set sex='"+rsiValues[0]+"',body='"+rsiValues[1]+"',hat='"+rsiValues[2]+"',face='"+rsiValues[3]+"',shirt='"+rsiValues[4]+"',coat='"+rsiValues[5]+"',pants='"+rsiValues[6]+"',shoes='"+rsiValues[7]+"',gloves='"+rsiValues[8]+"',glasses='"+rsiValues[9]+"',hair='"+rsiValues[10]+"',facialdetail='"+rsiValues[11]+"',shirtcolor='"+rsiValues[12]+"',pantscolor='"+rsiValues[13]+"',coatcolor='"+rsiValues[14]+"',shoecolor='"+rsiValues[15]+"',glassescolor='"+rsiValues[16]+"',haircolor='"+rsiValues[17]+"',skintone='"+rsiValues[18]+"',tattoo='"+rsiValues[19]+"',facialdetailcolor='"+rsiValues[20]+"',leggins='"+rsiValues[21]+"' where charId='"+charID+"';"; queryExecuter= conn.CreateCommand(); queryExecuter.CommandText = rsiQuery; Output.writeToLogForConsole("[WORLD DB ACCESS ]" + rsiQuery); queryExecuter.ExecuteNonQuery(); }
public static void HandleExchangeObjectMove(ExchangeObjectMoveMessage message, WorldClient client) { client.Character.GetDialog <Exchange>().MoveItem(message.objectUID, message.quantity); }