void ManufacturingSchematic::sendAttributes(PlayerObject* playerObject)
{

	if(playerObject->getConnectionState() != PlayerConnState_Connected)
		return;

	TangibleObject* tItem = this->getItem();
	if(!tItem)
		return;

	AttributeMap::iterator		mapIt;
	AttributeMap*				iAttributeMap		= tItem->getAttributeMap();
	AttributeOrderList*			iAttributeOrderList	= tItem->getAttributeOrder();

	AttributeMap*				rAttributeMap		= getAttributeMap();
	AttributeOrderList*			rAttributeOrderList	= getAttributeOrder();

	//DraftSchematic*				draftSchematic		= gSchematicManager->getSchematicBySlotId(mDynamicInt32);
	//DraftSlots*					draftSlots			= draftSchematic->getDraftSlots();

	Message*					newMessage;
	string						value,aStr;
	BStringVector				dataElements;

	//uint32	amountSlots		= draftSlots->size();
	//uint8	i				= 0;

	gMessageFactory->StartMessage();
	gMessageFactory->addUint32(opAttributeListMessage);
	gMessageFactory->addUint64(mId);

	//add slots and resource/item requirements

	gMessageFactory->addUint32(iAttributeMap->size()+ rAttributeMap->size()+1);

	AttributeOrderList::iterator	orderIt = rAttributeOrderList->begin();

	while(orderIt != rAttributeOrderList->end())
	{
		mapIt = rAttributeMap->find(*orderIt);

		gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

		value = (*mapIt).second.c_str();
		value.convert(BSTRType_Unicode16);

		gMessageFactory->addString(value);

		++orderIt;
	}

	//attributes ....
	gMessageFactory->addString(BString("manf_attribs"));
	aStr = "\\#"SOE_RED" --------------";
	aStr.convert(BSTRType_Unicode16);
	gMessageFactory->addString(aStr);


	orderIt = iAttributeOrderList->begin();

	while(orderIt != iAttributeOrderList->end())
	{
		mapIt = iAttributeMap->find(*orderIt);

		gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

		value = (*mapIt).second.c_str();
		value.convert(BSTRType_Unicode16);

		gMessageFactory->addString(value);

		++orderIt;
	}

	//gMessageFactory->addUint32(0xffffffff);

	newMessage = gMessageFactory->EndMessage();

	(playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(),CR_Client,9);

}
Exemplo n.º 2
0
void FactoryCrate::sendAttributes(PlayerObject* playerObject)
{

    if(!(playerObject->isConnected()))
        return;

    AttributeMap*				iAttributeMap		= this->getLinkedObject()->getAttributeMap();
    AttributeOrderList*			iAttributeOrderList	= this->getLinkedObject()->getAttributeOrder();

    Message* newMessage;

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opAttributeListMessage);
    gMessageFactory->addUint64(mId);

    gMessageFactory->addUint32(2 + mAttributeMap.size()+iAttributeMap->size());

    BString	tmpValueStr = BString(BSTRType_Unicode16,64);
    BString	value,aStr;

    tmpValueStr.setLength(swprintf(tmpValueStr.getUnicode16(),50,L"%u/%u",mMaxCondition - mDamage,mMaxCondition));

    gMessageFactory->addString(BString("condition"));
    gMessageFactory->addString(tmpValueStr);

    AttributeMap::iterator			mapIt;
    AttributeOrderList::iterator	orderIt = mAttributeOrderList.begin();



    while(orderIt != mAttributeOrderList.end())
    {
        mapIt = mAttributeMap.find(*orderIt);

        gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

        value = (*mapIt).second.c_str();
        value.convert(BSTRType_Unicode16);

        gMessageFactory->addString(value);

        ++orderIt;
    }

    gMessageFactory->addString(BString("factory_attribs"));
    aStr = "\\#"SOE_RED" --------------";
    aStr.convert(BSTRType_Unicode16);
    gMessageFactory->addString(aStr);

    orderIt = iAttributeOrderList->begin();

    while(orderIt != iAttributeOrderList->end())
    {
        mapIt = iAttributeMap->find(*orderIt);

        gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

        value = (*mapIt).second.c_str();
        value.convert(BSTRType_Unicode16);

        gMessageFactory->addString(value);

        ++orderIt;
    }

    newMessage = gMessageFactory->EndMessage();

    (playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(), CR_Client, 9);
}