Refactor into switch statement

This commit is contained in:
Kingsley Collie 2022-01-11 22:03:10 +00:00 committed by Alexander Harkness
parent f126e671f9
commit e1154ad070

View File

@ -1891,8 +1891,22 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
return;
}
// Result slot clicked
if (a_SlotNum == 2)
switch (a_SlotNum)
{
case 1: // Fuel slot clicked
{
cItem & DraggingItem = a_Player.GetDraggingItem();
cFurnaceRecipe * FurnaceRecipes = cRoot::Get()->GetFurnaceRecipe();
// Do not allow non-fuels to be placed in the fuel slot:
if (!DraggingItem.IsEmpty() && !FurnaceRecipes->IsFuel(DraggingItem) && (a_ClickAction != caShiftLeftClick) && (a_ClickAction != caShiftRightClick))
{
LOGD("Rejecting non fuel item being placed in fuel slot.");
return;
}
break;
}
case 2: // Result slot clicked
{
bool bAsync = false;
if (GetSlot(a_SlotNum, a_Player) == nullptr)
@ -2001,19 +2015,6 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
}
return;
}
// Fuel slot clicked
if (a_SlotNum == 1)
{
cItem & DraggingItem = a_Player.GetDraggingItem();
cFurnaceRecipe * FurnaceRecipes = cRoot::Get()->GetFurnaceRecipe();
// Do not allow non-fuels to be placed in the fuel slot:
if (!DraggingItem.IsEmpty() && !FurnaceRecipes->IsFuel(DraggingItem) && (a_ClickAction != caShiftLeftClick) && (a_ClickAction != caShiftRightClick))
{
LOGD("Rejecting non fuel item being placed in fuel slot.");
return;
}
}
Super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);