This commit is contained in:
Ahmed Samy 2013-08-22 21:15:17 +02:00
parent aaad8ab8a0
commit d5298c1011
2 changed files with 71 additions and 63 deletions

View File

@ -40,7 +40,6 @@ enum SpawnAttr : uint8
{
SpawnAttrRadius = 0,
SpawnAttrCenter = 1,
SpawnAttrPos = 2
};
class Spawn : public LuaObject

View File

@ -134,6 +134,7 @@ bool ThingTypeManager::loadOtml(std::string file)
void ThingTypeManager::loadOtb(const std::string& file)
{
try {
FileStreamPtr fin = g_resources.openFile(file);
uint signature = fin->getU32();
@ -168,10 +169,14 @@ void ThingTypeManager::loadOtb(const std::string& file)
}
m_otbLoaded = true;
} catch(std::exception& e) {
g_logger.error(stdext::format("Failed to load '%s' (OTB file): %s", file, e.what());)
}
}
void ThingTypeManager::loadXml(const std::string& file)
{
try {
if(!isOtbLoaded())
stdext::throw_exception("OTB must be loaded before XML");
@ -205,17 +210,19 @@ void ThingTypeManager::loadXml(const std::string& file)
std::vector<int32> end = stdext::split<int32>(element->Attribute("toid"), ";");
if(begin[0] && begin.size() == end.size()) {
size_t size = begin.size();
for(size_t i = 0; i < size; ++i) {
for(size_t i = 0; i < size; ++i)
while(begin[i] <= end[i])
parseItemType(begin[i]++, element);
}
}
}
}
doc.Clear();
m_xmlLoaded = true;
g_logger.debug("items.xml read successfully.");
} catch(std::exception& e) {
g_logger.error(stdext::format("Failed to load '%s' (XML file): %s", file, e.what()));
}
}
void ThingTypeManager::parseItemType(uint16 id, TiXmlElement* elem)
@ -303,7 +310,7 @@ const ThingTypePtr& ThingTypeManager::getThingType(uint16 id, ThingCategory cate
const ItemTypePtr& ThingTypeManager::getItemType(uint16 id)
{
if(id >= m_itemTypes.size() || m_itemTypes[id] == m_nullItemType) {
g_logger.error(stdext::format("invalid thing type server id %d", id));
g_logger.error(stdext::format("invalid thing type, server id: %d", id));
return m_nullItemType;
}
return m_itemTypes[id];
@ -334,3 +341,5 @@ const ThingTypeList& ThingTypeManager::getThingTypes(ThingCategory category)
stdext::throw_exception(stdext::format("invalid thing type category %d", category));
return m_thingTypes[category];
}
/* vim: set ts=4 sw=4 et: */