#include "ItemDefManager.h" #include #include "Item.h" ItemDefManager::ItemDefManager() { memset(this->armorSetsIndex, 0, 4*26); memset(modsIndex, 0, 26*4); memset(itemIdsIndex, 0, 26*4); memset(itemDefsIndex, 0, 26*4); memset(namesIndex, 0, 26*4); } ItemDefManager::~ItemDefManager() { mods.clear(); names.clear(); itemIds.clear(); armorSets.clear(); itemDefs.clear(); } //************************************ // Name: IsTemplate // // Checks if item definition is using a template. // // Parameters: // string - character // pTempArg - Template argument specified by user // // Return: // true - This item definition section is to be filled in // false - Not enough parameters in template // false - Not using a template //************************************ bool ItemDefManager::IsTemplate(char string, char* pTempArg) { if (string=='x' || string=='X' || string=='t') { if (pTempArg!=0) { return true; } else { gCoreLog.warning("Not enough parameters in template."); return false; } } return false; } //Compress the hex string data loaded into the itemdef into actual bytes //if the variable is a template then set a byte to 't' //************************************ // Name: CompressString // // Converts hex to a binary representation for templates and data. // // Parameters: // pString - Hex string // numBytes - Num bytes to make // // Return: // - true //************************************ bool ItemDefManager::CompressString(char* pString, int numBytes) { if (pString[0]!='x' && pString[0]!='X') { Util::ToBytes(pString, pString, numBytes); memset(pString+numBytes, 0, 1); return true; } else { memset(pString+numBytes, 't', 1); return true; } return true; } //************************************ // Name: CompressItemDefs // // Compress all item definitions. // // Parameters: // // Return: // - true //************************************ bool ItemDefManager::CompressItemDefs() { for (unsigned int i=0; i