Merge remote-tracking branch 'peterix/master'

develop
Alexander Gavrilov 2012-03-24 16:30:07 +04:00
commit 517b2ffadb
14 changed files with 43 additions and 509 deletions

@ -1,4 +1,4 @@
PROJECT ( lua C ) PROJECT ( lua CXX )
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# TODO: make this RelWithDebInfo only # TODO: make this RelWithDebInfo only
@ -77,9 +77,12 @@ src/lundump.c
src/lvm.c src/lvm.c
src/lzio.c src/lzio.c
) )
# compile with C++ compiler
set_source_files_properties(${SRC_LIBLUA} PROPERTIES LANGUAGE CXX)
# append headers to sources to make them show up in MSVC GUI
LIST(APPEND SRC_LIBLUA ${HDR_LIBLUA}) LIST(APPEND SRC_LIBLUA ${HDR_LIBLUA})
ADD_LIBRARY ( lua SHARED EXCLUDE_FROM_ALL ${SRC_LIBLUA} ) ADD_LIBRARY ( lua SHARED ${SRC_LIBLUA} )
TARGET_LINK_LIBRARIES ( lua ${LIBS}) TARGET_LINK_LIBRARIES ( lua ${LIBS})
install(TARGETS lua install(TARGETS lua

@ -43,7 +43,6 @@ include/TileTypes.h
include/Types.h include/Types.h
include/VersionInfo.h include/VersionInfo.h
include/VersionInfoFactory.h include/VersionInfoFactory.h
include/Virtual.h
include/RemoteClient.h include/RemoteClient.h
include/RemoteServer.h include/RemoteServer.h
include/RemoteTools.h include/RemoteTools.h
@ -66,7 +65,6 @@ MiscUtils.cpp
PluginManager.cpp PluginManager.cpp
TileTypes.cpp TileTypes.cpp
VersionInfoFactory.cpp VersionInfoFactory.cpp
Virtual.cpp
RemoteClient.cpp RemoteClient.cpp
RemoteServer.cpp RemoteServer.cpp
RemoteTools.cpp RemoteTools.cpp

@ -47,6 +47,7 @@ VersionInfoFactory::~VersionInfoFactory()
{ {
clear(); clear();
} }
void VersionInfoFactory::clear() void VersionInfoFactory::clear()
{ {
// for each stored version, delete // for each stored version, delete
@ -83,11 +84,11 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
TiXmlElement* pMemEntry; TiXmlElement* pMemEntry;
const char *cstr_name = entry->Attribute("name"); const char *cstr_name = entry->Attribute("name");
if (!cstr_name) if (!cstr_name)
throw Error::MemoryXmlBadAttribute("name"); throw Error::SymbolsXmlBadAttribute("name");
const char *cstr_os = entry->Attribute("os-type"); const char *cstr_os = entry->Attribute("os-type");
if (!cstr_os) if (!cstr_os)
throw Error::MemoryXmlBadAttribute("os-type"); throw Error::SymbolsXmlBadAttribute("os-type");
string os = cstr_os; string os = cstr_os;
mem->setVersion(cstr_name); mem->setVersion(cstr_name);
@ -106,7 +107,7 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
} }
else else
{ {
throw Error::MemoryXmlBadAttribute("os-type"); throw Error::SymbolsXmlBadAttribute("os-type");
} }
// process additional entries // process additional entries
@ -121,7 +122,7 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
{ {
const char *cstr_key = pMemEntry->Attribute("name"); const char *cstr_key = pMemEntry->Attribute("name");
if(!cstr_key) if(!cstr_key)
throw Error::MemoryXmlUnderspecifiedEntry(cstr_name); throw Error::SymbolsXmlUnderspecifiedEntry(cstr_name);
const char *cstr_value = pMemEntry->Attribute("value"); const char *cstr_value = pMemEntry->Attribute("value");
if(!cstr_value) if(!cstr_value)
{ {
@ -134,14 +135,14 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
{ {
const char *cstr_value = pMemEntry->Attribute("value"); const char *cstr_value = pMemEntry->Attribute("value");
if(!cstr_value) if(!cstr_value)
throw Error::MemoryXmlUnderspecifiedEntry(cstr_name); throw Error::SymbolsXmlUnderspecifiedEntry(cstr_name);
mem->addMD5(cstr_value); mem->addMD5(cstr_value);
} }
else if (type == "binary-timestamp") else if (type == "binary-timestamp")
{ {
const char *cstr_value = pMemEntry->Attribute("value"); const char *cstr_value = pMemEntry->Attribute("value");
if(!cstr_value) if(!cstr_value)
throw Error::MemoryXmlUnderspecifiedEntry(cstr_name); throw Error::SymbolsXmlUnderspecifiedEntry(cstr_name);
mem->addPE(strtol(cstr_value, 0, 16)); mem->addPE(strtol(cstr_value, 0, 16));
} }
} // for } // for
@ -157,7 +158,7 @@ bool VersionInfoFactory::loadFile(string path_to_xml)
{ {
error = true; error = true;
cerr << "failed!\n"; cerr << "failed!\n";
throw Error::MemoryXmlParse(doc.ErrorDesc(), doc.ErrorId(), doc.ErrorRow(), doc.ErrorCol()); throw Error::SymbolsXmlParse(doc.ErrorDesc(), doc.ErrorId(), doc.ErrorRow(), doc.ErrorCol());
} }
else else
{ {
@ -174,13 +175,13 @@ bool VersionInfoFactory::loadFile(string path_to_xml)
if (!pElem) if (!pElem)
{ {
error = true; error = true;
throw Error::MemoryXmlNoRoot(); throw Error::SymbolsXmlNoRoot();
} }
string m_name=pElem->Value(); string m_name=pElem->Value();
if(m_name != "data-definition") if(m_name != "data-definition")
{ {
error = true; error = true;
throw Error::MemoryXmlNoRoot(); throw Error::SymbolsXmlNoRoot();
} }
// save this for later // save this for later
hRoot=TiXmlHandle(pElem); hRoot=TiXmlHandle(pElem);

@ -1,16 +0,0 @@
#include "Internal.h"
#include <string>
#include <vector>
#include <map>
#include "MemAccess.h"
#include "Core.h"
#include "Virtual.h"
using namespace DFHack;
std::string t_virtual::getClassName() const
{
Core & c = Core::getInstance();
return c.p->readClassName(vptr);
}

@ -24,9 +24,6 @@ distribution.
#pragma once #pragma once
#ifndef ERROR_H_INCLUDED
#define ERROR_H_INCLUDED
#include "Export.h" #include "Export.h"
#include "Pragma.h" #include "Pragma.h"
#include <string> #include <string>
@ -42,176 +39,34 @@ namespace DFHack
* the whole array of DFHack exceptions from the rest * the whole array of DFHack exceptions from the rest
*/ */
class DFHACK_EXPORT All : public std::exception{}; class DFHACK_EXPORT All : public std::exception{};
class DFHACK_EXPORT AllMemdef : public All{}; class DFHACK_EXPORT AllSymbols : public All{};
class DFHACK_EXPORT NoProcess : public All
{
public:
virtual const char* what() const throw()
{
return "couldn't find a suitable process";
}
};
class DFHACK_EXPORT CantAttach : public All
{
public:
virtual const char* what() const throw()
{
return "couldn't attach to process";
}
};
class DFHACK_EXPORT NoMapLoaded : public All
{
public:
virtual const char* what() const throw()
{
return "no map has been loaded in the dwarf fortress process";
}
};
class DFHACK_EXPORT BadMapDimensions : public All
{
public:
BadMapDimensions(uint32_t& _x, uint32_t& _y) : x(_x), y(_y) {}
const uint32_t x;
const uint32_t y;
virtual const char* what() const throw()
{
return "both x and y needs to be between 0 and 48";
}
};
// a call to DFHack::mem_info::get* failed
class DFHACK_EXPORT MissingMemoryDefinition : public AllMemdef
{
public:
MissingMemoryDefinition(const char* _type, const std::string _key) : type(_type), key(_key)
{
std::stringstream s;
s << "memory object not declared: type=" << type << " key=" << key;
full = s.str();
}
// Used by functios using integer keys, such as getTrait
MissingMemoryDefinition(const char* _type, uint32_t _key) : type(_type)
{
std::stringstream s1;
s1 << _key;
key = s1.str();
std::stringstream s;
s << "memory object not declared: type=" << type << " key=" << key;
full = s.str();
}
virtual ~MissingMemoryDefinition() throw(){};
std::string full;
const std::string type;
std::string key;
virtual const char* what() const throw()
{
return full.c_str();
}
};
// a call to DFHack::mem_info::get* failed
class DFHACK_EXPORT UnsetMemoryDefinition : public AllMemdef
{
public:
UnsetMemoryDefinition(const char* _type, const std::string _key) : type(_type), key(_key)
{
std::stringstream s;
s << "memory object not set: type " << type << " key " << key;
full = s.str();
}
// Used by functios using integer keys, such as getTrait
UnsetMemoryDefinition(const char* _type, uint32_t _key) : type(_type)
{
std::stringstream s1;
s1 << _key;
key = s1.str();
std::stringstream s;
s << "memory object not set: type " << type << " key " << key;
full = s.str();
}
virtual ~UnsetMemoryDefinition() throw(){};
std::string full;
const std::string type;
std::string key;
virtual const char* what() const throw()
{
return full.c_str();
}
};
// a call to DFHack::mem_info::get* failed
class DFHACK_EXPORT InvalidMemoryDefinition : public AllMemdef
{
public:
InvalidMemoryDefinition(const char* _type, const std::string _key) : type(_type), key(_key)
{
std::stringstream s;
s << "memory object is INVALID: type " << type << " key " << key;
full = s.str();
}
// Used by functios using integer keys, such as getTrait
InvalidMemoryDefinition(const char* _type, uint32_t _key) : type(_type)
{
std::stringstream s1;
s1 << _key;
key = s1.str();
std::stringstream s;
s << "memory object is INVALID: type " << type << " key " << key;
full = s.str();
}
virtual ~InvalidMemoryDefinition() throw(){};
std::string full;
const std::string type;
std::string key;
virtual const char* what() const throw()
{
return full.c_str();
}
};
// Syntax errors and whatnot, the xml can't be read // Syntax errors and whatnot, the xml can't be read
class DFHACK_EXPORT MemoryXmlParse : public All class DFHACK_EXPORT SymbolsXmlParse : public AllSymbols
{ {
public: public:
MemoryXmlParse(const char* _desc, int _id, int _row, int _col) SymbolsXmlParse(const char* _desc, int _id, int _row, int _col)
:desc(_desc), id(_id), row(_row), col(_col) :desc(_desc), id(_id), row(_row), col(_col)
{ {
std::stringstream s; std::stringstream s;
s << "error " << id << ": " << desc << ", at row " << row << " col " << col; s << "error " << id << ": " << desc << ", at row " << row << " col " << col;
full = s.str(); full = s.str();
} }
std::string full; std::string full;
const std::string desc; const std::string desc;
const int id; const int id;
const int row; const int row;
const int col; const int col;
virtual ~MemoryXmlParse() throw(){}; virtual ~SymbolsXmlParse() throw(){};
virtual const char* what() const throw() virtual const char* what() const throw()
{ {
return full.c_str(); return full.c_str();
} }
}; };
class DFHACK_EXPORT MemoryXmlBadAttribute : public All class DFHACK_EXPORT SymbolsXmlBadAttribute : public All
{ {
public: public:
MemoryXmlBadAttribute(const char* _attr) : attr(_attr) SymbolsXmlBadAttribute(const char* _attr) : attr(_attr)
{ {
std::stringstream s; std::stringstream s;
s << "attribute is either missing or invalid: " << attr; s << "attribute is either missing or invalid: " << attr;
@ -219,58 +74,34 @@ namespace DFHack
} }
std::string full; std::string full;
std::string attr; std::string attr;
virtual ~SymbolsXmlBadAttribute() throw(){};
virtual ~MemoryXmlBadAttribute() throw(){};
virtual const char* what() const throw() virtual const char* what() const throw()
{ {
return full.c_str(); return full.c_str();
} }
}; };
class DFHACK_EXPORT MemoryXmlNoRoot : public All class DFHACK_EXPORT SymbolsXmlNoRoot : public All
{
public:
MemoryXmlNoRoot() {}
virtual ~MemoryXmlNoRoot() throw(){};
virtual const char* what() const throw()
{
return "no pElem found";
}
};
class DFHACK_EXPORT MemoryXmlNoDFExtractor : public All
{ {
public: public:
MemoryXmlNoDFExtractor(const char* _name) : name(_name) SymbolsXmlNoRoot() {}
{ virtual ~SymbolsXmlNoRoot() throw(){};
std::stringstream s;
s << "DFExtractor != " << name;
full = s.str();
}
virtual ~MemoryXmlNoDFExtractor() throw(){};
std::string name;
std::string full;
virtual const char* what() const throw() virtual const char* what() const throw()
{ {
return full.c_str(); return "Symbol file is missing root element.";
} }
}; };
class DFHACK_EXPORT MemoryXmlUnderspecifiedEntry : public All class DFHACK_EXPORT SymbolsXmlUnderspecifiedEntry : public All
{ {
public: public:
MemoryXmlUnderspecifiedEntry(const char * _where) : where(_where) SymbolsXmlUnderspecifiedEntry(const char * _where) : where(_where)
{ {
std::stringstream s; std::stringstream s;
s << "underspecified MemInfo entry, each entry needs to set both the name attribute and have a value. parent: " << where; s << "Underspecified symbol file entry, each entry needs to set both the name attribute and have a value. parent: " << where;
full = s.str(); full = s.str();
} }
virtual ~MemoryXmlUnderspecifiedEntry() throw(){}; virtual ~SymbolsXmlUnderspecifiedEntry() throw(){};
std::string where; std::string where;
std::string full; std::string full;
virtual const char* what() const throw() virtual const char* what() const throw()
@ -278,104 +109,6 @@ namespace DFHack
return full.c_str(); return full.c_str();
} }
}; };
class DFHACK_EXPORT MemoryXmlUnknownType : public All
{
public:
MemoryXmlUnknownType(const char* _type) : type(_type)
{
std::stringstream s;
s << "unknown MemInfo type: " << type;
full = s.str();
}
virtual ~MemoryXmlUnknownType() throw(){};
std::string type;
std::string full;
virtual const char* what() const throw()
{
return full.c_str();
}
};
class DFHACK_EXPORT SHMServerDisappeared : public All
{
public:
SHMServerDisappeared(){}
virtual ~SHMServerDisappeared() throw(){};
virtual const char* what() const throw()
{
return "The server process has disappeared";
}
};
class DFHACK_EXPORT SHMLockingError : public All
{
public:
SHMLockingError(const char* _type) : type(_type)
{
std::stringstream s;
s << "SHM locking error: " << type;
full = s.str();
}
virtual ~SHMLockingError() throw(){};
std::string type;
std::string full;
virtual const char* what() const throw()
{
return full.c_str();
}
};
class DFHACK_EXPORT MemoryAccessDenied : public All
{
public:
std::string descr;
MemoryAccessDenied(uint64_t address)
{
std::stringstream s;
s << "Invalid memory access @0x" << std::hex << address;
descr = s.str();
}
virtual ~MemoryAccessDenied() throw(){};
virtual const char* what() const throw()
{
return descr.c_str();
}
};
class DFHACK_EXPORT SHMVersionMismatch : public All
{
public:
SHMVersionMismatch() {}
virtual ~SHMVersionMismatch() throw(){};
virtual const char* what() const throw()
{
return "SHM VERSION MISMATCH";
}
};
class DFHACK_EXPORT SHMAttachFailure : public All
{
public:
SHMAttachFailure() {}
virtual ~SHMAttachFailure() throw(){};
virtual const char* what() const throw()
{
return "SHM ATTACH FAILURE";
}
};
class DFHACK_EXPORT ModuleNotInitialized : public All
{
public:
ModuleNotInitialized() {}
virtual ~ModuleNotInitialized() throw(){};
virtual const char* what() const throw()
{
return "Programmer error: module not initialized!";
}
};
} }
} }
#endif // ERROR_H_INCLUDED

@ -1,36 +0,0 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#pragma once
#include <string>
namespace DFHack
{
/// very generic representation of a virtual class... just the pointer to the vtable.
/// this is intended for instances where wrapping the classes properly hasn't been done yet.
struct t_virtual
{
void * vptr;
std::string getClassName() const;
};
}

@ -25,7 +25,6 @@ distribution.
#pragma once #pragma once
#include "Export.h" #include "Export.h"
#include "Module.h" #include "Module.h"
#include "Virtual.h"
#include "BitArray.h" #include "BitArray.h"
#include "ColorText.h" #include "ColorText.h"
#include <string> #include <string>

@ -29,7 +29,6 @@ distribution.
#include "Export.h" #include "Export.h"
#include "Module.h" #include "Module.h"
#include "Types.h" #include "Types.h"
#include "Virtual.h"
#include "modules/Materials.h" #include "modules/Materials.h"
#include "MemAccess.h" #include "MemAccess.h"
@ -123,8 +122,6 @@ DFHACK_EXPORT bool copyItem(df::item * source, dfh_item & target);
/// write copied item back to its origin /// write copied item back to its origin
DFHACK_EXPORT bool writeItem(const dfh_item & item); DFHACK_EXPORT bool writeItem(const dfh_item & item);
/// get the class name of an item
DFHACK_EXPORT std::string getItemClass(const df::item * item);
/// who owns this item we already read? /// who owns this item we already read?
DFHACK_EXPORT int32_t getItemOwnerID(const df::item * item); DFHACK_EXPORT int32_t getItemOwnerID(const df::item * item);
DFHACK_EXPORT df::unit *getItemOwner(const df::item * item); DFHACK_EXPORT df::unit *getItemOwner(const df::item * item);

@ -34,7 +34,6 @@ distribution.
#include "Module.h" #include "Module.h"
#include "modules/Vegetation.h" #include "modules/Vegetation.h"
#include <vector> #include <vector>
#include "Virtual.h"
#include "BitArray.h" #include "BitArray.h"
#include "modules/Materials.h" #include "modules/Materials.h"

@ -41,7 +41,6 @@ using namespace std;
#include "modules/Units.h" #include "modules/Units.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "Core.h" #include "Core.h"
#include "Virtual.h"
#include "MiscUtils.h" #include "MiscUtils.h"
#include "df/world.h" #include "df/world.h"
@ -502,10 +501,3 @@ bool Items::removeItemOwner(df::item * item)
return true; return true;
} }
std::string Items::getItemClass(const df::item * item)
{
const t_virtual * virt = (t_virtual *) item;
return virt->getClassName();
}

@ -88,7 +88,10 @@ bool Maps::IsValid ()
void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z) void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
{ {
if (!IsValid()) if (!IsValid())
throw DFHack::Error::ModuleNotInitialized(); {
x = y = z = 0;
return;
}
x = world->map.x_count_block; x = world->map.x_count_block;
y = world->map.y_count_block; y = world->map.y_count_block;
z = world->map.z_count_block; z = world->map.z_count_block;
@ -98,7 +101,10 @@ void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
void Maps::getPosition (int32_t& x, int32_t& y, int32_t& z) void Maps::getPosition (int32_t& x, int32_t& y, int32_t& z)
{ {
if (!IsValid()) if (!IsValid())
throw DFHack::Error::ModuleNotInitialized(); {
x = y = z = 0;
return;
}
x = world->map.region_x; x = world->map.region_x;
y = world->map.region_y; y = world->map.region_y;
z = world->map.region_z; z = world->map.region_z;

@ -24,7 +24,6 @@ distribution.
#include "Export.h" #include "Export.h"
#include "Module.h" #include "Module.h"
#include "Virtual.h"
#include "BitArray.h" #include "BitArray.h"
#include <string> #include <string>

@ -60,6 +60,8 @@ ADD_CUSTOM_COMMAND(
DEPENDS protoc-bin ${PROJECT_PROTOS} DEPENDS protoc-bin ${PROJECT_PROTOS}
) )
SET_SOURCE_FILES_PROPERTIES( Brushes.h PROPERTIES HEADER_FILE_ONLY TRUE )
# Plugins # Plugins
OPTION(BUILD_SUPPORTED "Build the supported plugins (reveal, probe, etc.)." ON) OPTION(BUILD_SUPPORTED "Build the supported plugins (reveal, probe, etc.)." ON)
if (BUILD_SUPPORTED) if (BUILD_SUPPORTED)
@ -79,8 +81,8 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(vdig vdig.cpp) DFHACK_PLUGIN(vdig vdig.cpp)
DFHACK_PLUGIN(colonies colonies.cpp) DFHACK_PLUGIN(colonies colonies.cpp)
DFHACK_PLUGIN(mode mode.cpp) DFHACK_PLUGIN(mode mode.cpp)
DFHACK_PLUGIN(liquids liquids.cpp) DFHACK_PLUGIN(liquids liquids.cpp Brushes.h)
DFHACK_PLUGIN(tiletypes tiletypes.cpp) DFHACK_PLUGIN(tiletypes tiletypes.cpp Brushes.h)
DFHACK_PLUGIN(tubefill tubefill.cpp) DFHACK_PLUGIN(tubefill tubefill.cpp)
DFHACK_PLUGIN(autodump autodump.cpp) DFHACK_PLUGIN(autodump autodump.cpp)
DFHACK_PLUGIN(cleanowned cleanowned.cpp) DFHACK_PLUGIN(cleanowned cleanowned.cpp)

@ -20,6 +20,7 @@ using std::set;
#include "TileTypes.h" #include "TileTypes.h"
#include "modules/MapCache.h" #include "modules/MapCache.h"
#include "df/tile_dig_designation.h" #include "df/tile_dig_designation.h"
#include "Brushes.h"
using namespace MapExtras; using namespace MapExtras;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; 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; CommandHistory tiletypes_hist;
command_result df_tiletypes (color_ostream &out, vector <string> & parameters); command_result df_tiletypes (color_ostream &out, vector <string> & parameters);