Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

randomize mount fix #4171

Merged
merged 1 commit into from
Jun 23, 2022
Merged
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
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