X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.cpp;h=4b0f5e0ae1228e34680a72991a3d24efd858b874;hb=8fd08e32d902b1340dd686ba0d7990fb1be3b861;hp=e8d4ec9ff5be63fae56efcde0e3eef8ead5c8867;hpb=040362d489952ddc935c7130cb54d8b9166b2569;p=l2e.git diff --git a/src/loader/Interpreter.cpp b/src/loader/Interpreter.cpp index e8d4ec9..4b0f5e0 100644 --- a/src/loader/Interpreter.cpp +++ b/src/loader/Interpreter.cpp @@ -14,6 +14,7 @@ #include "../battle/Resources.h" #include "../common/Ikari.h" #include "../common/Item.h" +#include "../common/Script.h" #include "../common/Spell.h" #include "../common/Stats.h" #include "../common/TargetingMode.h" @@ -34,6 +35,7 @@ using battle::Monster; using battle::PartyLayout; using common::Ikari; using common::Item; +using common::Script; using common::Spell; using common::Stats; using common::TargetingMode; @@ -60,8 +62,16 @@ Interpreter::~Interpreter() { } -const Interpreter::ParsedDefinition &Interpreter::GetDefinition(const string &identifier) const { - return parsedDefinitions.at(identifier); +const Interpreter::ParsedDefinition &Interpreter::GetDefinition(const string &identifier) { + std::map::const_iterator i(parsedDefinitions.find(identifier)); + if (i != parsedDefinitions.end()) { + return i->second; + } else if (source.IsDefined(identifier)) { + ReadDefinition(source.GetDefinition(identifier)); + return parsedDefinitions.at(identifier); + } else { + throw Error("access to undefined object " + identifier); + } } @@ -112,13 +122,13 @@ void Interpreter::ReadLiteral(const Definition &dfn) { || dfn.GetLiteral()->GetType() == Literal::STRING) ? dfn.GetLiteral()->GetString().size() : td.Size()); char *object(alloc.Alloc(size)); + values[typeId].push_back(object); + parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, id))); if (dfn.GetLiteral()->GetType() == Literal::OBJECT) { ReadObject(typeId, id, object, *dfn.GetLiteral()->GetProperties()); } else { ReadLiteral(typeId, id, object, *dfn.GetLiteral()); } - values[typeId].push_back(object); - parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, id))); } void Interpreter::ReadLiteral(int typeId, int id, char *object, const Literal &literal) { @@ -142,6 +152,10 @@ void Interpreter::ReadLiteral(int typeId, int id, char *object, const Literal &l std::memcpy(object, literal.GetString().c_str(), literal.GetString().size()); object[literal.GetString().size()] = '\0'; break; + case Literal::SCRIPT: + new (object) Script; + ReadScript(literal.GetScript(), reinterpret_cast