]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Interpreter.h
deallocate most of the stuff Interpreter reservers
[l2e.git] / src / loader / Interpreter.h
index 9ba5924a8ab85173e4967c167cc6a62ac6139149..a32b3cad6d4c8a90cd8401f25c868955c2dd23fc 100644 (file)
@@ -12,7 +12,6 @@
 #include "../graphics/ComplexAnimation.h"
 
 #include <map>
-#include <set>
 #include <stdexcept>
 #include <string>
 #include <vector>
@@ -47,7 +46,7 @@ public:
 
 public:
        Interpreter(const ParsedSource &source) : source(source) { }
-       ~Interpreter() { }
+       ~Interpreter();
 private:
        Interpreter(const Interpreter &);
        Interpreter &operator =(const Interpreter &);
@@ -55,6 +54,13 @@ private:
 public:
        void ReadSource();
 
+public:
+       graphics::Animation *GetAnimation(const std::string &name);
+       battle::Hero *GetHero(const std::string &name);
+       battle::Monster *GetMonster(const std::string &name);
+       int GetNumber(const std::string &name) const;
+       graphics::Sprite *GetSprite(const std::string &name);
+
 private:
        void ReadDefinition(const Definition &);
        void ReadLiteral(const Definition &);
@@ -81,13 +87,31 @@ private:
 
 private:
        const ParsedSource &source;
-       std::set<std::string> parsedDefinitions;
-
-       std::map<std::string, graphics::Animation *> animations;
-       std::map<std::string, battle::Hero *> heroes;
-       std::map<std::string, battle::Monster *> monsters;
-       std::map<std::string, int> numbers;
-       std::map<std::string, graphics::Sprite *> sprites;
+       enum DynamicType {
+               ANIMATION,
+               COMPLEX_ANIMATION,
+               HERO,
+               MONSTER,
+               NUMBER,
+               SIMPLE_ANIMATION,
+               SPRITE,
+       };
+       struct ParsedDefinition {
+               ParsedDefinition(const Definition *dfn, DynamicType type, int index)
+               : dfn(dfn), type(type), index(index) { }
+               bool IsCompatible(DynamicType with) const;
+               const Definition *dfn;
+               DynamicType type;
+               int index;
+       };
+       std::map<std::string, ParsedDefinition> parsedDefinitions;
+
+       std::vector<graphics::Animation *> animations;
+       std::vector<battle::Hero> heroes;
+       std::vector<SDL_Surface *> images;
+       std::vector<battle::Monster> monsters;
+       std::vector<int> numbers;
+       std::vector<graphics::Sprite> sprites;
 
 };