- for (vector<SDL_Surface *>::const_iterator i(images.begin()), end(images.end()); i != end; ++i) {
- SDL_FreeSurface(*i);
- }
- for (vector<Monster *>::const_iterator i(monsters.begin()), end(monsters.end()); i != end; ++i) {
- delete *i;
- }
- for (vector<SimpleAnimation *>::const_iterator i(simpleAnimations.begin()), end(simpleAnimations.end()); i != end; ++i) {
- delete *i;
- }
- for (vector<Sprite *>::const_iterator i(sprites.begin()), end(sprites.end()); i != end; ++i) {
- delete *i;
- }
- for (vector<const char *>::const_iterator i(strings.begin()), end(strings.end()); i != end; ++i) {
- delete *i;
- }
-}
-
-
-Animation *Interpreter::GetAnimation(const std::string &name) {
- map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
- if (i != parsedDefinitions.end()) {
- if (i->second.type == COMPLEX_ANIMATION) {
- return complexAnimations[i->second.index];
- } else if (i->second.type == SIMPLE_ANIMATION) {
- return simpleAnimations[i->second.index];
- } else {
- throw Error("cannot cast " + i->second.dfn->TypeName() + " to Animation");
- }
- } else {
- throw Error("access to undefined Animation " + name);
- }
-}
-
-bool Interpreter::GetBoolean(const std::string &name) const {
- map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
- if (i != parsedDefinitions.end()) {
- if (i->second.type == BOOLEAN) {
- return booleans[i->second.index];
- } else {
- throw Error("cannot cast " + i->second.dfn->TypeName() + " to Boolean");
- }
- } else {
- throw Error("access to undefined Boolean " + name);
- }
-}
-
-Hero *Interpreter::GetHero(const std::string &name) {
- map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
- if (i != parsedDefinitions.end()) {
- if (i->second.type == HERO) {
- return heroes[i->second.index];
- } else {
- throw Error("cannot cast " + i->second.dfn->TypeName() + " to Hero");
- }
- } else {
- throw Error("access to undefined Hero " + name);
- }
-}
-
-Monster *Interpreter::GetMonster(const std::string &name) {
- map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
- if (i != parsedDefinitions.end()) {
- if (i->second.type == MONSTER) {
- return monsters[i->second.index];
- } else {
- throw Error("cannot cast " + i->second.dfn->TypeName() + " to Monster");
- }
- } else {
- throw Error("access to undefined Monster " + name);
- }
-}
-
-int Interpreter::GetNumber(const std::string &name) const {
- map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
- if (i != parsedDefinitions.end()) {
- if (i->second.type == NUMBER) {
- return numbers[i->second.index];
- } else {
- throw Error("cannot cast " + i->second.dfn->TypeName() + " to Number");
- }
- } else {
- throw Error("access to undefined Number " + name);
- }
-}
-
-Sprite *Interpreter::GetSprite(const std::string &name) {
- map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
- if (i != parsedDefinitions.end()) {
- if (i->second.type == SPRITE) {
- return sprites[i->second.index];
- } else {
- throw Error("cannot cast " + i->second.dfn->TypeName() + " to Sprite");