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

Return-To-The-Roots / s25client / 26276677540

22 May 2026 08:17AM UTC coverage: 50.362% (+0.07%) from 50.29%
26276677540

push

github

web-flow
Merge pull request #1925 from DevOpsOfChaos/sidequest/ignore-isolated-fish-resources

Ignore isolated fish resources for fisheries

36 of 63 new or added lines in 4 files covered. (57.14%)

5 existing lines in 2 files now uncovered.

23180 of 46027 relevant lines covered (50.36%)

43873.39 hits per line

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

97.56
/libs/s25main/CheatCommandTracker.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 "CheatCommandTracker.h"
6
#include "Cheats.h"
7
#include "driver/KeyEvent.h"
8

9
namespace {
10
auto makeCircularBuffer(const std::string& str)
9✔
11
{
12
    return boost::circular_buffer<char>{cbegin(str), cend(str)};
9✔
13
}
14
const auto enableCheatsStr = makeCircularBuffer("winter");
15
} // namespace
16

17
CheatCommandTracker::CheatCommandTracker(Cheats& cheats) : cheats_(cheats), lastChars_(enableCheatsStr.size()) {}
13✔
18

19
void CheatCommandTracker::onKeyEvent(const KeyEvent& ke)
123✔
20
{
21
    if(!cheats_.areCheatsAllowed())
123✔
22
        return;
6✔
23

24
    if(ke.kt == KeyType::Char)
117✔
25
        onCharKeyEvent(ke);
105✔
26
    else
27
    {
28
        onSpecialKeyEvent(ke);
12✔
29
        lastChars_.clear();
12✔
30
    }
31
}
32

33
void CheatCommandTracker::onChatCommand(const std::string& cmd)
7✔
34
{
35
    if(!cheats_.areCheatsAllowed())
7✔
36
        return;
1✔
37

38
    if(cmd == "apocalypsis")
6✔
39
        cheats_.armageddon();
2✔
40
    else if(cmd == "impulse9")
4✔
41
        cheats_.toggleAllBuildingsEnabled();
2✔
42
    else if(cmd == "spies")
2✔
43
        cheats_.toggleShowEnemyProductivityOverlay();
2✔
44
}
45

46
void CheatCommandTracker::onSpecialKeyEvent(const KeyEvent& ke)
12✔
47
{
48
    if(ke.ctrl && ke.shift)
12✔
49
    {
50
        if(ke.kt >= KeyType::F1 && ke.kt <= KeyType::F8)
2✔
51
            cheats_.destroyBuildings({static_cast<unsigned>(ke.kt) - static_cast<unsigned>(KeyType::F1)});
1✔
52
        else if(ke.kt == KeyType::F9)
1✔
53
            cheats_.destroyAllAIBuildings();
1✔
54

55
        return;
2✔
56
    }
57

58
    switch(ke.kt)
10✔
59
    {
NEW
60
        case KeyType::F6: cheats_.toggleHumanAIPlayer(); break;
×
61
        case KeyType::F7:
6✔
62
        {
63
            if(ke.alt)
6✔
64
                cheats_.toggleResourceRevealMode();
2✔
65
            else
66
                cheats_.toggleAllVisible();
4✔
67
        }
68
        break;
6✔
69
        default: break;
4✔
70
    }
71
}
72

73
void CheatCommandTracker::onCharKeyEvent(const KeyEvent& ke)
105✔
74
{
75
    // Handle only ASCII chars
76
    if(ke.c > 0x7F)
105✔
77
        lastChars_.clear();
1✔
78
    else
79
    {
80
        lastChars_.push_back(static_cast<char>(ke.c));
104✔
81

82
        if(lastChars_ == enableCheatsStr)
104✔
83
            cheats_.toggleCheatMode();
6✔
84
    }
85
}
105✔
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