mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-01-11 15:27:07 +00:00
move semantics
This commit is contained in:
parent
43681b4494
commit
96f224c38c
@ -1253,8 +1253,8 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
Game::entityManager->ConstructEntity(pet);
|
||||
}
|
||||
|
||||
void InventoryComponent::SetDatabasePet(LWOOBJID id, const DatabasePet& data) {
|
||||
m_Pets.insert_or_assign(id, data);
|
||||
void InventoryComponent::SetDatabasePet(LWOOBJID id, DatabasePet&& data) {
|
||||
m_Pets.insert_or_assign(id, std::move(data));
|
||||
}
|
||||
|
||||
const DatabasePet& InventoryComponent::GetDatabasePet(LWOOBJID id) const {
|
||||
@ -1580,12 +1580,13 @@ void InventoryComponent::LoadPetXml(const tinyxml2::XMLDocument& document) {
|
||||
petElement->QueryAttribute("m", &moderationStatus);
|
||||
const char* name = petElement->Attribute("n");
|
||||
|
||||
DatabasePet databasePet;
|
||||
databasePet.lot = lot;
|
||||
databasePet.moderationState = moderationStatus;
|
||||
databasePet.name = std::string(name);
|
||||
auto databasePet = DatabasePet{
|
||||
.lot = lot,
|
||||
.name = std::string(name),
|
||||
.moderationState = moderationStatus,
|
||||
};
|
||||
|
||||
SetDatabasePet(id, databasePet);
|
||||
SetDatabasePet(id, std::move(databasePet));
|
||||
|
||||
petElement = petElement->NextSiblingElement();
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public:
|
||||
* @param id the id of the pet to find
|
||||
* @param data the data to store on the pet
|
||||
*/
|
||||
void SetDatabasePet(LWOOBJID id, const DatabasePet& data);
|
||||
void SetDatabasePet(LWOOBJID id, DatabasePet&& data);
|
||||
|
||||
/**
|
||||
* Returns the database pet information for an object
|
||||
|
@ -393,15 +393,12 @@ void PetComponent::NotifyTamingBuildSuccess(const NiPoint3 position) {
|
||||
auto* const inventoryComponent = tamer->GetComponent<InventoryComponent>();
|
||||
if (!inventoryComponent) return;
|
||||
|
||||
LWOOBJID petSubKey = ObjectIDManager::GenerateRandomObjectID();
|
||||
|
||||
auto petSubKey = ObjectIDManager::GenerateRandomObjectID();
|
||||
GeneralUtils::SetBit(petSubKey, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(petSubKey, eObjectBits::PERSISTENT);
|
||||
|
||||
m_DatabaseId = petSubKey;
|
||||
|
||||
std::string petName = tamer->GetCharacter()->GetName();
|
||||
petName += "'s Pet";
|
||||
auto petName = tamer->GetCharacter()->GetName() + "'s Pet";
|
||||
|
||||
GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::UTF8ToUTF16(petName), petSubKey, m_Parent->GetLOT(), tamer->GetSystemAddress());
|
||||
GameMessages::SendRegisterPetID(m_Tamer, m_Parent->GetObjectID(), tamer->GetSystemAddress());
|
||||
@ -412,13 +409,13 @@ void PetComponent::NotifyTamingBuildSuccess(const NiPoint3 position) {
|
||||
auto* const item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS);
|
||||
if (!item) return;
|
||||
|
||||
DatabasePet databasePet{};
|
||||
auto databasePet = DatabasePet{
|
||||
.lot = m_Parent->GetLOT(),
|
||||
.name = std::move(petName),
|
||||
.moderationState = 1,
|
||||
};
|
||||
|
||||
databasePet.lot = m_Parent->GetLOT();
|
||||
databasePet.moderationState = 1;
|
||||
databasePet.name = petName;
|
||||
|
||||
inventoryComponent->SetDatabasePet(petSubKey, databasePet);
|
||||
inventoryComponent->SetDatabasePet(petSubKey, std::move(databasePet));
|
||||
|
||||
Activate(item, false, true);
|
||||
|
||||
@ -1000,7 +997,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) { //
|
||||
databaseData.name = m_Name;
|
||||
databaseData.moderationState = m_ModerationStatus;
|
||||
|
||||
inventoryComponent->SetDatabasePet(m_DatabaseId, databaseData);
|
||||
inventoryComponent->SetDatabasePet(m_DatabaseId, std::move(databaseData));
|
||||
|
||||
updatedModerationStatus = true;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user