private void BeginReceive() { try { BroadcastSystem(General.Local(289)); byte[] msg = System.Text.Encoding.ASCII.GetBytes(" " + Server.Misc.ServerList.ServerName); c_Slave.Send(msg, 0, msg.Length, SocketFlags.None); c_Connected = true; c_Connecting = false; WaitForData(c_Slave); foreach (Data data in Data.Datas.Values) { if (data.Mobile.HasGump(typeof(MultiGump))) { GumpPlus.RefreshGump(data.Mobile, typeof(MultiGump)); } } } catch { Errors.Report("Error opening stream for slave."); //Console.WriteLine(e.Message); //Console.WriteLine(e.StackTrace); } }
public void CloseSlave() { try { if (c_Connected) { BroadcastSystem(General.Local(290)); } c_Connected = false; c_Connecting = false; if (c_Slave != null) { c_Slave.Close(); } foreach (Data data in Data.Datas.Values) { if (data.Mobile.HasGump(typeof(MultiGump))) { GumpPlus.RefreshGump(data.Mobile, typeof(MultiGump)); } } } catch { Errors.Report("Error disconnecting slave."); //Console.WriteLine(e.Message); //Console.WriteLine(e.Source); //Console.WriteLine(e.StackTrace); } }
public static void Save() { try { if (!Directory.Exists(General.SavePath)) { Directory.CreateDirectory(General.SavePath); } GenericWriter writer = new BinaryFileWriter(Path.Combine(General.SavePath, "Channels.bin"), true); writer.Write(0); // version writer.Write(s_Channels.Count); foreach (Channel c in s_Channels) { writer.Write(c.GetType().ToString()); c.Save(writer); } writer.Close(); } catch (Exception e) { Errors.Report(General.Local(187)); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public void Disconnect(bool reconn) { try { if (c_Connected) { BroadcastSystem(General.Local(110)); } c_Connected = false; c_Connecting = false; if (c_Thread != null) { try { c_Thread.Abort(); } catch { } c_Thread = null; } if (c_Reader != null) { c_Reader.Close(); } if (c_Writer != null) { c_Writer.Close(); } if (c_Tcp != null) { c_Tcp.Close(); } if (reconn) { Reconnect(); } foreach (Data data in Data.Datas.Values) { if (data.Mobile.HasGump(typeof(IrcGump))) { GumpPlus.RefreshGump(data.Mobile, typeof(IrcGump)); } } } catch (Exception e) { Errors.Report(General.Local(268), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public static void Load() { try { LoadGlobalOptions(); } catch (Exception e) { Errors.Report(General.Local(174), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { LoadPlayerOptions(); } catch (Exception e) { Errors.Report(General.Local(227), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { LoadFriends(); } catch (Exception e) { Errors.Report(General.Local(229), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { LoadIgnores(); } catch (Exception e) { Errors.Report(General.Local(231), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { LoadGlobalListens(); } catch (Exception e) { Errors.Report(General.Local(233), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { LoadMsgs(); } catch (Exception e) { Errors.Report(General.Local(235), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public static void Save() { try { SaveGlobalOptions(); } catch (Exception e) { Errors.Report(General.Local(175), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { SavePlayerOptions(); } catch (Exception e) { Errors.Report(General.Local(228), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { SaveFriends(); } catch (Exception e) { Errors.Report(General.Local(230), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { SaveIgnores(); } catch (Exception e) { Errors.Report(General.Local(232), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { SaveGlobalListens(); } catch (Exception e) { Errors.Report(General.Local(234), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } try { SaveMsgs(); } catch (Exception e) { Errors.Report(General.Local(236), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public static void Load() { try { if (!File.Exists(Path.Combine(General.SavePath, "Channels.bin"))) { PredefinedChannels(); return; } using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "Channels.bin"), FileMode.Open, FileAccess.Read, FileShare.Read)) { GenericReader reader = new BinaryFileReader(new BinaryReader(bin)); int version = reader.ReadInt(); int count = reader.ReadInt(); Channel c; for (int i = 0; i < count; ++i) { c = Activator.CreateInstance(ScriptCompiler.FindTypeByFullName(reader.ReadString())) as Channel; if (c == null) { c = new Channel(); c.Load(reader); s_Channels.Remove(c); } else { c.Load(reader); } } } PredefinedChannels(); } catch (Exception e) { Errors.Report(General.Local(186)); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public override void OnResponse(NetState state, RelayInfo info) { string name = ""; try { if (info.ButtonID == -5) { NewGump(); return; } foreach (TextRelay t in info.TextEntries) { c_Fields[c_Fields[t.EntryID].ToString()] = t.Text; } if (info.ButtonID == 0) { OnClose(); } if (c_Buttons[info.ButtonID] == null || !(c_Buttons[info.ButtonID] is ButtonPlus)) { return; } name = ((ButtonPlus)c_Buttons[info.ButtonID]).Name; ((ButtonPlus)c_Buttons[info.ButtonID]).Invoke(); } catch (Exception e) { Errors.Report("An error occured during a gump response. More information can be found on the console."); if (name != "") { Console.WriteLine("{0} gump name triggered an error.", name); } Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public void SendMaster(string str) { if (!c_Server || c_Master == null) { return; } try { byte[] msg = System.Text.Encoding.ASCII.GetBytes(" " + str); foreach (Socket sok in c_Clients) { sok.Send(msg, 0, msg.Length, SocketFlags.None); } } catch { Errors.Report("Error in sending to clients."); } }
private void ConnectStream() { try { c_Connecting = true; c_ConnectTimer = Server.Timer.DelayCall(TimeSpan.FromSeconds(30), new Server.TimerCallback(TimerFail)); c_LastPong = DateTime.Now; c_Reader = new StreamReader(c_Tcp.GetStream(), System.Text.Encoding.Default); c_Writer = new StreamWriter(c_Tcp.GetStream(), System.Text.Encoding.Default); BroadcastSystem(General.Local(107)); SendMessage(String.Format("USER {0} 1 * :Hello!", Data.IrcNick)); SendMessage(String.Format("NICK {0}", Data.IrcNick)); c_Thread = new Thread(new ThreadStart(ReadStream)); c_Thread.Start(); Server.Timer.DelayCall(TimeSpan.FromSeconds(15.0), new Server.TimerCallback(Names)); foreach (Data data in Data.Datas.Values) { if (data.Mobile.HasGump(typeof(IrcGump))) { GumpPlus.RefreshGump(data.Mobile, typeof(IrcGump)); } } } catch (Exception e) { Errors.Report(General.Local(266), e); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
private void HandleInput(string str) { try { if (str == null) { return; } BroadcastRaw(str); if (str.IndexOf("PONG") != -1 || str.IndexOf("PING") != -1) { PingPong(str); return; } if (str.IndexOf("353") != -1) { BroadcastRaw(General.Local(109)); int index = str.ToLower().IndexOf(Data.IrcRoom.ToLower()) + Data.IrcRoom.Length + 2; if (index == 1) { return; } string strList = str.Substring(index, str.Length - index); string[] strs = strList.Trim().Split(' '); Data.IrcList.Clear(); Data.IrcList.AddRange(strs); Data.IrcList.Remove(Data.IrcNick); } if (str.IndexOf("001") != -1 && c_Connecting) { c_Connected = true; c_Connecting = false; if (c_ConnectTimer != null) { c_ConnectTimer.Stop(); } BroadcastSystem(General.Local(108)); c_Attempts = 1; SendMessage(String.Format("JOIN {0}", Data.IrcRoom)); foreach (Data data in Data.Datas.Values) { if (data.Mobile.HasGump(typeof(IrcGump))) { GumpPlus.RefreshGump(data.Mobile, typeof(IrcGump)); } } } if (str.Length > 300) { return; } if (str.IndexOf("PRIVMSG") != -1) { string parOne = str.Substring(1, str.IndexOf("!") - 1); string parThree = str.Substring(str.IndexOf("!") + 1, str.Length - str.IndexOf("!") - (str.Length - str.IndexOf("PRIVMSG")) - 1); int index = 0; index = str.ToLower().IndexOf(Data.IrcRoom.ToLower()) + Data.IrcRoom.Length + 2; if (index == 1) { return; } string parTwo = str.Substring(index, str.Length - index); if (parTwo.IndexOf("ACTION") != -1) { index = parTwo.IndexOf("ACTION") + 7; parTwo = parTwo.Substring(index, parTwo.Length - index); str = String.Format("<{0}> {1} {2}", Data.IrcRoom, parOne, parTwo); } else { str = String.Format("<{0}> {1}: {2}", Data.IrcRoom, parOne, parTwo); } Broadcast(parOne, str); if (str.ToLower().IndexOf("!status") != -1 && c_NextStatus < DateTime.Now) { c_NextStatus = DateTime.Now + TimeSpan.FromSeconds(15); s_Connection.SendMessage(String.Format("PRIVMSG {0} : {1}", Data.IrcRoom, Status)); BroadcastSystem(Status); } } } catch (Exception e) { Errors.Report(General.Local(267), e); Console.WriteLine(e.Message); Console.WriteLine(e.Message); Console.WriteLine(e.Message); } }
private void ModifyGump() { try { AddPage(0); int maxWidth = 0; int maxHeight = 0; GumpBackground bg; foreach (GumpEntry entry in Entries) { if (entry is GumpBackground) { bg = (GumpBackground)entry; if (bg.X + bg.Width > maxWidth) { maxWidth = bg.X + bg.Width; } if (bg.Y + bg.Height > maxHeight) { maxHeight = bg.Y + bg.Height; } } } if (Owner.AccessLevel >= AccessLevel.Administrator || !GumpInfo.ForceMenu) { AddImage(maxWidth, maxHeight, 0x28DC, GumpInfo.ForceMenu ? 0x26 : 0x387); AddButton(maxWidth + 10, maxHeight + 4, 0x93A, 0x93A, "Transparency", new GumpCallback(Trans)); AddButton(maxWidth + 10, maxHeight + 15, 0x938, 0x938, "Default", new GumpCallback(Default)); if (Owner.AccessLevel >= AccessLevel.Administrator) { AddButton(maxWidth + 10, maxHeight + 26, 0x82C, 0x82C, "ForceMenu", new GumpCallback(Force)); } AddButton(maxWidth - 5, maxHeight + 2, 0x2626, 0x2627, "BackgroundDown", new GumpCallback(BackDown)); AddButton(maxWidth + 19, maxHeight + 2, 0x2622, 0x2623, "BackgroundUp", new GumpCallback(BackUp)); AddButton(maxWidth - 5, maxHeight + 13, 0x2626, 0x2627, "TextColorDown", new GumpCallback(TextDown)); AddButton(maxWidth + 19, maxHeight + 13, 0x2622, 0x2623, "TextColorUp", new GumpCallback(TextUp)); } if (!GumpInfo.HasMods(c_Owner, GetType())) { return; } ArrayList backs = new ArrayList(); foreach (GumpEntry entry in new ArrayList(Entries)) { if (entry is GumpBackground) { if (entry is BackgroundPlus && !((BackgroundPlus)entry).Override) { continue; } if (Info.Background != -1) { ((GumpBackground)entry).GumpID = Info.Background; } backs.Add(entry); } else if (entry is GumpAlphaRegion && !Info.DefaultTrans && !Info.Transparent) { ((GumpAlphaRegion)entry).Width = 0; ((GumpAlphaRegion)entry).Height = 0; } else if (entry is HtmlPlus) { if (!((HtmlPlus)entry).Override || Info.TextColorRGB == "") { continue; } string text = ((HtmlPlus)entry).Text; int num = 0; int length = 0; char[] chars; if (text == null) { continue; } while ((num = text.ToLower().IndexOf("<basefont")) != -1 || (num = text.ToLower().IndexOf("</font")) != -1) { length = 0; chars = text.ToCharArray(); for (int i = num; i < chars.Length; ++i) { if (chars[i] == '>') { length = i - num + 1; break; } } if (length == 0) { break; } text = text.Substring(0, num) + text.Substring(num + length, text.Length - num - length); } ((HtmlPlus)entry).Text = Info.TextColor + text; } } if (!Info.DefaultTrans && Info.Transparent) { foreach (GumpBackground back in backs) { AddAlphaRegion(back.X, back.Y, back.Width, back.Height); } } SortEntries(); } catch { Errors.Report("GumpPlus-> ModifyGump-> " + GetType()); } }
public static string FilterText(Mobile m, string s, bool punish) { try { string filter = ""; //string subOne = ""; //string subTwo = ""; //string subThree = ""; int index = 0; for (int i = 0; i < Data.Filters.Count; ++i) { filter = Data.Filters[i].ToString(); if (filter == "") { Data.Filters.Remove(filter); continue; } index = s.ToLower().IndexOf(filter); if (index >= 0) { if (m.AccessLevel == AccessLevel.Player && punish) { if (++Data.GetData(m).Warnings <= Data.FilterWarnings) { m.SendMessage(Data.GetData(m).SystemC, General.Local(111) + " " + filter); } else { Data.GetData(m).Warnings = 0; Events.InvokeFilterViolation(new FilterViolationEventArgs(m)); if (Data.FilterPenalty == FilterPenalty.Ban) { Data.GetData(m).Ban(TimeSpan.FromMinutes(Data.FilterBanLength)); } if (Data.FilterPenalty == FilterPenalty.Jail) { ChatJail.SendToJail(m); } if (Data.FilterPenalty != FilterPenalty.None) { return(""); } } } if (m.AccessLevel == AccessLevel.Player) { m.SendAsciiMessage("Harassing and excessive swearing is not allowed! Repeated offences will get you jailed!"); return(""); } m.SendAsciiMessage("You are staff so you can swear, but please try not to."); /* * subOne = s.Substring(0, index); * subTwo = ""; * * for (int ii = 0; ii < filter.Length; ++ii) * subTwo += "*"; * * subThree = s.Substring(index + filter.Length, s.Length - filter.Length - index); * * s = subOne + subTwo + subThree; * * i--;*/ } } } catch { Errors.Report(General.Local(176)); } return(s); }
public static string FilterText(Mobile m, string s, bool punish) { try { string filter = ""; string subOne = ""; string subTwo = ""; string subThree = ""; int index = 0; for (int i = 0; i < Data.Filters.Count; ++i) { filter = Data.Filters[i].ToString(); if (filter == "") { Data.Filters.Remove(filter); continue; } index = s.ToLower().IndexOf(filter); if (index >= 0) { if (m.AccessLevel == AccessLevel.Player && punish) { if (++Data.GetData(m).Warnings <= Data.FilterWarnings) { m.SendMessage(Data.GetData(m).SystemC, General.Local(111) + " " + filter); } else { Data.GetData(m).Warnings = 0; Events.InvokeFilterViolation(new FilterViolationEventArgs(m)); if (Data.FilterPenalty == FilterPenalty.Ban) { Data.GetData(m).Ban(TimeSpan.FromMinutes(Data.FilterBanLength)); } if (Data.FilterPenalty == FilterPenalty.Jail) { ChatJail.SendToJail(m); } if (Data.FilterPenalty != FilterPenalty.None) { return(""); } } } subOne = s.Substring(0, index); subTwo = ""; for (int ii = 0; ii < filter.Length; ++ii) { subTwo += "*"; } subThree = s.Substring(index + filter.Length, s.Length - filter.Length - index); s = subOne + subTwo + subThree; i--; } } } catch { Errors.Report(General.Local(176)); } return(s); }
public static void Save() { try { if (!Directory.Exists(General.SavePath)) { Directory.CreateDirectory(General.SavePath); } GenericWriter writer = new BinaryFileWriter(Path.Combine(General.SavePath, "Gumps.bin"), true); writer.Write(0); // version writer.Write(s_ForceMenu); writer.Write(s_ForceInfos.Count); foreach (GumpInfo ginfo in s_ForceInfos.Values) { ginfo.Save(writer); } ArrayList list = new ArrayList(); GumpInfo info; foreach (object o in new ArrayList(s_Infos.Values)) { if (!(o is Hashtable)) { continue; } foreach (object ob in new ArrayList(((Hashtable)o).Values)) { if (!(ob is GumpInfo)) { continue; } info = (GumpInfo)ob; if (info.Mobile != null && info.Mobile.Player && !info.Mobile.Deleted && info.Mobile.Account != null && ((Account)info.Mobile.Account).LastLogin > DateTime.Now - TimeSpan.FromDays(30)) { list.Add(ob); } } } writer.Write(list.Count); foreach (GumpInfo ginfo in list) { ginfo.Save(writer); } writer.Close(); } catch (Exception e) { Errors.Report(General.Local(199)); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }
public static void Load() { try { if (!File.Exists(Path.Combine(General.SavePath, "Gumps.bin"))) { return; } using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "Gumps.bin"), FileMode.Open, FileAccess.Read, FileShare.Read)) { GenericReader reader = new BinaryFileReader(new BinaryReader(bin)); int version = reader.ReadInt(); if (version >= 0) { s_ForceMenu = reader.ReadBool(); int count = reader.ReadInt(); GumpInfo info; for (int i = 0; i < count; ++i) { info = new GumpInfo(); info.Load(reader); if (info.Type == null) { continue; } s_ForceInfos[info.Type] = info; } count = reader.ReadInt(); for (int i = 0; i < count; ++i) { info = new GumpInfo(); info.Load(reader); if (info.Mobile == null || info.Type == null) { continue; } if (s_Infos[info.Mobile] == null) { s_Infos[info.Mobile] = new Hashtable(); } ((Hashtable)s_Infos[info.Mobile])[info.Type] = info; } } reader.End(); } } catch (Exception e) { Errors.Report(General.Local(198)); Console.WriteLine(e.Message); Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace); } }