MCPcopy Create free account
hub / github.com/EasyRPG/Player / Update

Method Update

src/game_interpreter.cpp:362–536  ·  view source on GitHub ↗

Update

Source from the content-addressed store, hash-verified

360
361// Update
362void 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;

Callers

nothing calls this directly

Calls 12

CancelMoveRouteMethod · 0.80
HasRequestedSceneMethod · 0.80
InVehicleMethod · 0.80
CheckInputMethod · 0.80
emptyMethod · 0.45
GetTypeMethod · 0.45
GetVehicleMethod · 0.45
SetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected