/*=========================================================================== * * 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); }
// Generate _ic_families.forage_source() void SaveFamiliesForageSource() { CSString output; printf( "-- GROUP ICONS FOR _ic_groups.forage_source --\n"); output = "<?xml version=\"1.0\"?>\n"; output+= "<FORM Revision=\"$Revision: 1.9 $\" State=\"modified\">\n"; output+= " <STRUCT>\n"; output+= " <ARRAY Name=\"Icons\">\n"; for ( uint i=0; i!=MPFamilies.size(); ++i ) { output+= toString(" <ATOM Value=\"%s\"/>\n", MPFamilies[i].Icon.c_str()); } output+= " </ARRAY>\n"; output+= " </STRUCT>\n"; output+= " <STRUCT/>\n"; output+= " <STRUCT/>\n"; output+= " <STRUCT/>\n"; output+= " <STRUCT/>\n"; output+= " <LOG></LOG>\n"; output+= "</FORM>\n"; output.writeToFile( IC_FAMILIES_FORAGE_SOURCE.c_str() ); }
void CCharacterScanJob::start() { // open the output file for the character table CSString filename= NLMISC::CPath::getFullPath(STAT_GLOBALS::getOutputFilePath(getOutputPath()))+_OutputName+"tbl.csv"; nlinfo("Opening output file: %s",filename.c_str()); _CharTblFile=fopen(filename.c_str(),"wb"); if (_CharTblFile==NULL) { nlwarning("Failed to open output file: %s",filename.c_str()); _State=ERROR; return; } // write a header line to the _CharTblFile file CSString rowTxt; for (uint32 i=0;i<_TblCols.size();++i) { rowTxt+=_TblCols[i]+','; } fprintf(_CharTblFile,"%s\n",rowTxt.rightCrop(1).c_str()); fflush(_CharTblFile); // setup the file list before the job begins nlinfo("Scanning for input files..."); _Files.clear(); getFileList(_Files); nlinfo("Input file scan completed: %d files found ... %s",_Files.size(),_Files.empty()?"Nothing to do!":"starting work"); // set the state to 'WORK' meaning we've finished init and now it's ok to do some work _State=WORK; }
// Parcours les différentes familles de MP pour effectuer // les traitements nécessaires void LoadFamillesMP() { printf( "-- LOADING RAW MATERIAL FAMILIES --\n" ); // Preload wk.uxt, item_mp_family.typ, and item_mp_group.typ (avoid to reload them each time) FamilyTypContent.readFromFile( ITEM_MP_FAMILY_TYP ); GroupTypContent.readFromFile( ITEM_MP_GROUPE_TYP ); WKContent.readFromFile( WK_UXT ); // avoid huge resize of vector<string> MPFamilies.reserve(1000); CSString fileData, ligne; if ( ! CFile::fileExists( "rm_fam_prop.csv" ) ) { nlError( "rm_fam_prop.csv not found\n"); exit( 1 ); } fileData.readFromFile( "rm_fam_prop.csv" ); ligne = fileData.splitTo( "\n", true ); while ( ligne != "" ) { NewMP( ligne ); ligne = fileData.splitTo( "\n", true ); } // le Primitive Necklace n'étant pas spécifié dans la liste des MP // on le rajoute à la main CreatePrimitiveNecklace(); }
/*=========================================================================== * * 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); }
void CWords_dicDlg::OnSelchangeResultList() { // Get selection CString resStr; m_Results.GetText( m_Results.GetCurSel(), resStr ); CSString key = Dico.getWordsKey( CSString(resStr) ); // Copy the selection into the clipboard if ( OpenClipboard() ) { HGLOBAL mem = GlobalAlloc (GHND|GMEM_DDESHARE, key.size()+1); if (mem) { char *pmem = (char*)GlobalLock( mem ); strcpy( pmem, key.c_str() ); GlobalUnlock( mem ); EmptyClipboard(); SetClipboardData( CF_TEXT, mem ); } CloseClipboard(); if ( mem ) { CString s; s.Format( "\"%s\" copied into the clipboard", key.c_str() ); GetDlgItem( IDC_Status )->SetWindowText( s ); } } else { GetDlgItem( IDC_Status )->SetWindowText( "Cannot access the clipboard" ); } }
bool CWebPageDef::r_WriteVal( lpctstr pszKey, CSString & sVal, CTextConsole * pSrc ) { ADDTOCALLSTACK("CWebPageDef::r_WriteVal"); EXC_TRY("WriteVal"); switch ( FindTableSorted( pszKey, sm_szLoadKeys, CountOf( sm_szLoadKeys )-1 )) { case WC_PLEVEL: sVal.FormatVal( m_privlevel ); break; case WC_WEBPAGEFILE: sVal = m_sDstFilePath; break; case WC_WEBPAGELOG: sVal.FormatVal( m_iUpdateLog ); break; case WC_WEBPAGESRC: sVal = m_sSrcFilePath; break; case WC_WEBPAGEUPDATE: // (seconds) sVal.FormatVal( m_iUpdatePeriod ); break; default: return( g_Serv.r_WriteVal( pszKey, sVal, pSrc )); } return true; EXC_CATCH; EXC_DEBUG_START; EXC_ADD_KEYRET(pSrc); EXC_DEBUG_END; return false; }
const CSString operator+ (const CSString &s1, const CSString &s2) { CSString rezult; rezult.append(s1); rezult.append(s2); return rezult; }
void CChat::DecorateName(CSString &sName, const CChatChanMember * pMember, bool fSystem) // static { ADDTOCALLSTACK("CChat::DecorateName"); CChatChannel * pChannel = nullptr; if (pMember) pChannel = pMember->GetChannel(); // 0 = yellow // 1 = purple // 2 = blue // 3 = purple // 4 = white // 5 = green int iResult = 0; if (!pMember || !pChannel) // Must be a system command if these are invalid { if (fSystem) iResult = 5; else iResult = 4; } else if (pChannel->IsModerator(pMember->GetChatName())) iResult = 1; else if (!pChannel->HasVoice(pMember->GetChatName())) iResult = 2; if (!pMember || !pChannel) sName.Format("%i%s", iResult, "SYSTEM"); else sName.Format("%i%s", iResult, static_cast<lpctstr>(pMember->GetChatName())); }
// Initialise les repertoires à partir de raw_material_generation.cfg void SetupDirectories() { CSString data; if ( ! CFile::fileExists( "raw_material_generation.cfg" ) ) { nlError( "raw_material_generation.cfg not found\n"); exit( 1 ); } data.readFromFile( "raw_material_generation.cfg" ); LEVEL_DESIGN_PATH = data.splitFrom( "LevelDesignPath = \"").splitTo( "\"" ); TRANSLATION_PATH = data.splitFrom( "TranslationPath = \"" ).splitTo( "\"" ); printf( "Level Design Path : %s\nTranslation Path : %s\n\n", LEVEL_DESIGN_PATH.c_str(), TRANSLATION_PATH.c_str() ); ITEM_MP_FAMILY_TYP = LEVEL_DESIGN_PATH + "leveldesign\\DFN\\game_elem\\_item\\item_mp_family.typ"; ITEM_MP_GROUPE_TYP = LEVEL_DESIGN_PATH + "leveldesign\\DFN\\game_elem\\_item\\item_mp_group.typ"; ITEM_MP_PARAM_DFN = LEVEL_DESIGN_PATH + "leveldesign\\DFN\\game_elem\\_item\\_item_mp_param.dfn"; MP_DIRECTORY = LEVEL_DESIGN_PATH + "leveldesign\\game_element\\sitem\\raw_material\\"; DEPOSIT_MPS = LEVEL_DESIGN_PATH + "leveldesign\\game_element\\deposit_system\\mps\\"; RAW_MATERIAL_ASSIGN = LEVEL_DESIGN_PATH + "leveldesign\\Game_elem\\Creature\\raw_material_assignment\\"; IC_FAMILIES_FORAGE_SOURCE = LEVEL_DESIGN_PATH + "leveldesign\\game_element\\forage_source\\_ic_families.forage_source"; WK_UXT = TRANSLATION_PATH + "work\\wk.uxt"; ITEM_WORDS_WK = TRANSLATION_PATH + "work\\item_words_wk.txt"; }
/** Replace false and true with _false_ and _true_ * this is used because excell force true and false in * uppercase when is save the file in cvs mode. * NB : this do the opposite jobs of the previous function */ void replaceTrueAndFalseTagToCsv(string &arg) { CSString str = arg; str.replace("false", "_false_"); str.replace("true", "_true_"); arg = str; }
double CIXml::getFloatProperty(xmlNodePtr node, const char *property, float defaultValue) { CSString s; bool b; b=getPropertyString(s,node,property); if (b==false) return defaultValue; return s.strip().atof(); }
/** Replace _false_ and _true_ with true and false * this is used because excell force true and false in * uppercase when is save the file in cvs mode. */ void replaceTrueAndFalseTagFromCsv(vector<string> &args) { for (uint i=0; i<args.size(); ++i) { CSString str = args[i]; str = str.replace("_false_", "false"); str = str.replace("_true_", "true"); args[i] = str; } }
int CSString::compare(const CSString &s1, const CSString &s2) { if (lexicographical_compare(s1._deqCustString->begin(), s1._deqCustString->end(), s2._deqCustString->begin(), s2._deqCustString->end())) return -1; if (s1.size() != s2.size()) return 1; for (int i = 0; i < s1.size(); i++) { if (s1[i] != s2[i]) return 1; } return 0; }
/* Some routines for dealing with script input */ void setOutputFile(const CSString &filename) { if (Outf!=NULL) fclose(Outf); Outf=fopen(filename.c_str(), "wt"); if (Outf == NULL) { fprintf(stderr, "Can't open output file '%s' ! aborting.", filename.c_str()); getchar(); exit(1); } fields.clear(); }
*=========================================================================*/ 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); }
// Génération d'un item spécial void GenerateSpecialItem( int numMP, const CSString& nomMP, const MPCraftStats& craftStats, const CSString& loc,CSString& itemData, int variation ) { CSString info, code, name; info = itemData.splitTo( "/", true ).toLower(); if ( loc.left(1) == "I" ) code = "ixx"; else if ( loc.left(1) == "D" ) code = "dxa"; else code = "cxx"; CreateSheet( numMP, nomMP, code, info.c_str()[0], info.c_str()[1]-'a', craftStats, true, variation ); name = toString( "m%04d%s%s%02d\t", numMP, code.c_str(), info.c_str(), variation ); name += itemData.splitTo( "/", true ); // singulier name += "\t"; name += itemData.splitTo( "/", true ); // article indéfini name += "\t"; name += itemData.splitTo( "/", true ); // article défini name += "\t"; name += itemData.splitTo( "/", true ); // pluriel name += "\t\t"; name += itemData.splitTo( "/", true ); // article pluriel itemNames.insert( name ); }
unsigned CSString::returnFirstPositionSubString(const CSString &str, int from, bool isCaseSensitive) const { unsigned position; int k = 0; for (int i = from; i < _deqCustString->size(); i++) { char curSymbol = str[k]; if (!isCaseSensitive) { curSymbol = tolower(str[k]); (*_deqCustString)[i] = tolower((*_deqCustString)[i]); } if (curSymbol != (*_deqCustString)[i]) continue; else { if (k != str._deqCustString->size() - 1) { k++; continue; } else { position = i - str.size() + 1; return position; } } } return -1; }
void CChat::GenerateChatName(CSString &sName, const CClient * pClient) // static { if (pClient == nullptr) return; // decide upon 'base' name lpctstr pszName = nullptr; if (pClient->GetChar() != nullptr) pszName = pClient->GetChar()->GetName(); else if (pClient->GetAccount() != nullptr) pszName = pClient->GetAccount()->GetName(); if (pszName == nullptr) return; // try the base name CSString sTempName(pszName); if (g_Accounts.Account_FindChat(sTempName.GetPtr()) != nullptr) { sTempName.Empty(); // append (n) to the name to make it unique for (uint attempts = 2; attempts <= g_Accounts.Account_GetCount(); attempts++) { sTempName.Format("%s (%u)", pszName, attempts); if (g_Accounts.Account_FindChat(static_cast<lpctstr>(sTempName)) == nullptr) break; sTempName.Empty(); } } // copy name to output sName.Copy(sTempName.GetPtr()); }
/*=========================================================================== * * Class CSrFile Method - bool ReadLine (Buffer); * * Inputs a line of text from a text file. * *=========================================================================*/ bool CSrFile::ReadLine (CSString& Buffer) { byte Value; size_t Result; //SSCHAR TempBuffer[256]; //SSCHAR* pResult; /* Set some initial string size */ Buffer.SetSizeEmpty(64); //Buffer.Empty(); while (!IsEOF()) { /* Attempt to input buffer */ Result = fread(&Value, 1, 1, m_pFile); if (Result != 1) { if (HasError()) return AddSrSystemError("Failed to read byte from file!"); return (true); } if (Value == '\n') { ++m_LineCount; return (true); } else { Buffer += Value; } } return (true); }
/*=========================================================================== * * Class char* CSrResourceFolder Method - const GetFullName (void); * *=========================================================================*/ const char* CSrResourceFolder::GetFullName (void) { static CSString s_Buffer; if (m_pParent != NULL) { s_Buffer = m_pParent->GetFullName(); } else { s_Buffer.Empty(); } if (!m_Name.IsEmpty()) { s_Buffer += GetName(); s_Buffer += "\\"; } return (s_Buffer); }
/*=========================================================================== * * 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 CSString::contains(const CSString &str, bool isCaseSensitive) const { bool isContain = false; if (_deqCustString->size() < str.size()) return isContain; if(returnFirstPositionSubString(str, isCaseSensitive) != -1) isContain = true; return isContain; }
int CIXml::getIntProperty(xmlNodePtr node, const char *property, int defaultValue) { CSString s; bool b; b=getPropertyString(s,node,property); if (b==false) return defaultValue; s=s.strip(); sint val=s.atoi(); if (val==0 && s!="0") { nlwarning("bad integer value: %s",s.c_str()); return defaultValue; } return val; }
// Génération du Primitive Necklace (objet particulier) void CreatePrimitiveNecklace() { CSString output; output = "<?xml version=\"1.0\"?>\n"; output += "<FORM Version=\"0.0\" State=\"modified\">\n"; output += " <PARENT Filename=\"_mc.sitem\"/>\n"; output += " <PARENT Filename=\"_m0696.sitem\"/>\n"; output += " <STRUCT>\n <STRUCT Name=\"mp\">\n"; output += " <ATOM Name=\"MpColor\" Value=\"Beige\"/>\n"; output += " <ATOM Name=\"MaxQuality\" Value=\"250\"/>\n"; output += " <ATOM Name=\"StatEnergy\" Value=\"0\"/>\n"; output += " </STRUCT>\n </STRUCT>\n <STRUCT/>\n <STRUCT/>\n"; output += " <STRUCT/>\n <STRUCT/>\n</FORM>\n"; output.writeToFile( toString( "%scommon\\m0696ixxcc01.sitem", MP_DIRECTORY.c_str() ) ); itemNames.insert( "m0696ixxcc01 Primitive Necklace a the Primitive Necklaces the" ); }
static void cbExecCommandResult(CMessage &msgin, const std::string &serviceName, TServiceId sid) { // treat the rely message sent back from a service whom we asked to execute a command NLMISC::InfoLog->displayNL("EXEC_COMMAND_RESULT' Received from: %3d: %s", sid.get() ,serviceName.c_str()); // retrieve the text from the input message CSString txt; msgin.serial(txt); // divide the text into lines because NeL doesn't like long texts CVectorSString lines; txt.splitLines(lines); // display the lines of text for (uint32 i=0;i<lines.size();++i) { NLMISC::InfoLog->displayNL("%s",lines[i].c_str()); } }
void RemoveExtensionString(CSString& Filename) { const char* pParse = Filename.c_str(); int Index = Filename.GetLength() - 1; while (Index >= 0) { if (pParse[Index] == '.') { Filename.Truncate(Index); return; } else if (pParse[Index] == '\\' || pParse[Index] == '/' || pParse[Index] == ':') { return; } --Index; } }
bool CCharScanScriptCommandRegistry::execute(CCharScanScriptFile& scriptFile,const CSString& commandLine,CCharScanScript* container) { // split the command line into its constituent parts CSString theCommand= commandLine.firstWordConst(); CSString theRawArgs= commandLine.tailFromFirstWord().strip(); CVectorSString theArgs; theRawArgs.splitByOneOfSeparators(" \t",theArgs,false,false,false,false,true); // try to locate and execute the given command for (uint32 i=0;i<_ScriptCommands.size();++i) { if (theCommand==_ScriptCommands[i]->getName()) { return _ScriptCommands[i]->execute(scriptFile,theArgs,theRawArgs,commandLine,container); } } // we failed to find the command so bomb nlwarning("Unknown script command '%s' in line: %s",theCommand.c_str(),commandLine.c_str()); return false; }
static bool needsQuotes(const CSString& src) { for (uint32 i=0;i<src.size();++i) { char c= src[i]; if (c<=32 || c=='.' || c==':' || c=='#' || c=='\"' || c=='=') { return true; } } return false; }
// Pour une MP se trouvant dans des déposits, génération de ses items void GenerateDepositItems( int numMP, const CSString& nomMP, const MPCraftStats& craftStats, const CSString& loc ) { CSString code; if ( loc.left(1) == "I" ) code = "ixx"; else if ( loc.left(1) == "D" ) code = "dxa"; else code = "cxx"; // pas de craft = items de mission if ( craftStats.Craft == "" ) { if ( loc != "G" ) CreateSheet( numMP, nomMP, code, 'c', 0, craftStats ); for ( int i=1; i<6; i++ ) { CreateSheet( numMP, nomMP, code, 'c', i, craftStats ); } } else { // 2 items dans common CreateSheet( numMP, nomMP, code, 'c', 1, craftStats ); CreateSheet( numMP, nomMP, code, 'c', 2, craftStats ); // 3 items par zone for ( int i=0; i<3; i++ ) { CreateSheet( numMP, nomMP, code, 'd', 3+i, craftStats ); CreateSheet( numMP, nomMP, code, 'f', 3+i, craftStats ); CreateSheet( numMP, nomMP, code, 'j', 3+i, craftStats ); CreateSheet( numMP, nomMP, code, 'l', 3+i, craftStats ); CreateSheet( numMP, nomMP, code, 'p', 3+i, craftStats ); } } }