2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
|
|
|
#include <Console.h>
|
|
|
|
#include <Export.h>
|
|
|
|
#include <PluginManager.h>
|
2011-07-21 14:37:02 -06:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2011-12-31 04:48:42 -07:00
|
|
|
#include <modules/Materials.h>
|
2011-07-21 14:37:02 -06:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using namespace DFHack;
|
|
|
|
//FIXME: possible race conditions with calling kittens from the IO thread and shutdown from Core.
|
|
|
|
bool shutdown_flag = false;
|
|
|
|
bool final_flag = true;
|
|
|
|
bool timering = false;
|
|
|
|
uint64_t timeLast = 0;
|
|
|
|
|
2011-10-27 21:10:18 -06:00
|
|
|
DFhackCExport command_result rawdump_i (Core * c, vector <string> & parameters);
|
|
|
|
DFhackCExport command_result rawdump_p (Core * c, vector <string> & parameters);
|
2011-07-21 14:37:02 -06:00
|
|
|
|
|
|
|
DFhackCExport const char * plugin_name ( void )
|
|
|
|
{
|
|
|
|
return "rawdump";
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
commands.clear();
|
2011-10-27 21:10:18 -06:00
|
|
|
commands.push_back(PluginCommand("dump_inorganic","Dump inorganic raws.",rawdump_i));
|
|
|
|
commands.push_back(PluginCommand("dump_plants","Dump plant raws.",rawdump_p));
|
2011-07-21 14:37:02 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown ( Core * c )
|
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-27 21:10:18 -06:00
|
|
|
DFhackCExport command_result rawdump_i (Core * c, vector <string> & parameters)
|
2011-07-21 14:37:02 -06:00
|
|
|
{
|
|
|
|
int index = -1;
|
|
|
|
Console & con = c->con;
|
|
|
|
if(parameters.size())
|
|
|
|
{
|
|
|
|
index = atoi(parameters[0].c_str());
|
|
|
|
}
|
|
|
|
c->Suspend();
|
|
|
|
Materials * mats = c->getMaterials();
|
|
|
|
if(!mats->df_inorganic)
|
|
|
|
{
|
|
|
|
con.printerr("No inorganic materials :(\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
if(index >= 0)
|
|
|
|
{
|
|
|
|
if( index < mats->df_inorganic->size())
|
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
df_inorganic_type * mat = mats->df_inorganic->at(index);
|
2011-07-21 14:37:02 -06:00
|
|
|
// dump single material
|
|
|
|
con.print("%-3d : [%s] %s\n",
|
|
|
|
index,
|
2011-11-04 02:08:29 -06:00
|
|
|
mat->ID.c_str(),
|
|
|
|
mat->mat.state_name[DFHack::state_solid].c_str());
|
|
|
|
con.print("MAX EDGE: %d\n",mat->mat.MAX_EDGE);
|
2011-07-21 14:37:02 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
con.printerr("Index out of range: %d of %d\n",index, mats->df_inorganic->size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// dump all materials
|
|
|
|
for(int i = 0; i < mats->df_inorganic->size();i++)
|
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
con.print("%-3d : %s\n",i,mats->df_inorganic->at(i)->ID.c_str());
|
2011-07-21 14:37:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
c->Resume();
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2011-10-27 21:10:18 -06:00
|
|
|
|
|
|
|
DFhackCExport command_result rawdump_p (Core * c, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
int index = -1;
|
|
|
|
Console & con = c->con;
|
|
|
|
if(parameters.size())
|
|
|
|
{
|
|
|
|
index = atoi(parameters[0].c_str());
|
|
|
|
}
|
|
|
|
c->Suspend();
|
|
|
|
Materials * mats = c->getMaterials();
|
|
|
|
if(!mats->df_plants)
|
|
|
|
{
|
|
|
|
con.printerr("No inorganic materials :(\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
if(index >= 0)
|
|
|
|
{
|
|
|
|
if( index < mats->df_plants->size())
|
|
|
|
{
|
|
|
|
df_plant_type * mat = mats->df_plants->at(index);
|
|
|
|
// dump single material
|
|
|
|
con.print("%-3d : [%s] %s %s %s\n",
|
|
|
|
index,
|
|
|
|
mat->ID.c_str(),
|
|
|
|
mat->material_str_leaves[0].c_str(),
|
|
|
|
mat->material_str_leaves[1].c_str(),
|
|
|
|
mat->material_str_leaves[2].c_str()
|
|
|
|
);
|
|
|
|
con.print("DEPTH: %d-%d\n",mat->underground_depth[0], mat->underground_depth[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
con.printerr("Index out of range: %d of %d\n",index, mats->df_plants->size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// dump all materials
|
|
|
|
for(int i = 0; i < mats->df_plants->size();i++)
|
|
|
|
{
|
|
|
|
df_plant_type * mat = mats->df_plants->at(i);
|
|
|
|
// dump single material
|
|
|
|
con.print("%-3d : [%s] %s %s %s\n",
|
|
|
|
i,
|
|
|
|
mat->ID.c_str(),
|
|
|
|
mat->material_str_leaves[0].c_str(),
|
|
|
|
mat->material_str_leaves[1].c_str(),
|
|
|
|
mat->material_str_leaves[2].c_str()
|
|
|
|
);
|
|
|
|
con.print("DEPTH: %d-%d\n",mat->underground_depth[0], mat->underground_depth[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c->Resume();
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|