when digging out-of-level minerals, dig slower to warn the player

This commit is contained in:
darkrose 2015-10-09 01:17:10 +10:00
parent 7980c37aa8
commit f4b6ed653b
4 changed files with 7 additions and 5 deletions

View File

@ -23,6 +23,7 @@
#include "content_craft.h"
#include "content_list.h"
#include "content_mapnode.h"
#include "mineral.h"
#include <map>
#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;

View File

@ -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);

View File

@ -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;

View File

@ -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"