Update
| 360 | |
| 361 | // Update |
| 362 | void Game_Interpreter::Update(bool reset_loop_count) { |
| 363 | if (reset_loop_count) { |
| 364 | loop_count = 0; |
| 365 | } |
| 366 | |
| 367 | // Always reset async status when we enter interpreter loop. |
| 368 | _async_op = {}; |
| 369 | |
| 370 | if (!IsRunning()) { |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | if (Input::IsTriggered(Input::DEBUG_ABORT_EVENT) && Player::debug_flag && !Game_Battle::IsBattleRunning()) { |
| 375 | if (Game_Message::IsMessageActive()) { |
| 376 | Game_Message::GetWindow()->FinishMessageProcessing(); |
| 377 | } |
| 378 | if (!Main_Data::game_player->GetMoveRoute().move_commands.empty()) { |
| 379 | Main_Data::game_player->CancelMoveRoute(); |
| 380 | } |
| 381 | EndEventProcessing(); |
| 382 | return; |
| 383 | } |
| 384 | |
| 385 | #ifdef ENABLE_DYNAMIC_INTERPRETER_CONFIG |
| 386 | Player::active_interpreter_flags = &_state.easyrpg_runtime_flags; |
| 387 | auto flags_guard = lcf::makeScopeGuard([]() { |
| 388 | Player::active_interpreter_flags = &Player::interpreter_default_flags; |
| 389 | }); |
| 390 | #endif |
| 391 | |
| 392 | for (; loop_count < loop_limit; ++loop_count) { |
| 393 | // If something is calling a menu, we're allowed to execute only 1 command per interpreter. So we pass through if loop_count == 0, and stop at 1 or greater. |
| 394 | // RPG_RT compatible behavior. |
| 395 | if (loop_count > 0 && Scene::instance->HasRequestedScene()) { |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | // Previous command triggered an async operation. |
| 400 | if (IsAsyncPending()) { |
| 401 | if (_async_op.GetType() == AsyncOp::Type::eYieldRepeat) { |
| 402 | // This will cause an incorrect execution when the yielding |
| 403 | // command changed the index. |
| 404 | // Only use YieldRepeat for commands that do not do this! |
| 405 | auto& frame = GetFrame(); |
| 406 | --frame.current_command; |
| 407 | } |
| 408 | break; |
| 409 | } |
| 410 | |
| 411 | if (main_flag) { |
| 412 | if (Main_Data::game_player->IsBoardingOrUnboarding()) |
| 413 | break; |
| 414 | |
| 415 | if (Main_Data::game_player->InVehicle() && Main_Data::game_player->GetVehicle()->IsAscendingOrDescending()) |
| 416 | break; |
| 417 | |
| 418 | if (Game_Message::IsMessagePending()) |
| 419 | break; |
nothing calls this directly
no test coverage detected