Merge remote-tracking branch 'zelurker/removed_items'

pull/778/head
Marc Zinnschlag 9 years ago
commit 9279ae4ba0

@ -170,25 +170,25 @@ namespace MWGui
mCommandLine->setFontName(fntName);
}
void Console::print(const std::string &msg)
void Console::print(const std::string &msg, const std::string& color)
{
mHistory->addText(msg);
mHistory->addText(color + MyGUI::TextIterator::toTagsString(msg));
}
void Console::printOK(const std::string &msg)
{
print("#FF00FF" + msg + "\n");
print(msg + "\n", "#FF00FF");
}
void Console::printError(const std::string &msg)
{
print("#FF2222" + msg + "\n");
print(msg + "\n", "#FF2222");
}
void Console::execute (const std::string& command)
{
// Log the command
print("#FFFFFF> " + command + "\n");
print("> " + command + "\n");
Compiler::Locals locals;
Compiler::Output output (locals);

@ -48,9 +48,8 @@ namespace MWGui
void onResChange(int width, int height);
// Print a message to the console. Messages may contain color
// code, eg. "#FFFFFF this is white".
void print(const std::string &msg);
// Print a message to the console, in specified color.
void print(const std::string &msg, const std::string& color = "#FFFFFF");
// These are pre-colored versions that you should use.

@ -411,41 +411,48 @@ void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const std::
void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::string& owner,
int count, bool topLevel, const std::string& levItem)
{
ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), id, count);
try {
ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), id, count);
if (ref.getPtr().getTypeName()==typeid (ESM::ItemLevList).name())
{
const ESM::ItemLevList* levItem = ref.getPtr().get<ESM::ItemLevList>()->mBase;
if (topLevel && std::abs(count) > 1 && levItem->mFlags & ESM::ItemLevList::Each)
if (ref.getPtr().getTypeName()==typeid (ESM::ItemLevList).name())
{
for (int i=0; i<std::abs(count); ++i)
addInitialItem(id, owner, count > 0 ? 1 : -1, true, levItem->mId);
return;
const ESM::ItemLevList* levItem = ref.getPtr().get<ESM::ItemLevList>()->mBase;
if (topLevel && std::abs(count) > 1 && levItem->mFlags & ESM::ItemLevList::Each)
{
for (int i=0; i<std::abs(count); ++i)
addInitialItem(id, owner, count > 0 ? 1 : -1, true, levItem->mId);
return;
}
else
{
std::string id = MWMechanics::getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false);
if (id.empty())
return;
addInitialItem(id, owner, count, false, levItem->mId);
}
}
else
{
std::string id = MWMechanics::getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false);
if (id.empty())
return;
addInitialItem(id, owner, count, false, levItem->mId);
// A negative count indicates restocking items
// For a restocking levelled item, remember what we spawned so we can delete it later when the merchant restocks
if (!levItem.empty() && count < 0)
{
if (mLevelledItemMap.find(id) == mLevelledItemMap.end())
mLevelledItemMap[id] = 0;
mLevelledItemMap[id] += std::abs(count);
}
count = std::abs(count);
ref.getPtr().getCellRef().setOwner(owner);
addImp (ref.getPtr(), count);
}
}
else
catch (const std::exception& e)
{
// A negative count indicates restocking items
// For a restocking levelled item, remember what we spawned so we can delete it later when the merchant restocks
if (!levItem.empty() && count < 0)
{
if (mLevelledItemMap.find(id) == mLevelledItemMap.end())
mLevelledItemMap[id] = 0;
mLevelledItemMap[id] += std::abs(count);
}
count = std::abs(count);
ref.getPtr().getCellRef().setOwner(owner);
addImp (ref.getPtr(), count);
std::cerr << "Error in MWWorld::ContainerStore::addInitialItem: " << e.what() << std::endl;
}
}
void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MWWorld::Ptr& ptr, const std::string& owner)

Loading…
Cancel
Save