mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
Merge remote-tracking branch 'scrawl/master'
This commit is contained in:
commit
f5e493de7e
@ -607,8 +607,8 @@ if (WIN32)
|
||||
|
||||
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
|
||||
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
|
||||
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)\" )
|
||||
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)\" )
|
||||
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)" )
|
||||
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)" )
|
||||
endforeach( OUTPUTCONFIG )
|
||||
|
||||
if (USE_DEBUG_CONSOLE)
|
||||
|
@ -76,7 +76,7 @@ MWWorld::Ptr ContainerItemModel::copyItem (const ItemStack& item, size_t count,
|
||||
const MWWorld::Ptr& source = mItemSources[mItemSources.size()-1];
|
||||
if (item.mBase.getContainerStore() == &source.getClass().getContainerStore(source))
|
||||
throw std::runtime_error("Item to copy needs to be from a different container!");
|
||||
return *source.getClass().getContainerStore(source).add(item.mBase, count, source);
|
||||
return *source.getClass().getContainerStore(source).add(item.mBase, count, source, setNewOwner);
|
||||
}
|
||||
|
||||
void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
|
||||
|
@ -278,14 +278,14 @@ namespace MWGui
|
||||
if (item.mType == ItemStack::Type_Barter)
|
||||
{
|
||||
// this was an item borrowed to us by the merchant
|
||||
MWBase::Environment::get().getWindowManager()->getTradeWindow()->returnItem(mSelectedItem, count);
|
||||
mTradeModel->returnItemBorrowedToUs(mSelectedItem, count);
|
||||
MWBase::Environment::get().getWindowManager()->getTradeWindow()->returnItem(mSelectedItem, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
// borrow item to the merchant
|
||||
MWBase::Environment::get().getWindowManager()->getTradeWindow()->borrowItem(mSelectedItem, count);
|
||||
mTradeModel->borrowItemFromUs(mSelectedItem, count);
|
||||
MWBase::Environment::get().getWindowManager()->getTradeWindow()->borrowItem(mSelectedItem, count);
|
||||
}
|
||||
|
||||
mItemView->update();
|
||||
|
@ -119,7 +119,7 @@ namespace MWGui
|
||||
return mBorrowedToUs;
|
||||
}
|
||||
|
||||
void TradeItemModel::transferItems()
|
||||
void TradeItemModel::transferItems(const MWWorld::Ptr& transferFrom)
|
||||
{
|
||||
std::vector<ItemStack>::iterator it = mBorrowedToUs.begin();
|
||||
for (; it != mBorrowedToUs.end(); ++it)
|
||||
@ -135,9 +135,11 @@ namespace MWGui
|
||||
if (i == sourceModel->getItemCount())
|
||||
throw std::runtime_error("The borrowed item disappeared");
|
||||
|
||||
// reset owner while copying, but only for items bought by the player
|
||||
bool setNewOwner = (mMerchant.isEmpty());
|
||||
const ItemStack& item = sourceModel->getItem(i);
|
||||
|
||||
bool setNewOwner = Misc::StringUtils::ciEqual(item.mBase.getCellRef().getOwner(), transferFrom.getCellRef().getRefId())
|
||||
|| item.mBase.getCellRef().getOwner().empty();
|
||||
|
||||
// copy the borrowed items to our model
|
||||
copyItem(item, it->mCount, setNewOwner);
|
||||
// then remove them from the source model
|
||||
|
@ -30,7 +30,8 @@ namespace MWGui
|
||||
void returnItemBorrowedFromUs (ModelIndex itemIndex, ItemModel* source, size_t count);
|
||||
|
||||
/// Permanently transfers items that were borrowed to us from another model to this model
|
||||
void transferItems ();
|
||||
/// @param transferFrom the actor that lent us the items
|
||||
void transferItems (const MWWorld::Ptr& transferFrom);
|
||||
/// Aborts trade
|
||||
void abort();
|
||||
|
||||
|
@ -360,8 +360,8 @@ namespace MWGui
|
||||
MWBase::Environment::get().getDialogueManager()->applyDispositionChange(iBarterSuccessDisposition);
|
||||
|
||||
// make the item transfer
|
||||
mTradeModel->transferItems();
|
||||
playerItemModel->transferItems();
|
||||
mTradeModel->transferItems(player);
|
||||
playerItemModel->transferItems(mPtr);
|
||||
|
||||
// transfer the gold
|
||||
if (mCurrentBalance != 0)
|
||||
@ -480,24 +480,38 @@ namespace MWGui
|
||||
mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(getMerchantGold()));
|
||||
}
|
||||
|
||||
void TradeWindow::updateOffer()
|
||||
{
|
||||
TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
|
||||
|
||||
int merchantOffer = 0;
|
||||
|
||||
std::vector<ItemStack> playerBorrowed = playerTradeModel->getItemsBorrowedToUs();
|
||||
for (std::vector<ItemStack>::const_iterator it = playerBorrowed.begin(); it != playerBorrowed.end(); ++it)
|
||||
{
|
||||
merchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), true);
|
||||
}
|
||||
|
||||
std::vector<ItemStack> merchantBorrowed = mTradeModel->getItemsBorrowedToUs();
|
||||
for (std::vector<ItemStack>::const_iterator it = merchantBorrowed.begin(); it != merchantBorrowed.end(); ++it)
|
||||
{
|
||||
merchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), false);
|
||||
}
|
||||
|
||||
int diff = merchantOffer - mCurrentMerchantOffer;
|
||||
mCurrentMerchantOffer = merchantOffer;
|
||||
mCurrentBalance += diff;
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem)
|
||||
{
|
||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(item, count), boughtItem);
|
||||
|
||||
mCurrentBalance += diff;
|
||||
mCurrentMerchantOffer += diff;
|
||||
|
||||
updateLabels();
|
||||
updateOffer();
|
||||
}
|
||||
|
||||
void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem)
|
||||
{
|
||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(item, count), !soldItem);
|
||||
|
||||
mCurrentBalance -= diff;
|
||||
mCurrentMerchantOffer -= diff;
|
||||
|
||||
updateLabels();
|
||||
updateOffer();
|
||||
}
|
||||
|
||||
void TradeWindow::onReferenceUnavailable()
|
||||
|
@ -72,6 +72,8 @@ namespace MWGui
|
||||
void sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem); ///< only used for adjusting the gold balance
|
||||
void buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem); ///< only used for adjusting the gold balance
|
||||
|
||||
void updateOffer();
|
||||
|
||||
void onItemSelected (int index);
|
||||
void sellItem (MyGUI::Widget* sender, int count);
|
||||
|
||||
|
@ -351,6 +351,7 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
|
||||
case ESM::REC_ACTC:
|
||||
case ESM::REC_PROJ:
|
||||
case ESM::REC_MPRJ:
|
||||
case ESM::REC_ENAB:
|
||||
|
||||
MWBase::Environment::get().getWorld()->readRecord (reader, n.val, contentFileMap);
|
||||
break;
|
||||
|
@ -289,6 +289,7 @@ namespace MWWorld
|
||||
mGodMode = false;
|
||||
mSky = true;
|
||||
mTeleportEnabled = true;
|
||||
mLevitationEnabled = true;
|
||||
|
||||
mGlobalVariables.fill (mStore);
|
||||
}
|
||||
@ -302,7 +303,8 @@ namespace MWWorld
|
||||
+mProjectileManager->countSavedGameRecords()
|
||||
+1 // player record
|
||||
+1 // weather record
|
||||
+1; // actorId counter
|
||||
+1 // actorId counter
|
||||
+1; // levitation/teleport enabled state
|
||||
}
|
||||
|
||||
void World::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
|
||||
@ -325,25 +327,37 @@ namespace MWWorld
|
||||
mPlayer->write (writer, progress);
|
||||
mWeatherManager->write (writer, progress);
|
||||
mProjectileManager->write (writer, progress);
|
||||
|
||||
writer.startRecord(ESM::REC_ENAB);
|
||||
writer.writeHNT("TELE", mTeleportEnabled);
|
||||
writer.writeHNT("LEVT", mLevitationEnabled);
|
||||
writer.endRecord(ESM::REC_ENAB);
|
||||
progress.increaseProgress();
|
||||
}
|
||||
|
||||
void World::readRecord (ESM::ESMReader& reader, int32_t type,
|
||||
const std::map<int, int>& contentFileMap)
|
||||
{
|
||||
if (type == ESM::REC_ACTC)
|
||||
switch (type)
|
||||
{
|
||||
MWMechanics::CreatureStats::readActorIdCounter(reader);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStore.readRecord (reader, type) &&
|
||||
!mGlobalVariables.readRecord (reader, type) &&
|
||||
!mPlayer->readRecord (reader, type) &&
|
||||
!mWeatherManager->readRecord (reader, type) &&
|
||||
!mCells.readRecord (reader, type, contentFileMap) &&
|
||||
!mProjectileManager->readRecord (reader, type))
|
||||
{
|
||||
throw std::runtime_error ("unknown record in saved game");
|
||||
case ESM::REC_ACTC:
|
||||
MWMechanics::CreatureStats::readActorIdCounter(reader);
|
||||
return;
|
||||
case ESM::REC_ENAB:
|
||||
reader.getHNT(mTeleportEnabled, "TELE");
|
||||
reader.getHNT(mLevitationEnabled, "LEVT");
|
||||
return;
|
||||
default:
|
||||
if (!mStore.readRecord (reader, type) &&
|
||||
!mGlobalVariables.readRecord (reader, type) &&
|
||||
!mPlayer->readRecord (reader, type) &&
|
||||
!mWeatherManager->readRecord (reader, type) &&
|
||||
!mCells.readRecord (reader, type, contentFileMap) &&
|
||||
!mProjectileManager->readRecord (reader, type))
|
||||
{
|
||||
throw std::runtime_error ("unknown record in saved game");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,7 @@ enum RecNameInts
|
||||
REC_PROJ = FourCC<'P','R','O','J'>::value,
|
||||
REC_DCOU = FourCC<'D','C','O','U'>::value,
|
||||
REC_MARK = FourCC<'M','A','R','K'>::value,
|
||||
REC_ENAB = FourCC<'E','N','A','B'>::value,
|
||||
|
||||
// format 1
|
||||
REC_FILT = 0x544C4946,
|
||||
|
Loading…
x
Reference in New Issue
Block a user