private TimeoutLock(object o) { target = o; #if DEBUG leakDetector = new Sentinel(); #endif }
/// <summary> /// Initializes a new instance of the <see cref="TimedLock"/> struct. /// </summary> /// <param retval="o"> /// The object to lock. /// </param> private TimedLock(object o) { _target = o; #if DEBUG _leakDetector = new Sentinel(); #endif }
public void MoveZeroJobIndexUpTest() { sentinel = new Sentinel(); sentinel.Jobs = new System.Collections.Generic.List <JenkinsJob>() { new JenkinsJob("j", "u1", false, 0), new JenkinsJob("j", "u2", false, 1), new JenkinsJob("j", "u3", false, 2), new JenkinsJob("j", "u4", false, 3), }; JenkinsJob Job = sentinel.Jobs[0]; sentinel.MoveJobIndexUp(Job); Assert.AreEqual(sentinel.Jobs[0].Index, 0); Assert.AreEqual(sentinel.Jobs[1].Index, 1); }
static Misc() { Menu = Config.Menu.AddSubMenu("杂项"); Menu.AddGroupLabel("杂项功能"); _killsteal = Menu.Add("killsteal", new CheckBox("使用E抢人头")); _bigE = Menu.Add("bigE", new CheckBox("总对炮兵使用E")); _saveSoulbound = Menu.Add("saveSoulbound", new CheckBox("使用R保护灵魂绑定的队友")); _secureE = Menu.Add("secureE", new CheckBox("使用E杀死无法平A的小兵")); _harassPlus = Menu.Add("harassPlus", new CheckBox("自动使用E当能杀死小兵以及敌人至少有一层E叠加")); _autoBelowHealthE = Menu.Add("autoBelowHealthE", new Slider("当你生命低于 ({0}%) 百分比时自动E", 10)); _reductionE = Menu.Add("reductionE", new Slider("减速E伤害计算 {0} 点", 20)); // Initialize other misc features Sentinel.Initialize(); }
static Misc() { Menu = Config.Menu.AddSubMenu("Misc"); Menu.AddGroupLabel("Ek Ayarlar"); _killsteal = Menu.Add("killsteal", new CheckBox("E ile kill çal")); _bigE = Menu.Add("bigE", new CheckBox("Büyük minyon ölecekse her zaman e kullan")); _saveSoulbound = Menu.Add("saveSoulbound", new CheckBox("R kullanarak Arkadaş koru")); _secureE = Menu.Add("secureE", new CheckBox("Düz vuruşla ölmeyecek minyonlarda e kullan")); _harassPlus = Menu.Add("harassPlus", new CheckBox("Minyon ölecekse ve rakipte 1den fazla yük varsa E kullan")); _autoBelowHealthE = Menu.Add("autoBelowHealthE", new Slider("Sağlığım şunun altındaysa otomatik E çek ({0}%) yüzzde", 10)); _reductionE = Menu.Add("reductionE", new Slider("Reduce E damage by {0} points", 20)); // Initialize other misc features Sentinel.Initialize(); }
static Misc() { Menu = Config.Menu.AddSubMenu("Misc"); Menu.AddGroupLabel("Misc features"); _killsteal = Menu.Add("killsteal", new CheckBox("Killsteal with E")); _bigE = Menu.Add("bigE", new CheckBox("Always use E on big minions")); _saveSoulbound = Menu.Add("saveSoulbound", new CheckBox("Use R to save your soulbound ally")); _secureE = Menu.Add("secureE", new CheckBox("Use E to kill unkillable (AA) minions")); _harassPlus = Menu.Add("harassPlus", new CheckBox("Auto E when a minion can die and enemies have 1+ stacks")); _autoBelowHealthE = Menu.Add("autoBelowHealthE", new Slider("Auto E when our health is below ({0}%) percent", 10)); _reductionE = Menu.Add("reductionE", new Slider("Reduce E damage by {0} points", 20)); // Initialize other misc features Sentinel.Initialize(); }
public void SentinelStopsWorkingOnException() { Sentinel testSentinel = new Sentinel(); try { testSentinel.DoWork(() => { throw new Exception("Kaboom!"); }); } catch (Exception) { } Assert.IsFalse(testSentinel.IsWorking, "The sentinel should not be working after an exception in its work routine!"); }
static Misc() { Menu = Config.Menu.AddSubMenu("Misc"); Menu.AddGroupLabel("Misc features"); _killsteal = Menu.Add("killsteal", new CheckBox("E ile oldur")); _bigE = Menu.Add("bigE", new CheckBox("Buyuk minyona surekli E kullan")); _saveSoulbound = Menu.Add("saveSoulbound", new CheckBox("Bagli kisiyi kurtarmak icin R kullan")); _secureE = Menu.Add("secureE", new CheckBox("Olmeyecek minyon icin E kullan")); _harassPlus = Menu.Add("harassPlus", new CheckBox("Bir minyon olucekse ve dusmanlarin 1+ yigini varsa Oto E")); _autoBelowHealthE = Menu.Add("autoBelowHealthE", new Slider("Sagligimiz altindayken otomatik E ({0}%) yuzde", 10)); _reductionE = Menu.Add("reductionE", new Slider("E hasarini {0} puan azalt", 20)); // Initialize other misc features Sentinel.Initialize(); }
private object PopulateWithSentinel(string key, Populator populator, Sentinel sentinel) { CacheOptions options; object value = populator(key, out options); if (value != null) { sentinel.FinishedWithValue(value); ReplaceSentinel(key, value, options, sentinel); } else { RemoveSentinel(key, sentinel); } return(value); }
/// <inheritdoc /> protected override object InternalGetOrPopulate(string key, Populator populator) { // Check if value has already been populated. object value = GetOrWaitUntilPopulated(key); if (value != null) { return(value); } Sentinel sentinel = new Sentinel(); try { // Add a sentinel into the cache unless some other thread has managed // to squeeze in here first. value = innerCache.Add(key, sentinel, null, ASPNetCache.NoAbsoluteExpiration, ASPNetCache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); if (value == null) { // The sentinel was added. return(PopulateWithSentinel(key, populator, sentinel)); } else { // The sentinel was not added. // That means some other thread has set the value or begun population // in the meantime so we have to handle each case. sentinel = value as Sentinel; if (sentinel != null) { value = sentinel.WaitUntilFinished(); } return(value); } } catch (Exception ex) { sentinel.FinishedWithException(ex); RemoveSentinel(key, sentinel); throw; } }
public static void PlayerEnterWorld(Session session, ObjectGuid guid) { var start = DateTime.UtcNow; DatabaseManager.Shard.GetPlayerBiotas(guid.Full, biotas => { log.Info("GetPlayerBiotas took " + (DateTime.UtcNow - start).TotalMilliseconds + " ms"); // This can be removed after EF performance is at the desired level. Player player; if (biotas.Player.WeenieType == (int)WeenieType.Admin) { player = new Admin(biotas.Player, biotas.Inventory, biotas.WieldedItems, session); } else if (biotas.Player.WeenieType == (int)WeenieType.Sentinel) { player = new Sentinel(biotas.Player, biotas.Inventory, biotas.WieldedItems, session); } else { player = new Player(biotas.Player, biotas.Inventory, biotas.WieldedItems, session); } player.Name = session.Character.Name; session.SetPlayer(player); session.Player.PlayerEnterWorld(); // check the value of the welcome message. Only display it if it is not empty if (!String.IsNullOrEmpty(ConfigManager.Config.Server.Welcome)) { session.Network.EnqueueSend(new GameEventPopupString(session, ConfigManager.Config.Server.Welcome)); } var location = player.GetPosition(PositionType.Location); Landblock block = GetLandblock(location.LandblockId, true); // Must enqueue add world object -- this is called from a message handler context block.AddWorldObject(session.Player); string welcomeMsg = "Welcome to Asheron's Call" + "\n"; welcomeMsg += " powered by ACEmulator " + "\n"; welcomeMsg += "" + "\n"; welcomeMsg += "For more information on commands supported by this server, type @acehelp" + "\n"; session.Network.EnqueueSend(new GameMessageSystemChat(welcomeMsg, ChatMessageType.Broadcast)); }); }
/// <inheritdoc /> protected override object InternalPopulate(string key, Populator populator) { Sentinel sentinel = new Sentinel(); try { innerCache.Insert(key, sentinel, null, ASPNetCache.NoAbsoluteExpiration, ASPNetCache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); return(PopulateWithSentinel(key, populator, sentinel)); } catch (Exception ex) { sentinel.FinishedWithException(ex); RemoveSentinel(key, sentinel); throw; } }
public void SentinelTest_ThisOneShouldntPassButDoes() { TestingUtils.ResetSentinel(); TestingUtils.ResetRoutesRepository(); var routesRepository = new RoutesRepository(); routesRepository.RegisterRoutesAsync(new List <IRouteDefinitions>() { new SpecialRouteTemplateRoutes() }).Wait(); var httpContext = new DefaultHttpContext(); httpContext.Response.Body = new MemoryStream(); var request = new DefaultHttpRequest(httpContext) { Method = HttpMethod.Post.Method, Path = "/v1/yolo/nolo/thisIsDefinitelyNotAnInteger", Query = new QueryCollection(new Dictionary <string, Microsoft.Extensions.Primitives.StringValues>() { { "No", "true" } }), Body = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new TestingType() { Yo = "lo", No = "low" }))) }; httpContext.Items.Add("ExpectedClaims", new List <Claim>() { new Claim("PityTheFoolType", "low"), new Claim("PityTheFoolJsonPath", "low"), new Claim("PityTheFoolKeyValue", "true"), new Claim("PityTheFoolRegex", "yolo"), }); var sentinel = new Sentinel(reqDelegate, routesRepository); var result = sentinel.Invoke(httpContext); Assert.NotNull(request); Assert.NotNull(result); Assert.Equal((int)HttpStatusCode.Created, httpContext.Response.StatusCode); }
/// <inheritdoc /> protected override object InternalPopulate(string key, Populator populator) { Sentinel sentinel = null; try { lock (items) { sentinel = new Sentinel(); items[key] = new CacheItem(sentinel, DateTime.MaxValue); } return(PopulateWithSentinel(key, populator, sentinel)); } catch (Exception) { if (sentinel != null) { RemoveSentinel(key, sentinel); } throw; } }
private static void DoPlayerEnterWorld(Session session, Character character, Biota playerBiota, PossessedBiotas possessedBiotas) { Player player; if (playerBiota.WeenieType == (int)WeenieType.Admin) { player = new Admin(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else if (playerBiota.WeenieType == (int)WeenieType.Sentinel) { player = new Sentinel(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else { player = new Player(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } session.SetPlayer(player); session.Player.PlayerEnterWorld(); if (character.TotalLogins <= 1 || PropertyManager.GetBool("alwaysshowwelcome").Item) { // check the value of the welcome message. Only display it if it is not empty string welcomeHeader = !string.IsNullOrEmpty(ConfigManager.Config.Server.Welcome) ? ConfigManager.Config.Server.Welcome : "Welcome to Asheron's Call!"; string msg = "To begin your training, speak to the Society Greeter. Walk up to the Society Greeter using the 'W' key, then double-click on her to initiate a conversation."; session.Network.EnqueueSend(new GameEventPopupString(session, $"{welcomeHeader}\n{msg}")); } LandblockManager.AddObject(session.Player, true); var motdString = PropertyManager.GetString("motd_string").Item; session.Network.EnqueueSend(new GameMessageSystemChat(motdString, ChatMessageType.Broadcast)); }
/// <inheritdoc /> protected override object InternalPopulate(string key, Populator populator) { Sentinel sentinel = new Sentinel(); try { innerCache.Insert(key, sentinel, null, ASPNetCache.NoAbsoluteExpiration, ASPNetCache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); return PopulateWithSentinel(key, populator, sentinel); } catch (Exception ex) { sentinel.FinishedWithException(ex); RemoveSentinel(key, sentinel); throw; } }
public IActionResult Add([FromBody] Sentinel sentinel) { if (sentinel == null) { return(BadRequest("Sentinel object can not be null!")); } using (var db = new AllInOneContext.AllInOneContext()) { try { //if (sentinel.DefenseDevices != null) //{ // sentinel.DefenseDevices.ForEach(t => { // var defenceType = db.SystemOption.FirstOrDefault(f => f.SystemOptionId.Equals(t.DeviceInfo.DeviceTypeId)); // if (defenceType.SystemOptionName.Contains("左")) // t.DefenseDirectionId = Guid.Parse("a0002016-e009-b019-e001-abcd13900001");//横向 // else // t.DefenseDirectionId = Guid.Parse("a0002016-e009-b019-e001-abcd13900002");//纵向 // }); //} //自定义分配哨位编号...1 - 32 2016-12-23 已取消,哨位编号从所属哨位节点获取 // int sentinelNum = NewSentinelNum(db, sentinel.DeviceInfo.OrganizationId); //if (sentinelNum == -1) //{ // return BadRequest(new ApplicationException() { ErrorMessage = "哨位编号已分配完成", ErrorCode = "Unknow" }); //} //_logger.LogInformation("哨位设备编号:{0}", sentinelNum); //Sentinel.DeviceInfo.IPDeviceCode = sentinelNum; //判断哨位节点下是否已添加哨位台 var deleteStatusId = Guid.Parse("a0002016-e009-b019-e001-abcd13800005"); var existSentinel = db.Sentinel.Include(t => t.DeviceInfo).FirstOrDefault(t => !deleteStatusId.Equals(t.DeviceInfo.StatusId) && t.DeviceInfo.OrganizationId.Equals(sentinel.DeviceInfo.OrganizationId)); if (existSentinel != null) { return(BadRequest(new ApplicationException() { ErrorCode = "限制错误", ErrorMessage = "已添加哨位终端设备" })); } //防区设备编号从1000开始 var node = db.Organization.FirstOrDefault(t => t.OrganizationId.Equals(sentinel.DeviceInfo.OrganizationId)); if (sentinel.DefenseDevices != null) { var defenceNum = NewDefenceNum(db, sentinel.DeviceInfo.OrganizationId); _logger.LogInformation("防区设备开始编号:{0}", defenceNum); ++defenceNum; sentinel.DefenseDevices.ForEach(t => { t.DeviceInfo.IPDeviceCode = defenceNum; t.DeviceInfo.Modified = DateTime.Now; var deviceType = db.SystemOption.FirstOrDefault(f => f.SystemOptionId.Equals(t.DeviceInfo.DeviceTypeId)); var direction = db.SystemOption.FirstOrDefault(f => f.SystemOptionId.Equals(t.DefenseDirectionId)); t.DeviceInfo.IPDeviceName = string.Format("{0}-{1}-{2}", node.OrganizationShortName, deviceType.SystemOptionName, direction.SystemOptionName); ++defenceNum; }); } sentinel.DeviceInfo.Modified = DateTime.Now; sentinel.DeviceInfo.IPDeviceName = node.OrganizationShortName; if (sentinel.SentinelVideos != null) { int order = 0; sentinel.SentinelVideos.ForEach(t => t.OrderNo = order++); } db.Sentinel.Add(sentinel); db.SaveChanges(); // return CreatedAtAction("GetById", new { id = sentinel.SentinelId }, sentinel); SendDatachangeNotify(sentinel.DeviceInfo, 2); return(CreatedAtAction("", sentinel)); } catch (DbUpdateException dbEx) { _logger.LogError("添加哨位台异常:Message:{0}\r\n,StackTrace:{1}", dbEx.Message, dbEx.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (Exception ex) { _logger.LogError("添加哨位台异常:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } } }
public Disposable(Action action) { this.action = action; sentinel = new Sentinel(); }
public static CreateResult Create(CharacterCreateInfo characterCreateInfo, Weenie weenie, ObjectGuid guid, uint accountId, WeenieType weenieType, out Player player) { var heritageGroup = DatManager.PortalDat.CharGen.HeritageGroups[characterCreateInfo.Heritage]; if (weenieType == WeenieType.Admin) { player = new Admin(weenie, guid, accountId); } else if (weenieType == WeenieType.Sentinel) { player = new Sentinel(weenie, guid, accountId); } else { player = new Player(weenie, guid, accountId); } player.SetProperty(PropertyInt.HeritageGroup, (int)characterCreateInfo.Heritage); player.SetProperty(PropertyString.HeritageGroup, heritageGroup.Name); player.SetProperty(PropertyInt.Gender, (int)characterCreateInfo.Gender); player.SetProperty(PropertyString.Sex, characterCreateInfo.Gender == 1 ? "Male" : "Female"); //player.SetProperty(PropertyDataId.Icon, cgh.IconImage); // I don't believe this is used anywhere in the client, but it might be used by a future custom launcher // pull character data from the dat file var sex = heritageGroup.Genders[(int)characterCreateInfo.Gender]; player.SetProperty(PropertyDataId.MotionTable, sex.MotionTable); player.SetProperty(PropertyDataId.SoundTable, sex.SoundTable); player.SetProperty(PropertyDataId.PhysicsEffectTable, sex.PhysicsTable); player.SetProperty(PropertyDataId.Setup, sex.SetupID); player.SetProperty(PropertyDataId.PaletteBase, sex.BasePalette); player.SetProperty(PropertyDataId.CombatTable, sex.CombatTable); // Check the character scale if (sex.Scale != 100u) { player.SetProperty(PropertyFloat.DefaultScale, (sex.Scale / 100f)); // Scale is stored as a percentage } // Get the hair first, because we need to know if you're bald, and that's the name of that tune! var hairstyle = sex.HairStyleList[Convert.ToInt32(characterCreateInfo.Apperance.HairStyle)]; // Olthoi and Gear Knights have a "Body Style" instead of a hair style. These styles have multiple model/texture changes, instead of a single head/hairstyle. // Storing this value allows us to send the proper appearance ObjDesc if (hairstyle.ObjDesc.AnimPartChanges.Count > 1) { player.SetProperty(PropertyInt.Hairstyle, (int)characterCreateInfo.Apperance.HairStyle); } // Certain races (Undead, Tumeroks, Others?) have multiple body styles available. This is controlled via the "hair style". if (hairstyle.AlternateSetup > 0) { player.SetProperty(PropertyDataId.Setup, hairstyle.AlternateSetup); } player.SetProperty(PropertyDataId.EyesTexture, sex.GetEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald)); player.SetProperty(PropertyDataId.DefaultEyesTexture, sex.GetDefaultEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald)); player.SetProperty(PropertyDataId.NoseTexture, sex.GetNoseTexture(characterCreateInfo.Apperance.Nose)); player.SetProperty(PropertyDataId.DefaultNoseTexture, sex.GetDefaultNoseTexture(characterCreateInfo.Apperance.Nose)); player.SetProperty(PropertyDataId.MouthTexture, sex.GetMouthTexture(characterCreateInfo.Apperance.Mouth)); player.SetProperty(PropertyDataId.DefaultMouthTexture, sex.GetDefaultMouthTexture(characterCreateInfo.Apperance.Mouth)); player.Character.HairTexture = sex.GetHairTexture(characterCreateInfo.Apperance.HairStyle); player.Character.DefaultHairTexture = sex.GetDefaultHairTexture(characterCreateInfo.Apperance.HairStyle); // HeadObject can be null if we're dealing with GearKnight or Olthoi var headObject = sex.GetHeadObject(characterCreateInfo.Apperance.HairStyle); if (headObject != null) { player.SetProperty(PropertyDataId.HeadObject, (uint)headObject); } // Skin is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette var skinPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.SkinPalSet); player.SetProperty(PropertyDataId.SkinPalette, skinPalSet.GetPaletteID(characterCreateInfo.Apperance.SkinHue)); player.SetProperty(PropertyFloat.Shade, characterCreateInfo.Apperance.SkinHue); // Hair is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette var hairPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.HairColorList[Convert.ToInt32(characterCreateInfo.Apperance.HairColor)]); player.SetProperty(PropertyDataId.HairPalette, hairPalSet.GetPaletteID(characterCreateInfo.Apperance.HairHue)); // Eye Color player.SetProperty(PropertyDataId.EyesPalette, sex.EyeColorList[Convert.ToInt32(characterCreateInfo.Apperance.EyeColor)]); if (characterCreateInfo.Apperance.HeadgearStyle < 0xFFFFFFFF) // No headgear is max UINT { var hat = GetClothingObject(sex.GetHeadgearWeenie(characterCreateInfo.Apperance.HeadgearStyle), characterCreateInfo.Apperance.HeadgearColor, characterCreateInfo.Apperance.HeadgearHue); if (hat != null) { player.TryEquipObject(hat, hat.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetHeadgearWeenie(characterCreateInfo.Apperance.HeadgearStyle))); } } var shirt = GetClothingObject(sex.GetShirtWeenie(characterCreateInfo.Apperance.ShirtStyle), characterCreateInfo.Apperance.ShirtColor, characterCreateInfo.Apperance.ShirtHue); if (shirt != null) { player.TryEquipObject(shirt, shirt.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetShirtWeenie(characterCreateInfo.Apperance.ShirtStyle))); } var pants = GetClothingObject(sex.GetPantsWeenie(characterCreateInfo.Apperance.PantsStyle), characterCreateInfo.Apperance.PantsColor, characterCreateInfo.Apperance.PantsHue); if (pants != null) { player.TryEquipObject(pants, pants.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetPantsWeenie(characterCreateInfo.Apperance.PantsStyle))); } var shoes = GetClothingObject(sex.GetFootwearWeenie(characterCreateInfo.Apperance.FootwearStyle), characterCreateInfo.Apperance.FootwearColor, characterCreateInfo.Apperance.FootwearHue); if (shoes != null) { player.TryEquipObject(shoes, shoes.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetFootwearWeenie(characterCreateInfo.Apperance.FootwearStyle))); } string templateName = heritageGroup.Templates[characterCreateInfo.TemplateOption].Name; //player.SetProperty(PropertyString.Title, templateName); player.SetProperty(PropertyString.Template, templateName); player.AddTitle(heritageGroup.Templates[characterCreateInfo.TemplateOption].Title, true); // stats uint totalAttributeCredits = heritageGroup.AttributeCredits; uint usedAttributeCredits = 0; player.Strength.StartingValue = ValidateAttributeCredits(characterCreateInfo.StrengthAbility, usedAttributeCredits, totalAttributeCredits); usedAttributeCredits += player.Strength.StartingValue; player.Endurance.StartingValue = ValidateAttributeCredits(characterCreateInfo.EnduranceAbility, usedAttributeCredits, totalAttributeCredits); usedAttributeCredits += player.Endurance.StartingValue; player.Coordination.StartingValue = ValidateAttributeCredits(characterCreateInfo.CoordinationAbility, usedAttributeCredits, totalAttributeCredits); usedAttributeCredits += player.Coordination.StartingValue; player.Quickness.StartingValue = ValidateAttributeCredits(characterCreateInfo.QuicknessAbility, usedAttributeCredits, totalAttributeCredits); usedAttributeCredits += player.Quickness.StartingValue; player.Focus.StartingValue = ValidateAttributeCredits(characterCreateInfo.FocusAbility, usedAttributeCredits, totalAttributeCredits); usedAttributeCredits += player.Focus.StartingValue; player.Self.StartingValue = ValidateAttributeCredits(characterCreateInfo.SelfAbility, usedAttributeCredits, totalAttributeCredits); usedAttributeCredits += player.Self.StartingValue; if (usedAttributeCredits > heritageGroup.AttributeCredits) { return(CreateResult.TooManySkillCreditsUsed); } // data we don't care about //characterCreateInfo.CharacterSlot; //characterCreateInfo.ClassId; // characters start with max vitals player.Health.Current = player.Health.Base; player.Stamina.Current = player.Stamina.Base; player.Mana.Current = player.Mana.Base; // set initial skill credit amount. 52 for all but "Olthoi", which have 68 player.SetProperty(PropertyInt.AvailableSkillCredits, (int)heritageGroup.SkillCredits); for (int i = 0; i < characterCreateInfo.SkillAdvancementClasses.Count; i++) { var sac = characterCreateInfo.SkillAdvancementClasses[i]; if (sac == SkillAdvancementClass.Inactive) { continue; } if (!DatManager.PortalDat.SkillTable.SkillBaseHash.ContainsKey((uint)i)) { log.ErrorFormat("Character {0} tried to create with skill {1} that was not found in Portal dat.", characterCreateInfo.Name, i); return(CreateResult.InvalidSkillRequested); } var skill = DatManager.PortalDat.SkillTable.SkillBaseHash[(uint)i]; var trainedCost = skill.TrainedCost; var specializedCost = skill.UpgradeCostFromTrainedToSpecialized; foreach (var skillGroup in heritageGroup.Skills) { if (skillGroup.SkillNum == i) { trainedCost = skillGroup.NormalCost; specializedCost = skillGroup.PrimaryCost; break; } } if (sac == SkillAdvancementClass.Specialized) { if (!player.TrainSkill((Skill)i, trainedCost)) { return(CreateResult.FailedToTrainSkill); } if (!player.SpecializeSkill((Skill)i, specializedCost)) { return(CreateResult.FailedToSpecializeSkill); } } else if (sac == SkillAdvancementClass.Trained) { if (!player.TrainSkill((Skill)i, trainedCost)) { return(CreateResult.FailedToTrainSkill); } } else if (sac == SkillAdvancementClass.Untrained) { player.UntrainSkill((Skill)i, 0); } } var isDualWieldTrainedOrSpecialized = player.Skills[Skill.DualWield].AdvancementClass > SkillAdvancementClass.Untrained; // Set Heritage based Melee and Ranged Masteries GetMasteries(player.HeritageGroup, out WeaponType meleeMastery, out WeaponType rangedMastery); player.SetProperty(PropertyInt.MeleeMastery, (int)meleeMastery); player.SetProperty(PropertyInt.RangedMastery, (int)rangedMastery); // Set innate augs SetInnateAugmentations(player); // grant starter items based on skills var starterGearConfig = StarterGearFactory.GetStarterGearConfiguration(); var grantedWeenies = new List <uint>(); foreach (var skillGear in starterGearConfig.Skills) { var charSkill = player.Skills[(Skill)skillGear.SkillId]; if (charSkill.AdvancementClass == SkillAdvancementClass.Trained || charSkill.AdvancementClass == SkillAdvancementClass.Specialized) { foreach (var item in skillGear.Gear) { if (grantedWeenies.Contains(item.WeenieId)) { var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClassId == item.WeenieId); if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1) { continue; } existingItem.SetStackSize(existingItem.StackSize + item.StackSize); continue; } var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (loot != null) { if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue) { loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize); } } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } if (loot != null && player.TryAddToInventory(loot)) { grantedWeenies.Add(item.WeenieId); } if (isDualWieldTrainedOrSpecialized && loot != null) { if (loot.WeenieType == WeenieType.MeleeWeapon) { var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (dualloot != null) { player.TryAddToInventory(dualloot); } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } } } } var heritageLoot = skillGear.Heritage.FirstOrDefault(sh => sh.HeritageId == characterCreateInfo.Heritage); if (heritageLoot != null) { foreach (var item in heritageLoot.Gear) { if (grantedWeenies.Contains(item.WeenieId)) { var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClassId == item.WeenieId); if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1) { continue; } existingItem.SetStackSize(existingItem.StackSize + item.StackSize); continue; } var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (loot != null) { if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue) { loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize); } } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } if (loot != null && player.TryAddToInventory(loot)) { grantedWeenies.Add(item.WeenieId); } if (isDualWieldTrainedOrSpecialized && loot != null) { if (loot.WeenieType == WeenieType.MeleeWeapon) { var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (dualloot != null) { player.TryAddToInventory(dualloot); } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } } } } } foreach (var spell in skillGear.Spells) { // Olthoi Spitter is a special case if (characterCreateInfo.Heritage == (int)HeritageGroup.OlthoiAcid) { player.AddKnownSpell(spell.SpellId); // Continue to next spell as Olthoi spells do not have the SpecializedOnly field continue; } if (charSkill.AdvancementClass == SkillAdvancementClass.Trained && spell.SpecializedOnly == false) { player.AddKnownSpell(spell.SpellId); } else if (charSkill.AdvancementClass == SkillAdvancementClass.Specialized) { player.AddKnownSpell(spell.SpellId); } } } } player.Name = characterCreateInfo.Name; player.Character.Name = characterCreateInfo.Name; // Index used to determine the starting location var startArea = characterCreateInfo.StartArea; var starterArea = DatManager.PortalDat.CharGen.StarterAreas[(int)startArea]; player.Location = new Position(starterArea.Locations[0].ObjCellID, starterArea.Locations[0].Frame.Origin.X, starterArea.Locations[0].Frame.Origin.Y, starterArea.Locations[0].Frame.Origin.Z, starterArea.Locations[0].Frame.Orientation.X, starterArea.Locations[0].Frame.Orientation.Y, starterArea.Locations[0].Frame.Orientation.Z, starterArea.Locations[0].Frame.Orientation.W); var instantiation = new Position(0xA9B40019, 84, 7.1f, 94, 0, 0, -0.0784591f, 0.996917f); // ultimate fallback. var spellFreeRide = new Spell(); switch (starterArea.Name) { case "OlthoiLair": //todo: check this when olthoi play is allowed in ace spellFreeRide = null; // no training area for olthoi, so they start and fall back to same place. instantiation = new Position(player.Location); break; case "Shoushi": spellFreeRide = DatabaseManager.World.GetCachedSpell(3813); // Free Ride to Shoushi break; case "Yaraq": spellFreeRide = DatabaseManager.World.GetCachedSpell(3814); // Free Ride to Yaraq break; case "Sanamar": spellFreeRide = DatabaseManager.World.GetCachedSpell(3535); // Free Ride to Sanamar break; case "Holtburg": default: spellFreeRide = DatabaseManager.World.GetCachedSpell(3815); // Free Ride to Holtburg break; } if (spellFreeRide != null && spellFreeRide.Name != "") { instantiation = new Position(spellFreeRide.PositionObjCellId.Value, spellFreeRide.PositionOriginX.Value, spellFreeRide.PositionOriginY.Value, spellFreeRide.PositionOriginZ.Value, spellFreeRide.PositionAnglesX.Value, spellFreeRide.PositionAnglesY.Value, spellFreeRide.PositionAnglesZ.Value, spellFreeRide.PositionAnglesW.Value); } player.Instantiation = new Position(instantiation); player.Sanctuary = new Position(player.Location); player.SetProperty(PropertyBool.RecallsDisabled, true); if (player is Sentinel || player is Admin) { player.Character.IsPlussed = true; player.CloakStatus = CloakStatus.Off; player.ChannelsAllowed = player.ChannelsActive; } CharacterCreateSetDefaultCharacterOptions(player); return(CreateResult.Success); }
private static void DoPlayerEnterWorld(Session session, Character character, Biota playerBiota, PossessedBiotas possessedBiotas) { Player player; Player.HandleNoLogLandblock(playerBiota); var stripAdminProperties = false; var addAdminProperties = false; var addSentinelProperties = false; if (ConfigManager.Config.Server.Accounts.OverrideCharacterPermissions) { if (session.AccessLevel <= AccessLevel.Advocate) // check for elevated characters { if (playerBiota.WeenieType == (int)WeenieType.Admin || playerBiota.WeenieType == (int)WeenieType.Sentinel) // Downgrade weenie { character.IsPlussed = false; playerBiota.WeenieType = (int)WeenieType.Creature; stripAdminProperties = true; } } else if (session.AccessLevel >= AccessLevel.Sentinel && session.AccessLevel <= AccessLevel.Envoy) { if (playerBiota.WeenieType == (int)WeenieType.Creature || playerBiota.WeenieType == (int)WeenieType.Admin) // Up/downgrade weenie { character.IsPlussed = true; playerBiota.WeenieType = (int)WeenieType.Sentinel; addSentinelProperties = true; } } else // Developers and Admins { if (playerBiota.WeenieType == (int)WeenieType.Creature || playerBiota.WeenieType == (int)WeenieType.Sentinel) // Up/downgrade weenie { character.IsPlussed = true; playerBiota.WeenieType = (int)WeenieType.Admin; addAdminProperties = true; } } } if (playerBiota.WeenieType == (int)WeenieType.Admin) { player = new Admin(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else if (playerBiota.WeenieType == (int)WeenieType.Sentinel) { player = new Sentinel(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else { player = new Player(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } session.SetPlayer(player); if (stripAdminProperties) // continue stripping properties { player.CloakStatus = null; player.Attackable = true; player.SetProperty(ACE.Entity.Enum.Properties.PropertyBool.DamagedByCollisions, true); player.AdvocateLevel = null; player.ChannelsActive = null; player.ChannelsAllowed = null; player.Invincible = false; player.Cloaked = null; player.IgnoreHouseBarriers = false; player.IgnorePortalRestrictions = false; player.SafeSpellComponents = false; player.ChangesDetected = true; player.CharacterChangesDetected = true; } if (addSentinelProperties || addAdminProperties) // continue restoring properties to default { WorldObject weenie; if (addAdminProperties) { weenie = Factories.WorldObjectFactory.CreateWorldObject(DatabaseManager.World.GetCachedWeenie("admin"), new ACE.Entity.ObjectGuid(ACE.Entity.ObjectGuid.Invalid.Full)); } else { weenie = Factories.WorldObjectFactory.CreateWorldObject(DatabaseManager.World.GetCachedWeenie("sentinel"), new ACE.Entity.ObjectGuid(ACE.Entity.ObjectGuid.Invalid.Full)); } if (weenie != null) { player.CloakStatus = CloakStatus.Off; player.Attackable = weenie.Attackable; player.SetProperty(ACE.Entity.Enum.Properties.PropertyBool.DamagedByCollisions, false); player.AdvocateLevel = weenie.GetProperty(ACE.Entity.Enum.Properties.PropertyInt.AdvocateLevel); player.ChannelsActive = (Channel?)weenie.GetProperty(ACE.Entity.Enum.Properties.PropertyInt.ChannelsActive); player.ChannelsAllowed = (Channel?)weenie.GetProperty(ACE.Entity.Enum.Properties.PropertyInt.ChannelsAllowed); player.Invincible = false; player.Cloaked = false; player.ChangesDetected = true; player.CharacterChangesDetected = true; } } // If the client is missing a location, we start them off in the starter town they chose if (session.Player.Location == null) { if (session.Player.Instantiation != null) { session.Player.Location = new Position(session.Player.Instantiation); } else { session.Player.Location = new Position(0xA9B40019, 84, 7.1f, 94, 0, 0, -0.0784591f, 0.996917f); // ultimate fallback; } } session.Player.PlayerEnterWorld(); var success = LandblockManager.AddObject(session.Player, true); if (!success) { // send to lifestone, or fallback location var fixLoc = session.Player.Sanctuary ?? new Position(0xA9B40019, 84, 7.1f, 94, 0, 0, -0.0784591f, 0.996917f); log.Error($"WorldManager.DoPlayerEnterWorld: failed to spawn {session.Player.Name}, relocating to {fixLoc.ToLOCString()}"); session.Player.Location = new Position(fixLoc); LandblockManager.AddObject(session.Player, true); var actionChain = new ActionChain(); actionChain.AddDelaySeconds(5.0f); actionChain.AddAction(session.Player, () => { if (session != null && session.Player != null) { session.Player.Teleport(fixLoc); } }); actionChain.EnqueueChain(); } var popup_header = PropertyManager.GetString("popup_header").Item; var popup_motd = PropertyManager.GetString("popup_motd").Item; var popup_welcome = PropertyManager.GetString("popup_welcome").Item; if (character.TotalLogins <= 1) { session.Network.EnqueueSend(new GameEventPopupString(session, AppendLines(popup_header, popup_motd, popup_welcome))); } else if (!string.IsNullOrEmpty(popup_motd)) { session.Network.EnqueueSend(new GameEventPopupString(session, AppendLines(popup_header, popup_motd))); } var info = "Welcome to Asheron's Call\n powered by ACEmulator\n\nFor more information on commands supported by this server, type @acehelp\n"; session.Network.EnqueueSend(new GameMessageSystemChat(info, ChatMessageType.Broadcast)); var server_motd = PropertyManager.GetString("server_motd").Item; if (!string.IsNullOrEmpty(server_motd)) { session.Network.EnqueueSend(new GameMessageSystemChat($"{server_motd}\n", ChatMessageType.Broadcast)); } }
public static CreateResult Create(CharacterCreateInfo characterCreateInfo, Weenie weenie, ObjectGuid guid, uint accountId, WeenieType weenieType, out Player player) { var heritageGroup = DatManager.PortalDat.CharGen.HeritageGroups[characterCreateInfo.Heritage]; if (weenieType == WeenieType.Admin) { player = new Admin(weenie, guid, accountId); } else if (weenieType == WeenieType.Sentinel) { player = new Sentinel(weenie, guid, accountId); } else { player = new Player(weenie, guid, accountId); } player.SetProperty(PropertyInt.HeritageGroup, (int)characterCreateInfo.Heritage); player.SetProperty(PropertyString.HeritageGroup, heritageGroup.Name); player.SetProperty(PropertyInt.Gender, (int)characterCreateInfo.Gender); player.SetProperty(PropertyString.Sex, characterCreateInfo.Gender == 1 ? "Male" : "Female"); //player.SetProperty(PropertyDataId.Icon, cgh.IconImage); // I don't believe this is used anywhere in the client, but it might be used by a future custom launcher // pull character data from the dat file var sex = heritageGroup.Genders[(int)characterCreateInfo.Gender]; player.SetProperty(PropertyDataId.MotionTable, sex.MotionTable); player.SetProperty(PropertyDataId.SoundTable, sex.SoundTable); player.SetProperty(PropertyDataId.PhysicsEffectTable, sex.PhysicsTable); player.SetProperty(PropertyDataId.Setup, sex.SetupID); player.SetProperty(PropertyDataId.PaletteBase, sex.BasePalette); player.SetProperty(PropertyDataId.CombatTable, sex.CombatTable); // Check the character scale if (sex.Scale != 100u) { player.SetProperty(PropertyFloat.DefaultScale, (sex.Scale / 100f)); // Scale is stored as a percentage } // Get the hair first, because we need to know if you're bald, and that's the name of that tune! var hairstyle = sex.HairStyleList[Convert.ToInt32(characterCreateInfo.Apperance.HairStyle)]; // Olthoi and Gear Knights have a "Body Style" instead of a hair style. These styles have multiple model/texture changes, instead of a single head/hairstyle. // Storing this value allows us to send the proper appearance ObjDesc if (hairstyle.ObjDesc.AnimPartChanges.Count > 1) { player.SetProperty(PropertyInt.Hairstyle, (int)characterCreateInfo.Apperance.HairStyle); } // Certain races (Undead, Tumeroks, Others?) have multiple body styles available. This is controlled via the "hair style". if (hairstyle.AlternateSetup > 0) { player.SetProperty(PropertyDataId.Setup, hairstyle.AlternateSetup); } player.SetProperty(PropertyDataId.EyesTexture, sex.GetEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald)); player.SetProperty(PropertyDataId.DefaultEyesTexture, sex.GetDefaultEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald)); player.SetProperty(PropertyDataId.NoseTexture, sex.GetNoseTexture(characterCreateInfo.Apperance.Nose)); player.SetProperty(PropertyDataId.DefaultNoseTexture, sex.GetDefaultNoseTexture(characterCreateInfo.Apperance.Nose)); player.SetProperty(PropertyDataId.MouthTexture, sex.GetMouthTexture(characterCreateInfo.Apperance.Mouth)); player.SetProperty(PropertyDataId.DefaultMouthTexture, sex.GetDefaultMouthTexture(characterCreateInfo.Apperance.Mouth)); player.Character.HairTexture = sex.GetHairTexture(characterCreateInfo.Apperance.HairStyle); player.Character.DefaultHairTexture = sex.GetDefaultHairTexture(characterCreateInfo.Apperance.HairStyle); // HeadObject can be null if we're dealing with GearKnight or Olthoi var headObject = sex.GetHeadObject(characterCreateInfo.Apperance.HairStyle); if (headObject != null) { player.SetProperty(PropertyDataId.HeadObject, (uint)headObject); } // Skin is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette var skinPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.SkinPalSet); player.SetProperty(PropertyDataId.SkinPalette, skinPalSet.GetPaletteID(characterCreateInfo.Apperance.SkinHue)); player.SetProperty(PropertyFloat.Shade, characterCreateInfo.Apperance.SkinHue); // Hair is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette var hairPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.HairColorList[Convert.ToInt32(characterCreateInfo.Apperance.HairColor)]); player.SetProperty(PropertyDataId.HairPalette, hairPalSet.GetPaletteID(characterCreateInfo.Apperance.HairHue)); // Eye Color player.SetProperty(PropertyDataId.EyesPalette, sex.EyeColorList[Convert.ToInt32(characterCreateInfo.Apperance.EyeColor)]); if (characterCreateInfo.Apperance.HeadgearStyle < 0xFFFFFFFF) // No headgear is max UINT { var hat = GetClothingObject(sex.GetHeadgearWeenie(characterCreateInfo.Apperance.HeadgearStyle), characterCreateInfo.Apperance.HeadgearColor, characterCreateInfo.Apperance.HeadgearHue); if (hat != null) { player.TryEquipObject(hat, hat.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetHeadgearWeenie(characterCreateInfo.Apperance.HeadgearStyle))); } } var shirt = GetClothingObject(sex.GetShirtWeenie(characterCreateInfo.Apperance.ShirtStyle), characterCreateInfo.Apperance.ShirtColor, characterCreateInfo.Apperance.ShirtHue); if (shirt != null) { player.TryEquipObject(shirt, shirt.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetShirtWeenie(characterCreateInfo.Apperance.ShirtStyle))); } var pants = GetClothingObject(sex.GetPantsWeenie(characterCreateInfo.Apperance.PantsStyle), characterCreateInfo.Apperance.PantsColor, characterCreateInfo.Apperance.PantsHue); if (pants != null) { player.TryEquipObject(pants, pants.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetPantsWeenie(characterCreateInfo.Apperance.PantsStyle))); } var shoes = GetClothingObject(sex.GetFootwearWeenie(characterCreateInfo.Apperance.FootwearStyle), characterCreateInfo.Apperance.FootwearColor, characterCreateInfo.Apperance.FootwearHue); if (shoes != null) { player.TryEquipObject(shoes, shoes.ValidLocations ?? 0); } else { player.TryAddToInventory(CreateIOU(sex.GetFootwearWeenie(characterCreateInfo.Apperance.FootwearStyle))); } string templateName = heritageGroup.Templates[characterCreateInfo.TemplateOption].Name; //player.SetProperty(PropertyString.Title, templateName); player.SetProperty(PropertyString.Template, templateName); player.AddTitle(heritageGroup.Templates[characterCreateInfo.TemplateOption].Title, true); // attributes var result = ValidateAttributeCredits(characterCreateInfo, heritageGroup.AttributeCredits); if (result != CreateResult.Success) { return(result); } player.Strength.StartingValue = characterCreateInfo.StrengthAbility; player.Endurance.StartingValue = characterCreateInfo.EnduranceAbility; player.Coordination.StartingValue = characterCreateInfo.CoordinationAbility; player.Quickness.StartingValue = characterCreateInfo.QuicknessAbility; player.Focus.StartingValue = characterCreateInfo.FocusAbility; player.Self.StartingValue = characterCreateInfo.SelfAbility; // data we don't care about //characterCreateInfo.CharacterSlot; //characterCreateInfo.ClassId; // characters start with max vitals player.Health.Current = player.Health.Base; player.Stamina.Current = player.Stamina.Base; player.Mana.Current = player.Mana.Base; // set initial skill credit amount. 52 for all but "Olthoi", which have 68 player.SetProperty(PropertyInt.AvailableSkillCredits, (int)heritageGroup.SkillCredits); if (characterCreateInfo.SkillAdvancementClasses.Count != 55) { return(CreateResult.ClientServerSkillsMismatch); } for (int i = 0; i < characterCreateInfo.SkillAdvancementClasses.Count; i++) { var sac = characterCreateInfo.SkillAdvancementClasses[i]; if (sac == SkillAdvancementClass.Inactive) { continue; } if (!DatManager.PortalDat.SkillTable.SkillBaseHash.ContainsKey((uint)i)) { log.ErrorFormat("Character {0} tried to create with skill {1} that was not found in Portal dat.", characterCreateInfo.Name, i); return(CreateResult.InvalidSkillRequested); } var skill = DatManager.PortalDat.SkillTable.SkillBaseHash[(uint)i]; var trainedCost = skill.TrainedCost; var specializedCost = skill.UpgradeCostFromTrainedToSpecialized; foreach (var skillGroup in heritageGroup.Skills) { if (skillGroup.SkillNum == i) { trainedCost = skillGroup.NormalCost; specializedCost = skillGroup.PrimaryCost; break; } } if (sac == SkillAdvancementClass.Specialized) { if (!player.TrainSkill((Skill)i, trainedCost)) { return(CreateResult.FailedToTrainSkill); } if (!player.SpecializeSkill((Skill)i, specializedCost)) { return(CreateResult.FailedToSpecializeSkill); } } else if (sac == SkillAdvancementClass.Trained) { if (!player.TrainSkill((Skill)i, trainedCost, true)) { return(CreateResult.FailedToTrainSkill); } } else if (sac == SkillAdvancementClass.Untrained) { player.UntrainSkill((Skill)i, 0); } } var isDualWieldTrainedOrSpecialized = player.Skills[Skill.DualWield].AdvancementClass > SkillAdvancementClass.Untrained; // Set Heritage based Melee and Ranged Masteries GetMasteries(player.HeritageGroup, out WeaponType meleeMastery, out WeaponType rangedMastery); player.SetProperty(PropertyInt.MeleeMastery, (int)meleeMastery); player.SetProperty(PropertyInt.RangedMastery, (int)rangedMastery); // Set innate augs SetInnateAugmentations(player); // grant starter items based on skills var starterGearConfig = StarterGearFactory.GetStarterGearConfiguration(); var grantedWeenies = new List <uint>(); foreach (var skillGear in starterGearConfig.Skills) { var charSkill = player.Skills[(Skill)skillGear.SkillId]; if (charSkill.AdvancementClass == SkillAdvancementClass.Trained || charSkill.AdvancementClass == SkillAdvancementClass.Specialized) { foreach (var item in skillGear.Gear) { if (grantedWeenies.Contains(item.WeenieId)) { var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClassId == item.WeenieId); if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1) { continue; } existingItem.SetStackSize(existingItem.StackSize + item.StackSize); continue; } var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (loot != null) { if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue) { loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize); } } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } if (loot != null && player.TryAddToInventory(loot)) { grantedWeenies.Add(item.WeenieId); } if (isDualWieldTrainedOrSpecialized && loot != null) { if (loot.WeenieType == WeenieType.MeleeWeapon) { var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (dualloot != null) { player.TryAddToInventory(dualloot); } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } } } } var heritageLoot = skillGear.Heritage.FirstOrDefault(sh => sh.HeritageId == characterCreateInfo.Heritage); if (heritageLoot != null) { foreach (var item in heritageLoot.Gear) { if (grantedWeenies.Contains(item.WeenieId)) { var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClassId == item.WeenieId); if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1) { continue; } existingItem.SetStackSize(existingItem.StackSize + item.StackSize); continue; } var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (loot != null) { if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue) { loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize); } } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } if (loot != null && player.TryAddToInventory(loot)) { grantedWeenies.Add(item.WeenieId); } if (isDualWieldTrainedOrSpecialized && loot != null) { if (loot.WeenieType == WeenieType.MeleeWeapon) { var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId); if (dualloot != null) { player.TryAddToInventory(dualloot); } else { player.TryAddToInventory(CreateIOU(item.WeenieId)); } } } } } foreach (var spell in skillGear.Spells) { // Olthoi Spitter is a special case if (characterCreateInfo.Heritage == (int)HeritageGroup.OlthoiAcid) { player.AddKnownSpell(spell.SpellId); // Continue to next spell as Olthoi spells do not have the SpecializedOnly field continue; } if (charSkill.AdvancementClass == SkillAdvancementClass.Trained && spell.SpecializedOnly == false) { player.AddKnownSpell(spell.SpellId); } else if (charSkill.AdvancementClass == SkillAdvancementClass.Specialized) { player.AddKnownSpell(spell.SpellId); } } } } player.Name = characterCreateInfo.Name; player.Character.Name = characterCreateInfo.Name; player.Instantiation = new Position(8323335, 260.085388f, -20.421343f, -59.994999f, 0.0f, -0.0f, -0.707107f, -0.707107f); player.Sanctuary = new Position(8323335, 260.085388f, -20.421343f, -59.994999f, 0.0f, -0.0f, -0.707107f, -0.707107f); player.SetProperty(PropertyBool.RecallsDisabled, false); player.AvailableSkillCredits = 50; player.AvailableExperience += 191226310247; player.TotalExperience += 191226310247; player.Level = 275; if (PropertyManager.GetBool("pk_server").Item) { player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.PK); } else if (PropertyManager.GetBool("pkl_server").Item) { player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK); } if ((PropertyManager.GetBool("pk_server").Item || PropertyManager.GetBool("pkl_server").Item) && PropertyManager.GetBool("pk_server_safe_training_academy").Item) { player.SetProperty(PropertyFloat.MinimumTimeSincePk, -PropertyManager.GetDouble("pk_new_character_grace_period").Item); player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK); } if (player is Sentinel || player is Admin) { player.Character.IsPlussed = true; player.CloakStatus = CloakStatus.Off; player.ChannelsAllowed = player.ChannelsActive; } CharacterCreateSetDefaultCharacterOptions(player); return(CreateResult.Success); }
public static CreateResult Create(CharacterCreateInfo characterCreateInfo, Weenie weenie, ObjectGuid guid, uint accountId, WeenieType weenieType, out Player player) { var heritageGroup = DatManager.PortalDat.CharGen.HeritageGroups[characterCreateInfo.Heritage]; if (weenieType == WeenieType.Admin) { player = new Admin(weenie, guid, accountId); } else if (weenieType == WeenieType.Sentinel) { player = new Sentinel(weenie, guid, accountId); } else { player = new Player(weenie, guid, accountId); } player.SetProperty(PropertyInt.HeritageGroup, (int)characterCreateInfo.Heritage); player.SetProperty(PropertyString.HeritageGroup, heritageGroup.Name); player.SetProperty(PropertyInt.Gender, (int)characterCreateInfo.Gender); player.SetProperty(PropertyString.Sex, characterCreateInfo.Gender == 1 ? "Male" : "Female"); //player.SetProperty(PropertyDataId.Icon, cgh.IconImage); // I don't believe this is used anywhere in the client, but it might be used by a future custom launcher // pull character data from the dat file var sex = heritageGroup.Genders[(int)characterCreateInfo.Gender]; player.SetProperty(PropertyDataId.MotionTable, sex.MotionTable); player.SetProperty(PropertyDataId.SoundTable, sex.SoundTable); player.SetProperty(PropertyDataId.PhysicsEffectTable, sex.PhysicsTable); player.SetProperty(PropertyDataId.Setup, sex.SetupID); player.SetProperty(PropertyDataId.PaletteBase, sex.BasePalette); player.SetProperty(PropertyDataId.CombatTable, sex.CombatTable); // Check the character scale if (sex.Scale != 100u) { player.SetProperty(PropertyFloat.DefaultScale, (sex.Scale / 100f)); // Scale is stored as a percentage } // Get the hair first, because we need to know if you're bald, and that's the name of that tune! var hairstyle = sex.HairStyleList[Convert.ToInt32(characterCreateInfo.Apperance.HairStyle)]; // Olthoi and Gear Knights have a "Body Style" instead of a hair style. These styles have multiple model/texture changes, instead of a single head/hairstyle. // Storing this value allows us to send the proper appearance ObjDesc if (hairstyle.ObjDesc.AnimPartChanges.Count > 1) { player.SetProperty(PropertyInt.Hairstyle, (int)characterCreateInfo.Apperance.HairStyle); } // Certain races (Undead, Tumeroks, Others?) have multiple body styles available. This is controlled via the "hair style". if (hairstyle.AlternateSetup > 0) { player.SetProperty(PropertyDataId.Setup, hairstyle.AlternateSetup); } player.SetProperty(PropertyDataId.EyesTexture, sex.GetEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald)); player.SetProperty(PropertyDataId.DefaultEyesTexture, sex.GetDefaultEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald)); player.SetProperty(PropertyDataId.NoseTexture, sex.GetNoseTexture(characterCreateInfo.Apperance.Nose)); player.SetProperty(PropertyDataId.DefaultNoseTexture, sex.GetDefaultNoseTexture(characterCreateInfo.Apperance.Nose)); player.SetProperty(PropertyDataId.MouthTexture, sex.GetMouthTexture(characterCreateInfo.Apperance.Mouth)); player.SetProperty(PropertyDataId.DefaultMouthTexture, sex.GetDefaultMouthTexture(characterCreateInfo.Apperance.Mouth)); player.Character.HairTexture = sex.GetHairTexture(characterCreateInfo.Apperance.HairStyle); player.Character.DefaultHairTexture = sex.GetDefaultHairTexture(characterCreateInfo.Apperance.HairStyle); // HeadObject can be null if we're dealing with GearKnight or Olthoi var headObject = sex.GetHeadObject(characterCreateInfo.Apperance.HairStyle); if (headObject != null) { player.SetProperty(PropertyDataId.HeadObject, (uint)headObject); } // Skin is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette var skinPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.SkinPalSet); player.SetProperty(PropertyDataId.SkinPalette, skinPalSet.GetPaletteID(characterCreateInfo.Apperance.SkinHue)); player.SetProperty(PropertyFloat.Shade, characterCreateInfo.Apperance.SkinHue); // Hair is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette var hairPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.HairColorList[Convert.ToInt32(characterCreateInfo.Apperance.HairColor)]); player.SetProperty(PropertyDataId.HairPalette, hairPalSet.GetPaletteID(characterCreateInfo.Apperance.HairHue)); // Eye Color player.SetProperty(PropertyDataId.EyesPalette, sex.EyeColorList[Convert.ToInt32(characterCreateInfo.Apperance.EyeColor)]); string templateName = heritageGroup.Templates[characterCreateInfo.TemplateOption].Name; //player.SetProperty(PropertyString.Title, templateName); player.SetProperty(PropertyString.Template, templateName); player.AddTitle(heritageGroup.Templates[characterCreateInfo.TemplateOption].Title, true); // set player attributes to 10/100/10/10/100/100 player.Strength.StartingValue = 10; player.Endurance.StartingValue = 100; player.Coordination.StartingValue = 10; player.Quickness.StartingValue = 60; player.Focus.StartingValue = 100; player.Self.StartingValue = 100; //unspecialize and untrain all skills //retrain/specialize appropriate war mage skills player.AvailableSkillCredits = 80; player.UnspecializeSkill(Skill.WarMagic, 0); player.UnspecializeSkill(Skill.Alchemy, 0); player.UnspecializeSkill(Skill.ArcaneLore, 0); player.UnspecializeSkill(Skill.ArmorTinkering, 0); player.UnspecializeSkill(Skill.AssessCreature, 0); player.UnspecializeSkill(Skill.Cooking, 0); player.UnspecializeSkill(Skill.CreatureEnchantment, 0); player.UnspecializeSkill(Skill.Deception, 0); player.UnspecializeSkill(Skill.DirtyFighting, 0); player.UnspecializeSkill(Skill.DualWield, 0); player.UnspecializeSkill(Skill.FinesseWeapons, 0); player.UnspecializeSkill(Skill.Fletching, 0); player.UnspecializeSkill(Skill.Healing, 0); player.UnspecializeSkill(Skill.HeavyWeapons, 0); player.UnspecializeSkill(Skill.ItemEnchantment, 0); player.UnspecializeSkill(Skill.ItemTinkering, 0); player.UnspecializeSkill(Skill.Jump, 0); player.UnspecializeSkill(Skill.Leadership, 0); player.UnspecializeSkill(Skill.LifeMagic, 0); player.UnspecializeSkill(Skill.LightWeapons, 0); player.UnspecializeSkill(Skill.Lockpick, 0); player.UnspecializeSkill(Skill.Loyalty, 0); player.UnspecializeSkill(Skill.MagicDefense, 0); player.UnspecializeSkill(Skill.MagicItemTinkering, 0); player.UnspecializeSkill(Skill.ManaConversion, 0); player.UnspecializeSkill(Skill.MeleeDefense, 0); player.UnspecializeSkill(Skill.MissileDefense, 0); player.UnspecializeSkill(Skill.MissileWeapons, 0); player.UnspecializeSkill(Skill.Recklessness, 0); player.UnspecializeSkill(Skill.Run, 0); player.UnspecializeSkill(Skill.Salvaging, 0); player.UnspecializeSkill(Skill.Shield, 0); player.UnspecializeSkill(Skill.SneakAttack, 0); player.UnspecializeSkill(Skill.Summoning, 0); player.UnspecializeSkill(Skill.TwoHandedCombat, 0); player.UnspecializeSkill(Skill.VoidMagic, 0); player.UnspecializeSkill(Skill.WeaponTinkering, 0); player.UntrainSkill(Skill.WarMagic, 0); player.UntrainSkill(Skill.Alchemy, 0); player.UntrainSkill(Skill.ArcaneLore, 0); player.UntrainSkill(Skill.ArmorTinkering, 0); player.UntrainSkill(Skill.AssessCreature, 0); player.UntrainSkill(Skill.Cooking, 0); player.UntrainSkill(Skill.CreatureEnchantment, 0); player.UntrainSkill(Skill.Deception, 0); player.UntrainSkill(Skill.DirtyFighting, 0); player.UntrainSkill(Skill.DualWield, 0); player.UntrainSkill(Skill.FinesseWeapons, 0); player.UntrainSkill(Skill.Fletching, 0); player.UntrainSkill(Skill.Healing, 0); player.UntrainSkill(Skill.HeavyWeapons, 0); player.UntrainSkill(Skill.ItemEnchantment, 0); player.UntrainSkill(Skill.ItemTinkering, 0); player.UntrainSkill(Skill.Jump, 0); player.UntrainSkill(Skill.Leadership, 0); player.UntrainSkill(Skill.LifeMagic, 0); player.UntrainSkill(Skill.LightWeapons, 0); player.UntrainSkill(Skill.Lockpick, 0); player.UntrainSkill(Skill.Loyalty, 0); player.UntrainSkill(Skill.MagicDefense, 0); player.UntrainSkill(Skill.MagicItemTinkering, 0); player.UntrainSkill(Skill.ManaConversion, 0); player.UntrainSkill(Skill.MeleeDefense, 0); player.UntrainSkill(Skill.MissileDefense, 0); player.UntrainSkill(Skill.MissileWeapons, 0); player.UntrainSkill(Skill.Recklessness, 0); player.UntrainSkill(Skill.Run, 0); player.UntrainSkill(Skill.Salvaging, 0); player.UntrainSkill(Skill.Shield, 0); player.UntrainSkill(Skill.SneakAttack, 0); player.UntrainSkill(Skill.Summoning, 0); player.UntrainSkill(Skill.TwoHandedCombat, 0); player.UntrainSkill(Skill.VoidMagic, 0); player.UntrainSkill(Skill.WeaponTinkering, 0); player.TrainSkill(Skill.ArcaneLore, 0); player.TrainSkill(Skill.Jump, 0); player.TrainSkill(Skill.MagicDefense, 0); player.TrainSkill(Skill.Run, 0); player.TrainSkill(Skill.WarMagic, 0); player.TrainSkill(Skill.ManaConversion, 0); player.TrainSkill(Skill.LifeMagic, 0); player.SpecializeSkill(Skill.WarMagic, 0); player.SpecializeSkill(Skill.MagicDefense, 0); player.SpecializeSkill(Skill.ManaConversion, 0); player.SpecializeSkill(Skill.LifeMagic, 0); // data we don't care about //characterCreateInfo.CharacterSlot; //characterCreateInfo.ClassId; // characters start with max vitals player.Health.Current = player.Health.Base; player.Stamina.Current = player.Stamina.Base; player.Mana.Current = player.Mana.Base; // Set Heritage based Melee and Ranged Masteries GetMasteries(player.HeritageGroup, out WeaponType meleeMastery, out WeaponType rangedMastery); player.SetProperty(PropertyInt.MeleeMastery, (int)meleeMastery); player.SetProperty(PropertyInt.RangedMastery, (int)rangedMastery); SetInnateAugmentations(player); AddWeeniesToInventoryX(player, new HashSet <uint> { 15271, 6799, 6801, 1000036, 25702, 1000030, 24207, 1000031 }); player.Name = characterCreateInfo.Name; player.Character.Name = characterCreateInfo.Name; player.Instantiation = new Position(8323335, 260.085388f, -20.421343f, -59.994999f, 0.0f, -0.0f, -0.707107f, -0.707107f); player.Sanctuary = new Position(8323335, 260.085388f, -20.421343f, -59.994999f, 0.0f, -0.0f, -0.707107f, -0.707107f); player.SetProperty(PropertyBool.RecallsDisabled, false); player.AvailableSkillCredits = 0; player.AvailableExperience += 191226310247; player.TotalExperience += 191226310247; player.Level = 275; SpendAllXpX(player); if (PropertyManager.GetBool("pk_server").Item) { player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.PK); } else if (PropertyManager.GetBool("pkl_server").Item) { player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK); } if ((PropertyManager.GetBool("pk_server").Item || PropertyManager.GetBool("pkl_server").Item) && PropertyManager.GetBool("pk_server_safe_training_academy").Item) { player.SetProperty(PropertyFloat.MinimumTimeSincePk, -PropertyManager.GetDouble("pk_new_character_grace_period").Item); player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK); } if (player is Sentinel || player is Admin) { player.Character.IsPlussed = true; player.CloakStatus = CloakStatus.Off; player.ChannelsAllowed = player.ChannelsActive; } CharacterCreateSetDefaultCharacterOptions(player); return(CreateResult.Success); }
/// <inheritdoc /> protected override object InternalGetOrPopulate(string key, Populator populator) { Sentinel sentinel = null; try { lock (items) { object existingValue = GetOrWaitUntilPopulatedInsideLock(key); if (existingValue != null) return existingValue; sentinel = new Sentinel(); items[key] = new CacheItem(sentinel, DateTime.MaxValue); } return PopulateWithSentinel(key, populator, sentinel); } catch (Exception) { if (sentinel != null) RemoveSentinel(key, sentinel); throw; } }
private static void DoPlayerEnterWorld(Session session, Character character, Biota playerBiota, PossessedBiotas possessedBiotas) { Player player; Player.HandleNoLogLandblock(playerBiota); var stripAdminProperties = false; var addAdminProperties = false; var addSentinelProperties = false; if (ConfigManager.Config.Server.Accounts.OverrideCharacterPermissions) { if (session.AccessLevel <= AccessLevel.Advocate) // check for elevated characters { if (playerBiota.WeenieType == (int)WeenieType.Admin || playerBiota.WeenieType == (int)WeenieType.Sentinel) // Downgrade weenie { character.IsPlussed = false; playerBiota.WeenieType = (int)WeenieType.Creature; stripAdminProperties = true; } } else if (session.AccessLevel >= AccessLevel.Sentinel && session.AccessLevel <= AccessLevel.Envoy) { if (playerBiota.WeenieType == (int)WeenieType.Creature || playerBiota.WeenieType == (int)WeenieType.Admin) // Up/downgrade weenie { character.IsPlussed = true; playerBiota.WeenieType = (int)WeenieType.Sentinel; addSentinelProperties = true; } } else // Developers and Admins { if (playerBiota.WeenieType == (int)WeenieType.Creature || playerBiota.WeenieType == (int)WeenieType.Sentinel) // Up/downgrade weenie { character.IsPlussed = true; playerBiota.WeenieType = (int)WeenieType.Admin; addAdminProperties = true; } } } if (playerBiota.WeenieType == (int)WeenieType.Admin) { player = new Admin(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else if (playerBiota.WeenieType == (int)WeenieType.Sentinel) { player = new Sentinel(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else { player = new Player(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } session.SetPlayer(player); if (stripAdminProperties) // continue stripping properties { player.CloakStatus = null; player.Attackable = true; player.SetProperty(ACE.Entity.Enum.Properties.PropertyBool.DamagedByCollisions, true); player.AdvocateLevel = null; player.ChannelsActive = null; player.ChannelsAllowed = null; player.Invincible = null; player.Cloaked = null; player.ChangesDetected = true; player.CharacterChangesDetected = true; } if (addSentinelProperties || addAdminProperties) // continue restoring properties to default { WorldObject weenie; if (addAdminProperties) { weenie = Factories.WorldObjectFactory.CreateWorldObject(DatabaseManager.World.GetCachedWeenie("admin"), new ACE.Entity.ObjectGuid(ACE.Entity.ObjectGuid.Invalid.Full)) as Admin; } else { weenie = Factories.WorldObjectFactory.CreateWorldObject(DatabaseManager.World.GetCachedWeenie("sentinel"), new ACE.Entity.ObjectGuid(ACE.Entity.ObjectGuid.Invalid.Full)) as Sentinel; } if (weenie != null) { player.CloakStatus = CloakStatus.Off; player.Attackable = weenie.Attackable; player.SetProperty(ACE.Entity.Enum.Properties.PropertyBool.DamagedByCollisions, false); player.AdvocateLevel = weenie.GetProperty(ACE.Entity.Enum.Properties.PropertyInt.AdvocateLevel); player.ChannelsActive = (Channel?)weenie.GetProperty(ACE.Entity.Enum.Properties.PropertyInt.ChannelsActive); player.ChannelsAllowed = (Channel?)weenie.GetProperty(ACE.Entity.Enum.Properties.PropertyInt.ChannelsAllowed); player.Invincible = false; player.Cloaked = false; player.ChangesDetected = true; player.CharacterChangesDetected = true; } } // If the client is missing a location, we start them off in the starter dungeon if (session.Player.Location == null) { if (session.Player.Instantiation != null) { session.Player.Location = new Position(session.Player.Instantiation); } else { session.Player.Location = new Position(2349072813, 12.3199f, -28.482f, 0.0049999995f, 0.0f, 0.0f, -0.9408059f, -0.3389459f); } } session.Player.PlayerEnterWorld(); LandblockManager.AddObject(session.Player, true); var popup_header = PropertyManager.GetString("popup_header").Item; var popup_motd = PropertyManager.GetString("popup_motd").Item; var popup_welcome = PropertyManager.GetString("popup_welcome").Item; if (character.TotalLogins <= 1) { session.Network.EnqueueSend(new GameEventPopupString(session, AppendLines(popup_header, popup_motd, popup_welcome))); } else if (!string.IsNullOrEmpty(popup_motd)) { session.Network.EnqueueSend(new GameEventPopupString(session, AppendLines(popup_header, popup_motd))); } var info = "Welcome to Asheron's Call\n powered by ACEmulator\n\nFor more information on commands supported by this server, type @acehelp\n"; session.Network.EnqueueSend(new GameMessageSystemChat(info, ChatMessageType.Broadcast)); var server_motd = PropertyManager.GetString("server_motd").Item; if (!string.IsNullOrEmpty(server_motd)) { session.Network.EnqueueSend(new GameMessageSystemChat($"{server_motd}\n", ChatMessageType.Broadcast)); } }
private void ReplaceSentinel(string key, object value, CacheOptions options, Sentinel sentinel) { // Note: This is a minor optimization to ensure we don't blow away // a newer value associated with the key when we're just trying // to replace the sentinel we stored in there. if (innerCache.Get(key) == sentinel) InternalSet(key, value, options); }
public SentinelTest() { sentinel = new Sentinel(); }
/// <inheritdoc /> protected override object InternalGetOrPopulate(string key, Populator populator) { // Check if value has already been populated. object value = GetOrWaitUntilPopulated(key); if (value != null) return value; Sentinel sentinel = new Sentinel(); try { // Add a sentinel into the cache unless some other thread has managed // to squeeze in here first. value = innerCache.Add(key, sentinel, null, ASPNetCache.NoAbsoluteExpiration, ASPNetCache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); if (value == null) { // The sentinel was added. return PopulateWithSentinel(key, populator, sentinel); } else { // The sentinel was not added. // That means some other thread has set the value or begun population // in the meantime so we have to handle each case. sentinel = value as Sentinel; if (sentinel != null) value = sentinel.WaitUntilFinished(); return value; } } catch (Exception ex) { sentinel.FinishedWithException(ex); RemoveSentinel(key, sentinel); throw; } }
public IActionResult Update([FromBody] Sentinel sentinel) { if (sentinel == null) { return(BadRequest("Sentinel object can not be null!")); } using (var db = new AllInOneContext.AllInOneContext()) { using (var tran = db.Database.BeginTransaction()) { try { Sentinel obj = GetQuery(db).FirstOrDefault(t => t.SentinelId.Equals(sentinel.SentinelId)); if (obj.BulletboxCamera != null) { db.Set <SentinelVideo>().Remove(obj.BulletboxCamera); } if (obj.FrontCamera != null) { db.Set <SentinelVideo>().Remove(obj.FrontCamera); } if (obj.SentinelVideos != null) { db.Set <SentinelVideo>().RemoveRange(obj.SentinelVideos); } //if (obj.DeviceInfo != null) // db.IPDeviceInfo.Remove(obj.DeviceInfo); if (obj.SentinelSetting != null) { db.Set <SentinelSetting>().Remove(obj.SentinelSetting); } //db.Sentinel.Remove(obj); //if (obj.DefenseDevices != null) // db.DefenseDevice.RemoveRange(obj.DefenseDevices); if (obj.AlarmOutputChannels != null) { db.Set <DeviceChannelSetting>().RemoveRange(obj.AlarmOutputChannels); } db.SaveChanges(); //if (sentinel.DefenseDevices != null) //{ // sentinel.DefenseDevices.ForEach(t => { // var defenceType = db.SystemOption.FirstOrDefault(f => f.SystemOptionId.Equals(t.DeviceInfo.DeviceTypeId)); // if (defenceType.SystemOptionName.Contains("左")) // t.DefenseDirectionId = Guid.Parse("a0002016-e009-b019-e001-abcd13900001");//横向 // else // t.DefenseDirectionId = Guid.Parse("a0002016-e009-b019-e001-abcd13900002");//纵向 // }); //} //已删除的防区设备 var deleteStatus = db.SystemOption.FirstOrDefault(t => t.SystemOptionCode.Equals("13800005")); if (obj.DefenseDevices != null) { if (sentinel.DefenseDevices == null) { obj.DefenseDevices.ForEach(t => t.DeviceInfo.StatusId = deleteStatus.SystemOptionId); } else { var uiDefenceDeviceIds = sentinel.DefenseDevices.Select(t => t.DefenseDeviceId).ToList(); obj.DefenseDevices.ForEach(t => { if (uiDefenceDeviceIds.Contains(t.DefenseDeviceId)) { //更新 t = sentinel.DefenseDevices.FirstOrDefault(f => f.DefenseDeviceId.Equals(t.DefenseDeviceId)); var device = db.IPDeviceInfo.FirstOrDefault(f => f.IPDeviceInfoId.Equals(t.DeviceInfoId)); device.DeviceTypeId = t.DeviceInfo.DeviceTypeId; //设备类型修改 db.SaveChanges(); } else { t.DeviceInfo.StatusId = deleteStatus.SystemOptionId; //已删除 } }); } } //防区设备更新 if (sentinel.DefenseDevices != null) { if (obj.DefenseDevices == null) { obj.DefenseDevices = sentinel.DefenseDevices; } else { var dbDefenceDevices = obj.DefenseDevices.Select(t => t.DefenseDeviceId).ToList(); sentinel.DefenseDevices.ForEach(t => { if (!dbDefenceDevices.Contains(t.DefenseDeviceId)) { obj.DefenseDevices.Add(t); } else //已添加,更新 { var dbDefenceDevice = obj.DefenseDevices.FirstOrDefault(f => f.DefenseDeviceId.Equals(t.DefenseDeviceId)); dbDefenceDevice.DeviceInfo.DeviceTypeId = t.DeviceInfo.DeviceTypeId; //dbDefenceDevice.DeviceInfo.IPDeviceName = t.DeviceInfo.IPDeviceName; dbDefenceDevice.DefenseDirectionId = t.DefenseDirectionId; dbDefenceDevice.AlarmIn = t.AlarmIn; dbDefenceDevice.AlarmOut = t.AlarmOut; dbDefenceDevice.AlarmInNormalOpen = t.AlarmInNormalOpen; } }); } } //暂时编号从0开始 if (sentinel.SentinelVideos != null) { int order = 0; sentinel.SentinelVideos.ForEach(t => t.OrderNo = order++); } //更新设备信息 obj.DeviceInfo.DeviceTypeId = sentinel.DeviceInfo.DeviceTypeId; obj.DeviceInfo.EndPointsJson = sentinel.DeviceInfo.EndPointsJson; //obj.DeviceInfo.IPDeviceCode = sentinel.DeviceInfo.IPDeviceCode; //obj.DeviceInfo.IPDeviceName = sentinel.DeviceInfo.IPDeviceName; obj.DeviceInfo.OrganizationId = sentinel.DeviceInfo.OrganizationId; obj.DeviceInfo.Modified = DateTime.Now; obj.SentinelSetting = sentinel.SentinelSetting; obj.BulletboxCamera = sentinel.BulletboxCamera; //obj.DeviceInfoId = sentinel.DeviceInfoId; obj.FrontCamera = sentinel.FrontCamera; obj.IsActive = sentinel.IsActive; obj.Phone = sentinel.Phone; obj.SentinelId = sentinel.SentinelId; obj.SentinelSetting = sentinel.SentinelSetting; obj.SentinelVideos = sentinel.SentinelVideos; //obj.DefenseDevices = sentinel.DefenseDevices; obj.AlarmOutputChannels = sentinel.AlarmOutputChannels; db.Sentinel.Update(obj); db.SaveChanges(); tran.Commit(); SendDatachangeNotify(sentinel.DeviceInfo, 1); return(NoContent()); } catch (DbUpdateException dbEx) { tran.Rollback(); _logger.LogError("更新哨位台异常:Message:{0}\r\n,StackTrace:{1}", dbEx.Message, dbEx.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (Exception ex) { tran.Rollback(); _logger.LogError("更新哨位台异常:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } } } }
public override Actor createActor(int id, Vector2 position, Microsoft.Xna.Framework.Vector2?velocity = null, double color = -1) { Actor a = null; if ((position.X >= 0 && position.X < world.width * Tile.size && position.Y >= 0 && position.Y < world.height * Tile.size)) { switch (id) { case 0: a = new Player(world, position); return(a); case 1: a = new Octo(world, position); break; case 2: a = new Blob(world, position, velocity ?? Vector2.Zero, color); break; case 3: a = new Sentinel(world, position); break; case 4: a = new Spikon(world, position); break; case 5: a = new Arrow(world, position, velocity ?? Vector2.Zero); return(a); case 6: a = new OctoBall(world, position, velocity ?? Vector2.Zero); return(a); case 7: a = new HealthOrb(world, position, velocity ?? Vector2.Zero); return(a); case 8: a = new FireShuriken(world, position, velocity ?? Vector2.Zero); return(a); case 9: a = new IceSpike(world, position, velocity ?? Vector2.Zero); return(a); case 10: a = new Numbers(world, position, velocity ?? Vector2.Zero); return(a); case 11: a = new FirstBoss(world, position); return(a); case 12: a = new LevelUp(world, position, velocity ?? Vector2.Zero); return(a); case 13: a = new Laser(world, position, velocity ?? Vector2.Zero); return(a); case 14: a = new FirePillar(world, position, velocity ?? Vector2.Zero); return(a); case 15: a = new ManaOrb(world, position, velocity ?? Vector2.Zero); return(a); case 16: a = new Zazzle(world, position); return(a); case 17: a = new ZazzleShot(world, position, velocity ?? Vector2.Zero); return(a); case 18: a = new Basilisk(world, position); return(a); case 19: a = new BlobSpawner(world, position); return(a); case 20: a = new Charger(world, position); return(a); case 21: a = new Grapple(world, position, velocity ?? Vector2.Zero); return(a); case 22: a = new Generator(world, position); return(a); case 23: a = new Explosion(world, position, velocity ?? Vector2.Zero); return(a); case 24: a = new Torch(world, position); return(a); case 25: a = new MagicPrimary(world, position, velocity ?? Vector2.Zero); return(a); case 26: a = new WizBlob(world, position); return(a); case 27: a = new LaserArrow(world, position, velocity ?? Vector2.Zero); return(a); case 28: a = new DiscoBlob(world, position, velocity ?? Vector2.Zero, color, checkpointCount++); break; case 29: a = new FireBlob(world, position, velocity ?? Vector2.Zero); break; case 30: a = new MrHammer(world, position, velocity ?? Vector2.Zero); break; case 31: a = new GigaBlob(world, position, velocity ?? Vector2.Zero); break; case 32: a = new MagicPrimary(world, position, velocity ?? Vector2.Zero); return(a); case 33: a = new DarkLucyPortrait(world, position, velocity ?? Vector2.Zero); return(a); case 34: a = new BloodyArrow(world, position, velocity ?? Vector2.Zero); return(a); case 35: a = new LucyFirePillar(world, position, velocity ?? Vector2.Zero); return(a); case 36: a = new WeddingPhoto(world, position, velocity ?? Vector2.Zero); return(a); case 37: a = new FancyPortrait(world, position, velocity ?? Vector2.Zero); return(a); case 38: a = new CoatOfArms(world, position, velocity ?? Vector2.Zero); return(a); case 39: a = new TandemBike(world, position, velocity ?? Vector2.Zero); return(a); case 40: a = new KnightStatue(world, position, velocity ?? Vector2.Zero); return(a); case 41: a = new SwordSlash(world, position, velocity ?? Vector2.Zero); return(a); } } return(a); }
public void CreatePlayer() { // Desginating a Name // ------------------------------------------- Console.Clear(); text.CenterText("Designate a name for yourself: "); Console.CursorTop = (Console.WindowHeight / 2) + 2; Console.CursorLeft = (Console.WindowWidth / 2) - 3; string playerName = Console.ReadLine(); System.Threading.Thread.Sleep(50); Console.Clear(); bool prompt = true; while (prompt == true) { text.CenterText("Is this correct?"); Console.CursorTop = (Console.WindowHeight / 2) + 2; Console.CursorLeft = (Console.WindowWidth / 2) - (playerName.Length / 2); Console.WriteLine(playerName); Console.CursorTop = (Console.WindowHeight / 2) + 6; Console.CursorLeft = (Console.WindowWidth / 2) - (text.YesNo().Length / 2); Console.WriteLine(text.YesNo()); var input = Console.ReadKey(); switch (input.KeyChar) { case 'Y': case 'y': prompt = false; break; case 'N': case 'n': CreatePlayer(); prompt = false; break; default: break; } } // Selecting Your Class // ------------------------------------------- Classes _class = new Striker(); bool classPrompt = true; while (classPrompt) { Console.Clear(); text.CenterText("Please Select a Class\n\n"); Console.CursorTop = (Console.WindowHeight / 2) + 2; string classList = "1.Striker\t2.Predator\t3.Advancer\t4.Sentinel\t5.Berzerker\t6.Siren\n" + "7.Warden\t8.Ranger\t9.Gunslinger\tq.Oracle\tw.Defiler\n" + "e.Dancer\tr.Reaver\tt.Arbiter\ty.Harbinger"; Console.CursorLeft = (Console.WindowWidth / 2) - (classList.Length / 2) - 12; Console.WriteLine(classList); var classInput = Console.ReadKey(); Console.CursorTop = (Console.WindowHeight / 2) + 4; switch (classInput.KeyChar) { case '1': _class = new Striker(); break; case '2': _class = new Predator(); break; case '3': _class = new Avenger(); break; case '4': _class = new Sentinel(); break; case '5': _class = new Berzerker(); break; case '6': _class = new Siren(); break; case '7': _class = new Warden(); break; case '8': _class = new Ranger(); break; case '9': _class = new Gunslinger(); break; case 'q': _class = new Oracle(); break; case 'w': _class = new Defiler(); break; case 'e': _class = new Dancer(); break; case 'r': _class = new Reaver(); break; case 't': _class = new Arbiter(); break; case 'y': _class = new Harbinger(); break; default: break; } bool finalizePrompt = true; while (finalizePrompt == true) { Console.Clear(); text.CenterText(_class.classDescription); Console.CursorTop = (Console.WindowHeight / 2) + 2; string s = "Choose this class?"; Console.CursorLeft = (Console.WindowWidth / 2) - (s.Length / 2); Console.WriteLine(s); Console.CursorTop = (Console.WindowHeight / 2) + 6; Console.CursorLeft = (Console.WindowWidth / 2) - (text.YesNo().Length / 2); Console.WriteLine(text.YesNo()); var input = Console.ReadKey(); switch (input.KeyChar) { case 'Y': case 'y': finalizePrompt = false; classPrompt = false; break; case 'N': case 'n': finalizePrompt = false; break; default: break; } } } Console.Clear(); InitializePlayer(playerName, _class); }
/// <inheritdoc /> protected override object InternalPopulate(string key, Populator populator) { Sentinel sentinel = null; try { lock (items) { sentinel = new Sentinel(); items[key] = new CacheItem(sentinel, DateTime.MaxValue); } return PopulateWithSentinel(key, populator, sentinel); } catch (Exception) { if (sentinel != null) RemoveSentinel(key, sentinel); throw; } }
private object PopulateWithSentinel(string key, Populator populator, Sentinel sentinel) { CacheOptions options; object populatedValue = populator(key, out options); lock (items) { CacheItem item; if (items.TryGetValue(key, out item) && item.Value == sentinel) { if (populatedValue != null) { DateTime expirationTime = options.GetUtcExpirationTimeRelativeToNow(); items[key] = new CacheItem(populatedValue, expirationTime); if (expirationTime < nextExpirationTime) nextExpirationTime = expirationTime; } else { items.Remove(key); } } Monitor.PulseAll(items); } return populatedValue; }
private void RemoveSentinel(string key, Sentinel sentinel) { lock (items) { CacheItem item; if (items.TryGetValue(key, out item) && item.Value == sentinel) items.Remove(key); Monitor.PulseAll(items); } }
public TestThreadSafety(Sentinel sentinel) { _sentinel = sentinel; _sentinel.Use(); }
private void RemoveSentinel(string key, Sentinel sentinel) { // Note: This is a minor optimization to ensure we don't blow away // a newer value associated with the key when we're just trying // to remove the sentinel we stored in there. if (innerCache.Get(key) == sentinel) innerCache.Remove(key); }
public Disposable(Action action) { m_action = action; m_sentinel = new Sentinel(); }
private void button2_Click(object sender, EventArgs e) { Sentinel.ExecuteScript(richTextBox1.Text); }
private static void DoPlayerEnterWorld(Session session, Character character, Biota playerBiota, PossessedBiotas possessedBiotas) { Player player; Player.HandleNoLogLandblock(playerBiota, out var playerLoggedInOnNoLogLandblock); var stripAdminProperties = false; var addAdminProperties = false; var addSentinelProperties = false; if (ConfigManager.Config.Server.Accounts.OverrideCharacterPermissions) { if (session.AccessLevel <= AccessLevel.Advocate) // check for elevated characters { if (playerBiota.WeenieType == WeenieType.Admin || playerBiota.WeenieType == WeenieType.Sentinel) // Downgrade weenie { character.IsPlussed = false; playerBiota.WeenieType = WeenieType.Creature; stripAdminProperties = true; } } else if (session.AccessLevel >= AccessLevel.Sentinel && session.AccessLevel <= AccessLevel.Envoy) { if (playerBiota.WeenieType == WeenieType.Creature || playerBiota.WeenieType == WeenieType.Admin) // Up/downgrade weenie { character.IsPlussed = true; playerBiota.WeenieType = WeenieType.Sentinel; addSentinelProperties = true; } } else // Developers and Admins { if (playerBiota.WeenieType == WeenieType.Creature || playerBiota.WeenieType == WeenieType.Sentinel) // Up/downgrade weenie { character.IsPlussed = true; playerBiota.WeenieType = WeenieType.Admin; addAdminProperties = true; } } } if (playerBiota.WeenieType == WeenieType.Admin) { player = new Admin(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else if (playerBiota.WeenieType == WeenieType.Sentinel) { player = new Sentinel(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } else { player = new Player(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session); } session.SetPlayer(player); if (stripAdminProperties) // continue stripping properties { player.CloakStatus = CloakStatus.Undef; player.Attackable = true; player.SetProperty(PropertyBool.DamagedByCollisions, true); player.AdvocateLevel = null; player.ChannelsActive = null; player.ChannelsAllowed = null; player.Invincible = false; player.Cloaked = null; player.IgnoreHouseBarriers = false; player.IgnorePortalRestrictions = false; player.SafeSpellComponents = false; player.ReportCollisions = true; player.ChangesDetected = true; player.CharacterChangesDetected = true; } if (addSentinelProperties || addAdminProperties) // continue restoring properties to default { WorldObject weenie; if (addAdminProperties) { weenie = Factories.WorldObjectFactory.CreateWorldObject(DatabaseManager.World.GetCachedWeenie("admin"), new ACE.Entity.ObjectGuid(ACE.Entity.ObjectGuid.Invalid.Full)); } else { weenie = Factories.WorldObjectFactory.CreateWorldObject(DatabaseManager.World.GetCachedWeenie("sentinel"), new ACE.Entity.ObjectGuid(ACE.Entity.ObjectGuid.Invalid.Full)); } if (weenie != null) { player.CloakStatus = CloakStatus.Off; player.Attackable = weenie.Attackable; player.SetProperty(PropertyBool.DamagedByCollisions, false); player.AdvocateLevel = weenie.GetProperty(PropertyInt.AdvocateLevel); player.ChannelsActive = (Channel?)weenie.GetProperty(PropertyInt.ChannelsActive); player.ChannelsAllowed = (Channel?)weenie.GetProperty(PropertyInt.ChannelsAllowed); player.Invincible = false; player.Cloaked = false; player.ChangesDetected = true; player.CharacterChangesDetected = true; } } // If the client is missing a location, we start them off in the starter town they chose if (session.Player.Location == null) { if (session.Player.Instantiation != null) { session.Player.Location = new Position(session.Player.Instantiation); } else { session.Player.Location = new Position(0xA9B40019, 84, 7.1f, 94, 0, 0, -0.0784591f, 0.996917f); // ultimate fallback } } var olthoiPlayerReturnedToLifestone = session.Player.IsOlthoiPlayer && character.TotalLogins >= 1 && session.Player.LoginAtLifestone; if (olthoiPlayerReturnedToLifestone) { session.Player.Location = new Position(session.Player.Sanctuary); } session.Player.PlayerEnterWorld(); var success = LandblockManager.AddObject(session.Player, true); if (!success) { // send to lifestone, or fallback location var fixLoc = session.Player.Sanctuary ?? new Position(0xA9B40019, 84, 7.1f, 94, 0, 0, -0.0784591f, 0.996917f); log.Error($"WorldManager.DoPlayerEnterWorld: failed to spawn {session.Player.Name}, relocating to {fixLoc.ToLOCString()}"); session.Player.Location = new Position(fixLoc); LandblockManager.AddObject(session.Player, true); var actionChain = new ActionChain(); actionChain.AddDelaySeconds(5.0f); actionChain.AddAction(session.Player, () => { if (session != null && session.Player != null) { session.Player.Teleport(fixLoc); } }); actionChain.EnqueueChain(); } // These warnings are set by DDD_InterrogationResponse if ((session.DatWarnCell || session.DatWarnLanguage || session.DatWarnPortal) && PropertyManager.GetBool("show_dat_warning").Item) { var msg = PropertyManager.GetString("dat_warning_msg").Item; var chatMsg = new GameMessageSystemChat(msg, ChatMessageType.System); session.Network.EnqueueSend(chatMsg); } var popup_header = PropertyManager.GetString("popup_header").Item; var popup_motd = PropertyManager.GetString("popup_motd").Item; var popup_welcome = player.IsOlthoiPlayer ? PropertyManager.GetString("popup_welcome_olthoi").Item : PropertyManager.GetString("popup_welcome").Item; if (character.TotalLogins <= 1) { if (player.IsOlthoiPlayer) { session.Network.EnqueueSend(new GameEventPopupString(session, AppendLines(popup_welcome, popup_motd))); } else { session.Network.EnqueueSend(new GameEventPopupString(session, AppendLines(popup_header, popup_motd, popup_welcome))); } } else if (!string.IsNullOrEmpty(popup_motd)) { session.Network.EnqueueSend(new GameEventPopupString(session, AppendLines(popup_header, popup_motd))); } var info = "Welcome to Asheron's Call\n powered by ACEmulator\n\nFor more information on commands supported by this server, type @acehelp\n"; session.Network.EnqueueSend(new GameMessageSystemChat(info, ChatMessageType.Broadcast)); var server_motd = PropertyManager.GetString("server_motd").Item; if (!string.IsNullOrEmpty(server_motd)) { session.Network.EnqueueSend(new GameMessageSystemChat($"{server_motd}\n", ChatMessageType.Broadcast)); } if (olthoiPlayerReturnedToLifestone) { session.Network.EnqueueSend(new GameMessageSystemChat("You have returned to the Olthoi Queen to serve the hive.", ChatMessageType.Broadcast)); } else if (playerLoggedInOnNoLogLandblock) // see http://acpedia.org/wiki/Mount_Elyrii_Hive { session.Network.EnqueueSend(new GameMessageSystemChat("The currents of portal space cannot return you from whence you came. Your previous location forbids login.", ChatMessageType.Broadcast)); } }
private object PopulateWithSentinel(string key, Populator populator, Sentinel sentinel) { CacheOptions options; object value = populator(key, out options); if (value != null) { sentinel.FinishedWithValue(value); ReplaceSentinel(key, value, options, sentinel); } else { RemoveSentinel(key, sentinel); } return value; }
public static void Main(string[] args) { Sentinel.Log(System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Test de log"); }
public IActionResult Delete(Guid id) { using (var db = new AllInOneContext.AllInOneContext()) { using (var tran = db.Database.BeginTransaction()) { try { Sentinel deleteObj = GetQuery(db).FirstOrDefault(t => t.SentinelId.Equals(id)); if (deleteObj == null) { return(NotFound()); } //if (deleteObj.BulletboxCamera != null) // db.Set<SentinelVideo>().Remove(deleteObj.BulletboxCamera); //if (deleteObj.FrontCamera != null) // db.Set<SentinelVideo>().Remove(deleteObj.FrontCamera); //if (deleteObj.SentinelVideos != null) // db.Set<SentinelVideo>().RemoveRange(deleteObj.SentinelVideos); //if (deleteObj.DeviceInfo != null) // db.IPDeviceInfo.Remove(deleteObj.DeviceInfo); //if (deleteObj.SentinelSetting != null) // db.Set<SentinelSetting>().Remove(deleteObj.SentinelSetting); //if (deleteObj.DefenseDevices != null) // db.DefenseDevice.RemoveRange(deleteObj.DefenseDevices); //if (deleteObj.AlarmOutputChannels != null) // db.Set<DeviceChannelSetting>().RemoveRange(deleteObj.AlarmOutputChannels); //移除哨位台人员指纹 DeleteSentinelFingerInfo(db, deleteObj); //db.Sentinel.Remove(deleteObj); //将设备标记为移除状态 var deleteStatusId = Guid.Parse("a0002016-e009-b019-e001-abcd13800005"); deleteObj.DeviceInfo.StatusId = deleteStatusId; //报警配置设备id List <Guid> alarmSourceIds = new List <Guid>(); if (deleteObj.DefenseDevices != null) { deleteObj.DefenseDevices.ForEach(t => { t.DeviceInfo.StatusId = deleteStatusId; alarmSourceIds.Add(t.DeviceInfoId); }); } db.IPDeviceInfo.Update(deleteObj.DeviceInfo); db.IPDeviceInfo.UpdateRange(deleteObj.DefenseDevices.Select(t => t.DeviceInfo)); db.SaveChanges(); alarmSourceIds.Add(deleteObj.DeviceInfoId); //删除报警配置 AlarmSettingUtility.RemoveAlarmSetting(db, alarmSourceIds); tran.Commit(); SendDatachangeNotify(deleteObj.DeviceInfo, 0); } catch (DbUpdateException dbEx) { tran.Rollback(); _logger.LogError("删除哨位台异常:Message:{0}\r\n,StackTrace:{1}", dbEx.Message, dbEx.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (Exception ex) { tran.Rollback(); _logger.LogError("删除哨位台异常:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } } } return(NoContent()); }