2012-02-17 15:20:17 -07:00
|
|
|
#include "Core.h"
|
|
|
|
#include "Console.h"
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "DataDefs.h"
|
2012-02-17 15:20:17 -07:00
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "df/block_square_event_frozen_liquidst.h"
|
|
|
|
#include "df/map_block.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
|
2012-02-17 15:20:17 -07:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using namespace DFHack;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
command_result df_frozenlava (color_ostream &out, vector <string> & parameters)
|
2012-02-17 15:20:17 -07:00
|
|
|
{
|
|
|
|
if (parameters.size())
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
CoreSuspender suspend;
|
2012-02-17 15:20:17 -07:00
|
|
|
|
|
|
|
if (!Maps::IsValid())
|
|
|
|
{
|
2012-03-10 06:25:00 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2012-02-17 15:20:17 -07:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
int tiles = changeLiquid(tile_liquid::Magma);
|
|
|
|
|
|
|
|
if (tiles)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("Changed %i tiles of ice into frozen lava.\n", tiles);
|
2012-02-17 15:20:17 -07:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
command_result df_frozenwater (color_ostream &out, vector <string> & parameters)
|
2012-02-17 15:20:17 -07:00
|
|
|
{
|
|
|
|
if (parameters.size())
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
CoreSuspender suspend;
|
2012-02-17 15:20:17 -07:00
|
|
|
|
|
|
|
if (!Maps::IsValid())
|
|
|
|
{
|
2012-03-10 06:25:00 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2012-02-17 15:20:17 -07:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
int tiles = changeLiquid(tile_liquid::Water);
|
|
|
|
|
|
|
|
if (tiles)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("Changed %i tiles of ice into frozen water.\n", tiles);
|
2012-02-17 15:20:17 -07:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-02-21 10:19:17 -07:00
|
|
|
DFHACK_PLUGIN("frozen");
|
2012-02-17 15:20:17 -07:00
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
2012-02-17 15:20:17 -07:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
2012-02-17 15:20:17 -07:00
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|