• 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

0.0
/libs/s25main/figures/nofForester.cpp
1
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "nofForester.h"
6

7
#include "GameInterface.h"
8
#include "GamePlayer.h"
9
#include "Loader.h"
10
#include "SoundManager.h"
11
#include "network/GameClient.h"
12
#include "ogl/glArchivItem_Bitmap_Player.h"
13
#include "random/Random.h"
14
#include "world/GameWorld.h"
15
#include "nodeObjs/noTree.h"
16
#include <boost/container/static_vector.hpp>
17

UNCOV
18
nofForester::nofForester(const MapPoint pos, const unsigned char player, nobUsual* workplace)
×
UNCOV
19
    : nofFarmhand(Job::Forester, pos, player, workplace)
×
UNCOV
20
{}
×
21

22
nofForester::nofForester(SerializedGameData& sgd, const unsigned obj_id) : nofFarmhand(sgd, obj_id) {}
×
23

24
/// Malt den Arbeiter beim Arbeiten
25
void nofForester::DrawWorking(DrawPoint drawPt)
×
26
{
27
    unsigned short now_id = GAMECLIENT.Interpolate(36, current_ev);
×
28
    // Baum pflanzen
29
    LOADER.GetPlayerImage("rom_bobs", 48 + now_id)->DrawFull(drawPt, COLOR_WHITE, world->GetPlayer(player).color);
×
30

31
    // Schaufel-Sound
32
    if(now_id == 7 || now_id == 18)
×
33
    {
34
        world->GetSoundMgr().playNOSound(76, *this, (now_id == 7) ? 0 : 1, 200);
×
35
        was_sounding = true;
×
36
    }
37
    // Baum-Einpflanz-Sound
38
    else if(now_id == 35)
×
39
    {
40
        world->GetSoundMgr().playNOSound(57, *this, 2);
×
41
        was_sounding = true;
×
42
    }
43
}
×
44

45
unsigned short nofForester::GetCarryID() const
×
46
{
47
    return 0;
×
48
}
49

50
/// Abgeleitete Klasse informieren, wenn sie anfängt zu arbeiten (Vorbereitungen)
51
void nofForester::WorkStarted() {}
×
52

53
/// Abgeleitete Klasse informieren, wenn fertig ist mit Arbeiten
54
void nofForester::WorkFinished()
×
55
{
56
    // Wenn irgendwo ne Straße schon ist, NICHT einsetzen!
57
    for(const auto dir : helpers::EnumRange<Direction>{})
×
58
    {
59
        if(world->GetPointRoad(pos, dir) != PointRoad::None)
×
60
            return;
×
61
    }
62

63
    NodalObjectType noType = world->GetNO(pos)->GetType();
×
64
    // Wenn Objekt ein Zierobjekt ist, dann löschen, ansonsten den Baum NICHT einsetzen!
65
    if(noType == NodalObjectType::Environment || noType == NodalObjectType::Nothing)
×
66
    {
67
        world->DestroyNO(pos, false);
×
68

69
        // Je nach Landschaft andere Bäume pflanzbar!
70
        const std::array<boost::container::static_vector<unsigned char, 6>, 3> AVAILABLE_TREES = {
71
          {{0, 1, 2, 6, 7, 8}, {0, 1, 7}, {0, 1, 6, 8}}};
×
72
        uint8_t landscapeType = std::min<uint8_t>(world->GetLandscapeType().value, AVAILABLE_TREES.size() - 1);
×
73

74
        // jungen Baum einsetzen
75
        world->SetNO(pos, new noTree(pos, RANDOM_ELEMENT(AVAILABLE_TREES[landscapeType]), 0));
×
76

77
        // BQ drumherum neu berechnen
78
        world->RecalcBQAroundPoint(pos);
×
79

80
        // Minimap Bescheid geben (neuer Baum)
81
        if(world->GetGameInterface())
×
82
            world->GetGameInterface()->GI_UpdateMinimap(pos);
×
83
    }
84
}
85

86
/// Returns the quality of this working point or determines if the worker can work here at all
87
nofFarmhand::PointQuality nofForester::GetPointQuality(const MapPoint pt, bool /* isBeforeWork */) const
×
88
{
89
    // Der Platz muss frei sein
90
    BlockingManner bm = world->GetNO(pt)->GetBM();
×
91

92
    if(bm != BlockingManner::None)
×
93
        return PointQuality::NotPossible;
×
94

95
    // Kein Grenzstein darf da stehen
96
    if(world->GetNode(pt).boundary_stones[BorderStonePos::OnPoint])
×
97
        return PointQuality::NotPossible;
×
98

99
    // darf außerdem nich auf einer Straße liegen
100
    for(const auto dir : helpers::EnumRange<Direction>{})
×
101
    {
102
        if(world->GetPointRoad(pt, dir) != PointRoad::None)
×
103
            return PointQuality::NotPossible;
×
104
    }
105

106
    // es dürfen außerdem keine Gebäude rund um den Baum stehen
107
    for(const MapPoint nb : world->GetNeighbours(pt))
×
108
    {
109
        if(world->GetNO(nb)->GetType() == NodalObjectType::Building)
×
110
            return PointQuality::NotPossible;
×
111
    }
112

113
    // Terrain untersuchen
114
    if(world->IsOfTerrain(pt, [](const auto& desc) { return desc.IsVital(); }))
×
115
        return PointQuality::Class1;
×
116
    else
117
        return PointQuality::NotPossible;
×
118
}
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