예제 #1
0
		private static void SendGuildBankList(Character chr, GameObject bank, byte tabId, bool hasTabNames, bool hasItemInfo)
		{
			if (bank == null) return;
			if (chr.Guild == null || chr.GuildMember == null) return;
			if (!bank.CanBeUsedBy(chr)) return;

			var guild = chr.Guild;
			var gBank = guild.Bank;

			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GUILD_BANK_LIST))
			{
				packet.Write(guild.Money);
				packet.Write(tabId);
				packet.Write(chr.GuildMember.Rank.BankTabRights[tabId].WithdrawlAllowance);
				var sendHasTabNames = tabId == 0 ? hasTabNames : false;
				packet.Write(sendHasTabNames);

				if (sendHasTabNames)
				{
					packet.Write((byte)guild.PurchasedBankTabCount);
					for (var i = 0; i < guild.PurchasedBankTabCount; ++i)
					{
						packet.Write(gBank[i].Name);
						packet.Write(gBank[i].Icon);
					}
				}

				if (!hasItemInfo)
				{
					chr.Client.Send(packet);
					return;
				}

				var bankTab = gBank[tabId];

				var bankTabItemCount = bankTab.ItemRecords.Where(record => record != null).Count();
				packet.Write((byte)bankTabItemCount);

				foreach (var item in bankTab.ItemRecords.Where(record => record != null))
				{
					packet.Write((byte)item.Slot);

					packet.Write(item.EntryId);

					packet.Write((uint)0);                  // 3.3.0 (0x8000, 0x8020)
					var randPropId = item.RandomProperty;
					packet.Write(randPropId);
					if (randPropId > 0)
					{
						packet.Write(item.RandomSuffix);
					}

					packet.Write(item.Amount);
					packet.Write((uint)0);
					packet.Write((byte)0);

					if (item.EnchantIds == null)
					{
						packet.Write((byte)0);
						continue;
					}

					var pos = packet.Position;
					var count = 0;
					for (var i = 0; i < 3; ++i)
					{
						if (item.EnchantIds[i] == 0) continue;
						packet.Write((byte)i);
						packet.Write(item.EnchantIds[i]);
						count++;
					}
					packet.InsertByteAt((byte)count, pos, true);

				}

				chr.Client.Send(packet);
			}
		}
예제 #2
0
		private static void SendGuildBankTabContentUpdate(GuildMember member, byte tabId, int slot1, int slot2)
		{
			// lock-free synchronization
			// don't mess with it, unless you know what you are doing
			var guild = member.Guild;
			if (guild == null) return;

			var rank = member.Rank;
			if (rank == null) return;


			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GUILD_BANK_LIST))
			{
				packet.Write(guild.Money);
				packet.Write(tabId);

				packet.Write(rank.BankTabRights[tabId].WithdrawlAllowance);
				packet.Write(false); // hasTabnames = false;

				var list = new List<int> 
				{
					slot1
                };

				if (slot2 != -1)
				{
					list.Add(slot2);
					list.Sort();
				}

				packet.WriteByte((byte)list.Count);
				foreach (var slot in list)
				{
					packet.Write((byte)slot);
					var item = guild.Bank[tabId][slot];

					if (item == null)
					{
						packet.Write(0);
						continue;
					}
					packet.Write(item.EntryId);
					packet.Write((uint)0);

					var randomPropId = item.RandomProperty;
					packet.Write(randomPropId);
					if (randomPropId != 0)
					{
						packet.Write(item.RandomSuffix);
					}

					packet.Write(item.Amount);
					packet.Write((uint)0);
					packet.Write((byte)0);

					if (item.EnchantIds == null)
					{
						packet.Write((byte)0);
						continue;
					}

					var pos = packet.Position;
					var count = 0;
					for (var i = 0; i < 3; ++i)
					{
						if (item.EnchantIds[i] == 0) continue;
						packet.Write((byte)i);
						packet.Write(item.EnchantIds[i]);
						count++;
					}
					packet.InsertByteAt((byte)count, pos, true);

				} // end foreach

				guild.Send(packet);
			} // end using
		}