mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 21:49:55 +00:00
Merchant items should be restocked instantly
This commit is contained in:
parent
1bcc4430e0
commit
fb542a64ec
3 changed files with 19 additions and 10 deletions
|
@ -415,20 +415,11 @@ namespace MWGui
|
||||||
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
|
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
|
||||||
float delay = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getFloat();
|
float delay = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getFloat();
|
||||||
|
|
||||||
|
// Gold is restocked every 24h
|
||||||
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getLastRestockTime() + delay)
|
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getLastRestockTime() + delay)
|
||||||
{
|
{
|
||||||
sellerStats.setGoldPool(mPtr.getClass().getBaseGold(mPtr));
|
sellerStats.setGoldPool(mPtr.getClass().getBaseGold(mPtr));
|
||||||
|
|
||||||
mPtr.getClass().restock(mPtr);
|
|
||||||
|
|
||||||
// Also restock any containers owned by this merchant, which are also available to buy in the trade window
|
|
||||||
std::vector<MWWorld::Ptr> itemSources;
|
|
||||||
MWBase::Environment::get().getWorld()->getContainersOwnedBy(mPtr, itemSources);
|
|
||||||
for (std::vector<MWWorld::Ptr>::iterator it = itemSources.begin(); it != itemSources.end(); ++it)
|
|
||||||
{
|
|
||||||
it->getClass().restock(*it);
|
|
||||||
}
|
|
||||||
|
|
||||||
sellerStats.setLastRestockTime(MWBase::Environment::get().getWorld()->getTimeStamp());
|
sellerStats.setLastRestockTime(MWBase::Environment::get().getWorld()->getTimeStamp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,20 @@ namespace MWGui
|
||||||
setCoord(400, 0, 400, 300);
|
setCoord(400, 0, 400, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TradeWindow::restock()
|
||||||
|
{
|
||||||
|
// Restock items on the actor inventory
|
||||||
|
mPtr.getClass().restock(mPtr);
|
||||||
|
|
||||||
|
// Also restock any containers owned by this merchant, which are also available to buy in the trade window
|
||||||
|
std::vector<MWWorld::Ptr> itemSources;
|
||||||
|
MWBase::Environment::get().getWorld()->getContainersOwnedBy(mPtr, itemSources);
|
||||||
|
for (std::vector<MWWorld::Ptr>::iterator it = itemSources.begin(); it != itemSources.end(); ++it)
|
||||||
|
{
|
||||||
|
it->getClass().restock(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TradeWindow::startTrade(const MWWorld::Ptr& actor)
|
void TradeWindow::startTrade(const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
mPtr = actor;
|
mPtr = actor;
|
||||||
|
@ -101,6 +115,8 @@ namespace MWGui
|
||||||
mCurrentBalance = 0;
|
mCurrentBalance = 0;
|
||||||
mCurrentMerchantOffer = 0;
|
mCurrentMerchantOffer = 0;
|
||||||
|
|
||||||
|
restock();
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> itemSources;
|
std::vector<MWWorld::Ptr> itemSources;
|
||||||
MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources);
|
MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources);
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,8 @@ namespace MWGui
|
||||||
virtual void onReferenceUnavailable();
|
virtual void onReferenceUnavailable();
|
||||||
|
|
||||||
int getMerchantGold();
|
int getMerchantGold();
|
||||||
|
|
||||||
|
void restock();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue