void HarvesterFactory::handleObjectReady(Object* object,DispatchClient* client) { //*ONLY* used to load resource containers //never used .... InLoadingContainer* ilc = _getObject(object->getParentId()); if (! ilc) {//ILC sanity check... LOG(warning) << "Could not locate InLoadingContainer for object parent [" << object->getParentId() << "]"; return; } HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(ilc->mObject); //add res containers gWorldManager->addObject(object,true); if(harvester->decLoadCount() == 0) { if(!(_removeFromObjectLoadMap(harvester->getId()))) LOG(warning) << "Failed removing object from loadmap"; ilc->mOfCallback->handleObjectReady(harvester,ilc->mClient); mILCPool.free(ilc); } }
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()); }
int VetHarvesterDeedImplementation::useObject(CreatureObject* creature) { ManagedReference<PlayerObject*> ghost = creature->getPlayerObject(); ZoneServer *zone = creature->getZoneServer(); if(ghost == NULL || zone == NULL) return 0; if (!isASubChildOf(creature)) return 0; uint64 targetID = creature->getTargetID(); ManagedReference<TangibleObject*> targetObject = zone->getObject(targetID).castTo<TangibleObject*>(); if (targetObject == NULL || !targetObject->isHarvesterObject()) return 0; HarvesterObject *harvester = targetObject.castTo<HarvesterObject*>(); if(harvester == NULL || !harvester->isOwnerOf(creature)) return 0; if(harvester->isSelfPowered()) { creature->sendSystemMessage("@veteran:harvester_already_selfpowered"); return 0; } StringIdChatParameter messageBody("veteran", "harvester_converted"); // Your harvester %TT has been converted to use 0 power. messageBody.setTT(harvester); ManagedReference<ChatManager*> cman = zone->getChatManager(); cman->sendMail("system", "@veteran:harvester_converted_subject", messageBody, creature->getFirstName()); EXECUTE_TASK_1(harvester, { Locker locker(harvester_p); harvester_p->setSelfPowered(true); });
//====================================================================================================================== // // Selects the resource for extraction // void ObjectController::_handleHarvesterSelectResource(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) { DLOG(info) << " ObjectController::_handleHarvesterSelectResource Structure not in Range"; return; } HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(structure); //get the relevant Resource BString dataStr; message->getStringUnicode16(dataStr); uint64 resourceId; swscanf(dataStr.getUnicode16(),L"%"WidePRIu64,&resourceId); Resource* tmpResource = gResourceManager->getResourceById(resourceId); if((!tmpResource)||(!tmpResource->getCurrent())) { DLOG(info) << " ObjectController::_handleHarvesterSelectResource No valid resource!"; return; } harvester->setCurrentResource(resourceId); // update the current resource in the db mDatabase->executeSqlAsync(0,0,"UPDATE %s.harvesters SET ResourceID=%"PRIu64" WHERE id=%"PRIu64" ",mDatabase->galaxy(),resourceId,harvester->getId()); CurrentResource* cR = reinterpret_cast<CurrentResource*>(tmpResource); //resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc())); float posX, posZ; float ratio = 0.0; posX = harvester->mPosition.x; posZ = harvester->mPosition.z; if(cR) { ratio = cR->getDistribution((int)posX + 8192,(int)posZ + 8192); if(ratio > 1.0) { ratio = 1.0; } } float ber = harvester->getSpecExtraction(); harvester->setCurrentExtractionRate(ber*ratio); // now enter the new resource in the hoppers resource list if its isnt already in there // TODO keep the list up to date by removing unnecessary resources // to this end read the list anew and delete every resource with zero amount // have a stored function do this if(!harvester->checkResourceList(resourceId)) { //do *not* add to list - otherwise we get a racecondition with the asynch update from db !!! //harvester->getResourceList()->push_back(std::make_pair(resourceId,float(0.0))); //add to db mDatabase->executeSqlAsync(0,0,"INSERT INTO %s.harvester_resources VALUES(%"PRIu64",%"PRIu64",0,0)",mDatabase->galaxy(),harvester->getId(),resourceId); } // update the current extractionrate in the db for the stored procedure handling the harvesting mDatabase->executeSqlAsync(0,0,"UPDATE %s.harvesters SET rate=%f WHERE id=%"PRIu64" ",mDatabase->galaxy(),(ber*ratio),harvester->getId()); //now send the updates gMessageLib->sendCurrentResourceUpdate(harvester,player); gMessageLib->sendCurrentExtractionRate(harvester,player); }
void HarvesterFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result) { QueryContainerBase* asyncContainer = reinterpret_cast<QueryContainerBase*>(ref); switch(asyncContainer->mQueryType) { case HFQuery_ResourceData: { uint32 count = (uint32)result->getRowCount(); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(asyncContainer->mObject); if(count) { DataBinding* binding = mDatabase->createDataBinding(2); binding->addField(DFT_uint64,offsetof(HarvesterHopperItem,ResourceID),8,0); binding->addField(DFT_float,offsetof(HarvesterHopperItem,Quantity),4,1); HResourceList* hRList = harvester->getResourceList(); hRList->resize(hRList->size()+count); HarvesterHopperItem hopperTemp; for(uint64 i=0; i <count; i++) { result->getNextRow(binding,&hopperTemp); hRList->push_back(std::make_pair(hopperTemp.ResourceID,hopperTemp.Quantity)); } } QueryContainerBase* asynContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,HFQuery_AttributeData,asyncContainer->mClient,asyncContainer->mId); asynContainer->mId = harvester->getId(); asynContainer->mObject = harvester; mDatabase->executeSqlAsync(this,asynContainer,"SELECT attributes.name,sa.value,attributes.internal" " FROM %s.structure_attributes sa" " INNER JOIN %s.attributes ON (sa.attribute_id = attributes.id)" " WHERE sa.structure_id = %" PRIu64 " ORDER BY sa.order", mDatabase->galaxy(),mDatabase->galaxy(),harvester->getId()); } break; case HFQuery_AttributeData: { HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(asyncContainer->mObject); //_buildAttributeMap(harvester,result); Attribute_QueryContainer attribute; uint64 count = result->getRowCount(); //int8 str[256]; //BStringVector dataElements; for(uint64 i = 0; i < count; i++) { result->getNextRow(mAttributeBinding,(void*)&attribute); harvester->addInternalAttribute(attribute.mKey,std::string(attribute.mValue.getAnsi())); } harvester->setLoadState(LoadState_Loaded); LOG(info) << "Loaded harvester with id [" << harvester->getId() << "]"; asyncContainer->mOfCallback->handleObjectReady(harvester,asyncContainer->mClient); } break; case HFQuery_MainData: { QueryContainerBase* asynContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,HFQuery_ResourceData,asyncContainer->mClient,asyncContainer->mId); HarvesterObject* harvester = new(HarvesterObject); _createHarvester(result,harvester); asynContainer->mObject = harvester; asynContainer->mClient = asyncContainer->mClient; //asyncContainer->mOfCallback->handleObjectReady(harvester,asyncContainer->mClient); //now request the associated resource container count int8 sql[250]; sprintf(sql,"SELECT hr.resourceID, hr.quantity FROM %s.harvester_resources hr WHERE hr.ID = '%" PRIu64 "' ",mDatabase->galaxy(),harvester->getId()); mDatabase->executeSqlAsync(this,asynContainer,sql); } break; default: break; } mQueryContainerPool.free(asyncContainer); }
void HarvesterFactory::handleDatabaseJobComplete(void* ref,swganh::database::DatabaseResult* result) { QueryContainerBase* asyncContainer = reinterpret_cast<QueryContainerBase*>(ref); switch(asyncContainer->mQueryType) { case HFQuery_ResourceData: { uint32 count = (uint32)result->getRowCount(); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(asyncContainer->mObject); if(count) { swganh::database::DataBinding* binding = mDatabase->createDataBinding(2); binding->addField(swganh::database::DFT_uint64,offsetof(HarvesterHopperItem,ResourceID),8,0); binding->addField(swganh::database::DFT_float,offsetof(HarvesterHopperItem,Quantity),4,1); HResourceList* hRList = harvester->getResourceList(); hRList->resize(hRList->size()+count); HarvesterHopperItem hopperTemp; for(uint64 i=0; i <count; i++) { result->getNextRow(binding,&hopperTemp); hRList->push_back(std::make_pair(hopperTemp.ResourceID,hopperTemp.Quantity)); } } QueryContainerBase* asynContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,HFQuery_AttributeData,asyncContainer->mClient,asyncContainer->mId); asynContainer->mId = harvester->getId(); asynContainer->mObject = harvester; mDatabase->executeSqlAsync(this,asynContainer,"SELECT attributes.name,sa.value,attributes.internal" " FROM %s.structure_attributes sa" " INNER JOIN %s.attributes ON (sa.attribute_id = attributes.id)" " WHERE sa.structure_id = %"PRIu64" ORDER BY sa.order", mDatabase->galaxy(),mDatabase->galaxy(),harvester->getId()); } break; case HFQuery_AttributeData: { HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(asyncContainer->mObject); //_buildAttributeMap(harvester,result); Attribute_QueryContainer attribute; uint64 count = result->getRowCount(); //int8 str[256]; //BStringVector dataElements; for(uint64 i = 0; i < count; i++) { result->getNextRow(mAttributeBinding,(void*)&attribute); harvester->addInternalAttribute(BString(attribute.mKey.c_str()),attribute.mValue); } QueryContainerBase* asynContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,HFQuery_AdminData,asyncContainer->mClient,asyncContainer->mId); asynContainer->mId = harvester->getId(); asynContainer->mObject = harvester; std::stringstream sql; sql << "SELECT sad.PlayerID, sad.AdminType, c.firstname FROM " << mDatabase->galaxy() << ".structure_admin_data sad INNER JOIN " << mDatabase->galaxy() << ".characters c ON (c.id = sad.PlayerID) WHERE StructureID = " << harvester->getId() << ";"; mDatabase->executeSqlAsync(this, asynContainer, sql.str()); } break; case HFQuery_AdminData: { HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(asyncContainer->mObject); std::unique_ptr<sql::ResultSet>& result_set = result->getResultSet(); while (result_set->next()) { std::string type = result_set->getString(2); if(type == "ADMIN") { harvester->admin_data_.admin_add_(result_set->getInt64(1), result_set->getString(3)); LOG(info) << " added Admin to harvester : " << harvester->getId(); } else if(type == "BAN") { harvester->admin_data_.ban_add_(result_set->getInt64(1), result_set->getString(3)); LOG(info) << " added ban to harvester : " << harvester->getId(); } else if(type == "ENTRY") { harvester->admin_data_.entry_add_(result_set->getInt64(1), result_set->getString(3)); LOG(info) << " added entry to harvester : " << harvester->getId(); } else if(type == "HOPPER") { harvester->admin_data_.entry_add_(result_set->getInt64(1), result_set->getString(3)); LOG(info) << " added entry to harvester : " << harvester->getId(); } } harvester->admin_data_.structure_id_ = harvester->getId(); harvester->admin_data_.owner_id_ = harvester->getOwner(); harvester->setLoadState(LoadState_Loaded); LOG(info) << "Loaded harvester with id [" << harvester->getId() << "]"; asyncContainer->mOfCallback->handleObjectReady(harvester,asyncContainer->mClient); } break; case HFQuery_MainData: { QueryContainerBase* asynContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,HFQuery_ResourceData,asyncContainer->mClient,asyncContainer->mId); HarvesterObject* harvester = new(HarvesterObject); _createHarvester(result,harvester); asynContainer->mObject = harvester; asynContainer->mClient = asyncContainer->mClient; //asyncContainer->mOfCallback->handleObjectReady(harvester,asyncContainer->mClient); //now request the associated resource container count int8 sql[250]; sprintf(sql,"SELECT hr.resourceID, hr.quantity FROM %s.harvester_resources hr WHERE hr.ID = '%"PRIu64"' ",mDatabase->galaxy(),harvester->getId()); mDatabase->executeSqlAsync(this,asynContainer,sql); } break; default: break; } mQueryContainerPool.free(asyncContainer); }
void HarvesterObject::handleDatabaseJobComplete(void* ref,swganh::database::DatabaseResult* result) { StructureManagerAsyncContainer* asynContainer = (StructureManagerAsyncContainer*)ref; switch(asynContainer->mQueryType) { case Structure_ResourceRetrieve: { PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId)); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(gWorldManager->getObjectById(asynContainer->mStructureId)); swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(1); binding->addField(swganh::database::DFT_uint32,0,4); uint64 count; uint32 error; count = result->getRowCount(); if(!count) { assert(false && "HarvesterObject::handleDatabaseJobComplete Structure_ResourceRetrieve did not find any resources"); return; } result->getNextRow(binding,&error); if(error > 0) { //mmh there was something fishy ... no changes db side gMessageLib->sendResourceEmptyHopperResponse(harvester,player,error, asynContainer->command.b1, asynContainer->command.b2); return; } createResourceContainer(asynContainer->command.ResourceId, player, asynContainer->command.Amount); StructureManagerAsyncContainer* asyncContainer = new StructureManagerAsyncContainer(Structure_ResourceDiscardUpdateHopper,player->getClient()); asyncContainer->mStructureId = asynContainer->mStructureId; asyncContainer->mPlayerId = asynContainer->mPlayerId; asyncContainer->command = asynContainer->command; gWorldManager->getKernel()->GetDatabase()->executeSqlAsync(harvester,asyncContainer,"SELECT hr.resourceID, hr.quantity FROM %s.harvester_resources hr WHERE hr.ID = '%"PRIu64"' ",gWorldManager->getKernel()->GetDatabase()->galaxy(), harvester->getId()); } break; case Structure_ResourceDiscard: { PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId)); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(gWorldManager->getObjectById(asynContainer->mStructureId)); swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(1); binding->addField(swganh::database::DFT_uint32,0,4); uint64 count; uint32 error; count = result->getRowCount(); if(!count) { assert(false && "HarvesterObject::handleDatabaseJobComplete Structure_ResourceDiscard did not find resource"); return; } result->getNextRow(binding,&error); if(result > 0) { //mmh there was something fishy ... no changes db side gMessageLib->sendResourceEmptyHopperResponse(harvester,player,error, asynContainer->command.b1, asynContainer->command.b2); return; } StructureManagerAsyncContainer* asyncContainer = new StructureManagerAsyncContainer(Structure_ResourceDiscardUpdateHopper,player->getClient()); asyncContainer->mStructureId = asynContainer->mStructureId; asyncContainer->mPlayerId = asynContainer->mPlayerId; asyncContainer->command = asyncContainer->command; gWorldManager->getKernel()->GetDatabase()->executeSqlAsync(harvester,asyncContainer,"SELECT hr.resourceID, hr.quantity FROM %s.harvester_resources hr WHERE hr.ID = '%"PRIu64"' ",gWorldManager->getKernel()->GetDatabase()->galaxy(),harvester->getId()); } break; case Structure_ResourceDiscardUpdateHopper: { uint64 count = result->getRowCount(); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(gWorldManager->getObjectById(asynContainer->mStructureId)); PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId)); swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(2); binding->addField(swganh::database::DFT_uint64,offsetof(HarvesterHopperItem,ResourceID),8,0); binding->addField(swganh::database::DFT_float,offsetof(HarvesterHopperItem,Quantity),4,1); HResourceList* hRList = harvester->getResourceList(); hRList->clear(); HarvesterHopperItem hopperTemp; for(uint64 i=0; i <count; i++) { result->getNextRow(binding,&hopperTemp); hRList->push_back(std::make_pair(hopperTemp.ResourceID,hopperTemp.Quantity)); } //now send the update to the client gMessageLib->SendHarvesterHopperUpdate(harvester,player); gMessageLib->sendResourceEmptyHopperResponse(harvester,player,0, asynContainer->command.b2, asynContainer->command.b2); gWorldManager->getKernel()->GetDatabase()->destroyDataBinding(binding); } break; case Structure_GetResourceData: { uint64 count = result->getRowCount(); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(gWorldManager->getObjectById(asynContainer->mStructureId)); PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId)); swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(2); binding->addField(swganh::database::DFT_uint64,offsetof(HarvesterHopperItem,ResourceID),8,0); binding->addField(swganh::database::DFT_float,offsetof(HarvesterHopperItem,Quantity),4,1); HResourceList* hRList = harvester->getResourceList(); hRList->clear(); HarvesterHopperItem hopperTemp; for(uint64 i=0; i <count; i++) { result->getNextRow(binding,&hopperTemp); hRList->push_back(std::make_pair(hopperTemp.ResourceID,hopperTemp.Quantity)); } //now send the update to the client gMessageLib->sendHarvesterResourceData(harvester,player); gMessageLib->sendBaselinesHINO_7(harvester,player); gWorldManager->getKernel()->GetDatabase()->destroyDataBinding(binding); } break; //read in the current resource hoppers contents case Structure_HopperUpdate: { uint64 count = result->getRowCount(); HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(gWorldManager->getObjectById(asynContainer->mStructureId)); PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId)); swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(2); binding->addField(swganh::database::DFT_uint64,offsetof(HarvesterHopperItem,ResourceID),8,0); binding->addField(swganh::database::DFT_float,offsetof(HarvesterHopperItem,Quantity),4,1); HResourceList* hRList = harvester->getResourceList(); hRList->clear(); HarvesterHopperItem hopperTemp; for(uint64 i=0; i <count; i++) { result->getNextRow(binding,&hopperTemp); hRList->push_back(std::make_pair(hopperTemp.ResourceID,hopperTemp.Quantity)); } //now send the update to the client gMessageLib->SendHarvesterHopperUpdate(harvester,player); gWorldManager->getKernel()->GetDatabase()->destroyDataBinding(binding); } break; case Structure_HopperDiscard: { //PlayerStructure* structure = dynamic_cast<PlayerStructure*>(gWorldManager->getObjectById(asynContainer->mStructureId)); PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId)); if(!player) { return; } StructureManagerAsyncContainer* asyncContainer = new StructureManagerAsyncContainer(Structure_HopperUpdate,player->getClient()); asyncContainer->mStructureId = this->getId(); asyncContainer->mPlayerId = player->getId(); int8 sql[250]; sprintf(sql,"SELECT hr.resourceID, hr.quantity FROM %s.harvester_resources hr WHERE hr.ID = '%"PRIu64"' ",gWorldManager->getKernel()->GetDatabase()->galaxy(),this->getId()); gWorldManager->getKernel()->GetDatabase()->executeSqlAsync(this,asyncContainer,sql); } break; default: break; } SAFE_DELETE(asynContainer); }
int StructureManager::redeedStructure(CreatureObject* creature) { ManagedReference<DestroyStructureSession*> session = creature->getActiveSession(SessionFacadeType::DESTROYSTRUCTURE).castTo<DestroyStructureSession*>(); if (session == NULL) return 0; ManagedReference<StructureObject*> structureObject = session->getStructureObject(); if (structureObject == NULL) return 0; Locker _locker(structureObject); ManagedReference<StructureDeed*> deed = server->getObject( structureObject->getDeedObjectID()).castTo<StructureDeed*>(); int maint = structureObject->getSurplusMaintenance(); int redeedCost = structureObject->getRedeedCost(); if (deed != NULL && structureObject->isRedeedable()) { Locker _lock(deed, structureObject); ManagedReference<SceneObject*> inventory = creature->getSlottedObject( "inventory"); bool isSelfPoweredHarvester = false; HarvesterObject* harvester = structureObject.castTo<HarvesterObject*>(); if(harvester != NULL) isSelfPoweredHarvester = harvester->isSelfPowered(); if (inventory == NULL || inventory->getCountableObjectsRecursive() > (inventory->getContainerVolumeLimit() - (isSelfPoweredHarvester ? 2 : 1))) { if(isSelfPoweredHarvester) { //This installation can not be destroyed because there is no room for the Self Powered Harvester Kit in your inventory. creature->sendSystemMessage("@player_structure:inventory_full_selfpowered"); } else { //This installation can not be redeeded because your inventory does not have room to put the deed. creature->sendSystemMessage("@player_structure:inventory_full"); } creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED! return session->cancelSession(); } else { if(isSelfPoweredHarvester) { Reference<SceneObject*> rewardSceno = server->createObject(STRING_HASHCODE("object/tangible/veteran_reward/harvester.iff"), 1); if( rewardSceno == NULL ){ creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED! return session->cancelSession(); } // Transfer to player if( !inventory->transferObject(rewardSceno, -1, false, true) ){ // Allow overflow creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED! rewardSceno->destroyObjectFromDatabase(true); return session->cancelSession(); } harvester->setSelfPowered(false); inventory->broadcastObject(rewardSceno, true); creature->sendSystemMessage("@player_structure:selfpowered"); } deed->setSurplusMaintenance(maint - redeedCost); deed->setSurplusPower(structureObject->getSurplusPower()); structureObject->setDeedObjectID(0); //Set this to 0 so the deed doesn't get destroyed with the structure. destroyStructure(structureObject); inventory->transferObject(deed, -1, true); inventory->broadcastObject(deed, true); creature->sendSystemMessage("@player_structure:deed_reclaimed"); //Structure destroyed and deed reclaimed. } } else { destroyStructure(structureObject); creature->sendSystemMessage("@player_structure:structure_destroyed"); //Structured destroyed. } return session->cancelSession(); }