mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
good enough
the client code for this is a mess and should load everything at once or use non race condition code
This commit is contained in:
@@ -1141,6 +1141,25 @@ void InventoryComponent::AddItemSkills(const LOT lot) {
|
||||
SetSkill(slot, skill);
|
||||
}
|
||||
|
||||
void InventoryComponent::FixInvisibleItems() {
|
||||
const auto numberItemsLoadedPerFrame = 12.0f;
|
||||
const auto callbackTime = 0.125f;
|
||||
const auto arbitaryInventorySize = 300.0f; // max in live + dlu is less than 300, seems like a good number.
|
||||
auto* const items = GetInventory(eInventoryType::ITEMS);
|
||||
if (!items) return;
|
||||
|
||||
// Add an extra update to make sure the client can see all the items.
|
||||
const auto something = static_cast<int32_t>(std::ceil(items->GetItems().size() / arbitaryInventorySize)) + 1;
|
||||
LOG_DEBUG("Fixing invisible items with %i updates", something);
|
||||
|
||||
for (int32_t i = 1; i < something + 1; i++) {
|
||||
// client loads 12 items every 1/8 seconds, we're adding a small hack to fix invisible inventory items due to closing the news screen too fast.
|
||||
m_Parent->AddCallbackTimer((arbitaryInventorySize / numberItemsLoadedPerFrame) * callbackTime * i, [this]() {
|
||||
GameMessages::SendUpdateInventoryUi(m_Parent->GetObjectID(), m_Parent->GetSystemAddress());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
const auto info = Inventory::FindItemComponent(lot);
|
||||
|
||||
|
Reference in New Issue
Block a user