Skip to content

Commit fd1dec1

Browse files
FlamefireFlow86
authored andcommitted
Factor out check if a GOT is a storehouse/nobBaseWarehouse
1 parent 95fcdb4 commit fd1dec1

4 files changed

Lines changed: 21 additions & 25 deletions

File tree

libs/s25main/Ware.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -164,9 +164,8 @@ void Ware::GoalDestroyed()
164164
RTTR_Assert(location);
165165
RTTR_Assert(location->GetPlayer() < MAX_PLAYERS);
166166

167-
// Wird sie gerade aus einem Lagerhaus rausgetragen?
168-
if(location->GetGOT() == GO_Type::NobStorehouse || location->GetGOT() == GO_Type::NobHarborbuilding
169-
|| location->GetGOT() == GO_Type::NobHq)
167+
// Currently carried out of a warehouse?
168+
if(nobBaseWarehouse::isStorehouseGOT(location->GetGOT()))
170169
{
171170
if(location != goal)
172171
{
@@ -199,11 +198,10 @@ void Ware::GoalDestroyed()
199198
if(goal != location)
200199
{
201200
// find a warehouse for us (if we are entering a warehouse already set this as new goal (should only
202-
// happen if its a harbor for shipping as the building wasnt our goal))
203-
if(location->GetGOT() == GO_Type::NobStorehouse || location->GetGOT() == GO_Type::NobHarborbuilding
204-
|| location->GetGOT()
205-
== GO_Type::NobHq) // currently carried into a warehouse? -> add ware (pathfinding
206-
// will not return this wh because of path lengths 0)
201+
// happen if its a harbor for shipping as the building wasn't our goal))
202+
if(nobBaseWarehouse::isStorehouseGOT(
203+
location->GetGOT())) // currently carried into a warehouse? -> add ware (pathfinding
204+
// will not return this wh because of path lengths 0)
207205
{
208206
if(location->GetGOT() != GO_Type::NobHarborbuilding)
209207
LOG.write("WARNING: Ware::GoalDestroyed() -- ware is currently being carried into warehouse or "

libs/s25main/buildings/nobBaseWarehouse.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2024 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -44,6 +44,12 @@ struct InventorySettings : GoodsAndPeopleArray<InventorySetting>
4444
/// Change events: 1=InventorySettings
4545
class nobBaseWarehouse : public nobBaseMilitary, public DataChangedObservable
4646
{
47+
public:
48+
static constexpr bool isStorehouseGOT(const GO_Type got)
49+
{
50+
return got == GO_Type::NobStorehouse || got == GO_Type::NobHarborbuilding || got == GO_Type::NobHq;
51+
}
52+
4753
protected:
4854
// Liste von Waren, die noch rausgebracht werden müssen, was im Moment aber nicht möglich ist,
4955
// weil die Flagge voll ist vor dem Lagerhaus

libs/s25main/figures/noFigure.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ noFigure::noFigure(const Job job, const MapPoint pos, const unsigned char player
4848
rs_pos(0), rs_dir(false), on_ship(false), goal_(goal), waiting_for_free_node(false), wander_way(0),
4949
wander_tryings(0), flagPos_(MapPoint::Invalid()), flag_obj_id(0), burned_wh_id(0xFFFFFFFF), last_id(0xFFFFFFFF)
5050
{
51-
// Haben wir ein Ziel?
52-
// Gehen wir in ein Lagerhaus? Dann dürfen wir da nicht unsere Arbeit ausführen, sondern
53-
// gehen quasi nach Hause von Anfang an aus
54-
if(goal
55-
&& (goal->GetGOT() == GO_Type::NobHarborbuilding || goal->GetGOT() == GO_Type::NobStorehouse
56-
|| goal->GetGOT() == GO_Type::NobHq))
51+
// If the goal is a storehouse we won't work there but go to the new home
52+
if(goal && nobBaseWarehouse::isStorehouseGOT(goal->GetGOT()))
5753
fs = FigureState::GoHome;
5854
}
5955

@@ -418,10 +414,7 @@ void noFigure::GoHome(noRoadNode* goal)
418414
// Wenn wir cur_rs == 0, dann hängen wir wahrscheinlich noch im Lagerhaus in der Warteschlange
419415
if(cur_rs == nullptr)
420416
{
421-
RTTR_Assert(world->GetNO(pos)->GetGOT() == GO_Type::NobHq || //-V807
422-
world->GetNO(pos)->GetGOT() == GO_Type::NobStorehouse
423-
|| world->GetNO(pos)->GetGOT() == GO_Type::NobHarborbuilding);
424-
417+
RTTR_Assert(nobBaseWarehouse::isStorehouseGOT(world->GetNO(pos)->GetGOT()));
425418
goal_ = nullptr;
426419
world->GetSpecObj<nobBaseWarehouse>(pos)->CancelFigure(this);
427420
return;

libs/s25main/ingameWindows/iwBaseWarehouse.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22
//
33
// SPDX-License-Identifier: GPL-2.0-or-later
44

@@ -80,11 +80,10 @@ iwBaseWarehouse::iwBaseWarehouse(GameWorldView& gwv, GameCommandFactory& gcFacto
8080

8181
UpdateOverlays();
8282

83-
// Lagerhaus oder Hafengebäude?
84-
if(wh->GetGOT() == GO_Type::NobStorehouse || wh->GetGOT() == GO_Type::NobHarborbuilding)
83+
// Add demolish button if not HQ
84+
if(wh->GetGOT() != GO_Type::NobHq)
8585
{
86-
// Abbrennbutton hinzufügen
87-
// "Blättern" in Bretter stauchen und verschieben
86+
// Make paginate button smaller and move to make space for demolish button
8887
GetCtrl<ctrlButton>(ID_PAGINATE)->SetWidth(32);
8988
GetCtrl<ctrlButton>(ID_PAGINATE)->SetPos(DrawPoint(86, GetFullSize().y - 47));
9089

0 commit comments

Comments
 (0)