Refactor into switch statement
This commit is contained in:
parent
f126e671f9
commit
e1154ad070
@ -1891,8 +1891,22 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result slot clicked
|
switch (a_SlotNum)
|
||||||
if (a_SlotNum == 2)
|
{
|
||||||
|
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;
|
bool bAsync = false;
|
||||||
if (GetSlot(a_SlotNum, a_Player) == nullptr)
|
if (GetSlot(a_SlotNum, a_Player) == nullptr)
|
||||||
@ -2001,19 +2015,6 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
|
|||||||
}
|
}
|
||||||
return;
|
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);
|
Super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user