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

Return-To-The-Roots / s25client / 12893089590

21 Jan 2025 06:06PM UTC coverage: 50.331% (+0.06%) from 50.267%
12893089590

push

github

web-flow
Merge pull request #1723 from kubaau/cheat_enable_buildings

Add cheat to enable all buildings

18 of 22 new or added lines in 4 files covered. (81.82%)

5 existing lines in 2 files now uncovered.

22370 of 44446 relevant lines covered (50.33%)

36321.37 hits per line

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

80.0
/libs/s25main/Cheats.cpp
1
// Copyright (C) 2024 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "Cheats.h"
6
#include "GameInterface.h"
7
#include "network/GameClient.h"
8
#include "world/GameWorldBase.h"
9

10
Cheats::Cheats(GameWorldBase& world) : world_(world) {}
14✔
11

12
bool Cheats::areCheatsAllowed() const
93✔
13
{
14
    return world_.IsSinglePlayer();
93✔
15
}
16

17
void Cheats::toggleCheatMode()
14✔
18
{
19
    // In S2, if you enabled cheat mode, revealed the map and disabled cheat mode, the map would remain revealed and you
20
    // would be unable to unreveal the map.
21
    // In RTTR, disabling cheat mode turns all cheats off and they have to be turned on again manually.
22
    if(isCheatModeOn_)
14✔
23
        turnAllCheatsOff();
5✔
24

25
    isCheatModeOn_ = !isCheatModeOn_;
14✔
26
}
14✔
27

28
void Cheats::toggleAllVisible()
6✔
29
{
30
    if(isCheatModeOn())
6✔
31
    {
32
        isAllVisible_ = !isAllVisible_;
5✔
33

34
        // In S2, the minimap is not updated immediately.
35
        // In RTTR, the minimap would become messed up if it wasn't updated here.
36
        if(GameInterface* gi = world_.GetGameInterface())
5✔
37
            gi->GI_UpdateMapVisibility();
5✔
38
    }
39
}
6✔
40

41
void Cheats::toggleAllBuildingsEnabled()
6✔
42
{
43
    // In S2, if you enabled cheats you would automatically have all buildings enabled.
44
    // In RTTR, because this may have unintended consequences when playing campaigns, the user must explicitly enable
45
    // all buildings after enabling cheats.
46
    if(isCheatModeOn())
6✔
47
        areAllBuildingsEnabled_ = !areAllBuildingsEnabled_;
5✔
48
}
6✔
49

50
void Cheats::toggleHumanAIPlayer()
1✔
51
{
52
    if(isCheatModeOn() && !GAMECLIENT.IsReplayModeOn())
1✔
53
    {
UNCOV
54
        GAMECLIENT.ToggleHumanAIPlayer(AI::Info{AI::Type::Default, AI::Level::Easy});
×
NEW
55
        isHumanAIPlayer_ = !isHumanAIPlayer_;
×
56
    }
57
}
1✔
58

59
void Cheats::armageddon() const
×
60
{
61
    if(isCheatModeOn())
×
62
        GAMECLIENT.CheatArmageddon();
×
63
}
×
64

65
void Cheats::turnAllCheatsOff()
5✔
66
{
67
    if(isAllVisible_)
5✔
68
        toggleAllVisible();
1✔
69
    if(areAllBuildingsEnabled_)
5✔
70
        toggleAllBuildingsEnabled();
1✔
71
    if(isHumanAIPlayer_)
5✔
NEW
72
        toggleHumanAIPlayer();
×
73
}
5✔
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