summaryrefslogtreecommitdiff
path: root/plugins/tiletypes.cpp
diff options
context:
space:
mode:
authorPetr Mrázek2012-03-24 12:13:51 +0100
committerPetr Mrázek2012-03-24 12:13:51 +0100
commit8a847dbaba6f8b38a0fc170f72692470557f2e12 (patch)
tree8443203a4d32eb90f1801e9dc86677b94d6d2e26 /plugins/tiletypes.cpp
parent7fe5fc9a906710bc603bf93b3e282872990a3361 (diff)
downloaddfhack-8a847dbaba6f8b38a0fc170f72692470557f2e12.tar.gz
dfhack-8a847dbaba6f8b38a0fc170f72692470557f2e12.tar.bz2
dfhack-8a847dbaba6f8b38a0fc170f72692470557f2e12.tar.xz
Tweaks and cleanups
Removed t_virtual. Made lua use C++ compiler Removed many silly exception types from Error.h and renamed the rest. Removed Brush classes from tiletypes plugin.
Diffstat (limited to 'plugins/tiletypes.cpp')
-rw-r--r--plugins/tiletypes.cpp145
1 files changed, 1 insertions, 144 deletions
diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp
index d704f030..32d0ba19 100644
--- a/plugins/tiletypes.cpp
+++ b/plugins/tiletypes.cpp
@@ -20,6 +20,7 @@ using std::set;
#include "TileTypes.h"
#include "modules/MapCache.h"
#include "df/tile_dig_designation.h"
+#include "Brushes.h"
using namespace MapExtras;
using namespace DFHack;
using namespace df::enums;
@@ -487,150 +488,6 @@ void help( std::ostream & out, const std::string &option)
}
}
-typedef std::vector<DFHack::DFCoord> coord_vec;
-
-class Brush
-{
-public:
- virtual ~Brush() {};
- virtual coord_vec points(MapExtras::MapCache &mc, DFHack::DFCoord start) = 0;
-};
-/**
- * generic 3D rectangle brush. you can specify the dimensions of
- * the rectangle and optionally which tile is its 'center'
- */
-class RectangleBrush : public Brush
-{
- int x_, y_, z_;
- int cx_, cy_, cz_;
-
-public:
- RectangleBrush(int x, int y, int z = 1, int centerx = -1, int centery = -1, int centerz = -1)
- {
- if (centerx == -1)
- {
- cx_ = x/2;
- }
- else
- {
- cx_ = centerx;
- }
-
- if (centery == -1)
- {
- cy_ = y/2;
- }
- else
- {
- cy_ = centery;
- }
-
- if (centerz == -1)
- {
- cz_ = z/2;
- }
- else
- {
- cz_ = centerz;
- }
-
- x_ = x;
- y_ = y;
- z_ = z;
- };
-
- coord_vec points(MapExtras::MapCache &mc, DFHack::DFCoord start)
- {
- coord_vec v;
- DFHack::DFCoord iterstart(start.x - cx_, start.y - cy_, start.z - cz_);
- DFHack::DFCoord iter = iterstart;
- for (int xi = 0; xi < x_; xi++)
- {
- for (int yi = 0; yi < y_; yi++)
- {
- for (int zi = 0; zi < z_; zi++)
- {
- if(mc.testCoord(iter))
- v.push_back(iter);
-
- iter.z++;
- }
-
- iter.z = iterstart.z;
- iter.y++;
- }
-
- iter.y = iterstart.y;
- iter.x ++;
- }
-
- return v;
- };
-
- ~RectangleBrush(){};
-};
-
-/**
- * stupid block brush, legacy. use when you want to apply something to a whole DF map block.
- */
-class BlockBrush : public Brush
-{
-public:
- BlockBrush() {};
- ~BlockBrush() {};
-
- coord_vec points(MapExtras::MapCache &mc, DFHack::DFCoord start)
- {
- coord_vec v;
- DFHack::DFCoord blockc = start % 16;
- DFHack::DFCoord iterc = blockc * 16;
- if (!mc.testCoord(start))
- return v;
-
- for (int xi = 0; xi < 16; xi++)
- {
- for (int yi = 0; yi < 16; yi++)
- {
- v.push_back(iterc);
- iterc.y++;
- }
- iterc.x++;
- }
-
- return v;
- };
-};
-
-/**
- * Column from a position through open space tiles
- * example: create a column of magma
- */
-class ColumnBrush : public Brush
-{
-public:
- ColumnBrush(){};
-
- ~ColumnBrush(){};
-
- coord_vec points(MapExtras::MapCache &mc, DFHack::DFCoord start)
- {
- coord_vec v;
- bool juststarted = true;
- while (mc.testCoord(start))
- {
- df::tiletype tt = mc.tiletypeAt(start);
- if(LowPassable(tt) || juststarted && HighPassable(tt))
- {
- v.push_back(start);
- juststarted = false;
- start.z++;
- }
- else break;
- }
- return v;
- };
-};
-
CommandHistory tiletypes_hist;
command_result df_tiletypes (color_ostream &out, vector <string> & parameters);