| 395 | |
| 396 | template <typename F> |
| 397 | void Scene_Map::OnAsyncSuspend(F&& f, AsyncOp aop, bool is_preupdate) { |
| 398 | if (CheckSceneExit(aop)) { |
| 399 | return; |
| 400 | } |
| 401 | |
| 402 | if (aop.GetType() == AsyncOp::eSave) { |
| 403 | auto savefs = FileFinder::Save(); |
| 404 | bool success = Scene_Save::Save(savefs, aop.GetSaveSlot()); |
| 405 | if (aop.GetSaveResultVar() > 0) { |
| 406 | Main_Data::game_variables->Set(aop.GetSaveResultVar(), success ? 1 : 0); |
| 407 | Game_Map::SetNeedRefresh(true); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | if (aop.GetType() == AsyncOp::eLoad) { |
| 412 | auto savefs = FileFinder::Save(); |
| 413 | std::string save_name = Scene_Save::GetSaveFilename(savefs, aop.GetSaveSlot()); |
| 414 | Player::LoadSavegame(save_name, aop.GetSaveSlot()); |
| 415 | } |
| 416 | |
| 417 | if (aop.GetType() == AsyncOp::eCloneMapEvent) { |
| 418 | Game_Map::CloneMapEvent(aop.GetMapId(), aop.GetSourceEventId(), aop.GetX(), aop.GetY(), aop.GetTargetEventId(), aop.GetEventName()); |
| 419 | } |
| 420 | |
| 421 | if (aop.GetType() == AsyncOp::eDestroyMapEvent) { |
| 422 | Game_Map::DestroyMapEvent(aop.GetTargetEventId()); |
| 423 | } |
| 424 | |
| 425 | auto& transition = Transition::instance(); |
| 426 | |
| 427 | if (aop.GetType() == AsyncOp::eEraseScreen) { |
| 428 | auto tt = static_cast<Transition::Type>(aop.GetTransitionType()); |
| 429 | if (tt == Transition::TransitionNone) { |
| 430 | // Emulates an RPG_RT bug where instantaneous transitions cause a |
| 431 | // 30 frame pause and then make the screen black. |
| 432 | transition.InitErase(Transition::TransitionCutOut, this, 30); |
| 433 | } else { |
| 434 | transition.InitErase(tt, this); |
| 435 | } |
| 436 | |
| 437 | if (!is_preupdate) { |
| 438 | // RPG_RT behavior: EraseScreen commands performed during pre-update don't stick. |
| 439 | screen_erased_by_event = true; |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | if (aop.GetType() == AsyncOp::eShowScreen) { |
| 444 | auto tt = static_cast<Transition::Type>(aop.GetTransitionType()); |
| 445 | transition.InitShow(tt, this); |
| 446 | screen_erased_by_event = false; |
| 447 | } |
| 448 | |
| 449 | if (aop.GetType() == AsyncOp::eCallInn) { |
| 450 | activate_inn = true; |
| 451 | inn_started = false; |
| 452 | music_before_inn = Main_Data::game_system->GetCurrentBGM(); |
| 453 | map_async_continuation = std::forward<F>(f); |
| 454 |
nothing calls this directly
no test coverage detected