private void ProcessEndWar(Character character) { ++character.Stunned; GlobalHandler.SendFightingModeChangedResponse(character.Client, character.SessionId, (int)character.AccId, (short)-1); if (this.MvpCharacter != null) { ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => new BattlegroundCharacterResultRecord(this.CurrentWarResultRecordGuid, character.Name, character.EntityId.Low, (int)character.BattlegroundActPoints, character.BattlegroundKills, character.BattlegroundDeathes).CreateLater())); } int honorPoints = this.WiningFactionId == 2 ? 0 : CharacterFormulas.CalcHonorPoints(character.Level, character.BattlegroundActPoints, this.LightScores > this.DarkScores, character.BattlegroundDeathes, character.BattlegroundKills, this.MvpCharacter == character, this.Town); short honorCoins = this.WiningFactionId == 2 ? (short)0 : (short)((double)honorPoints / (double)CharacterFormulas.HonorCoinsDivider); if (character.BattlegroundActPoints < (short)5) { character.BattlegroundActPoints = (short)5; } if (honorPoints <= 0) { honorPoints = 1; } if (honorCoins <= (short)0) { honorCoins = (short)1; } Asda2Item asda2Item = (Asda2Item)null; if (honorCoins > (short)0) { int num = (int)character.Asda2Inventory.TryAdd(20614, (int)honorCoins, true, ref asda2Item, new Asda2InventoryType?(), (Asda2Item)null); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, character.EntryId) .AddAttribute("source", 0.0, "honor_coins_for_bg").AddItemAttributes(asda2Item, "") .AddAttribute("amount", (double)honorCoins, "").Write(); } int bonusExp = this.WiningFactionId == 2 ? 0 : (int)((double)XpGenerator.GetBaseExpForLevel(character.Level) * (double)character.BattlegroundActPoints / 2.5); character.GainXp(bonusExp, "battle_ground", false); character.Asda2HonorPoints += honorPoints; AchievementProgressRecord progressRecord = character.Achievements.GetOrCreateProgressRecord(20U); if (character.FactionId == (FactionId)this.WiningFactionId) { switch (++progressRecord.Counter) { case 5: character.DiscoverTitle(Asda2TitleId.Challenger125); break; case 10: character.GetTitle(Asda2TitleId.Challenger125); break; case 25: character.DiscoverTitle(Asda2TitleId.Winner126); break; case 50: character.GetTitle(Asda2TitleId.Winner126); break; case 75: character.DiscoverTitle(Asda2TitleId.Champion127); break; case 100: character.GetTitle(Asda2TitleId.Champion127); break; case 250: character.DiscoverTitle(Asda2TitleId.Conqueror128); break; case 500: character.GetTitle(Asda2TitleId.Conqueror128); break; } progressRecord.SaveAndFlush(); } character.Resurrect(); character.Map.CallDelayed(500, (Action)(() => Asda2BattlegroundHandler.SendWarEndedResponse(character.Client, (byte)this.WiningFactionId, this.LightScores > this.DarkScores ? this.LightScores : this.DarkScores, this.LightScores > this.DarkScores ? this.DarkScores : this.LightScores, honorPoints, honorCoins, (long)bonusExp, this.MvpCharacter == null ? "" : this.MvpCharacter.Name))); Asda2BattlegroundHandler.SendWarEndedOneResponse(character.Client, (IEnumerable <Asda2Item>) new List <Asda2Item>() { asda2Item }); character.SendWarMsg("You will automaticly teleported to town in 1 minute."); }
private void MenuExit_Click(object sender, EventArgs e) { GlobalHandler.Close(); Application.Exit(); }
public static void Main(string[] args) { mAlive = true; DateTime InitStart = DateTime.Now; // Set up basic output, configuration, etc Output.InitializeStream(true, OutputLevel.DebugInformation); Output.WriteLine("Initializing Snowlight..."); ConfigManager.Initialize(Constants.DataFileDirectory + "\\server-main.cfg"); Output.SetVerbosityLevel((OutputLevel)ConfigManager.GetValue("output.verbositylevel")); // Process args foreach (string arg in args) { Output.WriteLine("Command line argument: " + arg); Input.ProcessInput(arg.Split(' ')); } try { // Initialize and test database Output.WriteLine("Initializing MySQL manager..."); SqlDatabaseManager.Initialize(); // Initialize network components Output.WriteLine("Setting up server listener on port " + (int)ConfigManager.GetValue("net.bind.port") + "..."); mServer = new SnowTcpListener(new IPEndPoint(IPAddress.Any, (int)ConfigManager.GetValue("net.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( SessionManager.HandleIncomingConnection)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Output.WriteLine("Resetting database counters and statistics..."); PerformDatabaseCleanup(MySqlClient); Output.WriteLine("Initializing game components and workers..."); // Core DataRouter.Initialize(); // Sessions, characters Handshake.Initialize(); GlobalHandler.Initialize(); SessionManager.Initialize(); CharacterInfoLoader.Initialize(); RightsManager.Initialize(MySqlClient); SingleSignOnAuthenticator.Initialize(); // Room management and navigator RoomManager.Initialize(MySqlClient); RoomInfoLoader.Initialize(); RoomHandler.Initialize(); RoomItemHandler.Initialize(); Navigator.Initialize(MySqlClient); // Help and moderation HelpTool.Initialize(MySqlClient); ModerationPresets.Initialize(MySqlClient); ModerationTicketManager.Initialize(MySqlClient); ModerationHandler.Initialize(); ModerationBanManager.Initialize(MySqlClient); // Catalog, pets and items ItemDefinitionManager.Initialize(MySqlClient); CatalogManager.Initialize(MySqlClient); CatalogPurchaseHandler.Initialize(); Inventory.Initialize(); ItemEventDispatcher.Initialize(); PetDataManager.Initialize(MySqlClient); // Messenger MessengerHandler.Initialize(); // Achievements and quests AchievementManager.Initialize(MySqlClient); QuestManager.Initialize(MySqlClient); // Misc/extras CrossdomainPolicy.Initialize("Data\\crossdomain.xml"); InfobusManager.Initialize(); ActivityPointsWorker.Initialize(); BotManager.Initialize(MySqlClient); InterstitialManager.Initialize(MySqlClient); ChatEmotions.Initialize(); EffectsCacheWorker.Initialize(); RecyclerManager.Initialize(MySqlClient); DrinkSetManager.Initialize(MySqlClient); SongManager.Initialize(); TradeHandler.Initialize(); RandomGenerator.Initialize(); StatisticsSyncUtil.Initialize(); // Polish WarningSurpressors.Initialize(); } } catch (Exception e) { HandleFatalError("Could not initialize Snowlight: " + e.Message + "\n" + e.StackTrace); return; } // Init complete TimeSpan TimeSpent = DateTime.Now - InitStart; Output.WriteLine("The server has initialized successfully (" + Math.Round(TimeSpent.TotalSeconds, 2) + " seconds). Ready for connections.", OutputLevel.Notification); Output.WriteLine("Press the ENTER key for command input. Shut down server with 'STOP' command.", OutputLevel.Notification); Console.Beep(); Input.Listen(); // This will make the main thread process console while Program.Alive. }
public override void Update(int dt) { base.Update(dt); if (m_isLoggingOut) { m_logoutTimer.Update(dt); } if (!IsMoving && LastSendIamNotMoving < (uint)Environment.TickCount) { LastSendIamNotMoving = (uint)(Environment.TickCount + CharacterFormulas.TimeBetweenImNotMovingPacketSendMillis); Asda2MovmentHandler.SendStartMoveCommonToAreaResponse(this, true, false); } Asda2MovmentHandler.CalculateAndSetRealPos(this, dt); if (Asda2Pet != null) { if (LastPetExpGainTime < (uint)Environment.TickCount) { Asda2Pet.GainXp(1); LastPetExpGainTime = (uint)Environment.TickCount + CharacterFormulas.TimeBetweenPetExpGainSecs * 1000; } if (!PetNotHungerEnabled && LastPetEatingTime < (uint)Environment.TickCount) { if (Asda2Pet.HungerPrc == 1) { Asda2TitleChecker.OnPetStarve(this); //Stop pet Asda2PetHandler.SendPetGoesSleepDueStarvationResponse(Client, Asda2Pet); Asda2Pet.RemoveStatsFromOwner(); Asda2Pet.HungerPrc = 0; Asda2Pet = null; GlobalHandler.UpdateCharacterPetInfoToArea(this); } else { Asda2Pet.HungerPrc--; LastPetEatingTime = (uint)Environment.TickCount + CharacterFormulas.TimeBetweenPetEatingsSecs * 1000; } } } if (PremiumBuffs.Count > 0) { foreach (var functionItemBuff in PremiumBuffs.Values) { if (functionItemBuff.Duration < dt) { ProcessFunctionalItemEffect(functionItemBuff, false); CategoryBuffsToDelete.Add(functionItemBuff.Template.Category); functionItemBuff.DeleteLater(); } else { functionItemBuff.Duration -= dt; } } } foreach (var functionItemBuff in LongTimePremiumBuffs) { if (functionItemBuff == null) { continue; } if (functionItemBuff.EndsDate < DateTime.Now) { ProcessFunctionalItemEffect(functionItemBuff, false); CategoryBuffsToDelete.Add(functionItemBuff.Template.Category); functionItemBuff.DeleteLater(); } } if (CategoryBuffsToDelete.Count > 0) { foreach (var asda2ItemCategory in CategoryBuffsToDelete) { PremiumBuffs.Remove(asda2ItemCategory); for (int i = 0; i < LongTimePremiumBuffs.Length; i++) { if (LongTimePremiumBuffs[i] == null || LongTimePremiumBuffs[i].Template.Category != asda2ItemCategory) { continue; } LongTimePremiumBuffs[i] = null; break; } } CategoryBuffsToDelete.Clear(); } var toDelete = new List <Asda2PereodicActionType>(); foreach (var pereodicAction in PereodicActions) { pereodicAction.Value.Update(dt); if (pereodicAction.Value.CallsNum <= 0) { toDelete.Add(pereodicAction.Key); } } foreach (var t in toDelete) { PereodicActions.Remove(t); } if (SoulmateRecord != null) { SoulmateRecord.OnUpdateTick(); } if (BanChatTill < DateTime.Now) { BanChatTill = null; ChatBanned = false; SendInfoMsg("Chat is unbanned."); } }
/// <summary> /// Collects all update-masks from nearby objects /// </summary> internal void UpdateEnvironment(HashSet <WorldObject> updatedObjects) { var toRemove = WorldObjectSetPool.Obtain(); toRemove.AddRange(KnownObjects); toRemove.Remove(this); NearbyObjects.Clear(); if (m_initialized) { Observing.IterateEnvironment(BroadcastRange, (obj) => { if (Client == null || Client.ActiveCharacter == null) { if (Client == null) { LogUtil.WarnException("Client is null. removeing from map and world? {0}[{1}]", Name, AccId); } else { if (Client.ActiveCharacter == null) { LogUtil.WarnException("Client.ActiveCharacter is null. removeing from map and world? {0}[{1}]", Name, AccId); } } if (Map != null) { Map.AddMessage(() => { Map.RemoveObject(this); World.RemoveCharacter(this); }); } return(false); } if (!Observing.IsInPhase(obj)) { return(true); } if (obj is GameObject && obj.GetDistance(this) > BroadcastRangeNpc) { return(true); } NearbyObjects.Add(obj); //ensure "this" never goes out of range //if we are observing another units broadcasts if (!Observing.CanSee(obj) && !ReferenceEquals(obj, this)) { return(true); } if (!KnownObjects.Contains(obj)) { // encountered new object //TODO Send upadte Packets here ASDA var visibleChr = obj as Character; if (visibleChr != null && visibleChr != this) { GlobalHandler.SendCharacterVisibleNowResponse(Client, visibleChr); if (visibleChr.Asda2Pet != null) { GlobalHandler.SendCharacterInfoPetResponse(Client, visibleChr); } if (visibleChr.IsAsda2TradeDescriptionEnabled) { Asda2PrivateShopHandler.SendtradeStatusTextWindowResponseToOne( visibleChr, Client); } GlobalHandler.SendCharacterPlaceInTitleRatingResponse(Client, visibleChr); GlobalHandler.SendBuffsOnCharacterInfoResponse(Client, visibleChr); if (visibleChr.IsInGuild) { GlobalHandler.SendCharacterInfoClanNameResponse(Client, visibleChr); } GlobalHandler.SendCharacterFactionAndFactionRankResponse(Client, visibleChr); GlobalHandler.SendCharacterFriendShipResponse(Client, visibleChr); if (visibleChr.ChatRoom != null) { ChatMgr.SendChatRoomVisibleResponse(visibleChr, ChatRoomVisibilityStatus.Visible, visibleChr.ChatRoom, this); } CheckAtackStateWithCharacter(visibleChr); if (visibleChr.Asda2WingsItemId != -1) { FunctionalItemsHandler.SendWingsInfoResponse(visibleChr, Client); } if (visibleChr.TransformationId != -1) { GlobalHandler.SendTransformToPetResponse(visibleChr, true, Client); } if (visibleChr.IsOnTransport) { FunctionalItemsHandler.SendShopItemUsedResponse(Client, visibleChr, int.MaxValue); } if (visibleChr.IsOnMount) { Asda2MountHandler.SendCharacterOnMountStatusChangedToPneClientResponse(Client, visibleChr); } } else { var visibleMonstr = obj as NPC; if (visibleMonstr != null && visibleMonstr.IsAlive) { GlobalHandler.SendMonstrVisibleNowResponse(Client, visibleMonstr); } else { var npc = obj as GameObject; if (npc != null && npc.GoId != GOEntryId.Portal) { if (!IsAsda2BattlegroundInProgress || CurrentBattleGround.WarType != Asda2BattlegroundType.Deathmatch || MapId != MapId.BatleField) { GlobalHandler.SendNpcVisiableNowResponse(Client, npc); } } else { var loot = obj as Asda2Loot; if (loot != null) { GlobalHandler.SendItemVisible(this, loot); } } } } OnEncountered(obj); } toRemove.Remove(obj); // still in range, no need to remove it return(true); }); //update group member stats for out of range players if (m_groupMember != null) { m_groupMember.Group.UpdateOutOfRangeMembers(m_groupMember); } // delete objects that are not in range anymore foreach (var obj in toRemove) { OnOutOfRange(obj); } } // init player, delete Items etc Action action; while (m_environmentQueue.TryDequeue(out action)) { var ac = action; // need to Add a message because Update state will be reset after method call AddMessage(ac); } // check rest state if (m_restTrigger != null) { UpdateRestState(); } toRemove.Clear(); WorldObjectSetPool.Recycle(toRemove); }
public static void Main(string[] args) { mAlive = true; DateTime InitStart = DateTime.Now; // Set up basic output Console.WriteLine("Initializing Snowlight..."); // Cannot be localized before config+lang is loaded // Load configuration, translation, and re-configure output from config data ConfigManager.Initialize(Constants.DataFileDirectory + "server-main.cfg"); Output.InitializeStream(true, (OutputLevel)ConfigManager.GetValue("output.verbositylevel")); Output.WriteLine("Initializing Snowlight..."); Localization.Initialize(Constants.LangFileDirectory + "lang_" + ConfigManager.GetValue("lang") + ".lang"); // Process args foreach (string arg in args) { Output.WriteLine(Localization.GetValue("core.init.cmdarg", arg)); Input.ProcessInput(arg.Split(' ')); } try { // Initialize and test database Output.WriteLine(Localization.GetValue("core.init.mysql")); SqlDatabaseManager.Initialize(); // Initialize network components Output.WriteLine(Localization.GetValue("core.init.net", ConfigManager.GetValue("net.bind.port").ToString())); mServer = new SnowTcpListener(new IPEndPoint((IPAddress)ConfigManager.GetValue("net.bind.ip"), (int)ConfigManager.GetValue("net.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( SessionManager.HandleIncomingConnection)); Output.WriteLine(Localization.GetValue("core.init.net", ConfigManager.GetValue("net.cmd.bind.port").ToString())); musServer = new SnowTcpListener(new IPEndPoint((IPAddress)ConfigManager.GetValue("net.cmd.bind.ip"), (int)ConfigManager.GetValue("net.cmd.bind.port")), (int)ConfigManager.GetValue("net.backlog"), new OnNewConnectionCallback( CommandListener.parse)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Output.WriteLine(Localization.GetValue("core.init.dbcleanup")); PerformDatabaseCleanup(MySqlClient); Output.WriteLine(Localization.GetValue("core.init.game")); // Core DataRouter.Initialize(); // Sessions, characters Handshake.Initialize(); GlobalHandler.Initialize(); SessionManager.Initialize(); CharacterInfoLoader.Initialize(); RightsManager.Initialize(MySqlClient); SingleSignOnAuthenticator.Initialize(); // Room management and navigator RoomManager.Initialize(MySqlClient); RoomInfoLoader.Initialize(); RoomHandler.Initialize(); RoomItemHandler.Initialize(); Navigator.Initialize(MySqlClient); // Help and moderation HelpTool.Initialize(MySqlClient); ModerationPresets.Initialize(MySqlClient); ModerationTicketManager.Initialize(MySqlClient); ModerationHandler.Initialize(); ModerationBanManager.Initialize(MySqlClient); // Catalog, pets and items ItemDefinitionManager.Initialize(MySqlClient); CatalogManager.Initialize(MySqlClient); CatalogPurchaseHandler.Initialize(); Inventory.Initialize(); ItemEventDispatcher.Initialize(); PetDataManager.Initialize(MySqlClient); // Messenger MessengerHandler.Initialize(); // Achievements and quests AchievementManager.Initialize(MySqlClient); QuestManager.Initialize(MySqlClient); // Misc/extras CrossdomainPolicy.Initialize("Data\\crossdomain.xml"); InfobusManager.Initialize(); ActivityPointsWorker.Initialize(); BotManager.Initialize(MySqlClient); InterstitialManager.Initialize(MySqlClient); ChatEmotions.Initialize(); EffectsCacheWorker.Initialize(); RecyclerManager.Initialize(MySqlClient); DrinkSetManager.Initialize(MySqlClient); SongManager.Initialize(); TradeHandler.Initialize(); RandomGenerator.Initialize(); StatisticsSyncUtil.Initialize(); Wordfilter.Initialize(MySqlClient); // Polish WarningSurpressors.Initialize(); } } catch (Exception e) { HandleFatalError(Localization.GetValue("core.init.error.details", new string[] { e.Message, e.StackTrace })); return; } // Init complete TimeSpan TimeSpent = DateTime.Now - InitStart; Output.WriteLine(Localization.GetValue("core.init.ok", Math.Round(TimeSpent.TotalSeconds, 2).ToString()), OutputLevel.Notification); Output.WriteLine((string)Localization.GetValue("core.init.ok.cmdinfo"), OutputLevel.Notification); Console.Write("$" + Environment.UserName.ToLower() + "@snowlight> "); Console.Beep(); Input.Listen(); // This will make the main thread process console while Program.Alive. }
private void ProcessEndWar(Character character) { character.Stunned++; GlobalHandler.SendFightingModeChangedResponse(character.Client, character.SessionId, (int)character.AccId, -1); //create db record if (MvpCharacter != null) { RealmServer.IOQueue.AddMessage(() => { var rec = new BattlegroundCharacterResultRecord(CurrentWarResultRecordGuid, character.Name, character.EntityId.Low, character.BattlegroundActPoints, character.BattlegroundKills, character.BattlegroundDeathes); rec.CreateLater(); }); } var honorPoints = WiningFactionId == 2 ? 0 : CharacterFormulas.CalcHonorPoints(character.Level, character.BattlegroundActPoints, LightScores > DarkScores, character.BattlegroundDeathes, character.BattlegroundKills, MvpCharacter == character, Town); var honorCoins = (short)(WiningFactionId == 2 ? 0 : (honorPoints / CharacterFormulas.HonorCoinsDivider)); if (character.BattlegroundActPoints < 5) { character.BattlegroundActPoints = 5; } if (honorPoints <= 0) { honorPoints = 1; } if (honorCoins <= 0) { honorCoins = 1; } Asda2Item itemCoins = null; if (honorCoins > 0) { character.Asda2Inventory.TryAdd( 20614, honorCoins, true, ref itemCoins); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, character.EntryId) .AddAttribute("source", 0, "honor_coins_for_bg") .AddItemAttributes(itemCoins) .AddAttribute("amount", honorCoins) .Write(); } var bonusExp = WiningFactionId == 2 ? 0 : (int)((float)XpGenerator.GetBaseExpForLevel(character.Level) * character.BattlegroundActPoints / 2.5); character.GainXp(bonusExp, "battle_ground"); character.Asda2HonorPoints += honorPoints; Asda2BattlegroundHandler.SendWarEndedResponse(character.Client, (byte)WiningFactionId, LightScores > DarkScores ? LightScores : DarkScores, LightScores > DarkScores ? DarkScores : LightScores, honorPoints, honorCoins, bonusExp, MvpCharacter == null ? "" : MvpCharacter.Name); Asda2BattlegroundHandler.SendWarEndedOneResponse(character.Client, new List <Asda2Item> { itemCoins }); character.SendWarMsg("ÓæÝ íÊã ÅÑÓÇáß Åáì ÇáãÏíäÉ ÈÚÏ 1 ÏÞíÞÉ ãä ÇáÇä."); }
public void DeviceRemovedHandler() { GlobalHandler.Detach(GetGamingPanel()); }