mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-12 04:11:06 -05:00
Fix "Date" condition returning true unexpectedly
This could happen if the plugin was stopped on the General tab and restarted or the first time the plugin was started.
This commit is contained in:
@@ -176,15 +176,21 @@ bool MacroConditionDate::CheckRegularDate(int64_t msSinceLastCheck)
|
||||
|
||||
bool MacroConditionDate::CheckCondition()
|
||||
{
|
||||
auto m = GetMacro();
|
||||
if (!m) {
|
||||
auto macro = GetMacro();
|
||||
if (!macro) {
|
||||
return false;
|
||||
}
|
||||
const auto timePassed = std::chrono::high_resolution_clock::now() -
|
||||
LastMacroConditionCheckTime(m);
|
||||
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
const auto lastCheck = LastMacroConditionCheckTime(macro);
|
||||
|
||||
const auto timePassed = now - lastCheck;
|
||||
|
||||
const auto msSinceLastCheck =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
timePassed);
|
||||
MacroWasCheckedSinceLastStart(macro)
|
||||
? std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
timePassed)
|
||||
: std::chrono::milliseconds(0);
|
||||
|
||||
if (_dayOfWeekCheck) {
|
||||
return CheckDayOfWeek(msSinceLastCheck.count());
|
||||
|
||||
Reference in New Issue
Block a user