public bool StoreTo(out GarrAbilityRecord val, string arg) { val = default; HyperlinkDataTokenizer t = new(arg); if (!t.TryConsumeTo(out uint garrAbilityId)) { return(false); } val = CliDB.GarrAbilityStorage.LookupByKey(garrAbilityId); return(val != null && t.IsEmpty()); }
void LoadFollowerClassSpecAbilities() { SQLResult result = DB.World.Query("SELECT classSpecId, abilityId FROM garrison_follower_class_spec_abilities"); if (result.IsEmpty()) { Log.outInfo(LogFilter.ServerLoading, "Loaded 0 garrison follower class spec abilities. DB table `garrison_follower_class_spec_abilities` is empty."); return; } uint msTime = Time.GetMSTime(); uint count = 0; do { uint classSpecId = result.Read <uint>(0); uint abilityId = result.Read <uint>(1); if (!CliDB.GarrClassSpecStorage.ContainsKey(classSpecId)) { Log.outError(LogFilter.Sql, "Non-existing GarrClassSpec.db2 entry {0} was referenced in `garrison_follower_class_spec_abilities` by row ({1}, {2}).", classSpecId, classSpecId, abilityId); continue; } GarrAbilityRecord ability = CliDB.GarrAbilityStorage.LookupByKey(abilityId); if (ability == null) { Log.outError(LogFilter.Sql, "Non-existing GarrAbility.db2 entry {0} was referenced in `garrison_follower_class_spec_abilities` by row ({1}, {2}).", abilityId, classSpecId, abilityId); continue; } _garrisonFollowerClassSpecAbilities.Add(classSpecId, ability); ++count; } while (result.NextRow()); //foreach (var key in _garrisonFollowerClassSpecAbilities.Keys) //_garrisonFollowerClassSpecAbilities[key].Sort(); Log.outInfo(LogFilter.ServerLoading, "Loaded {0} garrison follower class spec abilities in {1}.", count, Time.GetMSTimeDiffToNow(msTime)); }
public void Initialize() { foreach (GarrSiteLevelPlotInstRecord siteLevelPlotInst in CliDB.GarrSiteLevelPlotInstStorage.Values) { _garrisonPlotInstBySiteLevel.Add(siteLevelPlotInst.GarrSiteLevelID, siteLevelPlotInst); } foreach (GameObjectsRecord gameObject in CliDB.GameObjectsStorage.Values) { if (gameObject.TypeID == GameObjectTypes.GarrisonPlot) { if (!_garrisonPlots.ContainsKey(gameObject.OwnerID)) { _garrisonPlots[gameObject.OwnerID] = new Dictionary <uint, GameObjectsRecord>(); } _garrisonPlots[gameObject.OwnerID][(uint)gameObject.PropValue[0]] = gameObject; } } foreach (GarrPlotBuildingRecord plotBuilding in CliDB.GarrPlotBuildingStorage.Values) { _garrisonBuildingsByPlot.Add(plotBuilding.GarrPlotID, plotBuilding.GarrBuildingID); } foreach (GarrBuildingPlotInstRecord buildingPlotInst in CliDB.GarrBuildingPlotInstStorage.Values) { _garrisonBuildingPlotInstances[MathFunctions.MakePair64(buildingPlotInst.GarrBuildingID, buildingPlotInst.GarrSiteLevelPlotInstID)] = buildingPlotInst.Id; } foreach (GarrBuildingRecord building in CliDB.GarrBuildingStorage.Values) { _garrisonBuildingsByType.Add(building.BuildingType, building.Id); } for (var i = 0; i < 2; ++i) { _garrisonFollowerAbilities[i] = new Dictionary <uint, GarrAbilities>(); } foreach (GarrFollowerXAbilityRecord followerAbility in CliDB.GarrFollowerXAbilityStorage.Values) { GarrAbilityRecord ability = CliDB.GarrAbilityStorage.LookupByKey(followerAbility.GarrAbilityID); if (ability != null) { if (ability.GarrFollowerTypeID != (uint)GarrisonFollowerType.Garrison) { continue; } if (!ability.Flags.HasAnyFlag(GarrisonAbilityFlags.CannotRoll) && ability.Flags.HasAnyFlag(GarrisonAbilityFlags.Trait)) { _garrisonFollowerRandomTraits.Add(ability); } if (followerAbility.FactionIndex < 2) { var dic = _garrisonFollowerAbilities[followerAbility.FactionIndex]; if (!dic.ContainsKey(followerAbility.GarrFollowerID)) { dic[followerAbility.GarrFollowerID] = new GarrAbilities(); } if (ability.Flags.HasAnyFlag(GarrisonAbilityFlags.Trait)) { dic[followerAbility.GarrFollowerID].Traits.Add(ability); } else { dic[followerAbility.GarrFollowerID].Counters.Add(ability); } } } } InitializeDbIdSequences(); LoadPlotFinalizeGOInfo(); LoadFollowerClassSpecAbilities(); }
public bool LoadFromDB(SQLResult garrison, SQLResult blueprints, SQLResult buildings, SQLResult followers, SQLResult abilities) { if (garrison.IsEmpty()) { return(false); } _siteLevel = CliDB.GarrSiteLevelStorage.LookupByKey(garrison.Read <uint>(0)); _followerActivationsRemainingToday = garrison.Read <uint>(1); if (_siteLevel == null) { return(false); } InitializePlots(); if (!blueprints.IsEmpty()) { do { GarrBuildingRecord building = CliDB.GarrBuildingStorage.LookupByKey(blueprints.Read <uint>(0)); if (building != null) { _knownBuildings.Add(building.Id); } } while (blueprints.NextRow()); } if (!buildings.IsEmpty()) { do { uint plotInstanceId = buildings.Read <uint>(0); uint buildingId = buildings.Read <uint>(1); long timeBuilt = buildings.Read <long>(2); bool active = buildings.Read <bool>(3); Plot plot = GetPlot(plotInstanceId); if (plot == null) { continue; } if (!CliDB.GarrBuildingStorage.ContainsKey(buildingId)) { continue; } plot.BuildingInfo.PacketInfo.HasValue = true; plot.BuildingInfo.PacketInfo.Value.GarrPlotInstanceID = plotInstanceId; plot.BuildingInfo.PacketInfo.Value.GarrBuildingID = buildingId; plot.BuildingInfo.PacketInfo.Value.TimeBuilt = timeBuilt; plot.BuildingInfo.PacketInfo.Value.Active = active; } while (buildings.NextRow()); } if (!followers.IsEmpty()) { do { ulong dbId = followers.Read <ulong>(0); uint followerId = followers.Read <uint>(1); if (!CliDB.GarrFollowerStorage.ContainsKey(followerId)) { continue; } _followerIds.Add(followerId); var follower = new Follower(); follower.PacketInfo.DbID = dbId; follower.PacketInfo.GarrFollowerID = followerId; follower.PacketInfo.Quality = followers.Read <uint>(2); follower.PacketInfo.FollowerLevel = followers.Read <uint>(3); follower.PacketInfo.ItemLevelWeapon = followers.Read <uint>(4); follower.PacketInfo.ItemLevelArmor = followers.Read <uint>(5); follower.PacketInfo.Xp = followers.Read <uint>(6); follower.PacketInfo.CurrentBuildingID = followers.Read <uint>(7); follower.PacketInfo.CurrentMissionID = followers.Read <uint>(8); follower.PacketInfo.FollowerStatus = followers.Read <uint>(9); if (!CliDB.GarrBuildingStorage.ContainsKey(follower.PacketInfo.CurrentBuildingID)) { follower.PacketInfo.CurrentBuildingID = 0; } //if (!sGarrMissionStore.LookupEntry(follower.PacketInfo.CurrentMissionID)) // follower.PacketInfo.CurrentMissionID = 0; _followers[followerId] = follower; } while (followers.NextRow()); if (!abilities.IsEmpty()) { do { ulong dbId = abilities.Read <ulong>(0); GarrAbilityRecord ability = CliDB.GarrAbilityStorage.LookupByKey(abilities.Read <uint>(1)); if (ability == null) { continue; } var garrisonFollower = _followers.LookupByKey(dbId); if (garrisonFollower == null) { continue; } garrisonFollower.PacketInfo.AbilityID.Add(ability); } while (abilities.NextRow()); } } return(true); }