Try blocking any use of stockpiles for squad stuff in fix-armory.

develop
Alexander Gavrilov 2012-11-10 18:06:41 +04:00
parent 56ef33ea0e
commit f86371cfc3
1 changed files with 14 additions and 13 deletions

@ -132,6 +132,9 @@ DFhackCExport command_result plugin_shutdown (color_ostream &out)
* grace period during which the items can be instantly picked up again. * grace period during which the items can be instantly picked up again.
*/ */
// Completely block the use of stockpiles
#define NO_STOCKPILES
// Check if the item is assigned to any use controlled by the military tab // Check if the item is assigned to any use controlled by the military tab
static bool is_assigned_item(df::item *item) static bool is_assigned_item(df::item *item)
{ {
@ -143,19 +146,6 @@ static bool is_assigned_item(df::item *item)
if (idx < 0) if (idx < 0)
return false; return false;
// Exclude weapons used by miners, wood cutters etc
switch (type) {
case item_type::WEAPON:
// the game code also checks this for ammo, funnily enough
// maybe it's not just for weapons?..
if (binsearch_index(ui->equipment.work_weapons, item->id) >= 0)
return false;
break;
default:
break;
}
return true; return true;
} }
@ -328,6 +318,16 @@ template<class Item> struct armory_hook : Item {
*/ */
DEFINE_VMETHOD_INTERPOSE(bool, isCollected, ()) DEFINE_VMETHOD_INTERPOSE(bool, isCollected, ())
{ {
#ifdef NO_STOCKPILES
/*
* Completely block any items assigned to a squad from being stored
* in stockpiles. The reason is that I still observe haulers running
* around with bins to pick them up for some reason. There could be
* some unaccounted race conditions involved.
*/
if (is_assigned_item(this))
return false;
#else
// Block stockpiling of items in the armory. // Block stockpiling of items in the armory.
if (is_in_armory(this)) if (is_in_armory(this))
return false; return false;
@ -354,6 +354,7 @@ template<class Item> struct armory_hook : Item {
return false; return false;
} }
} }
#endif
// Call the original vmethod // Call the original vmethod
return INTERPOSE_NEXT(isCollected)(); return INTERPOSE_NEXT(isCollected)();