was causing crashes.
Get rid of drop_blood_potions_stack() and pick_up_blood_potions_stack(), replace with the more general merge_blood_potion_stacks() and merge_item_stacks().
When creating blood potions via debug command you can now specify how many turns away from coagulating/rotting it should be.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8471 c06c8d41-db1a-0410-9941-cceddc491573
KEWUUIWZCM2VE6WZX4BC4DXGL7LBAWGLUPCPA4KCBCUL5ZQLECBAC
67DLBYNHSKSNBCJR62ORIRTOIM3LKR62HZU4SOJRGRFGYOQY3SFAC
EPA5CK2JX4C7FXYCCA2VX3JPLUEYQYYQJYVA37AFNFBIL7JAAGAAC
JM5VDKPDSBVFW37RJRECYZ7AQUTHTFSGMZDUTU3F66U4QO6ZDMTQC
N6F35CMZALDQR4LD3HP2JQZGQ4JNBATAICO7ZUCF5M2ZW5E4QYVAC
S7Y7E2KDAFMTLDIXUTR673SYL5N35VXYGLRU67L42WHVYG5SEPBQC
QS3ZRS3E6KL3YJHPKYEWCWJYRBJSXD5OOYF6Y25HZVECGPJRDB5QC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
QCUMH3C7GXV7ZW444WT5SFAXQOJKJSE2YCQCEHMRYXCWF4QI7UMAC
TGJZXTUIAKCFZQJ54ZQEBGFBVZSJCAX6AWDRSH3TP7UJRLGUM5SAC
Q3XHNSHW6FI4JCXSEABATRFBJPMCF7PXNG2K6ZQTRRPVMIZFHUBQC
VXSORUQOM2VZA4CAZDC6KPAY373NQIN3UT7CXQXTRCYXO2WM62DAC
TO43FWKHNIA5MVDOFXYHQODTLBQYEZKX5UIUGID57436UF7G2EXQC
SIDH2P7NBIG5KEOE27XHD3ZT2NQ2OJZFN6VZXWNWYFFY5YVXSSVQC
2O3C3MTT2ZBYIFGPJ4MF5R4AXBYUHOEN62KAUWFWF6JWHIIVLRNQC
RQR4PTMGQLTRWLYRU3KXIIDGND7FBORESJWMWFVD3WYU5SISZXAAC
34C4U6EQWERY75GZJKUCM5KVGU2OUICETS5LGZF6RMKMZT4R5SQAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
M2HMYLYYXSP5XGX6MCI77IT6UW5K4YSEUJWHPQPYXVSW5L36BJ2AC
HNPSSHGZFQ3E2I6X6VTKZ3WBBM2G25P2D7SIL2SZYKV2CCEA2ADAC
L254F6ZIU2HWGLFFGPIORTN4C3TDQ3E5JZ7Z7GQA5AEDIKL6PKDAC
void drop_blood_potions_stack( item_def &stack, int quant,
const coord_def& p = you.pos() );
void pick_up_blood_potions_stack( item_def &stack, int quant );
void merge_blood_potion_stacks(item_def &source, item_def &dest, int quant);
// Now that coagulating is necessary, check square for !coagulated blood.
ASSERT(blood.pos.x >= 0 && blood.pos.y >= 0);
for (int o = igrd[blood.pos.x][blood.pos.y]; o != NON_ITEM; o = mitm[o].link)
if (!held_by_monster(blood))
if (mitm[o].base_type == OBJ_POTIONS
&& mitm[o].sub_type == POT_BLOOD_COAGULATED)
// Now that coagulating is necessary, check square for
// !coagulated blood.
ASSERT(blood.pos.x >= 0 && blood.pos.y >= 0);
for (int o = igrd[blood.pos.x][blood.pos.y]; o != NON_ITEM;
o = mitm[o].link)
// Merge with existing stack.
CrawlHashTable &props2 = mitm[o].props;
if (!props2.exists("timer"))
init_stack_blood_potions(mitm[o], mitm[o].special);
if (mitm[o].base_type == OBJ_POTIONS
&& mitm[o].sub_type == POT_BLOOD_COAGULATED)
{
// Merge with existing stack.
CrawlHashTable &props2 = mitm[o].props;
if (!props2.exists("timer"))
init_stack_blood_potions(mitm[o], mitm[o].special);
ASSERT(props2.exists("timer"));
CrawlVector &timer2 = props2["timer"].get_vector();
ASSERT(timer2.size() == mitm[o].quantity);
ASSERT(props2.exists("timer"));
CrawlVector &timer2 = props2["timer"].get_vector();
ASSERT(timer2.size() == mitm[o].quantity);
// Update timer -> push(pop).
long val;
while (!age_timer.empty())
{
val = age_timer[age_timer.size() - 1];
age_timer.pop_back();
timer2.push_back(val);
// Update timer -> push(pop).
long val;
while (!age_timer.empty())
{
val = age_timer[age_timer.size() - 1];
age_timer.pop_back();
timer2.push_back(val);
}
_long_sort(timer2);
inc_mitm_item_quantity(o, coag_count);
ASSERT(timer2.size() == mitm[o].quantity);
dec_mitm_item_quantity(obj, rot_count + coag_count);
return;
_long_sort(timer2);
inc_mitm_item_quantity(o, coag_count);
ASSERT(timer2.size() == mitm[o].quantity);
dec_mitm_item_quantity(obj, rot_count + coag_count);
return;
// Called from copy_item_to_grid.
// NOTE: Quantities are set afterwards, so don't ASSERT for those.
void drop_blood_potions_stack(item_def &stack, int quant, const coord_def& p)
void merge_blood_potion_stacks(item_def &source, item_def &dest, int quant)
// First check whether we can merge with an existing stack on the floor.
int o = igrd[p.x][p.y];
while (o != NON_ITEM)
// Update timer -> push(pop).
for (int i = 0; i < quant; i++)
if (mitm[o].base_type == OBJ_POTIONS
&& mitm[o].sub_type == stack.sub_type)
{
CrawlHashTable &props2 = mitm[o].props;
if (!props2.exists("timer"))
init_stack_blood_potions(mitm[o], mitm[o].special);
ASSERT(props2.exists("timer"));
CrawlVector &timer2 = props2["timer"].get_vector();
// Update timer -> push(pop).
for (int i = 0; i < quant; i++)
{
timer2.push_back(timer[timer.size() - 1].get_long());
timer.pop_back();
}
// Re-sort timer.
_long_sort(timer2);
return;
}
o = mitm[o].link;
}
// If we got here nothing was found.
// Stuff could have been destroyed or offered, either case we'll
// have to reduce the timer vector anyway.
while (!timer.empty() && quant-- > 0)
timer2.push_back(timer[timer.size() - 1].get_long());
}
// Called from move_item_to_player.
// Quantities are set afterwards, so don't ASSERT for those.
void pick_up_blood_potions_stack(item_def &stack, int quant)
{
ASSERT(quant > 0 && quant <= stack.quantity);
if (!is_valid_item(stack))
return;
ASSERT(is_blood_potion(stack));
}
CrawlHashTable &props = stack.props;
if (!props.exists("timer"))
init_stack_blood_potions(stack, stack.special);
ASSERT(props.exists("timer"));
CrawlVector &timer = props["timer"].get_vector();
ASSERT(!timer.empty());
// First check whether we can merge with an existing stack in inventory.
for (int m = 0; m < ENDOFPACK; m++)
{
if (!is_valid_item(you.inv[m]))
continue;
if (you.inv[m].base_type == OBJ_POTIONS
&& you.inv[m].sub_type == stack.sub_type)
{
CrawlHashTable &props2 = you.inv[m].props;
if (!props2.exists("timer"))
init_stack_blood_potions(you.inv[m], you.inv[m].special);
ASSERT(props2.exists("timer"));
CrawlVector &timer2 = props2["timer"].get_vector();
// Update timer -> push(pop).
for (int i = 0; i < quant; i++)
{
timer2.push_back(timer[timer.size() - 1].get_long());
timer.pop_back();
}
// Re-sort timer.
_long_sort(timer2);
return;
}
}
// If we got here nothing was found. Huh?
// Re-sort timer.
_long_sort(timer2);
if (is_blood_potion(item))
{
item_def help = item;
drop_blood_potions_stack(help, quant_drop, p);
}
init_stack_blood_potions(*item);
{
const char* prompt;
if (item->sub_type == POT_BLOOD)
prompt = "# turns away from coagulation? "
"[ENTER for fully fresh] ";
else
prompt = "# turns away from rotting? "
"[ENTER for fully fresh] ";
int age =
_debug_prompt_for_int(prompt, false);
if (age <= 0)
age = -1;
else if (item->sub_type == POT_BLOOD)
age += 500;
init_stack_blood_potions(*item, age);
}