public void SendFindConsortiaAlly(int state, int gameid) { GSPacketIn gSPacketIn = new GSPacketIn(69, gameid); gSPacketIn.WriteInt(state); gSPacketIn.WriteInt((int)RateMgr.GetRate(eRateType.Riches_Rate)); this.SendTCP(gSPacketIn); }
public void SendFindConsortiaAlly(int state, int gameid) { GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.FIND_CONSORTIA_ALLY, gameid); pkg.WriteInt(state); pkg.WriteInt((int)RateMgr.GetRate(eRateType.Riches_Rate)); SendTCP(pkg); }
public override bool Start() { if (m_isRunning) { return(false); } try { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Thread.CurrentThread.Priority = ThreadPriority.Normal; GameProperties.Refresh(); if (!InitComponent(RecompileScripts(), "Recompile Scripts")) { return(false); } if (!InitComponent(StartScriptComponents(), "Script components")) { return(false); } if (!InitComponent((GameProperties.EDITION == Edition), "Edition:" + Edition)) { return(false); } if (!InitComponent(InitSocket(IPAddress.Parse(Configuration.Ip), Configuration.Port), "InitSocket Port:" + Configuration.Port)) { return(false); } if (!InitComponent(AllocatePacketBuffers(), "AllocatePacketBuffers()")) { return(false); } if (!InitComponent(LogMgr.Setup(Configuration.GAME_TYPE, Configuration.ServerID, Configuration.AreaID), "LogMgr Init")) { return(false); } if (!InitComponent(WorldMgr.Init(), "WorldMgr Init")) { return(false); } if (!InitComponent(MapMgr.Init(), "MapMgr Init")) { return(false); } if (!InitComponent(ItemMgr.Init(), "ItemMgr Init")) { return(false); } if (!InitComponent(ItemBoxMgr.Init(), "ItemBox Init")) { return(false); } if (!InitComponent(BallMgr.Init(), "BallMgr Init")) { return(false); } if (!InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init")) { return(false); } if (!InitComponent(FusionMgr.Init(), "FusionMgr Init")) { return(false); } if (!InitComponent(AwardMgr.Init(), "AwardMgr Init")) { return(false); } if (!InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init")) { return(false); } if (!InitComponent(MissionInfoMgr.Init(), "MissionInfoMgr Init")) { return(false); } if (!InitComponent(PveInfoMgr.Init(), "PveInfoMgr Init")) { return(false); } if (!InitComponent(DropMgr.Init(), "Drop Init")) { return(false); } if (!InitComponent(FightRateMgr.Init(), "FightRateMgr Init")) { return(false); } if (!InitComponent(ConsortiaLevelMgr.Init(), "ConsortiaLevelMgr Init")) { return(false); } if (!InitComponent(RefineryMgr.Init(), "RefineryMgr Init")) { return(false); } if (!InitComponent(StrengthenMgr.Init(), "StrengthenMgr Init")) { return(false); } if (!InitComponent(PropItemMgr.Init(), "PropItemMgr Init")) { return(false); } if (!InitComponent(ShopMgr.Init(), "ShopMgr Init")) { return(false); } if (!InitComponent(QuestMgr.Init(), "QuestMgr Init")) { return(false); } if (!InitComponent(RoomMgr.Setup(Configuration.MaxRoomCount), "RoomMgr.Setup")) { return(false); } if (!InitComponent(GameMgr.Setup(Configuration.ServerID, GameProperties.BOX_APPEAR_CONDITION), "GameMgr.Start()")) { return(false); } if (!InitComponent(ConsortiaMgr.Init(), "ConsortiaMgr Init")) { return(false); } if (!InitComponent(LanguageMgr.Setup(@""), "LanguageMgr Init")) { return(false); } if (!InitComponent(RateMgr.Init(Configuration), "ExperienceRateMgr Init")) { return(false); } if (!InitComponent(MacroDropMgr.Init(), "MacroDropMgr Init")) { return(false); } if (!InitComponent(BattleMgr.Setup(), "BattleMgr Setup")) { return(false); } if (!InitComponent(InitGlobalTimer(), "Init Global Timers")) { return(false); } if (!InitComponent(MarryRoomMgr.Init(), "MarryRoomMgr Init")) { return(false); } if (!InitComponent(LogMgr.Setup(1, 4, 4), "LogMgr Setup")) { return(false); } GameEventMgr.Notify(ScriptEvent.Loaded); if (!InitComponent(InitLoginServer(), "Login To CenterServer")) { return(false); } RoomMgr.Start(); GameMgr.Start(); BattleMgr.Start(); MacroDropMgr.Start(); if (!InitComponent(base.Start(), "base.Start()")) { return(false); } GameEventMgr.Notify(GameServerEvent.Started, this); GC.Collect(GC.MaxGeneration); if (log.IsInfoEnabled) { log.Info("GameServer is now open for connections!"); } m_isRunning = true; return(true); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("Failed to start the server", e); } return(false); } }
public static void DoCommand(string CommandName, string[] CommandArgs) { PlayerBussiness bussiness; PlayerInfo userSingleByNickName; Exception exception; string str3; string str4; string str5; ManageBussiness bussiness2; switch (CommandName) { case "exit": GameServer.KeepRunning = false; break; case "cp": { GameClient[] allClients = GameServer.Instance.GetAllClients(); int num = (allClients == null) ? 0 : allClients.Length; GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); int num2 = (allPlayers == null) ? 0 : allPlayers.Length; List <BaseRoom> allUsingRoom = RoomMgr.GetAllUsingRoom(); int num3 = 0; int num4 = 0; foreach (BaseRoom room in allUsingRoom) { if (!room.IsEmpty) { num3++; if (room.IsPlaying) { num4++; } } } double totalMemory = GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", num, num2)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", num3, num4)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", (totalMemory / 1024.0) / 1024.0)); break; } case "setlevel": try { string path = Path.Combine(Environment.CurrentDirectory, "LevelList.xml"); if (!File.Exists(path)) { log.Error("LevelList.xml not found!"); } else { int num6; Console.Write("Please enter the level: "); string s = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(s, out num6)) { log.Error("Level is not valid int!"); } else { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName == null) { log.Error(string.Format("Player not found in db!", new object[0])); break; } if (!IsValidGZip(File.ReadAllBytes(path))) { log.Error("LevelList.xml is not valid!"); } else if (!IsValidXML(GZip.gzuncompress(File.ReadAllBytes(path)))) { log.Error("LevelList.xml is not valid!"); } if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } XmlDocument document = new XmlDocument(); document.LoadXml(GZip.gzuncompress(File.ReadAllBytes(path))); int num7 = -1; int num8 = -1; foreach (XmlNode node in document.SelectNodes("/Result/*")) { if (node.Attributes["Grade"].Value == s) { num7 = int.Parse(s); num8 = int.Parse(node.Attributes["GP"].Value) + 5; break; } } if ((num7 != -1) && (num8 != -1)) { userSingleByNickName.GP = num8; userSingleByNickName.Grade = num7; bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } else { log.Error(string.Format("Level {0} not found!", new object[0])); } } } } } catch (Exception exception1) { exception = exception1; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addmoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money += int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception3) { exception = exception3; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold += int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception4) { exception = exception4; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } userSingleByNickName.GiftToken += int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception5) { exception = exception5; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removemoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money -= int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception6) { exception = exception6; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold -= int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception7) { exception = exception7; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.GiftToken -= int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception8) { exception = exception8; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "shutdown": _count = 6; _timer = new System.Threading.Timer(new TimerCallback(ConsoleStart.ShutDownCallBack), null, 0, 0xea60); break; case "addcps": try { Console.Write("Insira o valor dos Cupons:"); int num9 = int.Parse((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.AddMoney(num9); player.SendMessage("Parab\x00e9ns, voc\x00ea recebeu " + num9 + " cupons do evento, bom jogo !"); } } catch (Exception exception9) { exception = exception9; log.Error("Error on AddCps", exception); } break; case "bnick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string nickName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string msg = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime date = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByNickName(nickName, date, false); bussiness2.KitoffUserByNickName(nickName, msg); } Console.WriteLine("O Usu\x00e1rio " + nickName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + nickName + " foi banido do servidor, motivo do BAN: " + msg + "."); } break; } case "buser": { Console.Clear(); Console.WriteLine("Digite o UserName do personagem: "); string userName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string str9 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime time2 = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByUserName(userName, time2, false); bussiness2.KitoffUserByUserName(userName, str9); } Console.WriteLine("O Usu\x00e1rio " + userName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + userName + " foi banido do servidor, motivo do BAN: " + str9 + "."); } break; } case "nkick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string name = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str11 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByNickName(name, str11); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + name + " foi kikado do servidor, motivo do KICK: " + str11 + "."); } break; } case "ukick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string str12 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str13 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByUserName(str12, str13); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + str12 + " foi kikado do servidor, motivo do KICK: " + str13 + "."); } break; } case "maint": try { int num10; Console.Write("Enter time in minutes to start maintenance: "); string str14 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(str14, out num10)) { log.Error("Invalid MainTime!"); } else { new Thread(delegate(object mt) { if (mt is string) { Action <string, string> Sys = delegate(string nick, string Text) { Console.WriteLine(Text); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.SendMessage(string.Format("[{0}] {1}", nick, Text)); } }; Action DisconnectAll = delegate { foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { log.Info(string.Format("Saving Player {0} into Database!", player.PlayerCharacter.NickName)); player.SaveIntoDatabase(); log.Info(string.Format("Disconnecting Player {0}!", player.PlayerCharacter.NickName)); player.Disconnect(); } log.Info("Shutdown Server!"); GameServer.Instance.Shutdown(); LogManager.Shutdown(); }; Sys("Auto Maintenance", "Manuten\x00e7\x00e3o agendada, fiquem atentos aos aviso!"); System.Timers.Timer MainTimer = new System.Timers.Timer { Interval = 1000.0 }; DateTime MainTime = DateTime.Parse(string.Format("{0} 00:00:00", "01/27/2011"), CultureInfo.GetCultureInfo("en-US")); MainTime = MainTime.AddMinutes(double.Parse(mt as string)); string CurrentTime = MainTime.ToString("HH:mm:ss"); MainTimer.Elapsed += delegate(object s, ElapsedEventArgs e) { if (CurrentTime != "00:00:00") { if ((MainTime.Minute != 0) && (MainTime.Second == 0)) { Sys("Auto Maintenance", string.Format("Falta {0} {1} para a manuten\x00e7\x00e3o!", MainTime.Minute, (MainTime.Minute == 1) ? "Minuto" : "Minutos")); } else if (MainTime.Second < 11) { Sys("Auto Maintenance", string.Format("Fechando o servidor em {0}", MainTime.Second)); } CurrentTime = MainTime.AddSeconds(-1.0).ToString("HH:mm:ss"); } else { Sys("Auto Maintenance", "Estamos desconectando todos os usu\x00e1rios para a manuten\x00e7\x00e3o, voltamos daqui a alguns minutos, saiam do servidor para evitar perca de itens!"); log.Info("End!"); DisconnectAll(); MainTimer.Stop(); } }; MainTimer.Start(); } }).Start(str14); } } catch (Exception exception10) { exception = exception10; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "savemap": break; case "clear": Console.Clear(); break; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); } else { Console.WriteLine("Ball info is Error!"); } break; case "map&reload": if (!MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Error!"); break; } Console.WriteLine("Map info is Reload!"); break; case "mapserver&reload": if (!MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Error!"); break; } Console.WriteLine("mapserver info is Reload!"); break; case "prop&reload": if (!PropItemMgr.Reload()) { Console.WriteLine("prop info is Error!"); break; } Console.WriteLine("prop info is Reload!"); break; case "item&reload": if (!ItemMgr.ReLoad()) { Console.WriteLine("item info is Error!"); break; } Console.WriteLine("item info is Reload!"); break; case "shop&reload": if (!ShopMgr.ReLoad()) { Console.WriteLine("shop info is Error!"); break; } Console.WriteLine("shop info is Reload!"); break; case "quest&reload": if (!QuestMgr.ReLoad()) { Console.WriteLine("quest info is Error!"); break; } Console.WriteLine("quest info is Reload!"); break; case "fusion&reload": if (!FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Error!"); break; } Console.WriteLine("fusion info is Reload!"); break; case "consortia&reload": if (!ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Error!"); break; } Console.WriteLine("consortiaMgr info is Reload!"); break; case "rate&reload": if (!RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Error!"); break; } Console.WriteLine("Rate Rate is Reload!"); break; case "fight&reload": if (!FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Error!"); break; } Console.WriteLine("FightRateMgr is Reload!"); break; case "dailyaward&reload": if (!AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Error!"); break; } Console.WriteLine("dailyaward is Reload!"); break; case "language&reload": if (!LanguageMgr.Reload("")) { Console.WriteLine("language is Error!"); break; } Console.WriteLine("language is Reload!"); break; case "treasure&reload": if (!TreasureAwardMgr.ReLoad()) { Console.WriteLine("TreasureAward is Error!"); break; } Console.WriteLine("TreasureAward is Reload!"); break; case "nickname": { Console.WriteLine("Please enter the nickname"); string str15 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine(WorldMgr.GetPlayerStringByPlayerNickName(str15)); break; } default: { string cmdLine = CommandName + string.Join(" ", CommandArgs); if (cmdLine.Length > 0) { if (cmdLine[0] == '/') { cmdLine = cmdLine.Remove(0, 1).Insert(0, "&"); } try { if (!CommandMgr.HandleCommandNoPlvl(client, cmdLine)) { Console.WriteLine("Unknown command: " + cmdLine); } } catch (Exception exception2) { Console.WriteLine(exception2.ToString()); } } break; } } }
public void SendAddRoom(BaseRoom room) { GSPacketIn gSPacketIn = new GSPacketIn(64); gSPacketIn.WriteInt(room.RoomId); gSPacketIn.WriteInt((int)room.GameType); gSPacketIn.WriteInt(room.GuildId); List <GamePlayer> players = room.GetPlayers(); gSPacketIn.WriteInt(players.Count); foreach (GamePlayer current in players) { gSPacketIn.WriteInt(current.PlayerCharacter.ID); gSPacketIn.WriteString(current.PlayerCharacter.NickName); gSPacketIn.WriteBoolean(current.PlayerCharacter.Sex); gSPacketIn.WriteByte(current.PlayerCharacter.typeVIP); gSPacketIn.WriteInt(current.PlayerCharacter.VIPLevel); gSPacketIn.WriteInt(current.PlayerCharacter.Hide); gSPacketIn.WriteString(current.PlayerCharacter.Style); gSPacketIn.WriteString(current.PlayerCharacter.Colors); gSPacketIn.WriteString(current.PlayerCharacter.Skin); gSPacketIn.WriteInt(current.PlayerCharacter.Offer); gSPacketIn.WriteInt(current.PlayerCharacter.GP); gSPacketIn.WriteInt(current.PlayerCharacter.Grade); gSPacketIn.WriteInt(current.PlayerCharacter.Repute); gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaID); gSPacketIn.WriteString(current.PlayerCharacter.ConsortiaName); gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaLevel); gSPacketIn.WriteInt(current.PlayerCharacter.ConsortiaRepute); gSPacketIn.WriteInt(current.PlayerCharacter.badgeID); gSPacketIn.WriteString(current.PlayerCharacter.WeaklessGuildProgressStr); gSPacketIn.WriteInt(current.PlayerCharacter.Attack); gSPacketIn.WriteInt(current.PlayerCharacter.Defence); gSPacketIn.WriteInt(current.PlayerCharacter.Agility); gSPacketIn.WriteInt(current.PlayerCharacter.Luck); gSPacketIn.WriteInt(current.PlayerCharacter.hp); gSPacketIn.WriteInt(current.PlayerCharacter.FightPower); gSPacketIn.WriteBoolean(current.PlayerCharacter.IsMarried); if (current.PlayerCharacter.IsMarried) { gSPacketIn.WriteInt(current.PlayerCharacter.SpouseID); gSPacketIn.WriteString(current.PlayerCharacter.SpouseName); } gSPacketIn.WriteDouble(current.GetBaseAttack()); gSPacketIn.WriteDouble(current.GetBaseDefence()); gSPacketIn.WriteDouble(current.GetBaseAgility()); gSPacketIn.WriteDouble(current.GetBaseBlood()); gSPacketIn.WriteInt(current.MainWeapon.TemplateID); gSPacketIn.WriteBoolean(current.CanUseProp); if (current.SecondWeapon != null) { gSPacketIn.WriteInt(current.SecondWeapon.TemplateID); gSPacketIn.WriteInt(current.SecondWeapon.StrengthenLevel); } else { gSPacketIn.WriteInt(0); gSPacketIn.WriteInt(0); } gSPacketIn.WriteDouble((double)RateMgr.GetRate(eRateType.Experience_Rate) * AntiAddictionMgr.GetAntiAddictionCoefficient(current.PlayerCharacter.AntiAddiction) * ((current.GPAddPlus == 0.0) ? 1.0 : current.GPAddPlus)); gSPacketIn.WriteDouble(AntiAddictionMgr.GetAntiAddictionCoefficient(current.PlayerCharacter.AntiAddiction) * ((current.OfferAddPlus == 0.0) ? 1.0 : current.OfferAddPlus)); gSPacketIn.WriteDouble((double)RateMgr.GetRate(eRateType.Experience_Rate)); gSPacketIn.WriteInt(GameServer.Instance.Configuration.ServerID); if (current.Pet == null) { gSPacketIn.WriteInt(0); } else { gSPacketIn.WriteInt(1); gSPacketIn.WriteInt(current.Pet.Place); gSPacketIn.WriteInt(current.Pet.TemplateID); gSPacketIn.WriteInt(current.Pet.ID); gSPacketIn.WriteString(current.Pet.Name); gSPacketIn.WriteInt(current.Pet.UserID); gSPacketIn.WriteInt(current.Pet.Level); gSPacketIn.WriteString(current.Pet.Skill); gSPacketIn.WriteString(current.Pet.SkillEquip); } List <AbstractBuffer> allBuffer = current.BufferList.GetAllBuffer(); gSPacketIn.WriteInt(allBuffer.Count); foreach (AbstractBuffer current2 in allBuffer) { BufferInfo info = current2.Info; gSPacketIn.WriteInt(info.Type); gSPacketIn.WriteBoolean(info.IsExist); gSPacketIn.WriteDateTime(info.BeginDate); gSPacketIn.WriteInt(info.ValidDate); gSPacketIn.WriteInt(info.Value); gSPacketIn.WriteInt(info.ValidCount); } gSPacketIn.WriteInt(current.EquipEffect.Count); foreach (ItemInfo current3 in current.EquipEffect) { gSPacketIn.WriteInt(current3.TemplateID); gSPacketIn.WriteInt(current3.Hole1); } } this.SendTCP(gSPacketIn); }
public void HandleRate(GSPacketIn packet) { RateMgr.ReLoad(); }
public void HandleReload(GSPacketIn packet) { eReloadType type = (eReloadType)packet.ReadInt(); bool result = false; switch (type) { case eReloadType.ball: result = BallMgr.ReLoad(); break; case eReloadType.fusion: result = FusionMgr.ReLoad(); break; case eReloadType.item: result = ItemMgr.ReLoad(); break; case eReloadType.map: result = MapMgr.ReLoadMap(); break; case eReloadType.mapserver: result = MapMgr.ReLoadMapServer(); break; case eReloadType.quest: result = QuestMgr.ReLoad(); break; case eReloadType.server: GameServer.Instance.Configuration.Refresh(); break; case eReloadType.rate: result = RateMgr.ReLoad(); break; case eReloadType.fight: result = FightRateMgr.ReLoad(); break; case eReloadType.dailyaward: result = AwardMgr.ReLoad(); break; case eReloadType.language: result = LanguageMgr.Reload(""); break; default: break; case eReloadType.shop: result = ShopMgr.ReLoad(); break; case eReloadType.consortia: result = ConsortiaMgr.ReLoad(); break; //case eReloadType.prop: // result = PropItemMgr.Reload(); // break; } packet.WriteInt(GameServer.Instance.Configuration.ServerID); packet.WriteBoolean(result); SendTCP(packet); }
public override void OnStopping(BaseSceneGame game, Game.Base.Packets.GSPacketIn pkg) { base.OnStopping(game, pkg); game.BeginTimer(TIMEOUT / 2); TankData data = game.Data; pkg.WriteByte((byte)data.Players.Count); int winTeam = -1; int lastTeam = -1; data.killFlag = false; foreach (KeyValuePair <GamePlayer, Player> p in data.Players) { //if(p.Value.TotalHurt > 0) //{ // data.killFlag = true; //} if (winTeam == -1 && p.Value.Blood > 0) { if (game.GameMode == eGameMode.FLAG) { if (p.Value.IsCaptain) { winTeam = p.Key.CurrentTeamIndex; break; } else { lastTeam = p.Key.CurrentTeamIndex; } } else { winTeam = p.Key.CurrentTeamIndex; break; } } } //if (!data.killFlag) //{ // game.BeginTimer(3000); //} if (winTeam == -1 && game.Data.CurrentIndex == null) { winTeam = lastTeam; } if (winTeam == -1) { if (game.Data.CurrentFire != null) { winTeam = game.Data.CurrentFire.CurrentTeamIndex; } else { winTeam = data.LastDead; } } int GP; //E等级差=(对方平均等级+5)-玩家等级;取值区间(1~9); // P赢=4*[(对方平均等级+5)-玩家等级]+伤害的血量*0.2%+击杀数*2+(命中次数/玩家总的回合次数)*8; //P输=1*[(对方平均等级+5)-玩家等级]+伤害的血量*0.2%+击杀数*2+(命中次数/玩家总的回合次数)*8 // P赢=[2+伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*[(对方平均等级+10)-玩家等级] //P输=[伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*[(对方平均等级+10)-玩家等级]; // P赢=[2+伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[1+(总击杀数-1)*33%] //P输=[伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[1+(总击杀数-1)*33%] //P赢=[2+伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[0.9+(游戏开始时对方玩家人数-1)*30%] //P输=[伤害的血量*0.1%+击杀数*0.5+(命中次数/玩家总的回合次数)*2]*对方平均等级*[0.9+(游戏开始时对方玩家人数-1)*30%] //bool flag = data.GameStart.AddMinutes(1).CompareTo(DateTime.Now) > 0; string winStr = LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg5"); GamePlayer winPlayer = null; string loseStr = LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg5"); GamePlayer losePlayer = null; foreach (KeyValuePair <GamePlayer, Player> p in data.Players) { if (game.RoomType == 0) { p.Key.PlayerCharacter.CheckCount++; } else { p.Key.PlayerCharacter.CheckCount += 2; } p.Key.Out.SendCheckCode(); if (p.Value.TotalHurt > 0) { data.killFlag = true; } if (game.GameClass == eGameClass.CONSORTIA) { if (p.Key.CurrentTeamIndex == winTeam) { winStr += " [" + p.Key.PlayerCharacter.NickName + "] "; winPlayer = p.Key; } else { loseStr += " [" + p.Key.PlayerCharacter.NickName + "] "; losePlayer = p.Key; } } } int riches = 0; if (game.GameClass == eGameClass.CONSORTIA) { winStr += LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg1") + losePlayer.PlayerCharacter.ConsortiaName + LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg2"); loseStr += LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg3") + winPlayer.PlayerCharacter.ConsortiaName + LanguageMgr.GetTranslation("Game.Server.SceneGames.OnStopping.Msg4"); riches = ConsortiaMgr.ConsortiaFight(winPlayer.CurrentTeamIndex == 1 ? data.ConsortiaID1 : data.ConsortiaID2, winPlayer.CurrentTeamIndex == 1 ? data.ConsortiaID2 : data.ConsortiaID1, game.Data.Players, game.RoomType, game.GameClass, data.persons[winPlayer.CurrentTeamIndex].TotalKillHealth); GameServer.Instance.LoginServer.SendConsortiaFight(winPlayer.PlayerCharacter.ConsortiaID, riches, winStr); //GameServer.Instance.LoginServer.SendConsortiaFight(losePlayer.PlayerCharacter.ConsortiaID, -riches, loseStr); } foreach (KeyValuePair <GamePlayer, Player> p in data.Players) { GP = 1; if (p.Value.State != TankGameState.LOSE) { if (game.RoomType == eRoomType.PAIRUP) { p.Key.PlayerCharacter.Total++; } double level = (data.TotalLevel - data.persons[p.Key.CurrentTeamIndex].TotalLevel) / (data.TotalPerson - data.persons[p.Key.CurrentTeamIndex].TeamPerson); double disLevel = level + 10 - p.Key.PlayerCharacter.Grade; if (p.Key.CurrentTeamIndex == winTeam) { if (game.RoomType == eRoomType.PAIRUP) { p.Key.PlayerCharacter.Win++; } //GP = (int)Math.Ceiling((((data.killFlag ? 2 : 0) + (double)p.Value.TotalHurt * 0.001 + p.Value.TotalKill * 0.5 + (p.Value.HitNum / (p.Value.BoutNum == 0 ? 1 : p.Value.BoutNum)) * 2) * level * (1 + (data.persons[p.Key.CurrentTeamIndex].TatolKill - 1) * 0.33))); GP = (int)Math.Ceiling((((data.killFlag ? 2 : 0) + (double)p.Value.TotalHurt * 0.001 + p.Value.TotalKill * 0.5 + (p.Value.HitNum / (p.Value.BoutNum == 0 ? 1 : p.Value.BoutNum)) * 2) * level * (0.9 + (data.persons[p.Key.CurrentTeamIndex].TeamPerson - 1) * 0.3))); } else { GP = (int)Math.Ceiling(((double)p.Value.TotalHurt * 0.001 + p.Value.TotalKill * 0.5 + (p.Value.HitNum / (p.Value.BoutNum == 0 ? 1 : p.Value.BoutNum)) * 2) * level * (0.9 + (data.persons[p.Key.CurrentTeamIndex].TeamPerson - 1) * 0.3)); } bool isMarried = false; if (p.Key.PlayerCharacter.IsMarried) { foreach (GamePlayer q in data.Players.Keys) { if (q.PlayerCharacter.ID != p.Key.PlayerCharacter.ID) { if (q.CurrentTeamIndex == p.Key.CurrentTeamIndex && p.Key.PlayerCharacter.SpouseID == q.PlayerCharacter.ID) { GP = (int)(GP * 1.2); isMarried = true; } } } } p.Key.QuestInventory.CheckWin(data.MapIndex, (int)game.GameMode, game.ScanTime, p.Value.IsCaptain, data.persons[p.Key.CurrentTeamIndex].TeamPerson, data.TotalPerson - data.persons[p.Key.CurrentTeamIndex].TeamPerson, p.Key.CurrentTeamIndex == winTeam, game.GameClass == eGameClass.CONSORTIA, (int)game.RoomType, isMarried); double AAS = AntiAddictionMgr.GetAntiAddictionCoefficient(p.Key.PlayerCharacter.AntiAddiction); GP = (int)(GP * AAS); GP = (int)(GP * RateMgr.GetRate(eRateType.Experience_Rate)); GP *= p.Key.BuffInventory.GPMultiple(); if (game.RoomType != eRoomType.PAIRUP && (disLevel <= 0 || disLevel >= 20)) { GP = 1; } if (AAS < 10E-6) { GP = 0; } else { if (GP < 1) { GP = 1; } } p.Key.SetGP(GP); Dictionary <int, int> requestItems = p.Key.QuestInventory.GetRequestItems(); List <MapGoodsInfo> questItems = Managers.MapMgr.GetQuestGoodsAll(data.MapIndex); foreach (MapGoodsInfo questID in questItems) { if (requestItems.ContainsKey(questID.GoodsID) && requestItems[questID.GoodsID] > 0) { int total = random.Next(questID.Value + 1); if (p.Key.CurrentTeamIndex != winTeam) { total = total / 2; } else if (total < 1) { total = 1; } if (total < 1) { continue; } int count = requestItems[questID.GoodsID] > total ? total : requestItems[questID.GoodsID]; ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.GetSingleGoods(questID.GoodsID); p.Key.TempInventory.AddItemTemplate(temp, questID, count); requestItems[questID.GoodsID] -= count; } } } //p.Value.IsTakeOut = true; pkg.WriteInt(p.Key.PlayerCharacter.ID); pkg.WriteBoolean(winTeam == p.Key.CurrentTeamIndex); pkg.WriteInt(p.Key.PlayerCharacter.Grade); pkg.WriteInt(p.Key.PlayerCharacter.GP); pkg.WriteInt((int)p.Value.TotalKill); pkg.WriteInt(p.Value.TotalHurt); pkg.WriteInt(GP); pkg.WriteInt((int)p.Value.HitNum); pkg.WriteInt((int)p.Value.BoutNum); pkg.WriteInt(p.Value.Offer); if (data.persons[p.Key.CurrentTeamIndex].TotalKillHealth > 0) { p.Value.IsTakeOut = true; if (p.Key.CurrentGame != null) { p.Key.CurrentGame.IsTakeOut = true; } } pkg.WriteBoolean(p.Value.IsTakeOut); } pkg.WriteInt(riches); //pkg.WriteBoolean(data.killFlag); pkg.WriteInt(data.TotalPerson / 2); data.InsertGameInfo(game, winTeam); GamePlayer[] list = data.Players.Keys.ToArray(); foreach (GamePlayer p in list) { if (data.Players[p].State == TankGameState.LOSE) { data.Players.Remove(p); } else { //data.Players[p].Reset(); //p.PropInventory.Clear(); //if (!killFlag) //{ // if (p.CurrentGame.GameState != eGameState.FREE) // { // p.CurrentGame.ShowArk(p.CurrentGame, p); // } //} } } }
public void SendAddRoom(Game.Server.Rooms.BaseRoom room) { GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.ROOM_CREATE); pkg.WriteInt(room.RoomId); pkg.WriteInt((int)room.GameType); pkg.WriteInt(room.GuildId); List <GamePlayer> players = room.GetPlayers(); pkg.WriteInt(players.Count); foreach (GamePlayer p in players) { pkg.WriteInt(p.PlayerCharacter.ID);//改为唯一ID pkg.WriteString(p.PlayerCharacter.NickName); pkg.WriteBoolean(p.PlayerCharacter.Sex); pkg.WriteInt(p.PlayerCharacter.Hide); pkg.WriteString(p.PlayerCharacter.Style); pkg.WriteString(p.PlayerCharacter.Colors); pkg.WriteString(p.PlayerCharacter.Skin); pkg.WriteInt(p.PlayerCharacter.Offer); pkg.WriteInt(p.PlayerCharacter.GP); pkg.WriteInt(p.PlayerCharacter.Grade); pkg.WriteInt(p.PlayerCharacter.Repute); pkg.WriteInt(p.PlayerCharacter.ConsortiaID); pkg.WriteString(p.PlayerCharacter.ConsortiaName); pkg.WriteInt(p.PlayerCharacter.ConsortiaLevel); pkg.WriteInt(p.PlayerCharacter.ConsortiaRepute); pkg.WriteInt(p.PlayerCharacter.Attack); pkg.WriteInt(p.PlayerCharacter.Defence); pkg.WriteInt(p.PlayerCharacter.Agility); pkg.WriteInt(p.PlayerCharacter.Luck); pkg.WriteDouble(p.GetBaseAttack()); pkg.WriteDouble(p.GetBaseDefence()); pkg.WriteDouble(p.GetBaseAgility()); pkg.WriteDouble(p.GetBaseBlood()); pkg.WriteInt(p.MainWeapon.TemplateID); pkg.WriteBoolean(p.CanUseProp); if (p.SecondWeapon != null) { pkg.WriteInt(p.SecondWeapon.TemplateID); pkg.WriteInt(p.SecondWeapon.StrengthenLevel); } else { pkg.WriteInt(0); pkg.WriteInt(0); } pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate) * AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.GPAddPlus == 0 ? 1 : p.GPAddPlus)); pkg.WriteDouble(AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.OfferAddPlus == 0 ? 1 : p.OfferAddPlus)); pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate)); pkg.WriteInt(GameServer.Instance.Configuration.ServerID); List <AbstractBuffer> infos = p.BufferList.GetAllBuffer(); pkg.WriteInt(infos.Count); foreach (AbstractBuffer bufferInfo in infos) { BufferInfo info = bufferInfo.Info; pkg.WriteInt(info.Type); pkg.WriteBoolean(info.IsExist); pkg.WriteDateTime(info.BeginDate); pkg.WriteInt(info.ValidDate); pkg.WriteInt(info.Value); } pkg.WriteInt(p.EquipEffect.Count); foreach (int i in p.EquipEffect) { pkg.WriteInt(i); } } SendTCP(pkg); }
/// <summary> /// Handles the server action /// </summary> /// <param name="parameters"></param> public void OnAction(Hashtable parameters) { Console.WriteLine("Starting GameServer ... please wait a moment!"); GameServer.CreateInstance(new GameServerConfig()); GameServer.Instance.Start(); GameServer.KeepRunning = true; Console.WriteLine("Server started!"); ConsoleClient client = new ConsoleClient(); while (GameServer.KeepRunning) { try { handler = ConsoleCtrHandler; SetConsoleCtrlHandler(handler, true); Console.Write("> "); string line = Console.ReadLine(); string[] para = line.Split(' '); switch (para[0]) { case "exit": GameServer.KeepRunning = false; break; case "cp": GameClient[] clients = GameServer.Instance.GetAllClients(); int clientCount = clients == null ? 0 : clients.Length; GamePlayer[] players = WorldMgr.GetAllPlayers(); int playerCount = players == null ? 0 : players.Length; List <BaseRoom> rooms = RoomMgr.GetAllUsingRoom(); int roomCount = 0; int gameCount = 0; foreach (BaseRoom r in rooms) { if (!r.IsEmpty) { roomCount++; if (r.IsPlaying) { gameCount++; } } } double memoryCount = GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", clientCount, playerCount)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", roomCount, gameCount)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", memoryCount / 1024 / 1024)); break; case "shutdown": _count = 6; //_timer = new Timer(new TimerCallback(GameServer.Instance.ShutDownCallBack), null, 0, 60 * 1000); _timer = new Timer(new TimerCallback(ShutDownCallBack), null, 0, 60 * 1000); break; case "savemap": //TODO: break; case "clear": Console.Clear(); break; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); } else { Console.WriteLine("Ball info is Error!"); } break; case "map&reload": if (MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Reload!"); } else { Console.WriteLine("Map info is Error!"); } break; case "mapserver&reload": if (MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Reload!"); } else { Console.WriteLine("mapserver info is Error!"); } break; case "prop&reload": if (PropItemMgr.Reload()) { Console.WriteLine("prop info is Reload!"); } else { Console.WriteLine("prop info is Error!"); } break; case "item&reload": if (ItemMgr.ReLoad()) { Console.WriteLine("item info is Reload!"); } else { Console.WriteLine("item info is Error!"); } break; case "shop&reload": if (ShopMgr.ReLoad()) { Console.WriteLine("shop info is Reload!"); } else { Console.WriteLine("shop info is Error!"); } break; case "quest&reload": if (QuestMgr.ReLoad()) { Console.WriteLine("quest info is Reload!"); } else { Console.WriteLine("quest info is Error!"); } break; case "fusion&reload": if (FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Reload!"); } else { Console.WriteLine("fusion info is Error!"); } break; case "consortia&reload": if (ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Reload!"); } else { Console.WriteLine("consortiaMgr info is Error!"); } break; case "rate&reload": if (RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Reload!"); } else { Console.WriteLine("Rate Rate is Error!"); } break; case "fight&reload": if (FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Reload!"); } else { Console.WriteLine("FightRateMgr is Error!"); } break; case "dailyaward&reload": if (AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Reload!"); } else { Console.WriteLine("dailyaward is Error!"); } break; case "language&reload": if (LanguageMgr.Reload("")) { Console.WriteLine("language is Reload!"); } else { Console.WriteLine("language is Error!"); } break; case "nickname": Console.WriteLine("Please enter the nickname"); string nickname = Console.ReadLine(); string state = WorldMgr.GetPlayerStringByPlayerNickName(nickname); Console.WriteLine(state); break; default: if (line.Length <= 0) { break; } if (line[0] == '/') { line = line.Remove(0, 1); line = line.Insert(0, "&"); } try { bool res = CommandMgr.HandleCommandNoPlvl(client, line); if (!res) { Console.WriteLine("Unknown command: " + line); } } catch (Exception e) { Console.WriteLine(e.ToString()); } break; } } catch (Exception ex) { Console.WriteLine(ex); } } if (GameServer.Instance != null) { GameServer.Instance.Stop(); } LogManager.Shutdown(); }
public void HandleReload(GSPacketIn packet) { eReloadType eReloadType = (eReloadType)packet.ReadInt(); bool val = false; switch (eReloadType) { case eReloadType.ball: val = BallMgr.ReLoad(); break; case eReloadType.map: val = MapMgr.ReLoadMap(); break; case eReloadType.mapserver: val = MapMgr.ReLoadMapServer(); break; case eReloadType.item: val = ItemMgr.ReLoad(); break; case eReloadType.quest: val = QuestMgr.ReLoad(); break; case eReloadType.fusion: val = FusionMgr.ReLoad(); break; case eReloadType.server: GameServer.Instance.Configuration.Refresh(); break; case eReloadType.rate: val = RateMgr.ReLoad(); break; case eReloadType.consortia: val = ConsortiaMgr.ReLoad(); break; case eReloadType.shop: val = ShopMgr.ReLoad(); break; case eReloadType.fight: val = FightRateMgr.ReLoad(); break; case eReloadType.dailyaward: val = AwardMgr.ReLoad(); break; case eReloadType.language: val = LanguageMgr.Reload(""); break; } packet.WriteInt(GameServer.Instance.Configuration.ServerID); packet.WriteBoolean(val); this.SendTCP(packet); }
public void OnAction(Hashtable parameters) { Console.WriteLine("This server GunnyII, edit and build by SkelletonX!"); Console.WriteLine("Starting GameServer ... please wait a moment!"); GameServer.CreateInstance(new GameServerConfig()); GameServer.Instance.Start(); GameServer.KeepRunning = true; Console.WriteLine("Server started!"); ConsoleClient client = new ConsoleClient(); while (GameServer.KeepRunning) { try { ConsoleStart.handler = new ConsoleStart.ConsoleCtrlDelegate(ConsoleStart.ConsoleCtrHandler); ConsoleStart.SetConsoleCtrlHandler(ConsoleStart.handler, true); Console.Write("> "); string text = Console.ReadLine(); string[] array = text.Split(new char[] { ' ' }); string key; switch (key = array[0]) { case "exit": GameServer.KeepRunning = false; continue; //dragonares case "lock": Console.Clear(); Console.WriteLine("Ten tai khoan: "); string bnickname = Console.ReadLine(); Console.WriteLine("Ly do band: "); string breason = Console.ReadLine(); DateTime dt2 = new DateTime(2014, 07, 02); //Tempo de banimento using (ManageBussiness mg = new ManageBussiness()) { mg.ForbidPlayerByNickName(bnickname, dt2, false); } Console.WriteLine("Nguoi dung " + bnickname + " da bi khoa."); break; case "unlock": Console.Clear(); Console.WriteLine("Ten tai khoan: "); string bnickname2 = Console.ReadLine(); DateTime dt22 = new DateTime(2014, 07, 02); //Tempo de banimento using (ManageBussiness mg = new ManageBussiness()) { mg.ForbidPlayerByNickName(bnickname2, dt22, true); } Console.WriteLine("Nguoi dung " + bnickname2 + " da mo khoa."); break; case "thongbao": { Console.WriteLine("Thong bao: "); string value = Console.ReadLine(); Console.WriteLine(string.Format(value)); Console.WriteLine("Thong bao thanh cong ."); continue; } case "cp": { GameClient[] allClients = GameServer.Instance.GetAllClients(); int num2 = (allClients == null) ? 0 : allClients.Length; GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); int num3 = (allPlayers == null) ? 0 : allPlayers.Length; List <BaseRoom> allUsingRoom = RoomMgr.GetAllUsingRoom(); int num4 = 0; int num5 = 0; foreach (BaseRoom current in allUsingRoom) { if (!current.IsEmpty) { num4++; if (current.IsPlaying) { num5++; } } } double num6 = (double)GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", num2, num3)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", num4, num5)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", num6 / 1024.0 / 1024.0)); continue; } case "shutdown": ConsoleStart._count = 6; ConsoleStart._timer = new Timer(new TimerCallback(ConsoleStart.ShutDownCallBack), null, 0, 60000); continue; case "savemap": continue; case "clear": Console.Clear(); continue; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); continue; } Console.WriteLine("Ball info is Error!"); continue; case "map&reload": if (MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Reload!"); continue; } Console.WriteLine("Map info is Error!"); continue; case "mapserver&reload": if (MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Reload!"); continue; } Console.WriteLine("mapserver info is Error!"); continue; case "prop&reload": if (PropItemMgr.Reload()) { Console.WriteLine("prop info is Reload!"); continue; } Console.WriteLine("prop info is Error!"); continue; case "item&reload": if (ItemMgr.ReLoad()) { Console.WriteLine("item info is Reload!"); continue; } Console.WriteLine("item info is Error!"); continue; case "shop&reload": if (ShopMgr.ReLoad()) { Console.WriteLine("shop info is Reload!"); continue; } Console.WriteLine("shop info is Error!"); continue; case "quest&reload": if (QuestMgr.ReLoad()) { Console.WriteLine("quest info is Reload!"); continue; } Console.WriteLine("quest info is Error!"); continue; case "fusion&reload": if (FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Reload!"); continue; } Console.WriteLine("fusion info is Error!"); continue; case "consortia&reload": if (ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Reload!"); continue; } Console.WriteLine("consortiaMgr info is Error!"); continue; case "rate&reload": if (RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Reload!"); continue; } Console.WriteLine("Rate Rate is Error!"); continue; case "fight&reload": if (FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Reload!"); continue; } Console.WriteLine("FightRateMgr is Error!"); continue; case "dailyaward&reload": if (AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Reload!"); continue; } Console.WriteLine("dailyaward is Error!"); continue; case "language&reload": if (LanguageMgr.Reload("")) { Console.WriteLine("language is Reload!"); continue; } Console.WriteLine("language is Error!"); continue; case "nickname": { Console.WriteLine("Please enter the nickname"); string nickName = Console.ReadLine(); string playerStringByPlayerNickName = WorldMgr.GetPlayerStringByPlayerNickName(nickName); Console.WriteLine(playerStringByPlayerNickName); continue; } } if (text.Length > 0) { if (text[0] == '/') { text = text.Remove(0, 1); text = text.Insert(0, "&"); } try { if (!CommandMgr.HandleCommandNoPlvl(client, text)) { Console.WriteLine("Unknown command: " + text); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } catch (Exception value) { Console.WriteLine(value); } } if (GameServer.Instance != null) { GameServer.Instance.Stop(); } LogManager.Shutdown(); }