]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/player.cpp
Pass ContentFeatures as reference to read_content_features (#10464)
[dragonfireclient.git] / src / player.cpp
index ccc753834c4ce92bc885151f922d32684e8a86c5..d3ba5c2c20e9944e531f14506e289d81fd0f7dde 100644 (file)
@@ -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)