Skip to content

Commit 4b2fad1

Browse files
committed
Fix recursive lock. Fix platform bot flying on SBB.
1 parent 37e7893 commit 4b2fad1

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

SerialPrograms/Source/NintendoSwitch/Controllers/SysbotBase/SysbotBase_Connection.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ void SysbotBaseNetwork_Connection::thread_body_internal(){
144144
m_socket->connect(
145145
m_socket, &QTcpSocket::disconnected,
146146
m_socket, [this]{
147-
m_ready.store(false, std::memory_order_release);
148-
m_stopping.store(true, std::memory_order_release);
149-
m_cv.notify_all();
147+
{
148+
std::unique_lock<std::mutex> lg(m_lock);
149+
m_ready.store(false, std::memory_order_release);
150+
m_stopping.store(true, std::memory_order_release);
151+
m_cv.notify_all();
152+
}
150153
set_status(html_color_text("Disconnected by host.", COLOR_RED));
151154
}
152155
);

SerialPrograms/Source/NintendoSwitch/Controllers/SysbotBase/SysbotBase_ProController.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,31 @@ ProController_SysbotBase::~ProController_SysbotBase(){
7676

7777
void ProController_SysbotBase::wait_for_all(const Cancellable* cancellable){
7878
// cout << "ProController_SysbotBase::wait_for_all()" << endl;
79-
std::unique_lock<std::mutex> lg(m_lock);
8079
issue_barrier(cancellable);
80+
std::unique_lock<std::mutex> lg(m_lock);
8181
m_cv.wait(lg, [this]{
8282
return m_command_queue.empty() || m_replace_on_next.load(std::memory_order_relaxed);
8383
});
8484
}
8585
void ProController_SysbotBase::cancel_all_commands(){
8686
// cout << "ProController_SysbotBase::cancel_all_commands()" << endl;
87-
std::lock_guard<std::mutex> lg(m_lock);
88-
if (!m_command_queue.empty()){
89-
m_command_queue.clear();
90-
m_is_active = false;
91-
m_cv.notify_all();
87+
{
88+
std::lock_guard<std::mutex> lg(m_lock);
89+
if (!m_command_queue.empty()){
90+
m_command_queue.clear();
91+
m_is_active = false;
92+
m_cv.notify_all();
93+
}
9294
}
9395
this->clear_on_next();
9496
}
9597
void ProController_SysbotBase::replace_on_next_command(){
9698
// cout << "ProController_SysbotBase::replace_on_next_command()" << endl;
97-
std::lock_guard<std::mutex> lg(m_lock);
98-
m_cv.notify_all();
99-
m_replace_on_next.store(true, std::memory_order_relaxed);
99+
{
100+
std::lock_guard<std::mutex> lg(m_lock);
101+
m_cv.notify_all();
102+
m_replace_on_next.store(true, std::memory_order_relaxed);
103+
}
100104
this->clear_on_next();
101105
}
102106

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ void SingleSwitchProgramSession::run_program_instance(SingleSwitchProgramEnviron
6969

7070
m_scope.store(&scope, std::memory_order_release);
7171

72+
#if 0
73+
ProControllerContext context(scope, env.console.controller());
74+
m_option.instance().program(env, context);
75+
context.wait_for_all_requests();
76+
#else
7277
try{
7378
ProControllerContext context(scope, env.console.controller());
7479
m_option.instance().program(env, context);
@@ -77,6 +82,7 @@ void SingleSwitchProgramSession::run_program_instance(SingleSwitchProgramEnviron
7782
m_scope.store(nullptr, std::memory_order_release);
7883
throw;
7984
}
85+
#endif
8086
m_scope.store(nullptr, std::memory_order_release);
8187
}
8288
void SingleSwitchProgramSession::internal_stop_program(){
@@ -157,7 +163,9 @@ void SingleSwitchProgramSession::internal_run_program(){
157163
env, m_option.instance().NOTIFICATION_ERROR_FATAL,
158164
message
159165
);
160-
}catch (std::exception& e){
166+
}
167+
#if 1
168+
catch (std::exception& e){
161169
logger().log("Program stopped with an exception!", COLOR_RED);
162170
std::string message = e.what();
163171
if (message.empty()){
@@ -176,6 +184,7 @@ void SingleSwitchProgramSession::internal_run_program(){
176184
"Unknown error."
177185
);
178186
}
187+
#endif
179188
}
180189

181190

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_TurboMacro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TurboMacro_Descriptor::TurboMacro_Descriptor()
2020
"Create macros",
2121
FeedbackType::NONE,
2222
AllowCommandsWhenRunning::DISABLE_COMMANDS,
23-
{SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS}
23+
{ControllerFeature::NintendoSwitch_ProController}
2424
)
2525
{}
2626

SerialPrograms/Source/PokemonSV/Programs/PokemonSV_AreaZero.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void return_to_outside_zero_gate(
186186
VideoStream& stream, ProControllerContext& context
187187
){
188188
open_map_from_overworld(info, stream, context);
189-
pbf_move_left_joystick(context, 0, 0, 5, 50);
189+
pbf_move_left_joystick(context, 96, 96, 5, 50);
190190
fly_to_overworld_from_map(info, stream, context);
191191
}
192192
void return_to_inside_zero_gate(

0 commit comments

Comments
 (0)