void NetworkMessage::AddItem(const Item* item) { const ItemType &it = Item::items[item->getID()]; AddU16(it.clientId); if(it.stackable || it.isRune()) AddByte(item->getSubType()); else if(it.isSplash() || it.isFluidContainer()) AddByte(fluidMap[item->getSubType() % 8]); }
void NetworkMessage::AddString(const char* value) { uint32_t stringlen = (uint32_t)strlen(value); if(!canAdd(stringlen+2) || stringlen > 8192) return; AddU16(stringlen); strcpy((char*)(m_MsgBuf + m_ReadPos), value); m_ReadPos += stringlen; m_MsgSize += stringlen; }
void NetworkMessage::AddString(const char* value) { size_t stringlen = strlen(value); if (!canAdd(stringlen + 2) || stringlen > 8192) { return; } AddU16(stringlen); memcpy((char*)m_MsgBuf + m_ReadPos, value, stringlen); m_ReadPos += stringlen; m_MsgSize += stringlen; }
void NetworkMessage::AddString(const std::string& value) { size_t stringlen = value.length(); if (!canAdd(stringlen + 2) || stringlen > 8192) { return; } AddU16(stringlen); memcpy(m_MsgBuf + m_ReadPos, value.c_str(), stringlen); m_ReadPos += stringlen; m_MsgSize += stringlen; }
void NetworkMessage::AddItem(uint16_t id, uint8_t count) { const ItemType &it = Item::items[id]; AddU16(it.clientId); if(it.stackable || it.isRune()) AddByte(count); else if(it.isSplash() || it.isFluidContainer()) { uint32_t fluidIndex = (count % 8); AddByte(fluidMap[fluidIndex]); } }
void NetworkMessage::AddItem(const Item* item) { const ItemType &it = Item::items[item->getID()]; AddU16(it.clientId); if(it.stackable){ AddByte(item->getSubType()); } else if(it.isSplash() || it.isFluidContainer()){ AddByte(Item::items.getClientFluidType(FluidTypes_t(item->getSubType()))); } }
void NetworkMessage::AddItem(uint16_t id, uint8_t count) { const ItemType &it = Item::items[id]; AddU16(it.clientId); if(it.stackable){ AddByte(count); } else if(it.isSplash() || it.isFluidContainer()){ AddByte(Item::items.getClientFluidType(FluidTypes_t(count))); } }
void NetworkMessage::AddItem(const Item* item) { const ItemType &it = Item::items[item->getID()]; AddU16(it.clientId); if(it.stackable){ AddByte(item->getSubType()); } else if(it.isSplash() || it.isFluidContainer()){ uint32_t fluidIndex = item->getSubType() % 8; AddByte(fluidMap[fluidIndex].value()); } }
void NetworkMessage::AddItem(const Item* item) { const ItemType& it = Item::items[item->getID()]; AddU16(it.clientId); if (it.stackable) { AddByte(std::min<uint16_t>(0xFF, item->getItemCount())); } else if (it.isSplash() || it.isFluidContainer()) { uint32_t fluidIndex = item->getFluidType() % 8; AddByte(fluidMap[fluidIndex]); } if (it.isAnimation) { AddByte(0xFE); // random phase (0xFF for async) } }
void NetworkMessage::AddItem(uint16_t id, uint8_t count) { const ItemType& it = Item::items[id]; AddU16(it.clientId); if (it.stackable) { AddByte(count); } else if (it.isSplash() || it.isFluidContainer()) { uint32_t fluidIndex = count % 8; AddByte(fluidMap[fluidIndex]); } if (it.isAnimation) { AddByte(0xFE); // random phase (0xFF for async) } }
void NetworkMessage::AddItemId(uint16_t itemId) { const ItemType& it = Item::items[itemId]; AddU16(it.clientId); }
void NetworkMessage::AddPosition(const Position& pos) { AddU16(pos.x); AddU16(pos.y); AddByte(pos.z); }
void NetworkMessage::AddItemId(const Item *item){ const ItemType &it = Item::items[item->getID()]; AddU16(it.clientId); }