Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions conf/mod_account_mount.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ Account.Mounts.Announce = 0

Account.Mounts.ExcludedSpellIDs = 0

# Limit race and class specific mounts? (1: true | 0: false)
# 0 = will allow any race/class to own other racial/class-specific mounts.
# Limit race specific mounts? (1: true | 0: false)
# 0 = will allow any race to own other racial-specific mounts.
# 1 = will enforce the limit.

Account.Mounts.LimitRace = 0
Account.Mounts.LimitRace = 1

# Limit class specific mounts? (1: true | 0: false)
# 0 = will allow any class to own other class-specific mounts.
# 1 = will enforce the limit.

Account.Mounts.LimitClass = 1
17 changes: 12 additions & 5 deletions src/mod_account_mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@

class AccountMounts : public PlayerScript
{
bool limitrace; // Boolean to hold limit race option
bool limitRace; // Boolean to hold limit race option
bool limitClass; // Boolean to hold limit class option
std::set<uint32> excludedSpellIds; // Set to hold the Spell IDs to be excluded

public:
AccountMounts() : PlayerScript("AccountMounts", {
PLAYERHOOK_ON_LOGIN
})
{
// Retrieve limitrace option from the config file
limitrace = sConfigMgr->GetOption<bool>("Account.Mounts.LimitRace", false);
// Retrieve limitRace / limitClass options from the config file
limitRace = sConfigMgr->GetOption<bool>("Account.Mounts.LimitRace", true);
limitClass = sConfigMgr->GetOption<bool>("Account.Mounts.LimitClass", true);
// Retrieve the string of excluded Spell IDs from the config file
std::string excludedSpellsStr = sConfigMgr->GetOption<std::string>("Account.Mounts.ExcludedSpellIDs", "");
// Proceed only if the configuration is not "0" or empty, indicating exclusions are specified
Expand All @@ -43,7 +45,7 @@ class AccountMounts : public PlayerScript

std::vector<uint32> Guids;
uint32 playerAccountID = pPlayer->GetSession()->GetAccountId();
QueryResult result1 = CharacterDatabase.Query("SELECT `guid`, `race` FROM `characters` WHERE `account`={};", playerAccountID);
QueryResult result1 = CharacterDatabase.Query("SELECT `guid`, `race`, `class` FROM `characters` WHERE `account`={};", playerAccountID);

if (!result1)
return;
Expand All @@ -52,8 +54,13 @@ class AccountMounts : public PlayerScript
{
Field* fields = result1->Fetch();
uint32 race = fields[1].Get<uint8>();
uint32 clazz = fields[2].Get<uint8>();

if ((Player::TeamIdForRace(race) == Player::TeamIdForRace(pPlayer->getRace())) || !limitrace)
bool push_back = true;
push_back &= Player::TeamIdForRace(race) == Player::TeamIdForRace(pPlayer->getRace()) || !limitRace;
push_back &= clazz == pPlayer->getClass() || !limitClass;
Comment thread
lucafolloni marked this conversation as resolved.

if (push_back)
Guids.push_back(fields[0].Get<uint32>());

} while (result1->NextRow());
Expand Down