Petr Mrázek 2012-02-19 20:28:08 +01:00
commit 33f77c8837
6 changed files with 131 additions and 18 deletions

@ -26,6 +26,12 @@ distribution.
#include "Export.h"
#include "DataDefs.h"
#include "df/building.h"
#include "df/furnace_type.h"
#include "df/workshop_type.h"
#include "df/construction_type.h"
#include "df/shop_type.h"
#include "df/siegeengine_type.h"
#include "df/trap_type.h"
namespace DFHack
{
@ -45,8 +51,17 @@ struct t_building
uint32_t y2;
uint32_t z;
t_matglossPair material;
int32_t type;
int16_t subtype;
df::building_type type;
union
{
int16_t subtype;
df::furnace_type furnace_type;
df::workshop_type workshop_type;
df::construction_type construction_type;
df::shop_type shop_type;
df::siegeengine_type siegeengine_type;
df::trap_type trap_type;
};
int32_t custom_type;
df::building * origin;
};

@ -57,19 +57,19 @@ uint32_t Buildings::getNumBuildings()
bool Buildings::Read (const uint32_t index, t_building & building)
{
Core & c = Core::getInstance();
df::building *bld_40d = world->buildings.all[index];
building.x1 = bld_40d->x1;
building.x2 = bld_40d->x2;
building.y1 = bld_40d->y1;
building.y2 = bld_40d->y2;
building.z = bld_40d->z;
building.material.index = bld_40d->mat_index;
building.material.type = bld_40d->mat_type;
building.type = bld_40d->getType();
building.subtype = bld_40d->getSubtype();
building.custom_type = bld_40d->getCustomType();
building.origin = bld_40d;
df::building *bld = world->buildings.all[index];
building.x1 = bld->x1;
building.x2 = bld->x2;
building.y1 = bld->y1;
building.y2 = bld->y2;
building.z = bld->z;
building.material.index = bld->mat_index;
building.material.type = bld->mat_type;
building.type = bld->getType();
building.subtype = bld->getSubtype();
building.custom_type = bld->getCustomType();
building.origin = bld;
return true;
}

@ -10,4 +10,5 @@ DFHACK_PLUGIN(memview memview.cpp)
DFHACK_PLUGIN(catsplosion catsplosion.cpp)
DFHACK_PLUGIN(buildprobe buildprobe.cpp)
DFHACK_PLUGIN(tilesieve tilesieve.cpp)
DFHACK_PLUGIN(frozen frozen.cpp)
#DFHACK_PLUGIN(tiles tiles.cpp)

@ -0,0 +1,99 @@
#include "Core.h"
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
#include "DataDefs.h"
#include "modules/Maps.h"
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;
int changeLiquid (df::tile_liquid type)
{
int tiles = 0;
for (int i = 0; i < world->map.map_blocks.size(); i++)
{
df::map_block *block = world->map.map_blocks[i];
for (size_t j = 0; j < block->block_events.size(); j++)
{
df::block_square_event *evt = block->block_events[j];
if (evt->getType() != block_square_event_type::frozen_liquid)
continue;
df::block_square_event_frozen_liquidst *frozen = (df::block_square_event_frozen_liquidst *)evt;
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 16; y++)
{
if ((frozen->tiles[x][y] != tiletype::Void) && (frozen->liquid_type[x][y] != type))
{
frozen->liquid_type[x][y] = type;
tiles++;
}
}
}
}
}
return tiles;
}
command_result df_frozenlava (Core * c, vector <string> & parameters)
{
if (parameters.size())
return CR_WRONG_USAGE;
CoreSuspender suspend(c);
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
int tiles = changeLiquid(tile_liquid::Magma);
if (tiles)
c->con.print("Changed %i tiles of ice into frozen lava.\n", tiles);
return CR_OK;
}
command_result df_frozenwater (Core * c, vector <string> & parameters)
{
if (parameters.size())
return CR_WRONG_USAGE;
CoreSuspender suspend(c);
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
int tiles = changeLiquid(tile_liquid::Water);
if (tiles)
c->con.print("Changed %i tiles of ice into frozen water.\n", tiles);
return CR_OK;
}
DFhackCExport const char * plugin_name ( void )
{
return "frozen";
}
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{
commands.clear();
commands.push_back(PluginCommand("frozenlava", "Changes all ice into frozen magma.", df_frozenlava));
commands.push_back(PluginCommand("frozenwater", "Changes all ice into frozen water.", df_frozenwater));
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( Core * c )
{
return CR_OK;
}

@ -409,9 +409,7 @@ command_result revflood(DFHack::Core * c, std::vector<std::string> & params)
case tiletype_shape::BOULDER:
case tiletype_shape::PEBBLES:
case tiletype_shape::BROOK_BED:
case tiletype_shape::RIVER_BED:
case tiletype_shape::ENDLESS_PIT:
case tiletype_shape::POOL:
if(from_below)
unhide = 0;
above = sides = true;

@ -850,7 +850,7 @@ command_result df_tiletypes (Core * c, vector <string> & parameters)
*/
// Remove direction from directionless tiles
DFHack::TileDirection direction = tileDirection(source);
if (!(shape == tiletype_shape::RIVER_BED || shape == tiletype_shape::BROOK_BED || shape == tiletype_shape::WALL && (material == tiletype_material::CONSTRUCTION || special == tiletype_special::SMOOTH))) {
if (!(material == tiletype_material::RIVER || shape == tiletype_shape::BROOK_BED || shape == tiletype_shape::WALL && (material == tiletype_material::CONSTRUCTION || special == tiletype_special::SMOOTH))) {
direction.whole = 0;
}