From f4b6ed653b717292c7e1f33d2ea861f606b56c47 Mon Sep 17 00:00:00 2001 From: darkrose Date: Fri, 9 Oct 2015 01:17:10 +1000 Subject: [PATCH] when digging out-of-level minerals, dig slower to warn the player --- src/content_toolitem.cpp | 5 +++-- src/content_toolitem.h | 2 +- src/game.cpp | 3 ++- src/server.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/content_toolitem.cpp b/src/content_toolitem.cpp index b930053..8a36acd 100644 --- a/src/content_toolitem.cpp +++ b/src/content_toolitem.cpp @@ -23,6 +23,7 @@ #include "content_craft.h" #include "content_list.h" #include "content_mapnode.h" +#include "mineral.h" #include #include "intl.h" #include "enchantment.h" @@ -49,7 +50,7 @@ ToolItemFeatures & content_toolitem_features(std::string subname) return g_content_toolitem_features[CONTENT_IGNORE]; } -DiggingProperties getDiggingProperties(content_t content, content_t tool, u16 data) +DiggingProperties getDiggingProperties(content_t content, u8 mineral, content_t tool, u16 data) { ToolItemFeatures t_features = content_toolitem_features(tool); ContentFeatures &c_features = content_features(content); @@ -81,7 +82,7 @@ DiggingProperties getDiggingProperties(content_t content, content_t tool, u16 da } break; case TT_PICK: - if (c_features.type != CMT_STONE) { + if (c_features.type != CMT_STONE || t_features.level < mineral_features(mineral).min_level) { time *= 2.; }else{ type_match = true; diff --git a/src/content_toolitem.h b/src/content_toolitem.h index d4adf6b..b2538ea 100644 --- a/src/content_toolitem.h +++ b/src/content_toolitem.h @@ -109,7 +109,7 @@ struct DiggingProperties }; // For getting the default properties, set toolid=CONTENT_IGNORE -DiggingProperties getDiggingProperties(content_t material, content_t toolid, u16 data=0); +DiggingProperties getDiggingProperties(content_t material, u8 mineral, content_t toolid, u16 data=0); std::string toolitem_overlay(content_t content, std::string ol); void content_toolitem_init(); ToolItemFeatures & content_toolitem_features(content_t i); diff --git a/src/game.cpp b/src/game.cpp index 237f9c8..1cc6194 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1740,7 +1740,8 @@ void the_game( // Get digging properties for material and tool content_t material = n.getContent(); - DiggingProperties prop = getDiggingProperties(material, toolid, tooldata); + u8 mineral = n.getMineral(); + DiggingProperties prop = getDiggingProperties(material, mineral, toolid, tooldata); float dig_time_complete = 0.0; diff --git a/src/server.cpp b/src/server.cpp index 7a5a8b0..df05388 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3296,7 +3296,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if (item && (std::string)item->getName() == "ToolItem") { ToolItem *titem = (ToolItem*)item; // Get digging properties for material and tool - DiggingProperties prop = getDiggingProperties(selected_content, titem->getContent(),titem->getData()); + DiggingProperties prop = getDiggingProperties(selected_content, mineral, titem->getContent(),titem->getData()); if (prop.diggable == false) { infostream<<"Server: WARNING: Player digged"