1
0

Fixed a bug in crafting recipes - would consume multiple items of asterisked ingredients (FS #205)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@593 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-06-09 18:52:30 +00:00
parent 6bf5fa0d88
commit 429ccb59b5

View File

@ -457,30 +457,37 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
EndY = itrS->y;
}
bool Found = false;
for (int x = StartX; x <= EndX; x++) for (int y = StartY; y <= EndY; y++)
for (int x = StartX; x <= EndX; x++)
{
if (HasMatched[x][y])
for (int y = StartY; y <= EndY; y++)
{
// Already matched some other item
continue;
}
int GridIdx = x + a_GridStride * y;
if (
(a_CraftingGrid[GridIdx].m_ItemID == itrS->m_Item.m_ItemID) &&
(
(itrS->m_Item.m_ItemHealth < 0) || // doesn't want damage comparison
(itrS->m_Item.m_ItemHealth == a_CraftingGrid[GridIdx].m_ItemHealth) // the damage matches
if (HasMatched[x][y])
{
// Already matched some other item
continue;
}
int GridIdx = x + a_GridStride * y;
if (
(a_CraftingGrid[GridIdx].m_ItemID == itrS->m_Item.m_ItemID) &&
(
(itrS->m_Item.m_ItemHealth < 0) || // doesn't want damage comparison
(itrS->m_Item.m_ItemHealth == a_CraftingGrid[GridIdx].m_ItemHealth) // the damage matches
)
)
)
{
HasMatched[x][y] = true;
Found = true;
MatchedSlots.push_back(*itrS);
MatchedSlots.back().x = x;
MatchedSlots.back().y = y;
break;
}
} // for y
if (Found)
{
HasMatched[x][y] = true;
Found = true;
MatchedSlots.push_back(*itrS);
MatchedSlots.back().x = x;
MatchedSlots.back().y = y;
break;
}
} // for y, for x - "anywhere"
} // for x
if (!Found)
{
return NULL;