]> git.localhorst.tv Git - l2e.git/commitdiff
moved map data to maps.l2s
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 14 Oct 2012 18:00:30 +0000 (20:00 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 14 Oct 2012 18:00:30 +0000 (20:00 +0200)
20 files changed:
src/loader/Caster.cpp
src/loader/Caster.h
src/loader/Interpreter.cpp
src/loader/Interpreter.h
src/loader/Parser.cpp
src/main.cpp
src/map/Area.cpp
src/map/Area.h
src/map/Entity.cpp
src/map/Entity.h
src/map/Map.cpp
src/map/Map.h
src/map/MapState.cpp
src/map/Tile.cpp
src/map/Tile.h
src/map/Trigger.cpp
src/map/Trigger.h
test-data/constants.l2h
test-data/constants.l2s
test-data/maps.l2s [new file with mode: 0644]

index 6d6d7184e2f7d1456544abf8eabe7caafd2d5750..152c8b298dfa1958a793800c35f7cd8d0a760f20 100644 (file)
@@ -14,6 +14,7 @@ using battle::PartyLayout;
 using common::Hero;
 using common::Item;
 using common::Spell;
+using map::Map;
 using std::string;
 
 
@@ -24,6 +25,7 @@ Caster::Caster(Interpreter &intp)
 , battleResourcesId(TypeDescription::GetTypeId("BattleResources"))
 , heroId(TypeDescription::GetTypeId("Hero"))
 , itemId(TypeDescription::GetTypeId("Item"))
+, mapId(TypeDescription::GetTypeId("Map"))
 , monsterId(TypeDescription::GetTypeId("Monster"))
 , partyLayoutId(TypeDescription::GetTypeId("PartyLayout"))
 , spellId(TypeDescription::GetTypeId("Spell")) {
@@ -43,6 +45,10 @@ Item *Caster::GetItem(const string &ident) {
        return reinterpret_cast<Item *>(intp.GetObject(itemId, ident));
 }
 
+Map *Caster::GetMap(const string &ident) {
+       return reinterpret_cast<Map *>(intp.GetObject(mapId, ident));
+}
+
 Monster *Caster::GetMonster(const string &ident) {
        return reinterpret_cast<Monster *>(intp.GetObject(monsterId, ident));
 }
index a3042accef0af000642fd4e8e0da1068b507c4d6..80e765e2d77c2404069fef8e0ce340e2056a1162 100644 (file)
@@ -11,6 +11,7 @@
 #include "Interpreter.h"
 #include "../battle/fwd.h"
 #include "../common/fwd.h"
+#include "../map/fwd.h"
 
 #include <string>
 
@@ -29,6 +30,7 @@ public:
        battle::Resources *GetBattleResources(const std::string &identifier);
        common::Hero *GetHero(const std::string &identifier);
        common::Item *GetItem(const std::string &identifier);
+       map::Map *GetMap(const std::string &identifier);
        battle::Monster *GetMonster(const std::string &identifier);
        battle::PartyLayout *GetPartyLayout(const std::string &identifier);
        common::Spell *GetSpell(const std::string &identifier);
@@ -39,6 +41,7 @@ private:
        int battleResourcesId;
        int heroId;
        int itemId;
+       int mapId;
        int monsterId;
        int partyLayoutId;
        int spellId;
index c2ce0d4145abf20ee1b90c291ad7965d2e5446aa..0fd2d883fba0a8129b3a896dd56d37f35e4af96f 100644 (file)
@@ -62,8 +62,16 @@ Interpreter::~Interpreter() {
 }
 
 
-const Interpreter::ParsedDefinition &Interpreter::GetDefinition(const string &identifier) const {
-       return parsedDefinitions.at(identifier);
+const Interpreter::ParsedDefinition &Interpreter::GetDefinition(const string &identifier) {
+       std::map<string, ParsedDefinition>::const_iterator i(parsedDefinitions.find(identifier));
+       if (i != parsedDefinitions.end()) {
+               return i->second;
+       } else if (source.IsDefined(identifier)) {
+               ReadDefinition(source.GetDefinition(identifier));
+               return parsedDefinitions.at(identifier);
+       } else {
+               throw Error("access to undefined object " + identifier);
+       }
 }
 
 
@@ -114,13 +122,13 @@ void Interpreter::ReadLiteral(const Definition &dfn) {
                                        || dfn.GetLiteral()->GetType() == Literal::STRING)
                        ? dfn.GetLiteral()->GetString().size() : td.Size());
        char *object(alloc.Alloc(size));
+       values[typeId].push_back(object);
+       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, id)));
        if (dfn.GetLiteral()->GetType() == Literal::OBJECT) {
                ReadObject(typeId, id, object, *dfn.GetLiteral()->GetProperties());
        } else {
                ReadLiteral(typeId, id, object, *dfn.GetLiteral());
        }
-       values[typeId].push_back(object);
-       parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, id)));
 }
 
 void Interpreter::ReadLiteral(int typeId, int id, char *object, const Literal &literal) {
@@ -221,8 +229,9 @@ void *Interpreter::GetObject(int typeId, const Value &v) {
                                case Literal::SCRIPT:
                                        {
                                                typeId = TypeDescription::GetTypeId("Script");
+                                               char *script(ReadScript(v.GetLiteral().GetScript()));
                                                id = values[typeId].size();
-                                               values[typeId].push_back(ReadScript(v.GetLiteral().GetScript()));
+                                               values[typeId].push_back(script);
                                        }
                                        break;
                                case Literal::STRING:
@@ -271,8 +280,8 @@ void Interpreter::ReadObject(const Definition &dfn) {
        char *object(alloc.Alloc(td.Size()));
        td.Construct(object);
        values[typeId].push_back(object);
-       ReadObject(typeId, id, object, *dfn.GetProperties());
        parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, typeId, id)));
+       ReadObject(typeId, id, object, *dfn.GetProperties());
 }
 
 
index 5fbded6a0dc4d324971c6d9fea5d5938db1376fd..9795a6062961b283d7efcb1e38fe1a2b8756538a 100644 (file)
@@ -67,7 +67,7 @@ public:
        };
 
        const std::set<std::string> &ExportedIdentifiers() const { return source.Exports(); }
-       const ParsedDefinition &GetDefinition(const std::string &identifier) const;
+       const ParsedDefinition &GetDefinition(const std::string &identifier);
        const std::map<std::string, SDL_Surface *> &Images() const { return imageCache; }
        const std::vector<PostponedDefinition> &PostponedDefinitions() const { return postponedDefinitions; }
        const std::map<int, std::vector<void *> > &Values() const { return values; }
index 8ba370408206bc60f0cfa4d98574e56f6222d624..9ddae34c5bdd4b2ac2a688c6765c925c05013917 100644 (file)
@@ -355,6 +355,7 @@ Literal *Parser::ParseScript() {
        Token t(GetToken());
        AssertTokenType(t.type, Token::SCRIPT_BEGIN, msg);
 
+       t = GetToken();
        vector<ScriptToken *> script;
        try {
                while (t.type != Token::SCRIPT_END) {
@@ -365,7 +366,7 @@ Literal *Parser::ParseScript() {
                                switch (t.type) {
                                        case Token::COMMAND: {
                                                Token t2(GetToken());
-                                               AssertTokenType(t.type, Token::IDENTIFIER, msg);
+                                               AssertTokenType(t2.type, Token::IDENTIFIER, msg);
                                                script.push_back(new ScriptToken(t2.str, ScriptToken::COMMAND));
                                                break;
                                        }
@@ -375,7 +376,7 @@ Literal *Parser::ParseScript() {
                                        }
                                        case Token::REGISTER: {
                                                Token t2(GetToken());
-                                               AssertTokenType(t.type, Token::IDENTIFIER, msg);
+                                               AssertTokenType(t2.type, Token::IDENTIFIER, msg);
                                                script.push_back(new ScriptToken(t2.str, ScriptToken::REGISTER));
                                                break;
                                        }
index a8a722552e2d8126cd6c22e40f88a92720dbcc9f..40b38f1bb98dd6d3d3f71844cc428e66150aaff1 100644 (file)
@@ -103,7 +103,6 @@ int main(int argc, char **argv) {
        const int width = 800;
        const int height = 480;
 
-       const int tileSize = 32;
        const float walkSpeed = 128.0f;
 
        bool battle(false);
@@ -114,6 +113,7 @@ int main(int argc, char **argv) {
                InitSDL sdl;
                InitImage image(IMG_INIT_PNG);
 
+               Area::CreateTypeDescription();
                battle::Resources::CreateTypeDescription();
                ComplexAnimation::CreateTypeDescription();
                Font::CreateTypeDescription();
@@ -123,6 +123,7 @@ int main(int argc, char **argv) {
                Ikari::CreateTypeDescription();
                Interpreter::CreateTypeDescriptions();
                Item::CreateTypeDescription();
+               Map::CreateTypeDescription();
                graphics::MenuProperties::CreateTypeDescription();
                Monster::CreateTypeDescription();
                PartyLayout::CreateTypeDescription();
@@ -131,6 +132,8 @@ int main(int argc, char **argv) {
                Sprite::CreateTypeDescription();
                Stats::CreateTypeDescription();
                common::TargetingMode::CreateTypeDescription();
+               Tile::CreateTypeDescription();
+               Trigger::CreateTypeDescription();
                Entity::CreateTypeDescription();
 
                Arguments args;
@@ -186,6 +189,12 @@ int main(int argc, char **argv) {
 
                Caster caster(intp);
 
+               {
+                       Map *map1(caster.GetMap("map1"));
+                       Map *map2(caster.GetMap("map2"));
+                       std::cout << map1 << ' ' << map2 << std::endl;
+               }
+
                GameState gameState;
 
                gameState.heroes[0] = *caster.GetHero("maxim");
@@ -263,301 +272,6 @@ int main(int argc, char **argv) {
                gameState.heroes[3].SetRing(caster.GetItem("rocketRingItem"));
                gameState.heroes[3].SetJewel(caster.GetItem("krakenRockItem"));
 
-               Tile tiles1[64];
-
-               tiles1[ 0].SetOffset(Vector<int>(2, 1));
-               tiles1[ 1].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_NORTH | Tile::BLOCK_WEST);
-               tiles1[ 2].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles1[ 3].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH | Tile::BLOCK_EAST);
-               tiles1[ 4].SetOffset(Vector<int>(0, 1));
-               tiles1[ 5].SetOffset(Vector<int>(2, 0));
-               tiles1[ 6].SetOffset(Vector<int>(2, 0));
-               tiles1[ 7].SetOffset(Vector<int>(2, 0));
-
-               tiles1[ 8].SetOffset(Vector<int>(2, 1));
-               tiles1[ 9].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles1[10].SetOffset(Vector<int>(3, 0));
-               tiles1[11].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles1[12].SetOffset(Vector<int>(0, 2));
-               tiles1[13].SetOffset(Vector<int>(1, 2));
-               tiles1[14].SetOffset(Vector<int>(1, 2));
-               tiles1[15].SetOffset(Vector<int>(1, 2));
-
-               tiles1[16].SetOffset(Vector<int>(2, 1));
-               tiles1[17].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles1[18].SetOffset(Vector<int>(3, 0));
-               tiles1[19].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles1[20].SetOffset(Vector<int>(0, 3));
-               tiles1[21].SetOffset(Vector<int>(1, 3));
-               tiles1[22].SetOffset(Vector<int>(1, 3));
-               tiles1[23].SetOffset(Vector<int>(2, 3));
-
-               tiles1[24].SetOffset(Vector<int>(2, 1));
-               tiles1[25].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles1[26].SetOffset(Vector<int>(3, 0));
-               tiles1[27].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles1[28].SetOffset(Vector<int>(0, 4));
-               tiles1[29].SetOffset(Vector<int>(1, 4));
-               tiles1[30].SetOffset(Vector<int>(1, 4));
-               tiles1[31].SetOffset(Vector<int>(2, 4));
-
-               tiles1[32].SetOffset(Vector<int>(2, 1));
-               tiles1[33].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles1[34].SetOffset(Vector<int>(3, 0));
-               tiles1[35].SetOffset(Vector<int>(3, 0));
-               tiles1[36].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles1[37].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles1[38].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles1[39].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-
-               tiles1[40].SetOffset(Vector<int>(2, 1));
-               tiles1[41].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles1[42].SetOffset(Vector<int>(3, 0));
-               tiles1[43].SetOffset(Vector<int>(3, 0));
-               tiles1[44].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles1[45].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles1[46].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles1[47].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH);
-
-               tiles1[48].SetOffset(Vector<int>(2, 1));
-               tiles1[49].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles1[50].SetOffset(Vector<int>(3, 0));
-               tiles1[51].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles1[52].SetOffset(Vector<int>(0, 0));
-               tiles1[53].SetOffset(Vector<int>(1, 0));
-               tiles1[54].SetOffset(Vector<int>(1, 0));
-               tiles1[55].SetOffset(Vector<int>(1, 0));
-
-               tiles1[56].SetOffset(Vector<int>(2, 1));
-               tiles1[57].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH | Tile::BLOCK_WEST);
-               tiles1[58].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles1[59].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_SOUTH | Tile::BLOCK_EAST);
-               tiles1[60].SetOffset(Vector<int>(0, 1));
-               tiles1[61].SetOffset(Vector<int>(1, 1));
-               tiles1[62].SetOffset(Vector<int>(1, 1));
-               tiles1[63].SetOffset(Vector<int>(1, 1));
-
-               Tile tiles2[64];
-
-               tiles2[ 0].SetOffset(Vector<int>(2, 0));
-               tiles2[ 1].SetOffset(Vector<int>(2, 0));
-               tiles2[ 2].SetOffset(Vector<int>(2, 0));
-               tiles2[ 3].SetOffset(Vector<int>(2, 0));
-               tiles2[ 4].SetOffset(Vector<int>(2, 0));
-               tiles2[ 5].SetOffset(Vector<int>(2, 0));
-               tiles2[ 6].SetOffset(Vector<int>(2, 0));
-               tiles2[ 7].SetOffset(Vector<int>(2, 0));
-
-               tiles2[ 8].SetOffset(Vector<int>(1, 2));
-               tiles2[ 9].SetOffset(Vector<int>(1, 2));
-               tiles2[10].SetOffset(Vector<int>(5, 3));
-               tiles2[11].SetOffset(Vector<int>(2, 0));
-               tiles2[12].SetOffset(Vector<int>(2, 0));
-               tiles2[13].SetOffset(Vector<int>(2, 0));
-               tiles2[14].SetOffset(Vector<int>(2, 0));
-               tiles2[15].SetOffset(Vector<int>(2, 0));
-
-               tiles2[16].SetOffset(Vector<int>(3, 3));
-               tiles2[17].SetOffset(Vector<int>(0, 3));
-               tiles2[18].SetOffset(Vector<int>(0, 1));
-               tiles2[19].SetOffset(Vector<int>(2, 0));
-               tiles2[20].SetOffset(Vector<int>(2, 0));
-               tiles2[21].SetOffset(Vector<int>(2, 0));
-               tiles2[22].SetOffset(Vector<int>(2, 0));
-               tiles2[23].SetOffset(Vector<int>(2, 0));
-
-               tiles2[24].SetOffset(Vector<int>(3, 4)).SetFlags(Tile::BLOCK_NORTH | Tile::BLOCK_EAST | Tile::BLOCK_WEST);
-               tiles2[25].SetOffset(Vector<int>(0, 4));
-               tiles2[26].SetOffset(Vector<int>(0, 1));
-               tiles2[27].SetOffset(Vector<int>(2, 0));
-               tiles2[28].SetOffset(Vector<int>(2, 0));
-               tiles2[29].SetOffset(Vector<int>(2, 0));
-               tiles2[30].SetOffset(Vector<int>(2, 0));
-               tiles2[31].SetOffset(Vector<int>(2, 0));
-
-               tiles2[32].SetOffset(Vector<int>(5, 0));
-               tiles2[33].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH | Tile::BLOCK_EAST);
-               tiles2[34].SetOffset(Vector<int>(0, 1));
-               tiles2[35].SetOffset(Vector<int>(2, 0));
-               tiles2[36].SetOffset(Vector<int>(2, 0));
-               tiles2[37].SetOffset(Vector<int>(2, 0));
-               tiles2[38].SetOffset(Vector<int>(2, 0));
-               tiles2[39].SetOffset(Vector<int>(2, 0));
-
-               tiles2[40].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles2[41].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH | Tile::BLOCK_EAST);
-               tiles2[42].SetOffset(Vector<int>(0, 1));
-               tiles2[43].SetOffset(Vector<int>(2, 0));
-               tiles2[44].SetOffset(Vector<int>(2, 0));
-               tiles2[45].SetOffset(Vector<int>(2, 0));
-               tiles2[46].SetOffset(Vector<int>(2, 0));
-               tiles2[47].SetOffset(Vector<int>(2, 0));
-
-               tiles2[48].SetOffset(Vector<int>(1, 0));
-               tiles2[49].SetOffset(Vector<int>(1, 0));
-               tiles2[50].SetOffset(Vector<int>(5, 4));
-               tiles2[51].SetOffset(Vector<int>(2, 0));
-               tiles2[52].SetOffset(Vector<int>(2, 0));
-               tiles2[53].SetOffset(Vector<int>(2, 0));
-               tiles2[54].SetOffset(Vector<int>(2, 0));
-               tiles2[55].SetOffset(Vector<int>(2, 0));
-
-               tiles2[56].SetOffset(Vector<int>(2, 0));
-               tiles2[57].SetOffset(Vector<int>(2, 0));
-               tiles2[58].SetOffset(Vector<int>(2, 0));
-               tiles2[59].SetOffset(Vector<int>(2, 0));
-               tiles2[60].SetOffset(Vector<int>(2, 0));
-               tiles2[61].SetOffset(Vector<int>(2, 0));
-               tiles2[62].SetOffset(Vector<int>(2, 0));
-               tiles2[63].SetOffset(Vector<int>(2, 0));
-
-               Area areas1[2];
-               areas1[0].SetTiles(tiles1, 64);
-               areas1[0].SetWidth(8);
-               areas1[1].SetTiles(tiles2, 64);
-               areas1[1].SetWidth(8);
-
-               Trigger triggers1[1];
-               triggers1[0].SetTilePosition(Vector<int>(8, 3));
-               triggers1[0].SetType(Trigger::TYPE_NORTH);
-
-               SDL_Surface *tilesetImg(IMG_Load("test-data/tileset.png"));
-               Sprite tileset(tilesetImg, tileSize, tileSize);
-
-               Map map1;
-               map1.SetAreas(areas1, 2);
-               map1.SetTileset(&tileset);
-               map1.SetTriggers(triggers1, 1);
-               map1.SetWidth(2);
-               map1.SetBattleBackground(bg);
-
-               Tile tiles3[64];
-
-               tiles3[ 0].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH | Tile::BLOCK_WEST);
-               tiles3[ 1].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles3[ 2].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles3[ 3].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles3[ 4].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles3[ 5].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles3[ 6].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH);
-               tiles3[ 7].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_NORTH | Tile::BLOCK_EAST);
-
-               tiles3[ 8].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles3[ 9].SetOffset(Vector<int>(3, 0));
-               tiles3[10].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles3[11].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles3[12].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles3[13].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_SOUTH);
-               tiles3[14].SetOffset(Vector<int>(4, 0));
-               tiles3[15].SetOffset(Vector<int>(4, 0)).SetFlags(Tile::BLOCK_EAST | Tile::BLOCK_SOUTH);
-
-               tiles3[16].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles3[17].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles3[18].SetOffset(Vector<int>(0, 0));
-               tiles3[19].SetOffset(Vector<int>(1, 0));
-               tiles3[20].SetOffset(Vector<int>(1, 0));
-               tiles3[21].SetOffset(Vector<int>(3, 2));
-               tiles3[22].SetOffset(Vector<int>(4, 2)).SetFlags(Tile::BLOCK_EAST | Tile::BLOCK_SOUTH | Tile::BLOCK_WEST);
-               tiles3[23].SetOffset(Vector<int>(5, 2));
-
-               tiles3[24].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles3[25].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles3[26].SetOffset(Vector<int>(0, 1));
-               tiles3[27].SetOffset(Vector<int>(2, 0));
-               tiles3[28].SetOffset(Vector<int>(2, 0));
-               tiles3[29].SetOffset(Vector<int>(1, 2));
-               tiles3[30].SetOffset(Vector<int>(1, 2));
-               tiles3[31].SetOffset(Vector<int>(1, 2));
-
-               tiles3[32].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles3[33].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles3[34].SetOffset(Vector<int>(0, 1));
-               tiles3[35].SetOffset(Vector<int>(2, 0));
-               tiles3[36].SetOffset(Vector<int>(2, 0));
-               tiles3[37].SetOffset(Vector<int>(2, 3));
-               tiles3[38].SetOffset(Vector<int>(3, 3));
-               tiles3[39].SetOffset(Vector<int>(0, 3));
-
-               tiles3[40].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles3[41].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles3[42].SetOffset(Vector<int>(0, 1));
-               tiles3[43].SetOffset(Vector<int>(2, 0));
-               tiles3[44].SetOffset(Vector<int>(2, 0));
-               tiles3[45].SetOffset(Vector<int>(2, 4));
-               tiles3[46].SetOffset(Vector<int>(3, 4));
-               tiles3[47].SetOffset(Vector<int>(0, 4));
-
-               tiles3[48].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_WEST);
-               tiles3[49].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST);
-               tiles3[50].SetOffset(Vector<int>(0, 1));
-               tiles3[51].SetOffset(Vector<int>(2, 0));
-               tiles3[52].SetOffset(Vector<int>(2, 0));
-               tiles3[53].SetOffset(Vector<int>(4, 1));
-               tiles3[54].SetOffset(Vector<int>(5, 1));
-               tiles3[55].SetOffset(Vector<int>(3, 1));
-
-               tiles3[56].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_SOUTH | Tile::BLOCK_WEST);
-               tiles3[57].SetOffset(Vector<int>(3, 0)).SetFlags(Tile::BLOCK_EAST | Tile::BLOCK_SOUTH);
-               tiles3[58].SetOffset(Vector<int>(0, 1));
-               tiles3[59].SetOffset(Vector<int>(2, 0));
-               tiles3[60].SetOffset(Vector<int>(2, 0));
-               tiles3[61].SetOffset(Vector<int>(2, 0));
-               tiles3[62].SetOffset(Vector<int>(2, 0));
-               tiles3[63].SetOffset(Vector<int>(2, 0));
-
-               Area areas2[1];
-               areas2[0].SetTiles(tiles3, 64);
-               areas2[0].SetWidth(8);
-
-               Trigger triggers2[1];
-               triggers2[0].SetTilePosition(Vector<int>(6, 2));
-               triggers2[0].SetType(Trigger::TYPE_SOUTH);
-
-               Map map2;
-               map2.SetAreas(areas2, 1);
-               map2.SetTileset(&tileset);
-               map2.SetTriggers(triggers2, 1);
-               map2.SetWidth(1);
-               map2.SetBattleBackground(bg);
-
-               unsigned char transition1text[4 + sizeof(int) + sizeof(Map *) + sizeof(Vector<int>)];
-               int i(0);
-               transition1text[i++] = Script::CODE_MOVE_I0;
-               *reinterpret_cast<int *>(transition1text + i) = 1;
-               i += sizeof(int);
-               transition1text[i++] = Script::CODE_MOVE_A0;
-               *reinterpret_cast<Map **>(transition1text + i) = &map2;
-               i += sizeof(Map *);
-               transition1text[i++] = Script::CODE_MOVE_V0;
-               *reinterpret_cast<Vector<int> *>(transition1text + i) = Vector<int>(6, 2);
-               i += sizeof(Vector<int>);
-               transition1text[i++] = Script::CODE_SYSCALL;
-
-               Script transition1;
-               transition1.text = transition1text;
-               transition1.textlen = sizeof(transition1text);
-
-               triggers1[0].SetScript(&transition1);
-
-               unsigned char transition2text[4 + sizeof(int) + sizeof(Map *) + sizeof(Vector<int>)];
-               i = 0;
-               transition2text[i++] = Script::CODE_MOVE_I0;
-               *reinterpret_cast<int *>(transition2text + i) = 1;
-               i += sizeof(int);
-               transition2text[i++] = Script::CODE_MOVE_A0;
-               *reinterpret_cast<Map **>(transition2text + i) = &map1;
-               i += sizeof(Map *);
-               transition2text[i++] = Script::CODE_MOVE_V0;
-               *reinterpret_cast<Vector<int> *>(transition2text + i) = Vector<int>(8, 3);
-               i += sizeof(Vector<int>);
-               transition2text[i++] = Script::CODE_SYSCALL;
-
-               Script transition2;
-               transition2.text = transition2text;
-               transition2.textlen = sizeof(transition2text);
-
-               triggers2[0].SetScript(&transition2);
-
                gameState.heroes[0].MapEntity().Position() = Vector<float>(64, 128);
 
                gameState.heroes[1].MapEntity().Position() = Vector<float>(64, 128);
@@ -572,23 +286,6 @@ int main(int argc, char **argv) {
                gameState.heroes[3].MapEntity().SetFlags(Entity::FLAG_NONBLOCKING);
                gameState.heroes[2].MapEntity().AddFollower(&gameState.heroes[3].MapEntity());
 
-               Entity mapPopulation[2];
-               map1.SetEntities(mapPopulation, 2);
-
-               SDL_Surface *mapMonsterImg(IMG_Load("test-data/monster-map.png"));
-               Sprite mapMonsterSprite(mapMonsterImg, 32, 32);
-               SimpleAnimation mapMonsterAnimation(&mapMonsterSprite, 500, 2, 0, 0, true);
-               mapPopulation[0].SetAnimation(&mapMonsterAnimation);
-               mapPopulation[0].Position() = Vector<float>(64, 32);
-               mapPopulation[0].SetOrientation(Entity::ORIENTATION_SOUTH);
-               mapPopulation[0].SetPartyLayout(&monstersLayout);
-               mapPopulation[0].SetMonsters(&monster, 1);
-
-               Sprite blockSprite(tilesetImg, tileSize, tileSize, 3 * tileSize, 1 * tileSize);
-               mapPopulation[1].SetSprite(&blockSprite);
-               mapPopulation[1].Position() = Vector<float>(64, 160);
-               mapPopulation[1].SetFlags(Entity::FLAG_PUSHABLE | Entity::FLAG_FIXED_ORIENTATION);
-
                InitScreen screen(width, height);
 
                app::State *state(0);
@@ -605,11 +302,10 @@ int main(int argc, char **argv) {
                        battleState->AddHero(gameState.heroes[3]);
                        state = battleState;
                } else {
-                       MapState *mapState(new MapState(&gameConfig, &map1));
+                       MapState *mapState(new MapState(&gameConfig, caster.GetMap("map1")));
 
                        mapState->ControlEntity(&gameState.heroes[0].MapEntity());
                        mapState->SetWalkingSpeed(walkSpeed);
-                       mapPopulation[0].StartAnimation(*mapState);
 
                        state = mapState;
                }
index 985dea2d5462f4aae5ecba7663d6c79651f635d3..1b9488a01120d045e2eddbeb0df94e402c0797a8 100644 (file)
@@ -9,11 +9,14 @@
 
 #include "Tile.h"
 #include "../graphics/Sprite.h"
+#include "../loader/TypeDescription.h"
 #include "../sdl/utility.h"
 
 #include <stdexcept>
 
 using geometry::Vector;
+using loader::FieldDescription;
+using loader::TypeDescription;
 
 namespace map {
 
@@ -86,4 +89,25 @@ void Area::RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const
        }
 }
 
+
+void Area::CreateTypeDescription() {
+       Area a;
+
+       int imageId(TypeDescription::GetTypeId("Image"));
+       int numberId(TypeDescription::GetTypeId("Number"));
+       int tileId(TypeDescription::GetTypeId("Tile"));
+
+       TypeDescription &td(TypeDescription::CreateOrGet("Area"));
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(Area));
+
+       td.AddField("battlebg", FieldDescription(((char *)&a.battlebg) - ((char *)&a), imageId).SetReferenced());
+       td.AddField("tiles", FieldDescription(((char *)&a.tiles) - ((char *)&a), tileId).SetReferenced().SetAggregate());
+       td.AddField("width", FieldDescription(((char *)&a.width) - ((char *)&a), numberId));
+}
+
+void Area::Construct(void *data) {
+       new (data) Area;
+}
+
 }
index a044c8ba01a010866d617e4aa32ede2eeb8e4693..3c370abc0acf88afb6ee8c78217cd88d4971bb83 100644 (file)
@@ -34,6 +34,9 @@ public:
        void Render(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
        void RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
 
+       static void CreateTypeDescription();
+       static void Construct(void *);
+
 // temporary setters
 public:
        void SetTiles(Tile *t, int num) { tiles = t; numTiles = num; }
index e922e54c74c1d5deefe18122afc4a8fc6b546d14..99295344dbd52127a2f58c6e9f17ed27161d5a2c 100644 (file)
@@ -143,7 +143,9 @@ void Entity::CreateTypeDescription() {
 
        int animationId(TypeDescription::GetTypeId("Animation"));
        int monsterId(TypeDescription::GetTypeId("Monster"));
+       int numberId(TypeDescription::GetTypeId("Number"));
        int partyLayoutId(TypeDescription::GetTypeId("PartyLayout"));
+       int spriteId(TypeDescription::GetTypeId("Sprite"));
        int vectorId(TypeDescription::GetTypeId("Vector"));
 
        TypeDescription &td(TypeDescription::CreateOrGet("Entity"));
@@ -152,9 +154,12 @@ void Entity::CreateTypeDescription() {
        td.SetSize(sizeof(Entity));
 
        td.AddField("animation", FieldDescription(((char *)&e.animation) - ((char *)&e), animationId).SetReferenced());
+       td.AddField("sprite", FieldDescription(((char *)&e.sprite) - ((char *)&e), spriteId).SetReferenced());
        td.AddField("partyLayout", FieldDescription(((char *)&e.partyLayout) - ((char *)&e), partyLayoutId).SetReferenced());
        td.AddField("monsters", FieldDescription(((char *)&e.monsters) - ((char *)&e), monsterId).SetReferenced().SetAggregate());
        td.AddField("spriteOffset", FieldDescription(((char *)&e.spriteOffset) - ((char *)&e), vectorId));
+       td.AddField("position", FieldDescription(((char *)&e.tilePosition) - ((char *)&e), vectorId));
+       td.AddField("flags", FieldDescription(((char *)&e.flags) - ((char *)&e), numberId));
 }
 
 void Entity::Construct(void *data) {
index fc1dc812194d5332e415e37501a35b90bc690301..cc30c9518288e3886a6711a937a9d4b22133cddf 100644 (file)
@@ -48,6 +48,8 @@ public:
        geometry::Vector<int> &SpriteOffset() { return spriteOffset; }
        const geometry::Vector<int> &SpriteOffset() const { return spriteOffset; }
 
+       void ResetPosition(const geometry::Vector<int> &tileSize) { position = tilePosition * tileSize; }
+
        void SetAnimation(const graphics::Animation *a);
        void StartAnimation(app::Application &ctrl);
        void StartAnimation(app::State &ctrl);
@@ -104,6 +106,7 @@ private:
        int numMonsters;
        graphics::AnimationRunner runner;
        geometry::Vector<int> spriteOffset;
+       geometry::Vector<int> tilePosition;
        geometry::Vector<float> position;
        geometry::Vector<float> velocity;
        Orientation orientation;
index 1c55eaf0690a552d470efcbb97a4be5ffe2ca2dd..3f05962a43b2e55db519f84565b362b16d748cc0 100644 (file)
 #include "Tile.h"
 #include "Trigger.h"
 #include "../graphics/Sprite.h"
+#include "../loader/TypeDescription.h"
 #include "../sdl/utility.h"
 
 #include <stdexcept>
 
 using geometry::Vector;
+using loader::FieldDescription;
+using loader::TypeDescription;
 
 namespace map {
 
@@ -149,4 +152,31 @@ void Map::RenderDebug(SDL_Surface *dest, const Vector<int> &inOffset) const {
        }
 }
 
+
+void Map::CreateTypeDescription() {
+       Map m;
+
+       int areaId(TypeDescription::GetTypeId("Area"));
+       int entityId(TypeDescription::GetTypeId("Entity"));
+       int imageId(TypeDescription::GetTypeId("Image"));
+       int numberId(TypeDescription::GetTypeId("Number"));
+       int spriteId(TypeDescription::GetTypeId("Sprite"));
+       int triggerId(TypeDescription::GetTypeId("Trigger"));
+
+       TypeDescription &td(TypeDescription::CreateOrGet("Map"));
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(Map));
+
+       td.AddField("tileset", FieldDescription(((char *)&m.tileset) - ((char *)&m), spriteId).SetReferenced());
+       td.AddField("battlebg", FieldDescription(((char *)&m.battlebg) - ((char *)&m), imageId).SetReferenced());
+       td.AddField("areas", FieldDescription(((char *)&m.areas) - ((char *)&m), areaId).SetReferenced().SetAggregate());
+       td.AddField("triggers", FieldDescription(((char *)&m.triggers) - ((char *)&m), triggerId).SetReferenced().SetAggregate());
+       td.AddField("entities", FieldDescription(((char *)&m.entities) - ((char *)&m), entityId).SetReferenced().SetAggregate());
+       td.AddField("width", FieldDescription(((char *)&m.width) - ((char *)&m), numberId));
+}
+
+void Map::Construct(void *data) {
+       new (data) Map;
+}
+
 }
index 40cce1c497259e31a719a4bcf3114c2ded2478b7..a985d8491f44928335ba06a618677d095da6079f 100644 (file)
@@ -39,14 +39,8 @@ public:
        void Render(SDL_Surface *dest, const geometry::Vector<int> &offset) const;
        void RenderDebug(SDL_Surface *dest, const geometry::Vector<int> &offset) const;
 
-// temporary setters
-public:
-       void SetTileset(const graphics::Sprite *t) { tileset = t; }
-       void SetBattleBackground(SDL_Surface *bg) { battlebg = bg; }
-       void SetAreas(Area *a, int num) { areas = a; numAreas = num; }
-       void SetTriggers(Trigger *t, int num) { triggers = t; numTriggers = num; }
-       void SetEntities(Entity *e, int num) { entities = e; numEntities = num; }
-       void SetWidth(int w) { width = w; }
+       static void CreateTypeDescription();
+       static void Construct(void *);
 
 private:
        const graphics::Sprite *tileset;
index 6b025319b42747e00accb8ef41badb87018e0df3..37ccc72246c1c62c84bac7c77e75af59ffe77107 100644 (file)
@@ -412,6 +412,7 @@ void MapState::LoadMap(Map *m) {
        map = m;
        for (Entity *e(m->EntitiesBegin()), *end(m->EntitiesEnd()); e != end; ++e) {
                entities.push_back(e);
+               e->ResetPosition(map->Tileset()->Size());
        }
        for (Entity *e(controlled); e; e = e->Follower()) {
                entities.push_back(e);
index 303c9e556eba5fcf1836eca8b7aa1ac4b05a4fb2..650bbdbc00b1397d7f9b0741c0e2f260b525569c 100644 (file)
@@ -7,6 +7,11 @@
 
 #include "Tile.h"
 
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
 namespace map {
 
 Tile::Tile()
@@ -15,4 +20,26 @@ Tile::Tile()
 
 }
 
+
+void Tile::CreateTypeDescription() {
+       Tile t;
+
+       int imageId(TypeDescription::GetTypeId("Image"));
+       int numberId(TypeDescription::GetTypeId("Number"));
+       int vectorId(TypeDescription::GetTypeId("Vector"));
+
+       TypeDescription &td(TypeDescription::CreateOrGet("Tile"));
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(Tile));
+
+       td.AddField("battlebg", FieldDescription(((char *)&t.battlebg) - ((char *)&t), imageId).SetReferenced());
+       td.AddField("t", FieldDescription(((char *)&t.offset) - ((char *)&t), vectorId));
+       td.AddField("flags", FieldDescription(((char *)&t.flags) - ((char *)&t), numberId));
+
+}
+
+void Tile::Construct(void *data) {
+       new (data) Tile;
+}
+
 }
index 06b3b1175b62ae315c5c5c3054e7b4e7eb051bc4..6706b01a42a53741af395591b46cc47df3af2a62 100644 (file)
@@ -37,6 +37,9 @@ public:
        bool BlocksSouth() const { return flags & BLOCK_SOUTH; }
        bool BlocksWest() const { return flags & BLOCK_WEST; }
 
+       static void CreateTypeDescription();
+       static void Construct(void *);
+
 // temporary setters
 public:
        Tile &SetOffset(const geometry::Vector<int> &o) { offset = o; return *this; }
@@ -45,7 +48,7 @@ public:
 private:
        SDL_Surface *battlebg;
        geometry::Vector<int> offset;
-       Uint32 flags;
+       int flags;
 
 };
 
index f454613579cd890134f1ec53110c505351be791e..ff4863d41c4e1f7a6177d7264903df8f3d1c43f7 100644 (file)
@@ -7,6 +7,11 @@
 
 #include "Trigger.h"
 
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
 namespace map {
 
 Trigger::Trigger()
@@ -15,4 +20,25 @@ Trigger::Trigger()
 
 }
 
+
+void Trigger::CreateTypeDescription() {
+       Trigger t;
+
+       int numberId(TypeDescription::GetTypeId("Number"));
+       int scriptId(TypeDescription::GetTypeId("Script"));
+       int vectorId(TypeDescription::GetTypeId("Vector"));
+
+       TypeDescription &td(TypeDescription::CreateOrGet("Trigger"));
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(Trigger));
+
+       td.AddField("script", FieldDescription(((char *)&t.script) - ((char *)&t), scriptId).SetReferenced());
+       td.AddField("position", FieldDescription(((char *)&t.tilePosition) - ((char *)&t), vectorId));
+       td.AddField("type", FieldDescription(((char *)&t.type) - ((char *)&t), numberId));
+}
+
+void Trigger::Construct(void *data) {
+       new (data) Trigger;
+}
+
 }
index 13b85ac491a08a65b5264991bc6918fa2325f385..eb174607d00e76a04c4cd8b68201f3da1ff097c9 100644 (file)
@@ -26,16 +26,19 @@ public:
                TYPE_EAST = Entity::ORIENTATION_EAST,
                TYPE_SOUTH = Entity::ORIENTATION_SOUTH,
                TYPE_WEST = Entity::ORIENTATION_WEST,
-               TYPE_CONTACT,
+               TYPE_CONTACT = 4,
        };
 
 public:
        const geometry::Vector<int> &TilePosition() const { return tilePosition; }
-       Type GetType() const { return type; }
+       Type GetType() const { return Type(type); }
        bool HasScript() const { return script; }
        common::Script &GetScript() { return *script; }
        const common::Script &GetScript() const { return *script; }
 
+       static void CreateTypeDescription();
+       static void Construct(void *);
+
 // temporary setters
 public:
        void SetTilePosition(const geometry::Vector<int> &p) { tilePosition = p; }
@@ -45,7 +48,7 @@ public:
 private:
        common::Script *script;
        geometry::Vector<int> tilePosition;
-       Type type;
+       int type;
 
 };
 
index 851f7ffc6ef953755f12cb7efb5619967e273abb..5ace629e05f3d0376fa2629fd55a53dfc9f3dd8c 100644 (file)
@@ -9,3 +9,22 @@ Number multiple
 // Ikari
 Boolean magical
 Boolean physical
+
+// Trigger type
+Number triggerNorth
+Number triggerEast
+Number triggerSouth
+Number triggerWest
+Number triggerContact
+
+// Tile flags
+Number blockN
+Number blockE
+Number blockNE
+Number blockS
+Number blockES
+Number blockW
+Number blockNW
+Number blockNEW
+Number blockSW
+Number blockESW
index 8c624ecfdf12594e7117231b5063bfde70a6683d..fa01f2b2eb9275794c2c7703f988c297fe4b4921 100644 (file)
@@ -9,3 +9,22 @@ export Number single 2
 // Ikari
 export Boolean magical false
 export Boolean physical true
+
+// Trigger type
+export Number triggerNorth 0
+export Number triggerEast 1
+export Number triggerSouth 2
+export Number triggerWest 3
+export Number triggerContact 4
+
+// Tile flags
+export Number blockN    1
+export Number blockE    2
+export Number blockNE   3
+export Number blockS    4
+export Number blockES   6
+export Number blockW    8
+export Number blockNW   9
+export Number blockNEW 11
+export Number blockSW  12
+export Number blockESW 14
diff --git a/test-data/maps.l2s b/test-data/maps.l2s
new file mode 100644 (file)
index 0000000..e91ace9
--- /dev/null
@@ -0,0 +1,291 @@
+include "constants.l2h"
+
+export Map map1 {
+       tileset: Sprite {
+               image: :"tileset.png",
+               size: <32, 32>
+       },
+       battlebg: :"battle-bg.png",
+       width: 2,
+       areas: [ Area
+               {
+                       width: 8,
+                       tiles: [ Tile
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockNW },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockNE },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockW },
+                               { t: <3, 0> },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 2> },
+                               { t: <1, 2> },
+                               { t: <1, 2> },
+                               { t: <1, 2> },
+                               
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockW },
+                               { t: <3, 0> },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 3> },
+                               { t: <1, 3> },
+                               { t: <1, 3> },
+                               { t: <2, 3> },
+                               
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockW },
+                               { t: <3, 0> },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 4> },
+                               { t: <1, 4> },
+                               { t: <1, 4> },
+                               { t: <2, 4> },
+                               
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockW },
+                               { t: <3, 0> },
+                               { t: <3, 0> },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockW },
+                               { t: <3, 0> },
+                               { t: <3, 0> },
+                               { t: <3, 0>, flags: blockS },
+                               { t: <4, 0>, flags: blockS },
+                               { t: <4, 0>, flags: blockS },
+                               { t: <4, 0>, flags: blockS },
+                               
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockW },
+                               { t: <3, 0> },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 0> },
+                               { t: <1, 0> },
+                               { t: <1, 0> },
+                               { t: <1, 0> },
+                               
+                               { t: <2, 1> },
+                               { t: <4, 0>, flags: blockSW },
+                               { t: <3, 0>, flags: blockS },
+                               { t: <3, 0>, flags: blockES },
+                               { t: <0, 1> },
+                               { t: <1, 1> },
+                               { t: <1, 1> },
+                               { t: <1, 1> }
+                       ]
+               },
+               {
+                       width: 8,
+                       tiles: [ Tile
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <1, 2> },
+                               { t: <1, 2> },
+                               { t: <5, 3> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <3, 3> },
+                               { t: <0, 3> },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <3, 4>, flags: blockNEW },
+                               { t: <0, 4> },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <5, 0> },
+                               { t: <3, 0>, flags: blockNE },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <4, 0>, flags: blockS },
+                               { t: <4, 0>, flags: blockES },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <1, 0> },
+                               { t: <1, 0> },
+                               { t: <5, 4> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> }
+                       ]
+               }
+       ],
+       triggers: [ Trigger
+               {
+                       position: <8, 3>,
+                       type: triggerNorth,
+                       script: <<
+                               $move %i0 1
+                               $move %a0 map2
+                               $move %v0 <6, 2>
+                               $sysc
+                       >>
+               }
+       ],
+       entities: [ Entity
+               {
+                       animation: SimpleAnimation {
+                               sprite: Sprite {
+                                       image: :"monster-map.png",
+                                       size: <32, 32>
+                               },
+                               framecount: 2,
+                               frametime: 500,
+                               repeat: true
+                       },
+                       position: <2, 1>,
+                       partyLayout: monstersLayout
+                       // TODO: monsters
+               },
+               {
+                       sprite: Sprite {
+                               image: :"tileset.png",
+                               size: <32, 32>,
+                               offset: <96, 32>
+                       },
+                       position: <2, 5>,
+                       flags: 6 // TODO: hard support for flags
+               }
+       ]
+}
+
+export Map map2 {
+       tileset: Sprite {
+               image: :"tileset.png",
+               size: <32, 32>
+       },
+       battlebg: :"battle-bg.png",
+       width: 2,
+       areas: [ Area
+               {
+                       width: 8,
+                       tiles: [ Tile
+                               { t: <3, 0>, flags: blockNW },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockN },
+                               { t: <3, 0>, flags: blockNE },
+                               
+                               { t: <3, 0>, flags: blockW },
+                               { t: <3, 0> },
+                               { t: <3, 0>, flags: blockS },
+                               { t: <4, 0>, flags: blockS },
+                               { t: <4, 0>, flags: blockS },
+                               { t: <4, 0>, flags: blockS },
+                               { t: <4, 0> },
+                               { t: <4, 0>, flags: blockES },
+                               
+                               { t: <3, 0>, flags: blockW },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 0> },
+                               { t: <1, 0> },
+                               { t: <1, 0> },
+                               { t: <3, 2> },
+                               { t: <4, 2>, flags: blockESW },
+                               { t: <5, 2> },
+                               
+                               { t: <3, 0>, flags: blockW },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <1, 2> },
+                               { t: <1, 2> },
+                               { t: <1, 2> },
+                               
+                               { t: <3, 0>, flags: blockW },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 4> },
+                               { t: <3, 4> },
+                               { t: <0, 4> },
+                               
+                               { t: <3, 0>, flags: blockW },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <4, 1> },
+                               { t: <5, 1> },
+                               { t: <3, 1> },
+                               
+                               { t: <3, 0>, flags: blockW },
+                               { t: <3, 0>, flags: blockE },
+                               { t: <0, 1> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> },
+                               { t: <2, 0> }
+                       ]
+               }
+       ],
+       triggers: [ Trigger
+               {
+                       position: <6, 2>,
+                       type: triggerSouth,
+                       script: <<
+                               $move %i0 1
+                               $move %a0 map1
+                               $move %v0 <8, 3>
+                               $sysc
+                       >>
+               }
+       ]
+}