From: Perttu Ahola Date: Sun, 4 Mar 2012 12:22:35 +0000 (+0200) Subject: itemgroup.h and ItemGroupList typedef X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=07ed57476f56c54e781ab33467d3373d976d24b1;p=zefram%2Fminetest%2Fminetest_engine.git itemgroup.h and ItemGroupList typedef --- diff --git a/src/content_sao.cpp b/src/content_sao.cpp index cb4d81f9..b7a6db90 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -724,7 +724,7 @@ void Oerkki1SAO::punch(ServerActiveObject *puncher, float time_from_last_punch) m_speed_f += dir*12*BS; // "Material" groups of the object - std::map groups; + ItemGroupList groups; groups["snappy"] = 1; groups["choppy"] = 1; groups["fleshy"] = 3; @@ -1419,7 +1419,7 @@ void MobV2SAO::punch(ServerActiveObject *puncher, float time_from_last_punch) // "Material" groups of the object - std::map groups; + ItemGroupList groups; groups["snappy"] = 1; groups["choppy"] = 1; groups["fleshy"] = 3; diff --git a/src/itemdef.h b/src/itemdef.h index 15734ff4..904b4a22 100644 --- a/src/itemdef.h +++ b/src/itemdef.h @@ -25,23 +25,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include -#include +#include "itemgroup.h" class IGameDef; struct ToolCapabilities; -/* - Some helpers -*/ - -static inline int itemgroup_get(const std::map &groups, - const std::string &name) -{ - std::map::const_iterator i = groups.find(name); - if(i == groups.end()) - return 0; - return i->second; -} - /* Base item definition */ @@ -78,7 +65,7 @@ struct ItemDefinition bool liquids_pointable; // May be NULL. If non-NULL, deleted by destructor ToolCapabilities *tool_capabilities; - std::map groups; + ItemGroupList groups; /* Cached stuff diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 7d0408eb..cc8009ab 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -154,7 +154,7 @@ void ContentFeatures::serialize(std::ostream &os) writeU8(os, 2); // version os<::const_iterator + for(ItemGroupList::const_iterator i = groups.begin(); i != groups.end(); i++){ os<first); writeS16(os, i->second); diff --git a/src/nodedef.h b/src/nodedef.h index 5196e023..c875e0b7 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef SERVER #include "tile.h" #endif +#include "itemgroup.h" class IItemDefManager; class ITextureSource; class IGameDef; @@ -148,7 +149,7 @@ struct ContentFeatures */ std::string name; // "" = undefined node - std::map groups; // Same as in itemdef + ItemGroupList groups; // Same as in itemdef // Visual definition enum NodeDrawType drawtype; diff --git a/src/serverremoteplayer.cpp b/src/serverremoteplayer.cpp index 9dd4723f..c57794ea 100644 --- a/src/serverremoteplayer.cpp +++ b/src/serverremoteplayer.cpp @@ -182,7 +182,7 @@ void ServerRemotePlayer::punch(ServerActiveObject *puncher, } // "Material" groups of the player - std::map groups; + ItemGroupList groups; groups["choppy"] = 2; groups["fleshy"] = 3; diff --git a/src/tool.cpp b/src/tool.cpp index 69141f4e..38994c62 100644 --- a/src/tool.cpp +++ b/src/tool.cpp @@ -68,7 +68,7 @@ void ToolCapabilities::deSerialize(std::istream &is) } } -DigParams getDigParams(const std::map &groups, +DigParams getDigParams(const ItemGroupList &groups, const ToolCapabilities *tp, float time_from_last_punch) { //infostream<<"getDigParams"< &groups, return DigParams(result_diggable, result_time, wear_i); } -DigParams getDigParams(const std::map &groups, +DigParams getDigParams(const ItemGroupList &groups, const ToolCapabilities *tp) { return getDigParams(groups, tp, 1000000); } -HitParams getHitParams(const std::map &groups, +HitParams getHitParams(const ItemGroupList &groups, const ToolCapabilities *tp, float time_from_last_punch) { DigParams digprop = getDigParams(groups, tp, @@ -145,7 +145,7 @@ HitParams getHitParams(const std::map &groups, return HitParams(hp, wear); } -HitParams getHitParams(const std::map &groups, +HitParams getHitParams(const ItemGroupList &groups, const ToolCapabilities *tp) { return getHitParams(groups, tp, 1000000); diff --git a/src/tool.h b/src/tool.h index cc2401a0..d2a9c13c 100644 --- a/src/tool.h +++ b/src/tool.h @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include "itemgroup.h" struct ToolGroupCap { @@ -84,10 +85,10 @@ struct DigParams {} }; -DigParams getDigParams(const std::map &groups, +DigParams getDigParams(const ItemGroupList &groups, const ToolCapabilities *tp, float time_from_last_punch); -DigParams getDigParams(const std::map &groups, +DigParams getDigParams(const ItemGroupList &groups, const ToolCapabilities *tp); struct HitParams @@ -101,10 +102,10 @@ struct HitParams {} }; -HitParams getHitParams(const std::map &groups, +HitParams getHitParams(const ItemGroupList &groups, const ToolCapabilities *tp, float time_from_last_punch); -HitParams getHitParams(const std::map &groups, +HitParams getHitParams(const ItemGroupList &groups, const ToolCapabilities *tp); #endif