Skip to content

Commit 949cdfb

Browse files
authored
Improve eligibility checks for portable transmog NPC (#211)
Added Game Master override for plus feature eligibility and enhanced error handling in the portable transmogrification NPC command. Now checks for feature enablement, player eligibility, and spell availability before casting.
1 parent 3a0d90a commit 949cdfb

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/Transmogrification.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,9 @@ bool Transmogrification::IsPlusFeatureEligible(ObjectGuid const &playerGuid, uin
12291229
if (!player)
12301230
return false;
12311231

1232+
if (player->IsGameMaster())
1233+
return true; // GM can use all features
1234+
12321235
const auto membershipLevel = GetPlayerMembershipLevel(player);
12331236

12341237
if (!membershipLevel)

src/cs_transmog.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Transmogrification.h"
2323
#include "Tokenize.h"
2424
#include "DatabaseEnv.h"
25+
#include "SpellMgr.h"
2526

2627
using namespace Acore::ChatCommands;
2728

@@ -280,27 +281,31 @@ class transmog_commandscript : public CommandScript
280281
{
281282
if (!sTransmogrification->IsPortableNPCEnabled)
282283
{
283-
handler->GetPlayer()->SendSystemMessage("The portable transmogrification NPC is disabled.");
284-
handler->SetSentErrorMessage(true);
284+
handler->SendErrorMessage("The portable transmogrification NPC is disabled.");
285285
return true;
286286
}
287287

288-
if (Player* player = PlayerIdentifier::FromSelf(handler)->GetConnectedPlayer())
288+
if (!sTransmogrification->IsTransmogPlusEnabled)
289289
{
290+
handler->SendErrorMessage("The portable transmogrification NPC is a plus feature. Plus features are currently disabled.");
291+
return true;
292+
}
290293

291-
if (sTransmogrification->IsTransmogPlusEnabled)
292-
if (sTransmogrification->IsPlusFeatureEligible(player->GetGUID(), PLUS_FEATURE_PET))
293-
{
294-
player->CastSpell((Unit*)nullptr, sTransmogrification->PetSpellId, true);
295-
return true;
296-
}
294+
Player* player = PlayerIdentifier::FromSelf(handler)->GetConnectedPlayer();
297295

298-
if (player->GetSession()->GetSecurity() < SEC_MODERATOR)
299-
return true;
296+
if (!sTransmogrification->IsPlusFeatureEligible(player->GetGUID(), PLUS_FEATURE_PET))
297+
{
298+
handler->SendErrorMessage("You are not eligible for the portable transmogrification NPC. Please check your subscription level.");
299+
return true;
300+
}
300301

301-
player->CastSpell((Unit*)nullptr, sTransmogrification->PetSpellId, true);
302+
if (!sSpellMgr->GetSpellInfo(sTransmogrification->PetSpellId))
303+
{
304+
handler->SendErrorMessage("The portable transmogrification NPC spell is not available.");
305+
return true;
302306
}
303307

308+
player->CastSpell((Unit*)nullptr, sTransmogrification->PetSpellId, true);
304309
return true;
305310
};
306311

0 commit comments

Comments
 (0)