• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 21586670805

02 Feb 2026 10:34AM UTC coverage: 50.811% (+0.06%) from 50.754%
21586670805

Pull #1882

github

web-flow
Merge 05dbd3856 into dc0ce04f6
Pull Request #1882: Fix collection of jobs to warehouses

81 of 126 new or added lines in 16 files covered. (64.29%)

8 existing lines in 4 files now uncovered.

22784 of 44841 relevant lines covered (50.81%)

41256.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

32.14
/libs/s25main/factories/JobFactory.cpp
1
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "JobFactory.h"
6
#include "buildings/noBuildingSite.h"
7
#include "buildings/nobBaseMilitary.h"
8
#include "buildings/nobBaseWarehouse.h"
9
#include "buildings/nobUsual.h"
10
#include "nodeObjs/noRoadNode.h"
11

12
//////////////////////////////////////////////////////////////////////////
13
// Job includes, maybe use register function in nof* classes?
14
//////////////////////////////////////////////////////////////////////////
15
#include "figures/nofArmorer.h"
16
#include "figures/nofBaker.h"
17
#include "figures/nofBrewer.h"
18
#include "figures/nofBuilder.h"
19
#include "figures/nofButcher.h"
20
#include "figures/nofCarpenter.h"
21
#include "figures/nofCarrier.h"
22
#include "figures/nofCatapultMan.h"
23
#include "figures/nofCharburner.h"
24
#include "figures/nofDonkeybreeder.h"
25
#include "figures/nofFarmer.h"
26
#include "figures/nofFisher.h"
27
#include "figures/nofForester.h"
28
#include "figures/nofGeologist.h"
29
#include "figures/nofHunter.h"
30
#include "figures/nofIronfounder.h"
31
#include "figures/nofMetalworker.h"
32
#include "figures/nofMiller.h"
33
#include "figures/nofMiner.h"
34
#include "figures/nofMinter.h"
35
#include "figures/nofPassiveSoldier.h"
36
#include "figures/nofPassiveWorker.h"
37
#include "figures/nofPigbreeder.h"
38
#include "figures/nofPlaner.h"
39
#include "figures/nofScout_Free.h"
40
#include "figures/nofScout_LookoutTower.h"
41
#include "figures/nofShipWright.h"
42
#include "figures/nofStonemason.h"
43
#include "figures/nofTempleServant.h"
44
#include "figures/nofVintner.h"
45
#include "figures/nofWellguy.h"
46
#include "figures/nofWinegrower.h"
47
#include "figures/nofWoodcutter.h"
48
#include "helpers/toString.h"
49
#include "nodeObjs/noFlag.h"
50
#include <stdexcept>
51

52
std::unique_ptr<noFigure> JobFactory::CreateJob(const Job job_id, const MapPoint pt, const unsigned char player,
117✔
53
                                                noRoadNode& goal)
54
{
55
    if(nobBaseWarehouse::isStorehouseGOT(goal.GetGOT()))
117✔
56
        return std::make_unique<nofPassiveWorker>(job_id, pt, player, &goal);
68✔
57
    switch(job_id)
49✔
58
    {
59
        case Job::Builder:
13✔
60
            if(goal.GetGOT() != GO_Type::Buildingsite)
13✔
NEW
61
                return std::make_unique<nofPassiveWorker>(Job::Builder, pt, player, &goal);
×
62
            else
63
                return std::make_unique<nofBuilder>(pt, player, &checkedCast<noBuildingSite>(goal));
13✔
NEW
64
        case Job::Planer: return std::make_unique<nofPlaner>(pt, player, &checkedCast<noBuildingSite>(goal));
×
NEW
65
        case Job::Carpenter: return std::make_unique<nofCarpenter>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
66
        case Job::Armorer: return std::make_unique<nofArmorer>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
67
        case Job::Stonemason: return std::make_unique<nofStonemason>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
68
        case Job::Brewer: return std::make_unique<nofBrewer>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
69
        case Job::Minter: return std::make_unique<nofMinter>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
70
        case Job::Butcher: return std::make_unique<nofButcher>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
71
        case Job::IronFounder: return std::make_unique<nofIronfounder>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
72
        case Job::Miller: return std::make_unique<nofMiller>(pt, player, &checkedCast<nobUsual>(goal));
×
73
        case Job::Metalworker: return std::make_unique<nofMetalworker>(pt, player, &checkedCast<nobUsual>(goal));
3✔
74
        case Job::Baker: return std::make_unique<nofBaker>(pt, player, &checkedCast<nobUsual>(goal));
1✔
UNCOV
75
        case Job::Helper:
×
NEW
76
            if(goal.GetGOT() == GO_Type::NobUsual)
×
77
            {
NEW
78
                auto* goalBld = &checkedCast<nobUsual>(goal);
×
79
                if(goalBld->GetBuildingType() == BuildingType::Well)
×
80
                    return std::make_unique<nofWellguy>(pt, player, goalBld);
×
81
                else if(goalBld->GetBuildingType() == BuildingType::Catapult)
×
82
                    return std::make_unique<nofCatapultMan>(pt, player, goalBld);
×
83
            }
NEW
84
            throw std::runtime_error("Invalid goal type: " + helpers::toString(goal.GetGOT()) + " for job "
×
85
                                     + helpers::toString(job_id));
×
86
        case Job::Geologist: return std::make_unique<nofGeologist>(pt, player, &checkedCast<noFlag>(goal));
22✔
87
        case Job::Scout:
4✔
88
            // Different scout for lookout towers and free scouts
89
            if(goal.GetGOT() == GO_Type::NobUsual)
4✔
90
            {
NEW
91
                return std::make_unique<nofScout_LookoutTower>(pt, player, &checkedCast<nobUsual>(goal));
×
92
            } else if(goal.GetGOT() == GO_Type::Flag)
4✔
93
                return std::make_unique<nofScout_Free>(pt, player, &goal);
4✔
NEW
94
            throw std::runtime_error("Invalid goal type: " + helpers::toString(goal.GetGOT()) + " for job "
×
95
                                     + helpers::toString(job_id));
×
NEW
96
        case Job::Miner: return std::make_unique<nofMiner>(pt, player, &checkedCast<nobUsual>(goal));
×
97
        case Job::Farmer: return std::make_unique<nofFarmer>(pt, player, &checkedCast<nobUsual>(goal));
1✔
98
        case Job::Forester: return std::make_unique<nofForester>(pt, player, &checkedCast<nobUsual>(goal));
1✔
99
        case Job::Woodcutter: return std::make_unique<nofWoodcutter>(pt, player, &checkedCast<nobUsual>(goal));
3✔
NEW
100
        case Job::PigBreeder: return std::make_unique<nofPigbreeder>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
101
        case Job::DonkeyBreeder: return std::make_unique<nofDonkeybreeder>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
102
        case Job::Hunter: return std::make_unique<nofHunter>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
103
        case Job::Fisher: return std::make_unique<nofFisher>(pt, player, &checkedCast<nobUsual>(goal));
×
UNCOV
104
        case Job::Private:
×
105
        case Job::PrivateFirstClass:
106
        case Job::Sergeant:
107
        case Job::Officer:
108
        case Job::General:
109
            // TODO: Is this ever called? If yes, then why is the home here set to nullptr?
NEW
110
            return std::make_unique<nofPassiveSoldier>(pt, player, &checkedCast<nobBaseMilitary>(goal), nullptr,
×
111
                                                       getSoldierRank(job_id));
×
NEW
112
        case Job::PackDonkey: return std::make_unique<nofCarrier>(CarrierType::Donkey, pt, player, nullptr, &goal);
×
113
        case Job::Shipwright: return std::make_unique<nofShipWright>(pt, player, &checkedCast<nobUsual>(goal));
1✔
NEW
114
        case Job::CharBurner: return std::make_unique<nofCharburner>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
115
        case Job::Winegrower: return std::make_unique<nofWinegrower>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
116
        case Job::Vintner: return std::make_unique<nofVintner>(pt, player, &checkedCast<nobUsual>(goal));
×
NEW
117
        case Job::TempleServant: return std::make_unique<nofTempleServant>(pt, player, &checkedCast<nobUsual>(goal));
×
118
        case Job::BoatCarrier:
×
119
            throw std::logic_error("Cannot create a boat carrier job (try creating Job::Helper).");
×
120
            break;
121
    }
122
    throw std::logic_error("Invalid job type " + helpers::toString(job_id));
×
123
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc