From 917bbf6c4a51f0c491f0043c116cf194d0f8b1ab Mon Sep 17 00:00:00 2001 From: belal Date: Mon, 15 Mar 2010 18:18:05 -0400 Subject: [PATCH] Fixed findnameindexes.cpp and added a description of its purpose, it wasn't working because someone had commented out the body, which makes it hard to function. --- examples/findnameindexes.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/examples/findnameindexes.cpp b/examples/findnameindexes.cpp index 98b83370a..48ad255bd 100644 --- a/examples/findnameindexes.cpp +++ b/examples/findnameindexes.cpp @@ -1,4 +1,5 @@ -// Map cleaner. Removes all the snow, mud spills, blood and vomit from map tiles. +// Dwarf fortress names are a complicated beast, in objects they are displayed as indexes into the language vectors +// use this tool if you are trying to find what the indexes are for a displayed name, so you can then search for it in your object #include #include @@ -62,16 +63,28 @@ int main (void) cout << "\nSelect Name to search or q to Quit" << endl; getline (cin, input); while(input != "q"){ - /*for( map< string, vector >::iterator it = names.begin();it != names.end(); it++){ - for(uint32_t i = 0; i < it->second.size(); i++){ - uint32_t found = tolower(input).find(tolower(it->second[i])); + for( uint32_t i = 0; i < englishWords.size();i++){ + for( uint32_t j = 0;j < englishWords[i].size();j++){ + if(englishWords[i][j] != ""){ + uint32_t found = tolower(input).find(tolower(englishWords[i][j])); + if(found != string::npos){ + stringstream value; + value << setfill('0') << setw(8) << hex << endian_swap(j); + cout << englishWords[i][j] << " " << groupBy2(value.str()) << endl; + } + } + } + } + for( uint32_t i = 0; i < foreignWords.size();i++){ + for( uint32_t j = 0;j < foreignWords[i].size();j++){ + uint32_t found = tolower(input).find(tolower(foreignWords[i][j])); if(found != string::npos){ stringstream value; - value << setfill('0') << setw(8) << hex << endian_swap(i); - cout << it->first << " " << it->second[i] << " " << groupBy2(value.str()) << endl; + value << setfill('0') << setw(8) << hex << endian_swap(j); + cout << foreignWords[i][j] << " " << groupBy2(value.str()) << endl; } } - }*/ + } DF.Resume(); getline(cin,input); }