Skip to content

Commit 23fad66

Browse files
FlamefireFlow86
authored andcommitted
Remove unused overload for figures with warehouse goal
It is never used and can cause confusion. `nofPassiveWorker` should be used for transfers to a warehouse.
1 parent 06b69de commit 23fad66

9 files changed

Lines changed: 15 additions & 51 deletions

File tree

libs/s25main/factories/JobFactory.cpp

Lines changed: 7 additions & 18 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

@@ -95,34 +95,23 @@ std::unique_ptr<noFigure> JobFactory::CreateJob(const Job job_id, const MapPoint
9595
RTTR_Assert(dynamic_cast<nobUsual*>(goal));
9696
return std::make_unique<nofBaker>(pt, player, static_cast<nobUsual*>(goal));
9797
case Job::Helper:
98-
// Wenn goal = 0 oder Lagerhaus, dann Auslagern anscheinend und mann kann irgendeinen Typ nehmen
99-
if(!goal)
100-
return std::make_unique<nofWellguy>(pt, player, static_cast<nobUsual*>(nullptr));
101-
else if(goal->GetGOT() == GO_Type::NobStorehouse || goal->GetGOT() == GO_Type::NobHarborbuilding
102-
|| goal->GetGOT() == GO_Type::NobHq)
103-
return std::make_unique<nofWellguy>(pt, player, static_cast<nobBaseWarehouse*>(goal));
104-
else if(goal->GetGOT() == GO_Type::NobUsual)
98+
if(goal && goal->GetGOT() == GO_Type::NobUsual)
10599
{
100+
RTTR_Assert(dynamic_cast<nobUsual*>(goal));
106101
auto* goalBld = static_cast<nobUsual*>(goal);
107102
if(goalBld->GetBuildingType() == BuildingType::Well)
108103
return std::make_unique<nofWellguy>(pt, player, goalBld);
109104
else if(goalBld->GetBuildingType() == BuildingType::Catapult)
110105
return std::make_unique<nofCatapultMan>(pt, player, goalBld);
111106
}
112-
throw std::runtime_error("Invalid goal type: " + helpers::toString(goal->GetGOT()) + " for job "
113-
+ helpers::toString(job_id));
107+
throw std::runtime_error("Invalid goal type: " + (goal ? helpers::toString(goal->GetGOT()) : "NULL")
108+
+ " for job " + helpers::toString(job_id));
114109
case Job::Geologist:
115110
RTTR_Assert(dynamic_cast<noFlag*>(goal));
116111
return std::make_unique<nofGeologist>(pt, player, static_cast<noFlag*>(goal));
117112
case Job::Scout:
118-
// Im Spähturm arbeitet ein anderer Späher-Typ
119-
// Wenn goal = 0 oder Lagerhaus, dann Auslagern anscheinend und mann kann irgendeinen Typ nehmen
120-
if(!goal)
121-
return std::make_unique<nofScout_LookoutTower>(pt, player, static_cast<nobUsual*>(nullptr));
122-
else if(goal->GetGOT() == GO_Type::NobHarborbuilding || goal->GetGOT() == GO_Type::NobStorehouse
123-
|| goal->GetGOT() == GO_Type::NobHq)
124-
return std::make_unique<nofPassiveWorker>(Job::Scout, pt, player, goal);
125-
else if(goal->GetGOT() == GO_Type::NobUsual) // Spähturm / Lagerhaus?
113+
// Different scout for lookout towers and free scouts
114+
if(goal->GetGOT() == GO_Type::NobUsual)
126115
{
127116
RTTR_Assert(dynamic_cast<nobUsual*>(goal));
128117
return std::make_unique<nofScout_LookoutTower>(pt, player, static_cast<nobUsual*>(goal));

libs/s25main/figures/nofBuildingWorker.cpp

Lines changed: 1 addition & 6 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

@@ -25,11 +25,6 @@ nofBuildingWorker::nofBuildingWorker(const Job job, const MapPoint pos, const un
2525
workplace))); // Assume we have at least a GameObject and check if it is a valid workplace
2626
}
2727

28-
nofBuildingWorker::nofBuildingWorker(const Job job, const MapPoint pos, const unsigned char player,
29-
nobBaseWarehouse* goalWh)
30-
: noFigure(job, pos, player, goalWh), state(State::FigureWork), workplace(nullptr), was_sounding(false)
31-
{}
32-
3328
void nofBuildingWorker::Serialize(SerializedGameData& sgd) const
3429
{
3530
noFigure::Serialize(sgd);

libs/s25main/figures/nofBuildingWorker.h

Lines changed: 1 addition & 2 deletions
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

@@ -92,7 +92,6 @@ class nofBuildingWorker : public noFigure
9292
State GetState() const { return state; }
9393

9494
nofBuildingWorker(Job job, MapPoint pos, unsigned char player, nobUsual* workplace);
95-
nofBuildingWorker(Job job, MapPoint pos, unsigned char player, nobBaseWarehouse* goalWh);
9695
nofBuildingWorker(SerializedGameData& sgd, unsigned obj_id);
9796
nofBuildingWorker(const nofBuildingWorker&) = delete;
9897

libs/s25main/figures/nofScout_LookoutTower.cpp

Lines changed: 1 addition & 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

@@ -15,10 +15,6 @@ nofScout_LookoutTower::nofScout_LookoutTower(const MapPoint pos, const unsigned
1515
: nofBuildingWorker(Job::Scout, pos, player, workplace)
1616
{}
1717

18-
nofScout_LookoutTower::nofScout_LookoutTower(const MapPoint pos, const unsigned char player, nobBaseWarehouse* goalWh)
19-
: nofBuildingWorker(Job::Scout, pos, player, goalWh)
20-
{}
21-
2218
nofScout_LookoutTower::nofScout_LookoutTower(SerializedGameData& sgd, const unsigned obj_id)
2319
: nofBuildingWorker(sgd, obj_id)
2420
{}

libs/s25main/figures/nofScout_LookoutTower.h

Lines changed: 1 addition & 2 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

@@ -28,7 +28,6 @@ class nofScout_LookoutTower : public nofBuildingWorker
2828

2929
public:
3030
nofScout_LookoutTower(MapPoint pos, unsigned char player, nobUsual* workplace);
31-
nofScout_LookoutTower(MapPoint pos, unsigned char player, nobBaseWarehouse* goalWh);
3231
nofScout_LookoutTower(SerializedGameData& sgd, unsigned obj_id);
3332

3433
GO_Type GetGOT() const final { return GO_Type::NofScoutLookouttower; }

libs/s25main/figures/nofWellguy.cpp

Lines changed: 1 addition & 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

@@ -19,10 +19,6 @@ nofWellguy::nofWellguy(const MapPoint pos, const unsigned char player, nobUsual*
1919
: nofWorkman(Job::Helper, pos, player, workplace)
2020
{}
2121

22-
nofWellguy::nofWellguy(const MapPoint pos, const unsigned char player, nobBaseWarehouse* goalWh)
23-
: nofWorkman(Job::Helper, pos, player, goalWh)
24-
{}
25-
2622
nofWellguy::nofWellguy(SerializedGameData& sgd, const unsigned obj_id) : nofWorkman(sgd, obj_id) {}
2723

2824
void nofWellguy::DrawWorking(DrawPoint drawPt)

libs/s25main/figures/nofWellguy.h

Lines changed: 1 addition & 4 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

@@ -26,10 +26,7 @@ class nofWellguy : public nofWorkman
2626
bool StartWorking() override;
2727

2828
public:
29-
/// Ctor for sending the figure to its workplace
3029
nofWellguy(MapPoint pos, unsigned char player, nobUsual* workplace);
31-
/// Ctor for sending the figure to a warehouse (harbor, HQ,...)
32-
nofWellguy(MapPoint pos, unsigned char player, nobBaseWarehouse* goalWh);
3330
nofWellguy(SerializedGameData& sgd, unsigned obj_id);
3431

3532
GO_Type GetGOT() const final { return GO_Type::NofWellguy; }

libs/s25main/figures/nofWorkman.cpp

Lines changed: 1 addition & 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

@@ -14,10 +14,6 @@ nofWorkman::nofWorkman(const Job job, const MapPoint pos, const unsigned char pl
1414
: nofBuildingWorker(job, pos, player, workplace)
1515
{}
1616

17-
nofWorkman::nofWorkman(const Job job, const MapPoint pos, const unsigned char player, nobBaseWarehouse* goalWh)
18-
: nofBuildingWorker(job, pos, player, goalWh)
19-
{}
20-
2117
nofWorkman::nofWorkman(SerializedGameData& sgd, const unsigned obj_id) : nofBuildingWorker(sgd, obj_id) {}
2218

2319
void nofWorkman::HandleDerivedEvent(const unsigned /*id*/)

libs/s25main/figures/nofWorkman.h

Lines changed: 1 addition & 4 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

@@ -40,10 +40,7 @@ class nofWorkman : public nofBuildingWorker
4040
MapPoint FindPointWithResource(ResourceType type) const;
4141

4242
public:
43-
/// Going to workplace
4443
nofWorkman(Job job, MapPoint pos, unsigned char player, nobUsual* workplace);
45-
/// Going to warehouse
46-
nofWorkman(Job job, MapPoint pos, unsigned char player, nobBaseWarehouse* goalWh);
4744
nofWorkman(SerializedGameData& sgd, unsigned obj_id);
4845

4946
void HandleDerivedEvent(unsigned id) override;

0 commit comments

Comments
 (0)