From 92c7d48af03a63eeeb4813fd5d10c9aff8841f0a Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 8 Sep 2012 21:49:27 +0000 Subject: ItemToString() now recognizes matches that are in the ini without metadata. "323:0" -> "sign", although ini says "sign=323" only. git-svn-id: http://mc-server.googlecode.com/svn/trunk@856 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/BlockID.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source') diff --git a/source/BlockID.cpp b/source/BlockID.cpp index 654a55e63..3652938c2 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -124,6 +124,7 @@ public: AString Desolve(short a_ItemType, short a_ItemDamage) { + // First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"): for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) { if ((itr->second.first == a_ItemType) && (itr->second.second == a_ItemDamage)) @@ -131,6 +132,20 @@ public: return itr->first; } } // for itr - m_Map[] + + // There is no exact match, try matching ItemType only ("planks=5"): + if (a_ItemDamage == 0) + { + for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) + { + if ((itr->second.first == a_ItemType) && (itr->second.second == -1)) + { + return itr->first; + } + } // for itr - m_Map[] + } + + // No match at all, synthesize a string ("5:1"): AString res; if (a_ItemDamage == -1) { -- cgit v1.2.3