Skip to content

Commit

Permalink
config: Allow more sensible input options for enabling animations. (#…
Browse files Browse the repository at this point in the history
…5659)

* Add check for on/off and true/false.

* Cleanup feature and comment it out.

* Use already created helper function for this.

* Fix comparing int to char* ptr
  • Loading branch information
The-Briel-Deal authored Apr 20, 2024
1 parent 10caa03 commit 5c97b96
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1786,12 +1786,15 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
PANIM->second.overridden = true;
PANIM->second.pValues = &PANIM->second;

// on/off
PANIM->second.internalEnabled = ARGS[1] == "1";
// This helper casts strings like "1", "true", "off", "yes"... to int.
int64_t enabledInt = configStringToInt(ARGS[1]) == 1;

if (ARGS[1] != "0" && ARGS[1] != "1")
// Checking that the int is 1 or 0 because the helper can return integers out of range.
if (enabledInt != 0 && enabledInt != 1)
return "invalid animation on/off state";

PANIM->second.internalEnabled = configStringToInt(ARGS[1]) == 1;

if (PANIM->second.internalEnabled) {
// speed
if (isNumber(ARGS[2], true)) {
Expand Down

0 comments on commit 5c97b96

Please sign in to comment.