]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Interpreter.cpp
ref and load images in l2o files
[l2e.git] / src / loader / Interpreter.cpp
index 51c6b9ce3b2648d23310f00f015126f2f394e2d7..ecbb076224e225bad82cd92017c4db9d5caa33fc 100644 (file)
@@ -906,6 +906,17 @@ SDL_Surface *Interpreter::GetImage(const string &path) {
        }
 }
 
+const string &Interpreter::FindImage(SDL_Surface *img) const {
+       for (std::map<string, SDL_Surface *>::const_iterator
+                       i(imageCache.begin()), end(imageCache.end());
+                       i != end; ++i) {
+               if (i->second == img) {
+                       return i->first;
+               }
+       }
+       throw Error("unable to locate image");
+}
+
 
 bool Interpreter::CanLink(const Value &v) const {
        return v.IsLiteral() || source.IsDefined(v.GetIdentifier());