Skip to content

Commit

Permalink
Fix crash when webhook throttling is set to zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticial committed Mar 23, 2024
1 parent dbe68ea commit a10dd4f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions SerialPrograms/Source/Integrations/DiscordWebhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ void DiscordWebhookSender::throttle(){
while (!m_sent.empty() && m_sent[0] + duration < now){
m_sent.pop_front();
}
if (m_sent.size() >= GlobalSettings::instance().DISCORD.webhooks.sends_per_second){
if (!m_sent.empty() && m_sent.size() >= GlobalSettings::instance().DISCORD.webhooks.sends_per_second){
m_logger.log("Throttling webhook messages due to rate limit...", COLOR_RED);
std::unique_lock<std::mutex> lg(m_lock);
m_cv.wait_for(
lg, duration,
[&]{ return m_sent[0] + duration < now || m_stopping; }
[&]{ return m_stopping || m_sent.empty() || m_sent[0] + duration < now; }
);
if (m_stopping){
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "Common/Cpp/Json/JsonObject.h"
#include "NintendoSwitch/NintendoSwitch_Settings.h"
#include "NintendoSwitch_SwitchSystemOption.h"
#include "UI/NintendoSwitch_SwitchSystemWidget.h"
//#include "UI/NintendoSwitch_SwitchSystemWidget.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,10 @@ void StatsResetEventBattle::program(SingleSwitchProgramEnvironment& env, BotBase
while (true){
if (TARGET == Target::Ursaluna) {
enter_battle_ursaluna(env, context);
} else {
}else{
enter_battle_pecharunt(env, context);
}

if (run_battle(env, context) && check_stats_after_win(env, context)){
break;
}
Expand Down

0 comments on commit a10dd4f

Please sign in to comment.