X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FInterpreter.cpp;h=c2ce0d4145abf20ee1b90c291ad7965d2e5446aa;hb=77915e0186f4fc0788054eb34651c726b80d981c;hp=a3d382ceba7618f9f1782bf718c1cf49293753be;hpb=4bc70f5311dcbcca4e6b9e852bbcb19602f50eeb;p=l2e.git diff --git a/src/loader/Interpreter.cpp b/src/loader/Interpreter.cpp index a3d382c..c2ce0d4 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; @@ -54,18 +56,9 @@ using std::vector; namespace loader { Interpreter::~Interpreter() { - for (vector::const_iterator i(postponedDefinitions.begin()), end(postponedDefinitions.end()); i != end; ++i) { - delete i->identifier; - } for (std::map::const_iterator i(imageCache.begin()), end(imageCache.end()); i != end; ++i) { SDL_FreeSurface(i->second); } - // TODO: maybe need to reverse the array deletion check if most objects turn out to be arrays (of char) - for (std::map >::const_iterator i(values.begin()), end(values.end()); i != end; ++i) { - for (vector::const_iterator j(i->second.begin()), end(i->second.end()); j != end; ++j) { - delete[] reinterpret_cast(*j); - } - } } @@ -120,7 +113,7 @@ void Interpreter::ReadLiteral(const Definition &dfn) { (dfn.GetLiteral()->GetType() == Literal::PATH || dfn.GetLiteral()->GetType() == Literal::STRING) ? dfn.GetLiteral()->GetString().size() : td.Size()); - char *object(new char[size]); + char *object(alloc.Alloc(size)); if (dfn.GetLiteral()->GetType() == Literal::OBJECT) { ReadObject(typeId, id, object, *dfn.GetLiteral()->GetProperties()); } else { @@ -151,6 +144,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