Skip to content

Commit

Permalink
added missing check to randomize mount (#4171)
Browse files Browse the repository at this point in the history
  • Loading branch information
reyaleman committed Jun 23, 2022
1 parent ac78f45 commit 397a090
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3514,7 +3514,7 @@ void Game::playerChangeOutfit(uint32_t playerId, Outfit_t outfit, bool randomize
return;
}

if (player->randomizeMount) {
if (player->randomizeMount && player->hasMounts()) {
const Mount* mount = mounts.getMountByID(player->getRandomMount());
outfit.lookMount = mount->clientId;
}
Expand Down
10 changes: 10 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4508,6 +4508,16 @@ bool Player::hasMount(const Mount* mount) const
return ((1 << (tmpMountId % 31)) & value) != 0;
}

bool Player::hasMounts() const
{
for (const Mount& mount : g_game.mounts.getMounts()) {
if (hasMount(&mount)) {
return true;
}
}
return false;
}

void Player::dismount()
{
Mount* mount = g_game.mounts.getMountByID(getCurrentMount());
Expand Down
1 change: 1 addition & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class Player final : public Creature, public Cylinder
bool tameMount(uint8_t mountId);
bool untameMount(uint8_t mountId);
bool hasMount(const Mount* mount) const;
bool hasMounts() const;
void dismount();

void sendFYIBox(const std::string& message)
Expand Down

0 comments on commit 397a090

Please sign in to comment.