2010-08-07 15:11:31 +02:00
|
|
|
#include "containerextensions.hpp"
|
|
|
|
|
2010-08-07 16:34:49 +02:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2012-12-27 15:28:13 +00:00
|
|
|
#include <MyGUI_LanguageManager.h>
|
|
|
|
|
2018-08-14 23:05:43 +04:00
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
|
2013-08-06 20:38:41 -04:00
|
|
|
#include <components/compiler/opcodes.hpp>
|
2010-08-07 15:11:31 +02:00
|
|
|
|
|
|
|
#include <components/interpreter/interpreter.hpp>
|
|
|
|
#include <components/interpreter/opcodes.hpp>
|
|
|
|
|
2022-08-03 00:00:54 +02:00
|
|
|
#include <components/misc/strings/format.hpp>
|
2015-02-09 16:23:41 +01:00
|
|
|
|
2022-10-18 09:26:55 +02:00
|
|
|
#include <components/esm3/loadcrea.hpp>
|
2022-06-26 16:42:29 +02:00
|
|
|
#include <components/esm3/loadlevlist.hpp>
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/loadskil.hpp>
|
2022-09-05 19:35:15 +02:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-12-26 22:57:53 +00:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2015-02-09 17:45:48 +01:00
|
|
|
#include "../mwbase/world.hpp"
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2019-02-22 23:16:47 +04:00
|
|
|
#include "../mwworld/action.hpp"
|
2010-08-07 15:11:31 +02:00
|
|
|
#include "../mwworld/class.hpp"
|
2012-02-23 12:34:51 +01:00
|
|
|
#include "../mwworld/containerstore.hpp"
|
2022-06-26 16:42:29 +02:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-11-23 20:48:59 +01:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2020-10-20 09:22:43 +00:00
|
|
|
#include "../mwworld/manualref.hpp"
|
2010-08-07 15:11:31 +02:00
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
2020-10-21 17:21:28 +02:00
|
|
|
#include "../mwmechanics/levelledlist.hpp"
|
2015-08-21 21:12:39 +12:00
|
|
|
|
2023-10-16 02:34:07 +03:00
|
|
|
#include "interpretercontext.hpp"
|
2010-12-31 19:09:25 +01:00
|
|
|
#include "ref.hpp"
|
2010-08-07 15:11:31 +02:00
|
|
|
|
2020-10-20 09:22:43 +00:00
|
|
|
namespace
|
|
|
|
{
|
2023-01-16 23:51:04 +01:00
|
|
|
void addToStore(const MWWorld::Ptr& itemPtr, int count, MWWorld::ContainerStore& store, bool resolve = true)
|
2020-10-20 09:22:43 +00:00
|
|
|
{
|
|
|
|
if (itemPtr.getClass().getScript(itemPtr).empty())
|
|
|
|
{
|
2023-01-16 23:51:04 +01:00
|
|
|
store.add(itemPtr, count, true, resolve);
|
2020-10-20 09:22:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Adding just one item per time to make sure there isn't a stack of scripted items
|
|
|
|
for (int i = 0; i < count; i++)
|
2023-01-16 23:51:04 +01:00
|
|
|
store.add(itemPtr, 1, true, resolve);
|
2020-10-20 09:22:43 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-21 17:21:28 +02:00
|
|
|
|
2023-01-16 23:51:04 +01:00
|
|
|
void addRandomToStore(const MWWorld::Ptr& itemPtr, int count, MWWorld::ContainerStore& store, bool topLevel = true)
|
2020-10-21 17:21:28 +02:00
|
|
|
{
|
2021-10-11 11:46:21 +00:00
|
|
|
if (itemPtr.getType() == ESM::ItemLevList::sRecordId)
|
2020-10-21 17:21:28 +02:00
|
|
|
{
|
|
|
|
const ESM::ItemLevList* levItemList = itemPtr.get<ESM::ItemLevList>()->mBase;
|
|
|
|
|
|
|
|
if (topLevel && count > 1 && levItemList->mFlags & ESM::ItemLevList::Each)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < count; i++)
|
2023-01-16 23:51:04 +01:00
|
|
|
addRandomToStore(itemPtr, 1, store, true);
|
2020-10-21 17:21:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-06 21:56:02 +02:00
|
|
|
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& itemId
|
2022-08-24 20:38:52 +02:00
|
|
|
= MWMechanics::getLevelledItem(itemPtr.get<ESM::ItemLevList>()->mBase, false, prng);
|
2020-10-21 17:21:28 +02:00
|
|
|
if (itemId.empty())
|
|
|
|
return;
|
2023-04-20 21:07:53 +02:00
|
|
|
MWWorld::ManualRef manualRef(*MWBase::Environment::get().getESMStore(), itemId, 1);
|
2023-01-16 23:51:04 +01:00
|
|
|
addRandomToStore(manualRef.getPtr(), count, store, false);
|
2020-10-21 17:21:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2023-01-16 23:51:04 +01:00
|
|
|
addToStore(itemPtr, count, store);
|
2020-10-21 17:21:28 +02:00
|
|
|
}
|
2020-10-20 09:22:43 +00:00
|
|
|
}
|
|
|
|
|
2010-08-07 15:11:31 +02:00
|
|
|
namespace MWScript
|
|
|
|
{
|
|
|
|
namespace Container
|
|
|
|
{
|
2010-12-31 19:09:25 +01:00
|
|
|
template <class R>
|
2010-08-07 15:11:31 +02:00
|
|
|
class OpAddItem : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2010-12-31 19:09:25 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2010-08-07 15:11:31 +02:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId item = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2010-12-31 19:09:25 +01:00
|
|
|
runtime.pop();
|
2010-08-07 15:11:31 +02:00
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
Interpreter::Type_Integer count = runtime[0].mInteger;
|
2010-08-07 15:11:31 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2023-10-16 02:34:07 +03:00
|
|
|
if (!MWBase::Environment::get().getESMStore()->find(item))
|
|
|
|
{
|
|
|
|
runtime.getContext().report("Failed to add item '" + item.getRefIdString() + "': unknown ID");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-07 15:11:31 +02:00
|
|
|
if (count < 0)
|
|
|
|
count = static_cast<uint16_t>(count);
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
// no-op
|
2010-08-07 16:34:49 +02:00
|
|
|
if (count == 0)
|
2021-04-05 09:43:37 +02:00
|
|
|
return;
|
2010-08-07 16:34:49 +02:00
|
|
|
|
2022-10-18 09:26:55 +02:00
|
|
|
if (item == "gold_005" || item == "gold_010" || item == "gold_025" || item == "gold_100")
|
2023-12-31 17:12:46 +00:00
|
|
|
item = MWWorld::ContainerStore::sGoldId;
|
2013-02-17 19:44:00 +01:00
|
|
|
|
2020-10-20 09:22:43 +00:00
|
|
|
// Check if "item" can be placed in a container
|
2023-04-20 21:07:53 +02:00
|
|
|
MWWorld::ManualRef manualRef(*MWBase::Environment::get().getESMStore(), item, 1);
|
2020-10-20 09:22:43 +00:00
|
|
|
MWWorld::Ptr itemPtr = manualRef.getPtr();
|
2021-10-11 11:46:21 +00:00
|
|
|
bool isLevelledList = itemPtr.getClass().getType() == ESM::ItemLevList::sRecordId;
|
2020-10-20 09:22:43 +00:00
|
|
|
if (!isLevelledList)
|
|
|
|
MWWorld::ContainerStore::getType(itemPtr);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-07-26 11:07:18 +02:00
|
|
|
// Explicit calls to non-unique actors affect the base record
|
|
|
|
if (!R::implicit && ptr.getClass().isActor()
|
2023-04-20 21:07:53 +02:00
|
|
|
&& MWBase::Environment::get().getESMStore()->getRefCount(ptr.getCellRef().getRefId()) > 1)
|
2020-07-26 11:07:18 +02:00
|
|
|
{
|
2022-08-23 16:59:03 +02:00
|
|
|
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, count);
|
2020-07-26 11:07:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-20 09:22:43 +00:00
|
|
|
// Calls to unresolved containers affect the base record
|
2021-10-11 11:46:21 +00:00
|
|
|
if (ptr.getClass().getType() == ESM::Container::sRecordId
|
|
|
|
&& (!ptr.getRefData().getCustomData() || !ptr.getClass().getContainerStore(ptr).isResolved()))
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2020-10-20 09:22:43 +00:00
|
|
|
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, count);
|
|
|
|
const ESM::Container* baseRecord
|
2023-04-20 21:07:53 +02:00
|
|
|
= MWBase::Environment::get().getESMStore()->get<ESM::Container>().find(
|
2020-10-20 09:22:43 +00:00
|
|
|
ptr.getCellRef().getRefId());
|
|
|
|
const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId());
|
|
|
|
for (const auto& container : ptrs)
|
2018-12-06 18:31:47 +03:00
|
|
|
{
|
2022-08-23 16:59:03 +02:00
|
|
|
// use the new base record
|
2020-10-20 09:22:43 +00:00
|
|
|
container.get<ESM::Container>()->mBase = baseRecord;
|
|
|
|
if (container.getRefData().getCustomData())
|
|
|
|
{
|
|
|
|
auto& store = container.getClass().getContainerStore(container);
|
|
|
|
if (isLevelledList)
|
|
|
|
{
|
|
|
|
if (store.isResolved())
|
|
|
|
{
|
2023-01-16 23:51:04 +01:00
|
|
|
addRandomToStore(itemPtr, count, store);
|
2020-10-20 09:22:43 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
else
|
2023-01-16 23:51:04 +01:00
|
|
|
addToStore(itemPtr, count, store, store.isResolved());
|
2020-10-20 09:22:43 +00:00
|
|
|
}
|
2018-12-06 18:31:47 +03:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
return;
|
|
|
|
}
|
2020-10-20 09:22:43 +00:00
|
|
|
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
|
2020-10-21 17:21:28 +02:00
|
|
|
if (isLevelledList)
|
2023-01-16 23:51:04 +01:00
|
|
|
addRandomToStore(itemPtr, count, store);
|
2022-09-22 21:26:05 +03:00
|
|
|
else
|
2023-01-16 23:51:04 +01:00
|
|
|
addToStore(itemPtr, count, store);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-05-10 01:19:04 +04:00
|
|
|
// Spawn a messagebox (only for items added to player's inventory and if player is talking to someone)
|
2014-01-08 18:39:44 +01:00
|
|
|
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-02-17 19:44:00 +01:00
|
|
|
// The two GMST entries below expand to strings informing the player of what, and how many of it has
|
|
|
|
// been added to their inventory
|
|
|
|
std::string msgBox;
|
2022-08-16 21:15:03 +02:00
|
|
|
std::string_view itemName = itemPtr.getClass().getName(itemPtr);
|
2013-02-17 19:44:00 +01:00
|
|
|
if (count == 1)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-02-17 19:44:00 +01:00
|
|
|
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage60}");
|
2019-05-19 12:33:57 +04:00
|
|
|
msgBox = ::Misc::StringUtils::format(msgBox, itemName);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2020-10-21 17:21:28 +02:00
|
|
|
else
|
2013-02-17 18:58:54 +01:00
|
|
|
{
|
2013-02-17 19:44:00 +01:00
|
|
|
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage61}");
|
2019-05-19 12:33:57 +04:00
|
|
|
msgBox = ::Misc::StringUtils::format(msgBox, count, itemName);
|
2013-02-17 19:44:00 +01:00
|
|
|
}
|
2015-01-10 23:21:39 +01:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
|
2010-08-07 15:11:31 +02:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2010-08-07 15:11:31 +02:00
|
|
|
};
|
|
|
|
|
2010-12-31 19:09:25 +01:00
|
|
|
template <class R>
|
2010-08-07 16:21:07 +02:00
|
|
|
class OpGetItemCount : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2010-08-07 16:21:07 +02:00
|
|
|
{
|
2010-12-31 19:09:25 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2010-08-07 16:21:07 +02:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId item = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2010-08-07 16:21:07 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2022-10-18 09:26:55 +02:00
|
|
|
if (item == "gold_005" || item == "gold_010" || item == "gold_025" || item == "gold_100")
|
2023-12-31 17:12:46 +00:00
|
|
|
item = MWWorld::ContainerStore::sGoldId;
|
2016-09-06 16:33:26 +02:00
|
|
|
|
2014-01-08 22:58:36 +01:00
|
|
|
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
|
2010-08-07 16:21:07 +02:00
|
|
|
|
2014-01-08 22:58:36 +01:00
|
|
|
runtime.push(store.count(item));
|
2010-08-07 16:21:07 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-12-31 19:09:25 +01:00
|
|
|
template <class R>
|
2010-08-07 17:00:04 +02:00
|
|
|
class OpRemoveItem : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2010-08-07 17:00:04 +02:00
|
|
|
{
|
2010-12-31 19:09:25 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2010-08-07 17:00:04 +02:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId item = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2010-08-07 17:00:04 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Integer count = runtime[0].mInteger;
|
|
|
|
runtime.pop();
|
2013-02-17 19:44:00 +01:00
|
|
|
|
2023-10-16 02:34:07 +03:00
|
|
|
if (!MWBase::Environment::get().getESMStore()->find(item))
|
|
|
|
{
|
|
|
|
runtime.getContext().report("Failed to remove item '" + item.getRefIdString() + "': unknown ID");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-07 17:00:04 +02:00
|
|
|
if (count < 0)
|
2022-07-24 20:15:44 +03:00
|
|
|
count = static_cast<uint16_t>(count);
|
2010-08-07 17:00:04 +02:00
|
|
|
|
2013-02-17 19:44:00 +01:00
|
|
|
// no-op
|
|
|
|
if (count == 0)
|
|
|
|
return;
|
|
|
|
|
2022-10-18 09:26:55 +02:00
|
|
|
if (item == "gold_005" || item == "gold_010" || item == "gold_025" || item == "gold_100")
|
2023-12-31 17:12:46 +00:00
|
|
|
item = MWWorld::ContainerStore::sGoldId;
|
2016-09-06 16:33:26 +02:00
|
|
|
|
2020-07-26 11:07:18 +02:00
|
|
|
// Explicit calls to non-unique actors affect the base record
|
|
|
|
if (!R::implicit && ptr.getClass().isActor()
|
2023-04-20 21:07:53 +02:00
|
|
|
&& MWBase::Environment::get().getESMStore()->getRefCount(ptr.getCellRef().getRefId()) > 1)
|
2020-07-26 11:07:18 +02:00
|
|
|
{
|
2022-08-23 16:59:03 +02:00
|
|
|
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, -count);
|
2020-07-26 11:07:18 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-10-20 09:22:43 +00:00
|
|
|
// Calls to unresolved containers affect the base record instead
|
2021-10-11 11:46:21 +00:00
|
|
|
else if (ptr.getClass().getType() == ESM::Container::sRecordId
|
2020-10-20 09:22:43 +00:00
|
|
|
&& (!ptr.getRefData().getCustomData() || !ptr.getClass().getContainerStore(ptr).isResolved()))
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2022-08-23 16:59:03 +02:00
|
|
|
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, -count);
|
2020-10-20 09:22:43 +00:00
|
|
|
const ESM::Container* baseRecord
|
2023-04-20 21:07:53 +02:00
|
|
|
= MWBase::Environment::get().getESMStore()->get<ESM::Container>().find(
|
2020-10-20 09:22:43 +00:00
|
|
|
ptr.getCellRef().getRefId());
|
|
|
|
const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId());
|
|
|
|
for (const auto& container : ptrs)
|
|
|
|
{
|
|
|
|
container.get<ESM::Container>()->mBase = baseRecord;
|
|
|
|
if (container.getRefData().getCustomData())
|
|
|
|
{
|
|
|
|
auto& store = container.getClass().getContainerStore(container);
|
|
|
|
// Note that unlike AddItem, RemoveItem only removes from unresolved containers
|
|
|
|
if (!store.isResolved())
|
2023-01-16 23:51:04 +01:00
|
|
|
store.remove(item, count, false, false);
|
2020-10-20 09:22:43 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
return;
|
|
|
|
}
|
2014-05-22 20:37:22 +02:00
|
|
|
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
|
2013-08-13 01:19:33 +02:00
|
|
|
|
2022-08-16 21:15:03 +02:00
|
|
|
std::string_view itemName;
|
2017-02-19 14:30:26 +00:00
|
|
|
for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2022-10-18 09:26:55 +02:00
|
|
|
if (iter->getCellRef().getRefId() == item)
|
2018-12-06 18:31:47 +03:00
|
|
|
{
|
2013-11-15 02:08:36 +01:00
|
|
|
itemName = iter->getClass().getName(*iter);
|
2018-12-06 18:31:47 +03:00
|
|
|
break;
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-02-17 19:44:00 +01:00
|
|
|
|
2023-01-16 23:51:04 +01:00
|
|
|
int numRemoved = store.remove(item, count);
|
2010-08-07 17:00:04 +02:00
|
|
|
|
2013-05-10 01:19:04 +04:00
|
|
|
// Spawn a messagebox (only for items removed from player's inventory)
|
2015-08-21 21:12:39 +12:00
|
|
|
if ((numRemoved > 0) && (ptr == MWMechanics::getPlayer()))
|
2012-12-27 15:28:13 +00:00
|
|
|
{
|
2013-02-17 19:44:00 +01:00
|
|
|
// The two GMST entries below expand to strings informing the player of what, and how many of it has
|
|
|
|
// been removed from their inventory
|
|
|
|
std::string msgBox;
|
2013-08-13 01:19:33 +02:00
|
|
|
|
2019-02-23 00:14:07 +03:00
|
|
|
if (numRemoved > 1)
|
2013-02-17 19:44:00 +01:00
|
|
|
{
|
|
|
|
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage63}");
|
2019-05-19 12:33:57 +04:00
|
|
|
msgBox = ::Misc::StringUtils::format(msgBox, numRemoved, itemName);
|
2013-02-17 19:44:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage62}");
|
2019-05-19 12:33:57 +04:00
|
|
|
msgBox = ::Misc::StringUtils::format(msgBox, itemName);
|
2013-02-17 19:44:00 +01:00
|
|
|
}
|
2015-01-10 23:21:39 +01:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
|
2010-08-07 17:00:04 +02:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2010-08-07 17:00:04 +02:00
|
|
|
};
|
|
|
|
|
2012-11-23 20:48:59 +01:00
|
|
|
template <class R>
|
|
|
|
class OpEquip : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2012-11-23 20:48:59 +01:00
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId item = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2012-11-23 20:48:59 +01:00
|
|
|
runtime.pop();
|
|
|
|
|
2014-01-19 11:42:58 +01:00
|
|
|
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
2022-08-25 21:37:20 +02:00
|
|
|
auto found = invStore.end();
|
2023-04-20 21:07:53 +02:00
|
|
|
const auto& store = *MWBase::Environment::get().getESMStore();
|
2022-07-24 23:02:26 +03:00
|
|
|
|
|
|
|
// With soul gems we prefer filled ones.
|
2022-08-25 21:37:20 +02:00
|
|
|
for (auto it = invStore.begin(); it != invStore.end(); ++it)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2022-10-18 09:26:55 +02:00
|
|
|
if (it->getCellRef().getRefId() == item)
|
2022-07-24 23:02:26 +03:00
|
|
|
{
|
2022-08-25 21:37:20 +02:00
|
|
|
found = it;
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& soul = it->getCellRef().getSoul();
|
2022-08-25 21:37:20 +02:00
|
|
|
if (!it->getClass().isSoulGem(*it)
|
|
|
|
|| (!soul.empty() && store.get<ESM::Creature>().search(soul)))
|
2022-07-24 23:02:26 +03:00
|
|
|
break;
|
2012-11-23 20:48:59 +01:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2022-07-24 23:02:26 +03:00
|
|
|
|
2022-08-25 21:37:20 +02:00
|
|
|
if (found == invStore.end())
|
2016-09-06 16:33:26 +02:00
|
|
|
{
|
2022-08-25 21:37:20 +02:00
|
|
|
MWWorld::ManualRef ref(store, item, 1);
|
2023-01-16 23:51:04 +01:00
|
|
|
found = ptr.getClass().getContainerStore(ptr).add(ref.getPtr(), 1, false);
|
2018-08-17 03:32:33 +03:00
|
|
|
Log(Debug::Warning) << "Implicitly adding one " << item << " to the inventory store of "
|
|
|
|
<< ptr.getCellRef().getRefId()
|
|
|
|
<< " to fulfill the requirements of Equip instruction";
|
2016-09-06 16:33:26 +02:00
|
|
|
}
|
2012-11-23 20:48:59 +01:00
|
|
|
|
2018-07-09 19:31:40 +04:00
|
|
|
if (ptr == MWMechanics::getPlayer())
|
2022-08-25 21:37:20 +02:00
|
|
|
MWBase::Environment::get().getWindowManager()->useItem(*found, true);
|
2015-09-07 21:32:28 +02:00
|
|
|
else
|
|
|
|
{
|
2022-08-25 21:37:20 +02:00
|
|
|
std::unique_ptr<MWWorld::Action> action = found->getClass().use(*found, true);
|
2017-04-13 22:18:03 +09:00
|
|
|
action->execute(ptr, true);
|
2012-11-23 20:48:59 +01:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-11-23 20:48:59 +01:00
|
|
|
};
|
|
|
|
|
2012-11-24 02:38:10 +01:00
|
|
|
template <class R>
|
|
|
|
class OpGetArmorType : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-24 02:38:10 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Interpreter::Type_Integer location = runtime[0].mInteger;
|
|
|
|
runtime.pop();
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2012-11-24 02:38:10 +01:00
|
|
|
int slot;
|
2020-10-16 22:18:54 +04:00
|
|
|
switch (location)
|
2012-11-24 02:38:10 +01:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
case 0:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_Helmet;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_Cuirass;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_LeftPauldron;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_RightPauldron;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 4:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_Greaves;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 5:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_Boots;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 6:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 7:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_RightGauntlet;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 8:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_CarriedLeft; // shield
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 9:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
case 10:
|
2012-11-24 02:38:10 +01:00
|
|
|
slot = MWWorld::InventoryStore::Slot_RightGauntlet;
|
2022-09-22 21:26:05 +03:00
|
|
|
break;
|
|
|
|
default:
|
2012-11-24 02:38:10 +01:00
|
|
|
throw std::runtime_error("armor index out of range");
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-11-24 02:38:10 +01:00
|
|
|
|
|
|
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
|
|
|
MWWorld::ConstContainerStoreIterator it = invStore.getSlot(slot);
|
|
|
|
|
|
|
|
if (it == invStore.end() || it->getType() != ESM::Armor::sRecordId)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-24 02:38:10 +01:00
|
|
|
runtime.push(-1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-06 17:24:22 +02:00
|
|
|
ESM::RefId skill = it->getClass().getEquipmentSkill(*it);
|
2012-11-24 02:38:10 +01:00
|
|
|
if (skill == ESM::Skill::HeavyArmor)
|
|
|
|
runtime.push(2);
|
|
|
|
else if (skill == ESM::Skill::MediumArmor)
|
|
|
|
runtime.push(1);
|
|
|
|
else if (skill == ESM::Skill::LightArmor)
|
|
|
|
runtime.push(0);
|
|
|
|
else
|
|
|
|
runtime.push(-1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-24 02:59:44 +01:00
|
|
|
template <class R>
|
|
|
|
class OpHasItemEquipped : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2012-11-24 02:59:44 +01:00
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId item = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2012-11-24 02:59:44 +01:00
|
|
|
runtime.pop();
|
|
|
|
|
2017-02-28 14:43:20 +00:00
|
|
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
2012-11-24 02:59:44 +01:00
|
|
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2017-02-28 14:43:20 +00:00
|
|
|
MWWorld::ConstContainerStoreIterator it = invStore.getSlot(slot);
|
2022-10-18 09:26:55 +02:00
|
|
|
if (it != invStore.end() && it->getCellRef().getRefId() == item)
|
2012-11-24 02:59:44 +01:00
|
|
|
{
|
|
|
|
runtime.push(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runtime.push(0);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-11-24 02:59:44 +01:00
|
|
|
};
|
|
|
|
|
2012-11-25 01:54:37 +01:00
|
|
|
template <class R>
|
|
|
|
class OpHasSoulGem : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2012-11-25 01:54:37 +01:00
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2014-02-23 20:11:05 +01:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId name = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2012-11-25 01:54:37 +01:00
|
|
|
runtime.pop();
|
|
|
|
|
2014-10-06 14:36:29 +02:00
|
|
|
int count = 0;
|
2017-02-19 14:30:26 +00:00
|
|
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
|
|
|
for (MWWorld::ConstContainerStoreIterator it
|
|
|
|
= invStore.cbegin(MWWorld::ContainerStore::Type_Miscellaneous);
|
|
|
|
it != invStore.cend(); ++it)
|
2012-11-25 01:54:37 +01:00
|
|
|
{
|
2022-10-18 09:26:55 +02:00
|
|
|
if (it->getCellRef().getSoul() == name)
|
2023-12-31 17:12:46 +00:00
|
|
|
count += it->getCellRef().getCount();
|
2012-11-25 01:54:37 +01:00
|
|
|
}
|
2014-10-06 14:36:29 +02:00
|
|
|
runtime.push(count);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-11-25 01:54:37 +01:00
|
|
|
};
|
|
|
|
|
2012-11-25 02:06:43 +01:00
|
|
|
template <class R>
|
|
|
|
class OpGetWeaponType : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-25 02:06:43 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
|
|
|
MWWorld::ConstContainerStoreIterator it = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
|
|
|
if (it == invStore.end())
|
2012-11-25 02:06:43 +01:00
|
|
|
{
|
|
|
|
runtime.push(-1);
|
2017-02-28 14:43:20 +00:00
|
|
|
return;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2017-02-28 14:43:20 +00:00
|
|
|
else if (it->getType() != ESM::Weapon::sRecordId)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2017-02-28 14:43:20 +00:00
|
|
|
if (it->getType() == ESM::Lockpick::sRecordId)
|
2012-11-25 02:06:43 +01:00
|
|
|
{
|
|
|
|
runtime.push(-2);
|
|
|
|
}
|
2021-10-11 11:46:21 +00:00
|
|
|
else if (it->getType() == ESM::Probe::sRecordId)
|
2019-05-11 03:38:06 +03:00
|
|
|
{
|
|
|
|
runtime.push(-3);
|
|
|
|
}
|
2012-11-25 02:06:43 +01:00
|
|
|
else
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-25 02:06:43 +01:00
|
|
|
runtime.push(-1);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-11-25 02:06:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
runtime.push(it->get<ESM::Weapon>()->mBase->mData.mType);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
};
|
2010-08-07 15:11:31 +02:00
|
|
|
|
|
|
|
void installOpcodes(Interpreter::Interpreter& interpreter)
|
|
|
|
{
|
2022-01-27 19:18:57 +00:00
|
|
|
interpreter.installSegment5<OpAddItem<ImplicitRef>>(Compiler::Container::opcodeAddItem);
|
|
|
|
interpreter.installSegment5<OpAddItem<ExplicitRef>>(Compiler::Container::opcodeAddItemExplicit);
|
|
|
|
interpreter.installSegment5<OpGetItemCount<ImplicitRef>>(Compiler::Container::opcodeGetItemCount);
|
|
|
|
interpreter.installSegment5<OpGetItemCount<ExplicitRef>>(Compiler::Container::opcodeGetItemCountExplicit);
|
|
|
|
interpreter.installSegment5<OpRemoveItem<ImplicitRef>>(Compiler::Container::opcodeRemoveItem);
|
|
|
|
interpreter.installSegment5<OpRemoveItem<ExplicitRef>>(Compiler::Container::opcodeRemoveItemExplicit);
|
|
|
|
interpreter.installSegment5<OpEquip<ImplicitRef>>(Compiler::Container::opcodeEquip);
|
|
|
|
interpreter.installSegment5<OpEquip<ExplicitRef>>(Compiler::Container::opcodeEquipExplicit);
|
|
|
|
interpreter.installSegment5<OpGetArmorType<ImplicitRef>>(Compiler::Container::opcodeGetArmorType);
|
|
|
|
interpreter.installSegment5<OpGetArmorType<ExplicitRef>>(Compiler::Container::opcodeGetArmorTypeExplicit);
|
|
|
|
interpreter.installSegment5<OpHasItemEquipped<ImplicitRef>>(Compiler::Container::opcodeHasItemEquipped);
|
|
|
|
interpreter.installSegment5<OpHasItemEquipped<ExplicitRef>>(
|
|
|
|
Compiler::Container::opcodeHasItemEquippedExplicit);
|
|
|
|
interpreter.installSegment5<OpHasSoulGem<ImplicitRef>>(Compiler::Container::opcodeHasSoulGem);
|
|
|
|
interpreter.installSegment5<OpHasSoulGem<ExplicitRef>>(Compiler::Container::opcodeHasSoulGemExplicit);
|
|
|
|
interpreter.installSegment5<OpGetWeaponType<ImplicitRef>>(Compiler::Container::opcodeGetWeaponType);
|
|
|
|
interpreter.installSegment5<OpGetWeaponType<ExplicitRef>>(Compiler::Container::opcodeGetWeaponTypeExplicit);
|
2010-08-07 15:11:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|