mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 17:59:56 +00:00
Add record presence early-outs for various script instructions (feature #7625)
AddItem, RemoveItem, StartScript, StopScript, AddTopic
This commit is contained in:
parent
3b6211ec4f
commit
e6c02efbb7
4 changed files with 39 additions and 0 deletions
|
@ -109,6 +109,7 @@
|
|||
Feature #7546: Start the game on Fredas
|
||||
Feature #7568: Uninterruptable scripted music
|
||||
Feature #7618: Show the player character's health in the save details
|
||||
Feature #7625: Add some missing console error outputs
|
||||
Feature #7634: Support NiParticleBomb
|
||||
Task #5896: Do not use deprecated MyGUI properties
|
||||
Task #7113: Move from std::atoi to std::from_char
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../mwmechanics/actorutil.hpp"
|
||||
#include "../mwmechanics/levelledlist.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
namespace
|
||||
|
@ -94,6 +95,12 @@ namespace MWScript
|
|||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
if (!MWBase::Environment::get().getESMStore()->find(item))
|
||||
{
|
||||
runtime.getContext().report("Failed to add item '" + item.getRefIdString() + "': unknown ID");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count < 0)
|
||||
count = static_cast<uint16_t>(count);
|
||||
|
||||
|
@ -210,6 +217,12 @@ namespace MWScript
|
|||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
if (!MWBase::Environment::get().getESMStore()->find(item))
|
||||
{
|
||||
runtime.getContext().report("Failed to remove item '" + item.getRefIdString() + "': unknown ID");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count < 0)
|
||||
count = static_cast<uint16_t>(count);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include "ref.hpp"
|
||||
|
||||
|
@ -89,6 +90,13 @@ namespace MWScript
|
|||
ESM::RefId topic = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
||||
runtime.pop();
|
||||
|
||||
if (!MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topic))
|
||||
{
|
||||
runtime.getContext().report(
|
||||
"Failed to add topic '" + topic.getRefIdString() + "': topic record not found");
|
||||
return;
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getDialogueManager()->addTopic(topic);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <components/esm3/loadmisc.hpp>
|
||||
#include <components/esm3/loadprob.hpp>
|
||||
#include <components/esm3/loadrepa.hpp>
|
||||
#include <components/esm3/loadscpt.hpp>
|
||||
#include <components/esm3/loadstat.hpp>
|
||||
#include <components/esm3/loadweap.hpp>
|
||||
|
||||
|
@ -184,6 +185,14 @@ namespace MWScript
|
|||
MWWorld::Ptr target = R()(runtime, false);
|
||||
ESM::RefId name = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
||||
runtime.pop();
|
||||
|
||||
if (!MWBase::Environment::get().getESMStore()->get<ESM::Script>().search(name))
|
||||
{
|
||||
runtime.getContext().report(
|
||||
"Failed to start global script '" + name.getRefIdString() + "': script record not found");
|
||||
return;
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getScriptManager()->getGlobalScripts().addScript(name, target);
|
||||
}
|
||||
};
|
||||
|
@ -206,6 +215,14 @@ namespace MWScript
|
|||
{
|
||||
const ESM::RefId& name = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
||||
runtime.pop();
|
||||
|
||||
if (!MWBase::Environment::get().getESMStore()->get<ESM::Script>().search(name))
|
||||
{
|
||||
runtime.getContext().report(
|
||||
"Failed to stop global script '" + name.getRefIdString() + "': script record not found");
|
||||
return;
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getScriptManager()->getGlobalScripts().removeScript(name);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue