forked from mirror/openmw-tes3mp
Moved merchant restock from trade start to dialogue start, since other services also interact with it.
This commit is contained in:
parent
315b022d2d
commit
c6d3b0b70b
4 changed files with 26 additions and 27 deletions
|
@ -396,6 +396,31 @@ namespace MWGui
|
|||
mLinks.clear();
|
||||
|
||||
updateOptions();
|
||||
|
||||
restock();
|
||||
}
|
||||
|
||||
void DialogueWindow::restock()
|
||||
{
|
||||
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
|
||||
float delay = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getFloat();
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getLastRestockTime() + delay)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
void DialogueWindow::setKeywords(std::list<std::string> keyWords)
|
||||
|
|
|
@ -152,6 +152,7 @@ namespace MWGui
|
|||
|
||||
private:
|
||||
void updateOptions();
|
||||
void restock();
|
||||
|
||||
int mServices;
|
||||
|
||||
|
|
|
@ -99,8 +99,6 @@ namespace MWGui
|
|||
mCurrentBalance = 0;
|
||||
mCurrentMerchantOffer = 0;
|
||||
|
||||
restock();
|
||||
|
||||
std::vector<MWWorld::Ptr> itemSources;
|
||||
MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources);
|
||||
|
||||
|
@ -509,29 +507,6 @@ namespace MWGui
|
|||
return merchantGold;
|
||||
}
|
||||
|
||||
void TradeWindow::restock()
|
||||
{
|
||||
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
|
||||
float delay = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getFloat();
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getLastRestockTime() + delay)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
void TradeWindow::resetReference()
|
||||
{
|
||||
ReferenceInterface::resetReference();
|
||||
|
|
|
@ -104,8 +104,6 @@ namespace MWGui
|
|||
virtual void onReferenceUnavailable();
|
||||
|
||||
int getMerchantGold();
|
||||
|
||||
void restock();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue