long WINAPI CCrashDumpWriter::HandleExceptionGlobal ( _EXCEPTION_POINTERS* pException ) { FreeMemoryForCrashDumpProcessing(); // Create the exception information class CExceptionInformation_Impl* pExceptionInformation = new CExceptionInformation_Impl; pExceptionInformation->Set ( pException->ExceptionRecord->ExceptionCode, pException ); WriteDebugEvent ( "CCrashDumpWriter::HandleExceptionGlobal" ); // Grab the mod manager CModManager* pModManager = CModManager::GetSingletonPtr (); if ( pModManager ) { // Got a client? if ( pModManager->GetCurrentMod () ) { // Protect us from "double-faults" try { // Let the client handle it. If it could, continue the execution if ( pModManager->GetCurrentMod ()->HandleException ( pExceptionInformation ) ) { // Delete the exception record and continue to search the exception stack delete pExceptionInformation; return EXCEPTION_CONTINUE_SEARCH; } // Save tick count now ms_uiTickCountBase = GetTickCount32 (); // The client wants us to terminate the process DumpCoreLog ( pExceptionInformation ); DumpMiniDump ( pException, pExceptionInformation ); RunErrorTool ( pExceptionInformation ); TerminateProcess ( GetCurrentProcess (), 1 ); } catch ( ... ) { // Double-fault, terminate the process DumpCoreLog ( pExceptionInformation ); DumpMiniDump ( pException, pExceptionInformation ); RunErrorTool ( pExceptionInformation ); TerminateProcess ( GetCurrentProcess (), 1 ); } } else { // Continue if we're in debug mode, if not terminate #ifdef MTA_DEBUG return EXCEPTION_CONTINUE_SEARCH; #endif } } // Terminate the process DumpCoreLog ( pExceptionInformation ); DumpMiniDump ( pException, pExceptionInformation ); RunErrorTool ( pExceptionInformation ); TerminateProcess ( GetCurrentProcess (), 1 ); return EXCEPTION_CONTINUE_SEARCH; }
bool CChat::CharacterKeyHandler(CGUIKeyEventArgs KeyboardArgs) { // If we can take input if (!CLocalGUI::GetSingleton().GetConsole()->IsVisible() && IsInputVisible()) { // Check if it's a special key like enter and backspace, if not, add it as a character to the message switch (KeyboardArgs.codepoint) { case VK_BACK: { if (m_strInputText.size() > 0) { // Convert our string to UTF8 before resizing, then back to ANSI. std::wstring strText = MbUTF8ToUTF16(m_strInputText); strText.resize(strText.size() - 1); SetInputText(UTF16ToMbUTF8(strText).c_str()); } break; } case VK_RETURN: { // Empty the chat and hide the input stuff // If theres a command to call, call it if (!m_strCommand.empty() && !m_strInputText.empty()) CCommands::GetSingleton().Execute(m_strCommand.c_str(), m_strInputText.c_str()); SetInputVisible(false); m_fSmoothScrollResetTime = GetSecondCount(); break; } case VK_TAB: { if (m_bNickCompletion && m_strInputText.size() > 0) { bool bSuccess = false; SString strCurrentInput = GetInputText(); size_t iFound; iFound = strCurrentInput.find_last_of(" "); if (iFound == std::string::npos) iFound = 0; else ++iFound; SString strPlayerNamePart = strCurrentInput.substr(iFound); CModManager* pModManager = CModManager::GetSingletonPtr(); if (pModManager && pModManager->GetCurrentMod()) { // Create vector and get playernames from deathmatch module std::vector<SString> vPlayerNames; pModManager->GetCurrentMod()->GetPlayerNames(vPlayerNames); for (std::vector<SString>::iterator iter = vPlayerNames.begin(); iter != vPlayerNames.end(); ++iter) { SString strPlayerName = *iter; // Check if there is another player after our last result if (m_strLastPlayerName.size() != 0) { if (strPlayerName.CompareI(m_strLastPlayerName)) { m_strLastPlayerName.clear(); if (*iter == vPlayerNames.back()) { CharacterKeyHandler(KeyboardArgs); return true; } } continue; } // Already a part? if (m_strLastPlayerNamePart.size() != 0) { strPlayerNamePart = m_strLastPlayerNamePart; } // Check namepart if (!RemoveColorCodes(strPlayerName).BeginsWith(strPlayerNamePart)) continue; else { // Check size if it's ok, then output SString strOutput = strCurrentInput.replace(iFound, std::string::npos, strPlayerName); if (MbUTF8ToUTF16(strOutput).size() < CHAT_MAX_CHAT_LENGTH) { bSuccess = true; m_strLastPlayerNamePart = strPlayerNamePart; m_strLastPlayerName = strPlayerName; SetInputText(strOutput); } break; } } // No success? Try again! if (!bSuccess) m_strLastPlayerName.clear(); } } break; } default: { // Clear last namepart when pressing letter if (m_strLastPlayerNamePart.size() != 0) m_strLastPlayerNamePart.clear(); // Clear last name when pressing letter if (m_strLastPlayerName.size() != 0) m_strLastPlayerName.clear(); // If we haven't exceeded the maximum number of characters per chat message, append the char to the message and update the input control if (MbUTF8ToUTF16(m_strInputText).size() < CHAT_MAX_CHAT_LENGTH) { if (KeyboardArgs.codepoint >= 32) { unsigned int uiCharacter = KeyboardArgs.codepoint; if (uiCharacter < 127) // we have any char from ASCII { // injecting as is m_strInputText += static_cast<char>(KeyboardArgs.codepoint); SetInputText(m_strInputText.c_str()); } else // we have any char from Extended ASCII, any ANSI code page or UNICODE range { // Generate a null-terminating string for our character wchar_t wUNICODE[2] = {uiCharacter, '\0'}; // Convert our UTF character into an ANSI string std::string strANSI = UTF16ToMbUTF8(wUNICODE); // Append the ANSI string, and update m_strInputText.append(strANSI); SetInputText(m_strInputText.c_str()); } } } break; } } } return true; }