/// deserialize message by reading bytes from stream
 void Deserialize(ByteStream& stream)
 {
    m_cszName = stream.ReadString(64);
    m_cBackgroundColor.m_color[Color::red] = stream.Read8();
    m_cBackgroundColor.m_color[Color::green] = stream.Read8();
    m_cBackgroundColor.m_color[Color::blue] = stream.Read8();
    m_fBrightness = stream.Read8() / 255.f;
 }
void DamageSpellEffect::Deserialize(ByteStream& stream)
{
   BaseClass::Deserialize(stream);

   unsigned char ucDamageType = stream.Read8();
   m_damageType = DamageType(static_cast<DamageType::T_enDamageType>(ucDamageType));
   if (m_damageType.Type() >= DamageType::typeMax)
      throw Exception(_T("invalid damage type"), __FILE__, __LINE__);

   m_ucRestriction = stream.Read8();
   if (m_ucRestriction > 3)
      throw Exception(_T("invalid damage restriction flags"), __FILE__, __LINE__);
}
std::shared_ptr<SpellEffect> SpellEffect::Construct(ByteStream& stream)
{
   // read type
   unsigned char ucType = stream.Read8();
   if (ucType >= typeMax)
      throw Exception(_T("invalid spell effect type"), __FILE__, __LINE__);

   T_enEffectType enEffectType = static_cast<T_enEffectType>(ucType);

   static std::shared_ptr<SpellEffect> spEffect;
   switch (enEffectType)
   {
   case SpellEffect::typeDamage: spEffect.reset(new DamageSpellEffect); break;
   case SpellEffect::typeHeal: spEffect.reset(new HealSpellEffect); break;
   case SpellEffect::typeModify: spEffect.reset(new ModifyAttrSpellEffect); break;
   case SpellEffect::typeResist: spEffect.reset(new ResistSpellEffect); break;
   case SpellEffect::typeDisable: spEffect.reset(new DisableSpellEffect); break;
   default: ATLASSERT(false); break;
   }

   ATLASSERT(spEffect != NULL);
   spEffect->Deserialize(stream);

   return spEffect;
}
void DisableSpellEffect::Deserialize(ByteStream& stream)
{
   BaseClass::Deserialize(stream);

   unsigned char ucDisableType = stream.Read8();
   if (ucDisableType >= disableMax)
      throw Exception(_T("invalid disable spell effect type"), __FILE__, __LINE__);

   m_enDisableType = static_cast<T_enDisableType>(ucDisableType);
}
Esempio n. 5
0
void Item::Deserialize(ByteStream& stream)
{
   ItemTemplate::Deserialize(stream);

   m_id = stream.ReadUuid();

   m_uiDurability = stream.Read8();
   if (m_uiDurability > ItemTemplate::MaxDurability())
      throw Exception(_T("invalid durability value"), __FILE__, __LINE__);
}
void EffectValueOrRange::Deserialize(ByteStream& stream)
{
   // read flag
   Flags8 flags = stream.Read8();

   m_bRange = flags.GetBit<0>();
   m_bPercent = flags.GetBit<1>();

   m_iValues[0] = static_cast<int>(stream.Read32());
   if (m_bRange)
      m_iValues[1] = static_cast<int>(stream.Read32());
}
void ItemTemplate::Deserialize(ByteStream& stream)
{
   m_uiTemplateId = stream.Read32();

   {
      unsigned char ucItemType = stream.Read8();
      if (ucItemType >= itemTypeMax)
         throw Exception(_T("invalid item type"), __FILE__, __LINE__);

      m_enItemType = static_cast<T_enItemType>(ucItemType);
   }

   {
      unsigned char ucEquipSlotType = stream.Read8();
      if (equipSlotCount > itemTypeMax)
         throw Exception(_T("invalid equip slot type"), __FILE__, __LINE__);

      m_enEquipSlotType = static_cast<T_enEquipSlotType>(ucEquipSlotType);
   }

   // TODO impl
}
void DamageHealSpellEffectBase::Deserialize(ByteStream& stream)
{
   BaseClass::Deserialize(stream);

   // read flag
   Flags8 flags = stream.Read8();

   m_bIsInstant = flags.GetBit<0>();

   bool bHasDuration = flags.GetBit<1>();
   bool bHasTickTime = flags.GetBit<2>();

   m_uiDuration = bHasDuration ? stream.Read32() : 0;
   m_uiTickTime = bHasTickTime ? stream.Read32() : 0;
}
 /// deserialize message by reading bytes from stream
 virtual void Deserialize(ByteStream& stream) override
 {
    BYTE bData = stream.Read8();
    if (bData != c_bResponseValue)
       throw Exception(_T("invalid ping response"), __FILE__, __LINE__);
 }