Example #1
0
void CraftingManager::handleCraftCustomization(Object* object,Message* message)
{
    PlayerObject*		player		= dynamic_cast<PlayerObject*>(object);
    CraftingSession*	session		= player->getCraftingSession();
    BString				itemName;
    uint8				hmmm1,hmmm2;
    uint32				amount,color;

    if(!session)
        return;
    player->setCraftingStage(4);

    message->getStringUnicode16(itemName);
    itemName.convert(BSTRType_ANSI);

    message->getUint8(hmmm1);

    message->getUint32(amount);
    message->getUint8(hmmm2);

    CustomizationList* cList;

    cList = session->getManufacturingSchematic()->getCustomizationList();
    CustomizationList::iterator	custIt = cList->begin();

    uint32 i = 0;
    while((custIt != cList->end())&&(i < hmmm2))
    {
        message->getUint32(color);
        message->getUint32(color);
        session->getItem()->setCustomization(static_cast<uint8>((*custIt)->cutomizationIndex),(uint16)color,3);

        i++;
        ++custIt;
    }

    int8 sql[550];
    sprintf(sql, "INSERT INTO item_customization VALUES (%"PRIu64", %u, %u)",session->getItem()->getId(), session->getItem()->getCustomization(1), session->getItem()->getCustomization(2));
    mDatabase->executeAsyncSql(sql);

    session->setProductionAmount(amount);
    session->customize(itemName.getAnsi());
}
bool MessageLib::sendBaselinesMSCO_7(ManufacturingSchematic* manSchem,PlayerObject* playerObject)
{

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

	Message*							message;
	Message*							finalMessage;

	ManufactureSlots*					manSlots			= manSchem->getManufactureSlots();
	ManufactureSlots::iterator			manSlotIt			= manSlots->begin();

	//ExperimentationProperties*			exProp				= manSchem->getExperimentationProperties();
	//ExperimentationProperties::iterator	epIt				= exProp->begin();

	ExperimentationPropertiesStore::iterator	epStoreIt	= manSchem->expPropStore.begin();

	CustomizationList*					custList			= manSchem->getCustomizationList();
	CustomizationList::iterator			custIt				= custList->begin();

	//start with the messagebody

	mMessageFactory->StartMessage();

	//object count
	mMessageFactory->addUint16(21);

	// slot description
	//SlotNameList
	//		-1-
	mMessageFactory->addUint32(manSlots->size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[0]);

	manSlotIt = manSlots->begin();

	while(manSlotIt != manSlots->end())
	{
		mMessageFactory->addString((*manSlotIt)->mDraftSlot->getComponentFile());
		mMessageFactory->addUint32(0);
		mMessageFactory->addString((*manSlotIt)->mDraftSlot->getComponentName());

		++manSlotIt;
	}

	// slots filled
	//SlotContentsList
	//		-2-
	mMessageFactory->addUint32(manSlots->size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[1]);

	manSlotIt = manSlots->begin();

	while(manSlotIt != manSlots->end())
	{
		mMessageFactory->addUint32(0);

		++manSlotIt;
	}

	// resources filled, all lists initially 0
	// IngridientList
	//		-3-
	mMessageFactory->addUint32(manSlots->size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[2]);
	manSlotIt = manSlots->begin();

	while(manSlotIt != manSlots->end())
	{
		mMessageFactory->addUint32(0);

		++manSlotIt;
	}

	// resources filled amounts, all lists initially 0
	// QuantityList
	//		-4-
	mMessageFactory->addUint32(manSlots->size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[3]);

	manSlotIt = manSlots->begin();

	while(manSlotIt != manSlots->end())
	{
		mMessageFactory->addUint32(0);

		++manSlotIt;
	}

	// SlotQualityList
	// is not used!!!!!!!!!!!!!! as quality is calculated clientside!
	//		-5-
	mMessageFactory->addUint32(manSlots->size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[4]);

	manSlotIt = manSlots->begin();

	while(manSlotIt != manSlots->end())
	{
		mMessageFactory->addUint32(0);

		++manSlotIt;
	}

	// CleanSlotList
	//
	//		-6-
	mMessageFactory->addUint32(manSlots->size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[5]);

	manSlotIt = manSlots->begin();

	while(manSlotIt != manSlots->end())
	{
		mMessageFactory->addUint32((*manSlotIt)->mUnknown2);

		++manSlotIt;
	}

	// SlotIndexList
	//
	//		-7-
	manSchem->mUpdateCounter[6] *= 2;

	mMessageFactory->addUint32(manSlots->size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[6]);

	manSlotIt = manSlots->begin();

	uint32 index = 0;
	while(manSlotIt != manSlots->end())
	{
		mMessageFactory->addUint32(index);
		index++;

		++manSlotIt;
	}

	// IngredientsCounter
	//flowcontrol - 4 times number of slots for every update
	manSchem->setCounter(manSlots->size() * 4);
	mMessageFactory->addUint8(manSlots->size() * 4);

	// experimentation
	///8
	//we need to send them so that they are shown on assembly!!!
	mMessageFactory->addUint32(manSchem->expPropStore.size());
	mMessageFactory->addUint32(manSchem->mUpdateCounter[8]);

	epStoreIt			= manSchem->expPropStore.begin();

	while(epStoreIt != manSchem->expPropStore.end())
	{
		mMessageFactory->addString(BString("crafting"));
		mMessageFactory->addUint32(0);
		mMessageFactory->addString((*epStoreIt).second->mExpAttributeName);
		++epStoreIt;
	}

	//9
	//CurrentExperimentationValueList

	mMessageFactory->addUint32(manSchem->expPropStore.size());

	//annoyingly the craftattributeslist is still zero at this time so we need to reinitialize them !!!!
	manSchem->mUpdateCounter[9] = manSchem->expPropStore.size();
	mMessageFactory->addUint32(manSchem->mUpdateCounter[9]);

	epStoreIt			= manSchem->expPropStore.begin();

	while(epStoreIt != manSchem->expPropStore.end())
	{
		mMessageFactory->addFloat(0);//(*epStoreIt)->mExpAttributeValue);
		(*epStoreIt).second->mExpAttributeValue = 0;
		(*epStoreIt).second->mExpAttributeValueOld = 0;

		++epStoreIt;
	}

	// 10
	//exp offset leave as 0

	mMessageFactory->addUint32(manSchem->expPropStore.size());
	//annoyingly the craftattributeslist is still zero at this time so we need to reinitialize them !!!!
	manSchem->mUpdateCounter[10] = manSchem->expPropStore.size();
	mMessageFactory->addUint32(manSchem->mUpdateCounter[10]);

	epStoreIt			= manSchem->expPropStore.begin();

	while(epStoreIt != manSchem->expPropStore.end())
	{

		mMessageFactory->addUint32(0);//(*epStoreIt)->mExpUnknown);

		++epStoreIt;
	}

	//11
	// bluebar / exp bar value

	mMessageFactory->addUint32(manSchem->expPropStore.size());
	//annoyingly the craftattributeslist is still zero at this time so we need to reinitialize them !!!!
	manSchem->mUpdateCounter[11] = manSchem->expPropStore.size();
	mMessageFactory->addUint32(manSchem->mUpdateCounter[11]);

	epStoreIt			= manSchem->expPropStore.begin();

	while(epStoreIt != manSchem->expPropStore.end())
	{
		(*epStoreIt).second->mBlueBarSizeOld = 1.0;
		(*epStoreIt).second->mBlueBarSize = 1.0;
		mMessageFactory->addFloat((*epStoreIt).second->mBlueBarSize);//

		++epStoreIt;
	}

	//12 (c)
	// max experimentation
	mMessageFactory->addUint32(manSchem->expPropStore.size());
	//annoyingly the craftattributeslist is still zero at this time so we need to reinitialize them !!!!
	manSchem->mUpdateCounter[12] = manSchem->expPropStore.size();
	mMessageFactory->addUint32(manSchem->mUpdateCounter[12]);

	epStoreIt			= manSchem->expPropStore.begin();

	while(epStoreIt != manSchem->expPropStore.end())
	{

		(*epStoreIt).second->mMaxExpValue = 0;
		(*epStoreIt).second->mMaxExpValueOld = 0;
		mMessageFactory->addFloat(0);//(*epStoreIt)->mMaxExpValue);

		++epStoreIt;
	}

	// 13 customization attribute name (d)
	uint32 custSize = custList->size();
	mMessageFactory->addUint32(custSize);
	mMessageFactory->addUint32(custSize);

	custIt = custList->begin();
	while(custIt != custList->end())
	{
		mMessageFactory->addString((*custIt)->attribute);
		++custIt;
	}


	// 14 customization default color
	mMessageFactory->addUint32(custSize);
	mMessageFactory->addUint32(custSize);

	custIt = custList->begin();
	while(custIt != custList->end())
	{
		mMessageFactory->addUint32((*custIt)->defaultValue);
		++custIt;
	}

	// 15 palette start
	mMessageFactory->addUint32(custSize);
	mMessageFactory->addUint32(custSize);

	custIt = custList->begin();
	while(custIt != custList->end())
	{
		mMessageFactory->addUint32(0);
		++custIt;
	}


	// 16 palette end
	mMessageFactory->addUint32(custSize);
	mMessageFactory->addUint32(custSize);


	custIt = custList->begin();
	while(custIt != custList->end())
	{
		mMessageFactory->addUint32((*custIt)->paletteSize);
		++custIt;
	}

	// 17 customization counter
	mMessageFactory->addUint8(static_cast<uint8>(custSize));

	mMessageFactory->addUint64(0);
	mMessageFactory->addUint32(0);
	mMessageFactory->addUint8(0);
	mMessageFactory->addUint8(1);

	message = mMessageFactory->EndMessage();


	mMessageFactory->StartMessage();
	mMessageFactory->addUint32(opBaselinesMessage);
	mMessageFactory->addUint64(manSchem->getId());
	mMessageFactory->addUint32(opMSCO);
	mMessageFactory->addUint8(7);

	mMessageFactory->addUint32(message->getSize());
	mMessageFactory->addData(message->getData(),message->getSize());

	finalMessage = mMessageFactory->EndMessage();
	message->setPendingDelete(true);

	(playerObject->getClient())->SendChannelA(finalMessage,playerObject->getAccountId(),CR_Client,5);

	return(true);
}