mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-22 04:41:36 +00:00
Cache failed compilation when getting locals
This commit is contained in:
parent
6d3cc0d281
commit
9a7c07173d
3 changed files with 101 additions and 108 deletions
|
@ -9,6 +9,7 @@
|
||||||
Bug #6066: addtopic "return" does not work from within script. No errors thrown
|
Bug #6066: addtopic "return" does not work from within script. No errors thrown
|
||||||
Bug #6101: Disarming trapped unlocked owned objects isn't considered a crime
|
Bug #6101: Disarming trapped unlocked owned objects isn't considered a crime
|
||||||
Bug #6115: Showmap overzealous matching
|
Bug #6115: Showmap overzealous matching
|
||||||
|
Bug #6123: NPC with broken script freezes the game on hello
|
||||||
Bug #6129: Player avatar not displayed correctly for large window sizes when GUI scaling active
|
Bug #6129: Player avatar not displayed correctly for large window sizes when GUI scaling active
|
||||||
Bug #6131: Item selection in the avatar window not working correctly for large window sizes
|
Bug #6131: Item selection in the avatar window not working correctly for large window sizes
|
||||||
Bug #6133: Cannot reliably sneak or steal in the sight of the NPCs siding with player
|
Bug #6133: Cannot reliably sneak or steal in the sight of the NPCs siding with player
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <components/esm/locals.hpp>
|
#include <components/esm/locals.hpp>
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/compiler/locals.hpp>
|
#include <components/compiler/locals.hpp>
|
||||||
#include <components/compiler/exception.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/scriptmanager.hpp"
|
#include "../mwbase/scriptmanager.hpp"
|
||||||
|
@ -64,8 +63,6 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Locals::hasVar(const std::string &script, const std::string &var)
|
bool Locals::hasVar(const std::string &script, const std::string &var)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ensure (script);
|
ensure (script);
|
||||||
|
|
||||||
|
@ -74,11 +71,6 @@ namespace MWScript
|
||||||
int index = locals.getIndex(var);
|
int index = locals.getIndex(var);
|
||||||
return (index != -1);
|
return (index != -1);
|
||||||
}
|
}
|
||||||
catch (const Compiler::SourceException&)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int Locals::getIntVar(const std::string &script, const std::string &var)
|
int Locals::getIntVar(const std::string &script, const std::string &var)
|
||||||
{
|
{
|
||||||
|
@ -162,8 +154,6 @@ namespace MWScript
|
||||||
if (!mInitialised)
|
if (!mInitialised)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const Compiler::Locals& declarations =
|
const Compiler::Locals& declarations =
|
||||||
MWBase::Environment::get().getScriptManager()->getLocals(script);
|
MWBase::Environment::get().getScriptManager()->getLocals(script);
|
||||||
|
|
||||||
|
@ -194,10 +184,6 @@ namespace MWScript
|
||||||
locals.mVariables.emplace_back (names[i2], value);
|
locals.mVariables.emplace_back (names[i2], value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (const Compiler::SourceException&)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -206,8 +192,6 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
ensure (script);
|
ensure (script);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const Compiler::Locals& declarations =
|
const Compiler::Locals& declarations =
|
||||||
MWBase::Environment::get().getScriptManager()->getLocals(script);
|
MWBase::Environment::get().getScriptManager()->getLocals(script);
|
||||||
|
|
||||||
|
@ -270,8 +254,4 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Compiler::SourceException&)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,14 +170,14 @@ namespace MWScript
|
||||||
std::string name2 = Misc::StringUtils::lowerCase (name);
|
std::string name2 = Misc::StringUtils::lowerCase (name);
|
||||||
|
|
||||||
{
|
{
|
||||||
ScriptCollection::iterator iter = mScripts.find (name2);
|
auto iter = mScripts.find (name2);
|
||||||
|
|
||||||
if (iter!=mScripts.end())
|
if (iter!=mScripts.end())
|
||||||
return iter->second.mLocals;
|
return iter->second.mLocals;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::map<std::string, Compiler::Locals>::iterator iter = mOtherLocals.find (name2);
|
auto iter = mOtherLocals.find (name2);
|
||||||
|
|
||||||
if (iter!=mOtherLocals.end())
|
if (iter!=mOtherLocals.end())
|
||||||
return iter->second;
|
return iter->second;
|
||||||
|
@ -192,10 +192,22 @@ namespace MWScript
|
||||||
std::istringstream stream (script->mScriptText);
|
std::istringstream stream (script->mScriptText);
|
||||||
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
||||||
Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions());
|
Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions());
|
||||||
|
try
|
||||||
|
{
|
||||||
scanner.scan (parser);
|
scanner.scan (parser);
|
||||||
|
}
|
||||||
|
catch (const Compiler::SourceException&)
|
||||||
|
{
|
||||||
|
// error has already been reported via error handler
|
||||||
|
locals.clear();
|
||||||
|
}
|
||||||
|
catch (const std::exception& error)
|
||||||
|
{
|
||||||
|
Log(Debug::Error) << "Error: An exception has been thrown: " << error.what();
|
||||||
|
locals.clear();
|
||||||
|
}
|
||||||
|
|
||||||
std::map<std::string, Compiler::Locals>::iterator iter =
|
auto iter = mOtherLocals.emplace(name2, locals).first;
|
||||||
mOtherLocals.emplace(name2, locals).first;
|
|
||||||
|
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue