X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fplayer.cpp;h=d3ba5c2c20e9944e531f14506e289d81fd0f7dde;hb=11f3deb9c4512b918de8f5e778bc8b9535bd62c7;hp=ccc753834c4ce92bc885151f922d32684e8a86c5;hpb=d77f3b3fdeb0da2a69547594b5a75570a54b02d1;p=dragonfireclient.git diff --git a/src/player.cpp b/src/player.cpp index ccc753834..d3ba5c2c2 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -90,6 +90,29 @@ Player::~Player() clearHud(); } +void Player::setWieldIndex(u16 index) +{ + const InventoryList *mlist = inventory.getList("main"); + m_wield_index = MYMIN(index, mlist ? mlist->getSize() : 0); +} + +ItemStack &Player::getWieldedItem(ItemStack *selected, ItemStack *hand) const +{ + assert(selected); + + const InventoryList *mlist = inventory.getList("main"); // TODO: Make this generic + const InventoryList *hlist = inventory.getList("hand"); + + if (mlist && m_wield_index < mlist->getSize()) + *selected = mlist->getItem(m_wield_index); + + if (hand && hlist) + *hand = hlist->getItem(0); + + // Return effective tool item + return (hand && selected->name.empty()) ? *hand : *selected; +} + u32 Player::addHud(HudElement *toadd) { MutexAutoLock lock(m_mutex); @@ -139,11 +162,13 @@ void Player::clearHud() void PlayerSettings::readGlobalSettings() { free_move = g_settings->getBool("free_move"); + pitch_move = g_settings->getBool("pitch_move"); fast_move = g_settings->getBool("fast_move"); continuous_forward = g_settings->getBool("continuous_forward"); always_fly_fast = g_settings->getBool("always_fly_fast"); aux1_descends = g_settings->getBool("aux1_descends"); noclip = g_settings->getBool("noclip"); + autojump = g_settings->getBool("autojump"); } void Player::settingsChangedCallback(const std::string &name, void *data)