public void LoadEliteDrops() { try { EliteDrops.Clear(); var pathArray = Directory.GetFiles(Settings.DropPath + @".\Elites\", Name + ".txt", SearchOption.TopDirectoryOnly); string path = string.Empty; if (pathArray.Length > 0) { path = pathArray[0]; } if (!File.Exists(path)) { // Create a dummy/empty return; } string[] lines = File.ReadAllLines(path); for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith(";") || string.IsNullOrWhiteSpace(lines[i])) { continue; } EliteDropInfo drop = EliteDropInfo.FromLine(lines[i], Name); if (drop == null) { SMain.Enqueue(string.Format("Could not load Drop: {0}, Line {1}", Name, lines[i])); continue; } EliteDrops.Add(drop); } } catch (Exception ex) { SMain.Enqueue(ex); } }
public void SaveProgressMagicDB(List <AccountInfo> AccountListDB) { try { MySqlConnection connectionMagics = new MySqlConnection(); //star conection String connectionString; connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True"; connectionMagics.ConnectionString = connectionString; connectionMagics.Open(); for (int i = 0; i < AccountListDB.Count; i++) { string sqlMagics; for (int c = 0; c < AccountListDB[i].Characters.Count; c++) { for (int mm = 0; mm < AccountListDB[i].Characters[c].Magics.Count; mm++) { sqlMagics = "INSERT INTO " + Settings.DBAccount + ".magics (Spell, ChName, Level, Key_, Experience, IsTempSpell, CastTime) VALUES (@Spell, @ChName, @Level, @Key_, @Experience, @IsTempSpell, @CastTime)"; using (var command = new MySqlCommand(sqlMagics, connectionMagics)) { command.Parameters.AddWithValue("@Spell", AccountListDB[i].Characters[c].Magics[mm].Spell); command.Parameters.AddWithValue("@ChName", AccountListDB[i].Characters[c].Name); command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Magics[mm].Level); command.Parameters.AddWithValue("@Key_", AccountListDB[i].Characters[c].Magics[mm].Key); command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Magics[mm].Experience); command.Parameters.AddWithValue("@IsTempSpell", AccountListDB[i].Characters[c].Magics[mm].IsTempSpell); command.Parameters.AddWithValue("@CastTime", AccountListDB[i].Characters[c].Magics[mm].CastTime); command.ExecuteNonQuery(); command.Dispose(); } } } } connectionMagics.Close(); } catch (MySqlException ex) { SMain.Enqueue(ex); } }
static void Run() { using (XnaGate gate = new XnaGate()) { gate.DragFiles = (strs) => SMain.DragFile(strs); gate.OnInitialized += new Action <EntryEngine.Entry>(gate_OnInitialized); try { gate.Run(); } catch (Exception ex) { #if DEBUG Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ReadKey(); #endif } } }
public MirConnection(int sessionID, TcpClient client) { SessionID = sessionID; IPAddress = client.Client.RemoteEndPoint.ToString().Split(':')[0]; SMain.Enqueue(IPAddress + ", Connected."); _client = client; _client.NoDelay = true; TimeConnected = SMain.Envir.Time; TimeOutTime = TimeConnected + Settings.TimeOut; _receiveList = new ConcurrentQueue <Packet>(); _sendList = new Queue <Packet>(new[] { new S.Connected() }); _retryList = new Queue <Packet>(); Connected = true; BeginReceive(); }
private List <string> ParseInsert(List <string> lines) { List <string> newLines = new List <string>(); for (int i = 0; i < lines.Count; i++) { if (!lines[i].ToUpper().StartsWith("#INSERT")) { continue; } string[] split = lines[i].Split(' '); if (split.Length < 2) { continue; } string path = Path.Combine(Settings.EnvirPath, split[1].Substring(1, split[1].Length - 2)); if (!File.Exists(path)) { SMain.Enqueue(string.Format("File Not Found: {0}, NPC: {1}", path, Info.Name)); } else { newLines = File.ReadAllLines(path).ToList(); } lines.AddRange(newLines); } lines.RemoveAll(str => str.ToUpper().StartsWith("#INSERT")); return(lines); }
private void LoadIngredients(string recipe) { List <string> lines = File.ReadAllLines(Settings.RecipePath + recipe + ".txt").ToList(); Ingredients = new List <UserItem>(); for (int i = 0; i < lines.Count; i++) { if (String.IsNullOrEmpty(lines[i])) { continue; } var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = SMain.Envir.GetItemInfo(data[0]); if (info == null) { SMain.Enqueue(string.Format("Could not find Item: {0}, Recipe: {1}", lines[i], recipe)); continue; } uint count = 1; if (data.Length == 2) { uint.TryParse(data[1], out count); } UserItem ingredient = SMain.Envir.CreateShopItem(info); ingredient.Count = count > info.StackSize ? info.StackSize : count; Ingredients.Add(ingredient); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); SMain.SetUpView(RespawnInfoGridView); }
private void MapInfoView_Load(object sender, EventArgs e) { SMain.SetUpView(MapInfoGridView); SMain.SetUpView(GuardsGridView); SMain.SetUpView(RegionGridView); }
public MailInfo(MySqlDataReader readerMail) { MailID = Convert.ToUInt32(readerMail["MailID"]); Sender = readerMail["Sender"].ToString(); RecipientIndex = Convert.ToInt32(readerMail["RecipientIndex"]); Message = readerMail["Message"].ToString(); Gold = Convert.ToUInt32(readerMail["Gold"]); ItemCount = Convert.ToInt32(readerMail["ItemCount"]); if (ItemCount > 0) { try { MySqlConnection connection = new MySqlConnection(); //star conection String connectionString; connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True"; connection.ConnectionString = connectionString; connection.Open(); MySqlCommand instruccion = connection.CreateCommand(); instruccion.CommandText = "SELECT * FROM " + Settings.DBAccount + ".mailitems WHERE MailID = '" + MailID + "'"; MySqlDataReader readerAuctions = instruccion.ExecuteReader(); while (readerAuctions.Read()) { UserItem AddItem = new UserItem(readerAuctions); if (SMain.Envir.BindItem(AddItem)) { Items.Add(AddItem); } } readerAuctions.Dispose(); for (int i = 0; i < Items.Count; i++) { if (Items[i].IsAwake) { MySqlCommand instruccionAwake = connection.CreateCommand(); instruccionAwake.CommandText = "SELECT * FROM " + Settings.DBAccount + ".mailitems WHERE UniqueID = '" + Items[i].UniqueID + "' ORDER BY Position"; MySqlDataReader readerAwakeDB = instruccionAwake.ExecuteReader(); Items[i].Awake = new Awake(); Items[i].Awake.type = (AwakeType)Convert.ToInt32(Items[i].AwakeType); while (readerAwakeDB.Read()) { Items[i].Awake.listAwake.Add(Convert.ToByte(readerAwakeDB["Value"])); } readerAwakeDB.Dispose(); } if (Items[i].IsAttached) { MySqlCommand instruccionAttached = connection.CreateCommand(); instruccionAttached.CommandText = "SELECT * FROM " + Settings.DBAccount + ".mailitems WHERE Attached = '" + Items[i].UniqueID + "' ORDER BY Position"; MySqlDataReader readerAttachedDB = instruccionAttached.ExecuteReader(); Items[i].Awake = new Awake(); Items[i].Awake.type = (AwakeType)Convert.ToInt32(Items[i].AwakeType); while (readerAttachedDB.Read()) { Items[i].Awake.listAwake.Add(Convert.ToByte(readerAttachedDB["Value"])); } readerAttachedDB.Dispose(); } } connection.Close(); } catch (MySqlException ex) { SMain.Enqueue(ex); } } DateSent = readerMail.GetDateTime(readerMail.GetOrdinal("DateSent")); DateOpened = readerMail.GetDateTime(readerMail.GetOrdinal("DateOpened")); Locked = Convert.ToBoolean(readerMail["Locked"]); Collected = Convert.ToBoolean(readerMail["Collected"]); CanReply = Convert.ToBoolean(readerMail["CanReply"]); }
public void CheckExternalLogin(C.ExternalToolLogin p) { if (p.Password.Length < 4 || p.Username.Length < 4) { Enqueue(new S.ExternalToolLogin { Result = 1 }); SMain.EnqueueDebugging(string.Format("[Server Manager] {0} login failure -1", IPAddress)); return; } if (Settings.ManagerUsers != null && Settings.ManagerUsers.Count > 0) { byte result = 0; bool userNameFound = false; for (int i = 0; i < Settings.ManagerUsers.Count; i++) { if (userNameFound) { continue; } if (Settings.ManagerUsers[i].UserName.ToUpper() == p.Username.ToUpper()) { userNameFound = true; if (Settings.ManagerUsers[i].Password == p.Password) { result = 0; } else { result = 1; } } } if (!userNameFound) { result = 2; } if (result == 0) { LoggedIn = true; ManagerUser = p.Username; Enqueue(new S.ExternalToolLogin { Result = result }); SMain.EnqueueDebugging(string.Format("[Server Manager] {0} login success", IPAddress)); return; } else { Enqueue(new S.ExternalToolLogin { Result = result }); SMain.EnqueueDebugging(string.Format("[Server Manager] {0} Login Failure -{1}", IPAddress, result)); return; } } else { Enqueue(new S.ExternalToolLogin { Result = 3 }); SMain.EnqueueDebugging(string.Format("[Server Manager] {0} No such user", IPAddress)); return; } }
public void Process() { if (SMain.Envir.Time > processMsgTime) { processMsgTime = SMain.Envir.Time + 1500; Enqueue(new S.KeepAlive { Time = SMain.Envir.Time }); } if (SMain.Envir.Running) { if (SMain.Envir.Time > playerListCounter) { playerListCounter = SMain.Envir.Time + Settings.Minute; if (SMain.Envir.Players == null || SMain.Envir.Players.Count <= 0) { } else { List <ToolOnlinePlayerListItem> players = new List <ToolOnlinePlayerListItem>(); for (int i = 0; i < SMain.Envir.Players.Count; i++) { PlayerObject pOb = SMain.Envir.Players[i]; players.Add(new ToolOnlinePlayerListItem { PlayerName = pOb.Name, PlayerGuild = pOb.MyGuild != null ? pOb.MyGuild.Name : "NONE", PlayerLevel = pOb.Level, PlayerCurrentMap = pOb.CurrentMap.Info.Title, PlayerCurrentLocation = string.Format("X:[{0}] Y:[{1}]", pOb.CurrentLocation.X, pOb.CurrentLocation.Y), AccountGold = pOb.Account.Gold, AccountCredit = pOb.Account.Credit }); } if (players != null && players.Count > 0) { Enqueue(new S.ToolPlayerList { Players = players }); } } } } if (_client == null || !_client.Connected || _receiveList == null || _retryList == null) { Disconnect(); return; } while (!_receiveList.IsEmpty && !Disconnecting) { if (DebugMode) { SMain.EnqueueDebugging(string.Format("[ServerManager][IN]Processing..")); } if (!_receiveList.TryDequeue(out Packet p)) { continue; } ProcessPacket(p); } while (_retryList.Count > 0) { if (!_retryList.TryDequeue(out Packet p) || p == null) { continue; } _receiveList.Enqueue(p); } if (_sendList == null || _sendList.Count <= 0) { return; } List <byte> data = new List <byte>(); while (_sendList.Count > 0) { if (DebugMode) { SMain.EnqueueDebugging(string.Format("[ServerManager][OUT]Processing..")); } if (!_sendList.TryDequeue(out Packet p) || p == null) { continue; } data.AddRange(p.GetPacketBytes()); } //BeginReceive(); BeginSend(data); }
public void SaveProgressDB(List <AccountInfo> AccountListDB) { var timer = Stopwatch.StartNew(); try { MySqlConnection connectioninfo = new MySqlConnection(); //star conection String connectionString; connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True"; connectioninfo.ConnectionString = connectionString; connectioninfo.Open(); for (int iii = 0; iii < 1; iii++) { for (int i = 0; i < AccountListDB.Count; i++) { string sqlAccount = "UPDATE " + Settings.DBAccount + ".account SET Gold = @Gold, Credit = @Credit WHERE AccountID = '" + AccountListDB[i].AccountID + "'"; using (var command = new MySqlCommand(sqlAccount, connectioninfo)) { command.Parameters.AddWithValue("@Gold", AccountListDB[i].Gold); command.Parameters.AddWithValue("@Credit", AccountListDB[i].Credit); command.ExecuteNonQuery(); command.Dispose(); } for (int c = 0; c < AccountListDB[i].Characters.Count; c++) { string sqlCharacterinfo = "UPDATE " + Settings.DBAccount + ".characterinfo SET Level = @Level, CurrentMapIndex = @CurrentMapIndex, CurrentLocation_X = @CurrentLocation_X, CurrentLocation_Y = @CurrentLocation_Y, Direction = @Direction, BindMapIndex = @BindMapIndex, BindLocation_X = @BindLocation_X, BindLocation_Y = @BindLocation_Y, Experience = @Experience, MentorExp = @MentorExp, PKPoints = @PKPoints WHERE AccountID = '" + AccountListDB[i].AccountID + "' AND IndexID = '" + AccountListDB[i].Characters[c].Index + "'"; using (var command = new MySqlCommand(sqlCharacterinfo, connectioninfo)) { command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Level); command.Parameters.AddWithValue("@CurrentMapIndex", AccountListDB[i].Characters[c].CurrentMapIndex); command.Parameters.AddWithValue("@CurrentLocation_X", AccountListDB[i].Characters[c].CurrentLocation.X); command.Parameters.AddWithValue("@CurrentLocation_Y", AccountListDB[i].Characters[c].CurrentLocation.Y); command.Parameters.AddWithValue("@Direction", AccountListDB[i].Characters[c].Direction); command.Parameters.AddWithValue("@BindMapIndex", AccountListDB[i].Characters[c].BindMapIndex); command.Parameters.AddWithValue("@BindLocation_X", AccountListDB[i].Characters[c].BindLocation.X); command.Parameters.AddWithValue("@BindLocation_Y", AccountListDB[i].Characters[c].BindLocation.Y); command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Experience); command.Parameters.AddWithValue("@MentorExp", AccountListDB[i].Characters[c].MentorExp); command.Parameters.AddWithValue("@PKPoints", AccountListDB[i].Characters[c].PKPoints); command.ExecuteNonQuery(); command.Dispose(); } for (int mm = 0; mm < AccountListDB[i].Characters[c].Magics.Count; mm++) { if (AccountListDB[i].Characters[c].Magics[mm].Level < 3 || AccountListDB[i].Characters[c].Magics[mm].Spell == Spell.Fury || AccountListDB[i].Characters[c].Magics[mm].Spell == Spell.ImmortalSkin || AccountListDB[i].Characters[c].Magics[mm].Spell == Spell.SwiftFeet) { int IdSpell = Convert.ToInt32(AccountListDB[i].Characters[c].Magics[mm].Spell); string sqlMagics = "UPDATE " + Settings.DBAccount + ".magics SET Level = @Level, Experience = @Experience, Key_ = @Key_ WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' And Spell = '" + IdSpell + "' "; using (var command = new MySqlCommand(sqlMagics, connectioninfo)) { command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Magics[mm].Level); command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Magics[mm].Experience); command.Parameters.AddWithValue("@Key_", AccountListDB[i].Characters[c].Magics[mm].Key); command.ExecuteNonQuery(); command.Dispose(); } } } for (int ee = 0; ee < AccountListDB[i].Characters[c].Equipment.Length; ee++) { if (AccountListDB[i].Characters[c].Equipment[ee] == null) { continue; } string sqlEquipment = "UPDATE " + Settings.DBAccount + ".inventory SET CurrentDura = @CurrentDura, MaxDura = @MaxDura, Count = @Count, Cursed = @Cursed, ExpireInfo = @ExpireInfo WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' AND UniqueID = '" + AccountListDB[i].Characters[c].Equipment[ee].UniqueID + "'"; using (var command = new MySqlCommand(sqlEquipment, connectioninfo)) { command.Parameters.AddWithValue("@CurrentDura", AccountListDB[i].Characters[c].Equipment[ee].CurrentDura); command.Parameters.AddWithValue("@MaxDura", AccountListDB[i].Characters[c].Equipment[ee].MaxDura); command.Parameters.AddWithValue("@Count", AccountListDB[i].Characters[c].Equipment[ee].Count); command.Parameters.AddWithValue("@Cursed", AccountListDB[i].Characters[c].Equipment[ee].Cursed); command.Parameters.AddWithValue("@ExpireInfo", AccountListDB[i].Characters[c].Equipment[ee].ExpiryDate); command.ExecuteNonQuery(); command.Dispose(); } if (AccountListDB[i].Characters[c].Equipment[ee].IsAttached) { for (int sl = 0; sl < AccountListDB[i].Characters[c].Equipment[ee].Slots.Length; sl++) { if (AccountListDB[i].Characters[c].Equipment[ee].Slots[sl] == null) { continue; } string sqlEquipmentSlot = "UPDATE " + Settings.DBAccount + ".inventory SET CurrentDura = @CurrentDura, MaxDura = @MaxDura, Count = @Count, Cursed = @Cursed, ExpireInfo = @ExpireInfo WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' AND UniqueID = '" + AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].UniqueID + "'"; using (var command = new MySqlCommand(sqlEquipmentSlot, connectioninfo)) { command.Parameters.AddWithValue("@CurrentDura", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].CurrentDura); command.Parameters.AddWithValue("@MaxDura", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].MaxDura); command.Parameters.AddWithValue("@Count", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].Count); command.Parameters.AddWithValue("@Cursed", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].Cursed); command.Parameters.AddWithValue("@ExpireInfo", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].ExpiryDate); command.ExecuteNonQuery(); command.Dispose(); } } } } for (int mm = 0; mm < AccountListDB[i].Characters[c].Buffs.Count; mm++) { if (AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.Drop || AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.Exp || AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.General || AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.Transform) { int typeBuff = Convert.ToInt32(AccountListDB[i].Characters[c].Buffs[mm].Type); string sqlbuff = "UPDATE " + Settings.DBAccount + ".buff SET ExpireTime = @ExpireTime WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' AND Type = '" + typeBuff + "'"; using (var command = new MySqlCommand(sqlbuff, connectioninfo)) { command.Parameters.AddWithValue("@ExpireTime", AccountListDB[i].Characters[c].Buffs[mm].ExpireTime); command.ExecuteNonQuery(); command.Dispose(); } } } for (int it = 0; it < AccountListDB[i].Characters[c].IntelligentCreatures.Count; it++) { string sqlIntelligentCreatures = "UPDATE " + Settings.DBAccount + ".intelligentcreatures SET ExpireTime = @ExpireTime, BlackstoneTime = @BlackstoneTime, MaintainFoodTime = @MaintainFoodTime, CustomName = @CustomName WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' And PetType = '" + Convert.ToInt32(AccountListDB[i].Characters[c].IntelligentCreatures[it].PetType) + "'"; using (var command = new MySqlCommand(sqlIntelligentCreatures, connectioninfo)) { command.Parameters.AddWithValue("@ExpireTime", AccountListDB[i].Characters[c].IntelligentCreatures[it].ExpireTime); command.Parameters.AddWithValue("@BlackstoneTime", AccountListDB[i].Characters[c].IntelligentCreatures[it].BlackstoneTime); command.Parameters.AddWithValue("@MaintainFoodTime", AccountListDB[i].Characters[c].IntelligentCreatures[it].MaintainFoodTime); command.Parameters.AddWithValue("@CustomName", AccountListDB[i].Characters[c].IntelligentCreatures[it].CustomName); command.ExecuteNonQuery(); command.Dispose(); } } } } } connectioninfo.Close(); AccountListDB.Clear(); } catch (MySqlException ex) { SMain.Enqueue(ex); } SMain.Enqueue(string.Format("Saved, Elapsed para int.Parse: {0}", timer.Elapsed)); }
public void LoadDrops() { for (int i = 0; i < Globals.MaxDragonLevel; i++) { Drops[i].Clear(); } string path = Path.Combine(Settings.DropPath, "DragonItem.txt"); if (!File.Exists(path)) { string[] contents = new[] { ";Pots + Other", string.Empty, string.Empty, ";Weapons", string.Empty, string.Empty, ";Armour", string.Empty, string.Empty, ";Helmets", string.Empty, string.Empty, ";Necklace", string.Empty, string.Empty, ";Bracelets", string.Empty, string.Empty, ";Rings", string.Empty, string.Empty, ";Shoes", string.Empty, string.Empty, ";Belts", string.Empty, string.Empty, ";Stone", }; File.WriteAllLines(path, contents); return; } string[] lines = File.ReadAllLines(path); for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith(";") || string.IsNullOrWhiteSpace(lines[i])) { continue; } DropInfo drop = DropInfo.FromLine(lines[i]); if (drop == null) { SMain.Enqueue(string.Format("Could not load Drop: DragonItem, Line {0}", lines[i])); continue; } if (drop.level <= 0 || drop.level > Globals.MaxDragonLevel) { return; } Drops[drop.level - 1].Add(drop); } for (int i = 0; i < Globals.MaxDragonLevel; i++) { Drops[i].Sort((drop1, drop2) => { if (drop1.Gold > 0 && drop2.Gold == 0) { return(1); } if (drop1.Gold == 0 && drop2.Gold > 0) { return(-1); } return(drop1.Item.Type.CompareTo(drop2.Item.Type)); }); } }
public void End_Match(bool foundWinner = false) { bool failed = false; string matchResult = ""; if (foundWinner) { LMS_Rank lmsRank = null; PlayerObject winningPlayer = null; for (int i = 0; i < CurrentMap.Players.Count; i++) { PlayerObject player = CurrentMap.Players[i]; if (player == null || player.Dead) { continue; } for (int x = 0; x < PlayerRanks.Count; x++) { if (player.Name == PlayerRanks[x].Player.Name && winningPlayer == null && lmsRank == null) { winningPlayer = player; lmsRank = PlayerRanks[x]; } } } if (winningPlayer != null && lmsRank != null) { // TODO Reward players (send by mail) matchResult = string.Format("{0} is the Victor of the match!", winningPlayer.Name); winningPlayer.Teleport(Envir.GetMap(winningPlayer.BindMapIndex), winningPlayer.BindLocation, true, 0); winningPlayer.InLMSBR = false; List <LMS_RewardInfo> rewards = CreateRewards(1, winningPlayer); if (rewards != null && rewards.Count > 0) { winningPlayer.ReceiveChat(string.Format("Victory is yours! Prize(s) will be sent via mail!"), ChatType.Hint); List <UserItem> items = new List <UserItem>(); for (int i = 0; i < rewards.Count; i++) { if (rewards[i].ItemReward == null) { SMain.EnqueueDebugging(string.Format("Null reward")); continue; } ItemInfo iInfo = Envir.GetItemInfo(rewards[i].ItemReward.Index); if (iInfo == null) { SMain.EnqueueDebugging(string.Format("Null item info")); continue; } UserItem item = Envir.CreateFreshItem(iInfo); if (item != null) { items.Add(item); } } MailInfo mail = new MailInfo(winningPlayer.Info.Index) { Items = items, Message = string.Format("Congratulations on winning the match! here is your prize(s)"), Sender = string.Format("LMS"), MailID = ++Envir.NextMailID }; mail.Send(); } SMain.EnqueueDebugging(string.Format("[LMS BR] Map {0} {1} wins the Match, made {2} kills.", CurrentMap.Info.Title, winningPlayer.Name, lmsRank.Kills)); } else { failed = true; } } if ((failed && foundWinner) || !foundWinner) { if (CurrentMap.Players.Count > 0) { string[] finalPlayers = new string[CurrentMap.Players.Count]; if (finalPlayers.Length >= 1) { int index = 0; for (int i = 0; i < CurrentMap.Players.Count; i++) { PlayerObject player = CurrentMap.Players[i]; if (player.Dead || player.IsGM) { continue; } finalPlayers[index] = player.Name; player.Teleport(Envir.GetMap(player.BindMapIndex), player.BindLocation); player.InLMSBR = failed; index++; } Array.Resize(ref finalPlayers, index); } matchResult = "Stalemate, Players "; for (int i = 0; i < finalPlayers.Length; i++) { matchResult += string.Format("{0}{1} ", finalPlayers[i], i - 1 <= finalPlayers.Length ? "," : " have drawn the match!"); } } } if (matchResult.Length > 0) { Envir.Broadcast(new ServerPackets.Chat { Message = matchResult, Type = ChatType.Announcement }); } StartTime = 0; EndTime = 0; SignedupPlayers = new List <PlayerObject>(); CircleLocations = new List <Point>(); PlayerRanks = new List <LMS_Rank>(); StartingLocation = Info.StartingLocation; Stage = 0; Finished = false; Started = false; }
public void Process() { if (Info.StartDay != 7 && (DayOfWeek)Info.StartDay == DateTime.Now.DayOfWeek) { DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Info.StartHour, Info.StartMinute, 0); DateTime hourTime = startTime.AddHours(-1); DateTime minuteTime = startTime.AddMinutes(-30); DateTime fifteen = startTime.AddMinutes(-15); DateTime five = startTime.AddMinutes(-5); if (((DateTime.Now >= hourTime && DateTime.Now <= hourTime.AddSeconds(30)) || (DateTime.Now >= minuteTime && DateTime.Now <= minuteTime.AddSeconds(30)) || (DateTime.Now >= fifteen && DateTime.Now <= fifteen.AddSeconds(30)) || (DateTime.Now >= five && DateTime.Now <= five.AddSeconds(30))) && Envir.Time > NextMessageTime) { NextMessageTime = Envir.Time + Settings.Minute; List <string> listedPlayers = new List <string>(); if (SignedupPlayers != null && SignedupPlayers.Count > 0) { for (int i = 0; i < SignedupPlayers.Count; i++) { if (SignedupPlayers[i].Connection == null || SignedupPlayers[i].Connection.Stage != MirNetwork.GameStage.Game) { continue; } listedPlayers.Add(SignedupPlayers[i].Name); SignedupPlayers[i].ReceiveChat(string.Format("LMS will start in {0} minutes", DateTime.Now == hourTime ? "60" : DateTime.Now == minuteTime ? "30" : DateTime.Now == fifteen ? "15" : "5"), ChatType.System); } } AnnounceCountDown(listedPlayers, DateTime.Now >= five && DateTime.Now <= five.AddSeconds(30)); } } else if (Info.StartDay == 7) { DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Info.StartHour, Info.StartMinute, 0); DateTime hourTime = startTime.AddHours(-1); DateTime minuteTime = startTime.AddMinutes(-30); DateTime fifteen = startTime.AddMinutes(-15); DateTime five = startTime.AddMinutes(-5); if (((DateTime.Now >= hourTime && DateTime.Now <= hourTime.AddSeconds(30)) || (DateTime.Now >= minuteTime && DateTime.Now <= minuteTime.AddSeconds(30)) || (DateTime.Now >= fifteen && DateTime.Now <= fifteen.AddSeconds(30)) || (DateTime.Now >= five && DateTime.Now <= five.AddSeconds(30))) && Envir.Time > NextMessageTime) { NextMessageTime = Envir.Time + Settings.Minute; List <string> listedPlayers = new List <string>(); if (SignedupPlayers != null && SignedupPlayers.Count > 0) { for (int i = 0; i < SignedupPlayers.Count; i++) { if (SignedupPlayers[i].Connection == null || SignedupPlayers[i].Connection.Stage != MirNetwork.GameStage.Game) { continue; } listedPlayers.Add(SignedupPlayers[i].Name); SignedupPlayers[i].ReceiveChat(string.Format("LMS will start in {0} minutes", DateTime.Now == hourTime ? "60" : DateTime.Now == minuteTime ? "30" : DateTime.Now == fifteen ? "15" : "5"), ChatType.System); } } AnnounceCountDown(listedPlayers, DateTime.Now >= five && DateTime.Now <= five.AddSeconds(30)); } } if (Info.StartDay == 7 && DateTime.Now.Hour == Info.StartHour && DateTime.Now.Minute == Info.StartMinute && !Started && !tempStarted) { tempStarted = true; SMain.EnqueueDebugging(string.Format("[LMS BR] {0} Started at {1}:{2}", CurrentMap.Info.Title, Info.StartHour, Info.StartMinute)); Start_Match(); return; } else if ((byte)DateTime.Now.DayOfWeek == Info.StartDay && DateTime.Now.Hour == Info.StartHour && DateTime.Now.Minute == Info.StartMinute && !Started && !tempStarted) { tempStarted = true; SMain.EnqueueDebugging(string.Format("[LMS BR] {0} Started at {1}:{2} on {3}", CurrentMap.Info.Title, Info.StartHour, Info.StartMinute, (DayOfWeek)Info.StartDay)); Start_Match(); return; } else if (DateTime.Now.Hour != Info.StartHour && DateTime.Now.Minute != Info.StartMinute) { tempStarted = false; } if (Started && Stage < 4) { if (CurrentMap.Players.Count == 0) { End_Match(); return; } if (GetAlivePlayers() == 1) { End_Match(true); return; } else { if (Envir.Time >= NextRemainingPlayerMsgTime) { SMain.EnqueueDebugging(string.Format("[LMS BR] {0} {1}/{2} Players remaining", CurrentMap.Info.Title, PlayerCount, OriginalPlayercount)); NextRemainingPlayerMsgTime = Envir.Time + (Settings.Second * 90); BroadcastMessage(string.Format("{0}/{1} players remaining", PlayerCount, OriginalPlayercount), ChatType.Hint, 2); } if (Envir.Time >= NextMessageTime) { if (ShrinkTime - Settings.Second * 60 == Envir.Time) { NextMessageTime = Settings.Second * 11; long temp = ShrinkTime - Envir.Time; string remainingTime = Functions.PrintTimeSpanFromSeconds(temp / 1000); SMain.EnqueueDebugging(string.Format("[LMS BR] {0} Circle will Shrink in {1}", CurrentMap.Info.Title, remainingTime)); BroadcastMessage(string.Format("The circle will shrink in {0}", remainingTime), ChatType.Announcement, 2); } else if (ShrinkTime - Settings.Second * 30 == Envir.Time) { CreateInnerCircle(); NextMessageTime = Settings.Second * 11; long temp = ShrinkTime - Envir.Time; string remainingTime = Functions.PrintTimeSpanFromSeconds(temp / 1000); SMain.EnqueueDebugging(string.Format("[LMS BR] {0} Circle will Shrink in {1}", CurrentMap.Info.Title, remainingTime)); BroadcastMessage(string.Format("The circle will shrink in {0}", remainingTime), ChatType.Announcement, 2); } } if (Envir.Time >= ShrinkTime) { Stage++; float tempDuration = Info.Duration; switch (Stage) { case 1: ShrinkTime = Envir.Time + (long)(tempDuration / 4 * Settings.Minute); CurrentSize = (byte)(CurrentSize - (Info.StartingSize * 20 / 100)); break; case 2: CurrentSize = (byte)(CurrentSize - (Info.StartingSize * 20 / 100)); ShrinkTime = Envir.Time + (long)(tempDuration / 8 * Settings.Minute); break; case 3: CurrentSize = (byte)(CurrentSize - (Info.StartingSize * 20 / 100)); ShrinkTime = Envir.Time + (long)(tempDuration / 8 * Settings.Minute); break; } if (Stage < 4) { CreateCircle(CurrentSize); CreateInnerCircle(); NextMessageTime = ShrinkTime - Settings.Second * 60; long temp = ShrinkTime - Envir.Time; string remainingTime = Functions.PrintTimeSpanFromSeconds(temp / 1000); SMain.EnqueueDebugging(string.Format("[LMS BR] Circle will Shrink again in {0}", CurrentMap.Info.Title, remainingTime)); BroadcastMessage(string.Format("The circle will shrink again in {0}", remainingTime), ChatType.Announcement, 2); } } else { if (Envir.Time > NextDamageTime) { for (int i = 0; i < CurrentMap.Players.Count; i++) { if (!InLMSRange(CurrentMap.Players[i].CurrentLocation)) { if (CurrentMap.Players[i].Dead) { continue; } CurrentMap.Players[i].LMS_DamageAccumulator = CurrentMap.Players[i].LMS_DamageAccumulator == 0 ? -5 : CurrentMap.Players[i].LMS_DamageAccumulator * 2; CurrentMap.Players[i].LMS_InflictDamage(); } else if (CurrentMap.Players[i].LMS_DamageAccumulator != 0) { CurrentMap.Players[i].LMS_DamageAccumulator = 0; } } NextDamageTime = Envir.Time + Settings.Second; } } } } else if (Finished || Stage == 4) { End_Match(); } }
public void SQLError(MySqlException ex) { switch (ex.ErrorCode) { case 0: SMain.Enqueue(string.Format("Cannot connect to MySQL Database :\tIP : {0}\tPort : {1}\tDatabase : {2}", Settings.SQL_IP, Settings.SQL_PORT, Settings.SQL_DBName)); break; case 1045: SMain.Enqueue(string.Format("Login failure for MySQL Database, check details!")); break; case 1053: SMain.Enqueue(string.Format("MySQL Server is shutting down..")); break; case 1054: SMain.Enqueue(string.Format("MySQL Column not found in table.")); break; case 1055: SMain.Enqueue(string.Format("MySQL Item isn't in GROUP BY.")); break; case 1056: SMain.Enqueue(string.Format("MySQL Cannot GROUP BY on table.")); break; case 1059: SMain.Enqueue(string.Format("MySQL Identifier name is too long.")); break; case 1060: SMain.Enqueue(string.Format("MySQL Column duplicate in statement.")); break; case 1061: SMain.Enqueue(string.Format("MySQL Key Name duplicate in statement.")); break; case 1062: SMain.Enqueue(string.Format("MySQL Duplicate entry for key in statement.")); break; case 1063: SMain.Enqueue(string.Format("MySQL Incorrect column specifier.")); break; case 1065: SMain.Enqueue(string.Format("MySQL Empty Query.")); break; case 1077: SMain.Enqueue(string.Format("MySQL Shutting down..")); break; case 1078: SMain.Enqueue(string.Format("MySQL Aborting : Reason receive Signal.")); break; case 1079: SMain.Enqueue(string.Format("MySQL Shutdown complete.")); break; case 1102: SMain.Enqueue(string.Format("MySQL Incorrect database name.")); break; case 1105: SMain.Enqueue("MySQL Unknown Error."); break; case 1146: SMain.Enqueue(string.Format("Table does not exist on MySQL Database.")); break; default: SMain.Enqueue(string.Format("MySQL insert characterinfo data error : {0}", ex.ToString())); break; } }
public void SaveProgressCharacterinfoDB(List <AccountInfo> AccountListDB) { try { MySqlConnection connectionCharacterinfo = new MySqlConnection(); //star conection String connectionString; connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True"; connectionCharacterinfo.ConnectionString = connectionString; connectionCharacterinfo.Open(); for (int i = 0; i < AccountListDB.Count; i++) { string sqlCharacterinfo; for (int c = 0; c < AccountListDB[i].Characters.Count; c++) { string query_Characters = "SELECT COUNT(*) FROM " + Settings.DBAccount + ".characterinfo WHERE AccountID = '" + AccountListDB[i].AccountID + "' AND IndexID = '" + AccountListDB[i].Characters[c].Index + "'"; using (var cmd = new MySqlCommand(query_Characters, connectionCharacterinfo)) { int count = Convert.ToInt32(cmd.ExecuteScalar()); if (count == 0) { sqlCharacterinfo = "INSERT INTO " + Settings.DBAccount + ".characterinfo (IndexID, AccountID, Name, Level, Class, Gender, Hair, CreationIP, CreationDate, Banned, HP, MP, BanReason, ExpiryDate, LastIP, LastDate, Deleted, DeleteDate, Married, MarriedDate, Mentor, MentorDate, isMentor, MentorExp, CurrentMapIndex, CurrentLocation_X, CurrentLocation_Y, Direction, BindMapIndex, BindLocation_X, BindLocation_Y, Experience, AMode, PMode, PKPoints, Thrusting, HalfMoon, CrossHalfMoon, DoubleSlash, MentalState, AllowGroup, AllowTrade, PearlCount, CollectTime, GuildIndex) VALUES (@IndexID, @AccountID, @Name, @Level, @Class, @Gender, @Hair, @CreationIP, @CreationDate, @Banned, @HP, @MP, @BanReason, @ExpiryDate, @LastIP, @LastDate, @Deleted, @DeleteDate, @Married, @MarriedDate, @Mentor, @MentorDate, @isMentor, @MentorExp, @CurrentMapIndex, @CurrentLocation_X, @CurrentLocation_Y, @Direction, @BindMapIndex, @BindLocation_X, @BindLocation_Y, @Experience, @AMode, @PMode, @PKPoints, @Thrusting, @HalfMoon, @CrossHalfMoon, @DoubleSlash, @MentalState, @AllowGroup, @AllowTrade, @PearlCount, @CollectTime, @GuildIndex)"; } else { sqlCharacterinfo = "UPDATE " + Settings.DBAccount + ".characterinfo SET AccountID = @AccountID, Name = @Name, Level = @Level, Class = @Class, Gender = @Gender, Hair = @Hair, CreationIP = @CreationIP, CreationDate = @CreationDate, Banned = @Banned, HP = @HP, MP = @MP, BanReason = @BanReason, ExpiryDate = @ExpiryDate, LastIP = @LastIP, LastDate = @LastDate, Deleted = @Deleted, DeleteDate = @DeleteDate, Married = @Married, MarriedDate = @MarriedDate, Mentor = @Mentor, MentorDate = @MentorDate, isMentor = @isMentor, MentorExp = @MentorExp, CurrentMapIndex = @CurrentMapIndex, CurrentLocation_X = @CurrentLocation_X, CurrentLocation_Y = @CurrentLocation_Y, Direction = @Direction, BindMapIndex = @BindMapIndex, BindLocation_X = @BindLocation_X, BindLocation_Y = @BindLocation_Y, Experience = @Experience, AMode = @AMode, PMode = @PMode, PKPoints = @PKPoints, Thrusting = @Thrusting, HalfMoon = @HalfMoon, CrossHalfMoon = @CrossHalfMoon, DoubleSlash = @DoubleSlash, MentalState = @MentalState, AllowGroup = @AllowGroup, AllowTrade = @AllowTrade, PearlCount = @PearlCount, CollectTime = @CollectTime, GuildIndex = @GuildIndex WHERE AccountID = '" + AccountListDB[i].AccountID + "' AND IndexID = '" + AccountListDB[i].Characters[c].Index + "'"; } } using (var command = new MySqlCommand(sqlCharacterinfo, connectionCharacterinfo)) { command.Parameters.AddWithValue("@IndexID", AccountListDB[i].Characters[c].Index); command.Parameters.AddWithValue("@AccountID", AccountListDB[i].AccountID); command.Parameters.AddWithValue("@Name", AccountListDB[i].Characters[c].Name); command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Level); command.Parameters.AddWithValue("@Class", AccountListDB[i].Characters[c].Class); command.Parameters.AddWithValue("@Gender", AccountListDB[i].Characters[c].Gender); command.Parameters.AddWithValue("@Hair", AccountListDB[i].Characters[c].Hair); command.Parameters.AddWithValue("@CreationIP", AccountListDB[i].Characters[c].CreationIP); command.Parameters.AddWithValue("@CreationDate", AccountListDB[i].Characters[c].CreationDate); command.Parameters.AddWithValue("@Banned", AccountListDB[i].Characters[c].Banned); command.Parameters.AddWithValue("@BanReason", AccountListDB[i].Characters[c].BanReason); command.Parameters.AddWithValue("@ExpiryDate", AccountListDB[i].Characters[c].ExpiryDate); command.Parameters.AddWithValue("@LastIP", AccountListDB[i].Characters[c].LastIP); command.Parameters.AddWithValue("@LastDate", AccountListDB[i].Characters[c].LastDate); command.Parameters.AddWithValue("@Deleted", AccountListDB[i].Characters[c].Deleted); command.Parameters.AddWithValue("@DeleteDate", AccountListDB[i].Characters[c].DeleteDate); command.Parameters.AddWithValue("@CurrentMapIndex", AccountListDB[i].Characters[c].CurrentMapIndex); command.Parameters.AddWithValue("@CurrentLocation_X", AccountListDB[i].Characters[c].CurrentLocation.X); command.Parameters.AddWithValue("@CurrentLocation_Y", AccountListDB[i].Characters[c].CurrentLocation.Y); command.Parameters.AddWithValue("@Direction", AccountListDB[i].Characters[c].Direction); command.Parameters.AddWithValue("@BindMapIndex", AccountListDB[i].Characters[c].BindMapIndex); command.Parameters.AddWithValue("@BindLocation_X", AccountListDB[i].Characters[c].BindLocation.X); command.Parameters.AddWithValue("@BindLocation_Y", AccountListDB[i].Characters[c].BindLocation.Y); command.Parameters.AddWithValue("@HP", AccountListDB[i].Characters[c].HP); command.Parameters.AddWithValue("@MP", AccountListDB[i].Characters[c].MP); command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Experience); command.Parameters.AddWithValue("@AMode", AccountListDB[i].Characters[c].AMode); command.Parameters.AddWithValue("@PMode", AccountListDB[i].Characters[c].PMode); command.Parameters.AddWithValue("@PKPoints", AccountListDB[i].Characters[c].PKPoints); command.Parameters.AddWithValue("@Thrusting", AccountListDB[i].Characters[c].Thrusting); command.Parameters.AddWithValue("@HalfMoon", AccountListDB[i].Characters[c].HalfMoon); command.Parameters.AddWithValue("@CrossHalfMoon", AccountListDB[i].Characters[c].CrossHalfMoon); command.Parameters.AddWithValue("@DoubleSlash", AccountListDB[i].Characters[c].DoubleSlash); command.Parameters.AddWithValue("@MentalState", AccountListDB[i].Characters[c].MentalState); command.Parameters.AddWithValue("@AllowGroup", AccountListDB[i].Characters[c].AllowGroup); command.Parameters.AddWithValue("@AllowTrade", AccountListDB[i].Characters[c].AllowTrade); command.Parameters.AddWithValue("@Married", AccountListDB[i].Characters[c].Married); command.Parameters.AddWithValue("@MarriedDate", AccountListDB[i].Characters[c].MarriedDate); command.Parameters.AddWithValue("@Mentor", AccountListDB[i].Characters[c].Mentor); command.Parameters.AddWithValue("@MentorDate", AccountListDB[i].Characters[c].MentorDate); command.Parameters.AddWithValue("@isMentor", AccountListDB[i].Characters[c].isMentor); command.Parameters.AddWithValue("@MentorExp", AccountListDB[i].Characters[c].MentorExp); command.Parameters.AddWithValue("@PearlCount", AccountListDB[i].Characters[c].PearlCount); command.Parameters.AddWithValue("@CollectTime", AccountListDB[i].Characters[c].CollectTime); command.Parameters.AddWithValue("@GuildIndex", AccountListDB[i].Characters[c].GuildIndex); command.ExecuteNonQuery(); command.Dispose(); } } } connectionCharacterinfo.Close(); } catch (MySqlException ex) { SMain.Enqueue(ex); } }
public static void SaveMonsterDB(MonsterInfo info) { try { MySqlConnection connection = new MySqlConnection(); //star conection String connectionString; connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True"; connection.ConnectionString = connectionString; connection.Open(); string sqlMonsterExists = "SELECT Count(*) FROM " + Settings.DBServer + ".monsterinfo where IndexID = '" + info.Index + "'"; string sqlCommand; if (Envir.ConnectADB.Count(sqlMonsterExists) > 0) { sqlCommand = "UPDATE " + Settings.DBServer + ".monsterinfo SET IndexID = @IndexID, AI = @AI, Accuracy = @Accuracy, Agility = @Agility, AttackSpeed = @AttackSpeed, CanPush = @CanPush, CanTame = @CanTame, Effect = @Effect, Experience = @Experience, HP = @HP, Image = @Image, Level = @Level, Light = @Light, MaxAC = @MaxAC, MaxDC = @MaxDC, MaxMAC = @MaxMAC, MaxMC = @MaxMC, MaxSC = @MaxSC, MinAC = @MinAC, MinDC = @MinDC, MinMAC = @MinMAC, MinMC = @MinMC, MinSC = @MinSC, MoveSpeed = @MoveSpeed, Name = @Name, ViewRange = @ViewRange, AutoRev_ = @AutoRev_, CoolEye_ = @CoolEye_, Undead_ = @Undead_ where IndexID = " + info.Index; } else { sqlCommand = "INSERT INTO " + Settings.DBServer + ".monsterinfo (IndexID, AI, Accuracy, Agility, AttackSpeed, CanPush, CanTame,Effect, Experience, HP, Image, Level, Light, MaxAC, MaxDC, MaxMAC, MaxMC, MaxSC, MinAC, MinDC, MinMAC, MinMC, MinSC, MoveSpeed, Name, ViewRange, AutoRev_, CoolEye_, Undead_ ) VALUES (@IndexID, @AI, @Accuracy, @Agility, @AttackSpeed, @CanPush, @CanTame, @Effect, @Experience, @HP, @Image, @Level, @Light, @MaxAC, @MaxDC, @MaxMAC, @MaxMC, @MaxSC, @MinAC, @MinDC, @MinMAC, @MinMC, @MinSC, @MoveSpeed, @Name, @ViewRange ,@AutoRev_, @CoolEye_, @Undead_)"; } using (var command = new MySqlCommand(sqlCommand, connection)) { command.Parameters.AddWithValue("@IndexID", info.Index); command.Parameters.AddWithValue("@Name", info.Name); command.Parameters.AddWithValue("@Image", info.Image); command.Parameters.AddWithValue("@AI", info.AI); command.Parameters.AddWithValue("@Effect", info.Effect); command.Parameters.AddWithValue("@Level", info.Level); command.Parameters.AddWithValue("@ViewRange", info.ViewRange); command.Parameters.AddWithValue("@HP", info.HP); command.Parameters.AddWithValue("@MinAC", info.MinAC); command.Parameters.AddWithValue("@MaxAC", info.MaxAC); command.Parameters.AddWithValue("@MinMAC", info.MinMAC); command.Parameters.AddWithValue("@MaxMAC", info.MaxMAC); command.Parameters.AddWithValue("@MinDC", info.MinDC); command.Parameters.AddWithValue("@MaxDC", info.MaxDC); command.Parameters.AddWithValue("@MinMC", info.MinMC); command.Parameters.AddWithValue("@MaxMC", info.MaxMC); command.Parameters.AddWithValue("@MinSC", info.MinSC); command.Parameters.AddWithValue("@MaxSC", info.MaxSC); command.Parameters.AddWithValue("@Accuracy", info.Accuracy); command.Parameters.AddWithValue("@Agility", info.Agility); command.Parameters.AddWithValue("@Light", info.Light); command.Parameters.AddWithValue("@AttackSpeed", info.AttackSpeed); command.Parameters.AddWithValue("@MoveSpeed", info.MoveSpeed); command.Parameters.AddWithValue("@Experience", info.Experience); command.Parameters.AddWithValue("@CanTame", info.CanTame); command.Parameters.AddWithValue("@CanPush", info.CanPush); command.Parameters.AddWithValue("@AutoRev_", info.AutoRev); command.Parameters.AddWithValue("@CoolEye_", info.CoolEye); command.Parameters.AddWithValue("@Undead_", info.Undead); command.ExecuteNonQuery(); command.Dispose(); } connection.Close(); } catch (MySqlException ex) { SMain.Enqueue(ex); } }
public void Start_Match() { if (CurrentMap == null) { return; } if (SignedupPlayers == null || SignedupPlayers.Count == 0) { return; } StartingLocation = new Point( Envir.Random.Next(Info.StartingLocation.X - Info.StartingRange <= 0 ? 1 : Info.StartingLocation.X - Info.StartingRange, Info.StartingLocation.X + Info.StartingRange >= CurrentMap.Width ? CurrentMap.Width - 1 : Info.StartingLocation.X + Info.StartingRange), Envir.Random.Next(Info.StartingLocation.Y - Info.StartingRange <= 0 ? 1 : Info.StartingLocation.Y - Info.StartingRange, Info.StartingLocation.Y + Info.StartingRange >= CurrentMap.Height ? CurrentMap.Height - 1 : Info.StartingLocation.Y + Info.StartingRange)); SMain.EnqueueDebugging(string.Format("[LMS BR] Map {0} Random Start Point X:{1} Y:{2}", CurrentMap.Info.Title, StartingLocation.X, StartingLocation.Y)); ShrinkTime = Envir.Time + (Info.Duration / 4 * Settings.Minute); for (int i = 0; i < SignedupPlayers.Count; i++) { if (SignedupPlayers[i].Connection == null) { continue; } if (SignedupPlayers[i].Connection.Stage != MirNetwork.GameStage.Game) { continue; } if (SignedupPlayers[i].Dead) { continue; } Point tempPoint = GetRandomPointInCircle(); while (!CurrentMap.ValidPoint(tempPoint)) { tempPoint = GetRandomPointInCircle(); } SignedupPlayers[i].Teleport(CurrentMap, tempPoint, true); SignedupPlayers[i].InLMSBR = true; SignedupPlayers[i].CurrentLMS = this; } SMain.EnqueueDebugging(string.Format("[LMS BR] Map {0} {1} Players signed up teleported in", CurrentMap.Info.Title, SignedupPlayers.Count)); for (int i = 0; i < CurrentMap.Players.Count; i++) { PlayerObject player = CurrentMap.Players[i]; if (player.IsGM || player.IsDev) { continue; } if (player.Dead) { continue; } PlayerRanks.Add(new LMS_Rank { Player = player, Kills = 0 }); } Started = true; StartTime = Envir.Time; EndTime = Envir.Time + (Settings.Minute * Info.Duration); CurrentSize = Info.StartingSize; OriginalPlayercount = (byte)PlayerRanks.Count; CreateCircle(Info.StartingSize); CreateInnerCircle(); BroadcastMessage(string.Format("Be advised you take damage while being OUTSIDE of the circle."), ChatType.Hint); long temp = ShrinkTime - Envir.Time; string remainingTime = Functions.PrintTimeSpanFromSeconds(temp / 1000); BroadcastMessage(string.Format("The Circle will shrink in {0} be ready!", remainingTime), ChatType.Announcement); }
public bool BuyNow() { // Sellers cannot bid on their own items if (IsSeller) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : Cannot bid on own item.", AuctionIndex)); return(false); } AuctionHouseInfo ListedItem = Envir.GetAuction(AuctionIndex); // Can't find the Auction if (ListedItem == null) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Index was not found.", AuctionIndex)); return(false); } if (ListedItem.Sold) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Auction has already finished or been purchased.", AuctionIndex)); return(false); } if (!ListedItem.CanBuyNow) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Auction is not Buy now.", AuctionIndex)); return(false); } if (ListedItem.BuyNowPrice <= 0 || ListedItem.BuyNowPrice > uint.MaxValue) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Auction Buy now price out of range.", AuctionIndex)); return(false); } // The Auctions ended if (SMain.Envir.Time > ListedItem.ListEndTime) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Auction has already finished.", AuctionIndex)); return(false); } // The Item up for Auction doesn't exist if (ListedItem.ListedItem == null) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Item not found.", AuctionIndex)); return(false); } PlayerObject bidder = Envir.GetPlayer((uint)PlayerIndex); // Can't find the player if (bidder == null) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : Buyer not found {0}.", PlayerIndex)); return(false); } // Can't find the players account if (bidder.Account == null) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : Buyer Account not found {0}.", PlayerIndex)); return(false); } PlayerObject seller = Envir.GetPlayer((uint)ListedItem.SellersIndex); if (seller == null) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : Sellers Account not found {0}.", PlayerIndex)); return(false); } uint gold = 0; string message = ""; List <UserItem> items = new List <UserItem>(); switch (ListedItem.CurrencyType) { default: case CurrencyType.Gold: { if (bidder.Account.Gold < ListedItem.BuyNowPrice) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Player does not have enough gold.", AuctionIndex)); return(false); } gold = ListedItem.BuyNowPrice; if (gold >= bidder.Account.Gold) { gold = bidder.Account.Gold; } bidder.Account.Gold -= gold; bidder.Enqueue(new S.LoseGold { Gold = gold }); items.Add(ListedItem.ListedItem); message = string.Format("You purchased {0} from {1} for {2:#,###,###,###}.", ListedItem.ListedItem.FriendlyName, seller.Name, ListedItem.BuyNowPrice); MailInfo mail = new MailInfo(PlayerIndex, false) { Gold = 0, Message = message, Items = items, Sender = "AuctionHouse", MailID = ++Envir.NextMailID }; mail.Send(); mail = null; items.Add(ListedItem.ListedItem); message = string.Format("{0} purchased {1} from you for {2:#,###,###,###}.", bidder.Name, ListedItem.ListedItem.FriendlyName, ListedItem.BuyNowPrice); mail = new MailInfo(PlayerIndex, false) { Gold = ListedItem.BuyNowPrice - (uint)Functions.GetPercentage(ListedItem.Commission, (int)ListedItem.BuyNowPrice), Message = message, Sender = "AuctionHouse", MailID = ++Envir.NextMailID }; mail.Send(); mail = null; // End it. ListedItem.ListedItem = null; ListedItem.CurrentBid = gold; ListedItem.HighestBidderIndex = PlayerIndex; ListedItem.ListEndTime = Envir.Time; ListedItem.Sold = true; GoldRetrived = true; /* * gold = MyBid; * // Message contents. * message = string.Format("{0:#,###,###,###} Gold has been returned to you.", MyBid); * // Create the mail * MailInfo mail = new MailInfo(PlayerIndex, true) * { * MailID = ++Envir.NextMailID, * Sender = "AuctionHouse", * Message = message, * Gold = gold, * }; */ } break; case CurrencyType.Credits: { if (bidder.Account.Credit < ListedItem.BuyNowPrice) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Player does not have enough credits.", AuctionIndex)); return(false); } } break; case CurrencyType.Pearl: { if (bidder.Info.PearlCount < ListedItem.BuyNowPrice) { SMain.EnqueueDebugging(string.Format("[BuyNow()]Auction House Error : {0} Player does not have enough pearls.", AuctionIndex)); return(false); } } break; } return(true); }
public AuctionInfo(MySqlDataReader readerAuctionsDB) { AuctionID = Convert.ToUInt64(readerAuctionsDB["AuctionID"]); NameSeller = Convert.ToString(readerAuctionsDB["NameSeller"]); try { MySqlConnection connection = new MySqlConnection(); //star conection String connectionString; connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True"; connection.ConnectionString = connectionString; connection.Open(); MySqlCommand instruccion = connection.CreateCommand(); instruccion.CommandText = "SELECT * FROM " + Settings.DBAccount + ".auctionsitems WHERE AuctionID = '" + AuctionID + "'"; MySqlDataReader readerAuctions = instruccion.ExecuteReader(); while (readerAuctions.Read()) { UserItem AddItem = new UserItem(readerAuctions); if (SMain.Envir.BindItem(AddItem)) { Item = AddItem; } } readerAuctions.Dispose(); if (Item != null) { if (Item.IsAwake) { MySqlCommand instruccionAwake = connection.CreateCommand(); instruccionAwake.CommandText = "SELECT * FROM " + Settings.DBAccount + ".awake WHERE UniqueID = '" + Item.UniqueID + "' ORDER BY Position"; MySqlDataReader readerAwakeDB = instruccionAwake.ExecuteReader(); Item.Awake = new Awake(); Item.Awake.type = (AwakeType)Convert.ToInt32(Item.AwakeType); while (readerAwakeDB.Read()) { Item.Awake.listAwake.Add(Convert.ToByte(readerAwakeDB["Value"])); } readerAwakeDB.Dispose(); } if (Item.IsAttached) { MySqlCommand instruccionAttached = connection.CreateCommand(); instruccionAttached.CommandText = "SELECT * FROM " + Settings.DBAccount + ".auctionsitems WHERE Attached = '" + Item.UniqueID + "' ORDER BY Position"; MySqlDataReader readerAttachedDB = instruccionAttached.ExecuteReader(); Item.Awake = new Awake(); Item.Awake.type = (AwakeType)Convert.ToInt32(Item.AwakeType); while (readerAttachedDB.Read()) { Item.Awake.listAwake.Add(Convert.ToByte(readerAttachedDB["Value"])); } readerAttachedDB.Dispose(); } } connection.Close(); } catch (MySqlException ex) { SMain.Enqueue(ex); } ConsignmentDate = readerAuctionsDB.GetDateTime(readerAuctionsDB.GetOrdinal("ConsignmentDate")); Price = Convert.ToUInt32(readerAuctionsDB["Price"]); CharacterIndex = Convert.ToInt32(readerAuctionsDB["CharacterIndex"]); Expired = Convert.ToBoolean(readerAuctionsDB["Expired"]); Sold = Convert.ToBoolean(readerAuctionsDB["Sold"]); }
public bool MakeBid(uint myBid) { // Range Check if (myBid <= 0 || myBid > uint.MaxValue) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Bid amount {0} out of range.", myBid)); return(false); } // Sellers cannot bid on their own items if (IsSeller) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Cannot bid on own item.", AuctionIndex)); return(false); } AuctionHouseInfo ListedItem = Envir.GetAuction(AuctionIndex); // Can't find the Auction if (ListedItem == null) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : {0} Index was not found.", AuctionIndex)); return(false); } // The Auctions ended if (SMain.Envir.Time > ListedItem.ListEndTime) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : {0} Auction has already finished.", AuctionIndex)); return(false); } // The Item up for Auction doesn't exist if (ListedItem.ListedItem == null) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : {0} Item not found.", AuctionIndex)); return(false); } // Bidder was the previous bidder if (ListedItem.HighestBidderIndex == PlayerIndex) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Already made bid.")); return(false); } PlayerObject bidder = Envir.GetPlayer((uint)PlayerIndex); // Can't find the player if (bidder == null) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer not found {0}.", PlayerIndex)); return(false); } // Can't find the players account if (bidder.Account == null) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Account not found {0}.", PlayerIndex)); return(false); } uint gold = 0; string message = ""; // Switch between the currency switch (ListedItem.CurrencyType) { default: case CurrencyType.Gold: { // Bid was more than the Account has if (bidder.Account.Gold < myBid) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Not enough gold {0}.", myBid - bidder.Account.Gold)); return(false); } // Bid was too low if (myBid <= ListedItem.CurrentBid + 1000) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Bid is too low {0}.", myBid - ListedItem.CurrentBid)); return(false); } if (!FirstBid && !GoldRetrived) { gold = MyBid; // Message contents. message = string.Format("{0:#,###,###,###} Gold has been returned to you.", MyBid); // Create the mail MailInfo mail = new MailInfo(PlayerIndex, true) { MailID = ++Envir.NextMailID, Sender = "AuctionHouse", Message = message, Gold = gold, }; GoldRetrived = true; } MyBid = myBid; if (myBid >= bidder.Account.Gold) { myBid = bidder.Account.Gold; } bidder.Account.Gold -= myBid; bidder.Enqueue(new S.LoseGold { Gold = myBid }); ListedItem.CurrentBid = myBid; ListedItem.HighestBidderIndex = PlayerIndex; GoldRetrived = false; bidder.ReceiveChat(string.Format("You bid {0:#,###,###,###} for {1}{2} has been placed.", MyBid, ListedItem.ListedItem.FriendlyName, ListedItem.ListedItem.Count >= 1 ? string.Format("[{0}]", ListedItem.ListedItem.Count) : ""), ChatType.System); if (FirstBid) { FirstBid = false; } return(true); } case CurrencyType.Credits: { if (bidder.Account.Credit < myBid) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Not enough credit {0}.", myBid - bidder.Account.Credit)); return(false); } // Only allow Increments of 1k if (myBid <= ListedItem.CurrentBid + 5) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Bid is too low {0}.", myBid - ListedItem.CurrentBid)); return(false); } if (!FirstBid && !GoldRetrived) { gold = MyBid; // Message contents. message = string.Format("{0:#,###,###,###} Gold has been returned to you.", MyBid); // Create the mail MailInfo mail = new MailInfo(PlayerIndex, true) { MailID = ++Envir.NextMailID, Sender = "AuctionHouse", Message = message, Gold = gold, }; GoldRetrived = true; } MyBid = myBid; if (myBid >= bidder.Account.Credit) { myBid = bidder.Account.Credit; } bidder.Account.Credit -= myBid; bidder.Enqueue(new S.LoseCredit { Credit = myBid }); ListedItem.CurrentBid = myBid; ListedItem.HighestBidderIndex = PlayerIndex; GoldRetrived = false; bidder.ReceiveChat(string.Format("You bid {0:#,###,###,###} for {1}{2} has been placed.", MyBid, ListedItem.ListedItem.FriendlyName, ListedItem.ListedItem.Count >= 1 ? string.Format("[{0}]", ListedItem.ListedItem.Count) : ""), ChatType.System); if (FirstBid) { FirstBid = false; } return(true); } case CurrencyType.Pearl: { if (bidder.Info.PearlCount < myBid) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Not enough pearl {0}.", myBid - bidder.Info.PearlCount)); return(false); } // Only allow Increments of 1k if (myBid <= ListedItem.CurrentBid + 1) { SMain.EnqueueDebugging(string.Format("[MakeBid(uint myBid)]Auction House Error : Buyer Bid is too low {0}.", myBid - ListedItem.CurrentBid)); return(false); } if (!FirstBid && !GoldRetrived) { gold = MyBid; // Message contents. message = string.Format("{0:#,###,###,###} Gold has been returned to you.", MyBid); // Create the mail MailInfo mail = new MailInfo(PlayerIndex, true) { MailID = ++Envir.NextMailID, Sender = "AuctionHouse", Message = message, Gold = gold, }; GoldRetrived = true; } MyBid = myBid; if (myBid >= bidder.Info.PearlCount) { myBid = (uint)bidder.Info.PearlCount; } bidder.Info.PearlCount -= (int)myBid; ListedItem.CurrentBid = myBid; ListedItem.HighestBidderIndex = PlayerIndex; GoldRetrived = false; bidder.ReceiveChat(string.Format("You bid {0:#,###,###,###} Pearl{2} for {1}{3} has been placed.", MyBid, ListedItem.ListedItem.FriendlyName, MyBid > 1 ? "s" : "", ListedItem.ListedItem.Count >= 1 ? string.Format("[{0}]", ListedItem.ListedItem.Count) : ""), ChatType.System); if (FirstBid) { FirstBid = false; } return(true); } } }
public bool Load() { try { MonsterInfo info = Envir.GetMonsterInfo(Info.MonsterName); if (info == null) { SMain.Enqueue("Failed to load Dragon (bad monster name): " + Info.MonsterName); return(false); } LinkedMonster = MonsterObject.GetMonster(info); Map map = SMain.Envir.GetMapByNameAndInstance(Info.MapFileName); if (map == null) { SMain.Enqueue("Failed to load Dragon (bad map name): " + Info.MapFileName); return(false); } if (Info.Location.X > map.Width || Info.Location.Y > map.Height) { SMain.Enqueue("Failed to load Dragon (bad map XY): " + Info.MapFileName); return(false); } if (LinkedMonster.Spawn(map, Info.Location)) { if (LinkedMonster is EvilMir) { EvilMir mob = (EvilMir)LinkedMonster; if (mob != null) { mob.DragonLink = true; } } MonsterInfo bodyinfo = Envir.GetMonsterInfo(Info.BodyName); if (bodyinfo != null) { MonsterObject bodymob; Point spawnlocation = Point.Empty; for (int i = 0; i <= BodyLocations.Length - 1; i++) { bodymob = MonsterObject.GetMonster(bodyinfo); spawnlocation = new Point(LinkedMonster.CurrentLocation.X + BodyLocations[i].X, LinkedMonster.CurrentLocation.Y + BodyLocations[i].Y); if (bodymob != null) { bodymob.Spawn(LinkedMonster.CurrentMap, spawnlocation); } } } DropArea = new Rectangle(Info.DropAreaTop.X, Info.DropAreaTop.Y, Info.DropAreaBottom.X - Info.DropAreaTop.X, Info.DropAreaBottom.Y - Info.DropAreaTop.Y); Loaded = true; return(true); } } catch (Exception ex) { SMain.Enqueue(ex); } SMain.Enqueue("Failed to load Dragon"); return(false); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); SMain.SetUpView(MonsterInfoStatGridView); }
private void LoadIngredients(string recipe) { List <string> lines = File.ReadAllLines(Settings.RecipePath + recipe + ".txt").ToList(); Ingredients = new List <UserItem>(); var mode = "ingredients"; for (int i = 0; i < lines.Count; i++) { if (String.IsNullOrEmpty(lines[i])) { continue; } var data1 = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info1 = SMain.Envir.GetItemInfo(data1[0]); if (info1 == null) { mode = lines[i].Substring(1, lines[i].Length - 2).ToLower(); continue; } switch (mode) { case "ingredients": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ItemInfo info = SMain.Envir.GetItemInfo(data[0]); if (info == null) { SMain.Enqueue(string.Format("Could not find Item: {0}, Recipe: {1}", lines[i], recipe)); continue; } uint count = 1; if (data.Length == 2) { uint.TryParse(data[1], out count); } UserItem ingredient = SMain.Envir.CreateShopItem(info); ingredient.Count = count > info.StackSize ? info.StackSize : count; Ingredients.Add(ingredient); } break; case "criteria": { var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length < 2) { continue; } try { switch (data[0].ToLower()) { case "level": RequiredLevel = ushort.Parse(data[1]); break; case "class": RequiredClass.Add((MirClass)byte.Parse(data[1])); break; case "gender": RequiredGender = (MirGender)byte.Parse(data[1]); break; case "flag": RequiredFlag.Add(int.Parse(data[1])); break; case "quest": RequiredQuest.Add(int.Parse(data[1])); break; } } catch { SMain.Enqueue(string.Format("Could not parse option: {0}, Value: {1}", data[0], data[1])); continue; } } break; } } }
public QuestProgressInfo(MySqlDataReader readerQuestProgressDB, string Name) { Index = Convert.ToInt32(readerQuestProgressDB["IndexID"]); Info = SMain.Envir.QuestInfoList.FirstOrDefault(e => e.Index == Index); // StartDateTime = DateTime.Now; // EndDateTime = DateTime.MaxValue; EndDateTime = readerQuestProgressDB.GetDateTime(readerQuestProgressDB.GetOrdinal("EndDateTime")); StartDateTime = readerQuestProgressDB.GetDateTime(readerQuestProgressDB.GetOrdinal("StartDateTime")); try { MySqlConnection connection = new MySqlConnection(); //star conection String connectionString; connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True"; connection.ConnectionString = connectionString; connection.Open(); MySqlCommand instruccionKillTask = connection.CreateCommand(); instruccionKillTask.CommandText = "SELECT * FROM " + Settings.DBAccount + ".killtaskcount WHERE ChName = '" + Name + "' and IndexID = '" + Index + "' ORDER BY IndexID, Position"; MySqlDataReader readerKillTask = instruccionKillTask.ExecuteReader(); while (readerKillTask.Read()) { int position = Convert.ToInt32(readerKillTask["Position"]); int value = Convert.ToInt32(readerKillTask["Value"]); KillTaskCount.Add(value); } readerKillTask.Dispose(); MySqlCommand instruccionItemTask = connection.CreateCommand(); instruccionItemTask.CommandText = "SELECT * FROM " + Settings.DBAccount + ".itemtaskcount WHERE ChName = '" + Name + "' and IndexID = '" + Index + "' ORDER BY IndexID, Position"; MySqlDataReader readerItemTask = instruccionItemTask.ExecuteReader(); while (readerItemTask.Read()) { int position = Convert.ToInt32(readerItemTask["Position"]); long value = Convert.ToInt64(readerItemTask["Value"]); ItemTaskCount.Add(value); } readerItemTask.Dispose(); MySqlCommand instruccionFlagTask = connection.CreateCommand(); instruccionFlagTask.CommandText = "SELECT * FROM " + Settings.DBAccount + ".flagtaskset WHERE ChName = '" + Name + "' and IndexID = '" + Index + "' ORDER BY IndexID, Position"; MySqlDataReader readerFlagTask = instruccionFlagTask.ExecuteReader(); while (readerFlagTask.Read()) { int position = Convert.ToInt32(readerFlagTask["Position"]); bool value = Convert.ToBoolean(readerFlagTask["value"]); FlagTaskSet.Add(value); } readerFlagTask.Dispose(); connection.Close(); } catch (MySqlException ex) { SMain.Enqueue(ex); } }
private void ProcessPacket(Packet p) { if (DebugMode) { SMain.EnqueueDebugging(string.Format("Packet Received {0}", p.Index)); } if (p == null || Disconnecting) { return; } switch (p.Index) { case (short)ClientPacketIds.ExternalToolLogin: if (DebugMode) { SMain.EnqueueDebugging(string.Format("{0} logging in...", IPAddress)); } CheckExternalLogin((C.ExternalToolLogin)p); break; case (short)ClientPacketIds.Disconnect: SMain.EnqueueDebugging(string.Format("{0} disconnected.", ManagerUser)); Disconnect(); break; case (short)ClientPacketIds.KeepAlive: C.KeepAlive keepAlive = (C.KeepAlive)p; if (DebugMode) { SMain.EnqueueDebugging(string.Format("Keep Alive {0}", keepAlive.Time)); } break; case (short)ClientPacketIds.ToolStats: if (LoggedIn) { GetStats(); } break; case (short)ClientPacketIds.Chat: if (LoggedIn) { C.Chat chat = (C.Chat)p; string[] splits = chat.Message.Split(' '); if (splits.Length == 0) { Enqueue(new S.Chat { Message = string.Format("Invalid Input"), Type = ChatType.System }); break; } else { if (splits[0].StartsWith("@")) { ReceiveCommand((C.Chat)p); } else if (splits[0].StartsWith("/")) { if (SMain.Envir.Running) { MessageToPlayer((C.Chat)p); } } else if (splits[0].StartsWith("!")) { if (SMain.Envir.Running) { BroadcastMessage((C.Chat)p); } } break; } } break; default: SMain.EnqueueDebugging(string.Format("Invalid Packet for Server Manager\nIndex : {0}", p.Index)); break; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); SMain.SetUpView(MovementGridView); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); SMain.SetUpView(CurrencyInfoGridView); }
public void EventMonsterDied(List <PlayerObject> monsterContributers) { if (!IsActive) { return; } for (int i = 0; i < monsterContributers.Count; i++) { var monContributor = monsterContributers[i]; if (!Contributers.Contains(monContributor)) { Contributers.Add(monContributor); } } switch (Info.EventType) { case EventType.Invasion: var invasionRespawns = MapRespawns.Where(o => o.IsEventObjective); if (invasionRespawns.All(o => o.Count == 0)) { foreach (var mapRespawn in MapRespawns) { Map.Respawns.Remove(mapRespawn); } MapRespawns.Clear(); Stage++; SpawnInvasionMonsters(Stage); List <MonsterEventObjective> monObj = MapRespawns.Select(o => new MonsterEventObjective() { MonsterName = o.Monster.Name, MonsterTotalCount = o.Info.Count, MonsterAliveCount = o.Info.Count }).ToList(); var p = new S.EnterOrUpdatePublicEvent(Info.EventName, Info.EventType, Info.ObjectiveMessage, Stage, monObj); foreach (var player in Players) { player.Enqueue(p); } } else { List <MonsterEventObjective> monObj = invasionRespawns.Select(o => new MonsterEventObjective() { MonsterName = o.Monster.Name, MonsterTotalCount = o.Info.Count, MonsterAliveCount = o.Count }).ToList(); //var remainingCount = string.Format("{0}/{1}", alive, total); //var completedPerc = (int)(((decimal)dead / total) * 100); var p = new S.EnterOrUpdatePublicEvent(Info.EventName, Info.EventType, Info.ObjectiveMessage, Stage, monObj); foreach (var player in Players) { player.Enqueue(p); } } break; default: var objectiveRespawns = MapRespawns.Where(o => o.IsEventObjective); List <MonsterEventObjective> monObjectives = objectiveRespawns.Select(o => new MonsterEventObjective() { MonsterName = o.Monster.Name, MonsterTotalCount = o.Info.Count, MonsterAliveCount = o.Count }).ToList(); var packet = new S.EnterOrUpdatePublicEvent(Info.EventName, Info.EventType, Info.ObjectiveMessage, Stage, monObjectives); foreach (var player in Players) { player.Enqueue(packet); } if (objectiveRespawns.All(o => o.Count == 0)) { SMain.EnqueueDebugging(string.Format("De Activating Event:{0}", Info.EventName)); IsActive = false; } break; } }