]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Interpreter.cpp
define NDEBUG for Release build config
[l2e.git] / src / loader / Interpreter.cpp
index 550be2678f7e75f175b9a187a50080079d911a70..1005c64db76e5bbbbe7f3aa800e9868e646a30cd 100644 (file)
@@ -301,6 +301,9 @@ void Interpreter::ReadObject(int typeId, int id, char *object, const PropertyLis
                                }
                        } else {
                                char *src(reinterpret_cast<char *>(GetObject(fd.TypeId(), *i->second)));
+                               if (fd.TypeId() == TypeDescription::GetTypeId("Image")) {
+                                       src = reinterpret_cast<char *>(GetImage(src));
+                               }
                                if (fd.IsReferenced()) {
                                        std::memcpy(dest, &src, sizeof(char *));
                                } else {
@@ -314,6 +317,18 @@ void Interpreter::ReadObject(int typeId, int id, char *object, const PropertyLis
 }
 
 
+SDL_Surface *Interpreter::GetImage(const string &path) {
+       map<string, SDL_Surface *>::const_iterator result(imageCache.find(path));
+       if (result != imageCache.end()) {
+               return result->second;
+       } else {
+               SDL_Surface *image(IMG_Load(path.c_str()));
+               imageCache.insert(make_pair(path, image));
+               return image;
+       }
+}
+
+
 bool Interpreter::CanLink(const Value &v) const {
        return v.IsLiteral() || source.IsDefined(v.GetIdentifier());
 }