Exemplo n.º 1
0
//----------------------------------------------------------------------
// get debug string
//----------------------------------------------------------------------
string PCSlayerInfo::toString () const 
	throw()
{
	StringStream msg;

	msg << "PCSlayerInfo("
		<< "NSize:" << m_Name.size()
		<< ",Name:" << m_Name 
		<< ",Slot:" << Slot2String[m_Slot]
		<< ",Alignment:" << m_Alignment
		<< ",Rank:" << m_Rank
		<< ",STR[BASIC]:" << (int)m_STR 
		<< ",DEX[BASIC]:" << (int)m_DEX
		<< ",INT[BASIC]:" << (int)m_INT
		<< ",HP:" << m_HP[ATTR_CURRENT] << "/" << m_HP[ATTR_MAX]
		<< ",MP:" << m_MP[ATTR_CURRENT] << "/" << m_MP[ATTR_MAX]
		<< ",Fame:" << m_Fame;
//		<< ",Gold:" << m_Gold;

	for (uint i = 0 ; i < SKILL_DOMAIN_VAMPIRE ; i ++ )
		msg << "," << SkillDomain2String[i] << ":" << (int)m_DomainLevels[i];

//	msg << ",ZoneID:" << m_ZoneID 
	msg	<< ",Sex:" << Sex2String[getSex()]
		<< ",HairStyle:" << HairStyle2String[getHairStyle()]
		<< ",HairColor:" << (int)getHairColor()
		<< ",SkinColor:" << (int)getSkinColor()
		<< " ,Helmet:" << (int)getHelmetType()
		<< ",HelmetColor:" << (int)getHelmetColor()
		<< " ,Jacket:" << (int)getJacketType()
		<< ",JacketColor:" << (int)getJacketColor()
		<< " ,Pants:" << (int)getPantsType()
		<< ",PantsColor:" << (int)getPantsColor()
		<< " ,Weapon:" << (int)getWeaponType()
		<< ",WeaponColor:" << (int)getWeaponColor()
		<< " ,Shield:" << (int)getShieldType()
		<< ",ShieldColor:" << (int)getShieldColor()
		<< ")";
	
	return msg.toString();
}
Exemplo n.º 2
0
void CharacterComponent::serialize(Entity &entity, MessageOut &msg)
{
    auto *beingComponent = entity.getComponent<BeingComponent>();

    // general character properties
    msg.writeInt8(getAccountLevel());
    msg.writeInt8(beingComponent->getGender());
    msg.writeInt8(getHairStyle());
    msg.writeInt8(getHairColor());
    msg.writeInt16(getAttributePoints());
    msg.writeInt16(getCorrectionPoints());


    const AttributeMap &attributes = beingComponent->getAttributes();
    std::map<const AttributeInfo *, const Attribute *> attributesToSend;
    for (auto &attributeIt : attributes)
    {
        if (attributeIt.first->persistent)
            attributesToSend.insert(std::make_pair(attributeIt.first,
                                                   &attributeIt.second));
    }
    msg.writeInt16(attributesToSend.size());
    for (auto &attributeIt : attributesToSend)
    {
        msg.writeInt16(attributeIt.first->id);
        msg.writeDouble(attributeIt.second->getBase());
        msg.writeDouble(attributeIt.second->getModifiedAttribute());
    }

    // status effects currently affecting the character
    auto &statusEffects = beingComponent->getStatusEffects();
    msg.writeInt16(statusEffects.size());
    for (auto &statusIt : statusEffects)
    {
        msg.writeInt16(statusIt.first);
        msg.writeInt16(statusIt.second.time);
    }

    // location
    msg.writeInt16(entity.getMap()->getID());
    const Point &pos = entity.getComponent<ActorComponent>()->getPosition();
    msg.writeInt16(pos.x);
    msg.writeInt16(pos.y);

    // kill count
    msg.writeInt16(getKillCountSize());
    for (auto &killCountIt : mKillCount)
    {
        msg.writeInt16(killCountIt.first);
        msg.writeInt32(killCountIt.second);
    }

    // character abilities
    auto &abilities = entity.getComponent<AbilityComponent>()->getAbilities();
    msg.writeInt16(abilities.size());
    for (auto &abilityIt : abilities) {
        msg.writeInt32(abilityIt.first);
    }

    // questlog
    msg.writeInt16(mQuestlog.size());
    for (auto questlogIt : mQuestlog) {
        QuestInfo &quest = questlogIt.second;
        msg.writeInt16(quest.id);
        msg.writeInt8(quest.state);
        msg.writeString(quest.title);
        msg.writeString(quest.description);
    }

    // inventory - must be last because size isn't transmitted
    const Possessions &poss = getPossessions();

    const InventoryData &inventoryData = poss.getInventory();
    for (InventoryData::const_iterator itemIt = inventoryData.begin(),
         itemIt_end = inventoryData.end(); itemIt != itemIt_end; ++itemIt)
    {
        msg.writeInt16(itemIt->first);           // slot id
        msg.writeInt16(itemIt->second.itemId);
        msg.writeInt16(itemIt->second.amount);
        msg.writeInt8(itemIt->second.equipmentSlot);
    }
}