summaryrefslogtreecommitdiff
path: root/src/craftdef.cpp
Commit message (Expand)AuthorAge
* Overall improvements to log messages (#9598)sfan52020-04-08
* Fix some issues with minetest.clear_craft (#8712)Paul Ouellette2019-08-10
* Prefix RecipePriority elements with PRIORITY_Paul Ouellette2019-07-27
* Initialize priority in CraftDefinition constructorsPaul Ouellette2019-07-27
* Prioritise craft recipesHybridDog2019-05-20
* Test crafting hash type only once for a recipeHybridDog2019-05-20
* Use unordered_map instead of map for craft definitions (#8432)HybridDog2019-03-31
* Speed up the craft definition handling (#8097)Jozef Behran2019-01-13
* Add disable_repair group to prevent tool repair (#7381)Wuzzy2018-10-16
* Don't try to craft a non-existent itemEsteban I. RM2017-10-16
* Modernize code: very last fixes (#6290)Loïc Blot2017-08-20
* Modernize src/c* src/d* and src/e* files (#6263)Loïc Blot2017-08-17
* Add ItemStack key-value meta storagerubenwardy2017-02-04
* Adding minetest.clear_craftFoghrye42016-07-05
* Clean up StrfndShadowNinja2016-03-19
* Allow craft replacements to use groupsTeTpaAka2015-11-15
* Change i++ to ++iDavid Jones2015-08-25
* Fix endless loop since grandparent commitest312015-07-04
* Craftdef: Use numbers instead of iteratorsest312015-07-04
* Fix missing check for 0 in craft replacementsTeTpaAka2015-07-04
* Fix bug when craft input isn't replacedTeTpaAka2015-06-22
* Fix release build warningest312015-05-08
* Remove craftdef serialisationest312015-04-26
* Craftdef refactorest312015-04-26
* craftdef.cpp: Return 0 after assert to make Clang happyLoic Blot2015-04-05
* Crafting speedupest312015-04-05
* Optimize minetest.get_(all)_craft_recipe(s)gregorycu2015-03-20
* Craftdef.cpp: Improve loop and mathematics for CraftDefinitionShaped::checkLoic Blot2015-02-10
* Fix getCraftRecipe returing wrong reciep due to way to unspecific output matc...sapier2015-02-02
* Fix aliases not working in shapeless crafting recipesKahrl2013-08-25
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Added method to get all registered recipes for item(node)RealBadAngel2013-03-05
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Working group-shapeless and multigroup recipesPerttu Ahola2012-07-26
* Add minetest.get_craft_recipe()darkrose2012-07-21
* Properly and efficiently use split utility headersPerttu Ahola2012-06-17
* Allow groups in crafting recipesPerttu Ahola2012-06-06
* Allow replacements in cooking and fuel recipesKahrl2012-06-06
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* Clean up log messages everywherePerttu Ahola2012-03-11
* The huge item definition and item namespace unification patch (itemdef), see ...Kahrl2012-01-12
* Add InvRef and InvStack (currently untested and unusable)Perttu Ahola2012-01-02
* Catch SerializationError in CCraftDefManager::getCraftResult()Perttu Ahola2011-11-29
* Crafting definition in scriptsPerttu Ahola2011-11-29
span class="hl num">2 * BS; movement_acceleration_fast = 10 * BS; movement_speed_walk = 4 * BS; movement_speed_crouch = 1.35 * BS; movement_speed_fast = 20 * BS; movement_speed_climb = 2 * BS; movement_speed_jump = 6.5 * BS; movement_liquid_fluidity = 1 * BS; movement_liquid_fluidity_smooth = 0.5 * BS; movement_liquid_sink = 10 * BS; movement_gravity = 9.81 * BS; local_animation_speed = 0.0; hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE | HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE | HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE | HUD_FLAG_MINIMAP_RADAR_VISIBLE | HUD_FLAG_BASIC_DEBUG; hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT; m_player_settings.readGlobalSettings(); // Register player setting callbacks for (const std::string &name : m_player_settings.setting_names) g_settings->registerChangedCallback(name, &Player::settingsChangedCallback, &m_player_settings); } Player::~Player() { // m_player_settings becomes invalid, remove callbacks for (const std::string &name : m_player_settings.setting_names) g_settings->deregisterChangedCallback(name, &Player::settingsChangedCallback, &m_player_settings); 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); u32 id = getFreeHudID(); if (id < hud.size()) hud[id] = toadd; else hud.push_back(toadd); return id; } HudElement* Player::getHud(u32 id) { MutexAutoLock lock(m_mutex); if (id < hud.size()) return hud[id]; return NULL; } HudElement* Player::removeHud(u32 id) { MutexAutoLock lock(m_mutex); HudElement* retval = NULL; if (id < hud.size()) { retval = hud[id]; hud[id] = NULL; } return retval; } void Player::clearHud() { MutexAutoLock lock(m_mutex); while(!hud.empty()) { delete hud.back(); hud.pop_back(); } } #ifndef SERVER u32 PlayerControl::getKeysPressed() const { u32 keypress_bits = ( (u32)(jump & 1) << 4) | ( (u32)(aux1 & 1) << 5) | ( (u32)(sneak & 1) << 6) | ( (u32)(dig & 1) << 7) | ( (u32)(place & 1) << 8) | ( (u32)(zoom & 1) << 9) ; // If any direction keys are pressed pass those through if (direction_keys != 0) { keypress_bits |= direction_keys; } // Otherwise set direction keys based on joystick movement (for mod compatibility) else if (isMoving()) { float abs_d; // (absolute value indicates forward / backward) abs_d = abs(movement_direction); if (abs_d < 3.0f / 8.0f * M_PI) keypress_bits |= (u32)1; // Forward if (abs_d > 5.0f / 8.0f * M_PI) keypress_bits |= (u32)1 << 1; // Backward // rotate entire coordinate system by 90 degree abs_d = movement_direction + M_PI_2; if (abs_d >= M_PI) abs_d -= 2 * M_PI; abs_d = abs(abs_d); // (value now indicates left / right) if (abs_d < 3.0f / 8.0f * M_PI) keypress_bits |= (u32)1 << 2; // Left if (abs_d > 5.0f / 8.0f * M_PI) keypress_bits |= (u32)1 << 3; // Right } return keypress_bits; } #endif void PlayerControl::unpackKeysPressed(u32 keypress_bits) { direction_keys = keypress_bits & 0xf; jump = keypress_bits & (1 << 4); aux1 = keypress_bits & (1 << 5); sneak = keypress_bits & (1 << 6); dig = keypress_bits & (1 << 7); place = keypress_bits & (1 << 8); zoom = keypress_bits & (1 << 9); } 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) { ((PlayerSettings *)data)->readGlobalSettings(); }