aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Player
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-01-01 23:31:16 -0300
committerariel- <ariel-@users.noreply.github.com>2018-01-01 23:33:04 -0300
commit5b663f116244b9d30a3f6ffae65649f4b1100cdd (patch)
tree1fe8bbe52d67ae98579b92d8f6ae43e097ecb573 /src/server/game/Entities/Player
parent2a5d3a64bcf5b3bb2e107b62411085ac29454ec3 (diff)
Core/Player: implemented facial hair validation
Diffstat (limited to 'src/server/game/Entities/Player')
-rw-r--r--src/server/game/Entities/Player/Player.cpp74
1 files changed, 34 insertions, 40 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index c757645606d..4b8a7b57742 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -26526,54 +26526,48 @@ void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const
bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create /*=false*/)
{
- // Check skin color
- // For Skin type is always 0
- if (CharSectionsEntry const* entry = GetCharSectionEntry(race, SECTION_TYPE_SKIN, gender, 0, skinColor))
- { // Skin Color defined as Face color, too, we check skin & face in one pass
- if (CharSectionsEntry const* entry2 = GetCharSectionEntry(race, SECTION_TYPE_FACE, gender, faceID, skinColor))
- {
- // Check DeathKnight exclusive
- if (((entry->Flags & SECTION_FLAG_DEATH_KNIGHT) || (entry2->Flags & SECTION_FLAG_DEATH_KNIGHT)) && class_ != CLASS_DEATH_KNIGHT)
- return false;
- if (create && !((entry->Flags & SECTION_FLAG_PLAYER) && (entry2->Flags & SECTION_FLAG_PLAYER)))
- return false;
- }
- else
+ auto validateCharSection = [class_, create](CharSectionsEntry const* entry) -> bool
+ {
+ if (!entry)
return false;
- }
- else
+
+ // Check Death Knight exclusive
+ if (class_ != CLASS_DEATH_KNIGHT && entry->HasFlag(SECTION_FLAG_DEATH_KNIGHT))
+ return false;
+
+ // Character creation/customize has some limited sections (as opposed to barbershop)
+ if (create && !entry->HasFlag(SECTION_FLAG_PLAYER))
+ return false;
+
+ return true;
+ };
+
+ // For Skin type is always 0
+ CharSectionsEntry const* skinEntry = GetCharSectionEntry(race, SECTION_TYPE_SKIN, gender, 0, skinColor);
+ if (!validateCharSection(skinEntry))
return false;
- // These combinations don't have an entry of Type SECTION_TYPE_FACIAL_HAIR, exclude them from that check
- bool excludeCheck = (race == RACE_TAUREN) || (race == RACE_DRAENEI) || (gender == GENDER_FEMALE && race != RACE_NIGHTELF && race != RACE_UNDEAD_PLAYER);
+ // Skin Color defined as Face color, too
+ CharSectionsEntry const* faceEntry = GetCharSectionEntry(race, SECTION_TYPE_FACE, gender, faceID, skinColor);
+ if (!validateCharSection(faceEntry))
+ return false;
// Check Hair
- if (CharSectionsEntry const* entry = GetCharSectionEntry(race, SECTION_TYPE_HAIR, gender, hairID, hairColor))
+ CharSectionsEntry const* hairEntry = GetCharSectionEntry(race, SECTION_TYPE_HAIR, gender, hairID, hairColor);
+ if (!validateCharSection(hairEntry))
+ return false;
+
+ // These combinations don't have an entry of Type SECTION_TYPE_FACIAL_HAIR, exclude them from that check
+ bool const excludeCheck = (race == RACE_TAUREN) || (race == RACE_DRAENEI) || (gender == GENDER_FEMALE && race != RACE_NIGHTELF && race != RACE_UNDEAD_PLAYER);
+ if (!excludeCheck)
{
- if ((entry->Flags & SECTION_FLAG_DEATH_KNIGHT) && class_ != CLASS_DEATH_KNIGHT)
+ CharSectionsEntry const* facialHairEntry = GetCharSectionEntry(race, SECTION_TYPE_FACIAL_HAIR, gender, facialHair, hairColor);
+ if (!validateCharSection(facialHairEntry))
return false;
- if (create && !(entry->Flags & SECTION_FLAG_PLAYER))
- return false;
-
- if (!excludeCheck)
- {
- if (CharSectionsEntry const* entry2 = GetCharSectionEntry(race, SECTION_TYPE_FACIAL_HAIR, gender, facialHair, hairColor))
- {
- if ((entry2->Flags & SECTION_FLAG_DEATH_KNIGHT) && class_ != CLASS_DEATH_KNIGHT)
- return false;
- if (create && !(entry2->Flags & SECTION_FLAG_PLAYER))
- return false;
- }
- else
- return false;
- }
- else
- {
- // @TODO: Bound checking for facialHair ID (used clientside for markings, tauren beard, etc.)
- // Not present in DBC
- }
}
- else
+
+ CharacterFacialHairStylesEntry const* entry = GetCharFacialHairEntry(race, gender, facialHair);
+ if (!entry)
return false;
return true;