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

Return-To-The-Roots / s25client / 19616826773

23 Nov 2025 08:27PM UTC coverage: 50.521% (+0.05%) from 50.474%
19616826773

Pull #1817

github

web-flow
Merge 4a3c7a2ba into 6da68acba
Pull Request #1817: Proposal to turn off/on bird sounds

2 of 66 new or added lines in 4 files covered. (3.03%)

727 existing lines in 11 files now uncovered.

22550 of 44635 relevant lines covered (50.52%)

35034.0 hits per line

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

66.67
/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()) {}
11✔
18

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

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

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

38
    if(cmd == "apocalypsis")
×
UNCOV
39
        cheats_.armageddon();
×
UNCOV
40
    else if(cmd == "impulse9")
×
UNCOV
41
        cheats_.toggleAllBuildingsEnabled();
×
42
}
43

44
void CheatCommandTracker::onSpecialKeyEvent(const KeyEvent& ke)
1✔
45
{
46
    switch(ke.kt)
1✔
47
    {
48
        case KeyType::F7: cheats_.toggleAllVisible(); break;
×
49
        case KeyType::F10: cheats_.toggleHumanAIPlayer(); break;
1✔
50
        default: break;
×
51
    }
52
}
1✔
53

54
void CheatCommandTracker::onCharKeyEvent(const KeyEvent& ke)
99✔
55
{
56
    // Handle only ASCII chars
57
    if(ke.c > 0x7F)
99✔
UNCOV
58
        lastChars_.clear();
×
59
    else
60
    {
61
        lastChars_.push_back(static_cast<char>(ke.c));
99✔
62

63
        if(lastChars_ == enableCheatsStr)
99✔
64
            cheats_.toggleCheatMode();
6✔
65
    }
66
}
99✔
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