Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 15 16 [17] 18 19 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1405020 times)

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: DFHack 0.31.25 r7c (current)
« Reply #240 on: November 02, 2011, 10:29:23 pm »

so should I pick up r7d? or continue with r7
r7d is r7 with bugfixes - they are functionally the same. It shouldn't be any problem to update :)

rampaging-poet

  • Bay Watcher
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #241 on: November 03, 2011, 03:15:56 am »

So I tried to make the two requested traffic plugins today, but something's broken on my end.  After creating a quick test function, I rebuilt dfhack, but it gave me an error message claiming the vector iterators were incompatible when I tried to run Dwarf Fortress.  My 30-day trial of Visual Studio 2010 just ran out and I had to actually register; could that be the problem?
Logged
Lame excuse? 'Having a drink instead' is the dwarfiest reason to not get something done, short of accidentally flooding your home with magma. Or intentionally flooding your home with magma.

uggi

  • Bay Watcher
    • View Profile
Re: DFHack 0.31.25 r7c (current)
« Reply #242 on: November 03, 2011, 04:41:55 am »

Awesome! Try the r7d binary release if you can. I added even more output when stuff fails and I'd like to see it. It's such a weird problem you ran into :)

I ran it a few times. The MD5 hash is still random, but the file length and hex dump are correct with every run, they match the libs/Dwarf_Fortress file.

Loading hack/Memory.xml ... OK
Unable to retrieve version information.
File: /proc/self/exe
MD5: 8e7a74e7735f8d4296171592f70cd1eb
working dir: /home/uggi/df_linux
length:12540712
1KB hexdump follows:
7f 45 4c 46  01 01 01 00  00 00 00 00  00 00 00 00
02 00 03 00  01 00 00 00  30 c9 04 08  34 00 00 00
c8 56 bf 00  00 00 00 00  34 00 20 00  08 00 28 00
1c 00 1b 00  06 00 00 00  34 00 00 00  34 80 04 08
34 80 04 08  00 01 00 00  00 01 00 00  05 00 00 00
04 00 00 00  03 00 00 00  34 01 00 00  34 81 04 08
34 81 04 08  13 00 00 00  13 00 00 00  04 00 00 00
01 00 00 00  01 00 00 00  00 00 00 00  00 80 04 08
00 80 04 08  00 49 bf 00  00 49 bf 00  05 00 00 00
00 10 00 00  01 00 00 00  00 49 bf 00  00 d9 c3 08
00 d9 c3 08  74 06 00 00  4c e2 a3 00  06 00 00 00
00 10 00 00  02 00 00 00  50 4a bf 00  50 da c3 08
50 da c3 08  00 01 00 00  00 01 00 00  06 00 00 00
04 00 00 00  04 00 00 00  48 01 00 00  48 81 04 08
48 81 04 08  20 00 00 00  20 00 00 00  04 00 00 00
04 00 00 00  50 e5 74 64  6c 18 b5 00  6c 98 b9 08
6c 98 b9 08  6c f1 00 00  6c f1 00 00  04 00 00 00
04 00 00 00  51 e5 74 64  00 00 00 00  00 00 00 00
00 00 00 00  00 00 00 00  00 00 00 00  06 00 00 00
04 00 00 00  2f 6c 69 62  2f 6c 64 2d  6c 69 6e 75
78 2e 73 6f  2e 32 00 00  04 00 00 00  10 00 00 00
01 00 00 00  47 4e 55 00  00 00 00 00  02 00 00 00
06 00 00 00  08 00 00 00  c5 00 00 00  fb 00 00 00
85 00 00 00  00 00 00 00  97 00 00 00  5b 00 00 00
df 00 00 00  00 00 00 00  dd 00 00 00  d4 00 00 00
31 00 00 00  c2 00 00 00  6d 00 00 00  79 00 00 00
11 00 00 00  21 00 00 00  6f 00 00 00  b3 00 00 00
90 00 00 00  e3 00 00 00  be 00 00 00  91 00 00 00
e2 00 00 00  00 00 00 00  57 00 00 00  d3 00 00 00
00 00 00 00  b9 00 00 00  00 00 00 00  00 00 00 00
00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
8e 00 00 00  c4 00 00 00  00 00 00 00  59 00 00 00
ec 00 00 00  00 00 00 00  00 00 00 00  9b 00 00 00
00 00 00 00  f9 00 00 00  9a 00 00 00  bc 00 00 00
cc 00 00 00  00 00 00 00  c7 00 00 00  bf 00 00 00
80 00 00 00  f0 00 00 00  b7 00 00 00  a4 00 00 00
ba 00 00 00  93 00 00 00  ca 00 00 00  00 00 00 00
8d 00 00 00  e0 00 00 00  00 00 00 00  b8 00 00 00
c5 00 00 00  c8 00 00 00  00 00 00 00  7f 00 00 00
6c 00 00 00  00 00 00 00  52 00 00 00  12 00 00 00
05 00 00 00  e8 00 00 00  f1 00 00 00  f2 00 00 00
f7 00 00 00  a5 00 00 00  00 00 00 00  00 00 00 00
28 00 00 00  3b 00 00 00  0f 00 00 00  00 00 00 00
d9 00 00 00  65 00 00 00  ce 00 00 00  68 00 00 00
00 00 00 00  70 00 00 00  55 00 00 00  00 00 00 00
00 00 00 00  7a 00 00 00  d8 00 00 00  af 00 00 00
e9 00 00 00  00 00 00 00  9d 00 00 00  00 00 00 00
32 00 00 00  c9 00 00 00  10 00 00 00  00 00 00 00
00 00 00 00  de 00 00 00  f5 00 00 00  e5 00 00 00
b5 00 00 00  04 00 00 00  00 00 00 00  eb 00 00 00
00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
d5 00 00 00  00 00 00 00  f3 00 00 00  00 00 00 00
8b 00 00 00  00 00 00 00  00 00 00 00  63 00 00 00
00 00 00 00  00 00 00 00  ea 00 00 00  c6 00 00 00
82 00 00 00  1a 00 00 00  44 00 00 00  c1 00 00 00
ee 00 00 00  00 00 00 00  f6 00 00 00  00 00 00 00
00 00 00 00  ab 00 00 00  00 00 00 00  a3 00 00 00
da 00 00 00  00 00 00 00  00 00 00 00  7b 00 00 00
d1 00 00 00  2a 00 00 00  d2 00 00 00  00 00 00 00
77 00 00 00  db 00 00 00  83 00 00 00  76 00 00 00
00 00 00 00  cb 00 00 00  00 00 00 00  81 00 00 00
bb 00 00 00  98 00 00 00  c3 00 00 00  95 00 00 00
88 00 00 00  ef 00 00 00  00 00 00 00  e1 00 00 00
aa 00 00 00  cd 00 00 00  0b 00 00 00  00 00 00 00
Not a known DF version. DFHack will now deactivate.
Logged

nf_xp

  • Escaped Lunatic
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #243 on: November 03, 2011, 05:06:10 am »

hi peterix,

i enhanced the tiletypes plugin to make it able to change variant, hidden, light, subterranean and skyview. so it's possible to do something like changing var_2 floor to a wall (cannot do before)... and these flags, it almost can UNDO any of your earth works without restart the game.

if you like the idea, could you add this change to dfhack? i'd like to commit the code but i dont know how to use the github.

sorry, seems i don't have permission to add attachment. i just post the code here.
<tiletypes.cpp>
Code: [Select]
//
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <sstream>
using std::vector;
using std::string;
using std::endl;
using std::set;

#include <dfhack/Core.h>
#include <dfhack/Console.h>
#include <dfhack/Export.h>
#include <dfhack/PluginManager.h>
#include <dfhack/modules/Vegetation.h>
#include <dfhack/modules/Maps.h>
#include <dfhack/modules/Gui.h>
#include <dfhack/TileTypes.h>
#include <dfhack/extra/MapExtras.h>
using namespace MapExtras;
using namespace DFHack;

//zilpin: These two functions were giving me compile errors in VS2008, so I cheated with the C style loop below, just to get it to build.
//Original code is commented out.
void tolower(std::string &str)
{
    //The C++ way...
    //std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(&std::tolower<char> ), std::locale("")));

    //The C way...
    for(char *c=(char *)str.c_str(); *c; ++c)
    {
        *c = tolower(*c);
    }
}

void toupper(std::string &str)
{
    //std::transform(str.begin(), str.end(), str.begin(), std::bind2nd(std::ptr_fun(&std::toupper<char>), std::locale("")));
    for(char *c=(char *)str.c_str(); *c; ++c)
    {
        *c = toupper(*c);
    }
}

int toint(const std::string &str, int failValue = 0)
{
    std::istringstream ss(str);
    int valInt;
    ss >> valInt;
    if (ss.fail())
    {
        return failValue;
    }
    return valInt;
}

struct TileType
{
    DFHack::TileShape shape;
    DFHack::TileMaterial material;
    DFHack::TileSpecial special;
    DFHack::TileVariant variant;
    int hidden;
    int light;
    int subterranean;
    int skyview;

    TileType()
    {
        shape = DFHack::tileshape_invalid;
        material = DFHack::tilematerial_invalid;
        special = DFHack::tilespecial_invalid;
        variant = DFHack::tilevariant_invalid;
        hidden = -1;
        light = -1;
        subterranean = -1;
        skyview = -1;
    }

    bool empty()
    {
        return shape == -1 && material == -1 && special == -1 && variant == -1
            && hidden == -1 && light == -1 && subterranean == -1 && skyview == -1;
    }
};

std::ostream &operator<<(std::ostream &stream, const TileType &paint)
{
    bool used = false;
    bool needSpace = false;

    if (paint.special >= 0)
    {
        stream << DFHack::TileSpecialString[paint.special];
        used = true;
        needSpace = true;
    }

    if (paint.material >= 0)
    {
        if (needSpace)
        {
            stream << " ";
            needSpace = false;
        }

        stream << DFHack::TileMaterialString[paint.material];
        used = true;
        needSpace = true;
    }

    if (paint.shape >= 0)
    {
        if (needSpace)
        {
            stream << " ";
            needSpace = false;
        }

        stream << DFHack::TileShapeString[paint.shape];
        used = true;
        needSpace = true;
    }

    if (paint.variant >= 0)
    {
        if (needSpace)
        {
            stream << " ";
            needSpace = false;
        }

        stream << "VAR_" << (paint.variant + 1);
        used = true;
        needSpace = true;
    }

    if (paint.hidden >= 0)
    {
        if (needSpace)
        {
            stream << " ";
            needSpace = false;
        }

        stream << (paint.hidden ? "HIDDEN" : "VISIBLE");
        used = true;
        needSpace = true;
    }

    if (paint.light >= 0)
    {
        if (needSpace)
        {
            stream << " ";
            needSpace = false;
        }

        stream << (paint.light ? "LIGHT" : "DARK");
        used = true;
        needSpace = true;
    }

    if (paint.subterranean >= 0)
    {
        if (needSpace)
        {
            stream << " ";
            needSpace = false;
        }

        stream << (paint.subterranean ? "SUBTERRANEAN" : "ABOVE GROUND");
        used = true;
        needSpace = true;
    }

    if (paint.skyview >= 0)
    {
        if (needSpace)
        {
            stream << " ";
            needSpace = false;
        }

        stream << (paint.skyview ? "OUTSIDE" : "INSIDE");
        used = true;
        needSpace = true;
    }

    if (!used)
    {
        stream << "any";
    }

    return stream;
}

bool processTileType(TileType &paint, const std::string &option, const std::string &value)
{
    std::string val = value;
    toupper(val);
    int valInt;
    if (val == "ANY")
    {
        valInt = -1;
    }
    else
    {
        valInt = toint(value, -2);
    }
    bool found = false;

    if (option == "shape" || option == "sh" || option == "s")
    {
        if (valInt >= -1 && valInt < DFHack::tileshape_count)
        {
            paint.shape = (DFHack::TileShape) valInt;
            found = true;
        }
        else
        {
            for (int i = 0; i < DFHack::tileshape_count; i++)
            {
                if (val == DFHack::TileShapeString[i])
                {
                    paint.shape = (DFHack::TileShape) i;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                std::cout << "Unknown tile shape: " << value << std::endl;
            }
        }
    }
    else if (option == "material" || option == "mat" || option == "m")
    {
        if (valInt >= -1 && valInt < DFHack::tilematerial_count)
        {
            paint.material = (DFHack::TileMaterial) valInt;
            found = true;
        }
        else
        {
            for (int i = 0; i < DFHack::tilematerial_count; i++)
            {
                if (val == DFHack::TileMaterialString[i])
                {
                    paint.material = (DFHack::TileMaterial) i;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                std::cout << "Unknown tile material: " << value << std::endl;
            }
        }
    }
    else if (option == "special" || option == "sp")
    {
        if (valInt >= -1 && valInt < DFHack::tilespecial_count)
        {
            paint.special = (DFHack::TileSpecial) valInt;
            found = true;
        }
        else
        {
            for (int i = 0; i < DFHack::tilespecial_count; i++)
            {
                if (val == DFHack::TileSpecialString[i])
                {
                    paint.special = (DFHack::TileSpecial) i;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                std::cout << "Unknown tile special: " << value << std::endl;
            }
        }
    }
    else if (option == "variant" || option == "var" || option == "v")
    {
        if (valInt >= -1 && valInt <= DFHack::VAR_4)
        {
            paint.variant = (DFHack::TileVariant) valInt;
            found = true;
        }
        else
        {
            std::cout << "Unknown tile variant: " << value << std::endl;
        }
    }
    else if (option == "hidden" || option == "h")
    {
        if (valInt >= -1 && valInt < 2)
        {
            paint.hidden = valInt;
            found = true;
        }
        else
        {
            std::cout << "Unknown hidden flag: " << value << std::endl;
        }
    }
    else if (option == "light" || option == "l")
    {
        if (valInt >= -1 && valInt < 2)
        {
            paint.light = valInt;
            found = true;
        }
        else
        {
            std::cout << "Unknown light flag: " << value << std::endl;
        }
    }
    else if (option == "subterranean" || option == "st")
    {
        if (valInt >= -1 && valInt < 2)
        {
            paint.subterranean = valInt;
            found = true;
        }
        else
        {
            std::cout << "Unknown subterranean flag: " << value << std::endl;
        }
    }
    else if (option == "skyview" || option == "sv")
    {
        if (valInt >= -1 && valInt < 2)
        {
            paint.skyview = valInt;
            found = true;
        }
        else
        {
            std::cout << "Unknown skyview flag: " << value << std::endl;
        }
    }
    else
    {
        std::cout << "Unknown option: '" << option << "'" << std::endl;
    }

    return found;
}

void help( std::ostream & out, const std::string &option)
{
    if (option.empty())
    {
        out << "Commands:" << std::endl
            << " quit / q              : quit" << std::endl
            << " filter / f [options]  : change filter options" << std::endl
            << " paint / p [options]   : change paint options" << std::endl
            << " point / p             : set point brush" << std::endl
            << " range / r             : set range brush" << std::endl
            << " block                 : set block brush" << std::endl
            << " column                : set column brush" << std::endl
            << std::endl
            << "Filter/paint options:" << std::endl
            << " Shape / sh / s: set tile shape information" << std::endl
            << " Material / mat / m: set tile material information" << std::endl
            << " Special / sp: set special tile information" << std::endl
            << " Variant / var / v: set variant tile information" << std::endl
            << " Hidden / h: set hidden flag" << std::endl
            << " Light / l: set light flag" << std::endl
            << " Subterranean / st: set subterranean flag" << std::endl
            << " Skyview / sv: set skyview flag" << std::endl
            << "See help [option] for more information" << std::endl;
    }
    else if (option == "shape" || option == "s" ||option == "sh")
    {
        out << "Available shapes:" << std::endl
            << " ANY" << std::endl;
        for (int i = 0; i < DFHack::tileshape_count; i++)
        {
            out << " " << DFHack::TileShapeString[i] << std::endl;
        }
    }
    else if (option == "material"|| option == "mat" ||option == "m")
    {
        out << "Available materials:" << std::endl
            << " ANY" << std::endl;
        for (int i = 0; i < DFHack::tilematerial_count; i++)
        {
            out << " " << DFHack::TileMaterialString[i] << std::endl;
        }
    }
    else if (option == "special" || option == "sp")
    {
        out << "Available specials:" << std::endl
            << " ANY" << std::endl;
        for (int i = 0; i < DFHack::tilespecial_count; i++)
        {
            out << " " << DFHack::TileSpecialString[i] << std::endl;
        }
    }
    else if (option == "variant" || option == "var" || option == "v")
    {
        out << "Available variants:" << std::endl
            << " ANY, 0 - " << DFHack::VAR_4 << std::endl;
    }
    else if (option == "hidden" || option == "h")
    {
        out << "Available hidden flags:" << std::endl
            << " ANY, 0, 1" << std::endl;
    }
    else if (option == "light" || option == "l")
    {
        out << "Available light flags:" << std::endl
            << " ANY, 0, 1" << std::endl;
    }
    else if (option == "subterranean" || option == "st")
    {
        out << "Available subterranean flags:" << std::endl
            << " ANY, 0, 1" << std::endl;
    }
    else if (option == "skyview" || option == "sv")
    {
        out << "Available skyview flags:" << std::endl
            << " ANY, 0, 1" << std::endl;
    }
}

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))
        {
            uint16_t tt = mc.tiletypeAt(start);
            if(DFHack::LowPassable(tt) || juststarted && DFHack::HighPassable(tt))
            {
                v.push_back(start);
                juststarted = false;
                start.z++;
            }
            else break;
        }
        return v;
    };
};

CommandHistory tiletypes_hist;

DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameters);

DFhackCExport const char * plugin_name ( void )
{
    return "tiletypes";
}

DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{
    tiletypes_hist.load("tiletypes.history");
    commands.clear();
    commands.push_back(PluginCommand("tiletypes", "Paint map tiles freely, similar to liquids.", df_tiletypes, true));
    return CR_OK;
}

DFhackCExport command_result plugin_shutdown ( Core * c )
{
    tiletypes_hist.save("tiletypes.history");
    return CR_OK;
}

DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameters)
{
    uint32_t x_max = 0, y_max = 0, z_max = 0;
    int32_t x = 0, y = 0, z = 0;

    DFHack::Maps *maps;
    DFHack::Gui *gui;
    for(int i = 0; i < parameters.size();i++)
    {
        if(parameters[i] == "help" || parameters[i] == "?")
        {
            c->con.print("This tool allows painting tiles types with a brush, using an optional filter.\n"
                         "The tool is interactive, similarly to the liquids tool.\n"
                         "Further help is available inside.\n"
            );
            return CR_OK;
        }
    }

    TileType filter, paint;
    Brush *brush = new RectangleBrush(1,1);
    bool end = false;
    std::string brushname = "point";
    int width = 1, height = 1, z_levels = 1;
    c->con << "Welcome to the tiletype tool.\nType 'help' or '?' for a list of available commands, 'q' to quit.\nPress return after a command to confirm." << std::endl;
    c->con.printerr("THIS TOOL CAN BE DANGEROUS. YOU'VE BEEN WARNED.\n");
    while (!end)
    {
        c->con << "Filter: " << filter    << std::endl
               << "Paint: "  << paint     << std::endl
               << "Brush: "  << brushname << std::endl;

        std::string input = "";
        std::string command = "";
        std::string option = "";
        std::string value = "";

        c->con.lineedit("tiletypes> ",input,tiletypes_hist);
        tiletypes_hist.add(input);
        std::istringstream ss(input);
        ss >> command >> option >> value;
        tolower(command);
        tolower(option);

        if (command == "help" || command == "?")
        {
            help(c->con,option);
        }
        else if (command == "quit" || command == "q")
        {
            end = true;
        }
        else if (command == "filter" || command == "f")
        {
            processTileType(filter, option, value);
        }
        else if (command == "paint" || (command == "p" && !option.empty()))
        {
            processTileType(paint, option, value);
        }
        else if (command == "point" || command == "p")
        {
            delete brush;
            brushname = "point";
            brush = new RectangleBrush(1,1);
        }
        else if (command == "range" || command == "r")
        {
            std::stringstream ss;
            CommandHistory hist;
            ss << "Set range width <" << width << "> ";
            c->con.lineedit(ss.str(),command,hist);
            width = command == "" ? width : toint(command);
            if (width < 1) width = 1;

            ss.str("");
            ss << "Set range height <" << height << "> ";
            c->con.lineedit(ss.str(),command,hist);
            height = command == "" ? height : toint(command);
            if (height < 1) height = 1;

            ss.str("");
            ss << "Set range z-levels <" << z_levels << "> ";
            c->con.lineedit(ss.str(),command,hist);
            z_levels = command == "" ? z_levels : toint(command);
            if (z_levels < 1) z_levels = 1;

            delete brush;
            if (width == 1 && height == 1 && z_levels == 1)
            {
                brushname = "point";
            }
            else
            {
                brushname = "range";
            }
            brush = new RectangleBrush(width, height, z_levels, 0, 0, 0);
        }
        else if (command == "block")
        {
            delete brush;
            brushname = "block";
            brush = new BlockBrush();
        }
        else if (command == "column")
        {
            delete brush;
            brushname = "column";
            brush = new ColumnBrush();
        }
        else if (command.empty())
        {
            if (paint.empty())
            {
                c->con.printerr("Set the paint first.\n");
                continue;
            }

            c->Suspend();
            maps = c->getMaps();
            gui = c->getGui();
            if (!maps->Start())
            {
                c->con.printerr("Cannot get map info!\n");
                c->Resume();
                return CR_FAILURE;
            }
            maps->getSize(x_max, y_max, z_max);

            if (!(gui->Start() && gui->getCursorCoords(x,y,z)))
            {
                c->con.printerr("Can't get cursor coords! Make sure you have a cursor active in DF.\n");
                c->Resume();
                return CR_FAILURE;
            }
            c->con.print("Cursor coords: (%d, %d, %d)\n",x,y,z);

            DFHack::DFCoord cursor(x,y,z);
            MapExtras::MapCache map(maps);
            coord_vec all_tiles = brush->points(map, cursor);
            c->con.print("working...\n");

            for (coord_vec::iterator iter = all_tiles.begin(); iter != all_tiles.end(); ++iter)
            {
                const DFHack::TileRow *source = DFHack::getTileRow(map.tiletypeAt(*iter));

                if ((filter.shape > -1 && filter.shape != source->shape)
                 || (filter.material > -1 && filter.material != source->material)
                 || (filter.special > -1 && filter.special != source->special))
                {
                    continue;
                }

                DFHack::TileShape shape = paint.shape;
                if (shape < 0)
                {
                    shape = source->shape;
                }

                DFHack::TileMaterial material = paint.material;
                if (material < 0)
                {
                    material = source->material;
                }

                DFHack::TileSpecial special = paint.special;
                if (special < 0)
                {
                    special = source->special;
                }

                DFHack::TileVariant variant = paint.variant;
                if (variant < 0)
                {
                    variant = source->variant;
                }

                // Remove direction from directionless tiles
                DFHack::TileDirection direction = source->direction;
                if (!(shape == DFHack::RIVER_BED || shape == DFHack::BROOK_BED || shape == DFHack::WALL && (material == DFHack::CONSTRUCTED || special == DFHack::TILE_SMOOTH))) {
                    direction.whole = 0;
                }

                int32_t type = DFHack::findTileType(shape, material, variant, special, direction);
                // hack for empty space
                if (shape == DFHack::EMPTY && material == DFHack::AIR && variant == DFHack::VAR_1 && special == DFHack::TILE_NORMAL && direction.whole == 0) {
                    type = 32;
                }
                // make sure it's not invalid
                if(type != -1)
                    map.setTiletypeAt(*iter, type);

                DFHack::t_designation des = map.designationAt(*iter);

                if (paint.hidden > -1)
                {
                    des.bits.hidden = paint.hidden;
                }

                if (paint.light > -1)
                {
                    des.bits.light = paint.light;
                }

                if (paint.subterranean > -1)
                {
                    des.bits.subterranean = paint.subterranean;
                }

                if (paint.skyview > -1)
                {
                    des.bits.skyview = paint.skyview;
                }

                // Remove liquid from walls, etc
                if (type != -1 && !DFHack::FlowPassable(type))
                {
                    des.bits.flow_size = 0;
                    //des.bits.liquid_type = DFHack::liquid_water;
                    //des.bits.water_table = 0;
                    des.bits.flow_forbid = 0;
                    //des.bits.liquid_static = 0;
                    //des.bits.water_stagnant = 0;
                    //des.bits.water_salt = 0;
                }

                map.setDesignationAt(*iter, des);
            }

            if (map.WriteAll())
            {
                c->con.print("OK\n");
            }
            else
            {
                c->con.printerr("Something failed horribly! RUN!\n");
            }
            maps->Finish();
            c->Resume();
        }
    }
    return CR_OK;
}
« Last Edit: November 03, 2011, 05:38:23 am by nf_xp »
Logged

Makbeth

  • Bay Watcher
  • His lower body is melted.
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #244 on: November 03, 2011, 01:19:44 pm »

Peterix, I have a feasibility question.

I've been wanting a way to absolutely forbid dwarves from passing through certain tiles, as if that tile were a wall, even if there's no other passage open to them, for a while now.  Is there a way to modify the passable state for a tile using DFhack, and can a burrow with a specific name like "forbidden" be used to tell DFhack which tiles to restrict?  I think an advantage of using burrows for this would be that burrows don't care if a tile is solid, hidden, or whatever, it still includes it.  So, prior to digging a magma channel, you could add the volume of the channel to the forbidden burrow, and the dwarves would stay out of it instead of using it as a walkway while it fills with magma.

Do you think this is possible?
Logged
Diso Faintpuzzles was born in 120.  Although accounts vary it is universally agreed that Diso was chosen by fate as the vanguard of destiny.

In the early spring of 143 Diso began wandering the wilds.

In the early spring of 143 Diso starved to death in the Horn of Striking.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #245 on: November 03, 2011, 01:21:15 pm »

I think it might be possible, maybe, by using the liquid passability flags.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #246 on: November 03, 2011, 01:59:18 pm »

wonder if someone found away to make DF accept underwater building/and pathing for those who want merman forts
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Andux

  • Bay Watcher
  • [PREFSTRING:semicolons]
    • View Profile
    • Andux's DFWiki page
Re: DFHack 0.31.25 r7d (current)
« Reply #247 on: November 03, 2011, 04:00:44 pm »

I think it might be possible, maybe, by using the liquid passability flags.

I've had some success doing that using the "dangerous terrain" flag (under designations, called flow_forbid in DFHack, danger_zone in my Pascal stuff, or has_liquid in Tweak); as far as I've seen, dwarves will not path through it except to escape from another dangerous tile.
Logged
(Do not sign anything.) -- Fell, Planescape: Torment

MADMAN · Save Tools · WTF Tools · Generated Raws Extractor · Tweak for 0.31–34.xx

T-manSim

  • Bay Watcher
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #248 on: November 03, 2011, 06:08:03 pm »

I'm crashing when I try to run r7d. I'm on Windows 7, using the Lazy Newb Pack. Am I the only one? It loads, but then almost instantly crashes.
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: DFHack 0.31.25 r7d (current)
« Reply #249 on: November 03, 2011, 06:29:03 pm »

Peterix, I have a feasibility question.

I've been wanting a way to absolutely forbid dwarves from passing through certain tiles, as if that tile were a wall, even if there's no other passage open to them, for a while now.  Is there a way to modify the passable state for a tile using DFhack, and can a burrow with a specific name like "forbidden" be used to tell DFhack which tiles to restrict?  I think an advantage of using burrows for this would be that burrows don't care if a tile is solid, hidden, or whatever, it still includes it.  So, prior to digging a magma channel, you could add the volume of the channel to the forbidden burrow, and the dwarves would stay out of it instead of using it as a walkway while it fills with magma.

Do you think this is possible?
There are some obstacles involved: burrows aren't figured out yet and the pathing stuff isn't either... The 'flow_forbid' flag mentioned is probably something like 'stable_liquid' instead - blocking your dwarfs, but also everything that doesn't like going into water.

Certainly feasible, but could be abused as a cheat, so it's not exactly the thing you want, but something more generic.

I'm crashing when I try to run r7d. I'm on Windows 7, using the Lazy Newb Pack. Am I the only one? It loads, but then almost instantly crashes.
Well, you're the first reporting the problem :)

DF version 0.31.25?
« Last Edit: November 03, 2011, 06:34:27 pm by peterix »
Logged

T-manSim

  • Bay Watcher
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #250 on: November 03, 2011, 06:30:41 pm »

I'm crashing when I try to run r7d. I'm on Windows 7, using the Lazy Newb Pack. Am I the only one? It loads, but then almost instantly crashes.
Well, you're the first reporting the problem :)

DF version 0.31.25?
Yes, is there a way to get a log or something?
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: DFHack 0.31.25 r7d (current)
« Reply #251 on: November 03, 2011, 06:35:05 pm »

I'm crashing when I try to run r7d. I'm on Windows 7, using the Lazy Newb Pack. Am I the only one? It loads, but then almost instantly crashes.
Well, you're the first reporting the problem :)

DF version 0.31.25?
Yes, is there a way to get a log or something?
Sort of. Look for stderr.log in your DF folder. Hopefully it's not empty ~_~

T-manSim

  • Bay Watcher
    • View Profile
Re: DFHack 0.31.25 r7d (current)
« Reply #252 on: November 03, 2011, 06:50:26 pm »

Quote
Sort of. Look for stderr.log in your DF folder. Hopefully it's not empty ~_~
Nope, can't find it. Nor can Windows search.  :(
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: DFHack 0.31.25 r7d (current)
« Reply #253 on: November 03, 2011, 07:05:35 pm »

Quote
Sort of. Look for stderr.log in your DF folder. Hopefully it's not empty ~_~
Nope, can't find it. Nor can Windows search.  :(
Ouch. looks like it doesn't even create one on Windows. I must have removed that by accident... gimme a few minutes and I should have a build where this works.

Ok. Here: http://dethware.org/dl/dfhack-0.31.25-r7e-dev1-Windows.zip

Output is fairly minimal when everything works properly.
« Last Edit: November 03, 2011, 07:17:22 pm by peterix »
Logged

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.31.25 r6 (current)
« Reply #254 on: November 03, 2011, 08:46:17 pm »

Is it possible to make a spot clean tool? I want to keep my filth-encrusted entrance hall but clean off some odd pools in the middle of complicated stockpiles.
Done.
Wow, that was quick. Thanks!
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.
Pages: 1 ... 15 16 [17] 18 19 ... 373