private void REGameShopToolStripMenuItem_Click(object sender, EventArgs e) { int u = 0; foreach (var NewItem in EditEnvir.GameShopList) { var OldItem = Envir.GameShopList.Find(x => x.GIndex == NewItem.GIndex); if (OldItem != null) { OldItem.UpdateItem(NewItem); } else { var CloneItem = GameShopItem.CloneItem(NewItem); Envir.GameShopList.Add(CloneItem); u++; } } SMain.Enqueue("[Gameshop DataBase] total items :" + Envir.GameShopList.Count.ToString()); SMain.Enqueue("[Gameshop DataBase] " + (Envir.GameShopList.Count - u).ToString() + " has been updated"); SMain.Enqueue("[Gameshop DataBase] " + u.ToString() + " has been added"); foreach (var p in Envir.Players)// update all info on players items { if (p.Info == null) { continue; } p.GetGameShop(); } }
public void Listen() { if (!HttpListener.IsSupported) { throw new System.InvalidOperationException( "To use HttpListener the operating system must be Windows XP SP2 or Server 2003 or higher."); } string[] prefixes = new string[] { host }; listener = new HttpListener(); try { foreach (string s in prefixes) { listener.Prefixes.Add(s); } listener.Start(); SMain.Enqueue("HttpService started."); } catch (Exception err) { SMain.Enqueue("HttpService start failed! Error:" + err); return; } while (is_active) { try { HttpListenerContext context = listener.GetContext(); HttpListenerRequest request = context.Request; Console.WriteLine("{0} {1} HTTP/1.1", request.HttpMethod, request.RawUrl); Console.WriteLine("User-Agent: {0}", request.UserAgent); Console.WriteLine("Accept-Encoding: {0}", request.Headers["Accept-Encoding"]); Console.WriteLine("Connection: {0}", request.KeepAlive ? "Keep-Alive" : "close"); Console.WriteLine("Host: {0}", request.UserHostName); HttpListenerResponse response = context.Response; var clientIP = context.Request.RemoteEndPoint.Address.ToString(); if (clientIP != Settings.HTTPTrustedIPAddress) { WriteResponse(response, "notrusted:" + clientIP); continue; } if (request.HttpMethod == "GET") { OnGetRequest(request, response); } else { OnPostRequest(request, response); } } catch { } } }
private void itemsToolStripMenuItem_Click(object sender, EventArgs e) { int u = 0; foreach (var NewItem in EditEnvir.ItemInfoList) { ItemInfo OldItem = Envir.ItemInfoList.Find(x => x.Index == NewItem.Index); if (OldItem != null) { OldItem.UpdateItem(NewItem); } else { ItemInfo CloneItem = ItemInfo.CloneItem(NewItem); Envir.ItemInfoList.Add(CloneItem); u++; } } SMain.Enqueue("[Item DataBase] total items :" + Envir.ItemInfoList.Count.ToString()); SMain.Enqueue("[Item DataBase] " + (Envir.ItemInfoList.Count - u).ToString() + " has been updated"); SMain.Enqueue("[Item DataBase] " + u.ToString() + " has been added"); /* * foreach (var c in Envir.Connections)// update all info on players items * { * if (!c.Connected) continue; * * foreach (var i in c.SentItemInfo) * { * var ni = new S.UpdateItemInfo { Info = i }; * //get name for updatetoname * if (ni.Info.UpdateTo > 0) * ni.updateto = Envir.GetItemInfo(ni.Info.UpdateTo).FriendlyName; * * c.Enqueue(ni); * * } * } */ foreach (var p in Envir.Players) // refresh all existing players stats { if (p.Info == null) { continue; } p.RefreshStats(); p.Enqueue(new S.RefreshStats()); } }
private void rleoadRecipeShopMenuItem_Click(object sender, EventArgs e) { int u = 0; foreach (var NewItem in EditEnvir.RecipeShopContents) { var OldItem = Envir.RecipeShopContents.Find(x => x.Index == NewItem.Index); if (OldItem != null) { OldItem = NewItem; } else { Envir.RecipeShopContents.Add(NewItem); u++; } } SMain.Enqueue("[Recipe Shop DataBase] total items :" + Envir.RecipeShopContents.Count.ToString()); SMain.Enqueue("[Recipe Shop DataBase] " + (Envir.RecipeShopContents.Count - u).ToString() + " has been updated"); SMain.Enqueue("[Recipe Shop DataBase] " + u.ToString() + " has been added"); }
private void craftingReloadToolStripMenuItem_Click(object sender, EventArgs e) { int newCrafts = 0; int updatedCrafts = 0; foreach (var craft in EditEnvir.CraftItems) { CraftItem tmp = Envir.CraftItems.Find(x => x.Recipie == craft.Recipie); if (tmp != null) { tmp = craft; updatedCrafts++; } else { CraftItem newCraft = craft; Envir.CraftItems.Add(newCraft); newCrafts++; } } SMain.Enqueue("[Recipes] total :" + Envir.CraftItems.Count.ToString()); SMain.Enqueue(string.Format("[Recipes] Updated : {0} | New Recipes : {1}", updatedCrafts, newCrafts)); //Envir.LoadCrafts(); }
private void magicToolStripMenuItem_Click(object sender, EventArgs e) { foreach (var NewMagic in EditEnvir.MagicInfoList) { MagicInfo OldMagic = Envir.MagicInfoList.Find(x => x.Spell == NewMagic.Spell); if (OldMagic != null) { OldMagic.Copy(NewMagic); } } foreach (var p in Envir.Players) { foreach (var Magic in Envir.MagicInfoList) { p.Enqueue(new S.RefreshMagic { Magic = (new UserMagic(Magic.Spell)).CreateClientMagic() }); } } SMain.Enqueue("[Magic DataBase] total magics :" + Envir.MagicInfoList.Count.ToString()); SMain.Enqueue("[Magic DataBase] " + (Envir.MagicInfoList.Count).ToString() + " has been updated"); }
private void monsterToolStripMenuItem_Click(object sender, EventArgs e) { int u = 0; foreach (var NewMob in EditEnvir.MonsterInfoList) { MonsterInfo OldMob = Envir.MonsterInfoList.Find(x => x.Index == NewMob.Index); if (OldMob != null) { OldMob.UpdateMonster(NewMob); } else { MonsterInfo CloneMonster = MonsterInfo.CloneMonster(NewMob); Envir.MonsterInfoList.Add(CloneMonster); u++; } } SMain.Enqueue("[Monster DataBase] total monsters :" + Envir.MonsterInfoList.Count.ToString()); SMain.Enqueue("[Monster DataBase] " + (Envir.MonsterInfoList.Count - u).ToString() + " has been updated"); SMain.Enqueue("[Monster DataBase] " + u.ToString() + " has been added"); }