diff options
author | Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> | 2011-06-27 06:56:26 -0700 |
---|---|---|
committer | Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> | 2011-06-27 06:56:26 -0700 |
commit | 1c90f9fc2eba43be71f9d49dad75c5d0514d4e50 (patch) | |
tree | 63c1116ff43936475874b54d171c7e08556d54ee /src/materials.cpp | |
parent | 158b054e72582005d895f1ed0e1cb0c9b22a8e57 (diff) | |
parent | 7efe89ff584b2c0338dcede4c1e08504d0158780 (diff) | |
download | minetest-1c90f9fc2eba43be71f9d49dad75c5d0514d4e50.tar.gz minetest-1c90f9fc2eba43be71f9d49dad75c5d0514d4e50.tar.bz2 minetest-1c90f9fc2eba43be71f9d49dad75c5d0514d4e50.zip |
Merge pull request #13 from Bahamada/upstream_merge
Upstream merge
Diffstat (limited to 'src/materials.cpp')
-rw-r--r-- | src/materials.cpp | 113 |
1 files changed, 7 insertions, 106 deletions
diff --git a/src/materials.cpp b/src/materials.cpp index a8a9a94a8..e3a24b9e3 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -1,119 +1,20 @@ #include "materials.h" +#include "mapnode.h" -#define MATERIAL_PROPERTIES_COUNT 256 +// NOTE: DEPRECATED -// These correspond to the CONTENT_* constants -MaterialProperties g_material_properties[MATERIAL_PROPERTIES_COUNT]; - -bool g_material_properties_initialized = false; - -void setStoneLikeDiggingProperties(u8 material, float toughness) -{ - g_material_properties[material].setDiggingProperties("", - DiggingProperties(true, 15.0*toughness, 0)); - - g_material_properties[material].setDiggingProperties("WPick", - DiggingProperties(true, 1.3*toughness, 65535./30.*toughness)); - g_material_properties[material].setDiggingProperties("STPick", - DiggingProperties(true, 0.75*toughness, 65535./100.*toughness)); - g_material_properties[material].setDiggingProperties("SteelPick", - DiggingProperties(true, 0.50*toughness, 65535./333.*toughness)); - - /*g_material_properties[material].setDiggingProperties("MesePick", - DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/ -} - -void setDirtLikeDiggingProperties(u8 material, float toughness) -{ - g_material_properties[material].setDiggingProperties("", - DiggingProperties(true, 0.75*toughness, 0)); - - g_material_properties[material].setDiggingProperties("WShovel", - DiggingProperties(true, 0.4*toughness, 65535./50.*toughness)); - g_material_properties[material].setDiggingProperties("STShovel", - DiggingProperties(true, 0.2*toughness, 65535./150.*toughness)); - g_material_properties[material].setDiggingProperties("SteelShovel", - DiggingProperties(true, 0.15*toughness, 65535./400.*toughness)); -} - -void setWoodLikeDiggingProperties(u8 material, float toughness) -{ - g_material_properties[material].setDiggingProperties("", - DiggingProperties(true, 3.0*toughness, 0)); - - g_material_properties[material].setDiggingProperties("WAxe", - DiggingProperties(true, 1.5*toughness, 65535./30.*toughness)); - g_material_properties[material].setDiggingProperties("STAxe", - DiggingProperties(true, 0.75*toughness, 65535./100.*toughness)); - g_material_properties[material].setDiggingProperties("SteelAxe", - DiggingProperties(true, 0.5*toughness, 65535./333.*toughness)); -} - -void initializeMaterialProperties() -{ - /* - Now, the g_material_properties array is already initialized - by the constructors to such that no digging is possible. - - Add some digging properties to them. - */ - - setStoneLikeDiggingProperties(CONTENT_STONE, 1.0); - setStoneLikeDiggingProperties(CONTENT_SANDSTONE, 1.0); - setStoneLikeDiggingProperties(CONTENT_BRICK, 3.0); - setStoneLikeDiggingProperties(CONTENT_MESE, 0.5); - setStoneLikeDiggingProperties(CONTENT_COALSTONE, 1.5); - setStoneLikeDiggingProperties(CONTENT_FURNACE, 3.0); - setStoneLikeDiggingProperties(CONTENT_COBBLE, 1.0); - setStoneLikeDiggingProperties(CONTENT_STEEL, 5.0); - - setDirtLikeDiggingProperties(CONTENT_MUD, 1.0); - setDirtLikeDiggingProperties(CONTENT_GRASS, 1.0); - setDirtLikeDiggingProperties(CONTENT_GRASS_FOOTSTEPS, 1.0); - setDirtLikeDiggingProperties(CONTENT_SAND, 1.0); - setDirtLikeDiggingProperties(CONTENT_CLAY, 1.0); - - setWoodLikeDiggingProperties(CONTENT_TREE, 1.0); - setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15); - setWoodLikeDiggingProperties(CONTENT_CACTUS, 0.75); - setWoodLikeDiggingProperties(CONTENT_PAPYRUS, 0.25); - setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15); - setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75); - setDirtLikeDiggingProperties(CONTENT_RAIL, 0.75); - setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75); - setWoodLikeDiggingProperties(CONTENT_BOOKSHELF, 0.75); - setWoodLikeDiggingProperties(CONTENT_CHEST, 1.0); - - g_material_properties[CONTENT_SIGN_WALL].setDiggingProperties("", - DiggingProperties(true, 0.5, 0)); - g_material_properties[CONTENT_TORCH].setDiggingProperties("", - DiggingProperties(true, 0.0, 0)); - - /* - Add MesePick to everything - */ - for(u16 i=0; i<MATERIAL_PROPERTIES_COUNT; i++) - { - g_material_properties[i].setDiggingProperties("MesePick", - DiggingProperties(true, 0.0, 65535./1337)); - } - - g_material_properties_initialized = true; -} - -MaterialProperties * getMaterialProperties(u8 material) +DiggingPropertiesList * getDiggingPropertiesList(u8 content) { - assert(g_material_properties_initialized); - return &g_material_properties[material]; + return &content_features(content).digging_properties; } -DiggingProperties getDiggingProperties(u8 material, const std::string &tool) +DiggingProperties getDiggingProperties(u8 content, const std::string &tool) { - MaterialProperties *mprop = getMaterialProperties(material); + DiggingPropertiesList *mprop = getDiggingPropertiesList(content); if(mprop == NULL) // Not diggable return DiggingProperties(); - return mprop->getDiggingProperties(tool); + return mprop->get(tool); } |