2012-02-22 13:00:37 -07:00
|
|
|
// Dump all hardcoded materials
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/material.h"
|
|
|
|
#include "df/builtin_mats.h"
|
|
|
|
#include "df/matter_state.h"
|
|
|
|
#include "df/descriptor_color.h"
|
|
|
|
#include "df/item_type.h"
|
2012-09-14 10:22:49 -06:00
|
|
|
#include "df/strain_type.h"
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
|
|
|
|
using df::global::world;
|
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
command_result df_dumpmats (color_ostream &out, vector<string> ¶meters)
|
2012-02-22 13:00:37 -07:00
|
|
|
{
|
|
|
|
if (!parameters.empty())
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
CoreSuspender suspend;
|
2012-02-22 13:00:37 -07:00
|
|
|
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("hardcoded_materials\n\n");
|
|
|
|
out.print("[OBJECT:MATERIAL]\n");
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
FOR_ENUM_ITEMS(builtin_mats, mat_num)
|
|
|
|
{
|
|
|
|
df::material *mat = world->raws.mat_table.builtin[mat_num];
|
|
|
|
if (!mat)
|
|
|
|
continue;
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\n[MATERIAL:%s] - reconstructed from data extracted from memory\n", mat->id.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
int32_t def_color[6] = {-1,-1,-1,-1,-1,-1};
|
|
|
|
bool name_all = false;
|
|
|
|
bool name_all_solid = false;
|
|
|
|
string def_name[6];
|
|
|
|
bool adj_all = false;
|
|
|
|
bool adj_all_solid = false;
|
|
|
|
string def_adj[6];
|
|
|
|
|
|
|
|
int32_t solid_color = mat->state_color[matter_state::Solid];
|
|
|
|
if (solid_color == mat->state_color[matter_state::Powder] ||
|
|
|
|
solid_color == mat->state_color[matter_state::Paste] ||
|
|
|
|
solid_color == mat->state_color[matter_state::Pressed])
|
|
|
|
{
|
|
|
|
def_color[matter_state::Solid] = solid_color;
|
|
|
|
def_color[matter_state::Powder] = solid_color;
|
|
|
|
def_color[matter_state::Paste] = solid_color;
|
|
|
|
def_color[matter_state::Pressed] = solid_color;
|
|
|
|
if (solid_color == mat->state_color[matter_state::Liquid] ||
|
|
|
|
solid_color == mat->state_color[matter_state::Gas])
|
|
|
|
{
|
|
|
|
def_color[matter_state::Liquid] = solid_color;
|
|
|
|
def_color[matter_state::Gas] = solid_color;
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_COLOR:ALL:%s]\n", world->raws.language.colors[solid_color]->id.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
else
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_COLOR:ALL_SOLID:%s]\n", world->raws.language.colors[solid_color]->id.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
string solid_name = mat->state_name[matter_state::Solid];
|
|
|
|
string solid_adj = mat->state_adj[matter_state::Solid];
|
|
|
|
if (solid_name == solid_adj)
|
|
|
|
{
|
|
|
|
if (solid_name == mat->state_name[matter_state::Powder] ||
|
|
|
|
solid_name == mat->state_name[matter_state::Paste] ||
|
|
|
|
solid_name == mat->state_name[matter_state::Pressed])
|
|
|
|
{
|
|
|
|
def_name[matter_state::Solid] = solid_name;
|
|
|
|
def_name[matter_state::Powder] = solid_name;
|
|
|
|
def_name[matter_state::Paste] = solid_name;
|
|
|
|
def_name[matter_state::Pressed] = solid_name;
|
|
|
|
def_adj[matter_state::Solid] = solid_name;
|
|
|
|
def_adj[matter_state::Powder] = solid_name;
|
|
|
|
def_adj[matter_state::Paste] = solid_name;
|
|
|
|
def_adj[matter_state::Pressed] = solid_name;
|
|
|
|
|
|
|
|
if (solid_name == mat->state_name[matter_state::Liquid] ||
|
|
|
|
solid_name == mat->state_name[matter_state::Gas])
|
|
|
|
{
|
|
|
|
def_name[matter_state::Liquid] = solid_name;
|
|
|
|
def_name[matter_state::Gas] = solid_name;
|
|
|
|
def_adj[matter_state::Liquid] = solid_name;
|
|
|
|
def_adj[matter_state::Gas] = solid_name;
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_NAME_ADJ:ALL:%s]\n", solid_name.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
else
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_NAME_ADJ:ALL_SOLID:%s]\n", solid_name.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (solid_name == mat->state_name[matter_state::Powder] ||
|
|
|
|
solid_name == mat->state_name[matter_state::Paste] ||
|
|
|
|
solid_name == mat->state_name[matter_state::Pressed])
|
|
|
|
{
|
|
|
|
def_name[matter_state::Solid] = solid_name;
|
|
|
|
def_name[matter_state::Powder] = solid_name;
|
|
|
|
def_name[matter_state::Paste] = solid_name;
|
|
|
|
def_name[matter_state::Pressed] = solid_name;
|
|
|
|
|
|
|
|
if (solid_name == mat->state_name[matter_state::Liquid] ||
|
|
|
|
solid_name == mat->state_name[matter_state::Gas])
|
|
|
|
{
|
|
|
|
def_name[matter_state::Liquid] = solid_name;
|
|
|
|
def_name[matter_state::Gas] = solid_name;
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_NAME:ALL:%s]\n", solid_name.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
else
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_NAME:ALL_SOLID:%s]\n", solid_name.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
if (solid_adj == mat->state_adj[matter_state::Powder] ||
|
|
|
|
solid_adj == mat->state_adj[matter_state::Paste] ||
|
|
|
|
solid_adj == mat->state_adj[matter_state::Pressed])
|
|
|
|
{
|
|
|
|
def_adj[matter_state::Solid] = solid_adj;
|
|
|
|
def_adj[matter_state::Powder] = solid_adj;
|
|
|
|
def_adj[matter_state::Paste] = solid_adj;
|
|
|
|
def_adj[matter_state::Pressed] = solid_adj;
|
|
|
|
|
|
|
|
if (solid_adj == mat->state_adj[matter_state::Liquid] ||
|
|
|
|
solid_adj == mat->state_adj[matter_state::Gas])
|
|
|
|
{
|
|
|
|
def_adj[matter_state::Liquid] = solid_adj;
|
|
|
|
def_adj[matter_state::Gas] = solid_adj;
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_ADJ:ALL:%s]\n", solid_adj.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
else
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_ADJ:ALL_SOLID:%s]\n", solid_adj.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
}
|
2012-03-10 06:25:00 -07:00
|
|
|
const char *state_names[6] = {"SOLID", "LIQUID", "GAS", "SOLID_POWDER", "SOLID_PASTE", "SOLID_PRESSED"};
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
FOR_ENUM_ITEMS(matter_state, state)
|
|
|
|
{
|
|
|
|
if (mat->state_color[state] != -1 && mat->state_color[state] != def_color[state])
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_COLOR:%s:%s]\n", state_names[state], world->raws.language.colors[mat->state_color[state]]->id.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->state_name[state] == mat->state_adj[state])
|
|
|
|
{
|
|
|
|
if (mat->state_name[state].size() && mat->state_name[state] != def_name[state] || mat->state_adj[state].size() && mat->state_adj[state] != def_adj[state])
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_NAME_ADJ:%s:%s]\n", state_names[state], mat->state_name[state].c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mat->state_name[state].size() && mat->state_name[state] != def_name[state])
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_NAME:%s:%s]\n", state_names[state], mat->state_name[state].c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->state_adj[state].size() && mat->state_adj[state] != def_adj[state])
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STATE_ADJ:%s:%s]\n", state_names[state], mat->state_adj[state].c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mat->basic_color[0] != 7 || mat->basic_color[1] != 0)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[BASIC_COLOR:%i:%i]\n", mat->basic_color[0], mat->basic_color[1]);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->build_color[0] != 7 || mat->build_color[1] != 7 || mat->build_color[2] != 0)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[BUILD_COLOR:%i:%i:%i]\n", mat->build_color[0], mat->build_color[1], mat->build_color[2]);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->tile_color[0] != 7 || mat->tile_color[1] != 7 || mat->tile_color[2] != 0)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[TILE_COLOR:%i:%i:%i]\n", mat->tile_color[0], mat->tile_color[1], mat->tile_color[2]);
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
if (mat->tile != 0xdb)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[TILE:%i]\n", mat->tile);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->item_symbol != 0x07)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[ITEM_SYMBOL:%i]\n", mat->item_symbol);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->material_value != 1)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[MATERIAL_VALUE:%i]\n", mat->material_value);
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
if (mat->gem_name1.size())
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[IS_GEM:%s:%s]\n", mat->gem_name1.c_str(), mat->gem_name2.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->stone_name.size())
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[STONE_NAME:%s]\n", mat->stone_name.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
if (mat->heat.spec_heat != 60001)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[SPEC_HEAT:%i]\n", mat->heat.spec_heat);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->heat.heatdam_point != 60001)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[HEATDAM_POINT:%i]\n", mat->heat.heatdam_point);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->heat.colddam_point != 60001)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[COLDDAM_POINT:%i]\n", mat->heat.colddam_point);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->heat.ignite_point != 60001)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[IGNITE_POINT:%i]\n", mat->heat.ignite_point);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->heat.melting_point != 60001)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[MELTING_POINT:%i]\n", mat->heat.melting_point);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->heat.boiling_point != 60001)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[BOILING_POINT:%i]\n", mat->heat.boiling_point);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->heat.mat_fixed_temp != 60001)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[MAT_FIXED_TEMP:%i]\n", mat->heat.mat_fixed_temp);
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
if (mat->solid_density != 0xFBBC7818)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[SOLID_DENSITY:%i]\n", mat->solid_density);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->liquid_density != 0xFBBC7818)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[LIQUID_DENSITY:%i]\n", mat->liquid_density);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->molar_mass != 0xFBBC7818)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[MOLAR_MASS:%i]\n", mat->molar_mass);
|
2012-02-22 13:00:37 -07:00
|
|
|
|
2012-09-14 10:22:49 -06:00
|
|
|
FOR_ENUM_ITEMS(strain_type, strain)
|
|
|
|
{
|
|
|
|
auto name = ENUM_KEY_STR(strain_type,strain);
|
|
|
|
|
|
|
|
if (mat->strength.yield[strain] != 10000)
|
|
|
|
out.print("\t[%s_YIELD:%i]\n", name.c_str(), mat->strength.yield[strain]);
|
|
|
|
if (mat->strength.fracture[strain] != 10000)
|
|
|
|
out.print("\t[%s_FRACTURE:%i]\n", name.c_str(), mat->strength.fracture[strain]);
|
|
|
|
if (mat->strength.strain_at_yield[strain] != 0)
|
|
|
|
out.print("\t[%s_STRAIN_AT_YIELD:%i]\n", name.c_str(), mat->strength.strain_at_yield[strain]);
|
|
|
|
}
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
if (mat->strength.max_edge != 0)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[MAX_EDGE:%i]\n", mat->strength.max_edge);
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->strength.absorption != 0)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[ABSORPTION:%i]\n", mat->strength.absorption);
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
FOR_ENUM_ITEMS(material_flags, i)
|
|
|
|
{
|
|
|
|
if (mat->flags.is_set(i))
|
2012-03-17 02:52:22 -06:00
|
|
|
out.print("\t[%s]\n", ENUM_KEY_STR(material_flags, i).c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mat->extract_storage != item_type::BARREL)
|
2012-03-17 02:52:22 -06:00
|
|
|
out.print("\t[EXTRACT_STORAGE:%s]\n", ENUM_KEY_STR(item_type, mat->extract_storage).c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->butcher_special_type != item_type::NONE || mat->butcher_special_subtype != -1)
|
2012-03-17 02:52:22 -06:00
|
|
|
out.print("\t[BUTCHER_SPECIAL:%s:%s]\n", ENUM_KEY_STR(item_type, mat->butcher_special_type).c_str(), (mat->butcher_special_subtype == -1) ? "NONE" : "?");
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->meat_name[0].size() || mat->meat_name[1].size() || mat->meat_name[2].size())
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[MEAT_NAME:%s:%s:%s]\n", mat->meat_name[0].c_str(), mat->meat_name[1].c_str(), mat->meat_name[2].c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->block_name[0].size() || mat->block_name[1].size())
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[BLOCK_NAME:%s:%s]\n", mat->block_name[0].c_str(), mat->block_name[1].c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
for (int i = 0; i < mat->reaction_class.size(); i++)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[REACTION_CLASS:%s]\n", mat->reaction_class[i]->c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
for (int i = 0; i < mat->reaction_product.id.size(); i++)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[MATERIAL_REACTION_PRODUCT:%s:%s:%s%s%s]\n", mat->reaction_product.id[i]->c_str(), mat->reaction_product.str[0][i]->c_str(), mat->reaction_product.str[1][i]->c_str(), mat->reaction_product.str[2][i]->size() ? ":" : "", mat->reaction_product.str[2][i]->c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
if (mat->hardens_with_water.mat_type != -1)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[HARDENS_WITH_WATER:%s:%s%s%s]\n", mat->hardens_with_water.str[0].c_str(), mat->hardens_with_water.str[1].c_str(), mat->hardens_with_water.str[2].size() ? ":" : "", mat->hardens_with_water.str[2].c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->powder_dye != -1)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[POWDER_DYE:%s]\n", world->raws.language.colors[mat->powder_dye]->id.c_str());
|
2012-02-22 13:00:37 -07:00
|
|
|
if (mat->soap_level != -0)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[SOAP_LEVEL:%o]\n", mat->soap_level);
|
2012-02-22 13:00:37 -07:00
|
|
|
|
|
|
|
for (int i = 0; i < mat->syndrome.size(); i++)
|
2012-03-10 06:25:00 -07:00
|
|
|
out.print("\t[SYNDROME] ...\n");
|
2012-02-22 13:00:37 -07:00
|
|
|
}
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("dumpmats");
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand("dumpmats", "Dump raws for all hardcoded materials", df_dumpmats, false));
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown ( Core * c )
|
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|