@@ -676,15 +676,7 @@ void nobBaseWarehouse::FigureLeft(const noFigure& fig)
676676 // Adapt inventory for non-warehouse workers
677677 if (fig.MemberOfWarehouse ())
678678 return ;
679- if (fig.GetJobType () == Job::BoatCarrier)
680- {
681- // Remove helper and boat separately
682- inventory.visual .Remove (Job::Helper);
683- inventory.visual .Remove (GoodType::Boat);
684- } else
685- inventory.visual .Remove (fig.GetJobType ());
686-
687- RemoveArmoredFigurFromVisualInventory (fig);
679+ RemoveFromVisualInventory (fig);
688680
689681 if (fig.GetGOT () == GO_Type::NofTradedonkey)
690682 {
@@ -839,38 +831,9 @@ void nobBaseWarehouse::AddFigure(std::unique_ptr<noFigure> figure, const bool in
839831 // Warenhausarbeiter werden nicht gezählt!
840832 if (!figure->MemberOfWarehouse ())
841833 {
842- // War das ein Boot-Träger?
843- if (figure->GetJobType () == Job::BoatCarrier)
844- {
845- if (increase_visual_counts)
846- {
847- inventory.Add (Job::Helper);
848- inventory.Add (GoodType::Boat);
849- } else
850- {
851- inventory.real .Add (Job::Helper);
852- inventory.real .Add (GoodType::Boat);
853- }
854- } else if (isSoldier (figure->GetJobType ()))
855- {
856- if (increase_visual_counts)
857- {
858- inventory.Add (figure->GetJobType ());
859- if (figure->HasArmor ())
860- inventory.Add (jobEnumToAmoredSoldierEnum (figure->GetJobType ()));
861- } else
862- {
863- inventory.real .Add (figure->GetJobType ());
864- if (figure->HasArmor ())
865- inventory.real .Add (jobEnumToAmoredSoldierEnum (figure->GetJobType ()));
866- }
867- } else
868- {
869- if (increase_visual_counts)
870- inventory.Add (figure->GetJobType ());
871- else
872- inventory.real .Add (figure->GetJobType ());
873- }
834+ AddToRealInventory (*figure);
835+ if (increase_visual_counts)
836+ AddToVisualInventory (*figure);
874837 }
875838
876839 // Check if we were actually waiting for this figure or if it was just added (e.g. builder that constructed it) to
@@ -882,19 +845,45 @@ void nobBaseWarehouse::AddFigure(std::unique_ptr<noFigure> figure, const bool in
882845 GetEvMgr ().AddToKillList (std::move (figure));
883846}
884847
885- void nobBaseWarehouse::RemoveArmoredFigurFromVisualInventory (const noFigure& figure)
848+ void nobBaseWarehouse::RemoveFromVisualInventory (const noFigure& figure)
886849{
887- if (isSoldier (figure.GetJobType ()) && figure.HasArmor ())
850+ const auto job = figure.GetJobType ();
851+ if (job == Job::BoatCarrier)
888852 {
889- RTTR_Assert (inventory.visual [jobEnumToAmoredSoldierEnum (figure.GetJobType ())] > 0 );
890- inventory.visual .Remove (jobEnumToAmoredSoldierEnum (figure.GetJobType ()));
853+ // Remove helper and boat separately
854+ inventory.visual .Remove (Job::Helper);
855+ inventory.visual .Remove (GoodType::Boat);
856+ } else
857+ {
858+ inventory.visual .Remove (job);
859+ if (isSoldier (job) && figure.HasArmor ())
860+ inventory.visual .Remove (jobEnumToAmoredSoldierEnum (job));
891861 }
892862}
893863
894- void nobBaseWarehouse::AddArmoredFigurToVisualInventory (const noFigure& figure)
864+ static void addToInventory (Inventory& inventory, const noFigure& figure)
865+ {
866+ const auto job = figure.GetJobType ();
867+ if (job == Job::BoatCarrier)
868+ {
869+ inventory.Add (Job::Helper);
870+ inventory.Add (GoodType::Boat);
871+ } else
872+ {
873+ inventory.Add (job);
874+ if (isSoldier (job) && figure.HasArmor ())
875+ inventory.Add (jobEnumToAmoredSoldierEnum (job));
876+ }
877+ }
878+
879+ void nobBaseWarehouse::AddToVisualInventory (const noFigure& figure)
880+ {
881+ addToInventory (inventory.visual , figure);
882+ }
883+
884+ void nobBaseWarehouse::AddToRealInventory (const noFigure& figure)
895885{
896- if (isSoldier (figure.GetJobType ()) && figure.HasArmor ())
897- inventory.visual .Add (jobEnumToAmoredSoldierEnum (figure.GetJobType ()));
886+ addToInventory (inventory.real , figure);
898887}
899888
900889void nobBaseWarehouse::FetchWare ()
0 commit comments