Core/AdventureJournal: Check if player can access adventure journal with ChrClassUIDisplay.db2

Port From (https://github.com/TrinityCore/TrinityCore/commit/d0246e5835ea184b22896e6b354fb28c28890810)
This commit is contained in:
hondacrx
2021-03-15 17:05:52 -04:00
parent eee335291f
commit 75559fc9d6
6 changed files with 53 additions and 0 deletions
@@ -199,6 +199,9 @@ namespace Framework.Database
PrepareStatement(HotfixStatements.SEL_CHAT_CHANNELS, "SELECT Name, Shortcut, ID, Flags, FactionGroup, Ruleset FROM chat_channels");
PrepareStatement(HotfixStatements.SEL_CHAT_CHANNELS_LOCALE, "SELECT ID, Name_lang, Shortcut_lang FROM chat_channels_locale WHERE locale = ?");
// ChrClassUiDisplay.db2
PrepareStatement(HotfixStatements.SEL_CHR_CLASS_UI_DISPLAY, "SELECT ID, ChrClassesID, AdvGuidePlayerConditionID, SplashPlayerConditionID FROM chr_class_ui_display");
// ChrClasses.db2
PrepareStatement(HotfixStatements.SEL_CHR_CLASSES, "SELECT Name, Filename, NameMale, NameFemale, PetNameToken, Description, RoleInfoString, DisabledString, " +
"HyphenatedNameMale, HyphenatedNameFemale, ID, CreateScreenFileDataID, SelectScreenFileDataID, IconFileDataID, LowResScreenFileDataID, Flags, " +
@@ -1256,6 +1259,8 @@ namespace Framework.Database
SEL_CHAT_CHANNELS,
SEL_CHAT_CHANNELS_LOCALE,
SEL_CHR_CLASS_UI_DISPLAY,
SEL_CHR_CLASSES,
SEL_CHR_CLASSES_LOCALE,
+2
View File
@@ -96,6 +96,7 @@ namespace Game.DataStorage
CharacterLoadoutStorage = ReadDB2<CharacterLoadoutRecord>("CharacterLoadout.db2", HotfixStatements.SEL_CHARACTER_LOADOUT);
CharacterLoadoutItemStorage = ReadDB2<CharacterLoadoutItemRecord>("CharacterLoadoutItem.db2", HotfixStatements.SEL_CHARACTER_LOADOUT_ITEM);
ChatChannelsStorage = ReadDB2<ChatChannelsRecord>("ChatChannels.db2", HotfixStatements.SEL_CHAT_CHANNELS, HotfixStatements.SEL_CHAT_CHANNELS_LOCALE);
ChrClassUIDisplayStorage = ReadDB2<ChrClassUIDisplayRecord>("ChrClassUIDisplay.db2", HotfixStatements.SEL_CHR_CLASS_UI_DISPLAY);
ChrClassesStorage = ReadDB2<ChrClassesRecord>("ChrClasses.db2", HotfixStatements.SEL_CHR_CLASSES, HotfixStatements.SEL_CHR_CLASSES_LOCALE);
ChrClassesXPowerTypesStorage = ReadDB2<ChrClassesXPowerTypesRecord>("ChrClassesXPowerTypes.db2", HotfixStatements.SEL_CHR_CLASSES_X_POWER_TYPES);
ChrCustomizationChoiceStorage= ReadDB2<ChrCustomizationChoiceRecord>("ChrCustomizationChoice.db2", HotfixStatements.SEL_CHR_CUSTOMIZATION_CHOICE, HotfixStatements.SEL_CHR_CUSTOMIZATION_CHOICE_LOCALE);
@@ -455,6 +456,7 @@ namespace Game.DataStorage
public static DB6Storage<CharacterLoadoutRecord> CharacterLoadoutStorage;
public static DB6Storage<CharacterLoadoutItemRecord> CharacterLoadoutItemStorage;
public static DB6Storage<ChatChannelsRecord> ChatChannelsStorage;
public static DB6Storage<ChrClassUIDisplayRecord> ChrClassUIDisplayStorage;
public static DB6Storage<ChrClassesRecord> ChrClassesStorage;
public static DB6Storage<ChrClassesXPowerTypesRecord> ChrClassesXPowerTypesStorage;
public static DB6Storage<ChrCustomizationChoiceRecord> ChrCustomizationChoiceStorage;
+13
View File
@@ -133,6 +133,12 @@ namespace Game.DataStorage
}
}
foreach (var uiDisplay in CliDB.ChrClassUIDisplayStorage.Values)
{
Cypher.Assert(uiDisplay.ChrClassesID < (byte)Class.Max);
_uiDisplayByClass[uiDisplay.ChrClassesID] = uiDisplay;
}
var powers = new List<ChrClassesXPowerTypesRecord>();
foreach (var chrClasses in CliDB.ChrClassesXPowerTypesStorage.Values)
powers.Add(chrClasses);
@@ -999,6 +1005,12 @@ namespace Game.DataStorage
return broadcastText.Text[SharedConst.DefaultLocale];
}
public ChrClassUIDisplayRecord GetUiDisplayForClass(Class unitClass)
{
Cypher.Assert(unitClass < Class.Max);
return _uiDisplayByClass[(int)unitClass];
}
public string GetClassName(Class class_, Locale locale = Locale.enUS)
{
ChrClassesRecord classEntry = CliDB.ChrClassesStorage.LookupByKey(class_);
@@ -2292,6 +2304,7 @@ namespace Game.DataStorage
MultiMap<uint, AzeritePowerSetMemberRecord> _azeritePowers = new MultiMap<uint, AzeritePowerSetMemberRecord>();
Dictionary<(uint azeriteUnlockSetId, ItemContext itemContext), byte[]> _azeriteTierUnlockLevels = new Dictionary<(uint azeriteUnlockSetId, ItemContext itemContext), byte[]>();
Dictionary<(uint itemId, ItemContext itemContext), AzeriteUnlockMappingRecord> _azeriteUnlockMappings = new Dictionary<(uint itemId, ItemContext itemContext), AzeriteUnlockMappingRecord>();
ChrClassUIDisplayRecord[] _uiDisplayByClass = new ChrClassUIDisplayRecord[(int)Class.Max];
uint[][] _powersByClass = new uint[(int)Class.Max][];
MultiMap<uint, ChrCustomizationChoiceRecord> _chrCustomizationChoicesByOption = new MultiMap<uint, ChrCustomizationChoiceRecord>();
Dictionary<Tuple<byte, byte>, ChrModelRecord> _chrModelsByRaceAndGender = new Dictionary<Tuple<byte, byte>, ChrModelRecord>();
@@ -66,6 +66,14 @@ namespace Game.DataStorage
public int Ruleset;
}
public sealed class ChrClassUIDisplayRecord
{
public uint Id;
public byte ChrClassesID;
public uint AdvGuidePlayerConditionID;
public uint SplashPlayerConditionID;
}
public sealed class ChrClassesRecord
{
public LocalizedString Name;
@@ -38,6 +38,11 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.AdventureJournalOpenQuest)]
void HandleAdventureJournalOpenQuest(AdventureJournalOpenQuest openQuest)
{
var uiDisplay = Global.DB2Mgr.GetUiDisplayForClass(_player.GetClass());
if (uiDisplay != null)
if (!_player.MeetPlayerCondition(uiDisplay.AdvGuidePlayerConditionID))
return;
var adventureJournal = CliDB.AdventureJournalStorage.LookupByKey(openQuest.AdventureJournalID);
if (adventureJournal == null)
return;
@@ -80,6 +85,11 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.AdventureJournalUpdateSuggestions)]
void HandleAdventureJournalUpdateSuggestions(AdventureJournalUpdateSuggestions updateSuggestions)
{
var uiDisplay = Global.DB2Mgr.GetUiDisplayForClass(_player.GetClass());
if (uiDisplay != null)
if (!_player.MeetPlayerCondition(uiDisplay.AdvGuidePlayerConditionID))
return;
AdventureJournalDataResponse response = new AdventureJournalDataResponse();
response.OnLevelUp = updateSuggestions.OnLevelUp;
@@ -0,0 +1,15 @@
--
-- Table structure for table `chr_class_ui_display`
--
DROP TABLE IF EXISTS `chr_class_ui_display`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `chr_class_ui_display` (
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`ChrClassesID` tinyint(3) unsigned NOT NULL DEFAULT '0',
`AdvGuidePlayerConditionID` int(10) unsigned NOT NULL DEFAULT '0',
`SplashPlayerConditionID` int(10) unsigned NOT NULL DEFAULT '0',
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`,`VerifiedBuild`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;