#include "stdafx.h" #include "rmgen.h" #include "map.h" #include "entity.h" using namespace std; Map::Map(int size, Terrain* baseTerrain, float baseHeight) { if(size<0 || size>1024) { JS_ReportError(cx, "init: map size out of range"); } else if(size%16 != 0) { JS_ReportError(cx, "init: map size must be divisible by 16"); } this->size = size; texture = new int*[size]; for(int i=0; i*[size]; for(int i=0; i[size]; } area = new Area**[size]; for(int i=0; iplace(this, i, j); } } } Map::~Map() { for(int i=0; i=0 && y>=0 && x=0 && y>=0 && xplace(this, x, y); } void Map::addEntity(Entity* ent) { entities.push_back(ent); } Area* Map::createArea(AreaPlacer* placer, AreaPainter* painter, Constraint* constr) { vector points; if(!placer->place(this, constr, points)) { return 0; } Area* a = new Area(points); for(int i=0; ipaint(this, a); areas.push_back(a); return a; }