本文整理汇总了C++中PropWriteStream::ADD_USHORT方法的典型用法代码示例。如果您正苦于以下问题:C++ PropWriteStream::ADD_USHORT方法的具体用法?C++ PropWriteStream::ADD_USHORT怎么用?C++ PropWriteStream::ADD_USHORT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropWriteStream
的用法示例。
在下文中一共展示了PropWriteStream::ADD_USHORT方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serializeAttr
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;
}
示例2: saveTile
bool IOMapSerialize::saveTile(PropWriteStream& stream, const Tile* tile)
{
int32_t tileCount = tile->getThingCount();
if(!tileCount)
return true;
std::vector<Item*> items;
Item* item = NULL;
for(; tileCount > 0; --tileCount)
{
if((item = tile->__getThing(tileCount - 1)->getItem()) &&
(item->isMoveable() || item->forceSerialize()))
items.push_back(item);
}
tileCount = items.size(); //lame, but at least we don't need a new variable
if(tileCount > 0)
{
stream.ADD_USHORT(tile->getPosition().x);
stream.ADD_USHORT(tile->getPosition().y);
stream.ADD_UCHAR(tile->getPosition().z);
stream.ADD_ULONG(tileCount);
for(std::vector<Item*>::iterator it = items.begin(); it != items.end(); ++it)
saveItem(stream, (*it));
}
return true;
}
示例3: saveTile
void IOMapSerialize::saveTile(PropWriteStream& stream, const Tile* tile)
{
const TileItemVector* tileItems = tile->getItemList();
if (!tileItems) {
return;
}
std::forward_list<Item*> items;
uint16_t count = 0;
for (Item* item : *tileItems) {
// Note that these are NEGATED, ie. these are the items that will be saved.
if (!(item->isMoveable() || item->getDoor() || (item->getContainer() && !item->getContainer()->empty()) || item->canWriteText() || item->getBed())) {
continue;
}
items.push_front(item);
++count;
}
if (!items.empty()) {
const Position& tilePosition = tile->getPosition();
stream.ADD_USHORT(tilePosition.x);
stream.ADD_USHORT(tilePosition.y);
stream.ADD_UCHAR(tilePosition.z);
stream.ADD_ULONG(count);
for (const Item* item : items) {
saveItem(stream, item);
}
}
}
示例4: saveTile
void IOMapSerialize::saveTile(PropWriteStream& stream, const Tile* tile)
{
const Position& tilePosition = tile->getPosition();
if (tilePosition.x == 0 || tilePosition.y == 0) {
return;
}
std::vector<Item*> items;
if (const TileItemVector* tileItems = tile->getItemList()) {
for (ItemVector::const_reverse_iterator it = tileItems->rbegin(), rend = tileItems->rend(); it != rend; ++it) {
Item* item = (*it);
// Note that these are NEGATED, ie. these are the items that will be saved.
if (!(!item->isNotMoveable() || item->getDoor() || (item->getContainer() && !item->getContainer()->empty()) || item->canWriteText() || item->getBed())) {
continue;
}
items.push_back(item);
}
}
if (!items.empty()) {
stream.ADD_USHORT(tilePosition.x);
stream.ADD_USHORT(tilePosition.y);
stream.ADD_UCHAR(tilePosition.z);
stream.ADD_ULONG(items.size());
for (const Item* item : items) {
saveItem(stream, item);
}
}
}
示例5: serializeAttr
bool Teleport::serializeAttr(PropWriteStream& propWriteStream) const
{
bool ret = Item::serializeAttr(propWriteStream);
propWriteStream.ADD_UCHAR(ATTR_TELE_DEST);
propWriteStream.ADD_USHORT(destPos.x);
propWriteStream.ADD_USHORT(destPos.y);
propWriteStream.ADD_UCHAR(destPos.z);
return ret;
}
示例6: saveItem
bool IOMapSerialize::saveItem(PropWriteStream& stream, const Item* item)
{
stream.ADD_USHORT(item->getID());
item->serializeAttr(stream);
if(const Container* container = item->getContainer())
{
stream.ADD_UCHAR(ATTR_CONTAINER_ITEMS);
stream.ADD_ULONG(container->size());
for(ItemList::const_reverse_iterator rit = container->getReversedItems(); rit != container->getReversedEnd(); ++rit)
saveItem(stream, (*rit));
}
stream.ADD_UCHAR(ATTR_END);
return true;
}
示例7: serializeAttributeMap
void ItemAttributes::serializeAttributeMap(PropWriteStream& stream) const
{
// maximum of 65535 attributes per item
stream.ADD_USHORT(std::min((size_t)0xFFFF, attributes->size()));
AttributeMap::const_iterator attribute = attributes->begin();
int i = 0;
while(attribute != attributes->end() && i <= 0xFFFF){
const std::string& key = attribute->first;
if(key.size() > 0xFFFF)
stream.ADD_STRING(key.substr(0, 65535));
else
stream.ADD_STRING(key);
attribute->second.serialize(stream);
++attribute, ++i;
}
}
示例8: serializeAttr
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;
}
示例9: saveItem
void IOMapSerialize::saveItem(PropWriteStream& stream, const Item* item)
{
const Container* container = item->getContainer();
// Write ID & props
stream.ADD_USHORT(item->getID());
item->serializeAttr(stream);
if (container) {
// Hack our way into the attributes
stream.ADD_UCHAR(ATTR_CONTAINER_ITEMS);
stream.ADD_ULONG(container->size());
for (ItemDeque::const_reverse_iterator it = container->getReversedItems(), end = container->getReversedEnd(); it != end; ++it) {
saveItem(stream, *it);
}
}
stream.ADD_UCHAR(0x00); // attr end
}
示例10: serialize
bool ConditionEffect::serialize(PropWriteStream& propWriteStream)
{
propWriteStream.ADD_UCHAR(*CONDITIONATTRIBUTE_EFFECT);
propWriteStream.ADD_VALUE((uint32_t)type);
propWriteStream.ADD_VALUE(interval);
switch(type){
case ConditionEffect::PERIODIC_HEAL:
case ConditionEffect::PERIODIC_DAMAGE:
{
ConditionEffect::ModPeriodicDamage& mod = getModEffect<ConditionEffect::ModPeriodicDamage>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE((uint32_t)mod.type.value());
propWriteStream.ADD_VALUE(mod.min);
propWriteStream.ADD_VALUE(mod.max);
propWriteStream.ADD_VALUE(mod.value);
propWriteStream.ADD_VALUE(mod.total);
propWriteStream.ADD_VALUE(mod.percent);
propWriteStream.ADD_VALUE(mod.first);
propWriteStream.ADD_VALUE(mod.rounds);
break;
}
case ConditionEffect::PERIODIC_MOD_STAMINA:
{
ConditionEffect::ModPeriodicStamina& mod = getModEffect<ConditionEffect::ModPeriodicStamina>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE(mod.value);
break;
}
case ConditionEffect::REGEN_HEALTH:
case ConditionEffect::REGEN_MANA:
case ConditionEffect::REGEN_SOUL:
{
ConditionEffect::ModRegen& mod = getModEffect<ConditionEffect::ModRegen>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE((uint32_t)mod.type.value());
propWriteStream.ADD_VALUE(mod.percent);
propWriteStream.ADD_VALUE(mod.value);
break;
}
case ConditionEffect::MOD_SPEED:
{
ConditionEffect::ModSpeed& mod = getModEffect<ConditionEffect::ModSpeed>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE(mod.percent);
propWriteStream.ADD_VALUE(mod.value);
propWriteStream.ADD_VALUE(mod.delta);
break;
}
case ConditionEffect::MOD_STAT:
{
ConditionEffect::ModStat& mod = getModEffect<ConditionEffect::ModStat>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE((uint32_t)mod.type.value());
propWriteStream.ADD_VALUE(mod.percent);
propWriteStream.ADD_VALUE(mod.value);
propWriteStream.ADD_VALUE(mod.delta);
break;
}
case ConditionEffect::MOD_SKILL:
{
ConditionEffect::ModSkill& mod = getModEffect<ConditionEffect::ModSkill>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE((uint32_t)mod.type.value());
propWriteStream.ADD_VALUE(mod.percent);
propWriteStream.ADD_VALUE(mod.value);
propWriteStream.ADD_VALUE(mod.delta);
break;
}
case ConditionEffect::SHAPESHIFT:
{
ConditionEffect::ModShapeShift& mod = getModEffect<ConditionEffect::ModShapeShift>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE(mod.lookType);
propWriteStream.ADD_VALUE(mod.lookTypeEx);
propWriteStream.ADD_VALUE(mod.lookHead);
propWriteStream.ADD_VALUE(mod.lookBody);
propWriteStream.ADD_VALUE(mod.lookLegs);
propWriteStream.ADD_VALUE(mod.lookFeet);
propWriteStream.ADD_VALUE(mod.lookAddons);
break;
}
case ConditionEffect::LIGHT:
{
ConditionEffect::ModLight& mod = getModEffect<ConditionEffect::ModLight>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_VALUE(mod.level);
propWriteStream.ADD_VALUE(mod.color);
break;
}
case ConditionEffect::DISPEL:
{
ConditionEffect::ModDispel& mod = getModEffect<ConditionEffect::ModDispel>();
propWriteStream.ADD_USHORT(1); //revision
propWriteStream.ADD_STRING(mod.name);
break;
}
case ConditionEffect::SCRIPT:
{
ConditionEffect::ModScript& mod = getModEffect<ConditionEffect::ModScript>();
//.........这里部分代码省略.........