1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 09:23:53 +00:00

Merge remote-tracking branch 'zelurker/removed_items'

This commit is contained in:
Marc Zinnschlag 2015-09-26 11:24:56 +02:00
commit 9279ae4ba0
3 changed files with 42 additions and 36 deletions

View file

@ -170,25 +170,25 @@ namespace MWGui
mCommandLine->setFontName(fntName); 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) void Console::printOK(const std::string &msg)
{ {
print("#FF00FF" + msg + "\n"); print(msg + "\n", "#FF00FF");
} }
void Console::printError(const std::string &msg) void Console::printError(const std::string &msg)
{ {
print("#FF2222" + msg + "\n"); print(msg + "\n", "#FF2222");
} }
void Console::execute (const std::string& command) void Console::execute (const std::string& command)
{ {
// Log the command // Log the command
print("#FFFFFF> " + command + "\n"); print("> " + command + "\n");
Compiler::Locals locals; Compiler::Locals locals;
Compiler::Output output (locals); Compiler::Output output (locals);

View file

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

View file

@ -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, void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::string& owner,
int count, bool topLevel, const std::string& levItem) 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()) 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)
{ {
for (int i=0; i<std::abs(count); ++i) const ESM::ItemLevList* levItem = ref.getPtr().get<ESM::ItemLevList>()->mBase;
addInitialItem(id, owner, count > 0 ? 1 : -1, true, levItem->mId);
return; 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 else
{ {
std::string id = MWMechanics::getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false); // A negative count indicates restocking items
if (id.empty()) // For a restocking levelled item, remember what we spawned so we can delete it later when the merchant restocks
return; if (!levItem.empty() && count < 0)
addInitialItem(id, owner, count, false, levItem->mId); {
} if (mLevelledItemMap.find(id) == mLevelledItemMap.end())
} mLevelledItemMap[id] = 0;
else mLevelledItemMap[id] += std::abs(count);
{ }
// A negative count indicates restocking items count = std::abs(count);
// 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); ref.getPtr().getCellRef().setOwner(owner);
addImp (ref.getPtr(), count); addImp (ref.getPtr(), count);
}
} }
catch (const std::exception& e)
{
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) void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MWWorld::Ptr& ptr, const std::string& owner)