Added the new recipe parser, parsing the crafting.txt file. Included are a few recipes. The old parser still works, but will be replaced soon.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@549 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "Globals.h"
|
||||
#include "BlockID.h"
|
||||
#include "../iniFile/iniFile.h"
|
||||
#include "cItem.h"
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +36,11 @@ public:
|
||||
return m_Ini.GetValueI("Items", a_ItemName, -1);
|
||||
}
|
||||
|
||||
AString ResolveString(AString & a_ItemName)
|
||||
{
|
||||
return m_Ini.GetValue("Items", a_ItemName, "");
|
||||
}
|
||||
|
||||
protected:
|
||||
cIniFile m_Ini;
|
||||
} ;
|
||||
@@ -58,12 +64,47 @@ int BlockStringToType(const AString & a_BlockTypeString)
|
||||
return res;
|
||||
}
|
||||
|
||||
return gsBlockIDMap.Resolve(a_BlockTypeString);
|
||||
return gsBlockIDMap.Resolve(TrimString(a_BlockTypeString));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item)
|
||||
{
|
||||
AString Resolved = TrimString(gsBlockIDMap.ResolveString(TrimString(a_ItemTypeString)));
|
||||
AString txt = (!Resolved.empty()) ? Resolved : a_ItemTypeString;
|
||||
AStringVector Split = StringSplit(txt, ":");
|
||||
if (Split.size() == 1)
|
||||
{
|
||||
Split = StringSplit(txt, "^");
|
||||
}
|
||||
if (Split.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
a_Item.m_ItemID = (ENUM_ITEM_ID)atoi(Split[0].c_str());
|
||||
if ((a_Item.m_ItemID == 0) && (Split[0] != "0"))
|
||||
{
|
||||
// Parsing the number failed
|
||||
return false;
|
||||
}
|
||||
if (Split.size() > 1)
|
||||
{
|
||||
a_Item.m_ItemHealth = atoi(Split[1].c_str());
|
||||
if ((a_Item.m_ItemHealth == 0) && (Split[1] != "0"))
|
||||
{
|
||||
// Parsing the number failed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EMCSBiome StringToBiome(const AString & a_BiomeString)
|
||||
{
|
||||
// If it is a number, return it:
|
||||
|
||||
Reference in New Issue
Block a user