void SchematicMap::buildSchematicGroups() { while(iffGroupMap.size() > 0) { VectorMapEntry<uint32, String> entry = iffGroupMap.remove(0); String groupName = entry.getValue(); DraftSchematic* schematic = schematicCrcMap.get(entry.getKey()); if(schematic != NULL) { Locker locker(schematic); schematic->setGroupName(groupName); DraftSchematicGroup* group = groupMap.get(groupName); if (group == NULL) { group = new DraftSchematicGroup(); groupMap.put(groupName, group); } if(!group->contains(schematic)) group->add(schematic); } } }
void ManufacturingSchematic::prepareManufactureSlots() { DraftSchematic* draftSchematic = gSchematicManager->getSchematicBySlotId(mDynamicInt32); DraftSlots* draftSlots = draftSchematic->getDraftSlots(); DraftSlots::iterator draftSlotIt = draftSlots->begin(); while(draftSlotIt != draftSlots->end()) { mManufactureSlots.push_back(new ManufactureSlot(*draftSlotIt)); ++draftSlotIt; } for(uint32 i = 0;i < 8;i++) mUpdateCounter[i] = mManufactureSlots.size(); //annoyingly the craftattributeslist is still zero at this time so we need to reinitialize them !!!! mUpdateCounter[8] = mExperimentationProperties.size(); mUpdateCounter[9] = mExperimentationProperties.size(); mUpdateCounter[10] = mExperimentationProperties.size(); mUpdateCounter[11] = mExperimentationProperties.size(); mUpdateCounter[12] = mExperimentationProperties.size(); mUpdateCounter[13] = 0; mUpdateCounter[14] = 0; mUpdateCounter[15] = 0; mUpdateCounter[16] = 0; mUpdateCounter[17] = 0; mUpdateCounter[18] = 0; mUnknown = mManufactureSlots.size(); }
bool MessageLib::sendBaselinesMSCO_6(ManufacturingSchematic* manSchem,PlayerObject* playerObject) { if(!(playerObject->isConnected())) return(false); Message* message; DraftSchematic* draftSchematic = gSchematicManager->getSchematicBySlotId(manSchem->getDynamicInt32()); if(!draftSchematic) return(false); mMessageFactory->StartMessage(); mMessageFactory->addUint32(opBaselinesMessage); mMessageFactory->addUint64(manSchem->getId()); mMessageFactory->addUint32(opMSCO); mMessageFactory->addUint8(6); mMessageFactory->addUint32(16 + manSchem->getItemModel().getLength()); mMessageFactory->addUint16(6); mMessageFactory->addFloat(static_cast<float>(draftSchematic->getComplexity())); //customization string mMessageFactory->addUint16(0); mMessageFactory->addString(manSchem->getItemModel()); //prototype crc mMessageFactory->addUint32(manSchem->getDynamicInt32()); mMessageFactory->addUint8(1); mMessageFactory->addUint8(manSchem->getFilledSlotCount()); message = mMessageFactory->EndMessage(); (playerObject->getClient())->SendChannelA(message,playerObject->getAccountId(),CR_Client,5); return(true); }
void ContractCrateImplementation::parseDraftSchematic(const String& schematic) { DraftSchematic* schematicTemplate = SchematicMap::instance()->get(schematic.hashCode()); if (schematicTemplate == NULL) return; xpType = schematicTemplate->getXpType(); itemName = schematicTemplate->getCustomName(); xpAmount = schematicTemplate->getXpAmount(); }
void ManufacturingSchematic::prepareCraftingAttributes() { DraftSchematic* draftSchematic = gSchematicManager->getSchematicBySlotId(mDynamicInt32); CraftBatches* expCraftBatches = draftSchematic->getCraftBatches(); CraftBatches::iterator expCraftBatchIt = expCraftBatches->begin(); while(expCraftBatchIt != expCraftBatches->end()) { string attName = gSchematicManager->getExpGroup((*expCraftBatchIt)->getExpGroup()); ExperimentationProperty* expProperty = new ExperimentationProperty(attName.getAnsi(),(*expCraftBatchIt)->getCraftWeights(),(*expCraftBatchIt)->getCraftAttributes(),0.0f,0.0f,0.0f); mExperimentationProperties.push_back(expProperty); ++expCraftBatchIt; } //for(uint32 i = 8;i < 15;i++) // mUpdateCounter[i] = mExperimentationProperties.size(); mExpFailureChance = 90.0f; // ---------------------------------------------------------------- // collect the *unique* exp properties in a list for easy reference // so we can bundle them on sending the deltas / baseline ExperimentationProperties* expProp = getExperimentationProperties(); ExperimentationProperties::iterator epIt = expProp->begin(); epIt = expProp->begin(); while(epIt != expProp->end()) { // do we have this exp property already?? if(!expPropStorefind((*epIt)->mExpAttributeName.getCrc())) { // add it expPropStore.push_back(std::make_pair((*epIt)->mExpAttributeName.getCrc(),(*epIt))); } ++epIt; } }
void SchematicManager::handleDatabaseJobComplete(void* ref,swganh::database::DatabaseResult* result) { ScMAsyncContainer* asyncContainer = reinterpret_cast<ScMAsyncContainer*>(ref); switch(asyncContainer->mQueryType) { // index table for experimentation properties case ScMQuery_ExperimentationGroups: { BString expGroup; swganh::database::DataBinding* binding = mDatabase->createDataBinding(1); binding->addField(swganh::database::DFT_bstring,0,64,1); uint64 count = result->getRowCount(); mvExpGroups.reserve((uint32)count); for(uint64 i = 0; i < count; i++) { result->getNextRow(binding,&expGroup); mvExpGroups.push_back(expGroup.getAnsi()); } mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading Experimentation Groups."); } break; case ScMQuery_SchematicGroups: { SchematicGroup* scGroup; swganh::database::DataBinding* binding = mDatabase->createDataBinding(2); binding->addField(swganh::database::DFT_uint32,offsetof(SchematicGroup,mId),4,0); binding->addField(swganh::database::DFT_bstring,offsetof(SchematicGroup,mName),64,1); uint64 count = mGroupCount = mGroupLoadCount = static_cast<uint32>(result->getRowCount()); mSchematicGroupList.reserve((uint32)count); for(uint64 i = 0; i < count; i++) { scGroup = new SchematicGroup(); result->getNextRow(binding,scGroup); mSchematicGroupList.push_back(scGroup); } mDatabase->destroyDataBinding(binding); ScMAsyncContainer* asContainer; DLOG(info) << "Started Loading Schematics"; asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_GroupSchematics); mDatabase->executeSqlAsync(this,asContainer,"SELECT object_string,weightsbatch_id,complexity,datasize,subCategory,craftEnabled,group_id FROM %s.draft_schematics",mDatabase->galaxy()); } break; case ScMQuery_GroupSchematics: { DraftSchematic* schematic = NULL; swganh::database::DataBinding* binding = mDatabase->createDataBinding(7); binding->addField(swganh::database::DFT_bstring,offsetof(DraftSchematic,mModel),128,0); binding->addField(swganh::database::DFT_uint32,offsetof(DraftSchematic,mWeightsBatchId),4,1); binding->addField(swganh::database::DFT_uint32,offsetof(DraftSchematic,mComplexity),4,2); binding->addField(swganh::database::DFT_uint32,offsetof(DraftSchematic,mDataSize),4,3); binding->addField(swganh::database::DFT_uint32,offsetof(DraftSchematic,mSubCategory),4,4); binding->addField(swganh::database::DFT_uint8,offsetof(DraftSchematic,mCraftEnabled),1,5); binding->addField(swganh::database::DFT_uint32,offsetof(DraftSchematic,mGroupId),4,6); uint64 count = result->getRowCount(); //mSchematicList.reserve((uint32)count); uint32 num = 0; for(uint64 i = 0; i < count; i++) { schematic = new DraftSchematic(); result->getNextRow(binding,schematic); schematic->template_string_ = schematic->mModel.getAnsi(); // gotta get shared_ into the name BStringVector splits; int elements = schematic->mModel.split(splits,'/'); if(elements < 3) { LOG(error) << "Error in Schematic String"; break; } //uint32 size = schematic->mModel.getLength(); schematic->mModel.setLength(256); schematic->mModel = splits[0].getAnsi(); for(int j = 1; j < elements - 1; j++) schematic->mModel << "/" << splits[j].getAnsi(); schematic->mModel << "/shared_" << splits[elements-1].getAnsi(); // glue our ids and insert into maps uint64 schem_crc = schematic->mModel.getCrc(); schematic->setId((schem_crc << 32) | (schematic->mWeightsBatchId)); //added temporary log in order to dump schematic ids for DB insertion //gLogger->log(LogManager::DEBUG,"Schematic,%"PRIu64",%u",schematic->mId,schematic->mWeightsBatchId); //mSchematicList.push_back(schematic); mSchematicList.insert(std::make_pair(schematic->getWeightsBatchId(), schematic)); mSchematicGroupList[schematic->getGroupId()-1]->mSchematics.push_back(schematic); mSchematicSlotMap.insert(std::make_pair(schematic->mModel.getCrc(),schematic)); mSchematicWeightMap.insert(std::make_pair((schematic->mWeightsBatchId ),schematic)); num++; } mSchematicCount += static_cast<uint32>(count); DLOG(info) << "Started Loading Schematic Draft Slots."; // now query the draftslots ScMAsyncContainer* asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicSlots); int8 sql[2048]; sprintf(sql,"SELECT draft_slots.component_file, draft_slots.component_name, draft_slots.resource_name, draft_slots.amount, draft_slots.optional, draft_slots.`type`, draft_schematics.weightsbatch_id" " FROM %s.draft_slots" " INNER JOIN %s.draft_schematics_slots ON (draft_slots.id = draft_schematics_slots.draft_slot_id)" " INNER JOIN %s.schem_crc ON (draft_schematics_slots.schematic_id = schem_crc.crc)" " INNER JOIN %s.draft_schematics ON (schem_crc.object_string = draft_schematics.object_string)", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); mDatabase->executeSqlAsync(this,asContainer,sql); DLOG(info) << "Started Loading Schematic Assembly Batches."; // assemblybatches asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicAssemblyBatches); sprintf(sql,"SELECT draft_assembly_batches.id,draft_assembly_batches.list_id,draft_weights.id" " FROM %s.draft_weights" " INNER JOIN %s.draft_assembly_batches ON (draft_weights.assembly_batch_id = draft_assembly_batches.id)" " ORDER BY draft_weights.id", mDatabase->galaxy(),mDatabase->galaxy()); mDatabase->executeSqlAsync(this,asContainer,sql); DLOG(info) << "Started Loading Schematic Experimentation Batches."; // experimentbatches asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicExperimentBatches); sprintf(sql,"SELECT draft_experiment_batches.id,draft_experiment_batches.list_id,draft_schematics.weightsbatch_id" " FROM %s.draft_weights " " INNER JOIN %s.draft_experiment_batches ON (draft_weights.experiment_batch_id = draft_experiment_batches.id) " " INNER JOIN %s.draft_schematics ON(draft_weights.id = draft_schematics.weightsbatch_id) " " ORDER BY draft_experiment_batches.list_id ", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); mDatabase->executeSqlAsync(this,asContainer,sql); DLOG(info) << "Started Loading Schematic Crafting Batches."; // craftingbatches asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicCraftBatches); sprintf(sql,"SELECT draft_craft_batches.id,draft_craft_batches.list_id,draft_craft_batches.expGroup,draft_schematics.weightsbatch_id" " FROM %s.draft_weights " " INNER JOIN %s.draft_craft_batches ON (draft_weights.craft_batch_id = draft_craft_batches.id) " " INNER JOIN %s.draft_schematics ON(draft_weights.id = draft_schematics.weightsbatch_id) " " ORDER BY draft_craft_batches.list_id ", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); mDatabase->executeSqlAsync(this,asContainer,sql); if(!--mGroupLoadCount) { DLOG(info) << "Finished Loading " << num << " Groups and Schematics out of " << count; } mDatabase->destroyDataBinding(binding); } break; case ScMQuery_SchematicSlots: { DraftSchematic* schematic = NULL;//asyncContainer->mSchematic; DraftSlot* slot; swganh::database::DataBinding* binding = mDatabase->createDataBinding(7); binding->addField(swganh::database::DFT_bstring,offsetof(DraftSlot,mFile),64,0); binding->addField(swganh::database::DFT_bstring,offsetof(DraftSlot,mName),64,1); binding->addField(swganh::database::DFT_bstring,offsetof(DraftSlot,mResourceName),128,2); binding->addField(swganh::database::DFT_uint32,offsetof(DraftSlot,mAmount),4,3); binding->addField(swganh::database::DFT_uint8,offsetof(DraftSlot,mOptional),1,4); binding->addField(swganh::database::DFT_uint8,offsetof(DraftSlot,mType),1,5); binding->addField(swganh::database::DFT_uint32,offsetof(DraftSlot,mSchemWeightBatch),4,6); uint64 count = result->getRowCount(); uint32 num=0; for(uint64 i = 0; i < count; i++) { slot = new DraftSlot(); result->getNextRow(binding,slot); if((schematic == NULL) || (schematic->getWeightsBatchId() != slot->getSchemWeightBatch())) { schematic = getSchematicByWeightID(slot->getSchemWeightBatch()); } if(schematic != NULL) { schematic->mDraftSlots.push_back(slot); num++; } slot->mResourceName.convert(BSTRType_Unicode16); } mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading %u Schematic Draft Slots out of %u.",num,count); } break; case ScMQuery_SchematicAssemblyBatches: { DraftSchematic* schematic = NULL;//asyncContainer->mSchematic; WeightsBatch* batch; swganh::database::DataBinding* binding = mDatabase->createDataBinding(3); binding->addField(swganh::database::DFT_uint32,offsetof(WeightsBatch,mId),4,0); binding->addField(swganh::database::DFT_uint32,offsetof(WeightsBatch,mListId),4,1); binding->addField(swganh::database::DFT_uint32,offsetof(WeightsBatch,mSchemWeightBatch),4,2); uint64 count = result->getRowCount(); uint32 num=0; for(uint64 i = 0; i < count; i++) { batch = new WeightsBatch(); result->getNextRow(binding,batch); if((schematic == NULL) || (schematic->getId() != batch->getSchemWeightBatch())) { schematic = getSchematicByWeightID(batch->getSchemWeightBatch()); } if(schematic != NULL) { schematic->mAssemblyBatch.push_back(batch); num++; } } // query list items ScMAsyncContainer* asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicAssemblyWeights); mDatabase->executeSqlAsync(this,asContainer,"SELECT datatype,distribution,draft_weights.id,draft_assembly_batches.list_id" " FROM %s.draft_assembly_lists" " INNER JOIN %s.draft_assembly_batches ON(draft_assembly_batches.list_id = draft_assembly_lists.id)" " INNER JOIN %s.draft_weights ON(draft_weights.assembly_batch_id = draft_assembly_batches.id)" " ORDER BY draft_weights.id", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); mDatabase->destroyDataBinding(binding); } break; case ScMQuery_SchematicExperimentBatches: { DraftSchematic* schematic = NULL;//asyncContainer->mSchematic; WeightsBatch* batch; swganh::database::DataBinding* binding = mDatabase->createDataBinding(3); binding->addField(swganh::database::DFT_uint32,offsetof(WeightsBatch,mId),4,0); binding->addField(swganh::database::DFT_uint32,offsetof(WeightsBatch,mListId),4,1); binding->addField(swganh::database::DFT_uint32,offsetof(WeightsBatch,mSchemWeightBatch),4,2); uint64 count = result->getRowCount(); uint32 num=0; for(uint64 i = 0; i < count; i++) { batch = new WeightsBatch(); result->getNextRow(binding,batch); if((schematic == NULL) || (schematic->getId() != batch->getSchemWeightBatch())) { schematic = getSchematicByWeightID(batch->getSchemWeightBatch()); } if(schematic != NULL) { schematic->mExperimentBatch.push_back(batch); num++; } } // query list items ScMAsyncContainer* asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicExperimentWeights); mDatabase->executeSqlAsync(this,asContainer,"SELECT datatype,distribution,draft_weights.id,draft_experiment_batches.list_id " " FROM %s.draft_experiment_lists " " INNER JOIN %s.draft_experiment_batches ON(draft_experiment_batches.list_id = draft_experiment_lists.id)" " INNER JOIN %s.draft_weights ON (draft_weights.experiment_batch_id = draft_experiment_batches.id)" " ORDER BY draft_weights.id", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); mDatabase->destroyDataBinding(binding); } break; case ScMQuery_SchematicCraftBatches: { DraftSchematic* schematic = NULL;//asyncContainer->mSchematic; CraftBatch* batch; swganh::database::DataBinding* binding = mDatabase->createDataBinding(4); binding->addField(swganh::database::DFT_uint32,offsetof(CraftBatch,mId),4,0); binding->addField(swganh::database::DFT_uint32,offsetof(CraftBatch,mListId),4,1); binding->addField(swganh::database::DFT_uint32,offsetof(CraftBatch,mExpGroup),4,2); binding->addField(swganh::database::DFT_uint32,offsetof(CraftBatch,mSchemWeightBatch),4,3); uint64 count = result->getRowCount(); uint32 num=0; for(uint64 i = 0; i < count; i++) { batch = new CraftBatch(); result->getNextRow(binding,batch); if((schematic == NULL) || (schematic->getId() != batch->getSchemWeightBatch())) { schematic = getSchematicByWeightID(batch->getSchemWeightBatch()); } if(schematic != NULL) { schematic->mCraftBatch.push_back(batch); num++; } } // query weight distribution ScMAsyncContainer* asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicCraftWeights); mDatabase->executeSqlAsync(this,asContainer,"SELECT type,distribution,draft_weights.id,draft_craft_batches.list_id " " FROM %s.draft_craft_attribute_weights" " INNER JOIN %s.draft_craft_batches ON(draft_craft_attribute_weights.id = draft_craft_batches.list_id)" " INNER JOIN %s.draft_weights ON(draft_weights.craft_batch_id = draft_craft_batches.id)" " ORDER BY draft_weights.id", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); // query attribute links and ranges asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicCraftAttributeLinks); mDatabase->executeSqlAsync(this,asContainer, "SELECT attributes.name,dcial.item_attribute,dcial.attribute_min,dcial.attribute_max,dcial.attribute_type,draft_craft_batches.id,dcial.list_id " " FROM %s.draft_craft_item_attribute_link as dcial" " INNER JOIN %s.attributes ON (dcial.item_attribute = attributes.id)" " INNER JOIN %s.draft_craft_batches ON(dcial.list_id = draft_craft_batches.list_id)" " ORDER BY draft_craft_batches.id", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); // query attribute weighting for component crafting asContainer = new(mDBAsyncPool.ordered_malloc()) ScMAsyncContainer(ScMQuery_SchematicCraftAttributeWeights); //gLogger->log(LogManager::DEBUG,"Started Loading Schematic Craft Attribute Weights."); mDatabase->executeSqlAsync(this,asContainer, "SELECT dsam.Attribute, dsam.AffectedAttribute, dsam.Manipulation, a.name, b.name,draft_schematics.weightsbatch_id " " FROM %s.draft_schematic_attribute_manipulation as dsam" " INNER JOIN %s.attributes as a ON (dsam.attribute = a.id)" " INNER JOIN %s.attributes as b ON (dsam.affectedattribute = b.id)" " INNER JOIN %s.draft_schematics ON(dsam.Draft_Schematic = draft_schematics.weightsbatch_id)", mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy(),mDatabase->galaxy()); mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading %u Schematic Crafting Batches out of %u.",num,count); } break; case ScMQuery_SchematicCraftAttributeWeights: { // "SELECT dsam.Attribute, dsam.AffectedAttribute, dsam.Manipulation, a.name, b.name " DraftSchematic* schematic = NULL;//asyncContainer->mSchematic; CraftAttributeWeight* craftAttributeWeight; swganh::database::DataBinding* binding = mDatabase->createDataBinding(6); binding->addField(swganh::database::DFT_uint32,offsetof(CraftAttributeWeight,mAttributeId),4,0); binding->addField(swganh::database::DFT_uint32,offsetof(CraftAttributeWeight,mAffectedAttributeId),4,1); binding->addField(swganh::database::DFT_uint32,offsetof(CraftAttributeWeight,mManipulation),4,2); binding->addField(swganh::database::DFT_stdstring,offsetof(CraftAttributeWeight,mAttributeKey),255,3); binding->addField(swganh::database::DFT_stdstring,offsetof(CraftAttributeWeight,mAffectedAttributeKey),255,4); binding->addField(swganh::database::DFT_uint32,offsetof(CraftAttributeWeight,mSchemWeightBatch),4,5); uint64 count = result->getRowCount(); uint32 num = 0; for(uint64 i = 0; i < count; i++) { craftAttributeWeight = new CraftAttributeWeight(); result->getNextRow(binding,craftAttributeWeight); if((schematic == NULL) || (schematic->getId() != craftAttributeWeight->getSchemWeightBatch())) { schematic = getSchematicByWeightID(craftAttributeWeight->getSchemWeightBatch()); } if(schematic != NULL) { //CraftBatch* batch = schematic->getCraftBatchByListId(asyncContainer->mBatchId); schematic->mAttributeWeights.push_back(craftAttributeWeight); num++; } } mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading %u Schematic Craft Attribute Weights out of %u",num,count); } break; case ScMQuery_SchematicCraftAttributeLinks: { DraftSchematic* schematic = NULL;//asyncContainer->mSchematic; CraftAttribute* craftAttribute; swganh::database::DataBinding* binding = mDatabase->createDataBinding(7); binding->addField(swganh::database::DFT_stdstring,offsetof(CraftAttribute,mAttributeKey),255,0); binding->addField(swganh::database::DFT_uint32,offsetof(CraftAttribute,mAttributeId),4,1); binding->addField(swganh::database::DFT_float,offsetof(CraftAttribute,mMin),4,2); binding->addField(swganh::database::DFT_float,offsetof(CraftAttribute,mMax),4,3); binding->addField(swganh::database::DFT_uint8,offsetof(CraftAttribute,mType),1,4); binding->addField(swganh::database::DFT_uint32,offsetof(CraftAttribute,mSchemWeightBatch),4,5); binding->addField(swganh::database::DFT_uint32,offsetof(CraftAttribute,mListId),4,6); uint64 count = result->getRowCount(); uint32 num = 0; for(uint64 i = 0; i < count; i++) { craftAttribute = new CraftAttribute(); result->getNextRow(binding,craftAttribute); if((schematic == NULL) || (schematic->getId() != craftAttribute->getSchemWeightBatch())) { schematic = getSchematicByWeightID(craftAttribute->getSchemWeightBatch()); } if(schematic != NULL) { CraftBatch* batch = schematic->getCraftBatchByListId(craftAttribute->getListId()); if(batch != NULL) { batch->mAttributes.push_back(craftAttribute); num++; } } } mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading %u Schematic Craft Attribute Links out of %u",num,count); } break; case ScMQuery_SchematicCraftWeights: { DraftSchematic* schematic = NULL;//asyncContainer->mSchematic; CraftWeight* weight; swganh::database::DataBinding* binding = mDatabase->createDataBinding(4); binding->addField(swganh::database::DFT_uint8,offsetof(CraftWeight,mDataType),1,0); binding->addField(swganh::database::DFT_float,offsetof(CraftWeight,mDistribution),4,1); binding->addField(swganh::database::DFT_uint32,offsetof(CraftWeight,mSchemWeightBatch),4,2); binding->addField(swganh::database::DFT_uint32,offsetof(CraftWeight,mBatchListId),4,3); uint64 count = result->getRowCount(); uint32 num = 0; for(uint64 i = 0; i < count; i++) { weight = new CraftWeight(); result->getNextRow(binding,weight); if((schematic == NULL) || (schematic->getId() != weight->getSchemWeightBatch())) { schematic = getSchematicByWeightID(weight->getSchemWeightBatch()); } if(schematic != NULL) { CraftBatch* batch = schematic->getCraftBatchByListId(weight->getBatchListId()); if(batch != NULL) { batch->mWeights.push_back(weight); num++; } } } mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading %u Schematic Craft Weights out of %u.",num,count); } break; case ScMQuery_SchematicAssemblyWeights: { DraftSchematic* schematic = NULL; DraftWeight* weight; swganh::database::DataBinding* binding = mDatabase->createDataBinding(4); binding->addField(swganh::database::DFT_uint8,offsetof(DraftWeight,mDataType),1,0); binding->addField(swganh::database::DFT_uint8,offsetof(DraftWeight,mDistribution),1,1); binding->addField(swganh::database::DFT_uint32,offsetof(DraftWeight,mSchemWeightBatch),4,2); binding->addField(swganh::database::DFT_uint32,offsetof(DraftWeight,mBatchListId),4,3); uint64 count = result->getRowCount(); uint32 num = 0; for(uint64 i = 0; i < count; i++) { weight = new DraftWeight(); result->getNextRow(binding,weight); weight->prepareData(); if((schematic == NULL) || (schematic->getId() != weight->getSchemWeightBatch())) { schematic = getSchematicByWeightID(weight->getSchemWeightBatch()); } if(schematic != NULL) { WeightsBatch* batch = schematic->getAssemblyWeightsBatchByListId(weight->getBatchListId()); if(batch != NULL) { batch->mWeights.push_back(weight); num++; } } } mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading %u Schematic Assembly Weights out of %u",num,count); } break; case ScMQuery_SchematicExperimentWeights: { DraftSchematic* schematic = NULL; DraftWeight* weight; swganh::database::DataBinding* binding = mDatabase->createDataBinding(4); binding->addField(swganh::database::DFT_uint8,offsetof(DraftWeight,mDataType),1,0); binding->addField(swganh::database::DFT_uint8,offsetof(DraftWeight,mDistribution),1,1); binding->addField(swganh::database::DFT_uint32,offsetof(DraftWeight,mSchemWeightBatch),4,2); binding->addField(swganh::database::DFT_uint32,offsetof(DraftWeight,mBatchListId),4,3); uint64 count = result->getRowCount(); uint32 num = 0; for(uint64 i = 0; i < count; i++) { weight = new DraftWeight(); result->getNextRow(binding,weight); weight->prepareData(); if((schematic == NULL) || (schematic->getWeightsBatchId() != weight->getSchemWeightBatch())) { schematic = getSchematicByWeightID(weight->getSchemWeightBatch()); } if(schematic != NULL) { WeightsBatch* batch = schematic->getExperimentWeightsBatchByListId(weight->getBatchListId()); if(batch != NULL) { batch->mWeights.push_back(weight); num++; } } } mDatabase->destroyDataBinding(binding); //gLogger->log(LogManager::DEBUG,"Finished Loading %u Schematic Experimentation Weights out of %u",num,count); } break; default: break; } mDBAsyncPool.ordered_free(asyncContainer); }
int CraftingSessionImplementation::startSession() { // crafter and craftingTool locked already in initializeSession ManagedReference<CraftingTool*> craftingTool = this->craftingTool.get(); ManagedReference<CreatureObject*> crafter = this->crafter.get(); ManagedReference<PlayerObject*> crafterGhost = this->crafterGhost.get(); ManagedReference<CraftingStation*> craftingStation = this->craftingStation.get(); if(crafter == NULL || craftingTool == NULL || crafterGhost == NULL) { cancelSession(); return false; } /// Get current allowed complexity ManagedReference<PlayerObject*> playerObject = crafter->getPlayerObject(); int complexityLevel = craftingTool->getComplexityLevel(); if (craftingStation != NULL) complexityLevel = craftingStation->getComplexityLevel(); /// Get filtered schematic list based on tool type and complexity currentSchematicList.removeAll(); currentSchematicList = playerObject->filterSchematicList(crafter, craftingTool->getToolTabs(), complexityLevel); /// DPlay9 *********************************** PlayerObjectDeltaMessage9* dplay9 = new PlayerObjectDeltaMessage9(playerObject); dplay9->setExperimentationEnabled(craftingStation != NULL); dplay9->setCraftingState(1); if (craftingStation != NULL) dplay9->setClosestCraftingStation(craftingStation->getObjectID()); else dplay9->setClosestCraftingStation(0); dplay9->setExperimentationPoints(experimentationPointsTotal); dplay9->close(); crafter->sendMessage(dplay9); // End dplay9*********************************** /// Object Controller Message 102 - Schematic List ObjectControllerMessage* ocm = new ObjectControllerMessage( crafter->getObjectID(), 0x0B, 0x102); ocm->insertLong(craftingTool->getObjectID()); if (craftingStation != NULL) ocm->insertLong(craftingStation->getObjectID()); else ocm->insertLong(0); ocm->insertInt(currentSchematicList.size()); for (int i = 0; i < currentSchematicList.size(); ++i) { DraftSchematic* draftSchematic = currentSchematicList.get(i).get(); ocm->insertInt(draftSchematic->getClientObjectCRC()); ocm->insertInt(draftSchematic->getClientObjectCRC()); ocm->insertInt(draftSchematic->getToolTab()); // this number decides what tab the schematic goes in (ex: 4 = food tab in crafting window) } crafter->sendMessage(ocm); /// *********************************************** /// Reset session state state = 1; if(crafterGhost != NULL && crafterGhost->getDebug()) { crafter->sendSystemMessage("*** Starting new crafting session ***"); } return true; }
void CraftingSessionImplementation::selectDraftSchematic(int index) { ManagedReference<CreatureObject*> crafter = this->crafter.get(); ManagedReference<PlayerObject*> crafterGhost = this->crafterGhost.get(); ManagedReference<CraftingTool*> craftingTool = this->craftingTool.get(); if (index >= currentSchematicList.size()) { crafter->sendSystemMessage("Invalid Schematic Index"); closeCraftingWindow(1); cancelSession(); return; } DraftSchematic* draftschematic = currentSchematicList.get(index); if (draftschematic == NULL) { crafter->sendSystemMessage("@ui_craft:err_no_draft_schematic"); closeCraftingWindow(1); cancelSession(); return; } clearSession(); Locker slocker(_this.get()); if(crafterGhost != NULL && crafterGhost->getDebug()) { crafter->sendSystemMessage("Selected DraftSchematic: " + draftschematic->getCustomName()); } state = 2; if (craftingTool != NULL) { Locker locker(craftingTool); if (createSessionObjects(draftschematic)) { if (prototype == NULL) { crafter->sendSystemMessage("@ui_craft:err_no_prototype"); closeCraftingWindow(1); cancelSession(); return; } // Dplay9 ******************************************************** // Sets the Crafting state to 2, which is the Resource screen PlayerObjectDeltaMessage9* dplay9 = new PlayerObjectDeltaMessage9( crafter->getPlayerObject()); dplay9->setExperimentationPoints(0xFFFFFFFF); dplay9->setCraftingState(2); dplay9->close(); crafter->sendMessage(dplay9); // End Dplay9 ***************************************************** } else { crafter->sendSystemMessage("This type of object has not yet been implemented"); } } else { crafter->sendSystemMessage("@ui_craft:err_no_crafting_tool"); closeCraftingWindow(1); cancelSession(); } }
bool MessageLib::sendBaselinesMSCO_3(ManufacturingSchematic* manSchem,PlayerObject* playerObject,bool sendAttributes) { if(!(playerObject->isConnected())) return(false); Message* message; Message* part; DraftSchematic* draftSchematic = gSchematicManager->getSchematicBySlotId(manSchem->getDynamicInt32()); AttributeMap* attributes = manSchem->getAttributeMap(); AttributeMap::iterator it = attributes->begin(); uint32 attByteCount = 0; if(sendAttributes) { while(it != attributes->end()) { attByteCount += 21 + gWorldManager->getAttributeKey((*it).first).getLength(); ++it; } } if(!draftSchematic) return(false); string convPlayerName = playerObject->getFirstName(); string convCustomName = manSchem->getCustomName(); convPlayerName.convert(BSTRType_Unicode16); convCustomName.convert(BSTRType_Unicode16); mMessageFactory->StartMessage(); //object count mMessageFactory->addUint16(13); //0 mMessageFactory->addFloat(static_cast<float>(draftSchematic->getComplexity())); //1 mMessageFactory->addString(manSchem->getNameFile()); mMessageFactory->addUint32(0); mMessageFactory->addString(manSchem->getName()); //2 mMessageFactory->addString(convCustomName); //3 = volume mMessageFactory->addUint32(1); //4 = schematic quantity used with schematics with limited uses mMessageFactory->addUint32(1); //5 // send attributes on baseline so that they are shown on assembly //cave review update counter if(sendAttributes) { manSchem->mAttributesUpdateCounter = attributes->size(); mMessageFactory->addUint32(attributes->size()); mMessageFactory->addUint32(manSchem->mAttributesUpdateCounter); it = attributes->begin(); while(it != attributes->end()) { mMessageFactory->addUint8(0); mMessageFactory->addString(BString("crafting")); mMessageFactory->addUint32(0); mMessageFactory->addString(gWorldManager->getAttributeKey((*it).first)); //=============================0 // see whether the attribute has any component values which need adding in the preview if(manSchem->hasPPAttribute(gWorldManager->getAttributeKey((*it).first))) { float attributeValue = boost::lexical_cast<float,std::string>((*it).second); float attributeAddValue = manSchem->getPPAttribute<float>(gWorldManager->getAttributeKey((*it).first)); gLogger->logMsgF("MessageLib::sendBaselinesMSCO_3 Attribute Add Value",MSG_NORMAL); gLogger->logMsgF("MessageLib::sendBaselinesMSCO_3 we will add %f to %S",MSG_NORMAL,attributeAddValue,gWorldManager->getAttributeKey((*it).first).getAnsi()); mMessageFactory->addFloat(attributeValue+attributeAddValue); } else mMessageFactory->addFloat(boost::lexical_cast<float,std::string>((*it).second)); ++it; } } else { mMessageFactory->addUint32(0); mMessageFactory->addUint32(0); } //6 creators name mMessageFactory->addString(convPlayerName); //7 complexity mMessageFactory->addUint32(static_cast<uint32>(manSchem->getComplexity())); // schematic data size mMessageFactory->addUint32(1); part = mMessageFactory->EndMessage(); mMessageFactory->StartMessage(); mMessageFactory->addUint32(opBaselinesMessage); mMessageFactory->addUint64(manSchem->getId()); mMessageFactory->addUint32(opMSCO); mMessageFactory->addUint8(3); mMessageFactory->addUint32(part->getSize()); mMessageFactory->addData(part->getData(),part->getSize()); message = mMessageFactory->EndMessage(); part->setPendingDelete(true); (playerObject->getClient())->SendChannelA(message,playerObject->getAccountId(),CR_Client,5); return(true); }