2012-06-14 09:06:06 -04:00
|
|
|
// BlockID.cpp
|
|
|
|
|
|
|
|
// Implements the helper functions for converting Block ID string to int etc.
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "BlockID.h"
|
2014-10-23 09:15:10 -04:00
|
|
|
#include "IniFile.h"
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Item.h"
|
2013-08-16 04:48:19 -04:00
|
|
|
#include "Mobs/Monster.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockIDMap
|
|
|
|
{
|
2012-09-08 12:38:27 -04:00
|
|
|
// Making the map case-insensitive:
|
|
|
|
struct Comparator
|
|
|
|
{
|
2014-08-03 05:57:05 -04:00
|
|
|
bool operator ()(const AString & a_Item1, const AString & a_Item2) const
|
2012-09-08 12:38:27 -04:00
|
|
|
{
|
|
|
|
return (NoCaseCompare(a_Item1, a_Item2) > 0);
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
typedef std::map<AString, std::pair<short, short>, Comparator> ItemMap;
|
2012-09-08 12:08:29 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
public:
|
2015-03-31 09:50:03 -04:00
|
|
|
static bool m_bHasRunInit;
|
|
|
|
|
2012-09-08 12:08:29 -04:00
|
|
|
cBlockIDMap(void)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2015-03-31 09:50:03 -04:00
|
|
|
// Dont load items.ini on construct, this will search the wrong path when running as a service.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
m_bHasRunInit = true;
|
|
|
|
|
2013-10-25 05:15:44 -04:00
|
|
|
cIniFile Ini;
|
|
|
|
if (!Ini.ReadFile("items.ini"))
|
2012-09-08 12:08:29 -04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-10-25 05:38:14 -04:00
|
|
|
int KeyID = Ini.FindKey("Items");
|
2012-09-08 12:08:29 -04:00
|
|
|
if (KeyID == cIniFile::noID)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-10-25 05:38:14 -04:00
|
|
|
int NumValues = Ini.GetNumValues(KeyID);
|
|
|
|
for (int i = 0; i < NumValues; i++)
|
2012-09-08 12:08:29 -04:00
|
|
|
{
|
2013-10-25 05:38:14 -04:00
|
|
|
AString Name = Ini.GetValueName(KeyID, i);
|
2012-09-08 12:08:29 -04:00
|
|
|
if (Name.empty())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
AString Value = Ini.GetValue(KeyID, i);
|
|
|
|
AddToMap(Name, Value);
|
|
|
|
} // for i - Ini.Values[]
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
2012-09-08 12:08:29 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
int Resolve(const AString & a_ItemName)
|
|
|
|
{
|
2012-09-08 12:08:29 -04:00
|
|
|
ItemMap::iterator itr = m_Map.find(a_ItemName);
|
|
|
|
if (itr == m_Map.end())
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return itr->second.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ResolveItem(const AString & a_ItemName, cItem & a_Item)
|
|
|
|
{
|
2013-10-18 12:13:20 -04:00
|
|
|
// Split into parts divided by either ':' or '^'
|
|
|
|
AStringVector Split = StringSplitAndTrim(a_ItemName, ":^");
|
|
|
|
if (Split.empty())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemMap::iterator itr = m_Map.find(Split[0]);
|
2012-09-08 12:08:29 -04:00
|
|
|
if (itr != m_Map.end())
|
|
|
|
{
|
2013-10-18 12:13:20 -04:00
|
|
|
// Resolved as a string, assign the type and the default damage / count
|
2012-09-08 12:08:29 -04:00
|
|
|
a_Item.m_ItemType = itr->second.first;
|
|
|
|
a_Item.m_ItemDamage = itr->second.second;
|
2012-09-08 17:20:36 -04:00
|
|
|
if (a_Item.m_ItemDamage == -1)
|
|
|
|
{
|
|
|
|
a_Item.m_ItemDamage = 0;
|
|
|
|
}
|
2012-09-08 12:08:29 -04:00
|
|
|
}
|
2013-10-18 12:13:20 -04:00
|
|
|
else
|
2012-09-08 12:08:29 -04:00
|
|
|
{
|
2013-10-18 12:13:20 -04:00
|
|
|
// Not a resolvable string, try pure numbers: "45:6", "45^6" etc.
|
|
|
|
a_Item.m_ItemType = (short)atoi(Split[0].c_str());
|
|
|
|
if ((a_Item.m_ItemType == 0) && (Split[0] != "0"))
|
|
|
|
{
|
|
|
|
// Parsing the number failed
|
|
|
|
return false;
|
|
|
|
}
|
2012-09-08 12:08:29 -04:00
|
|
|
}
|
2013-10-18 12:13:20 -04:00
|
|
|
|
|
|
|
// Parse the damage, if present:
|
2012-09-08 12:08:29 -04:00
|
|
|
if (Split.size() < 2)
|
|
|
|
{
|
2013-10-18 12:13:20 -04:00
|
|
|
// Not present, set the item as valid and return success:
|
2012-09-08 17:33:53 -04:00
|
|
|
a_Item.m_ItemCount = 1;
|
2012-09-08 12:08:29 -04:00
|
|
|
return true;
|
|
|
|
}
|
2013-10-18 12:13:20 -04:00
|
|
|
|
2014-05-01 16:47:02 -04:00
|
|
|
a_Item.m_ItemDamage = (short)atoi(Split[1].c_str());
|
2012-09-08 12:08:29 -04:00
|
|
|
if ((a_Item.m_ItemDamage == 0) && (Split[1] != "0"))
|
|
|
|
{
|
|
|
|
// Parsing the number failed
|
|
|
|
return false;
|
|
|
|
}
|
2012-09-08 17:33:53 -04:00
|
|
|
a_Item.m_ItemCount = 1;
|
2012-09-08 12:08:29 -04:00
|
|
|
return true;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
2012-09-08 12:08:29 -04:00
|
|
|
|
|
|
|
AString Desolve(short a_ItemType, short a_ItemDamage)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2012-09-08 17:49:27 -04:00
|
|
|
// First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"):
|
2012-09-08 12:08:29 -04:00
|
|
|
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))
|
|
|
|
{
|
|
|
|
return itr->first;
|
|
|
|
}
|
|
|
|
} // for itr - m_Map[]
|
2012-09-08 17:49:27 -04:00
|
|
|
|
|
|
|
// 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"):
|
2012-09-08 12:08:29 -04:00
|
|
|
AString res;
|
|
|
|
if (a_ItemDamage == -1)
|
|
|
|
{
|
|
|
|
Printf(res, "%d", a_ItemType);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Printf(res, "%d:%d", a_ItemType, a_ItemDamage);
|
|
|
|
}
|
|
|
|
return res;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
2012-09-08 12:08:29 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
protected:
|
2012-09-08 12:08:29 -04:00
|
|
|
ItemMap m_Map;
|
|
|
|
|
|
|
|
|
|
|
|
void AddToMap(const AString & a_Name, const AString & a_Value)
|
|
|
|
{
|
|
|
|
AStringVector Split = StringSplit(a_Value, ":");
|
|
|
|
if (Split.size() == 1)
|
|
|
|
{
|
|
|
|
Split = StringSplit(a_Value, "^");
|
|
|
|
}
|
|
|
|
if (Split.empty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
short ItemType = (short)atoi(Split[0].c_str());
|
|
|
|
short ItemDamage = (Split.size() > 1) ? (short)atoi(Split[1].c_str()) : -1;
|
|
|
|
m_Map[a_Name] = std::make_pair(ItemType, ItemDamage);
|
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-03-31 09:50:03 -04:00
|
|
|
bool cBlockIDMap::m_bHasRunInit = false;
|
2012-06-14 09:06:06 -04:00
|
|
|
static cBlockIDMap gsBlockIDMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-08 12:08:29 -04:00
|
|
|
/*
|
|
|
|
// Quick self-test:
|
|
|
|
class Tester
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Tester(void)
|
|
|
|
{
|
|
|
|
cItem Item;
|
|
|
|
gsBlockIDMap.ResolveItem("charcoal", Item);
|
|
|
|
AString Charcoal = gsBlockIDMap.Desolve(Item.m_ItemType, Item.m_ItemDamage);
|
|
|
|
ASSERT(Charcoal == "charcoal");
|
|
|
|
}
|
|
|
|
} test;
|
|
|
|
//*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-11-27 15:19:52 -05:00
|
|
|
int BlockStringToType(const AString & a_BlockTypeString)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
int res = atoi(a_BlockTypeString.c_str());
|
|
|
|
if ((res != 0) || (a_BlockTypeString.compare("0") == 0))
|
|
|
|
{
|
|
|
|
// It was a valid number, return that
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-03-31 09:50:03 -04:00
|
|
|
if (!gsBlockIDMap.m_bHasRunInit)
|
|
|
|
{
|
|
|
|
gsBlockIDMap.init();
|
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
return gsBlockIDMap.Resolve(TrimString(a_BlockTypeString));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item)
|
|
|
|
{
|
2014-10-29 10:47:43 -04:00
|
|
|
AString ItemName = TrimString(a_ItemTypeString);
|
|
|
|
if (ItemName.substr(0, 10) == "minecraft:")
|
|
|
|
{
|
|
|
|
ItemName = ItemName.substr(10);
|
|
|
|
}
|
2015-03-31 09:50:03 -04:00
|
|
|
|
|
|
|
if (!gsBlockIDMap.m_bHasRunInit)
|
|
|
|
{
|
|
|
|
gsBlockIDMap.init();
|
|
|
|
}
|
2014-10-29 10:47:43 -04:00
|
|
|
return gsBlockIDMap.ResolveItem(ItemName, a_Item);
|
2012-09-08 12:08:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AString ItemToString(const cItem & a_Item)
|
|
|
|
{
|
2015-03-31 09:50:03 -04:00
|
|
|
if (!gsBlockIDMap.m_bHasRunInit)
|
|
|
|
{
|
|
|
|
gsBlockIDMap.init();
|
|
|
|
}
|
2012-09-08 12:08:29 -04:00
|
|
|
return gsBlockIDMap.Desolve(a_Item.m_ItemType, a_Item.m_ItemDamage);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AString ItemTypeToString(short a_ItemType)
|
|
|
|
{
|
2015-03-31 09:50:03 -04:00
|
|
|
if (!gsBlockIDMap.m_bHasRunInit)
|
|
|
|
{
|
|
|
|
gsBlockIDMap.init();
|
|
|
|
}
|
2012-09-08 12:08:29 -04:00
|
|
|
return gsBlockIDMap.Desolve(a_ItemType, -1);
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-20 09:25:54 -04:00
|
|
|
AString ItemToFullString(const cItem & a_Item)
|
|
|
|
{
|
|
|
|
AString res;
|
2013-01-11 23:46:01 -05:00
|
|
|
Printf(res, "%s:%d * %d", ItemToString(a_Item).c_str(), a_Item.m_ItemDamage, a_Item.m_ItemCount);
|
2012-09-20 09:25:54 -04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-22 14:41:08 -04:00
|
|
|
eDimension StringToDimension(const AString & a_DimensionString)
|
|
|
|
{
|
2013-07-01 14:46:45 -04:00
|
|
|
// First try decoding as a number
|
2013-06-22 14:41:08 -04:00
|
|
|
int res = atoi(a_DimensionString.c_str());
|
|
|
|
if ((res != 0) || (a_DimensionString == "0"))
|
|
|
|
{
|
|
|
|
// It was a valid number
|
|
|
|
return (eDimension)res;
|
|
|
|
}
|
|
|
|
|
2013-07-01 14:46:45 -04:00
|
|
|
// Decode using a built-in map:
|
2013-06-22 14:41:08 -04:00
|
|
|
static struct
|
|
|
|
{
|
|
|
|
eDimension m_Dimension;
|
|
|
|
const char * m_String;
|
|
|
|
} DimensionMap [] =
|
|
|
|
{
|
|
|
|
{ dimOverworld, "Overworld"},
|
|
|
|
{ dimOverworld, "Normal"},
|
|
|
|
{ dimOverworld, "World"},
|
|
|
|
{ dimNether, "Nether"},
|
2014-04-25 19:26:24 -04:00
|
|
|
{ dimNether, "Hell"}, // Alternate name for Nether
|
2013-06-22 14:41:08 -04:00
|
|
|
{ dimEnd, "End"},
|
|
|
|
{ dimEnd, "Sky"}, // Old name for End
|
|
|
|
} ;
|
2013-12-20 10:01:34 -05:00
|
|
|
for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++)
|
2013-06-22 14:41:08 -04:00
|
|
|
{
|
|
|
|
if (NoCaseCompare(DimensionMap[i].m_String, a_DimensionString) == 0)
|
|
|
|
{
|
|
|
|
return DimensionMap[i].m_Dimension;
|
|
|
|
}
|
|
|
|
} // for i - DimensionMap[]
|
|
|
|
|
|
|
|
// Not found
|
2014-04-25 19:26:24 -04:00
|
|
|
LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", a_DimensionString.c_str());
|
|
|
|
return dimOverworld;
|
2013-06-22 14:41:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-10 15:43:27 -04:00
|
|
|
AString DimensionToString(eDimension a_Dimension)
|
|
|
|
{
|
|
|
|
// Decode using a built-in map:
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
eDimension m_Dimension;
|
|
|
|
const char * m_String;
|
|
|
|
} DimensionMap[] =
|
|
|
|
{
|
|
|
|
{ dimOverworld, "Overworld" },
|
|
|
|
{ dimNether, "Nether" },
|
|
|
|
{ dimEnd, "End" },
|
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++)
|
|
|
|
{
|
|
|
|
if (DimensionMap[i].m_Dimension == a_Dimension)
|
|
|
|
{
|
|
|
|
return DimensionMap[i].m_String;
|
|
|
|
}
|
|
|
|
} // for i - DimensionMap[]
|
|
|
|
|
|
|
|
// Not found
|
|
|
|
LOGWARNING("Unknown dimension: \"%i\". Setting to Overworld", (int)a_Dimension);
|
|
|
|
return "Overworld";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-01 14:46:45 -04:00
|
|
|
/// Translates damage type constant to a string representation (built-in).
|
|
|
|
AString DamageTypeToString(eDamageType a_DamageType)
|
|
|
|
{
|
2013-11-13 15:13:35 -05:00
|
|
|
// Make sure to keep this alpha-sorted.
|
2013-07-01 14:46:45 -04:00
|
|
|
switch (a_DamageType)
|
|
|
|
{
|
2013-11-13 15:13:35 -05:00
|
|
|
case dtAdmin: return "dtAdmin";
|
2013-07-01 14:46:45 -04:00
|
|
|
case dtAttack: return "dtAttack";
|
|
|
|
case dtCactusContact: return "dtCactusContact";
|
2013-11-13 15:13:35 -05:00
|
|
|
case dtDrowning: return "dtDrowning";
|
|
|
|
case dtEnderPearl: return "dtEnderPearl";
|
|
|
|
case dtFalling: return "dtFalling";
|
2013-07-01 14:46:45 -04:00
|
|
|
case dtFireContact: return "dtFireContact";
|
|
|
|
case dtInVoid: return "dtInVoid";
|
2013-11-13 15:13:35 -05:00
|
|
|
case dtLavaContact: return "dtLavaContact";
|
|
|
|
case dtLightning: return "dtLightning";
|
|
|
|
case dtOnFire: return "dtOnFire";
|
|
|
|
case dtPoisoning: return "dtPoisoning";
|
2014-06-09 00:51:55 -04:00
|
|
|
case dtWithering: return "dtWithering";
|
2013-07-01 14:46:45 -04:00
|
|
|
case dtPotionOfHarming: return "dtPotionOfHarming";
|
2013-11-13 15:13:35 -05:00
|
|
|
case dtRangedAttack: return "dtRangedAttack";
|
|
|
|
case dtStarving: return "dtStarving";
|
|
|
|
case dtSuffocating: return "dtSuffocation";
|
2014-02-04 17:09:07 -05:00
|
|
|
case dtExplosion: return "dtExplosion";
|
2013-07-01 14:46:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unknown damage type:
|
|
|
|
ASSERT(!"Unknown DamageType");
|
|
|
|
return Printf("dtUnknown_%d", (int)a_DamageType);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Translates a damage type string to damage type. Takes either a number or a damage type alias (built-in). Returns -1 on failure
|
|
|
|
eDamageType StringToDamageType(const AString & a_DamageTypeString)
|
|
|
|
{
|
|
|
|
// First try decoding as a number:
|
|
|
|
int res = atoi(a_DamageTypeString.c_str());
|
|
|
|
if ((res != 0) || (a_DamageTypeString == "0"))
|
|
|
|
{
|
|
|
|
// It was a valid number
|
|
|
|
return (eDamageType)res;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decode using a built-in map:
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
eDamageType m_DamageType;
|
|
|
|
const char * m_String;
|
|
|
|
} DamageTypeMap [] =
|
|
|
|
{
|
|
|
|
// Cannonical names:
|
|
|
|
{ dtAttack, "dtAttack"},
|
2013-09-01 14:06:49 -04:00
|
|
|
{ dtRangedAttack, "dtRangedAttack"},
|
2013-07-01 14:46:45 -04:00
|
|
|
{ dtLightning, "dtLightning"},
|
|
|
|
{ dtFalling, "dtFalling"},
|
|
|
|
{ dtDrowning, "dtDrowning"},
|
|
|
|
{ dtSuffocating, "dtSuffocation"},
|
|
|
|
{ dtStarving, "dtStarving"},
|
|
|
|
{ dtCactusContact, "dtCactusContact"},
|
|
|
|
{ dtLavaContact, "dtLavaContact"},
|
|
|
|
{ dtPoisoning, "dtPoisoning"},
|
2014-06-09 00:51:55 -04:00
|
|
|
{ dtWithering, "dtWithering"},
|
2013-07-01 14:46:45 -04:00
|
|
|
{ dtOnFire, "dtOnFire"},
|
|
|
|
{ dtFireContact, "dtFireContact"},
|
|
|
|
{ dtInVoid, "dtInVoid"},
|
|
|
|
{ dtPotionOfHarming, "dtPotionOfHarming"},
|
|
|
|
{ dtAdmin, "dtAdmin"},
|
2014-02-04 17:09:07 -05:00
|
|
|
{ dtExplosion, "dtExplosion"},
|
2013-07-01 14:46:45 -04:00
|
|
|
|
|
|
|
// Common synonyms:
|
2013-09-01 14:06:49 -04:00
|
|
|
{ dtAttack, "dtPawnAttack"},
|
|
|
|
{ dtAttack, "dtEntityAttack"},
|
|
|
|
{ dtAttack, "dtMob"},
|
|
|
|
{ dtAttack, "dtMobAttack"},
|
|
|
|
{ dtRangedAttack, "dtArrowAttack"},
|
|
|
|
{ dtRangedAttack, "dtArrow"},
|
|
|
|
{ dtRangedAttack, "dtProjectile"},
|
|
|
|
{ dtFalling, "dtFall"},
|
|
|
|
{ dtDrowning, "dtDrown"},
|
|
|
|
{ dtSuffocating, "dtSuffocation"},
|
|
|
|
{ dtStarving, "dtStarvation"},
|
|
|
|
{ dtStarving, "dtHunger"},
|
|
|
|
{ dtCactusContact, "dtCactus"},
|
|
|
|
{ dtCactusContact, "dtCactuses"},
|
|
|
|
{ dtCactusContact, "dtCacti"},
|
|
|
|
{ dtLavaContact, "dtLava"},
|
|
|
|
{ dtPoisoning, "dtPoison"},
|
2014-06-09 00:51:55 -04:00
|
|
|
{ dtWithering, "dtWither"},
|
2013-09-01 14:06:49 -04:00
|
|
|
{ dtOnFire, "dtBurning"},
|
|
|
|
{ dtFireContact, "dtInFire"},
|
|
|
|
{ dtAdmin, "dtPlugin"},
|
2013-07-01 14:46:45 -04:00
|
|
|
} ;
|
2013-12-20 10:01:34 -05:00
|
|
|
for (size_t i = 0; i < ARRAYCOUNT(DamageTypeMap); i++)
|
2013-07-01 14:46:45 -04:00
|
|
|
{
|
|
|
|
if (NoCaseCompare(DamageTypeMap[i].m_String, a_DamageTypeString) == 0)
|
|
|
|
{
|
|
|
|
return DamageTypeMap[i].m_DamageType;
|
|
|
|
}
|
|
|
|
} // for i - DamageTypeMap[]
|
|
|
|
|
|
|
|
// Not found:
|
|
|
|
return (eDamageType)-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-11 04:12:36 -04:00
|
|
|
cItem GetIniItemSet(cIniFile & a_IniFile, const char * a_Section, const char * a_Key, const char * a_Default)
|
|
|
|
{
|
|
|
|
AString ItemStr = a_IniFile.GetValueSet(a_Section, a_Key, a_Default);
|
|
|
|
cItem res;
|
|
|
|
if (!StringToItem(ItemStr, res))
|
|
|
|
{
|
|
|
|
res.Empty();
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-18 17:30:34 -05:00
|
|
|
|