diff --git a/Main/Include/craft.h b/Main/Include/craft.h index 61b9a07f7..7fc2f6269 100644 --- a/Main/Include/craft.h +++ b/Main/Include/craft.h @@ -16,6 +16,11 @@ #include #include +static constexpr int ingredient_slot_main = 0; +static constexpr int ingredient_slot_second = 1; +static constexpr int ingredient_slot_thread = 2; +static constexpr int ingredient_slots = 3; + class craft; class humanoid; class item; @@ -172,9 +177,8 @@ class recipedata { int iMinTurns; bool bFailedTerminateCancel; bool bFailedSuspend; - - undoremains urMain; - undoremains urSecond; + + undoremains urRemains[ingredient_slots]; /******************************************* * save REQUIRED fields!!! diff --git a/Main/Source/cmdcraft.cpp b/Main/Source/cmdcraft.cpp index b1c6d27a6..5a5b0d5a0 100644 --- a/Main/Source/cmdcraft.cpp +++ b/Main/Source/cmdcraft.cpp @@ -689,7 +689,7 @@ struct ci{ //create item info/helper/data/config/param bool bMustBeTailorable=false; bool bMixRemainingLump=true; bool bAddEquippedItemsToChoiceList=false; - bool bIsMainIngredient=true; //false if it is secondary ingredient + int iIngredientSlot=ingredient_slot_main; }; struct recipe{ festring action; @@ -1180,9 +1180,9 @@ struct recipe{ item* lumpMixed=NULL; if(CI.bMixRemainingLump) lumpMixed=lumpMix(vi,lumpR,rpd.bSpendCurrentTurn); - undoremains* pur = CI.bIsMainIngredient ? &rpd.urMain : &rpd.urSecond; + undoremains* pur = &rpd.urRemains[CI.iIngredientSlot]; if(pur->ulUndoRemainsIngredientID!=0) - ABORT("craft remains undo for %s ingredient was already set!",(CI.bIsMainIngredient?"MAIN":"SECOND")); + ABORT("craft remains undo for ingredient %i was already set!", CI.iIngredientSlot + 1); pur->ulUndoRemainsIngredientID = ToUse[i]->GetID(); pur->ulUndoRemainsLumpID = lumpMixed!=NULL ? lumpMixed->GetID() : lumpR->GetID(); pur->lUndoRemainsVolume = lRemainingVol; @@ -2509,7 +2509,7 @@ struct srpForgeItem : public recipe{ ci CIS; CIS.bMainMaterRemainsBecomeLump=true; - CIS.bIsMainIngredient=false; + CIS.iIngredientSlot=ingredient_slot_second; // some material constraints/limitations if(dynamic_cast(itSpawn)!=NULL){ @@ -2658,7 +2658,7 @@ struct srpForgeItem : public recipe{ CISW.bMainMaterRemainsBecomeLump=true; CISW.bMixRemainingLump = false; CISW.iReqMatCfgMain=SPIDER_SILK; - CISW.bIsMainIngredient = false; + CISW.iIngredientSlot=ingredient_slot_thread; if(!choseIngredients(cfestring("as sewing material"),lVolSewing,rpd,iSCfg,CISW)){ //TODO instead of should be with new graphics ADD_MESSAGE("You don't have enough sewing thread..."); rpd.SetAlreadyExplained(); @@ -3142,11 +3142,8 @@ void craftcore::UndoRemainsIfNeeded(recipedata& rpd) static undoremains* pur; static item *itIngredient, *itLump; static material* matM; - for(int i=0;i<2;i++){ - switch(i){ - case 0: pur=&rpd.urMain;break; - case 1: pur=&rpd.urSecond;break; - } + for(int i=0;iulUndoRemainsIngredientID,pur->ulUndoRemainsLumpID,pur->lUndoRemainsVolume,rpd.dbgInfo().CStr()); if(pur->lUndoRemainsVolume==0)