mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-24 09:39:51 +00:00
allow stacking gold
This commit is contained in:
parent
0f1e09d2c1
commit
4b5d6ce311
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
#include "misc.hpp"
|
#include "misc.hpp"
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <components/esm/loadmisc.hpp>
|
#include <components/esm/loadmisc.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include <components/esm_store/cell_store.hpp>
|
||||||
@ -142,12 +144,18 @@ namespace MWClass
|
|||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
int count = ptr.getRefData().getCount();
|
int count = ptr.getRefData().getCount();
|
||||||
// gold has count both as reference count and as value, multiply them together to get real count
|
|
||||||
bool isGold = (ref->base->name == store.gameSettings.search("sGold")->str);
|
|
||||||
if (isGold)
|
|
||||||
count *= ref->base->data.value;
|
|
||||||
|
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(count);
|
bool isGold = (ref->base->name == store.gameSettings.search("sGold")->str);
|
||||||
|
if (isGold && count == 1)
|
||||||
|
count = ref->base->data.value;
|
||||||
|
|
||||||
|
std::string countString;
|
||||||
|
if (!isGold)
|
||||||
|
countString = MWGui::ToolTips::getCountString(count);
|
||||||
|
else // gold displays its count also if it's 1.
|
||||||
|
countString = " (" + boost::lexical_cast<std::string>(count) + ")";
|
||||||
|
|
||||||
|
info.caption = ref->base->name + countString;
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
if (ref->ref.soul != "")
|
if (ref->ref.soul != "")
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
#include <components/esm/loadcont.hpp>
|
#include <components/esm/loadcont.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
#include "manualref.hpp"
|
#include "manualref.hpp"
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
@ -62,6 +65,32 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr)
|
|||||||
{
|
{
|
||||||
int type = getType(ptr);
|
int type = getType(ptr);
|
||||||
|
|
||||||
|
// gold needs special treatment because it uses several different meshes
|
||||||
|
if (MWWorld::Class::get(ptr).getName(ptr) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *gold =
|
||||||
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
|
int goldValue = (ptr.getRefData().getCount() == 1) ? gold->base->data.value : ptr.getRefData().getCount();
|
||||||
|
|
||||||
|
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
|
||||||
|
{
|
||||||
|
if (MWWorld::Class::get(*iter).getName(*iter) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||||
|
iter->get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
|
if (iter->getRefData().getCount() == 1)
|
||||||
|
iter->getRefData().setCount(ref->base->data.value + goldValue);
|
||||||
|
else
|
||||||
|
iter->getRefData().setCount(iter->getRefData().getCount() + goldValue);
|
||||||
|
|
||||||
|
flagAsModified();
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// determine whether to stack or not
|
// determine whether to stack or not
|
||||||
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user