Francesco Borzi
Francesco Borzi

Reputation: 61984

AzerothCore change race or faction "could not change race for character"

After using a .character changefaction xxx or .character changerace xxx on the character xxx I cannot customise and save the character because it fails with:

Could not change faction for character

Upvotes: 2

Views: 1112

Answers (1)

Francesco Borzi
Francesco Borzi

Reputation: 61984

TLDR: here's the solution:

  • make sure the character is NOT in a guild
  • make sure the character is NOT an arena team captain
  • make sure the character does NOT have any mail in the mailbox
  • make sure the character does NOT have any auction pending

And here's how I found the solution.

This action is handled by the following method:

void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)

inside the CharacterHandler.cpp file.

So here's everything that could go wrong:

        // if player is in a guild
        if (playerData->guildId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
        {
            WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
            data << (uint8)CHAR_CREATE_CHARACTER_IN_GUILD;
            SendPacket(&data);
            return;
        }

        // is arena team captain
        if (sArenaTeamMgr->GetArenaTeamByCaptain(guid))
        {
            WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
            data << (uint8)CHAR_CREATE_CHARACTER_ARENA_LEADER;
            SendPacket(&data);
            return;
        }

        // check mailbox
        if (playerData->mailCount)
        {
            WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
            data << (uint8)CHAR_CREATE_CHARACTER_DELETE_MAIL;
            SendPacket(&data);
            return;
        }

        // check auctions, current packet is processed single-threaded way, so not a problem
        bool has_auctions = false;
        for (uint8 i = 0; i < 2; ++i) // check both neutral and faction-specific AH
        {
            AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(i == 0 ? 0 : (((1 << (playerData->race - 1))&RACEMASK_ALLIANCE) ? 12 : 29));
            AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();
            AuctionHouseObject::AuctionEntryMap::const_iterator _end = auctionHouse->GetAuctionsEnd();
            for (; itr != _end; ++itr)
            {
                AuctionEntry* Aentry = itr->second;
                if (Aentry && (Aentry->owner == guid || Aentry->bidder == guid))
                {
                    has_auctions = true;
                    break;
                }
            }
            if (has_auctions)
                break;
        }
        if (has_auctions)
        {
            WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
            data << (uint8)CHAR_CREATE_ERROR;
            SendPacket(&data);
            return;
        }
    }

Upvotes: 2

Related Questions