Skip to content

Commit

Permalink
Merge branch 'areyouthere' into 'master'
Browse files Browse the repository at this point in the history
Add record presence early-outs for various script instructions (feature #7625)

Closes #7625

See merge request OpenMW/openmw!3501
  • Loading branch information
uramer committed Oct 29, 2023
2 parents 2488ece + e6c02ef commit 1ec4681
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,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
Expand Down
13 changes: 13 additions & 0 deletions apps/openmw/mwscript/containerextensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/levelledlist.hpp"

#include "interpretercontext.hpp"
#include "ref.hpp"

namespace
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
8 changes: 8 additions & 0 deletions apps/openmw/mwscript/dialogueextensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "../mwmechanics/npcstats.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"

#include "ref.hpp"

Expand Down Expand Up @@ -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);
}
};
Expand Down
17 changes: 17 additions & 0 deletions apps/openmw/mwscript/miscextensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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);
}
};
Expand All @@ -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);
}
};
Expand Down

0 comments on commit 1ec4681

Please sign in to comment.