/*=========================================================================== * * Class CSrErrorDlg Method - void AddErrorInfo (pError, ErrorIndex); * *=========================================================================*/ void CSrErrorDlg::AddErrorInfo (CSrError* pError, const int ErrorIndex) { CString Buffer; CString IndexBuffer; int Length; if (ErrorIndex >= 0) IndexBuffer.Format(_T("%d) "), ErrorIndex); /* Check for no error information */ if (pError == NULL) { Buffer.Format(_T("%sNo Error!\r\n"), ErrorIndex >= 0 ? IndexBuffer : _T("")); } /* Fill in error information */ else { CSString ErrorString = pError->GetErrorString(); Buffer.Format(_T("%s%s\r\n%s%s%s"), ErrorIndex >= 0 ? IndexBuffer : _T(""), pError->GetErrorMessage(), ErrorString.IsEmpty() ? _T("") : _T("\t"), ErrorString.c_str(), ErrorString.IsEmpty() ? _T("") : _T("\r\n")); ++m_OutputCount; } Length = m_ErrorDetails.GetWindowTextLength(); m_ErrorDetails.SetSel(Length, Length, TRUE); m_ErrorDetails.ReplaceSel(Buffer, FALSE); }
/*=========================================================================== * * Class CSrSelectRecordDlg Method - int UpdateEditorID (void); * *=========================================================================*/ int CSrSelectRecordDlg::UpdateEditorID (void) { CString Buffer; CSString EditorID; CSrIdRecord* pIdRecord; int ListIndex; m_CurrentText.GetWindowText(Buffer); EditorID = Buffer; SrPrepareEditorID(EditorID); if (EditorID.IsEmpty()) { m_CurrentFormID = 0; } else { pIdRecord = m_pRecordHandler->FindEditorID(EditorID); if (pIdRecord == NULL) return (SR_CHECKRESULT_ERROR); ListIndex = m_RecordList.FindRecord(pIdRecord); if (ListIndex < 0) return (SR_CHECKRESULT_ERROR); m_CurrentEditorID = pIdRecord->GetEditorID(); m_CurrentFormID = pIdRecord->GetFormID(); } if (m_CurrentFormID == m_InitialFormID) return (SR_CHECKRESULT_NOCHANGE); Buffer.Format(_T("0x%08X"), m_CurrentFormID); m_CurrentFormIDText.SetWindowText(Buffer); return (SR_CHECKRESULT_OK); }
*=========================================================================*/ bool CNifCopyDlg::CheckCsvColumns (void) { CNifSourceTexture* pSourceTexture; POSITION FindPos; CSString* pString; CCsvRow* pRow; int CsvColIndex; int MatchColCount; int RowIndex; /* Check for the required filename column */ m_FilenameColIndex = m_CsvFile.FindHeaderCol(NIFCOPY_CSV_FILENAME); if (m_FilenameColIndex < 0) { ErrorHandler.AddError(ERR_BADINPUT, _T("Missing the required '%s' CSV column!"), NIFCOPY_CSV_FILENAME); return (false); } /* See if there is any matching csv columns and source textures */ pSourceTexture = (CNifSourceTexture *) m_NifFile.FindFirstRecord(FindPos, _T("NiSourceTexture")); MatchColCount = 0; while (pSourceTexture != NULL) { /* See if there is matching csv column */ CsvColIndex = m_CsvFile.FindHeaderCol(pSourceTexture->GetTextureName()); if (CsvColIndex >= 0) MatchColCount++; /* Get the next source texture record */ pSourceTexture = (CNifSourceTexture *) m_NifFile.FindNextRecord(FindPos, _T("NiSourceTexture")); } /* Did we find any matching columns? */ /*if (MatchColCount == 0) { ErrorHandler.AddError(ERR_BADINPUT, _T("Found no matching texture name columns in the CSV file!")); return (false); } //*/ /* Check the NIF filenames in the CSV file */ for (RowIndex = 1; RowIndex < m_CsvFile.GetNumLines(); RowIndex++) { pRow = m_CsvFile.GetRow(RowIndex); if (pRow == NULL) continue; pString = pRow->GetAt(m_FilenameColIndex); if (pString == NULL || pString->IsEmpty()) { ErrorHandler.AddError(ERR_BADINPUT, _T("Missing the required %s string in row %d of the CSV file!"), RowIndex); return (false); } } return (true); }
/*=========================================================================== * * Function - bool GetSrInstallPath (Buffer); * * Attempt to find Skyrim's install path in the registry. On success true * is returned and the path copied to the given buffer. On error false is * returned. * * HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Bethesda Softworks\Skyrim * *=========================================================================*/ bool GetSrInstallPath (CSString& OutputBuffer) { HKEY hKey; BYTE Buffer[300]; DWORD Size = 256; DWORD Type; int Result; /* Use the manual install path if set */ if (!g_SrManualInstallPath.IsEmpty()) { OutputBuffer = g_SrManualInstallPath; return true; } OutputBuffer.Empty(); Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, SR_REG_SUBKEY, 0, KEY_READ, &hKey); if (Result != ERROR_SUCCESS) { Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, SR_REG_SUBKEY64, 0, KEY_READ, &hKey); if (Result != ERROR_SUCCESS) { AddSrGeneralError("Failed to find Skyrim's install path in the Windows registry!"); return (false); } } Result = RegQueryValueEx(hKey, SR_REG_INSTALLPATH, NULL, &Type, Buffer, &Size); if (Result == ERROR_SUCCESS && Type == REG_SZ) { OutputBuffer = (char *)Buffer; } else { AddSrGeneralError("Failed to find Skyrim's install path in the Windows registry!"); RegCloseKey(hKey); return (false); } RegCloseKey(hKey); return (true); }
bool CClient::OnRxAxis( const byte * pData, size_t iLen ) { ADDTOCALLSTACK("CClient::OnRxAxis"); if ( !iLen || ( GetConnectType() != CONNECT_AXIS )) return false; while ( iLen -- ) { int iRet = OnConsoleKey( m_Targ_Text, *pData++, GetAccount() != NULL ); if ( ! iRet ) return false; if ( iRet == 2 ) { if ( GetAccount() == NULL ) { if ( !m_zLogin[0] ) { if ( (uint)(m_Targ_Text.GetLength()) <= (CountOf(m_zLogin) - 1) ) strcpy(m_zLogin, m_Targ_Text); m_Targ_Text.Empty(); } else { CSString sMsg; CAccountRef pAccount = g_Accounts.Account_Find(m_zLogin); if (( pAccount == NULL ) || ( pAccount->GetPrivLevel() < PLEVEL_Counsel )) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_NOT_PRIV)); m_Targ_Text.Empty(); return false; } if ( LogIn(m_zLogin, m_Targ_Text, sMsg ) == PacketLoginError::Success ) { m_Targ_Text.Empty(); if ( GetPrivLevel() < PLEVEL_Counsel ) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_NOT_PRIV)); return false; } if (GetPeer().IsValidAddr()) { CScriptTriggerArgs Args; Args.m_VarsLocal.SetStrNew("Account",GetName()); Args.m_VarsLocal.SetStrNew("IP",GetPeer().GetAddrStr()); TRIGRET_TYPE tRet = TRIGRET_RET_DEFAULT; r_Call("f_axis_preload", this, &Args, NULL, &tRet); if ( tRet == TRIGRET_RET_FALSE ) return false; if ( tRet == TRIGRET_RET_TRUE ) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_DENIED)); return false; } time_t dateChange; dword dwSize; if ( ! CSFileList::ReadFileInfo( "Axis.db", dateChange, dwSize )) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_INFO_ERROR)); return false; } CSFile FileRead; if ( ! FileRead.Open( "Axis.db", OF_READ|OF_BINARY )) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_FILE_ERROR)); return false; } tchar szTmp[8*1024]; PacketWeb packet; for (;;) { size_t iLength = FileRead.Read( szTmp, sizeof( szTmp ) ); if ( iLength <= 0 ) break; packet.setData((byte*)szTmp, iLength); packet.send(this); dwSize -= (dword)iLength; if ( dwSize <= 0 ) break; } return true; } return false; } else if ( ! sMsg.IsEmpty()) { SysMessagef("\"MSG:%s\"", (lpctstr)sMsg); return false; } m_Targ_Text.Empty(); } return true; } } } return true; }
bool CClient::OnRxConsole( const byte * pData, size_t iLen ) { ADDTOCALLSTACK("CClient::OnRxConsole"); // A special console version of the client. (Not game protocol) if ( !iLen || ( GetConnectType() != CONNECT_TELNET )) return false; if ( IsSetEF( EF_AllowTelnetPacketFilter ) ) { bool fFiltered = xPacketFilter(pData, iLen); if ( fFiltered ) return fFiltered; } while ( iLen -- ) { int iRet = OnConsoleKey( m_Targ_Text, *pData++, GetAccount() != NULL ); if ( ! iRet ) return false; if ( iRet == 2 ) { if ( GetAccount() == NULL ) { if ( !m_zLogin[0] ) { if ( (uint)(m_Targ_Text.GetLength()) > (CountOf(m_zLogin) - 1) ) { SysMessage("Login:\n"); } else { strcpy(m_zLogin, m_Targ_Text); SysMessage("Password:\n"); } m_Targ_Text.Empty(); } else { CSString sMsg; CAccountRef pAccount = g_Accounts.Account_Find(m_zLogin); if (( pAccount == NULL ) || ( pAccount->GetPrivLevel() < PLEVEL_Admin )) { SysMessagef("%s\n", g_Cfg.GetDefaultMsg(DEFMSG_CONSOLE_NOT_PRIV)); m_Targ_Text.Empty(); return false; } if ( LogIn(m_zLogin, m_Targ_Text, sMsg ) == PacketLoginError::Success ) { m_Targ_Text.Empty(); return OnRxConsoleLoginComplete(); } else if ( ! sMsg.IsEmpty()) { SysMessage( sMsg ); return false; } m_Targ_Text.Empty(); } return true; } else { iRet = g_Serv.OnConsoleCmd( m_Targ_Text, this ); if (g_Cfg.m_fTelnetLog && GetPrivLevel() >= g_Cfg.m_iCommandLog) g_Log.Event(LOGM_GM_CMDS, "%x:'%s' commands '%s'=%d\n", GetSocketID(), GetName(), static_cast<lpctstr>(m_Targ_Text), iRet); } } } return true; }