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

Method UpdateForegroundEvents

src/game_map.cpp:1402–1468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1400}
1401
1402bool Game_Map::UpdateForegroundEvents(MapUpdateAsyncContext& actx) {
1403 auto& interp = GetInterpreter();
1404
1405 // If we resume from async op, we don't clear the loop index.
1406 const bool resume_fg = actx.IsForegroundEvent();
1407
1408 // Run any event loaded from last frame.
1409 interp.Update(!resume_fg);
1410 if (interp.IsAsyncPending()) {
1411 // Suspend due to this event ..
1412 actx = MapUpdateAsyncContext::FromForegroundEvent(interp.GetAsyncOp());
1413 return false;
1414 }
1415
1416 while (!interp.IsRunning() && !interp.ReachedLoopLimit()) {
1417 interp.Clear();
1418
1419 // This logic is probably one big loop in RPG_RT. We have to replicate
1420 // it here because once we stop executing from this we should not
1421 // clear anymore waiting flags.
1422 if (Scene::instance->HasRequestedScene() && interp.GetLoopCount() > 0) {
1423 break;
1424 }
1425 Game_CommonEvent* run_ce = nullptr;
1426
1427 for (auto& ce: common_events) {
1428 if (ce.IsWaitingForegroundExecution()) {
1429 run_ce = &ce;
1430 break;
1431 }
1432 }
1433 if (run_ce) {
1434 interp.Push(run_ce);
1435 }
1436
1437 Game_Event* run_ev = nullptr;
1438 for (auto& ev: events) {
1439 if (ev.IsWaitingForegroundExecution()) {
1440 if (!ev.IsActive()) {
1441 ev.ClearWaitingForegroundExecution();
1442 continue;
1443 }
1444 run_ev = &ev;
1445 break;
1446 }
1447 }
1448 if (run_ev) {
1449 interp.Push(run_ev);
1450 run_ev->ClearWaitingForegroundExecution();
1451 }
1452
1453 // If no events to run we're finished.
1454 if (!interp.IsRunning()) {
1455 break;
1456 }
1457
1458 interp.Update(false);
1459 if (interp.IsAsyncPending()) {

Callers

nothing calls this directly

Calls 13

IsForegroundEventMethod · 0.80
IsRunningMethod · 0.80
ReachedLoopLimitMethod · 0.80
HasRequestedSceneMethod · 0.80
UpdateMethod · 0.45
IsAsyncPendingMethod · 0.45
GetAsyncOpMethod · 0.45
ClearMethod · 0.45
GetLoopCountMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected