mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Core/Guild: Add validation for guild tabard colors
This commit is contained in:
@@ -132,6 +132,9 @@ GameTable <GtSpellScalingEntry> sGtSpellScalingStore(GtSpellScalingfmt)
|
||||
GameTable <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore(GtOCTBaseHPByClassfmt);
|
||||
GameTable <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore(GtOCTBaseMPByClassfmt);
|
||||
DBCStorage <GuildPerkSpellsEntry> sGuildPerkSpellsStore(GuildPerkSpellsfmt);
|
||||
DBCStorage <GuildColorBackgroundEntry> sGuildColorBackgroundStore(GuildColorBackgroundfmt);
|
||||
DBCStorage <GuildColorBorderEntry> sGuildColorBorderStore(GuildColorBorderfmt);
|
||||
DBCStorage <GuildColorEmblemEntry> sGuildColorEmblemStore(GuildColorEmblemfmt);
|
||||
|
||||
DBCStorage <ImportPriceArmorEntry> sImportPriceArmorStore(ImportPriceArmorfmt);
|
||||
DBCStorage <ImportPriceQualityEntry> sImportPriceQualityStore(ImportPriceQualityfmt);
|
||||
@@ -464,6 +467,9 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sGlyphPropertiesStore, dbcPath, "GlyphProperties.dbc");//19116
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sGlyphSlotStore, dbcPath, "GlyphSlot.dbc");//19116
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sGuildPerkSpellsStore, dbcPath, "GuildPerkSpells.dbc");//19116
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sGuildColorBackgroundStore, dbcPath, "GuildColorBackground.dbc");//19865
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sGuildColorBorderStore, dbcPath, "GuildColorBorder.dbc"); //19865
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sGuildColorEmblemStore, dbcPath, "GuildColorEmblem.dbc");//19865
|
||||
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sImportPriceArmorStore, dbcPath, "ImportPriceArmor.dbc"); // 19116
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sImportPriceQualityStore, dbcPath, "ImportPriceQuality.dbc"); // 19116
|
||||
|
||||
@@ -185,6 +185,9 @@ extern GameTable <GtSpellScalingEntry> sGtSpellScalingStore;
|
||||
extern GameTable <GtOCTBaseHPByClassEntry> sGtOCTBaseHPByClassStore;
|
||||
extern GameTable <GtOCTBaseMPByClassEntry> sGtOCTBaseMPByClassStore;
|
||||
extern DBCStorage <GuildPerkSpellsEntry> sGuildPerkSpellsStore;
|
||||
extern DBCStorage <GuildColorBackgroundEntry> sGuildColorBackgroundStore;
|
||||
extern DBCStorage <GuildColorBorderEntry> sGuildColorBorderStore;
|
||||
extern DBCStorage <GuildColorEmblemEntry> sGuildColorEmblemStore;
|
||||
extern DBCStorage <ImportPriceArmorEntry> sImportPriceArmorStore;
|
||||
extern DBCStorage <ImportPriceQualityEntry> sImportPriceQualityStore;
|
||||
extern DBCStorage <ImportPriceShieldEntry> sImportPriceShieldStore;
|
||||
|
||||
@@ -953,6 +953,33 @@ struct GuildPerkSpellsEntry
|
||||
uint32 SpellID; // 2
|
||||
};
|
||||
|
||||
// GuildColorBackground.dbc
|
||||
struct GuildColorBackgroundEntry
|
||||
{
|
||||
uint32 ID;
|
||||
//uint8 Red;
|
||||
//uint8 Green;
|
||||
//uint8 Blue;
|
||||
};
|
||||
|
||||
// GuildColorBorder.dbc
|
||||
struct GuildColorBorderEntry
|
||||
{
|
||||
uint32 ID;
|
||||
//uint8 Red;
|
||||
//uint8 Green;
|
||||
//uint8 Blue;
|
||||
};
|
||||
|
||||
// GuildColorEmblem.dbc
|
||||
struct GuildColorEmblemEntry
|
||||
{
|
||||
uint32 ID;
|
||||
//uint8 Red;
|
||||
//uint8 Green;
|
||||
//uint8 Blue;
|
||||
};
|
||||
|
||||
// ImportPriceArmor.dbc
|
||||
struct ImportPriceArmorEntry
|
||||
{
|
||||
|
||||
@@ -88,6 +88,9 @@ char const GtSpellScalingfmt[] = "df";
|
||||
char const GtOCTBaseHPByClassfmt[] = "df";
|
||||
char const GtOCTBaseMPByClassfmt[] = "df";
|
||||
char const GuildPerkSpellsfmt[] = "dii";
|
||||
char const GuildColorBackgroundfmt[] = "iXXX";
|
||||
char const GuildColorBorderfmt[] = "iXXX";
|
||||
char const GuildColorEmblemfmt[] = "iXXX";
|
||||
char const ImportPriceArmorfmt[] = "nffff";
|
||||
char const ImportPriceQualityfmt[] = "nf";
|
||||
char const ImportPriceShieldfmt[] = "nf";
|
||||
|
||||
@@ -678,13 +678,25 @@ void EmblemInfo::ReadPacket(WorldPackets::Guild::SaveGuildEmblem& packet)
|
||||
m_backgroundColor = packet.Bg;
|
||||
}
|
||||
|
||||
void EmblemInfo::LoadFromDB(Field* fields)
|
||||
bool EmblemInfo::ValidateEmblemColors()
|
||||
{
|
||||
if (sGuildColorBackgroundStore.LookupEntry(m_backgroundColor) &&
|
||||
sGuildColorBorderStore.LookupEntry(m_borderColor) &&
|
||||
sGuildColorEmblemStore.LookupEntry(m_color))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EmblemInfo::LoadFromDB(Field* fields)
|
||||
{
|
||||
m_style = fields[3].GetUInt8();
|
||||
m_color = fields[4].GetUInt8();
|
||||
m_borderStyle = fields[5].GetUInt8();
|
||||
m_borderColor = fields[6].GetUInt8();
|
||||
m_backgroundColor = fields[7].GetUInt8();
|
||||
|
||||
return ValidateEmblemColors();
|
||||
}
|
||||
|
||||
void EmblemInfo::SaveToDB(ObjectGuid::LowType guildId) const
|
||||
@@ -2244,7 +2256,13 @@ bool Guild::LoadFromDB(Field* fields)
|
||||
m_id = fields[0].GetUInt64();
|
||||
m_name = fields[1].GetString();
|
||||
m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt64());
|
||||
m_emblemInfo.LoadFromDB(fields);
|
||||
|
||||
if (!m_emblemInfo.LoadFromDB(fields))
|
||||
{
|
||||
TC_LOG_ERROR("guild", "Guild " UI64FMTD " has invalid emblem colors, skipped.", m_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_info = fields[8].GetString();
|
||||
m_motd = fields[9].GetString();
|
||||
m_createdDate = time_t(fields[10].GetUInt32());
|
||||
|
||||
@@ -266,9 +266,10 @@ class EmblemInfo
|
||||
public:
|
||||
EmblemInfo() : m_style(0), m_color(0), m_borderStyle(0), m_borderColor(0), m_backgroundColor(0) { }
|
||||
|
||||
void LoadFromDB(Field* fields);
|
||||
bool LoadFromDB(Field* fields);
|
||||
void SaveToDB(ObjectGuid::LowType guildId) const;
|
||||
void ReadPacket(WorldPackets::Guild::SaveGuildEmblem& packet);
|
||||
bool ValidateEmblemColors();
|
||||
|
||||
uint32 GetStyle() const { return m_style; }
|
||||
uint32 GetColor() const { return m_color; }
|
||||
|
||||
@@ -191,6 +191,12 @@ void WorldSession::HandleSaveGuildEmblem(WorldPackets::Guild::SaveGuildEmblem& p
|
||||
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
|
||||
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
if (!emblemInfo.ValidateEmblemColors())
|
||||
{
|
||||
Guild::SendSaveEmblemResult(this, ERR_GUILDEMBLEM_INVALID_TABARD_COLORS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Guild* guild = GetPlayer()->GetGuild())
|
||||
guild->HandleSetEmblem(this, emblemInfo);
|
||||
else
|
||||
|
||||
@@ -3030,8 +3030,8 @@ void SpellMgr::LoadSpellInfoCorrections()
|
||||
|
||||
switch (spellInfo->Id)
|
||||
{
|
||||
case 63026: // Force Cast (HACK: Target shouldn't be changed)
|
||||
case 63137: // Force Cast (HACK: Target shouldn't be changed; summon position should be untied from spell destination)
|
||||
case 63026: // Summon Aspirant Test NPC (HACK: Target shouldn't be changed)
|
||||
case 63137: // Summon Valiant Test (HACK: Target shouldn't be changed; summon position should be untied from spell destination)
|
||||
const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB);
|
||||
break;
|
||||
case 42436: // Drink! (Brewfest)
|
||||
|
||||
@@ -94,7 +94,8 @@ public:
|
||||
uint32 GetId() const { return _id; }
|
||||
ObjectGuid GetPlayerGuid() const { return _playerGuid; }
|
||||
Player* GetPlayer() const { return ObjectAccessor::FindConnectedPlayer(_playerGuid); }
|
||||
std::string GetPlayerName() const {
|
||||
std::string GetPlayerName() const
|
||||
{
|
||||
std::string name;
|
||||
if (!_playerGuid.IsEmpty())
|
||||
ObjectMgr::GetPlayerNameByGUID(_playerGuid, name);
|
||||
|
||||
Reference in New Issue
Block a user