Added a basic plant raw check to rawdump plugin.

develop
Petr Mrázek 2011-10-28 05:10:18 +02:00
parent 4d6e93988a
commit 9f9e8f012d
1 changed files with 62 additions and 3 deletions

@ -16,7 +16,8 @@ bool final_flag = true;
bool timering = false; bool timering = false;
uint64_t timeLast = 0; uint64_t timeLast = 0;
DFhackCExport command_result rawdump (Core * c, vector <string> & parameters); DFhackCExport command_result rawdump_i (Core * c, vector <string> & parameters);
DFhackCExport command_result rawdump_p (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -26,7 +27,8 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("rawdump","Dump them raws.",rawdump)); commands.push_back(PluginCommand("dump_inorganic","Dump inorganic raws.",rawdump_i));
commands.push_back(PluginCommand("dump_plants","Dump plant raws.",rawdump_p));
return CR_OK; return CR_OK;
} }
@ -35,7 +37,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result rawdump (Core * c, vector <string> & parameters) DFhackCExport command_result rawdump_i (Core * c, vector <string> & parameters)
{ {
int index = -1; int index = -1;
Console & con = c->con; Console & con = c->con;
@ -78,3 +80,60 @@ DFhackCExport command_result rawdump (Core * c, vector <string> & parameters)
c->Resume(); c->Resume();
return CR_OK; return CR_OK;
} }
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;
}