X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FArea.cpp;h=b6d02f6204f7ba0477b4c7c9df636fc2a3bad936;hb=350055a7ff27c74882aff8a4d6af2014782f830b;hp=9c066d646f021a0b8d0d644bb6806fbb5f98622d;hpb=ed792d6d00d822384d79d049e644e372f7c3b4cd;p=l2e.git diff --git a/src/map/Area.cpp b/src/map/Area.cpp index 9c066d6..b6d02f6 100644 --- a/src/map/Area.cpp +++ b/src/map/Area.cpp @@ -9,22 +9,37 @@ #include "Tile.h" #include "../graphics/Sprite.h" +#include "../loader/TypeDescription.h" +#include "../loader/Interpreter.h" #include "../sdl/utility.h" #include using geometry::Vector; +using loader::FieldDescription; +using loader::Interpreter; +using loader::TypeDescription; namespace map { Area::Area() -: tiles(0) +: battlebg(0) +, tiles(0) , numTiles(0) , width(0) { } +Tile *Area::TileAt(const geometry::Vector &offset) { + int tileIndex(offset.Y() * width + offset.X()); + if (tileIndex < numTiles) { + return tiles +tileIndex; + } else { + return 0; + } +} + const Tile *Area::TileAt(const geometry::Vector &offset) const { int tileIndex(offset.Y() * width + offset.X()); if (tileIndex < numTiles) { @@ -76,4 +91,21 @@ void Area::RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const } } + +void Area::CreateTypeDescription() { + Area a; + + TypeDescription &td(TypeDescription::Create(TYPE_ID, "Area")); + td.SetConstructor(&Construct); + td.SetSize(sizeof(Area)); + + td.AddField("battlebg", FieldDescription(((char *)&a.battlebg) - ((char *)&a), Interpreter::IMAGE_ID).SetReferenced()); + td.AddField("tiles", FieldDescription(((char *)&a.tiles) - ((char *)&a), Tile::TYPE_ID).SetReferenced().SetAggregate()); + td.AddField("width", FieldDescription(((char *)&a.width) - ((char *)&a), Interpreter::NUMBER_ID)); +} + +void Area::Construct(void *data) { + new (data) Area; +} + }