bool Item::serializeAttr(PropWriteStream& propWriteStream) const { if (isStackable() || isFluidContainer() || isSplash()) { uint8_t _count = getSubType(); propWriteStream.ADD_UCHAR(ATTR_COUNT); propWriteStream.ADD_UCHAR(_count); } if (hasCharges()) { uint16_t _count = getCharges(); propWriteStream.ADD_UCHAR(ATTR_CHARGES); propWriteStream.ADD_USHORT(_count); } if (!isNotMoveable()) { uint16_t _actionId = getActionId(); if (_actionId) { propWriteStream.ADD_UCHAR(ATTR_ACTION_ID); propWriteStream.ADD_USHORT(_actionId); } } const std::string& _text = getText(); if (!_text.empty()) { propWriteStream.ADD_UCHAR(ATTR_TEXT); propWriteStream.ADD_STRING(_text); } const time_t _writtenDate = getDate(); if (_writtenDate > 0) { propWriteStream.ADD_UCHAR(ATTR_WRITTENDATE); propWriteStream.ADD_ULONG(_writtenDate); } const std::string& _writer = getWriter(); if (!_writer.empty()) { propWriteStream.ADD_UCHAR(ATTR_WRITTENBY); propWriteStream.ADD_STRING(_writer); } const std::string& _specialDesc = getSpecialDescription(); if (!_specialDesc.empty()) { propWriteStream.ADD_UCHAR(ATTR_DESC); propWriteStream.ADD_STRING(_specialDesc); } if (hasAttribute(ATTR_ITEM_DURATION)) { uint32_t duration = getDuration(); propWriteStream.ADD_UCHAR(ATTR_DURATION); propWriteStream.ADD_ULONG(duration); } ItemDecayState_t decayState = getDecaying(); if (decayState == DECAYING_TRUE || decayState == DECAYING_PENDING) { propWriteStream.ADD_UCHAR(ATTR_DECAYING_STATE); propWriteStream.ADD_UCHAR(decayState); } return true; }
xmlNodePtr Item::serialize() { xmlNodePtr nodeItem = xmlNewNode(NULL,(const xmlChar*)"item"); std::stringstream ss; ss.str(""); ss << getID(); xmlSetProp(nodeItem, (const xmlChar*)"id", (const xmlChar*)ss.str().c_str()); if(hasSubType()){ ss.str(""); ss << (int)getItemCountOrSubtype(); xmlSetProp(nodeItem, (const xmlChar*)"count", (const xmlChar*)ss.str().c_str()); } if(specialDescription){ ss.str(""); ss << getSpecialDescription(); xmlSetProp(nodeItem, (const xmlChar*)"special_description", (const xmlChar*)ss.str().c_str()); } if(text){ ss.str(""); ss << getText(); xmlSetProp(nodeItem, (const xmlChar*)"text", (const xmlChar*)ss.str().c_str()); } if(!isNotMoveable() /*moveable*/){ if(actionId != 0){ ss.str(""); ss << actionId; xmlSetProp(nodeItem, (const xmlChar*)"actionId", (const xmlChar*)ss.str().c_str()); } } /*we are not saving unique ids if(uniqueId != 0){ ss.str(""); ss << uniqueId; xmlSetProp(nodeItem, (const xmlChar*)"uniqueId", (const xmlChar*)ss.str().c_str()); } */ return nodeItem; }
bool Item::serializeAttr(PropWriteStream& propWriteStream) { if(isStackable() || isSplash() || isFluidContainer()){ unsigned char _count = getItemCountOrSubtype(); propWriteStream.ADD_UCHAR(ATTR_COUNT); propWriteStream.ADD_UCHAR(_count); } if(isRune()){ unsigned char _count = getItemCharge(); propWriteStream.ADD_UCHAR(ATTR_RUNE_CHARGES); propWriteStream.ADD_UCHAR(_count); } if(!isNotMoveable() /*moveable*/){ if(actionId){ unsigned short _actionId = getActionId(); propWriteStream.ADD_UCHAR(ATTR_ACTION_ID); propWriteStream.ADD_USHORT(_actionId); } } /*we are not saving unique ids if(uniqueId){ unsigned short _uniqueId = getUniqueId(); propWriteStream.ADD_UCHAR(ATTR_UNIQUE_ID); propWriteStream.ADD_USHORT(_uniqueId); } */ const std::string& _text = getText(); if(_text.length() > 0){ propWriteStream.ADD_UCHAR(ATTR_TEXT); propWriteStream.ADD_STRING(_text); } const std::string& _specialDesc = getSpecialDescription(); if(_specialDesc.length() > 0){ propWriteStream.ADD_UCHAR(ATTR_DESC); propWriteStream.ADD_STRING(_specialDesc); } return true; }
bool Item::isPushable() const { return !isNotMoveable(); }
xmlNodePtr Item::serialize() { xmlNodePtr nodeItem = xmlNewNode(NULL,(const xmlChar*)"item"); std::stringstream ss; ss.str(""); ss << getID(); xmlSetProp(nodeItem, (const xmlChar*)"id", (const xmlChar*)ss.str().c_str()); if(hasSubType()){ ss.str(""); ss << (int32_t)getSubType(); xmlSetProp(nodeItem, (const xmlChar*)"count", (const xmlChar*)ss.str().c_str()); } if(getSpecialDescription() != ""){ ss.str(""); ss << getSpecialDescription(); xmlSetProp(nodeItem, (const xmlChar*)"special_description", (const xmlChar*)ss.str().c_str()); } if(getText() != ""){ ss.str(""); ss << getText(); xmlSetProp(nodeItem, (const xmlChar*)"text", (const xmlChar*)ss.str().c_str()); } if(getWrittenDate() != 0){ ss.str(""); ss << getWrittenDate(); xmlSetProp(nodeItem, (const xmlChar*)"written_date", (const xmlChar*)ss.str().c_str()); } if(getWriter() != ""){ ss.str(""); ss << getWriter(); xmlSetProp(nodeItem, (const xmlChar*)"writer", (const xmlChar*)ss.str().c_str()); } if(!isNotMoveable() /*moveable*/){ if(getActionId() != 0){ ss.str(""); ss << getActionId(); xmlSetProp(nodeItem, (const xmlChar*)"actionId", (const xmlChar*)ss.str().c_str()); } } if(hasAttribute(ATTR_ITEM_DURATION)){ uint32_t duration = getDuration(); ss.str(""); ss << duration; xmlSetProp(nodeItem, (const xmlChar*)"duration", (const xmlChar*)ss.str().c_str()); } uint32_t decayState = getDecaying(); if(decayState == DECAYING_TRUE || decayState == DECAYING_PENDING){ ss.str(""); ss << decayState; xmlSetProp(nodeItem, (const xmlChar*)"decayState", (const xmlChar*)ss.str().c_str()); } return nodeItem; }