summaryrefslogtreecommitdiffstats
path: root/src/BlockID.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:45:45 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:50:18 +0100
commitca6ef58b1ee8521e4b940ee4883dee714960e413 (patch)
tree8532add455224b07c07a759e3d906f50c0695888 /src/BlockID.cpp
parentMerge pull request #2972 from marvinkopf/PlayerAutoComplete (diff)
downloadcuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.gz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.bz2
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.lz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.xz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.zst
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.zip
Diffstat (limited to 'src/BlockID.cpp')
-rw-r--r--src/BlockID.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index b60ac0b4a..357f6a5a4 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -22,9 +22,9 @@ class cBlockIDMap
return (NoCaseCompare(a_Item1, a_Item2) > 0);
}
} ;
-
+
typedef std::map<AString, std::pair<short, short>, Comparator> ItemMap;
-
+
public:
static bool m_bHasRunInit;
@@ -60,8 +60,8 @@ public:
AddToMap(Name, Value);
} // for i - Ini.Values[]
}
-
-
+
+
int Resolve(const AString & a_ItemName)
{
ItemMap::iterator itr = m_Map.find(a_ItemName);
@@ -71,8 +71,8 @@ public:
}
return itr->second.first;
}
-
-
+
+
bool ResolveItem(const AString & a_ItemName, cItem & a_Item)
{
// Split into parts divided by either ':' or '^'
@@ -102,7 +102,7 @@ public:
return false;
}
}
-
+
// Parse the damage, if present:
if (Split.size() < 2)
{
@@ -119,8 +119,8 @@ public:
a_Item.m_ItemCount = 1;
return true;
}
-
-
+
+
AString Desolve(short a_ItemType, short a_ItemDamage)
{
// First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"):
@@ -131,7 +131,7 @@ public:
return itr->first;
}
} // for itr - m_Map[]
-
+
// There is no exact match, try matching ItemType only ("planks=5"):
if (a_ItemDamage == 0)
{
@@ -156,12 +156,12 @@ public:
}
return res;
}
-
-
+
+
protected:
ItemMap m_Map;
-
-
+
+
void AddToMap(const AString & a_Name, const AString & a_Value)
{
AStringVector Split = StringSplit(a_Value, ":");
@@ -224,7 +224,7 @@ int BlockStringToType(const AString & a_BlockTypeString)
// It was a valid number, return that
return res;
}
-
+
if (!gsBlockIDMap.m_bHasRunInit)
{
gsBlockIDMap.init();
@@ -300,7 +300,7 @@ eDimension StringToDimension(const AString & a_DimensionString)
// It was a valid number
return static_cast<eDimension>(res);
}
-
+
// Decode using a built-in map:
static struct
{
@@ -323,7 +323,7 @@ eDimension StringToDimension(const AString & a_DimensionString)
return DimensionMap[i].m_Dimension;
}
} // for i - DimensionMap[]
-
+
// Not found
LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", a_DimensionString.c_str());
return dimOverworld;
@@ -389,7 +389,7 @@ AString DamageTypeToString(eDamageType a_DamageType)
case dtSuffocating: return "dtSuffocation";
case dtExplosion: return "dtExplosion";
}
-
+
// Unknown damage type:
ASSERT(!"Unknown DamageType");
return Printf("dtUnknown_%d", static_cast<int>(a_DamageType));
@@ -410,7 +410,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
// It was a valid number
return static_cast<eDamageType>(res);
}
-
+
// Decode using a built-in map:
static struct
{
@@ -467,7 +467,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
return DamageTypeMap[i].m_DamageType;
}
} // for i - DamageTypeMap[]
-
+
// Not found:
return static_cast<eDamageType>(-1);
}