2010-05-25 19:22:17 -06:00
|
|
|
// This tool counts static tiles and active flows of water and magma.
|
2010-05-03 20:47:06 -06:00
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
2012-01-11 09:29:59 -07:00
|
|
|
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "DataDefs.h"
|
2012-01-11 09:29:59 -07:00
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/map_block.h"
|
|
|
|
#include "df/tile_liquid.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
2011-08-08 18:07:29 -06:00
|
|
|
using namespace DFHack;
|
2012-01-21 17:31:15 -07:00
|
|
|
using namespace df::enums;
|
2010-05-03 20:47:06 -06:00
|
|
|
|
2012-01-11 09:29:59 -07:00
|
|
|
using df::global::world;
|
|
|
|
|
2012-02-13 21:54:08 -07:00
|
|
|
command_result df_flows (Core * c, vector <string> & parameters)
|
2012-01-11 09:29:59 -07:00
|
|
|
{
|
|
|
|
CoreSuspender suspend(c);
|
|
|
|
|
|
|
|
int flow1 = 0, flow2 = 0, flowboth = 0, water = 0, magma = 0;
|
|
|
|
c->con.print("Counting flows and liquids ...\n");
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < world->map.map_blocks.size(); i++)
|
2012-01-11 09:29:59 -07:00
|
|
|
{
|
|
|
|
df::map_block *cur = world->map.map_blocks[i];
|
2012-02-15 13:35:44 -07:00
|
|
|
if (cur->flags.bits.update_liquid)
|
2012-01-11 09:29:59 -07:00
|
|
|
flow1++;
|
2012-02-15 13:35:44 -07:00
|
|
|
if (cur->flags.bits.update_liquid_twice)
|
2012-01-11 09:29:59 -07:00
|
|
|
flow2++;
|
2012-02-15 13:35:44 -07:00
|
|
|
if (cur->flags.bits.update_liquid && cur->flags.bits.update_liquid_twice)
|
2012-01-11 09:29:59 -07:00
|
|
|
flowboth++;
|
|
|
|
for (int x = 0; x < 16; x++)
|
|
|
|
{
|
|
|
|
for (int y = 0; y < 16; y++)
|
|
|
|
{
|
|
|
|
// only count tiles with actual liquid in them
|
|
|
|
if (cur->designation[x][y].bits.flow_size == 0)
|
|
|
|
continue;
|
2012-01-21 17:31:15 -07:00
|
|
|
if (cur->designation[x][y].bits.liquid_type == tile_liquid::Magma)
|
2012-01-11 09:29:59 -07:00
|
|
|
magma++;
|
2012-01-21 17:31:15 -07:00
|
|
|
if (cur->designation[x][y].bits.liquid_type == tile_liquid::Water)
|
2012-01-11 09:29:59 -07:00
|
|
|
water++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c->con.print("Blocks with liquid_1=true: %d\n", flow1);
|
|
|
|
c->con.print("Blocks with liquid_2=true: %d\n", flow2);
|
|
|
|
c->con.print("Blocks with both: %d\n", flowboth);
|
|
|
|
c->con.print("Water tiles: %d\n", water);
|
|
|
|
c->con.print("Magma tiles: %d\n", magma);
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2011-08-08 18:07:29 -06:00
|
|
|
|
|
|
|
DFhackCExport const char * plugin_name ( void )
|
|
|
|
{
|
|
|
|
return "flows";
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
commands.clear();
|
|
|
|
commands.push_back(PluginCommand("flows",
|
2012-01-11 09:29:59 -07:00
|
|
|
"Counts map blocks with flowing liquids.",
|
|
|
|
df_flows));
|
2011-08-08 18:07:29 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown ( Core * c )
|
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|