]> git.localhorst.tv Git - l2e.git/commitdiff
fixed some issues to get it to compile again
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 9 Sep 2012 13:32:16 +0000 (15:32 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 9 Sep 2012 13:32:16 +0000 (15:32 +0200)
18 files changed:
Debug/src/battle/subdir.mk
Debug/src/common/subdir.mk
Debug/src/graphics/subdir.mk
Debug/src/loader/subdir.mk
Release/src/battle/subdir.mk
Release/src/common/subdir.mk
Release/src/graphics/subdir.mk
Release/src/loader/subdir.mk
src/battle/Resources.h
src/common/Item.cpp
src/common/TargetingMode.cpp [new file with mode: 0644]
src/common/TargetingMode.h
src/graphics/Animation.cpp
src/loader/Interpreter.cpp
src/loader/Interpreter.h
src/loader/ParsedSource.h
src/loader/TypeDescription.cpp
src/main.cpp

index 703adbfd609f2d2f9f0b395956b307ddeb7e5f68..7d95878030080d5f096f60212e325ce55e829353 100644 (file)
@@ -13,6 +13,7 @@ CPP_SRCS += \
 ../src/battle/MoveMenu.cpp \
 ../src/battle/NumberAnimation.cpp \
 ../src/battle/PartyLayout.cpp \
 ../src/battle/MoveMenu.cpp \
 ../src/battle/NumberAnimation.cpp \
 ../src/battle/PartyLayout.cpp \
+../src/battle/Resources.cpp \
 ../src/battle/SmallHeroTag.cpp \
 ../src/battle/Stats.cpp \
 ../src/battle/TargetSelection.cpp 
 ../src/battle/SmallHeroTag.cpp \
 ../src/battle/Stats.cpp \
 ../src/battle/TargetSelection.cpp 
@@ -27,6 +28,7 @@ OBJS += \
 ./src/battle/MoveMenu.o \
 ./src/battle/NumberAnimation.o \
 ./src/battle/PartyLayout.o \
 ./src/battle/MoveMenu.o \
 ./src/battle/NumberAnimation.o \
 ./src/battle/PartyLayout.o \
+./src/battle/Resources.o \
 ./src/battle/SmallHeroTag.o \
 ./src/battle/Stats.o \
 ./src/battle/TargetSelection.o 
 ./src/battle/SmallHeroTag.o \
 ./src/battle/Stats.o \
 ./src/battle/TargetSelection.o 
@@ -41,6 +43,7 @@ CPP_DEPS += \
 ./src/battle/MoveMenu.d \
 ./src/battle/NumberAnimation.d \
 ./src/battle/PartyLayout.d \
 ./src/battle/MoveMenu.d \
 ./src/battle/NumberAnimation.d \
 ./src/battle/PartyLayout.d \
+./src/battle/Resources.d \
 ./src/battle/SmallHeroTag.d \
 ./src/battle/Stats.d \
 ./src/battle/TargetSelection.d 
 ./src/battle/SmallHeroTag.d \
 ./src/battle/Stats.d \
 ./src/battle/TargetSelection.d 
index f25318031141ec5a305c938084eca78bb2a5a5d7..8072d36e6d405ba3139a573b649e03d0316df173 100644 (file)
@@ -7,19 +7,22 @@ CPP_SRCS += \
 ../src/common/Ikari.cpp \
 ../src/common/Inventory.cpp \
 ../src/common/Item.cpp \
 ../src/common/Ikari.cpp \
 ../src/common/Inventory.cpp \
 ../src/common/Item.cpp \
-../src/common/Spell.cpp 
+../src/common/Spell.cpp \
+../src/common/TargetingMode.cpp 
 
 OBJS += \
 ./src/common/Ikari.o \
 ./src/common/Inventory.o \
 ./src/common/Item.o \
 
 OBJS += \
 ./src/common/Ikari.o \
 ./src/common/Inventory.o \
 ./src/common/Item.o \
-./src/common/Spell.o 
+./src/common/Spell.o \
+./src/common/TargetingMode.o 
 
 CPP_DEPS += \
 ./src/common/Ikari.d \
 ./src/common/Inventory.d \
 ./src/common/Item.d \
 
 CPP_DEPS += \
 ./src/common/Ikari.d \
 ./src/common/Inventory.d \
 ./src/common/Item.d \
-./src/common/Spell.d 
+./src/common/Spell.d \
+./src/common/TargetingMode.d 
 
 
 # Each subdirectory must supply rules for building sources it contributes
 
 
 # Each subdirectory must supply rules for building sources it contributes
index 53d19d54d82b9c236ea12d9edb7bd24b86689c1a..c755a65ad3f45555602c49fe91c1b97171d85316 100644 (file)
@@ -4,21 +4,33 @@
 
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
 
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
+../src/graphics/Animation.cpp \
+../src/graphics/ComplexAnimation.cpp \
 ../src/graphics/Font.cpp \
 ../src/graphics/Frame.cpp \
 ../src/graphics/Gauge.cpp \
 ../src/graphics/Font.cpp \
 ../src/graphics/Frame.cpp \
 ../src/graphics/Gauge.cpp \
+../src/graphics/Menu.cpp \
+../src/graphics/SimpleAnimation.cpp \
 ../src/graphics/Sprite.cpp 
 
 OBJS += \
 ../src/graphics/Sprite.cpp 
 
 OBJS += \
+./src/graphics/Animation.o \
+./src/graphics/ComplexAnimation.o \
 ./src/graphics/Font.o \
 ./src/graphics/Frame.o \
 ./src/graphics/Gauge.o \
 ./src/graphics/Font.o \
 ./src/graphics/Frame.o \
 ./src/graphics/Gauge.o \
+./src/graphics/Menu.o \
+./src/graphics/SimpleAnimation.o \
 ./src/graphics/Sprite.o 
 
 CPP_DEPS += \
 ./src/graphics/Sprite.o 
 
 CPP_DEPS += \
+./src/graphics/Animation.d \
+./src/graphics/ComplexAnimation.d \
 ./src/graphics/Font.d \
 ./src/graphics/Frame.d \
 ./src/graphics/Gauge.d \
 ./src/graphics/Font.d \
 ./src/graphics/Frame.d \
 ./src/graphics/Gauge.d \
+./src/graphics/Menu.d \
+./src/graphics/SimpleAnimation.d \
 ./src/graphics/Sprite.d 
 
 
 ./src/graphics/Sprite.d 
 
 
index bebb9ab15b132e6eb03c29adcba6779cefe77115..bedbb88b3492ad16404c4df755a8fdfa08039ced 100644 (file)
@@ -8,6 +8,7 @@ CPP_SRCS += \
 ../src/loader/ParsedSource.cpp \
 ../src/loader/Parser.cpp \
 ../src/loader/Tokenizer.cpp \
 ../src/loader/ParsedSource.cpp \
 ../src/loader/Parser.cpp \
 ../src/loader/Tokenizer.cpp \
+../src/loader/TypeDescription.cpp \
 ../src/loader/utility.cpp 
 
 OBJS += \
 ../src/loader/utility.cpp 
 
 OBJS += \
@@ -15,6 +16,7 @@ OBJS += \
 ./src/loader/ParsedSource.o \
 ./src/loader/Parser.o \
 ./src/loader/Tokenizer.o \
 ./src/loader/ParsedSource.o \
 ./src/loader/Parser.o \
 ./src/loader/Tokenizer.o \
+./src/loader/TypeDescription.o \
 ./src/loader/utility.o 
 
 CPP_DEPS += \
 ./src/loader/utility.o 
 
 CPP_DEPS += \
@@ -22,6 +24,7 @@ CPP_DEPS += \
 ./src/loader/ParsedSource.d \
 ./src/loader/Parser.d \
 ./src/loader/Tokenizer.d \
 ./src/loader/ParsedSource.d \
 ./src/loader/Parser.d \
 ./src/loader/Tokenizer.d \
+./src/loader/TypeDescription.d \
 ./src/loader/utility.d 
 
 
 ./src/loader/utility.d 
 
 
index 70d865dcb7e4e46339460740d91f419c380076eb..ba4653eab5f607c8a93a77f3bbca286acdbaf33b 100644 (file)
@@ -13,6 +13,7 @@ CPP_SRCS += \
 ../src/battle/MoveMenu.cpp \
 ../src/battle/NumberAnimation.cpp \
 ../src/battle/PartyLayout.cpp \
 ../src/battle/MoveMenu.cpp \
 ../src/battle/NumberAnimation.cpp \
 ../src/battle/PartyLayout.cpp \
+../src/battle/Resources.cpp \
 ../src/battle/SmallHeroTag.cpp \
 ../src/battle/Stats.cpp \
 ../src/battle/TargetSelection.cpp 
 ../src/battle/SmallHeroTag.cpp \
 ../src/battle/Stats.cpp \
 ../src/battle/TargetSelection.cpp 
@@ -27,6 +28,7 @@ OBJS += \
 ./src/battle/MoveMenu.o \
 ./src/battle/NumberAnimation.o \
 ./src/battle/PartyLayout.o \
 ./src/battle/MoveMenu.o \
 ./src/battle/NumberAnimation.o \
 ./src/battle/PartyLayout.o \
+./src/battle/Resources.o \
 ./src/battle/SmallHeroTag.o \
 ./src/battle/Stats.o \
 ./src/battle/TargetSelection.o 
 ./src/battle/SmallHeroTag.o \
 ./src/battle/Stats.o \
 ./src/battle/TargetSelection.o 
@@ -41,6 +43,7 @@ CPP_DEPS += \
 ./src/battle/MoveMenu.d \
 ./src/battle/NumberAnimation.d \
 ./src/battle/PartyLayout.d \
 ./src/battle/MoveMenu.d \
 ./src/battle/NumberAnimation.d \
 ./src/battle/PartyLayout.d \
+./src/battle/Resources.d \
 ./src/battle/SmallHeroTag.d \
 ./src/battle/Stats.d \
 ./src/battle/TargetSelection.d 
 ./src/battle/SmallHeroTag.d \
 ./src/battle/Stats.d \
 ./src/battle/TargetSelection.d 
index c471112a89764a0633a49af0e134a92a1f8b64a8..d86dbcd271da0437f681fe043b03e8481d007b60 100644 (file)
@@ -7,19 +7,22 @@ CPP_SRCS += \
 ../src/common/Ikari.cpp \
 ../src/common/Inventory.cpp \
 ../src/common/Item.cpp \
 ../src/common/Ikari.cpp \
 ../src/common/Inventory.cpp \
 ../src/common/Item.cpp \
-../src/common/Spell.cpp 
+../src/common/Spell.cpp \
+../src/common/TargetingMode.cpp 
 
 OBJS += \
 ./src/common/Ikari.o \
 ./src/common/Inventory.o \
 ./src/common/Item.o \
 
 OBJS += \
 ./src/common/Ikari.o \
 ./src/common/Inventory.o \
 ./src/common/Item.o \
-./src/common/Spell.o 
+./src/common/Spell.o \
+./src/common/TargetingMode.o 
 
 CPP_DEPS += \
 ./src/common/Ikari.d \
 ./src/common/Inventory.d \
 ./src/common/Item.d \
 
 CPP_DEPS += \
 ./src/common/Ikari.d \
 ./src/common/Inventory.d \
 ./src/common/Item.d \
-./src/common/Spell.d 
+./src/common/Spell.d \
+./src/common/TargetingMode.d 
 
 
 # Each subdirectory must supply rules for building sources it contributes
 
 
 # Each subdirectory must supply rules for building sources it contributes
index fa52cf2ca812b2cb13de42159e04298d216591bb..1b53d998e1bed13a37f298a1ca0f4d5ff4ed421c 100644 (file)
@@ -4,21 +4,33 @@
 
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
 
 # Add inputs and outputs from these tool invocations to the build variables 
 CPP_SRCS += \
+../src/graphics/Animation.cpp \
+../src/graphics/ComplexAnimation.cpp \
 ../src/graphics/Font.cpp \
 ../src/graphics/Frame.cpp \
 ../src/graphics/Gauge.cpp \
 ../src/graphics/Font.cpp \
 ../src/graphics/Frame.cpp \
 ../src/graphics/Gauge.cpp \
+../src/graphics/Menu.cpp \
+../src/graphics/SimpleAnimation.cpp \
 ../src/graphics/Sprite.cpp 
 
 OBJS += \
 ../src/graphics/Sprite.cpp 
 
 OBJS += \
+./src/graphics/Animation.o \
+./src/graphics/ComplexAnimation.o \
 ./src/graphics/Font.o \
 ./src/graphics/Frame.o \
 ./src/graphics/Gauge.o \
 ./src/graphics/Font.o \
 ./src/graphics/Frame.o \
 ./src/graphics/Gauge.o \
+./src/graphics/Menu.o \
+./src/graphics/SimpleAnimation.o \
 ./src/graphics/Sprite.o 
 
 CPP_DEPS += \
 ./src/graphics/Sprite.o 
 
 CPP_DEPS += \
+./src/graphics/Animation.d \
+./src/graphics/ComplexAnimation.d \
 ./src/graphics/Font.d \
 ./src/graphics/Frame.d \
 ./src/graphics/Gauge.d \
 ./src/graphics/Font.d \
 ./src/graphics/Frame.d \
 ./src/graphics/Gauge.d \
+./src/graphics/Menu.d \
+./src/graphics/SimpleAnimation.d \
 ./src/graphics/Sprite.d 
 
 
 ./src/graphics/Sprite.d 
 
 
index d4a66859affc29ba4bd24d396cc1e0f441637c6c..8b5366f185d926fca52c0a70b56fa4d94d90630f 100644 (file)
@@ -8,6 +8,7 @@ CPP_SRCS += \
 ../src/loader/ParsedSource.cpp \
 ../src/loader/Parser.cpp \
 ../src/loader/Tokenizer.cpp \
 ../src/loader/ParsedSource.cpp \
 ../src/loader/Parser.cpp \
 ../src/loader/Tokenizer.cpp \
+../src/loader/TypeDescription.cpp \
 ../src/loader/utility.cpp 
 
 OBJS += \
 ../src/loader/utility.cpp 
 
 OBJS += \
@@ -15,6 +16,7 @@ OBJS += \
 ./src/loader/ParsedSource.o \
 ./src/loader/Parser.o \
 ./src/loader/Tokenizer.o \
 ./src/loader/ParsedSource.o \
 ./src/loader/Parser.o \
 ./src/loader/Tokenizer.o \
+./src/loader/TypeDescription.o \
 ./src/loader/utility.o 
 
 CPP_DEPS += \
 ./src/loader/utility.o 
 
 CPP_DEPS += \
@@ -22,6 +24,7 @@ CPP_DEPS += \
 ./src/loader/ParsedSource.d \
 ./src/loader/Parser.d \
 ./src/loader/Tokenizer.d \
 ./src/loader/ParsedSource.d \
 ./src/loader/Parser.d \
 ./src/loader/Tokenizer.d \
+./src/loader/TypeDescription.d \
 ./src/loader/utility.d 
 
 
 ./src/loader/utility.d 
 
 
index 64fc8e798bde692e53b287641b2f6c79160ec2b1..7286e0db54878dc9ec486821a3b5638920d52d1e 100644 (file)
@@ -9,6 +9,7 @@
 #define BATTLE_RESOURCES_H_
 
 #include "../graphics/Color.h"
 #define BATTLE_RESOURCES_H_
 
 #include "../graphics/Color.h"
+#include "../graphics/Menu.h"
 
 #include <SDL.h>
 
 
 #include <SDL.h>
 
index e695e8d641c0ccf3f7530a024e1c04b081cb82c2..1b54c9a2ac73eef37a0278f64e32bee9b7d72d30 100644 (file)
@@ -38,7 +38,6 @@ void Item::CreateTypeDescription() {
 
        int animationId(TypeDescription::GetTypeId("Animation"));
        int ikariId(TypeDescription::GetTypeId("Ikari"));
 
        int animationId(TypeDescription::GetTypeId("Animation"));
        int ikariId(TypeDescription::GetTypeId("Ikari"));
-       int numberId(TypeDescription::GetTypeId("Number"));
        int spriteId(TypeDescription::GetTypeId("Sprite"));
        int stringId(TypeDescription::GetTypeId("String"));
        int targetsId(TypeDescription::GetTypeId("TargetingMode"));
        int spriteId(TypeDescription::GetTypeId("Sprite"));
        int stringId(TypeDescription::GetTypeId("String"));
        int targetsId(TypeDescription::GetTypeId("TargetingMode"));
diff --git a/src/common/TargetingMode.cpp b/src/common/TargetingMode.cpp
new file mode 100644 (file)
index 0000000..d1627bc
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * TargetingMode.cpp
+ *
+ *  Created on: Sep 9, 2012
+ *      Author: holy
+ */
+
+#include "TargetingMode.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace common {
+
+void TargetingMode::CreateTypeDescription() {
+       TargetingMode t;
+       TypeDescription &td(TypeDescription::CreateOrGet("TargetingMode"));
+
+       td.SetSize(sizeof(TargetingMode));
+
+       // TODO: fields
+}
+
+}
index 90414485599168a349a1cf4572b4e1506f539621..08829deeb30aab092b8ed10da88307179d729d98 100644 (file)
@@ -37,6 +37,8 @@ public:
        void TargetMultipleAllies() { mode = ALLY | MULTIPLE; }
        void TargetSingleAlly() { mode = ALLY | SINGLE; }
 
        void TargetMultipleAllies() { mode = ALLY | MULTIPLE; }
        void TargetSingleAlly() { mode = ALLY | SINGLE; }
 
+       static void CreateTypeDescription();
+
 private:
        enum {
                ALL = 0,
 private:
        enum {
                ALL = 0,
index caffb50c653a814ed9d1512e0c1591531d2b5095..c1ba63797ab7ac061163a600a7d50fd5104f144f 100644 (file)
@@ -14,7 +14,7 @@ using loader::TypeDescription;
 
 namespace graphics {
 
 
 namespace graphics {
 
-void AddFields(TypeDescription &td, const Animation &a, std::ptrdiff_t offset) {
+void Animation::AddFields(TypeDescription &td, const Animation &a, std::ptrdiff_t offset) {
        int boolId(TypeDescription::GetTypeId("Boolean"));
        int numberId(TypeDescription::GetTypeId("Number"));
        int spriteId(TypeDescription::GetTypeId("Sprite"));
        int boolId(TypeDescription::GetTypeId("Boolean"));
        int numberId(TypeDescription::GetTypeId("Number"));
        int spriteId(TypeDescription::GetTypeId("Sprite"));
index fcfe473eaad533b69210a914ebd66d9710873704..ddcc8528b95183e33bc25c8ca4e822cc9316ca19 100644 (file)
@@ -54,320 +54,37 @@ using std::vector;
 namespace loader {
 
 Interpreter::~Interpreter() {
 namespace loader {
 
 Interpreter::~Interpreter() {
-       for (vector<battle::Resources *>::const_iterator i(battleResources.begin()), end(battleResources.end()); i != end; ++i) {
-               delete *i;
+       for (vector<PostponedDefinition>::const_iterator i(postponedDefinitions.begin()), end(postponedDefinitions.end()); i != end; ++i) {
+               delete i->identifier;
        }
        }
-       for (vector<ComplexAnimation *>::const_iterator i(complexAnimations.begin()), end(complexAnimations.end()); i != end; ++i) {
-               delete *i;
+       for (map<string, SDL_Surface *>::const_iterator i(imageCache.begin()), end(imageCache.end()); i != end; ++i) {
+               SDL_FreeSurface(i->second);
        }
        }
-       for (vector<Font *>::const_iterator i(fonts.begin()), end(fonts.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<Frame *>::const_iterator i(frames.begin()), end(frames.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<Gauge *>::const_iterator i(gauges.begin()), end(gauges.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<Hero *>::const_iterator i(heroes.begin()), end(heroes.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<Ikari *>::const_iterator i(ikaris.begin()), end(ikaris.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<SDL_Surface *>::const_iterator i(images.begin()), end(images.end()); i != end; ++i) {
-               SDL_FreeSurface(*i);
-       }
-       for (vector<Item *>::const_iterator i(items.begin()), end(items.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<graphics::MenuProperties *>::const_iterator i(menuProperties.begin()), end(menuProperties.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<Monster *>::const_iterator i(monsters.begin()), end(monsters.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<PartyLayout *>::const_iterator i(partyLayouts.begin()), end(partyLayouts.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<SimpleAnimation *>::const_iterator i(simpleAnimations.begin()), end(simpleAnimations.end()); i != end; ++i) {
-               delete *i;
-       }
-       for (vector<Spell *>::const_iterator i(spells.begin()), end(spells.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;
-       }
-       for (vector<TargetingMode *>::const_iterator i(targetingModes.begin()), end(targetingModes.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);
-       }
-}
-
-battle::Resources *Interpreter::GetBattleResources(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == BATTLE_RESOURCES) {
-                       return battleResources[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to BattleResources");
-               }
-       } else {
-               throw Error("access to undefined BattleResources " + 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);
-       }
-}
-
-const Color &Interpreter::GetColor(const std::string &name) const {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == COLOR) {
-                       return colors[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Color");
-               }
-       } else {
-               throw Error("access to undefined Color " + name);
-       }
-}
-
-Font *Interpreter::GetFont(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == FONT) {
-                       return fonts[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Font");
+       // TODO: maybe need to reverse the array deletion check if most objects turn out to be arrays (of char)
+       for (map<int, vector<void *> >::const_iterator i(values.begin()), end(values.end()); i != end; ++i) {
+               for (vector<void *>::const_iterator j(i->second.begin()), end(i->second.end()); j != end; ++j) {
+                       delete[] reinterpret_cast<char *>(*j);
                }
                }
-       } else {
-               throw Error("access to undefined Font " + name);
        }
 }
 
        }
 }
 
-Frame *Interpreter::GetFrame(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == FRAME) {
-                       return frames[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Frame");
-               }
-       } else {
-               throw Error("access to undefined Frame " + name);
-       }
-}
-
-Gauge *Interpreter::GetGauge(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == GAUGE) {
-                       return gauges[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Gauge");
-               }
-       } else {
-               throw Error("access to undefined Gauge " + name);
-       }
-}
 
 
-Hero *Interpreter::GetHero(const std::string &name) {
+void *Interpreter::GetObject(int typeId, const std::string &name) {
        map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
        if (i != parsedDefinitions.end()) {
        map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
        if (i != parsedDefinitions.end()) {
-               if (i->second.type == HERO) {
-                       return heroes[i->second.index];
+               const TypeDescription &requested(TypeDescription::Get(typeId));
+               const TypeDescription &actual(TypeDescription::Get(i->second.type));
+               if (requested.TypeId() == actual.TypeId()) {
+                       return values[actual.TypeId()][i->second.id];
+               } else if (actual.IsSubtypeOf(requested)) {
+                       char *sub(reinterpret_cast<char *>(values[actual.TypeId()][i->second.id]));
+                       std::ptrdiff_t offset(actual.SupertypeOffset(requested));
+                       return sub - offset;
                } else {
                } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Hero");
+                       throw Error("cannot cast " + actual.TypeName() + " to " + requested.TypeName());
                }
        } else {
                }
        } else {
-               throw Error("access to undefined Hero " + name);
-       }
-}
-
-Ikari *Interpreter::GetIkari(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == IKARI) {
-                       return ikaris[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Ikari");
-               }
-       } else {
-               throw Error("access to undefined Ikari " + name);
-       }
-}
-
-Item *Interpreter::GetItem(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == ITEM) {
-                       return items[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Item");
-               }
-       } else {
-               throw Error("access to undefined Item " + name);
-       }
-}
-
-graphics::MenuProperties *Interpreter::GetMenuProperties(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == MENU_PROPERTIES) {
-                       return menuProperties[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to MenuProperties");
-               }
-       } else {
-               throw Error("access to undefined MenuProperties " + 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);
-       }
-}
-
-PartyLayout *Interpreter::GetPartyLayout(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == PARTY_LAYOUT) {
-                       return partyLayouts[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to PartyLayout");
-               }
-       } else {
-               throw Error("access to undefined PartyLayout " + name);
-       }
-}
-
-const char *Interpreter::GetPath(const std::string &name) const {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == PATH) {
-                       return strings[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Path");
-               }
-       } else {
-               throw Error("access to undefined Path " + name);
-       }
-}
-
-Spell *Interpreter::GetSpell(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == SPELL) {
-                       return spells[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Spell");
-               }
-       } else {
-               throw Error("access to undefined Spell " + 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");
-               }
-       } else {
-               throw Error("access to undefined Sprite " + name);
-       }
-}
-
-const char *Interpreter::GetString(const std::string &name) const {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               // TODO: enable path to string casting some time
-               if (i->second.type == STRING /* || i->second.type == PATH */) {
-                       return strings[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to String");
-               }
-       } else {
-               throw Error("access to undefined String " + name);
-       }
-}
-
-TargetingMode *Interpreter::GetTargetingMode(const std::string &name) {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == TARGETING_MODE) {
-                       return targetingModes[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to TargetingMode");
-               }
-       } else {
-               throw Error("access to undefined TargetingMode " + name);
-       }
-}
-
-Vector<int> Interpreter::GetVector(const std::string &name) const {
-       map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(name));
-       if (i != parsedDefinitions.end()) {
-               if (i->second.type == VECTOR) {
-                       return vectors[i->second.index];
-               } else {
-                       throw Error("cannot cast " + i->second.dfn->TypeName() + " to Vector");
-               }
-       } else {
-               throw Error("access to undefined Vector " + name);
+               throw Error("access to undefined object " + name);
        }
 }
 
        }
 }
 
@@ -392,46 +109,58 @@ void Interpreter::ReadDefinition(const Definition &dfn) {
 void Interpreter::ReadLiteral(const Definition &dfn) {
        switch (dfn.GetLiteral()->GetType()) {
                case Literal::ARRAY_VALUES:
 void Interpreter::ReadLiteral(const Definition &dfn) {
        switch (dfn.GetLiteral()->GetType()) {
                case Literal::ARRAY_VALUES:
-                       valueArrays.push_back(dfn.GetLiteral()->GetValues());
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, VALUE_ARRAY, valueArrays.size() - 1)));
+                       throw Error("named value arrays are not supported, sorry");
                        break;
                case Literal::ARRAY_PROPS:
                        break;
                case Literal::ARRAY_PROPS:
-                       propertyListArrays.push_back(dfn.GetLiteral()->GetPropertyLists());
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, PROPERTY_LIST_ARRAY, propertyListArrays.size() - 1)));
+                       throw Error("named property list arrays are not supported, sorry");
                        break;
                case Literal::BOOLEAN:
                        break;
                case Literal::BOOLEAN:
-                       booleans.push_back(dfn.GetLiteral()->GetBoolean());
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, BOOLEAN, booleans.size() - 1)));
+                       {
+                               int typeId(TypeDescription::GetTypeId("Boolean"));
+                               values[typeId].push_back(new bool(dfn.GetLiteral()->GetBoolean()));
+                               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, values[typeId].size() - 1)));
+                       }
                        break;
                case Literal::COLOR:
                        break;
                case Literal::COLOR:
-                       colors.push_back(Color(dfn.GetLiteral()->GetRed(), dfn.GetLiteral()->GetGreen(), dfn.GetLiteral()->GetBlue(), dfn.GetLiteral()->GetAlpha()));
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, COLOR, colors.size() - 1)));
+                       {
+                               int typeId(TypeDescription::GetTypeId("Color"));
+                               values[typeId].push_back(new Color(dfn.GetLiteral()->GetRed(), dfn.GetLiteral()->GetGreen(), dfn.GetLiteral()->GetBlue(), dfn.GetLiteral()->GetAlpha()));
+                               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, values[typeId].size() - 1)));
+                       }
                        break;
                case Literal::NUMBER:
                        break;
                case Literal::NUMBER:
-                       numbers.push_back(dfn.GetLiteral()->GetNumber());
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, NUMBER, numbers.size() - 1)));
+                       {
+                               int typeId(TypeDescription::GetTypeId("Number"));
+                               values[typeId].push_back(new int(dfn.GetLiteral()->GetNumber()));
+                               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, values[typeId].size() - 1)));
+                       }
                        break;
                case Literal::PATH:
                        {
                        break;
                case Literal::PATH:
                        {
+                               int typeId(TypeDescription::GetTypeId("Path"));
                                char *str(new char[dfn.GetLiteral()->GetString().size() + 1]);
                                std::memcpy(str, dfn.GetLiteral()->GetString().c_str(), dfn.GetLiteral()->GetString().size());
                                str[dfn.GetLiteral()->GetString().size()] = '\0';
                                char *str(new char[dfn.GetLiteral()->GetString().size() + 1]);
                                std::memcpy(str, dfn.GetLiteral()->GetString().c_str(), dfn.GetLiteral()->GetString().size());
                                str[dfn.GetLiteral()->GetString().size()] = '\0';
-                               strings.push_back(str);
+                               values[typeId].push_back(str);
+                               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, values[typeId].size() - 1)));
                        }
                        }
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, PATH, strings.size() - 1)));
                        break;
                case Literal::STRING:
                        {
                        break;
                case Literal::STRING:
                        {
+                               int typeId(TypeDescription::GetTypeId("String"));
                                char *str(new char[dfn.GetLiteral()->GetString().size() + 1]);
                                std::memcpy(str, dfn.GetLiteral()->GetString().c_str(), dfn.GetLiteral()->GetString().size());
                                str[dfn.GetLiteral()->GetString().size()] = '\0';
                                char *str(new char[dfn.GetLiteral()->GetString().size() + 1]);
                                std::memcpy(str, dfn.GetLiteral()->GetString().c_str(), dfn.GetLiteral()->GetString().size());
                                str[dfn.GetLiteral()->GetString().size()] = '\0';
-                               strings.push_back(str);
+                               values[typeId].push_back(str);
+                               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, values[typeId].size() - 1)));
                        }
                        }
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, STRING, strings.size() - 1)));
                        break;
                case Literal::VECTOR:
                        break;
                case Literal::VECTOR:
-                       vectors.push_back(Vector<int>(dfn.GetLiteral()->GetX(), dfn.GetLiteral()->GetY()));
-                       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, VECTOR, vectors.size() - 1)));
+                       {
+                               int typeId(TypeDescription::GetTypeId("Vector"));
+                               values[typeId].push_back(new Vector<int>(dfn.GetLiteral()->GetX(), dfn.GetLiteral()->GetY()));
+                               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, values[typeId].size() - 1)));
+                       }
                        break;
                case Literal::OBJECT:
                        ReadObject(dfn);
                        break;
                case Literal::OBJECT:
                        ReadObject(dfn);
@@ -439,810 +168,193 @@ void Interpreter::ReadLiteral(const Definition &dfn) {
        }
 }
 
        }
 }
 
-Animation *Interpreter::GetAnimation(const Value &v) {
-       if (v.IsLiteral()) {
-               if (v.GetLiteral().GetTypeName() == "ComplexAnimation") {
-                       ComplexAnimation *a(new ComplexAnimation);
-                       ReadComplexAnimation(*a, *v.GetLiteral().GetProperties());
-                       complexAnimations.push_back(a);
-                       return a;
-               } else {
-                       SimpleAnimation *a(new SimpleAnimation);
-                       ReadSimpleAnimation(*a, *v.GetLiteral().GetProperties());
-                       simpleAnimations.push_back(a);
-                       return a;
-               }
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetAnimation(v.GetIdentifier());
-       }
-}
-
-battle::Resources *Interpreter::GetBattleResources(const Value &v) {
-       if (v.IsLiteral()) {
-               battle::Resources *r(new battle::Resources);
-               ReadBattleResources(*r, *v.GetLiteral().GetProperties());
-               return r;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetBattleResources(v.GetIdentifier());
-       }
-}
 
 
-bool Interpreter::GetBoolean(const Value &v) {
+void *Interpreter::GetObject(int typeId, const Value &v) {
        if (v.IsLiteral()) {
        if (v.IsLiteral()) {
-               return v.GetLiteral().GetBoolean();
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetBoolean(v.GetIdentifier());
-       }
-}
-
-Color Interpreter::GetColor(const Value &v) {
-       if (v.IsLiteral()) {
-               return Color(v.GetLiteral().GetRed(), v.GetLiteral().GetGreen(), v.GetLiteral().GetBlue(), v.GetLiteral().GetAlpha());
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetColor(v.GetIdentifier());
-       }
-}
-
-Font *Interpreter::GetFont(const Value &v) {
-       if (v.IsLiteral()) {
-               Font *f(new Font);
-               ReadFont(*f, *v.GetLiteral().GetProperties());
-               return f;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetFont(v.GetIdentifier());
-       }
-}
-
-Frame *Interpreter::GetFrame(const Value &v) {
-       if (v.IsLiteral()) {
-               Frame *f(new Frame);
-               ReadFrame(*f, *v.GetLiteral().GetProperties());
-               return f;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetFrame(v.GetIdentifier());
-       }
-}
-
-Gauge *Interpreter::GetGauge(const Value &v) {
-       if (v.IsLiteral()) {
-               Gauge *g(new Gauge);
-               ReadGauge(*g, *v.GetLiteral().GetProperties());
-               return g;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetGauge(v.GetIdentifier());
-       }
-}
-
-Hero *Interpreter::GetHero(const Value &v) {
-       if (v.IsLiteral()) {
-               Hero *h(new Hero);
-               ReadHero(*h, *v.GetLiteral().GetProperties());
-               return h;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetHero(v.GetIdentifier());
-       }
-}
-
-Ikari *Interpreter::GetIkari(const Value &v) {
-       if (v.IsLiteral()) {
-               Ikari *i(new Ikari);
-               ReadIkari(*i, *v.GetLiteral().GetProperties());
-               return i;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetIkari(v.GetIdentifier());
-       }
-}
-
-SDL_Surface *Interpreter::GetImage(const Value &v) {
-       string path(GetPath(v));
-       map<string, SDL_Surface *>::const_iterator i(imageCache.find(path));
-       if (i == imageCache.end()) {
-               SDL_Surface *image(IMG_Load(path.c_str()));
-               images.push_back(image);
-               imageCache.insert(make_pair(path, image));
-               return image;
-       } else {
-               return i->second;
-       }
-}
-
-Item *Interpreter::GetItem(const Value &v) {
-       if (v.IsLiteral()) {
-               Item *i(new Item);
-               ReadItem(*i, *v.GetLiteral().GetProperties());
-               return i;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetItem(v.GetIdentifier());
-       }
-}
-
-graphics::MenuProperties *Interpreter::GetMenuProperties(const Value &v) {
-       if (v.IsLiteral()) {
-               graphics::MenuProperties *m(new graphics::MenuProperties);
-               ReadMenuProperties(*m, *v.GetLiteral().GetProperties());
-               return m;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetMenuProperties(v.GetIdentifier());
-       }
-}
-
-Monster *Interpreter::GetMonster(const Value &v) {
-       if (v.IsLiteral()) {
-               Monster *m(new Monster);
-               ReadMonster(*m, *v.GetLiteral().GetProperties());
-               return m;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetMonster(v.GetIdentifier());
-       }
-}
-
-int Interpreter::GetNumber(const Value &v) {
-       if (v.IsLiteral()) {
-               return v.GetLiteral().GetNumber();
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetNumber(v.GetIdentifier());
-       }
-}
-
-PartyLayout *Interpreter::GetPartyLayout(const Value &v) {
-       if (v.IsLiteral()) {
-               PartyLayout *l(new PartyLayout);
-               ReadPartyLayout(*l, *v.GetLiteral().GetProperties());
-               return l;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetPartyLayout(v.GetIdentifier());
-       }
-}
-
-const char *Interpreter::GetPath(const Value &v) {
-       if (v.IsLiteral()) {
-               return v.GetLiteral().GetString().c_str();
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetPath(v.GetIdentifier());
-       }
-}
-
-const PropertyList *Interpreter::GetPropertyList(const Value &v) {
-       if (v.IsLiteral()) {
-               return v.GetLiteral().GetProperties();
-       } else {
-               throw Error("cannot reference property lists");
-       }
-}
-
-const vector<PropertyList *> &Interpreter::GetPropertyListArray(const Value &v) {
-       if (v.IsLiteral()) {
-               return v.GetLiteral().GetPropertyLists();
-       } else {
-               throw Error("cannot reference property list arrays");
-       }
-}
-
-Spell *Interpreter::GetSpell(const Value &v) {
-       if (v.IsLiteral()) {
-               Spell *s(new Spell);
-               ReadSpell(*s, *v.GetLiteral().GetProperties());
-               return s;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetSpell(v.GetIdentifier());
-       }
-}
-
-Sprite *Interpreter::GetSprite(const Value &v) {
-       if (v.IsLiteral()) {
-               Sprite *s(new Sprite);
-               ReadSprite(*s, *v.GetLiteral().GetProperties());
-               return s;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetSprite(v.GetIdentifier());
-       }
-}
-
-const char *Interpreter::GetString(const Value &v) {
-       if (v.IsLiteral()) {
-               return v.GetLiteral().GetString().c_str();
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetString(v.GetIdentifier());
-       }
-}
-
-TargetingMode *Interpreter::GetTargetingMode(const Value &v) {
-       if (v.IsLiteral()) {
-               TargetingMode *t(new TargetingMode);
-               ReadTargetingMode(*t, *v.GetLiteral().GetProperties());
-               return t;
-       } else {
-               ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetTargetingMode(v.GetIdentifier());
-       }
-}
-
-Vector<int> Interpreter::GetVector(const Value &v) {
-       if (v.IsLiteral()) {
-               return Vector<int>(v.GetLiteral().GetX(), v.GetLiteral().GetY());
+               if (v.GetLiteral().IsObject()) {
+                       int typeId(TypeDescription::GetTypeId(v.GetLiteral().GetTypeName()));
+                       const TypeDescription &td(TypeDescription::Get(typeId));
+                       char *object(new char[td.Size()]);
+                       int id(values[typeId].size());
+                       values[typeId].push_back(object);
+                       ReadObject(typeId, id, object, *v.GetLiteral().GetProperties());
+                       return object;
+               } else {
+                       int typeId(0), id(0);
+                       switch (v.GetLiteral().GetType()) {
+                               case Literal::ARRAY_VALUES:
+                                       throw Error("cannot copy value arrays, sorry");
+                                       break;
+                               case Literal::ARRAY_PROPS:
+                                       throw Error("cannot copy property list arrays, sorry");
+                                       break;
+                               case Literal::BOOLEAN:
+                                       {
+                                               typeId = TypeDescription::GetTypeId("Boolean");
+                                               id = values[typeId].size();
+                                               const TypeDescription &td(TypeDescription::Get(typeId));
+                                               char *object(new char[td.Size()]);
+                                               values[typeId].push_back(new (object) bool(v.GetLiteral().GetBoolean()));
+                                       }
+                                       break;
+                               case Literal::COLOR:
+                                       {
+                                               typeId = TypeDescription::GetTypeId("Color");
+                                               id = values[typeId].size();
+                                               const TypeDescription &td(TypeDescription::Get(typeId));
+                                               char *object(new char[td.Size()]);
+                                               values[typeId].push_back(new (object) Color(v.GetLiteral().GetRed(), v.GetLiteral().GetGreen(), v.GetLiteral().GetBlue(), v.GetLiteral().GetAlpha()));
+                                       }
+                                       break;
+                               case Literal::NUMBER:
+                                       {
+                                               typeId = TypeDescription::GetTypeId("Number");
+                                               id = values[typeId].size();
+                                               const TypeDescription &td(TypeDescription::Get(typeId));
+                                               char *object(new char[td.Size()]);
+                                               values[typeId].push_back(new (object) int(v.GetLiteral().GetNumber()));
+                                       }
+                                       break;
+                               case Literal::PATH:
+                                       {
+                                               typeId = TypeDescription::GetTypeId("Path");
+                                               id = values[typeId].size();
+                                               char *str(new char[v.GetLiteral().GetString().size() + 1]);
+                                               std::memcpy(str, v.GetLiteral().GetString().c_str(), v.GetLiteral().GetString().size());
+                                               str[v.GetLiteral().GetString().size()] = '\0';
+                                               values[typeId].push_back(str);
+                                       }
+                                       break;
+                               case Literal::STRING:
+                                       {
+                                               typeId = TypeDescription::GetTypeId("String");
+                                               id = values[typeId].size();
+                                               char *str(new char[v.GetLiteral().GetString().size() + 1]);
+                                               std::memcpy(str, v.GetLiteral().GetString().c_str(), v.GetLiteral().GetString().size());
+                                               str[v.GetLiteral().GetString().size()] = '\0';
+                                               values[typeId].push_back(str);
+                                       }
+                                       break;
+                               case Literal::VECTOR:
+                                       {
+                                               typeId = TypeDescription::GetTypeId("Vector");
+                                               id = values[typeId].size();
+                                               const TypeDescription &td(TypeDescription::Get(typeId));
+                                               char *object(new char[td.Size()]);
+                                               values[typeId].push_back(new (object) Vector<int>(v.GetLiteral().GetX(), v.GetLiteral().GetY()));
+                                       }
+                                       break;
+                               case Literal::OBJECT:
+                                       {
+                                               typeId = TypeDescription::GetTypeId(v.GetLiteral().GetTypeName());
+                                               const TypeDescription &td(TypeDescription::Get(typeId));
+                                               id = values[typeId].size();
+                                               char *object(new char[td.Size()]);
+                                               ReadObject(typeId, id, object, *v.GetLiteral().GetProperties());
+                                       }
+                                       break;
+                       }
+                       return values[typeId][id];
+               }
        } else {
                ReadDefinition(source.GetDefinition(v.GetIdentifier()));
        } else {
                ReadDefinition(source.GetDefinition(v.GetIdentifier()));
-               return GetVector(v.GetIdentifier());
-       }
-}
-
-const vector<Value *> &Interpreter::GetValueArray(const Value &v) {
-       if (v.IsLiteral()) {
-               return v.GetLiteral().GetValues();
-       } else {
-               throw Error("cannot reference value arrays");
+               return GetObject(typeId, v.GetIdentifier());
        }
 }
 
 
 void Interpreter::ReadObject(const Definition &dfn) {
        }
 }
 
 
 void Interpreter::ReadObject(const Definition &dfn) {
-       if (dfn.TypeName() == "BattleResources") {
-               battle::Resources *res(new battle::Resources);
-               int index(battleResources.size());
-               battleResources.push_back(res);
-               ReadBattleResources(*res, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, BATTLE_RESOURCES, index)));
-       } else if (dfn.TypeName() == "ComplexAnimation") {
-               ComplexAnimation *animation(new ComplexAnimation);
-               int index(complexAnimations.size());
-               complexAnimations.push_back(animation);
-               ReadComplexAnimation(*animation, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, COMPLEX_ANIMATION, index)));
-       } else if (dfn.TypeName() == "Font") {
-               Font *font(new Font);
-               int index(fonts.size());
-               fonts.push_back(font);
-               ReadFont(*font, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, FONT, index)));
-       } else if (dfn.TypeName() == "Frame") {
-               Frame *frame(new Frame);
-               int index(frames.size());
-               frames.push_back(frame);
-               ReadFrame(*frame, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, FRAME, index)));
-       } else if (dfn.TypeName() == "Gauge") {
-               Gauge *gauge(new Gauge);
-               int index(gauges.size());
-               gauges.push_back(gauge);
-               ReadGauge(*gauge, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, GAUGE, index)));
-       } else if (dfn.TypeName() == "Hero") {
-               Hero *hero(new Hero);
-               int index(heroes.size());
-               heroes.push_back(hero);
-               ReadHero(*hero, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, HERO, index)));
-       } else if (dfn.TypeName() == "Ikari") {
-               Ikari *ikari(new Ikari);
-               int index(ikaris.size());
-               ikaris.push_back(ikari);
-               ReadIkari(*ikari, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, IKARI, index)));
-       } else if (dfn.TypeName() == "Item") {
-               Item *item(new Item);
-               int index(items.size());
-               items.push_back(item);
-               ReadItem(*item, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, ITEM, index)));
-       } else if (dfn.TypeName() == "MenuProperties") {
-               graphics::MenuProperties *mprops(new graphics::MenuProperties);
-               int index(menuProperties.size());
-               menuProperties.push_back(mprops);
-               ReadMenuProperties(*mprops, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, MENU_PROPERTIES, index)));
-       } else if (dfn.TypeName() == "Monster") {
-               Monster *monster(new Monster);
-               int index(monsters.size());
-               monsters.push_back(monster);
-               ReadMonster(*monster, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, MONSTER, index)));
-       } else if (dfn.TypeName() == "PartyLayout") {
-               PartyLayout *layout(new PartyLayout);
-               int index(partyLayouts.size());
-               partyLayouts.push_back(layout);
-               ReadPartyLayout(*layout, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, PARTY_LAYOUT, index)));
-       } else if (dfn.TypeName() == "SimpleAnimation") {
-               SimpleAnimation *animation(new SimpleAnimation);
-               int index(simpleAnimations.size());
-               simpleAnimations.push_back(animation);
-               ReadSimpleAnimation(*animation, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, SIMPLE_ANIMATION, index)));
-       } else if (dfn.TypeName() == "Spell") {
-               Spell *spell(new Spell);
-               int index(spells.size());
-               spells.push_back(spell);
-               ReadSpell(*spell, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, SPELL, index)));
-       } else if (dfn.TypeName() == "Sprite") {
-               Sprite *sprite(new Sprite);
-               int index(sprites.size());
-               sprites.push_back(sprite);
-               ReadSprite(*sprite, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, SPRITE, index)));
-       } else if (dfn.TypeName() == "TargetingMode") {
-               TargetingMode *mode(new TargetingMode);
-               int index(targetingModes.size());
-               targetingModes.push_back(mode);
-               ReadTargetingMode(*mode, *dfn.GetProperties());
-               parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, TARGETING_MODE, index)));
-       } else {
-               throw Error("unhandled object type: " + dfn.TypeName());
-       }
+       int typeId(TypeDescription::GetTypeId(dfn.TypeName()));
+       const TypeDescription &td(TypeDescription::Get(typeId));
+       int id(values[typeId].size());
+       char *object(new char[td.Size()]);
+       values[typeId].push_back(object);
+       ReadObject(typeId, id, object, *dfn.GetProperties());
+       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, id)));
 }
 
 
 }
 
 
-void Interpreter::ReadBattleResources(battle::Resources &res, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "swapCursor") {
-                       res.swapCursor = GetSprite(*i->second);
-               } else if (i->first == "moveIcons") {
-                       res.moveIcons = GetSprite(*i->second);
-               } else if (i->first == "attackIcons") {
-                       res.attackIcons = GetSprite(*i->second);
-               } else if (i->first == "attackChoiceIcons") {
-                       res.attackChoiceIcons = GetSprite(*i->second);
-               } else if (i->first == "titleFrame") {
-                       res.titleFrame = GetFrame(*i->second);
-               } else if (i->first == "titleFont") {
-                       res.titleFont = GetFont(*i->second);
-               } else if (i->first == "heroTagFrame") {
-                       res.heroTagFrame = GetFrame(*i->second);
-               } else if (i->first == "activeHeroTagFrame") {
-                       res.activeHeroTagFrame = GetFrame(*i->second);
-               } else if (i->first == "smallHeroTagFrame") {
-                       res.smallHeroTagFrame = GetFrame(*i->second);
-               } else if (i->first == "lastSmallHeroTagFrame") {
-                       res.lastSmallHeroTagFrame = GetFrame(*i->second);
-               } else if (i->first == "heroTagFont") {
-                       res.heroTagFont = GetFont(*i->second);
-               } else if (i->first == "heroTagLabels") {
-                       res.heroTagLabels = GetSprite(*i->second);
-               } else if (i->first == "healthGauge") {
-                       res.healthGauge = GetGauge(*i->second);
-               } else if (i->first == "manaGauge") {
-                       res.manaGauge = GetGauge(*i->second);
-               } else if (i->first == "ikariGauge") {
-                       res.ikariGauge = GetGauge(*i->second);
-               } else if (i->first == "selectFrame") {
-                       res.selectFrame = GetFrame(*i->second);
-               } else if (i->first == "normalFont") {
-                       res.normalFont = GetFont(*i->second);
-               } else if (i->first == "disabledFont") {
-                       res.disabledFont = GetFont(*i->second);
-               } else if (i->first == "menuCursor") {
-                       res.menuCursor = GetSprite(*i->second);
-               } else if (i->first == "weaponTargetCursor") {
-                       res.weaponTargetCursor = GetSprite(*i->second);
-               } else if (i->first == "magicTargetCursor") {
-                       res.magicTargetCursor = GetSprite(*i->second);
-               } else if (i->first == "itemTargetCursor") {
-                       res.itemTargetCursor = GetSprite(*i->second);
-               } else if (i->first == "spellMenuHeadline") {
-                       res.spellMenuHeadline = GetString(*i->second);
-               } else if (i->first == "spellMenuProperties") {
-                       res.spellMenuProperties = GetMenuProperties(*i->second);
-               } else if (i->first == "itemMenuHeadline") {
-                       res.itemMenuHeadline = GetString(*i->second);
-               } else if (i->first == "itemMenuProperties") {
-                       res.itemMenuProperties = GetMenuProperties(*i->second);
-               } else if (i->first == "ikariMenuHeadline") {
-                       res.ikariMenuHeadline = GetString(*i->second);
-               } else if (i->first == "ikariMenuProperties") {
-                       res.ikariMenuProperties = GetMenuProperties(*i->second);
-               } else if (i->first == "noEquipmentText") {
-                       res.noEquipmentText = GetString(*i->second);
-               } else if (i->first == "escapeText") {
-                       res.escapeText = GetString(*i->second);
-               } else if (i->first == "numberAnimationPrototype") {
-                       res.numberAnimationPrototype = GetAnimation(*i->second);
-               } else if (i->first == "bigNumberSprite") {
-                       res.bigNumberSprite = GetSprite(*i->second);
-               } else if (i->first == "greenNumberSprite") {
-                       res.greenNumberSprite = GetSprite(*i->second);
-               } else if (i->first == "weaponMenuIcon") {
-                       res.weaponMenuIcon = GetSprite(*i->second);
-               } else if (i->first == "armorMenuIcon") {
-                       res.armorMenuIcon = GetSprite(*i->second);
-               } else if (i->first == "shieldMenuIcon") {
-                       res.shieldMenuIcon = GetSprite(*i->second);
-               } else if (i->first == "helmetMenuIcon") {
-                       res.helmetMenuIcon = GetSprite(*i->second);
-               } else if (i->first == "ringMenuIcon") {
-                       res.ringMenuIcon = GetSprite(*i->second);
-               } else if (i->first == "jewelMenuIcon") {
-                       res.jewelMenuIcon = GetSprite(*i->second);
-               } else if (i->first == "levelLabelCol") {
-                       res.levelLabelCol = GetNumber(*i->second);
-               } else if (i->first == "levelLabelRow") {
-                       res.levelLabelRow = GetNumber(*i->second);
-               } else if (i->first == "healthLabelCol") {
-                       res.healthLabelCol = GetNumber(*i->second);
-               } else if (i->first == "healthLabelRow") {
-                       res.healthLabelRow = GetNumber(*i->second);
-               } else if (i->first == "manaLabelCol") {
-                       res.manaLabelCol = GetNumber(*i->second);
-               } else if (i->first == "manaLabelRow") {
-                       res.manaLabelRow = GetNumber(*i->second);
-               } else if (i->first == "moveLabelCol") {
-                       res.moveLabelCol = GetNumber(*i->second);
-               } else if (i->first == "moveLabelRow") {
-                       res.moveLabelRow = GetNumber(*i->second);
-               } else if (i->first == "ikariLabelCol") {
-                       res.ikariLabelCol = GetNumber(*i->second);
-               } else if (i->first == "ikariLabelRow") {
-                       res.ikariLabelRow = GetNumber(*i->second);
-               } else if (i->first == "heroesBgColor") {
-                       res.heroesBgColor = GetColor(*i->second);
-               } else {
-                       throw Error("unknown BattleResources property: " + i->first);
-               }
-       }
-}
-
-void Interpreter::ReadComplexAnimation(ComplexAnimation &a, const PropertyList &props) {
+void Interpreter::ReadObject(int typeId, int id, char *object, const PropertyList &props) {
+       const TypeDescription &td(TypeDescription::Get(typeId));
        for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
        for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "sprite") {
-                       a.SetSprite(GetSprite(*i->second));
-               } else if (i->first == "frametime") {
-                       a.SetFrameTime(GetNumber(*i->second));
-               } else if (i->first == "repeat") {
-                       a.SetRepeat(GetBoolean(*i->second));
-               } else if (i->first == "frames") {
-                       const vector<PropertyList *> &values(GetPropertyListArray(*i->second));
-                       for (vector<PropertyList *>::const_iterator i(values.begin()), end(values.end()); i != end; ++i) {
-                               ComplexAnimation::FrameProp frame;
-                               ReadComplexAnimationFrame(frame, **i);
-                               a.AddFrame(frame);
+               const FieldDescription &fd(td.GetField(i->first));
+               const TypeDescription &fieldType(TypeDescription::Get(fd.TypeId()));
+               if (CanLink(*i->second)) {
+                       char *dest(object + fd.Offset());
+                       if (fd.IsAggregate()) {
+                               if (i->second->GetLiteral().GetType() != Literal::ARRAY_PROPS) {
+                                       throw Error("unsupported aggregate type");
+                               }
+                               int arraySize(i->second->GetLiteral().ArraySize());
+                               char *aggregate(new char[fieldType.Size() * arraySize]);
+                               char *iter(aggregate);
+                               vector<PropertyList *> list(i->second->GetLiteral().GetPropertyLists());
+                               for (vector<PropertyList *>::const_iterator j(list.begin()), end(list.end()); j != end; ++j, iter += fieldType.Size()) {
+                                       ReadObject(fieldType.TypeId(), -1, iter, **j);
+                               }
+                               if (fd.IsReferenced()) {
+                                       std::memcpy(dest, &aggregate, sizeof(char *));
+                                       dest += sizeof(char *);
+                                       std::memcpy(dest, &arraySize, sizeof(int));
+                               } else {
+                                       throw Error("aggregate type fields must be referenced");
+                               }
+                       } else {
+                               char *src(reinterpret_cast<char *>(GetObject(fd.TypeId(), *i->second)));
+                               if (fd.IsReferenced()) {
+                                       std::memcpy(dest, &src, sizeof(char *));
+                               } else {
+                                       std::memcpy(dest, src, fieldType.Size());
+                               }
                        }
                } else {
                        }
                } else {
-                       throw Error("unknown ComplexAnimation property: " + i->first);
+                       Postpone(typeId, id, fd.Offset(), i->second->GetIdentifier(), fd.TypeId());
                }
        }
 }
 
                }
        }
 }
 
-void Interpreter::ReadComplexAnimationFrame(ComplexAnimation::FrameProp &f, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "column") {
-                       f.col = GetNumber(*i->second);
-               } else if (i->first == "row") {
-                       f.row = GetNumber(*i->second);
-               } else if (i->first == "disposition") {
-                       f.disposition = GetVector(*i->second);
-               } else {
-                       throw Error("unknown ComplexAnimationFrame property: " + i->first);
-               }
-       }
-}
 
 
-void Interpreter::ReadFont(Font &f, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "sprite") {
-                       f.SetSprite(GetSprite(*i->second));
-               } else if (i->first == "columnoffset") {
-                       f.SetColOffset(GetNumber(*i->second));
-               } else if (i->first == "rowoffset") {
-                       f.SetRowOffset(GetNumber(*i->second));
-               } else {
-                       throw Error("unknown Font property: " + i->first);
-               }
-       }
+bool Interpreter::CanLink(const Value &v) const {
+       return v.IsLiteral() || source.IsDefined(v.GetIdentifier());
 }
 
 }
 
-void Interpreter::ReadFrame(Frame &f, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "image") {
-                       f.SetSurface(GetImage(*i->second));
-               } else if (i->first == "border") {
-                       f.SetBorderSize(GetVector(*i->second));
-               } else if (i->first == "repeat") {
-                       f.SetRepeatSize(GetVector(*i->second));
-               } else if (i->first == "offset") {
-                       f.SetOffset(GetVector(*i->second));
-               } else {
-                       throw Error("unknown Frame property: " + i->first);
-               }
-       }
+void Interpreter::Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType) {
+       char *str(new char[identifier.size() + 1]);
+       std::memcpy(str, identifier.c_str(), identifier.size());
+       str[identifier.size()] = '\0';
+       postponedDefinitions.push_back(PostponedDefinition(type, id, offset, str, linkedType));
 }
 
 }
 
-void Interpreter::ReadGauge(Gauge &g, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "image") {
-                       g.SetSurface(GetImage(*i->second));
-               } else if (i->first == "full") {
-                       g.SetFullOffset(GetVector(*i->second));
-               } else if (i->first == "empty") {
-                       g.SetEmptyOffset(GetVector(*i->second));
-               } else if (i->first == "height") {
-                       g.SetHeight(GetNumber(*i->second));
-               } else if (i->first == "start") {
-                       g.SetStartWidth(GetNumber(*i->second));
-               } else if (i->first == "repeat") {
-                       g.SetRepeatWidth(GetNumber(*i->second));
-               } else if (i->first == "end") {
-                       g.SetEndWidth(GetNumber(*i->second));
-               } else {
-                       throw Error("unknown Gauge property: " + i->first);
-               }
-       }
-}
 
 
-void Interpreter::ReadIkari(Ikari &ikari, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "name") {
-                       ikari.SetName(GetString(*i->second));
-               } else if (i->first == "cost") {
-                       ikari.SetCost(GetNumber(*i->second));
-               } else if (i->first == "targets") {
-                       ikari.GetTargetingMode() = *GetTargetingMode(*i->second);
-               } else if (i->first == "magical") {
-                       if (GetBoolean(*i->second)) {
-                               ikari.SetMagical();
-                       }
-               } else if (i->first == "physical") {
-                       if (GetBoolean(*i->second)) {
-                               ikari.SetPhysical();
-                       }
-               } else {
-                       throw Error("unknown Ikari property: " + i->first);
-               }
+void Interpreter::CreateTypeDescriptions() {
+       {
+               TypeDescription &td(TypeDescription::CreateOrGet("Boolean"));
+               td.SetSize(sizeof(bool));
        }
        }
-}
-
-void Interpreter::ReadItem(Item &item, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "name") {
-                       item.SetName(GetString(*i->second));
-               } else if (i->first == "menuicon") {
-                       item.SetMenuIcon(GetSprite(*i->second));
-               } else if (i->first == "battle") {
-                       if (GetBoolean(*i->second)) {
-                               item.SetUsableInBattle();
-                       }
-               } else if (i->first == "targets") {
-                       item.GetTargetingMode() = *GetTargetingMode(*i->second);
-               } else if (i->first == "ikari") {
-                       item.SetIkari(GetIkari(*i->second));
-               } else if (i->first == "attackanimation") {
-                       item.SetAttackAnimation(GetAnimation(*i->second));
-               } else {
-                       throw Error("unknown Item property: " + i->first);
-               }
+       {
+               TypeDescription &td(TypeDescription::CreateOrGet("Color"));
+               td.SetSize(sizeof(Color));
        }
        }
-}
-
-void Interpreter::ReadHero(Hero &h, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "name") {
-                       h.SetName(GetString(*i->second));
-               } else if (i->first == "sprite") {
-                       h.SetSprite(GetSprite(*i->second));
-               } else if (i->first == "level") {
-                       h.SetLevel(GetNumber(*i->second));
-               } else if (i->first == "maxHealth") {
-                       h.SetMaxHealth(GetNumber(*i->second));
-               } else if (i->first == "health") {
-                       h.SetHealth(GetNumber(*i->second));
-               } else if (i->first == "maxMana") {
-                       h.SetMaxMana(GetNumber(*i->second));
-               } else if (i->first == "mana") {
-                       h.SetMana(GetNumber(*i->second));
-               } else if (i->first == "ip") {
-                       h.SetIP(GetNumber(*i->second));
-               } else if (i->first == "stats") {
-                       battle::Stats stats;
-                       ReadStats(stats, *GetPropertyList(*i->second));
-                       h.SetStats(stats);
-               } else if (i->first == "attackAnimation") {
-                       h.SetAttackAnimation(GetAnimation(*i->second));
-               } else if (i->first == "spellAnimation") {
-                       h.SetSpellAnimation(GetAnimation(*i->second));
-               } else if (i->first == "meleeAnimation") {
-                       h.SetMeleeAnimation(GetAnimation(*i->second));
-               } else {
-                       throw Error("unknown Hero property: " + i->first);
-               }
+       {
+               TypeDescription &td(TypeDescription::CreateOrGet("Image"));
+               td.SetSize(sizeof(SDL_Surface));
        }
        }
-}
-
-void Interpreter::ReadMenuProperties(graphics::MenuProperties &mprops, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "font") {
-                       mprops.font = GetFont(*i->second);
-               } else if (i->first == "disabledFont") {
-                       mprops.disabledFont = GetFont(*i->second);
-               } else if (i->first == "cursor") {
-                       mprops.cursor = GetSprite(*i->second);
-               } else if (i->first == "charsPerEntry") {
-                       mprops.charsPerEntry = GetNumber(*i->second);
-               } else if (i->first == "rows") {
-                       mprops.rows = GetNumber(*i->second);
-               } else if (i->first == "rowGap") {
-                       mprops.rowGap = GetNumber(*i->second);
-               } else if (i->first == "iconSpace") {
-                       mprops.iconSpace = GetNumber(*i->second);
-               } else if (i->first == "cols") {
-                       mprops.cols = GetNumber(*i->second);
-               } else if (i->first == "colGap") {
-                       mprops.colGap = GetNumber(*i->second);
-               } else if (i->first == "delimiter") {
-                       mprops.delimiter = *GetString(*i->second);
-               } else if (i->first == "charsPerNumber") {
-                       mprops.charsPerNumber = GetNumber(*i->second);
-               } else if (i->first == "charsPerAdditionalText") {
-                       mprops.charsPerAdditionalText = GetNumber(*i->second);
-               } else if (i->first == "additionalTextGap") {
-                       mprops.additionalTextGap = GetNumber(*i->second);
-               } else {
-                       throw Error("unknown MenuProperties property: " + i->first);
-               }
-       }
-}
-
-void Interpreter::ReadMonster(Monster &m, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "name") {
-                       m.SetName(GetString(*i->second));
-               } else if (i->first == "sprite") {
-                       m.SetSprite(GetSprite(*i->second));
-               } else if (i->first == "level") {
-                       m.SetLevel(GetNumber(*i->second));
-               } else if (i->first == "maxHealth") {
-                       m.SetMaxHealth(GetNumber(*i->second));
-               } else if (i->first == "health") {
-                       m.SetHealth(GetNumber(*i->second));
-               } else if (i->first == "maxMana") {
-                       m.SetMaxMana(GetNumber(*i->second));
-               } else if (i->first == "mana") {
-                       m.SetMana(GetNumber(*i->second));
-               } else if (i->first == "stats") {
-                       battle::Stats stats;
-                       ReadStats(stats, *GetPropertyList(*i->second));
-                       m.SetStats(stats);
-               } else if (i->first == "attackAnimation") {
-                       m.SetAttackAnimation(GetAnimation(*i->second));
-               } else if (i->first == "meleeAnimation") {
-                       m.SetMeleeAnimation(GetAnimation(*i->second));
-               } else {
-                       throw Error("unknown Monster property: " + i->first);
-               }
-       }
-}
-
-void Interpreter::ReadPartyLayout(PartyLayout &p, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "positions") {
-                       const vector<Value *> &positions(GetValueArray(*i->second));
-                       for (vector<Value *>::const_iterator j(positions.begin()), end(positions.end()); j != end; ++j) {
-                               p.AddPosition(GetVector(**j));
-                       }
-               } else {
-                       throw Error("unknown PartyLayout property: " + i->first);
-               }
-       }
-}
-
-void Interpreter::ReadSimpleAnimation(SimpleAnimation &a, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "sprite") {
-                       a.SetSprite(GetSprite(*i->second));
-               } else if (i->first == "frametime") {
-                       a.SetFrameTime(GetNumber(*i->second));
-               } else if (i->first == "repeat") {
-                       a.SetRepeat(GetBoolean(*i->second));
-               } else if (i->first == "framecount") {
-                       a.SetNumFrames(GetNumber(*i->second));
-               } else if (i->first == "col") {
-                       a.SetCol(GetNumber(*i->second));
-               } else if (i->first == "row") {
-                       a.SetRow(GetNumber(*i->second));
-               } else {
-                       throw Error("unknown SimpleAnimation property: " + i->first);
-               }
-       }
-}
-
-void Interpreter::ReadSpell(Spell &s, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "name") {
-                       s.SetName(GetString(*i->second));
-               } else if (i->first == "cost") {
-                       s.SetCost(GetNumber(*i->second));
-               } else if (i->first == "battle") {
-                       if (GetBoolean(*i->second)) {
-                               s.SetUsableInBattle();
-                       }
-               } else if (i->first == "targets") {
-                       s.GetTargetingMode() = *GetTargetingMode(*i->second);
-               } else {
-                       throw Error("unknown Spell property: " + i->first);
-               }
+       {
+               TypeDescription &td(TypeDescription::CreateOrGet("Number"));
+               td.SetSize(sizeof(int));
        }
        }
-}
-
-void Interpreter::ReadSprite(Sprite &s, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "image") {
-                       s.SetSurface(GetImage(*i->second));
-               } else if (i->first == "size") {
-                       s.SetSize(GetVector(*i->second));
-               } else if (i->first == "offset") {
-                       s.SetOffset(GetVector(*i->second));
-               } else {
-                       throw Error("unknown Sprite property: " + i->first);
-               }
+       {
+               TypeDescription &td(TypeDescription::CreateOrGet("Path"));
+               td.SetSize(1);
+               td.AddSupertype(TypeDescription::GetTypeId("String"), 0);
        }
        }
-}
-
-void Interpreter::ReadStats(Stats &s, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "atp") {
-                       s.SetAttack(GetNumber(*i->second));
-               } else if (i->first == "dfp") {
-                       s.SetDefense(GetNumber(*i->second));
-               } else if (i->first == "str") {
-                       s.SetStrength(GetNumber(*i->second));
-               } else if (i->first == "agl") {
-                       s.SetAgility(GetNumber(*i->second));
-               } else if (i->first == "int") {
-                       s.SetIntelligence(GetNumber(*i->second));
-               } else if (i->first == "gut") {
-                       s.SetGut(GetNumber(*i->second));
-               } else if (i->first == "mgr") {
-                       s.SetMagicResistance(GetNumber(*i->second));
-               } else {
-                       throw Error("unknown Stats property: " + i->first);
-               }
+       {
+               TypeDescription &td(TypeDescription::CreateOrGet("String"));
+               td.SetSize(1);
        }
        }
-}
-
-void Interpreter::ReadTargetingMode(TargetingMode &t, const PropertyList &props) {
-       for (PropertyList::ConstIterator i(props.Begin()), end(props.End()); i != end; ++i) {
-               if (i->first == "ally") {
-                       if (GetBoolean(*i->second)) {
-                               t.TargetAlly();
-                       } else {
-                               t.TargetEnemy();
-                       }
-               } else if (i->first == "enemy") {
-                       if (GetBoolean(*i->second)) {
-                               t.TargetEnemy();
-                       } else {
-                               t.TargetAlly();
-                       }
-               } else if (i->first == "all") {
-                       if (GetBoolean(*i->second)) {
-                               t.TargetAll();
-                       }
-               } else if (i->first == "multiple") {
-                       if (GetBoolean(*i->second)) {
-                               t.TargetMultiple();
-                       }
-               } else if (i->first == "single") {
-                       if (GetBoolean(*i->second)) {
-                               t.TargetSingle();
-                       }
-               } else {
-                       throw Error("unknown TargetingMode property: " + i->first);
-               }
+       {
+               TypeDescription &td(TypeDescription::CreateOrGet("Vector"));
+               td.SetSize(sizeof(Vector<int>));
        }
 }
 
        }
 }
 
index 044a3c0848c0dd51bb0df8a3124fb48e1c0457f2..b826d2cf7be2b15b03c58903b7b3078881545d04 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef LOADER_INTERPRETER_H_
 #define LOADER_INTERPRETER_H_
 
 #ifndef LOADER_INTERPRETER_H_
 #define LOADER_INTERPRETER_H_
 
+#include "TypeDescription.h"
 #include "../geometry/Vector.h"
 #include "../graphics/Color.h"
 #include "../graphics/ComplexAnimation.h"
 #include "../geometry/Vector.h"
 #include "../graphics/Color.h"
 #include "../graphics/ComplexAnimation.h"
@@ -67,163 +68,47 @@ private:
 
 public:
        void ReadSource();
 
 public:
        void ReadSource();
+       void *GetObject(int typeId, const std::string &name);
+
+       static void CreateTypeDescriptions();
+       struct PostponedDefinition {
+               PostponedDefinition(int type, int id, std::ptrdiff_t offset, const char *identifier, int linkedType)
+               : type(type), id(id), offset(offset), identifier(identifier), linkedType(linkedType) { }
+               int type;
+               int id;
+               std::ptrdiff_t offset;
+               const char *identifier;
+               int linkedType;
+       };
 
 
-public:
-       graphics::Animation *GetAnimation(const std::string &name);
-       battle::Resources *GetBattleResources(const std::string &name);
-       bool GetBoolean(const std::string &name) const;
-       const graphics::Color &GetColor(const std::string &name) const;
-       graphics::Font *GetFont(const std::string &name);
-       graphics::Frame *GetFrame(const std::string &name);
-       graphics::Gauge *GetGauge(const std::string &name);
-       battle::Hero *GetHero(const std::string &name);
-       common::Ikari *GetIkari(const std::string &name);
-       common::Item *GetItem(const std::string &name);
-       graphics::MenuProperties *GetMenuProperties(const std::string &name);
-       battle::Monster *GetMonster(const std::string &name);
-       int GetNumber(const std::string &name) const;
-       battle::PartyLayout *GetPartyLayout(const std::string &name);
-       const char *GetPath(const std::string &name) const;
-       common::Spell *GetSpell(const std::string &name);
-       graphics::Sprite *GetSprite(const std::string &name);
-       const char *GetString(const std::string &name) const;
-       common::TargetingMode *GetTargetingMode(const std::string &name);
-       geometry::Vector<int> GetVector(const std::string &name) const;
-
-public:
-       const std::vector<battle::Resources *> &BattleResources() const { return battleResources; }
-       const std::vector<bool> &Booleans() const { return booleans; }
-       const std::vector<graphics::Color> &Colors() const { return colors; }
-       const std::vector<graphics::ComplexAnimation *> &ComplexAnimations() const { return complexAnimations; }
-       const std::vector<graphics::Font *> &Fonts() const { return fonts; }
-       const std::vector<graphics::Frame *> &Frames() const { return frames; }
-       const std::vector<graphics::Gauge *> &Gauges() const { return gauges; }
-       const std::vector<battle::Hero *> &Heroes() const { return heroes; }
-       const std::vector<common::Ikari *> &Ikaris() const { return ikaris; }
-       const std::vector<SDL_Surface *> &Images() const { return images; }
-       const std::vector<common::Item *> &Items() const { return items; }
-       const std::vector<graphics::MenuProperties *> &MenuProperties() const { return menuProperties; }
-       const std::vector<battle::Monster *> &Monsters() const { return monsters; }
-       const std::vector<int> &Numbers() const { return numbers; }
-       const std::vector<battle::PartyLayout *> &PartyLayouts() const { return partyLayouts; }
-       const std::vector<graphics::SimpleAnimation *> &SimpleAnimations() const { return simpleAnimations; }
-       const std::vector<common::Spell *> &Spells() const { return spells; }
-       const std::vector<graphics::Sprite *> &Sprites() const { return sprites; }
-       const std::vector<const char *> &Strings() const { return strings; }
-       const std::vector<common::TargetingMode *> &TargetingModes() const { return targetingModes; }
-       const std::vector<geometry::Vector<int> > &Vectors() const { return vectors; }
+       const std::vector<PostponedDefinition> &PostponedDefinitions() { return postponedDefinitions; }
 
 private:
        void ReadDefinition(const Definition &);
        void ReadLiteral(const Definition &);
        void ReadObject(const Definition &);
 
 
 private:
        void ReadDefinition(const Definition &);
        void ReadLiteral(const Definition &);
        void ReadObject(const Definition &);
 
-       graphics::Animation *GetAnimation(const Value &);
-       battle::Resources *GetBattleResources(const Value &);
-       graphics::Color GetColor(const Value &);
-       bool GetBoolean(const Value &);
-       graphics::Font *GetFont(const Value &);
-       graphics::Frame *GetFrame(const Value &);
-       graphics::Gauge *GetGauge(const Value &);
-       battle::Hero *GetHero(const Value &);
-       common::Ikari *GetIkari(const Value &);
-       SDL_Surface *GetImage(const Value &);
-       common::Item *GetItem(const Value &);
-       graphics::MenuProperties *GetMenuProperties(const Value &);
-       battle::Monster *GetMonster(const Value &);
-       int GetNumber(const Value &);
-       battle::PartyLayout *GetPartyLayout(const Value &);
-       const PropertyList *GetPropertyList(const Value &);
-       const std::vector<PropertyList *> &GetPropertyListArray(const Value &);
-       const char *GetPath(const Value &);
-       common::Spell *GetSpell(const Value &);
-       graphics::Sprite *GetSprite(const Value &);
-       const char *GetString(const Value &);
-       common::TargetingMode *GetTargetingMode(const Value &);
-       const std::vector<Value *> &GetValueArray(const Value &);
-       geometry::Vector<int> GetVector(const Value &);
-
-       void ReadBattleResources(battle::Resources &, const PropertyList &);
-       void ReadComplexAnimation(graphics::ComplexAnimation &, const PropertyList &);
-       void ReadComplexAnimationFrame(graphics::ComplexAnimation::FrameProp &, const PropertyList &);
-       void ReadFont(graphics::Font &, const PropertyList &);
-       void ReadFrame(graphics::Frame &, const PropertyList &);
-       void ReadGauge(graphics::Gauge &, const PropertyList &);
-       void ReadHero(battle::Hero &, const PropertyList &);
-       void ReadIkari(common::Ikari &, const PropertyList &);
-       void ReadItem(common::Item &, const PropertyList &);
-       void ReadMenuProperties(graphics::MenuProperties &, const PropertyList &);
-       void ReadMonster(battle::Monster &, const PropertyList &);
-       void ReadPartyLayout(battle::PartyLayout &, const PropertyList &);
-       void ReadSimpleAnimation(graphics::SimpleAnimation &, const PropertyList &);
-       void ReadSpell(common::Spell &, const PropertyList &);
-       void ReadSprite(graphics::Sprite &, const PropertyList &);
-       void ReadStats(battle::Stats &, const PropertyList &);
-       void ReadTargetingMode(common::TargetingMode &, const PropertyList &);
+       void *GetObject(int typeId, const Value &value);
+       void ReadObject(int typeId, int id, char *dest, const PropertyList &);
 
 private:
        const ParsedSource &source;
 
 private:
        const ParsedSource &source;
-       enum Type {
-               BATTLE_RESOURCES,
-               BOOLEAN,
-               COLOR,
-               COMPLEX_ANIMATION,
-               FONT,
-               FRAME,
-               GAUGE,
-               HERO,
-               IKARI,
-               IMAGE,
-               ITEM,
-               MENU_PROPERTIES,
-               MONSTER,
-               NUMBER,
-               PARTY_LAYOUT,
-               PATH,
-               PROPERTY_LIST_ARRAY,
-               SIMPLE_ANIMATION,
-               SPELL,
-               SPRITE,
-               STRING,
-               TARGETING_MODE,
-               VECTOR,
-               VALUE_ARRAY,
-       };
        struct ParsedDefinition {
        struct ParsedDefinition {
-               ParsedDefinition(const Definition *dfn, Type type, int index)
-               : dfn(dfn), type(type), index(index) { }
+               ParsedDefinition(const Definition *dfn, int type, int id)
+               : dfn(dfn), type(type), id(id) { }
                const Definition *dfn;
                const Definition *dfn;
-               Type type;
-               int index;
+               int type;
+               int id;
        };
        std::map<std::string, ParsedDefinition> parsedDefinitions;
 
        };
        std::map<std::string, ParsedDefinition> parsedDefinitions;
 
+       bool CanLink(const Value &) const;
+       void Postpone(int type, int id, std::ptrdiff_t offset, const std::string &identifier, int linkedType);
+       std::vector<PostponedDefinition> postponedDefinitions;
+
        std::map<std::string, SDL_Surface *> imageCache;
 
        std::map<std::string, SDL_Surface *> imageCache;
 
-       std::vector<battle::Resources *> battleResources;
-       std::vector<bool> booleans;
-       std::vector<graphics::Color> colors;
-       std::vector<graphics::ComplexAnimation *> complexAnimations;
-       std::vector<graphics::Font *> fonts;
-       std::vector<graphics::Frame *> frames;
-       std::vector<graphics::Gauge *> gauges;
-       std::vector<battle::Hero *> heroes;
-       std::vector<common::Ikari *> ikaris;
-       std::vector<SDL_Surface *> images;
-       std::vector<common::Item *> items;
-       std::vector<graphics::MenuProperties *> menuProperties;
-       std::vector<battle::Monster *> monsters;
-       std::vector<int> numbers;
-       std::vector<battle::PartyLayout *> partyLayouts;
-       std::vector<PropertyList *> propertyLists;
-       std::vector<std::vector<PropertyList *> > propertyListArrays;
-       std::vector<graphics::SimpleAnimation *> simpleAnimations;
-       std::vector<common::Spell *> spells;
-       std::vector<graphics::Sprite *> sprites;
-       std::vector<const char *> strings;
-       std::vector<common::TargetingMode *> targetingModes;
-       std::vector<std::vector<Value *> > valueArrays;
-       std::vector<geometry::Vector<int> > vectors;
+       std::map<int, std::vector<void *> > values;
 
 };
 
 
 };
 
index 98ecd8423c401652f235c01a5ed7d68d40b1379b..e10b287aa661fbd9b5b9cdfac71c593d0714dc47 100644 (file)
@@ -51,6 +51,9 @@ private:
 
 public:
        Type GetType() const { return type; }
 
 public:
        Type GetType() const { return type; }
+       bool IsArray() const { return GetType() == ARRAY_VALUES || GetType() == ARRAY_PROPS; }
+       bool IsObject() const { return GetType() == OBJECT; }
+       int ArraySize() const { return GetType() == ARRAY_VALUES ? GetValues().size() : GetPropertyLists().size(); }
 
        const std::vector<Value *> &GetValues() const;
        const std::vector<PropertyList *> &GetPropertyLists() const;
 
        const std::vector<Value *> &GetValues() const;
        const std::vector<PropertyList *> &GetPropertyLists() const;
index c69efbe9b443170d6472d065c6ff717afa93bd42..07be7b29f165dd091e36d78e292851377546c858 100644 (file)
@@ -51,10 +51,10 @@ std::ptrdiff_t TypeDescription::SupertypeOffset(int id) const {
 }
 
 
 }
 
 
-vector<TypeDescription> Interpreter::typeDescriptions;
+vector<TypeDescription> TypeDescription::typeDescriptions;
 
 TypeDescription &TypeDescription::CreateOrGet(const std::string &name) {
 
 TypeDescription &TypeDescription::CreateOrGet(const std::string &name) {
-       for (vector<TypeDescription>::const_iterator i(typeDescriptions.begin()), end(typeDescriptions.end()); i != end; ++i) {
+       for (vector<TypeDescription>::iterator i(typeDescriptions.begin()), end(typeDescriptions.end()); i != end; ++i) {
                if (i->name == name) {
                        return *i;
                }
                if (i->name == name) {
                        return *i;
                }
@@ -74,7 +74,7 @@ int TypeDescription::GetTypeId(const std::string &name) {
 }
 
 const TypeDescription &TypeDescription::Get(int id) {
 }
 
 const TypeDescription &TypeDescription::Get(int id) {
-       assert(id >= 0 && id < typeDescriptions.size());
+       assert(id >= 0 && id < int(typeDescriptions.size()));
        return typeDescriptions[id];
 }
 
        return typeDescriptions[id];
 }
 
index 4280985185a5e8e144aa6f46d855c463dcf635d1..2117a02efbe471437a050869d2c80f3200876546 100644 (file)
@@ -28,6 +28,7 @@
 #include "loader/Interpreter.h"
 #include "loader/ParsedSource.h"
 #include "loader/Parser.h"
 #include "loader/Interpreter.h"
 #include "loader/ParsedSource.h"
 #include "loader/Parser.h"
+#include "loader/TypeDescription.h"
 #include "sdl/InitImage.h"
 #include "sdl/InitScreen.h"
 #include "sdl/InitSDL.h"
 #include "sdl/InitImage.h"
 #include "sdl/InitScreen.h"
 #include "sdl/InitSDL.h"
@@ -61,6 +62,7 @@ using graphics::Sprite;
 using loader::Interpreter;
 using loader::ParsedSource;
 using loader::Parser;
 using loader::Interpreter;
 using loader::ParsedSource;
 using loader::Parser;
+using loader::TypeDescription;
 using sdl::InitImage;
 using sdl::InitScreen;
 using sdl::InitSDL;
 using sdl::InitImage;
 using sdl::InitScreen;
 using sdl::InitSDL;
@@ -80,6 +82,22 @@ int main(int argc, char **argv) {
                InitSDL sdl;
                InitImage image(IMG_INIT_PNG);
 
                InitSDL sdl;
                InitImage image(IMG_INIT_PNG);
 
+               battle::Resources::CreateTypeDescription();
+               ComplexAnimation::CreateTypeDescription();
+               Font::CreateTypeDescription();
+               Frame::CreateTypeDescription();
+               Gauge::CreateTypeDescription();
+               Hero::CreateTypeDescription();
+               Ikari::CreateTypeDescription();
+               Item::CreateTypeDescription();
+               graphics::MenuProperties::CreateTypeDescription();
+               PartyLayout::CreateTypeDescription();
+               SimpleAnimation::CreateTypeDescription();
+               Spell::CreateTypeDescription();
+               Sprite::CreateTypeDescription();
+               Stats::CreateTypeDescription();
+               common::TargetingMode::CreateTypeDescription();
+
                ParsedSource source;
                Parser("test-data/test.l2s", source).Parse();
                Parser("test-data/ikaris.l2s", source).Parse();
                ParsedSource source;
                Parser("test-data/test.l2s", source).Parse();
                Parser("test-data/ikaris.l2s", source).Parse();
@@ -88,76 +106,83 @@ int main(int argc, char **argv) {
                Interpreter intp(source);
                intp.ReadSource();
 
                Interpreter intp(source);
                intp.ReadSource();
 
-               InitScreen screen(width, height);
+               int battleResId(TypeDescription::GetTypeId("BattleResources"));
+               int heroId(TypeDescription::GetTypeId("Hero"));
+               int itemId(TypeDescription::GetTypeId("Item"));
+               int monsterId(TypeDescription::GetTypeId("Monster"));
+               int partyLayoutId(TypeDescription::GetTypeId("PartyLayout"));
+               int spellId(TypeDescription::GetTypeId("Spell"));
 
                // temporary test data
                SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
 
                // temporary test data
                SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
-               PartyLayout monstersLayout(*intp.GetPartyLayout("monstersLayout"));
-               PartyLayout heroesLayout(*intp.GetPartyLayout("heroesLayout"));
+               PartyLayout monstersLayout(*reinterpret_cast<PartyLayout *>(intp.GetObject(partyLayoutId, "monstersLayout")));
+               PartyLayout heroesLayout(*reinterpret_cast<PartyLayout *>(intp.GetObject(partyLayoutId, "heroesLayout")));
 
 
-               Monster monster(*intp.GetMonster("lizard"));
-               Hero maxim(*intp.GetHero("maxim"));
-               Hero selan(*intp.GetHero("selan"));
-               Hero guy(*intp.GetHero("guy"));
-               Hero dekar(*intp.GetHero("dekar"));
+               Monster monster(*reinterpret_cast<Monster *>(intp.GetObject(monsterId, "lizard")));
+               Hero maxim(*reinterpret_cast<Hero *>(intp.GetObject(heroId, "maxim")));
+               Hero selan(*reinterpret_cast<Hero *>(intp.GetObject(heroId, "selan")));
+               Hero guy(*reinterpret_cast<Hero *>(intp.GetObject(heroId, "guy")));
+               Hero dekar(*reinterpret_cast<Hero *>(intp.GetObject(heroId, "dekar")));
 
 
-               battle::Resources *battleRes(intp.GetBattleResources("battleResources"));
+               battle::Resources *battleRes(reinterpret_cast<battle::Resources *>(intp.GetObject(battleResId, "battleResources")));
 
 
-               maxim.AddSpell(intp.GetSpell("resetSpell"));
-               Spell *strongSpell(intp.GetSpell("strongSpell"));
+               maxim.AddSpell(reinterpret_cast<Spell *>(intp.GetObject(spellId, "resetSpell")));
+               Spell *strongSpell(reinterpret_cast<Spell *>(intp.GetObject(spellId, "strongSpell")));
                maxim.AddSpell(strongSpell);
                selan.AddSpell(strongSpell);
                maxim.AddSpell(strongSpell);
                selan.AddSpell(strongSpell);
-               Spell *strongerSpell(intp.GetSpell("strongerSpell"));
+               Spell *strongerSpell(reinterpret_cast<Spell *>(intp.GetObject(spellId, "strongerSpell")));
                maxim.AddSpell(strongerSpell);
                selan.AddSpell(strongerSpell);
                maxim.AddSpell(strongerSpell);
                selan.AddSpell(strongerSpell);
-               Spell *championSpell(intp.GetSpell("championSpell"));
+               Spell *championSpell(reinterpret_cast<Spell *>(intp.GetObject(spellId, "championSpell")));
                maxim.AddSpell(championSpell);
                selan.AddSpell(championSpell);
                maxim.AddSpell(championSpell);
                selan.AddSpell(championSpell);
-               Spell *rallySpell(intp.GetSpell("rallySpell"));
+               Spell *rallySpell(reinterpret_cast<Spell *>(intp.GetObject(spellId, "rallySpell")));
                maxim.AddSpell(rallySpell);
                selan.AddSpell(rallySpell);
                maxim.AddSpell(rallySpell);
                selan.AddSpell(rallySpell);
-               selan.AddSpell(intp.GetSpell("escapeSpell"));
-               Spell *valorSpell(intp.GetSpell("valorSpell"));
+               selan.AddSpell(reinterpret_cast<Spell *>(intp.GetObject(spellId, "escapeSpell")));
+               Spell *valorSpell(reinterpret_cast<Spell *>(intp.GetObject(spellId, "valorSpell")));
                maxim.AddSpell(valorSpell);
                selan.AddSpell(valorSpell);
 
                Inventory inventory;
                maxim.AddSpell(valorSpell);
                selan.AddSpell(valorSpell);
 
                Inventory inventory;
-               inventory.Add(intp.GetItem("antidoteItem"), 9);
-               inventory.Add(intp.GetItem("magicJarItem"), 4);
-               inventory.Add(intp.GetItem("hiPotionItem"), 4);
-               inventory.Add(intp.GetItem("powerPotionItem"), 4);
-               inventory.Add(intp.GetItem("escapeItem"), 2);
-               inventory.Add(intp.GetItem("sleepBallItem"), 1);
+               inventory.Add(reinterpret_cast<Item *>(intp.GetObject(itemId, "antidoteItem")), 9);
+               inventory.Add(reinterpret_cast<Item *>(intp.GetObject(itemId, "magicJarItem")), 4);
+               inventory.Add(reinterpret_cast<Item *>(intp.GetObject(itemId, "hiPotionItem")), 4);
+               inventory.Add(reinterpret_cast<Item *>(intp.GetObject(itemId, "powerPotionItem")), 4);
+               inventory.Add(reinterpret_cast<Item *>(intp.GetObject(itemId, "escapeItem")), 2);
+               inventory.Add(reinterpret_cast<Item *>(intp.GetObject(itemId, "sleepBallItem")), 1);
                battleRes->inventory = &inventory;
 
                battleRes->inventory = &inventory;
 
-               maxim.SetWeapon(intp.GetItem("zircoSwordItem"));
-               maxim.SetArmor(intp.GetItem("zirconArmorItem"));
-               maxim.SetShield(intp.GetItem("holyShieldItem"));
-               maxim.SetHelmet(intp.GetItem("legendHelmItem"));
-               maxim.SetRing(intp.GetItem("sProRingItem"));
-               maxim.SetJewel(intp.GetItem("evilJewelItem"));
-
-//             selan.SetWeapon(intp.GetItem("zircoWhipItem"));
-               selan.SetArmor(intp.GetItem("zirconPlateItem"));
-               selan.SetShield(intp.GetItem("zircoGlovesItem"));
-               selan.SetHelmet(intp.GetItem("holyCapItem"));
-               selan.SetRing(intp.GetItem("ghostRingItem"));
-               selan.SetJewel(intp.GetItem("eagleRockItem"));
-
-//             guy.SetWeapon(intp.GetItem("zircoAxItem"));
-               guy.SetArmor(intp.GetItem("zirconArmorItem"));
-               guy.SetShield(intp.GetItem("megaShieldItem"));
-               guy.SetHelmet(intp.GetItem("zircoHelmetItem"));
-               guy.SetRing(intp.GetItem("powerRingItem"));
-               guy.SetJewel(intp.GetItem("evilJewelItem"));
+               maxim.SetWeapon(reinterpret_cast<Item *>(intp.GetObject(itemId, "zircoSwordItem")));
+               maxim.SetArmor(reinterpret_cast<Item *>(intp.GetObject(itemId, "zirconArmorItem")));
+               maxim.SetShield(reinterpret_cast<Item *>(intp.GetObject(itemId, "holyShieldItem")));
+               maxim.SetHelmet(reinterpret_cast<Item *>(intp.GetObject(itemId, "legendHelmItem")));
+               maxim.SetRing(reinterpret_cast<Item *>(intp.GetObject(itemId, "sProRingItem")));
+               maxim.SetJewel(reinterpret_cast<Item *>(intp.GetObject(itemId, "evilJewelItem")));
+
+//             selan.SetWeapon(reinterpret_cast<Item *>(intp.GetObject(itemId, "zircoWhipItem")));
+               selan.SetArmor(reinterpret_cast<Item *>(intp.GetObject(itemId, "zirconPlateItem")));
+               selan.SetShield(reinterpret_cast<Item *>(intp.GetObject(itemId, "zircoGlovesItem")));
+               selan.SetHelmet(reinterpret_cast<Item *>(intp.GetObject(itemId, "holyCapItem")));
+               selan.SetRing(reinterpret_cast<Item *>(intp.GetObject(itemId, "ghostRingItem")));
+               selan.SetJewel(reinterpret_cast<Item *>(intp.GetObject(itemId, "eagleRockItem")));
+
+//             guy.SetWeapon(reinterpret_cast<Item *>(intp.GetObject(itemId, "zircoAxItem")));
+               guy.SetArmor(reinterpret_cast<Item *>(intp.GetObject(itemId, "zirconArmorItem")));
+               guy.SetShield(reinterpret_cast<Item *>(intp.GetObject(itemId, "megaShieldItem")));
+               guy.SetHelmet(reinterpret_cast<Item *>(intp.GetObject(itemId, "zircoHelmetItem")));
+               guy.SetRing(reinterpret_cast<Item *>(intp.GetObject(itemId, "powerRingItem")));
+               guy.SetJewel(reinterpret_cast<Item *>(intp.GetObject(itemId, "evilJewelItem")));
 
                // NOTE: this is actually Artea equipment
 
                // NOTE: this is actually Artea equipment
-//             dekar.SetWeapon(intp.GetItem("lizardBlowItem"));
-               dekar.SetArmor(intp.GetItem("holyRobeItem"));
-               dekar.SetShield(intp.GetItem("zircoGlovesItem"));
-               dekar.SetHelmet(intp.GetItem("holyCapItem"));
-               dekar.SetRing(intp.GetItem("rocketRingItem"));
-               dekar.SetJewel(intp.GetItem("krakenRockItem"));
+//             dekar.SetWeapon(reinterpret_cast<Item *>(intp.GetObject(itemId, "lizardBlowItem")));
+               dekar.SetArmor(reinterpret_cast<Item *>(intp.GetObject(itemId, "holyRobeItem")));
+               dekar.SetShield(reinterpret_cast<Item *>(intp.GetObject(itemId, "zircoGlovesItem")));
+               dekar.SetHelmet(reinterpret_cast<Item *>(intp.GetObject(itemId, "holyCapItem")));
+               dekar.SetRing(reinterpret_cast<Item *>(intp.GetObject(itemId, "rocketRingItem")));
+               dekar.SetJewel(reinterpret_cast<Item *>(intp.GetObject(itemId, "krakenRockItem")));
+
+               InitScreen screen(width, height);
 
                BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, battleRes));
                battleState->AddMonster(monster);
 
                BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, battleRes));
                battleState->AddMonster(monster);