void Game_Interpreter::SetupWait(int duration) { CloseMessageWindow(); if (duration == 0) { // 0.0 waits 1 frame wait_count = 1; } else { wait_count = duration * DEFAULT_FPS / 10; } }
bool Game_Interpreter::CommandEnd() { CloseMessageWindow(); list.clear(); if ((main_flag) && (event_id > 0)) { Game_Map::GetEvents().find(event_id)->second->Unlock(); } return true; }
// Clear. void Game_Interpreter::Clear() { map_id = 0; // map ID when starting up CloseMessageWindow(); event_id = 0; // event ID move_route_waiting = false; // waiting for move completion wait_count = 0; // wait count continuation = NULL; // function to execute to resume command button_timer = 0; if (child_interpreter) { // clear child interpreter for called events if (child_interpreter->updating) clear_child = true; else child_interpreter.reset(); } list.clear(); }
bool Game_Interpreter::CommandEnd() { CloseMessageWindow(); if (main_flag) { Game_Message::SetFaceName(""); } // FIXME: Hangs in some cases when Autostart events start //if (main_flag) { // Game_Message::FullClear(); //} list.clear(); if ((main_flag) && (event_id > 0)) { Game_Map::GetEvents().find(event_id)->second->StopTalkToHero(); } return true; }
bool Game_Interpreter::CommandGameOver(RPG::EventCommand const& /* com */) { // code 12420 CloseMessageWindow(); Game_Temp::gameover = true; SetContinuation(&Game_Interpreter::DefaultContinuation); return false; }
// Update void Game_Interpreter::Update() { // 10000 based on: https://gist.github.com/4406621 for (loop_count = 0; loop_count < 10000; ++loop_count) { /* If map is different than event startup time set event_id to 0 */ if (Game_Map::GetMapId() != map_id) { event_id = 0; } /* If there's any active child interpreter, update it */ if (child_interpreter) { child_interpreter->Update(); if (!child_interpreter->IsRunning()) { child_interpreter.reset(); } // If child interpreter still exists if (child_interpreter) { return; } } if (Game_Message::message_waiting) { return; } // If waiting for a move to end if (move_route_waiting) { if (Main_Data::game_player->GetMoveRouteForcing()) { return; } Game_Event* g_event; for (size_t i = 0; i < Game_Map::GetEvents().size(); i++) { g_event = Game_Map::GetEvents().find(i)->second.get(); if (g_event->GetMoveRouteForcing()) { return; } } move_route_waiting = false; } if (button_input_variable_id > 0) { InputButton(); return; } if (wait_count > 0) { wait_count--; return; } if (Game_Temp::forcing_battler != NULL) { return; } if (//Game_Temp::battle_calling || Game_Temp::shop_calling || // Game_Temp::inn_calling || Game_Temp::name_calling || Game_Temp::menu_calling || Game_Temp::save_calling || Game_Temp::to_title || Game_Temp::gameover) { return; } if (continuation) { bool result = (this->*continuation)(list[index]); continuation = NULL; if (result) continue; else return; } if (list.empty()) { if (!Main_Data::game_player->IsTeleporting() && main_flag) { if (Game_Map::GetNeedRefresh()) { Game_Map::Refresh(); } } if (list.empty()) { return; } } if (!ExecuteCommand()) { CloseMessageWindow(); active = true; return; } active = false; // FIXME? // After calling SkipTo this index++ will skip execution of e.g. END. // This causes a different timing because loop_count reaches 10000 // faster then Player does. // No idea if any game depends on this special case. index++; } // for // Executed Events Count exceeded (10000) active = true; Output::Debug("Event %d exceeded execution limit", event_id); CloseMessageWindow(); }
Game_Interpreter::~Game_Interpreter() { if (depth == 0) { CloseMessageWindow(); } }
/****************************************************************** WixWaitForEvent - entry point for WixWaitForEvent custom action which waits for either the WixWaitForEventFail or WixWaitForEventSucceed named auto reset events. Signaling the WixWaitForEventFail event will return ERROR_INSTALL_FAILURE or signaling the WixWaitForEventSucceed event will return ERROR_SUCCESS. Both events are declared in the Global\ namespace. ********************************************************************/ extern "C" UINT __stdcall WixWaitForEvent( __in MSIHANDLE hInstall ) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; HWND hMessageWindow = NULL; LPCWSTR wzSDDL = L"D:(A;;GA;;;WD)"; OS_VERSION version = OS_VERSION_UNKNOWN; DWORD dwServicePack = 0; PSECURITY_DESCRIPTOR pSD = NULL; SECURITY_ATTRIBUTES sa = { }; HANDLE rghEvents[2]; hr = WcaInitialize(hInstall, "WixWaitForEvent"); ExitOnFailure(hr, "Failed to initialize."); // Create a window to prevent shutdown requests. hr = CreateMessageWindow(&hMessageWindow); ExitOnFailure(hr, "Failed to create message window."); // If running on Vista/2008 or newer use integrity enhancements. OsGetVersion(&version, &dwServicePack); if (OS_VERSION_VISTA <= version) { // Add SACL to allow Everyone to signal from a medium integrity level. wzSDDL = L"D:(A;;GA;;;WD)S:(ML;;NW;;;ME)"; } // Create the security descriptor and attributes for the events. if (!::ConvertStringSecurityDescriptorToSecurityDescriptorW(wzSDDL, SDDL_REVISION_1, &pSD, NULL)) { ExitWithLastError(hr, "Failed to create the security descriptor for the events."); } sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = pSD; sa.bInheritHandle = FALSE; rghEvents[0] = ::CreateEventW(&sa, FALSE, FALSE, L"Global\\WixWaitForEventFail"); ExitOnNullWithLastError(rghEvents[0], hr, "Failed to create the Global\\WixWaitForEventFail event."); rghEvents[1] = ::CreateEventW(&sa, FALSE, FALSE, L"Global\\WixWaitForEventSucceed"); ExitOnNullWithLastError(rghEvents[1], hr, "Failed to create the Global\\WixWaitForEventSucceed event."); // Wait for either of the events to be signaled and handle accordingly. er = ::WaitForMultipleObjects(countof(rghEvents), rghEvents, FALSE, INFINITE); switch (er) { case WAIT_OBJECT_0 + 0: er = ERROR_INSTALL_FAILURE; break; case WAIT_OBJECT_0 + 1: er = ERROR_SUCCESS; break; default: ExitOnWin32Error(er, hr, "Unexpected failure."); } LExit: ReleaseHandle(rghEvents[1]); ReleaseHandle(rghEvents[0]); if (pSD) { ::LocalFree(pSD); } if (hMessageWindow) { CloseMessageWindow(hMessageWindow); } if (FAILED(hr)) { er = ERROR_INSTALL_FAILURE; } return WcaFinalize(er); }