You can just check the return value of the DoRefine function:
Replace this:
Code:
if (ch->GetQuestFlag("deviltower_zone.can_refine"))
{
ch->DoRefine(item, true);
ch->SetQuestFlag("deviltower_zone.can_refine", 0);
}
with this:
Code:
if (ch->GetQuestFlag("deviltower_zone.can_refine"))
{
if (ch->DoRefine(item, true))
{
ch->SetQuestFlag("deviltower_zone.can_refine", 0);
}
}
I just did a real quick look but the DoRefine function returns false if the requirements to do the upgrade are not fulfilled by the player so this should be enough.
Regards