void StructureManager::_HandleGetInactiveHarvesters(StructureManagerAsyncContainer* asynContainer,DatabaseResult* result) { struct structData { uint64 id; uint32 condition; }; structData sd; DataBinding* binding = mDatabase->CreateDataBinding(2); binding->addField(DFT_uint64,offsetof(structData,id),8,0); binding->addField(DFT_uint32,offsetof(structData,condition),4,1); uint64 count; count = result->getRowCount(); for(uint64 i = 0;i < count;i++) { result->GetNextRow(binding,&sd); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(gWorldManager->getObjectById(sd.id)); if(harvester) { //if the harvesters status is changed we need to alter it if(harvester->getActive()) { harvester->setActive(false); harvester->setDamage(sd.condition); gMessageLib->sendHarvesterActive(harvester); } //Now update the condition gMessageLib->sendHarvesterCurrentConditionUpdate(harvester); } } mDatabase->DestroyDataBinding(binding); }
void ObjectController::_handleHarvesterDeActivate(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { CreatureObject* creature = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost(); if(!player) { return; } //do we have a valid structure ??? uint64 id = targetId; Object* object = gWorldManager->getObjectById(id); PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object); if(!structure) { //gMessageLib->sendSystemMessage(player,L"","player_structure","command_no_building"); return; } //is the structure in Range??? float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0); if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance) { return; } HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(structure); harvester->setActive(false); //send the respective delta gMessageLib->sendHarvesterActive(harvester); //send the db update mDatabase->executeSqlAsync(0,0,"UPDATE %s.harvesters SET active = 0 WHERE id=%"PRIu64" ",mDatabase->galaxy(),harvester->getId()); }