Skip to content

Commit 7b4120c

Browse files
committed
noexcept everywhere
1 parent bc776a2 commit 7b4120c

21 files changed

Lines changed: 97 additions & 73 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A plethora of ways to ruin your gaming experience...
88
---
99

1010
## About
11-
This silly lil' mod adds a mod menu filled to the brim with **over 30 crazy troll options** to mes around with! Spice up your gameplay by adding some truly terrible features to absolutely wreck your entire game.
11+
This silly lil' mod adds a mod menu filled to the brim with **over 35 crazy troll options** to mes around with! Spice up your gameplay by adding some truly terrible features to absolutely wreck your entire game.
1212

1313
---
1414

about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
---
77

88
## About
9-
This silly lil' mod adds a mod menu filled to the brim with **over 30 crazy troll options** to mess around with! Spice up your gameplay by adding some truly terrible features to absolutely wreck your entire game.
9+
This silly lil' mod adds a mod menu filled to the brim with **over 35 crazy troll options** to mess around with! Spice up your gameplay by adding some truly terrible features to absolutely wreck your entire game.
1010

1111
---
1212

include/Events.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace horrible {
1717
public:
1818
OptionEvent(std::string id, bool toggled); // Constructor
1919

20-
AWCW_HORRIBLE_API_DLL std::string const& getId() const; // Get the unique ID of the option
21-
AWCW_HORRIBLE_API_DLL bool getToggled() const; // Get the toggle boolean of the option
20+
AWCW_HORRIBLE_API_DLL std::string_view getId() const noexcept; // Get the unique ID of the option
21+
AWCW_HORRIBLE_API_DLL bool getToggled() const noexcept; // Get the toggle boolean of the option
2222
};
2323

2424
// Filter for option toggle event

include/Horrible.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ namespace horrible {
4545
*
4646
* @returns Whether this option already exists or not
4747
*/
48-
bool doesOptionExist(std::string_view id) const;
48+
bool doesOptionExist(std::string_view id) const noexcept;
4949

5050
friend class OptionEventFilter;
5151

5252
public:
5353
// Get option manager singleton
54-
static OptionManager* get();
54+
static OptionManager* get() noexcept;
5555

5656
/**
5757
* Register a new option
@@ -65,7 +65,7 @@ namespace horrible {
6565
*
6666
* @returns An array of every registered option, main and external
6767
*/
68-
std::vector<Option> const& getOptions() const;
68+
std::span<const Option> getOptions() const noexcept;
6969

7070
/**
7171
* Returns the toggle state of an option
@@ -74,7 +74,7 @@ namespace horrible {
7474
*
7575
* @returns Boolean of the current value
7676
*/
77-
bool getOption(std::string_view id) const;
77+
bool getOption(std::string_view id) const noexcept;
7878

7979
/**
8080
* Set the toggle state of an option
@@ -84,13 +84,13 @@ namespace horrible {
8484
*
8585
* @returns Boolean of the old value
8686
*/
87-
bool setOption(std::string_view id, bool enable) const;
87+
bool setOption(std::string_view id, bool enable) const noexcept;
8888

8989
/**
9090
* Returns a reference to the array of all registered categories
9191
*
9292
* @returns An array of every category name
9393
*/
94-
std::vector<std::string> const& getCategories() const;
94+
std::span<const std::string> getCategories() const noexcept;
9595
};
9696
};

include/OptionalAPI.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ namespace horrible {
1919
public:
2020
OptionEventV2(std::string id, bool toggled) : m_id(std::move(id)), m_toggled(toggled) {};
2121

22-
std::string const& getId() const { return m_id; };
23-
bool getToggled() const { return m_toggled; };
22+
std::string_view getId() const noexcept { return m_id; };
23+
bool getToggled() const noexcept { return m_toggled; };
2424
};
2525

2626
class OptionEventFilterV2 : public geode::EventFilter<OptionEventV2> {

src/classes/Options.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace horrible {
1111
*
1212
* @returns An array of every registered option, main and external
1313
*/
14-
std::vector<horrible::Option> const& getAll();
14+
std::span<const Option> getAll() noexcept;
1515

1616
/**
1717
* Returns the toggle state of an option
@@ -20,7 +20,7 @@ namespace horrible {
2020
*
2121
* @returns Boolean of the current value
2222
*/
23-
bool get(std::string_view id);
23+
bool get(std::string_view id) noexcept;
2424

2525
/**
2626
* Returns the chance value for an option
@@ -46,14 +46,14 @@ namespace horrible {
4646
*
4747
* @returns An array of every registered option category, main and external
4848
*/
49-
std::vector<std::string> const& getAllCategories();
49+
std::span<const std::string> getAllCategories() noexcept;
5050

5151
/**
5252
* Returns if a category exists or not
5353
*
5454
* @param category The exact name of the category to check
5555
*/
56-
bool doesCategoryExist(std::string_view category);
56+
bool doesCategoryExist(std::string_view category) noexcept;
5757
};
5858
};
5959
};

src/classes/src/Options.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
using namespace horrible;
66
using namespace horrible::util;
77

8-
std::vector<Option> const& options::getAll() {
8+
std::span<const Option> options::getAll() noexcept {
99
if (auto om = OptionManager::get()) return om->getOptions();
10-
11-
static const std::vector<Option> ret;
12-
return ret;
10+
return {};
1311
};
1412

15-
bool options::get(std::string_view id) {
13+
bool options::get(std::string_view id) noexcept {
1614
if (auto om = OptionManager::get()) return om->getOption(id);
1715
return false;
1816
};
@@ -26,13 +24,14 @@ bool options::set(std::string_view id, bool enable) {
2624
return false;
2725
};
2826

29-
std::vector<std::string> const& options::getAllCategories() {
27+
std::span<const std::string> options::getAllCategories() noexcept {
3028
if (auto om = OptionManager::get()) return om->getCategories();
3129

3230
static const std::vector<std::string> ret;
3331
return ret;
3432
};
3533

36-
bool options::doesCategoryExist(std::string_view category) {
37-
return str::containsAny(category.data(), getAllCategories());
34+
bool options::doesCategoryExist(std::string_view category) noexcept {
35+
auto cats = getAllCategories();
36+
return str::containsAny(category.data(), { cats.begin(), cats.end() });
3837
};

src/classes/ui/MathQuiz.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace horrible {
2727
void closeAfterFeedback(CCNode* node);
2828
void onAnswerClicked(CCObject* sender);
2929

30-
bool hasAnswer(int answer) const;
30+
bool hasAnswer(int answer) const noexcept;
3131

3232
void keyBackClicked() override;
3333
void update(float dt) override;

src/classes/ui/src/MathQuiz.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void MathQuiz::onAnswerClicked(CCObject* sender) {
299299
};
300300
};
301301

302-
bool MathQuiz::hasAnswer(int answer) const {
302+
bool MathQuiz::hasAnswer(int answer) const noexcept {
303303
for (auto const& a : m_impl->m_answers) {
304304
if (a == answer) return true;
305305
};

src/hooks/Achievement.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class $modify(AchievementCCMenuItem, CCMenuItem) {
1818

1919
auto f = m_fields.self();
2020

21+
this->template addEventListener<OptionEventFilter>(
22+
[this, f](OptionEvent* ev) {
23+
f->enabled = ev->getToggled();
24+
return ListenerResult::Propagate;
25+
},
26+
"achieve"
27+
);
28+
2129
if (f->enabled) {
2230
if (auto fmod = FMODAudioEngine::sharedEngine()) {
2331
int rnd = randng::fast();

0 commit comments

Comments
 (0)