Merge remote-tracking branch 'scrawl/script'

deque
Marc Zinnschlag 11 years ago
commit 111b55f48e

@ -111,7 +111,7 @@ namespace MWScript
const std::string& name, char type) const const std::string& name, char type) const
{ {
int index = MWBase::Environment::get().getScriptManager()->getLocals (scriptId). int index = MWBase::Environment::get().getScriptManager()->getLocals (scriptId).
search (type, name); searchIndex (type, name);
if (index!=-1) if (index!=-1)
return index; return index;

@ -528,11 +528,12 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr actor = R()(runtime, false);
std::string factionID = ""; std::string factionID = "";
if(arg0==0) if(arg0==0)
{ {
MWWorld::Ptr actor = R()(runtime);
factionID = getDialogueActorFaction(actor); factionID = getDialogueActorFaction(actor);
} }
else else
@ -562,11 +563,12 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr actor = R()(runtime, false);
std::string factionID = ""; std::string factionID = "";
if(arg0==0) if(arg0==0)
{ {
MWWorld::Ptr actor = R()(runtime);
factionID = getDialogueActorFaction(actor); factionID = getDialogueActorFaction(actor);
} }
else else
@ -602,11 +604,12 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr actor = R()(runtime, false);
std::string factionID = ""; std::string factionID = "";
if(arg0==0) if(arg0==0)
{ {
MWWorld::Ptr actor = R()(runtime);
factionID = getDialogueActorFaction(actor); factionID = getDialogueActorFaction(actor);
} }
else else
@ -637,6 +640,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr ptr = R()(runtime, false);
std::string factionID = ""; std::string factionID = "";
if(arg0 >0) if(arg0 >0)
{ {
@ -645,8 +650,6 @@ namespace MWScript
} }
else else
{ {
MWWorld::Ptr ptr = R()(runtime);
if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty()) if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty())
{ {
factionID = ""; factionID = "";
@ -750,6 +753,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr ptr = R()(runtime, false);
std::string factionId; std::string factionId;
if (arg0==1) if (arg0==1)
@ -759,8 +764,6 @@ namespace MWScript
} }
else else
{ {
MWWorld::Ptr ptr = R()(runtime);
if (!ptr.getClass().getNpcStats (ptr).getFactionRanks().empty()) if (!ptr.getClass().getNpcStats (ptr).getFactionRanks().empty())
factionId = ptr.getClass().getNpcStats (ptr).getFactionRanks().begin()->first; factionId = ptr.getClass().getNpcStats (ptr).getFactionRanks().begin()->first;
} }
@ -783,6 +786,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr ptr = R()(runtime, false);
Interpreter::Type_Integer value = runtime[0].mInteger; Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop(); runtime.pop();
@ -795,8 +800,6 @@ namespace MWScript
} }
else else
{ {
MWWorld::Ptr ptr = R()(runtime);
if (!ptr.getClass().getNpcStats (ptr).getFactionRanks().empty()) if (!ptr.getClass().getNpcStats (ptr).getFactionRanks().empty())
factionId = ptr.getClass().getNpcStats (ptr).getFactionRanks().begin()->first; factionId = ptr.getClass().getNpcStats (ptr).getFactionRanks().begin()->first;
} }
@ -818,6 +821,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr ptr = R()(runtime, false);
Interpreter::Type_Integer value = runtime[0].mInteger; Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop(); runtime.pop();
@ -830,8 +835,6 @@ namespace MWScript
} }
else else
{ {
MWWorld::Ptr ptr = R()(runtime);
if (!ptr.getClass().getNpcStats (ptr).getFactionRanks().empty()) if (!ptr.getClass().getNpcStats (ptr).getFactionRanks().empty())
factionId = ptr.getClass().getNpcStats (ptr).getFactionRanks().begin()->first; factionId = ptr.getClass().getNpcStats (ptr).getFactionRanks().begin()->first;
} }
@ -913,6 +916,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr ptr = R()(runtime, false);
std::string factionID = ""; std::string factionID = "";
if(arg0 >0 ) if(arg0 >0 )
{ {
@ -921,8 +926,6 @@ namespace MWScript
} }
else else
{ {
MWWorld::Ptr ptr = R()(runtime);
if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty()) if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty())
{ {
factionID = ""; factionID = "";
@ -952,6 +955,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr ptr = R()(runtime, false);
std::string factionID = ""; std::string factionID = "";
if(arg0 >0 ) if(arg0 >0 )
{ {
@ -960,7 +965,6 @@ namespace MWScript
} }
else else
{ {
MWWorld::Ptr ptr = R()(runtime);
if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty()) if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty())
{ {
factionID = ""; factionID = "";
@ -985,6 +989,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{ {
MWWorld::Ptr ptr = R()(runtime, false);
std::string factionID = ""; std::string factionID = "";
if(arg0 >0 ) if(arg0 >0 )
{ {
@ -993,7 +999,6 @@ namespace MWScript
} }
else else
{ {
MWWorld::Ptr ptr = R()(runtime);
if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty()) if(ptr.getClass().getNpcStats(ptr).getFactionRanks().empty())
{ {
factionID = ""; factionID = "";

@ -1,6 +1,8 @@
#include "lineparser.hpp" #include "lineparser.hpp"
#include <memory>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include "scanner.hpp" #include "scanner.hpp"
@ -120,7 +122,7 @@ namespace Compiler
if (mState==SetMemberVarState) if (mState==SetMemberVarState)
{ {
mMemberName = name; mMemberName = Misc::StringUtils::lowerCase (name);
std::pair<char, bool> type = getContext().getMemberType (mMemberName, mName); std::pair<char, bool> type = getContext().getMemberType (mMemberName, mName);
if (type.first!=' ') if (type.first!=' ')
@ -297,7 +299,12 @@ namespace Compiler
try try
{ {
ErrorDowngrade errorDowngrade (getErrorHandler()); // workaround for broken positioncell instructions.
/// \todo add option to disable this
std::auto_ptr<ErrorDowngrade> errorDowngrade (0);
if (Misc::StringUtils::lowerCase (loc.mLiteral)=="positioncell")
errorDowngrade.reset (new ErrorDowngrade (getErrorHandler()));
std::vector<Interpreter::Type_Code> code; std::vector<Interpreter::Type_Code> code;
optionals = mExprParser.parseArguments (argumentType, scanner, code); optionals = mExprParser.parseArguments (argumentType, scanner, code);
mCode.insert (mCode.begin(), code.begin(), code.end()); mCode.insert (mCode.begin(), code.begin(), code.end());

@ -15,8 +15,6 @@ namespace Compiler
std::vector<std::string> mLongs; std::vector<std::string> mLongs;
std::vector<std::string> mFloats; std::vector<std::string> mFloats;
int searchIndex (char type, const std::string& name) const;
std::vector<std::string>& get (char type); std::vector<std::string>& get (char type);
public: public:
@ -27,9 +25,11 @@ namespace Compiler
int getIndex (const std::string& name) const; int getIndex (const std::string& name) const;
///< return index for local variable \a name (-1: does not exist). ///< return index for local variable \a name (-1: does not exist).
bool search (char type, const std::string& name) const;
/// Return index for local variable \a name of type \a type (-1: variable does not /// Return index for local variable \a name of type \a type (-1: variable does not
/// exit). /// exit).
bool search (char type, const std::string& name) const; int searchIndex (char type, const std::string& name) const;
const std::vector<std::string>& get (char type) const; const std::vector<std::string>& get (char type) const;

Loading…
Cancel
Save