From 2b9474f171a4c0e1863b52ea585f145ddaabe404 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 4 Apr 2020 15:13:41 +0000 Subject: Remove switch statements from cItemFoodHandler (#4610) * Remove switch statements from cItemFoodHandler * Alpha-sort and add comment * Relocate golden apple handler --- src/Items/ItemCookedFish.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Items/ItemCookedFish.h (limited to 'src/Items/ItemCookedFish.h') diff --git a/src/Items/ItemCookedFish.h b/src/Items/ItemCookedFish.h new file mode 100644 index 000000000..8a819c6f6 --- /dev/null +++ b/src/Items/ItemCookedFish.h @@ -0,0 +1,37 @@ + +#pragma once + +#include "ItemFood.h" + + + + + +class cItemCookedFishHandler : + public cItemFoodHandler +{ + typedef cItemFoodHandler super; + +public: + cItemCookedFishHandler() + : super(E_ITEM_COOKED_FISH, FoodInfo(0, 0)) + { + } + + virtual FoodInfo GetFoodInfo(const cItem * a_Item) override + { + static const FoodInfo CookedFishInfos[] = + { + FoodInfo(5, 6.0), // Cooked fish + FoodInfo(6, 9.6), // Cooked salmon + }; + + if (a_Item->m_ItemDamage >= static_cast(ARRAYCOUNT(CookedFishInfos))) + { + LOGWARNING("Unknown cooked fish type '%d'", a_Item->m_ItemDamage); + return FoodInfo(0, 0); + } + return CookedFishInfos[a_Item->m_ItemDamage]; + } + +}; -- cgit v1.2.3