Modify DFHack to handle new produce() prototype. Major thanks to lethosor, and ragundo for their help in this

Signed-off-by: Michael Casadevall <mcasadevall@ubuntu.com>
develop
Michael Casadevall 2016-06-13 16:57:45 -04:00
parent bcefb0205a
commit a03b32846a
5 changed files with 13 additions and 11 deletions

@ -1375,8 +1375,9 @@ int32_t Items::createItem(df::item_type item_type, int16_t item_subtype, int16_t
df::enums::game_type::game_type type = *df::global::gametype;
prod->produce(unit, &out_products, &out_items, &in_reag, &in_items, 1, job_skill::NONE,
df::historical_entity::find(unit->civ_id),
((type == df::enums::game_type::DWARF_MAIN) || (type == df::enums::game_type::DWARF_RECLAIM)) ? df::world_site::find(df::global::ui->site_id) : NULL);
df::historical_entity::find(unit->civ_id), 0,
((type == df::enums::game_type::DWARF_MAIN) || (type == df::enums::game_type::DWARF_RECLAIM)) ? df::world_site::find(df::global::ui->site_id) : NULL,
0);
if ( out_items.size() != 1 )
return -1;

@ -249,7 +249,7 @@ struct product_hook : improvement_product {
std::vector<df::reaction_reagent*> *in_reag,
std::vector<df::item*> *in_items,
int32_t quantity, df::job_skill skill,
df::historical_entity *entity, df::world_site *site)
df::historical_entity *entity, int32_t unk, df::world_site *site, void* unk2)
) {
if (auto product = products[this])
{
@ -295,7 +295,7 @@ struct product_hook : improvement_product {
return;
}
INTERPOSE_NEXT(produce)(unit, out_products, out_items, in_reag, in_items, quantity, skill, entity, site);
INTERPOSE_NEXT(produce)(unit, out_products, out_items, in_reag, in_items, quantity, skill, entity, unk, site, unk2);
}
};

@ -86,8 +86,8 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_it
building = df::building::find(dest_building);
prod->produce(unit, &out_products, &out_items, &in_reag, &in_items, 1, job_skill::NONE,
df::historical_entity::find(unit->civ_id),
(World::isFortressMode()) ? df::world_site::find(ui->site_id) : NULL);
df::historical_entity::find(unit->civ_id), 0,
(World::isFortressMode()) ? df::world_site::find(ui->site_id) : NULL, 0);
if (!out_items.size())
return false;
// if we asked to make shoes and we got twice as many as we asked, then we're okay

@ -257,8 +257,8 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
vector<df::reaction_reagent*> in_reag;
vector<df::item*> in_items;
prod->produce(firstInvader, &out_products, &out_items, &in_reag, &in_items, 1, df::job_skill::NONE,
df::historical_entity::find(firstInvader->civ_id),
df::world_site::find(df::global::ui->site_id));
df::historical_entity::find(firstInvader->civ_id), 0,
df::world_site::find(df::global::ui->site_id), 0);
if ( out_items.size() != 1 ) {
out.print("%s, %d: wrong size: %d.\n", __FILE__, __LINE__, out_items.size());

@ -298,12 +298,12 @@ struct product_hook : item_product {
std::vector<df::reaction_reagent*> *in_reag,
std::vector<df::item*> *in_items,
int32_t quantity, df::job_skill skill,
df::historical_entity *entity, df::world_site *site)
df::historical_entity *entity, int32_t unk, df::world_site *site, void* unk2)
) {
color_ostream_proxy out(Core::getInstance().getConsole());
auto product = products[this];
if ( !product ) {
INTERPOSE_NEXT(produce)(unit, out_products, out_items, in_reag, in_items, quantity, skill, entity, site);
INTERPOSE_NEXT(produce)(unit, out_products, out_items, in_reag, in_items, quantity, skill, entity, unk, site, unk2);
return;
}
df::reaction* this_reaction=product->react;
@ -314,7 +314,8 @@ struct product_hook : item_product {
return;
size_t out_item_count = out_items->size();
INTERPOSE_NEXT(produce)(unit, out_products, out_items, in_reag, in_items, quantity, skill, entity, site);
INTERPOSE_NEXT(produce)(unit, out_products, out_items, in_reag, in_items, quantity, skill, entity, unk, site, unk2);
if ( out_items->size() == out_item_count )
return;
//if it produced something, call the scripts