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

Return-To-The-Roots / s25client / 24041761791

06 Apr 2026 05:10PM UTC coverage: 50.37% (+0.03%) from 50.337%
24041761791

Pull #1910

github

web-flow
Merge 8d86aacd8 into e4146df45
Pull Request #1910: Fix wrongly shown soldiers & Refactor HQ start wares and inventory handling

197 of 409 new or added lines in 22 files covered. (48.17%)

96 existing lines in 25 files now uncovered.

23067 of 45795 relevant lines covered (50.37%)

43239.58 hits per line

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

27.12
/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/nofLeatherWorker.h"
32
#include "figures/nofMetalworker.h"
33
#include "figures/nofMiller.h"
34
#include "figures/nofMiner.h"
35
#include "figures/nofMinter.h"
36
#include "figures/nofPassiveSoldier.h"
37
#include "figures/nofPassiveWorker.h"
38
#include "figures/nofPigbreeder.h"
39
#include "figures/nofPlaner.h"
40
#include "figures/nofScout_Free.h"
41
#include "figures/nofScout_LookoutTower.h"
42
#include "figures/nofShipWright.h"
43
#include "figures/nofSkinner.h"
44
#include "figures/nofStonemason.h"
45
#include "figures/nofTanner.h"
46
#include "figures/nofTempleServant.h"
47
#include "figures/nofVintner.h"
48
#include "figures/nofWellguy.h"
49
#include "figures/nofWinegrower.h"
50
#include "figures/nofWoodcutter.h"
51
#include "helpers/toString.h"
52
#include "nodeObjs/noFlag.h"
53
#include <stdexcept>
54

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