From a32c5a2f3c2cfac1234931fcd21a94d5325f9ebb Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 13 Apr 2022 01:49:55 -0700 Subject: [PATCH] Vault corrections --- dGame/Entity.cpp | 12 ++++++++++++ dGame/Entity.h | 6 +++++- dGame/UserManager.cpp | 2 +- dGame/dComponents/InventoryComponent.cpp | 1 + dGame/dMission/Mission.cpp | 4 +++- dWorldServer/WorldServer.cpp | 2 ++ 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index bca7ffa2..57b7af14 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -2173,3 +2173,15 @@ void Entity::AddToGroup(const std::string& group) { m_Groups.push_back(group); } } + +void Entity::RetroactiveVaultSize() { + auto inventoryComponent = GetComponent(); + if (!inventoryComponent) return; + + auto itemsVault = inventoryComponent->GetInventory(eInventoryType::VAULT_ITEMS); + auto modelVault = inventoryComponent->GetInventory(eInventoryType::VAULT_MODELS); + + if (itemsVault->GetSize() == modelVault->GetSize()) return; + + modelVault->SetSize(itemsVault->GetSize()); +} diff --git a/dGame/Entity.h b/dGame/Entity.h index 31b2b303..cef7b97f 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -220,7 +220,11 @@ public: /* * Utility */ - + /** + * Retroactively corrects the model vault size due to incorrect initialization in a previous patch. + * + */ + void RetroactiveVaultSize(); bool GetBoolean(const std::u16string& name) const; int32_t GetI32(const std::u16string& name) const; int64_t GetI64(const std::u16string& name) const; diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index adae72b0..1d14cb0a 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -291,7 +291,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) xml << "ls=\"0\" lzx=\"-626.5847\" lzy=\"613.3515\" lzz=\"-28.6374\" lzrx=\"0.0\" lzry=\"0.7015\" lzrz=\"0.0\" lzrw=\"0.7126\" "; xml << "stt=\"0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;\">"; xml << ""; - xml << ""; + xml << ""; std::string xmlSave1 = xml.str(); ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforshirt) { diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 63080b2d..5d3dda2e 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -84,6 +84,7 @@ Inventory* InventoryComponent::GetInventory(const eInventoryType type) case eInventoryType::ITEMS: size = 20u; break; + case eInventoryType::VAULT_MODELS: case eInventoryType::VAULT_ITEMS: size = 40u; break; diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index f7b57071..14fc5a24 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -511,9 +511,11 @@ void Mission::YieldRewards() { } if (info->reward_bankinventory > 0) { - auto* inventory = inventoryComponent->GetInventory(VAULT_ITEMS); + auto* inventory = inventoryComponent->GetInventory(eInventoryType::VAULT_ITEMS); + auto modelInventory = inventoryComponent->GetInventory(eInventoryType::VAULT_MODELS); inventory->SetSize(inventory->GetSize() + info->reward_bankinventory); + modelInventory->SetSize(modelInventory->GetSize() + info->reward_bankinventory); } if (info->reward_reputation > 0) { diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index a4056de9..9d0c84cc 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -975,6 +975,8 @@ void HandlePacket(Packet* packet) { player->GetComponent()->SetLastRocketConfig(u""); c->SetRetroactiveFlags(); + + player->RetroactiveVaultSize(); player->GetCharacter()->SetTargetScene("");