public void PostMessage(Mobile from, BulletinMessage thread, string subject, string[] lines) { if (thread != null) { thread.LastPostTime = DateTime.UtcNow; } AddItem(new BulletinMessage(from, thread, subject, lines)); }
public static void BBPostMessage(Mobile from, BaseBulletinBoard board, PacketReader pvSrc) { BulletinMessage thread = World.FindItem(pvSrc.ReadInt32()) as BulletinMessage; if (thread != null && thread.Parent != board) { thread = null; } int breakout = 0; while (thread != null && thread.Thread != null && breakout++ < 10) { thread = thread.Thread; } DateTime lastPostTime = DateTime.MinValue; if (board.GetLastPostTime(from, (thread == null), ref lastPostTime)) { if (!CheckTime(lastPostTime, (thread == null ? ThreadCreateTime : ThreadReplyTime))) { if (thread == null) { from.SendMessage("You must wait {0} before creating a new thread.", FormatTS(ThreadCreateTime)); } else { from.SendMessage("You must wait {0} before replying to another thread.", FormatTS(ThreadReplyTime)); } return; } } string subject = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte()); if (subject.Length == 0) { return; } string[] lines = new string[pvSrc.ReadByte()]; if (lines.Length == 0) { return; } for (int i = 0; i < lines.Length; ++i) { lines[i] = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte()); } board.PostMessage(from, thread, subject, lines); }
public static void BBRequestHeader(Mobile from, BaseBulletinBoard board, PacketReader pvSrc) { BulletinMessage msg = World.FindItem(pvSrc.ReadInt32()) as BulletinMessage; if (msg == null || msg.Parent != board) { return; } from.Send(new BBMessageHeader(board, msg)); }
public BBMessageContent(BaseBulletinBoard board, BulletinMessage msg) : base(0x71) { string poster = SafeString(msg.PostedName); string subject = SafeString(msg.Subject); string time = SafeString(msg.GetTimeAsString()); EnsureCapacity(22 + poster.Length + subject.Length + time.Length); Stream.Write((byte)0x02); // PacketID Stream.Write((int)board.Serial); // Bulletin board serial Stream.Write((int)msg.Serial); // Message serial WriteString(poster); WriteString(subject); WriteString(time); Stream.Write((short)msg.PostedBody); Stream.Write((short)msg.PostedHue); int len = msg.PostedEquip.Length; if (len > 255) { len = 255; } Stream.Write((byte)len); for (int i = 0; i < len; ++i) { BulletinEquip eq = msg.PostedEquip[i]; Stream.Write((short)eq.itemID); Stream.Write((short)eq.hue); } len = msg.Lines.Length; if (len > 255) { len = 255; } Stream.Write((byte)len); for (int i = 0; i < len; ++i) { WriteString(msg.Lines[i], true); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 1: case 0: { m_Poster = reader.ReadMobile(); m_Subject = reader.ReadString(); m_Time = reader.ReadDateTime(); m_LastPostTime = reader.ReadDateTime(); bool hasThread = reader.ReadBool(); m_Thread = reader.ReadItem() as BulletinMessage; m_PostedName = reader.ReadString(); m_PostedBody = reader.ReadInt(); m_PostedHue = reader.ReadInt(); m_PostedEquip = new BulletinEquip[reader.ReadInt()]; for (int i = 0; i < m_PostedEquip.Length; ++i) { m_PostedEquip[i].itemID = reader.ReadInt(); m_PostedEquip[i].hue = reader.ReadInt(); } m_Lines = new string[reader.ReadInt()]; for (int i = 0; i < m_Lines.Length; ++i) { m_Lines[i] = reader.ReadString(); } if (hasThread && m_Thread == null) { Delete(); } if (version == 0) { ValidationQueue <BulletinMessage> .Add(this); } break; } } }
public static void BBRemoveMessage(Mobile from, BaseBulletinBoard board, PacketReader pvSrc) { BulletinMessage msg = World.FindItem(pvSrc.ReadInt32()) as BulletinMessage; if (msg == null || msg.Parent != board) { return; } if (from.AccessLevel < AccessLevel.GameMaster && msg.Poster != from) { return; } msg.Delete(); }